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-precaching.dev.js","sources":["../_version.js","../utils/precachePlugins.js","../addPlugins.js","../utils/cleanRedirect.js","../utils/createCacheKey.js","../utils/printCleanupDetails.js","../utils/printInstallDetails.js","../PrecacheController.js","../utils/getOrCreatePrecacheController.js","../utils/removeIgnoredSearchParams.js","../utils/generateURLVariations.js","../utils/getCacheKeyForURL.js","../utils/addFetchListener.js","../addRoute.js","../utils/deleteOutdatedCaches.js","../cleanupOutdatedCaches.js","../getCacheKeyForURL.js","../precache.js","../precacheAndRoute.js","../index.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:precaching:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2019 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';\nconst plugins = [];\nexport const precachePlugins = {\n /*\n * @return {Array}\n * @private\n */\n get() {\n return plugins;\n },\n /*\n * @param {Array} newPlugins\n * @private\n */\n add(newPlugins) {\n plugins.push(...newPlugins);\n },\n};\n","/*\n Copyright 2019 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 { precachePlugins } from './utils/precachePlugins.js';\nimport './_version.js';\n/**\n * Adds plugins to precaching.\n *\n * @param {Array<Object>} newPlugins\n *\n * @alias workbox.precaching.addPlugins\n */\nconst addPlugins = (newPlugins) => {\n precachePlugins.add(newPlugins);\n};\nexport { addPlugins };\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 * @param {Response} response\n * @return {Response}\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport async function cleanRedirect(response) {\n const clonedResponse = response.clone();\n // Not all browsers support the Response.body stream, so fall back\n // to reading the entire body into memory as a blob.\n const bodyPromise = 'body' in clonedResponse ?\n Promise.resolve(clonedResponse.body) :\n clonedResponse.blob();\n const body = await bodyPromise;\n // new Response() is happy when passed either a stream or a Blob.\n return new Response(body, {\n headers: clonedResponse.headers,\n status: clonedResponse.status,\n statusText: clonedResponse.statusText,\n });\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport '../_version.js';\n// Name of the search parameter used to store revision info.\nconst REVISION_SEARCH_PARAM = '__WB_REVISION__';\n/**\n * Converts a manifest entry into a versioned URL suitable for precaching.\n *\n * @param {Object|string} entry\n * @return {string} A URL with versioning info.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function createCacheKey(entry) {\n if (!entry) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', { entry });\n }\n // If a precache manifest entry is a string, it's assumed to be a versioned\n // URL, like '/app.abcd1234.js'. Return as-is.\n if (typeof entry === 'string') {\n const urlObject = new URL(entry, location.href);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n const { revision, url } = entry;\n if (!url) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', { entry });\n }\n // If there's just a URL and no revision, then it's also assumed to be a\n // versioned URL.\n if (!revision) {\n const urlObject = new URL(url, location.href);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n // Otherwise, construct a properly versioned URL using the custom Workbox\n // search parameter along with the revision info.\n const cacheKeyURL = new URL(url, location.href);\n const originalURL = new URL(url, location.href);\n cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision);\n return {\n cacheKey: cacheKeyURL.href,\n url: originalURL.href,\n };\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport '../_version.js';\n/**\n * @param {string} groupTitle\n * @param {Array<string>} deletedURLs\n *\n * @private\n */\nconst logGroup = (groupTitle, deletedURLs) => {\n logger.groupCollapsed(groupTitle);\n for (const url of deletedURLs) {\n logger.log(url);\n }\n logger.groupEnd();\n};\n/**\n * @param {Array<string>} deletedURLs\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function printCleanupDetails(deletedURLs) {\n const deletionCount = deletedURLs.length;\n if (deletionCount > 0) {\n logger.groupCollapsed(`During precaching cleanup, ` +\n `${deletionCount} cached ` +\n `request${deletionCount === 1 ? ' was' : 's were'} deleted.`);\n logGroup('Deleted Cache Requests', deletedURLs);\n logger.groupEnd();\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport '../_version.js';\n/**\n * @param {string} groupTitle\n * @param {Array<string>} urls\n *\n * @private\n */\nfunction _nestedGroup(groupTitle, urls) {\n if (urls.length === 0) {\n return;\n }\n logger.groupCollapsed(groupTitle);\n for (const url of urls) {\n logger.log(url);\n }\n logger.groupEnd();\n}\n/**\n * @param {Array<string>} urlsToPrecache\n * @param {Array<string>} urlsAlreadyPrecached\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function printInstallDetails(urlsToPrecache, urlsAlreadyPrecached) {\n const precachedCount = urlsToPrecache.length;\n const alreadyPrecachedCount = urlsAlreadyPrecached.length;\n if (precachedCount || alreadyPrecachedCount) {\n let message = `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`;\n if (alreadyPrecachedCount > 0) {\n message += ` ${alreadyPrecachedCount} ` +\n `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`;\n }\n logger.groupCollapsed(message);\n _nestedGroup(`View newly precached URLs.`, urlsToPrecache);\n _nestedGroup(`View previously precached URLs.`, urlsAlreadyPrecached);\n logger.groupEnd();\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { cacheWrapper } from 'workbox-core/_private/cacheWrapper.js';\nimport { fetchWrapper } from 'workbox-core/_private/fetchWrapper.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { cleanRedirect } from './utils/cleanRedirect.js';\nimport { createCacheKey } from './utils/createCacheKey.js';\nimport { printCleanupDetails } from './utils/printCleanupDetails.js';\nimport { printInstallDetails } from './utils/printInstallDetails.js';\nimport './_version.js';\n/**\n * Performs efficient precaching of assets.\n *\n * @memberof module:workbox-precaching\n */\nclass PrecacheController {\n /**\n * Create a new PrecacheController.\n *\n * @param {string} [cacheName] An optional name for the cache, to override\n * the default precache name.\n */\n constructor(cacheName) {\n this._cacheName = cacheNames.getPrecacheName(cacheName);\n this._urlsToCacheKeys = new Map();\n }\n /**\n * This method will add items to the precache list, removing duplicates\n * and ensuring the information is valid.\n *\n * @param {\n * Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>\n * } entries Array of entries to precache.\n */\n addToCacheList(entries) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(entries, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'addToCacheList',\n paramName: 'entries',\n });\n }\n for (const entry of entries) {\n const { cacheKey, url } = createCacheKey(entry);\n if (this._urlsToCacheKeys.has(url) &&\n this._urlsToCacheKeys.get(url) !== cacheKey) {\n throw new WorkboxError('add-to-cache-list-conflicting-entries', {\n firstEntry: this._urlsToCacheKeys.get(url),\n secondEntry: cacheKey,\n });\n }\n this._urlsToCacheKeys.set(url, cacheKey);\n }\n }\n /**\n * Precaches new and updated assets. Call this method from the service worker\n * install event.\n *\n * @param {Object} options\n * @param {Event} [options.event] The install event (if needed).\n * @param {Array<Object>} [options.plugins] Plugins to be used for fetching\n * and caching during install.\n * @return {Promise<workbox.precaching.InstallResult>}\n */\n async install({ event, plugins } = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (plugins) {\n assert.isArray(plugins, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'install',\n paramName: 'plugins',\n });\n }\n }\n const urlsToPrecache = [];\n const urlsAlreadyPrecached = [];\n const cache = await caches.open(this._cacheName);\n const alreadyCachedRequests = await cache.keys();\n const alreadyCachedURLs = new Set(alreadyCachedRequests.map((request) => request.url));\n for (const cacheKey of this._urlsToCacheKeys.values()) {\n if (alreadyCachedURLs.has(cacheKey)) {\n urlsAlreadyPrecached.push(cacheKey);\n }\n else {\n urlsToPrecache.push(cacheKey);\n }\n }\n const precacheRequests = urlsToPrecache.map((url) => {\n return this._addURLToCache({ event, plugins, url });\n });\n await Promise.all(precacheRequests);\n if (process.env.NODE_ENV !== 'production') {\n printInstallDetails(urlsToPrecache, urlsAlreadyPrecached);\n }\n return {\n updatedURLs: urlsToPrecache,\n notUpdatedURLs: urlsAlreadyPrecached,\n };\n }\n /**\n * Deletes assets that are no longer present in the current precache manifest.\n * Call this method from the service worker activate event.\n *\n * @return {Promise<workbox.precaching.CleanupResult>}\n */\n async activate() {\n const cache = await caches.open(this._cacheName);\n const currentlyCachedRequests = await cache.keys();\n const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());\n const deletedURLs = [];\n for (const request of currentlyCachedRequests) {\n if (!expectedCacheKeys.has(request.url)) {\n await cache.delete(request);\n deletedURLs.push(request.url);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n printCleanupDetails(deletedURLs);\n }\n return { deletedURLs };\n }\n /**\n * Requests the entry and saves it to the cache if the response is valid.\n * By default, any response with a status code of less than 400 (including\n * opaque responses) is considered valid.\n *\n * If you need to use custom criteria to determine what's valid and what\n * isn't, then pass in an item in `options.plugins` that implements the\n * `cacheWillUpdate()` lifecycle event.\n *\n * @private\n * @param {Object} options\n * @param {string} options.url The URL to fetch and cache.\n * @param {Event} [options.event] The install event (if passed).\n * @param {Array<Object>} [options.plugins] An array of plugins to apply to\n * fetch and caching.\n */\n async _addURLToCache({ url, event, plugins }) {\n const request = new Request(url, { credentials: 'same-origin' });\n let response = await fetchWrapper.fetch({\n event,\n plugins,\n request,\n });\n // Allow developers to override the default logic about what is and isn't\n // valid by passing in a plugin implementing cacheWillUpdate(), e.g.\n // a workbox.cacheableResponse.Plugin instance.\n let cacheWillUpdatePlugin;\n for (const plugin of (plugins || [])) {\n if ('cacheWillUpdate' in plugin) {\n cacheWillUpdatePlugin = plugin;\n }\n }\n const isValidResponse = cacheWillUpdatePlugin ?\n // Use a callback if provided. It returns a truthy value if valid.\n // NOTE: invoke the method on the plugin instance so the `this` context\n // is correct.\n cacheWillUpdatePlugin.cacheWillUpdate({ event, request, response }) :\n // Otherwise, default to considering any response status under 400 valid.\n // This includes, by default, considering opaque responses valid.\n response.status < 400;\n // Consider this a failure, leading to the `install` handler failing, if\n // we get back an invalid response.\n if (!isValidResponse) {\n throw new WorkboxError('bad-precaching-response', {\n url,\n status: response.status,\n });\n }\n if (response.redirected) {\n response = await cleanRedirect(response);\n }\n await cacheWrapper.put({\n event,\n plugins,\n request,\n response,\n cacheName: this._cacheName,\n matchOptions: {\n ignoreSearch: true,\n },\n });\n }\n /**\n * Returns a mapping of a precached URL to the corresponding cache key, taking\n * into account the revision information for the URL.\n *\n * @return {Map<string, string>} A URL to cache key mapping.\n */\n getURLsToCacheKeys() {\n return this._urlsToCacheKeys;\n }\n /**\n * Returns a list of all the URLs that have been precached by the current\n * service worker.\n *\n * @return {Array<string>} The precached URLs.\n */\n getCachedURLs() {\n return [...this._urlsToCacheKeys.keys()];\n }\n /**\n * Returns the cache key used for storing a given URL. If that URL is\n * unversioned, like `/index.html', then the cache key will be the original\n * URL with a search parameter appended to it.\n *\n * @param {string} url A URL whose cache key you want to look up.\n * @return {string} The versioned URL that corresponds to a cache key\n * for the original URL, or undefined if that URL isn't precached.\n */\n getCacheKeyForURL(url) {\n const urlObject = new URL(url, location.href);\n return this._urlsToCacheKeys.get(urlObject.href);\n }\n}\nexport { PrecacheController };\n","/*\n Copyright 2019 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 { PrecacheController } from '../PrecacheController.js';\nimport '../_version.js';\nlet precacheController;\n/**\n * @return {PrecacheController}\n * @private\n */\nexport const getOrCreatePrecacheController = () => {\n if (!precacheController) {\n precacheController = new PrecacheController();\n }\n return precacheController;\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * Removes any URL search parameters that should be ignored.\n *\n * @param {URL} urlObject The original URL.\n * @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against\n * each search parameter name. Matches mean that the search parameter should be\n * ignored.\n * @return {URL} The URL with any ignored search parameters removed.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching = []) {\n // Convert the iterable into an array at the start of the loop to make sure\n // deletion doesn't mess up iteration.\n for (const paramName of [...urlObject.searchParams.keys()]) {\n if (ignoreURLParametersMatching.some((regExp) => regExp.test(paramName))) {\n urlObject.searchParams.delete(paramName);\n }\n }\n return urlObject;\n}\n","/*\n Copyright 2019 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 { removeIgnoredSearchParams } from './removeIgnoredSearchParams.js';\nimport '../_version.js';\n/**\n * Generator function that yields possible variations on the original URL to\n * check, one at a time.\n *\n * @param {string} url\n * @param {Object} options\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function* generateURLVariations(url, { ignoreURLParametersMatching, directoryIndex, cleanURLs, urlManipulation, } = {}) {\n const urlObject = new URL(url, location.href);\n urlObject.hash = '';\n yield urlObject.href;\n const urlWithoutIgnoredParams = removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching);\n yield urlWithoutIgnoredParams.href;\n if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {\n const directoryURL = new URL(urlWithoutIgnoredParams.href);\n directoryURL.pathname += directoryIndex;\n yield directoryURL.href;\n }\n if (cleanURLs) {\n const cleanURL = new URL(urlWithoutIgnoredParams.href);\n cleanURL.pathname += '.html';\n yield cleanURL.href;\n }\n if (urlManipulation) {\n const additionalURLs = urlManipulation({ url: urlObject });\n for (const urlToAttempt of additionalURLs) {\n yield urlToAttempt.href;\n }\n }\n}\n","/*\n Copyright 2019 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 { getOrCreatePrecacheController } from './getOrCreatePrecacheController.js';\nimport { generateURLVariations } from './generateURLVariations.js';\nimport '../_version.js';\n/**\n * This function will take the request URL and manipulate it based on the\n * configuration options.\n *\n * @param {string} url\n * @param {Object} options\n * @return {string} Returns the URL in the cache that matches the request,\n * if possible.\n *\n * @private\n */\nexport const getCacheKeyForURL = (url, options) => {\n const precacheController = getOrCreatePrecacheController();\n const urlsToCacheKeys = precacheController.getURLsToCacheKeys();\n for (const possibleURL of generateURLVariations(url, options)) {\n const possibleCacheKey = urlsToCacheKeys.get(possibleURL);\n if (possibleCacheKey) {\n return possibleCacheKey;\n }\n }\n};\n","/*\n Copyright 2019 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 { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { getCacheKeyForURL } from './getCacheKeyForURL.js';\nimport '../_version.js';\n/**\n * Adds a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * NOTE: when called more than once this method will replace the previously set\n * configuration options. Calling it more than once is not recommended outside\n * of tests.\n *\n * @private\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n */\nexport const addFetchListener = ({ ignoreURLParametersMatching = [/^utm_/], directoryIndex = 'index.html', cleanURLs = true, urlManipulation, } = {}) => {\n const cacheName = cacheNames.getPrecacheName();\n addEventListener('fetch', (event) => {\n const precachedURL = getCacheKeyForURL(event.request.url, {\n cleanURLs,\n directoryIndex,\n ignoreURLParametersMatching,\n urlManipulation,\n });\n if (!precachedURL) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Precaching did not find a match for ` +\n getFriendlyURL(event.request.url));\n }\n return;\n }\n let responsePromise = caches.open(cacheName).then((cache) => {\n return cache.match(precachedURL);\n }).then((cachedResponse) => {\n if (cachedResponse) {\n return cachedResponse;\n }\n // Fall back to the network if we don't have a cached response\n // (perhaps due to manual cache cleanup).\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`The precached response for ` +\n `${getFriendlyURL(precachedURL)} in ${cacheName} was not found. ` +\n `Falling back to the network instead.`);\n }\n return fetch(precachedURL);\n });\n if (process.env.NODE_ENV !== 'production') {\n responsePromise = responsePromise.then((response) => {\n // Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Precaching is responding to: ` +\n getFriendlyURL(event.request.url));\n logger.log(`Serving the precached url: ${precachedURL}`);\n logger.groupCollapsed(`View request details here.`);\n logger.log(event.request);\n logger.groupEnd();\n logger.groupCollapsed(`View response details here.`);\n logger.log(response);\n logger.groupEnd();\n logger.groupEnd();\n return response;\n });\n }\n event.respondWith(responsePromise);\n });\n};\n","/*\n Copyright 2019 Google LLC\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 { addFetchListener } from './utils/addFetchListener.js';\nimport './_version.js';\nlet listenerAdded = false;\n/**\n * Add a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n *\n * @alias workbox.precaching.addRoute\n */\nexport const addRoute = (options) => {\n if (!listenerAdded) {\n addFetchListener(options);\n listenerAdded = true;\n }\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\nconst SUBSTRING_TO_FIND = '-precache-';\n/**\n * Cleans up incompatible precaches that were created by older versions of\n * Workbox, by a service worker registered under the current scope.\n *\n * This is meant to be called as part of the `activate` event.\n *\n * This should be safe to use as long as you don't include `substringToFind`\n * (defaulting to `-precache-`) in your non-precache cache names.\n *\n * @param {string} currentPrecacheName The cache name currently in use for\n * precaching. This cache won't be deleted.\n * @param {string} [substringToFind='-precache-'] Cache names which include this\n * substring will be deleted (excluding `currentPrecacheName`).\n * @return {Array<string>} A list of all the cache names that were deleted.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nconst deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => {\n const cacheNames = await caches.keys();\n const cacheNamesToDelete = cacheNames.filter((cacheName) => {\n return cacheName.includes(substringToFind) &&\n cacheName.includes(self.registration.scope) &&\n cacheName !== currentPrecacheName;\n });\n await Promise.all(cacheNamesToDelete.map((cacheName) => caches.delete(cacheName)));\n return cacheNamesToDelete;\n};\nexport { deleteOutdatedCaches };\n","/*\n Copyright 2019 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 { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { deleteOutdatedCaches } from './utils/deleteOutdatedCaches.js';\nimport './_version.js';\n/**\n * Adds an `activate` event listener which will clean up incompatible\n * precaches that were created by older versions of Workbox.\n *\n * @alias workbox.precaching.cleanupOutdatedCaches\n */\nexport const cleanupOutdatedCaches = () => {\n addEventListener('activate', (event) => {\n const cacheName = cacheNames.getPrecacheName();\n event.waitUntil(deleteOutdatedCaches(cacheName).then((cachesDeleted) => {\n if (process.env.NODE_ENV !== 'production') {\n if (cachesDeleted.length > 0) {\n logger.log(`The following out-of-date precaches were cleaned up ` +\n `automatically:`, cachesDeleted);\n }\n }\n }));\n });\n};\n","/*\n Copyright 2019 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 { getOrCreatePrecacheController } from './utils/getOrCreatePrecacheController.js';\nimport './_version.js';\n/**\n * Takes in a URL, and returns the corresponding URL that could be used to\n * lookup the entry in the precache.\n *\n * If a relative URL is provided, the location of the service worker file will\n * be used as the base.\n *\n * For precached entries without revision information, the cache key will be the\n * same as the original URL.\n *\n * For precached entries with revision information, the cache key will be the\n * original URL with the addition of a query parameter used for keeping track of\n * the revision info.\n *\n * @param {string} url The URL whose cache key to look up.\n * @return {string} The cache key that corresponds to that URL.\n *\n * @alias workbox.precaching.getCacheKeyForURL\n */\nexport const getCacheKeyForURL = (url) => {\n const precacheController = getOrCreatePrecacheController();\n return precacheController.getCacheKeyForURL(url);\n};\n","/*\n Copyright 2019 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 { getOrCreatePrecacheController } from './utils/getOrCreatePrecacheController.js';\nimport { precachePlugins } from './utils/precachePlugins.js';\nimport './_version.js';\nconst installListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n const plugins = precachePlugins.get();\n event.waitUntil(precacheController.install({ event, plugins })\n .catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Service worker installation failed. It will ` +\n `be retried automatically during the next navigation.`);\n }\n // Re-throw the error to ensure installation fails.\n throw error;\n }));\n};\nconst activateListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n event.waitUntil(precacheController.activate());\n};\n/**\n * Adds items to the precache list, removing any duplicates and\n * stores the files in the\n * [\"precache cache\"]{@link module:workbox-core.cacheNames} when the service\n * worker installs.\n *\n * This method can be called multiple times.\n *\n * Please note: This method **will not** serve any of the cached files for you.\n * It only precaches files. To respond to a network request you call\n * [addRoute()]{@link module:workbox-precaching.addRoute}.\n *\n * If you have a single array of files to precache, you can just call\n * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.\n *\n * @param {Array<Object|string>} [entries=[]] Array of entries to precache.\n *\n * @alias workbox.precaching.precache\n */\nexport const precache = (entries) => {\n const precacheController = getOrCreatePrecacheController();\n precacheController.addToCacheList(entries);\n if (entries.length > 0) {\n // NOTE: these listeners will only be added once (even if the `precache()`\n // method is called multiple times) because event listeners are implemented\n // as a set, where each listener must be unique.\n addEventListener('install', installListener);\n addEventListener('activate', activateListener);\n }\n};\n","/*\n Copyright 2019 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 { addRoute } from './addRoute.js';\nimport { precache } from './precache.js';\nimport './_version.js';\n/**\n * This method will add entries to the precache list and add a route to\n * respond to fetch events.\n *\n * This is a convenience method that will call\n * [precache()]{@link module:workbox-precaching.precache} and\n * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.\n *\n * @param {Array<Object|string>} entries Array of entries to precache.\n * @param {Object} options See\n * [addRoute() options]{@link module:workbox-precaching.addRoute}.\n *\n * @alias workbox.precaching.precacheAndRoute\n */\nexport const precacheAndRoute = (entries, options) => {\n precache(entries);\n addRoute(options);\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { addPlugins } from './addPlugins.js';\nimport { addRoute } from './addRoute.js';\nimport { cleanupOutdatedCaches } from './cleanupOutdatedCaches.js';\nimport { getCacheKeyForURL } from './getCacheKeyForURL.js';\nimport { precache } from './precache.js';\nimport { precacheAndRoute } from './precacheAndRoute.js';\nimport { PrecacheController } from './PrecacheController.js';\nimport './_version.js';\nif (process.env.NODE_ENV !== 'production') {\n assert.isSWEnv('workbox-precaching');\n}\n/**\n * Most consumers of this module will want to use the\n * [precacheAndRoute()]{@link workbox.precaching.precacheAndRoute}\n * method to add assets to the Cache and respond to network requests with these\n * cached assets.\n *\n * If you require finer grained control, you can use the\n * [PrecacheController]{@link workbox.precaching.PrecacheController}\n * to determine when performed.\n *\n * @namespace workbox.precaching\n */\nexport { addPlugins, addRoute, cleanupOutdatedCaches, getCacheKeyForURL, precache, precacheAndRoute, PrecacheController, };\n"],"names":["self","_","e","plugins","precachePlugins","get","add","newPlugins","push","addPlugins","cleanRedirect","response","clonedResponse","clone","bodyPromise","Promise","resolve","body","blob","Response","headers","status","statusText","REVISION_SEARCH_PARAM","createCacheKey","entry","WorkboxError","urlObject","URL","location","href","cacheKey","url","revision","cacheKeyURL","originalURL","searchParams","set","logGroup","groupTitle","deletedURLs","logger","groupCollapsed","log","groupEnd","printCleanupDetails","deletionCount","length","_nestedGroup","urls","printInstallDetails","urlsToPrecache","urlsAlreadyPrecached","precachedCount","alreadyPrecachedCount","message","PrecacheController","constructor","cacheName","_cacheName","cacheNames","getPrecacheName","_urlsToCacheKeys","Map","addToCacheList","entries","assert","isArray","moduleName","className","funcName","paramName","has","firstEntry","secondEntry","install","event","cache","caches","open","alreadyCachedRequests","keys","alreadyCachedURLs","Set","map","request","values","precacheRequests","_addURLToCache","all","updatedURLs","notUpdatedURLs","activate","currentlyCachedRequests","expectedCacheKeys","delete","Request","credentials","fetchWrapper","fetch","cacheWillUpdatePlugin","plugin","isValidResponse","cacheWillUpdate","redirected","cacheWrapper","put","matchOptions","ignoreSearch","getURLsToCacheKeys","getCachedURLs","getCacheKeyForURL","precacheController","getOrCreatePrecacheController","removeIgnoredSearchParams","ignoreURLParametersMatching","some","regExp","test","generateURLVariations","directoryIndex","cleanURLs","urlManipulation","hash","urlWithoutIgnoredParams","pathname","endsWith","directoryURL","cleanURL","additionalURLs","urlToAttempt","options","urlsToCacheKeys","possibleURL","possibleCacheKey","addFetchListener","addEventListener","precachedURL","debug","getFriendlyURL","responsePromise","then","match","cachedResponse","warn","respondWith","listenerAdded","addRoute","SUBSTRING_TO_FIND","deleteOutdatedCaches","currentPrecacheName","substringToFind","cacheNamesToDelete","filter","includes","registration","scope","cleanupOutdatedCaches","waitUntil","cachesDeleted","installListener","catch","error","activateListener","precache","precacheAndRoute","isSWEnv"],"mappings":";;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,kCAAD,CAAJ,IAA4CC,CAAC,EAA7C;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IACA,MAAMC,OAAO,GAAG,EAAhB;AACA,IAAO,MAAMC,eAAe,GAAG;IAC3B;;;;IAIAC,EAAAA,GAAG,GAAG;IACF,WAAOF,OAAP;IACH,GAP0B;;IAQ3B;;;;IAIAG,EAAAA,GAAG,CAACC,UAAD,EAAa;IACZJ,IAAAA,OAAO,CAACK,IAAR,CAAa,GAAGD,UAAhB;IACH;;IAd0B,CAAxB;;ICTP;;;;;;;AAOA,IAEA;;;;;;;;AAOA,UAAME,UAAU,GAAIF,UAAD,IAAgB;IAC/BH,EAAAA,eAAe,CAACE,GAAhB,CAAoBC,UAApB;IACH,CAFD;;IChBA;;;;;;;AAOA,IACA;;;;;;;;AAOA,IAAO,eAAeG,aAAf,CAA6BC,QAA7B,EAAuC;IAC1C,QAAMC,cAAc,GAAGD,QAAQ,CAAC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;;;AAmBA,UAAawE,QAAQ,GAAInG,OAAD,IAAa;IACjC,QAAM+C,kBAAkB,GAAGC,6BAA6B,EAAxD;IACAD,EAAAA,kBAAkB,CAAChD,cAAnB,CAAkCC,OAAlC;;IACA,MAAIA,OAAO,CAAClB,MAAR,GAAiB,CAArB,EAAwB;IACpB;IACA;IACA;IACAyF,IAAAA,gBAAgB,CAAC,SAAD,EAAYwB,eAAZ,CAAhB;IACAxB,IAAAA,gBAAgB,CAAC,UAAD,EAAa2B,gBAAb,CAAhB;IACH;IACJ,CAVM;;IC/CP;;;;;;;AAOA,IAGA;;;;;;;;;;;;;;;AAcA,UAAaE,gBAAgB,GAAG,CAACpG,OAAD,EAAUkE,OAAV,KAAsB;IAClDiC,EAAAA,QAAQ,CAACnG,OAAD,CAAR;IACAkF,EAAAA,QAAQ,CAAChB,OAAD,CAAR;IACH,CAHM;;ICxBP;;;;;;;AAOA;AASA,IAA2C;IACvCjE,EAAAA,gBAAM,CAACoG,OAAP,CAAe,oBAAf;IACH;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ this.workbox=this.workbox||{},this.workbox.precaching=function(t,e,n,s,c){"use strict";try{self["workbox:precaching:5.0.0-alpha.0"]&&_()}catch(t){}const o=[],i={get:()=>o,add(t){o.push(...t)}};const a="__WB_REVISION__";function r(t){if(!t)throw new c.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if("string"==typeof t){const e=new URL(t,location.href);return{cacheKey:e.href,url:e.href}}const{revision:e,url:n}=t;if(!n)throw new c.WorkboxError("add-to-cache-list-unexpected-type",{entry:t});if(!e){const t=new URL(n,location.href);return{cacheKey:t.href,url:t.href}}const s=new URL(n,location.href),o=new URL(n,location.href);return s.searchParams.set(a,e),{cacheKey:s.href,url:o.href}}class l{constructor(t){this.t=e.cacheNames.getPrecacheName(t),this.s=new Map}addToCacheList(t){for(const e of t){const{cacheKey:t,url:n}=r(e);if(this.s.has(n)&&this.s.get(n)!==t)throw new c.WorkboxError("add-to-cache-list-conflicting-entries",{firstEntry:this.s.get(n),secondEntry:t});this.s.set(n,t)}}async install({event:t,plugins:e}={}){const n=[],s=[],c=await caches.open(this.t),o=await c.keys(),i=new Set(o.map(t=>t.url));for(const t of this.s.values())i.has(t)?s.push(t):n.push(t);const a=n.map(n=>this.o({event:t,plugins:e,url:n}));return await Promise.all(a),{updatedURLs:n,notUpdatedURLs:s}}async activate(){const t=await caches.open(this.t),e=await t.keys(),n=new Set(this.s.values()),s=[];for(const c of e)n.has(c.url)||(await t.delete(c),s.push(c.url));return{deletedURLs:s}}async o({url:t,event:e,plugins:o}){const i=new Request(t,{credentials:"same-origin"});let a,r=await s.fetchWrapper.fetch({event:e,plugins:o,request:i});for(const t of o||[])"cacheWillUpdate"in t&&(a=t);if(!(a?a.cacheWillUpdate({event:e,request:i,response:r}):r.status<400))throw new c.WorkboxError("bad-precaching-response",{url:t,status:r.status});r.redirected&&(r=await async function(t){const e=t.clone(),n="body"in e?Promise.resolve(e.body):e.blob(),s=await n;return new Response(s,{headers:e.headers,status:e.status,statusText:e.statusText})}(r)),await n.cacheWrapper.put({event:e,plugins:o,request:i,response:r,cacheName:this.t,matchOptions:{ignoreSearch:!0}})}getURLsToCacheKeys(){return this.s}getCachedURLs(){return[...this.s.keys()]}getCacheKeyForURL(t){const e=new URL(t,location.href);return this.s.get(e.href)}}let h;const u=()=>(h||(h=new l),h);const d=(t,e)=>{const n=u().getURLsToCacheKeys();for(const s of function*(t,{ignoreURLParametersMatching:e,directoryIndex:n,cleanURLs:s,urlManipulation:c}={}){const o=new URL(t,location.href);o.hash="",yield o.href;const i=function(t,e=[]){for(const n of[...t.searchParams.keys()])e.some(t=>t.test(n))&&t.searchParams.delete(n);return t}(o,e);if(yield i.href,n&&i.pathname.endsWith("/")){const t=new URL(i.href);t.pathname+=n,yield t.href}if(s){const t=new URL(i.href);t.pathname+=".html",yield t.href}if(c){const t=c({url:o});for(const e of t)yield e.href}}(t,e)){const t=n.get(s);if(t)return t}};let w=!1;const f=t=>{w||((({ignoreURLParametersMatching:t=[/^utm_/],directoryIndex:n="index.html",cleanURLs:s=!0,urlManipulation:c}={})=>{const o=e.cacheNames.getPrecacheName();addEventListener("fetch",e=>{const i=d(e.request.url,{cleanURLs:s,directoryIndex:n,ignoreURLParametersMatching:t,urlManipulation:c});if(!i)return;let a=caches.open(o).then(t=>t.match(i)).then(t=>t||fetch(i));e.respondWith(a)})})(t),w=!0)},y=t=>{const e=u(),n=i.get();t.waitUntil(e.install({event:t,plugins:n}).catch(t=>{throw t}))},L=t=>{const e=u();t.waitUntil(e.activate())},p=t=>{u().addToCacheList(t),t.length>0&&(addEventListener("install",y),addEventListener("activate",L))};return t.PrecacheController=l,t.addPlugins=(t=>{i.add(t)}),t.addRoute=f,t.cleanupOutdatedCaches=(()=>{addEventListener("activate",t=>{const n=e.cacheNames.getPrecacheName();t.waitUntil((async(t,e="-precache-")=>{const n=(await caches.keys()).filter(n=>n.includes(e)&&n.includes(self.registration.scope)&&n!==t);return await Promise.all(n.map(t=>caches.delete(t))),n})(n).then(t=>{}))})}),t.getCacheKeyForURL=(t=>{return u().getCacheKeyForURL(t)}),t.precache=p,t.precacheAndRoute=((t,e)=>{p(t),f(e)}),t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
2
+ //# sourceMappingURL=workbox-precaching.prod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-precaching.prod.js","sources":["../_version.js","../utils/precachePlugins.js","../utils/createCacheKey.js","../PrecacheController.js","../utils/cleanRedirect.js","../utils/getOrCreatePrecacheController.js","../utils/getCacheKeyForURL.js","../utils/generateURLVariations.js","../utils/removeIgnoredSearchParams.js","../addRoute.js","../utils/addFetchListener.js","../precache.js","../addPlugins.js","../cleanupOutdatedCaches.js","../utils/deleteOutdatedCaches.js","../getCacheKeyForURL.js","../precacheAndRoute.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:precaching:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2019 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';\nconst plugins = [];\nexport const precachePlugins = {\n /*\n * @return {Array}\n * @private\n */\n get() {\n return plugins;\n },\n /*\n * @param {Array} newPlugins\n * @private\n */\n add(newPlugins) {\n plugins.push(...newPlugins);\n },\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport '../_version.js';\n// Name of the search parameter used to store revision info.\nconst REVISION_SEARCH_PARAM = '__WB_REVISION__';\n/**\n * Converts a manifest entry into a versioned URL suitable for precaching.\n *\n * @param {Object|string} entry\n * @return {string} A URL with versioning info.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function createCacheKey(entry) {\n if (!entry) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', { entry });\n }\n // If a precache manifest entry is a string, it's assumed to be a versioned\n // URL, like '/app.abcd1234.js'. Return as-is.\n if (typeof entry === 'string') {\n const urlObject = new URL(entry, location.href);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n const { revision, url } = entry;\n if (!url) {\n throw new WorkboxError('add-to-cache-list-unexpected-type', { entry });\n }\n // If there's just a URL and no revision, then it's also assumed to be a\n // versioned URL.\n if (!revision) {\n const urlObject = new URL(url, location.href);\n return {\n cacheKey: urlObject.href,\n url: urlObject.href,\n };\n }\n // Otherwise, construct a properly versioned URL using the custom Workbox\n // search parameter along with the revision info.\n const cacheKeyURL = new URL(url, location.href);\n const originalURL = new URL(url, location.href);\n cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision);\n return {\n cacheKey: cacheKeyURL.href,\n url: originalURL.href,\n };\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { cacheWrapper } from 'workbox-core/_private/cacheWrapper.js';\nimport { fetchWrapper } from 'workbox-core/_private/fetchWrapper.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { cleanRedirect } from './utils/cleanRedirect.js';\nimport { createCacheKey } from './utils/createCacheKey.js';\nimport { printCleanupDetails } from './utils/printCleanupDetails.js';\nimport { printInstallDetails } from './utils/printInstallDetails.js';\nimport './_version.js';\n/**\n * Performs efficient precaching of assets.\n *\n * @memberof module:workbox-precaching\n */\nclass PrecacheController {\n /**\n * Create a new PrecacheController.\n *\n * @param {string} [cacheName] An optional name for the cache, to override\n * the default precache name.\n */\n constructor(cacheName) {\n this._cacheName = cacheNames.getPrecacheName(cacheName);\n this._urlsToCacheKeys = new Map();\n }\n /**\n * This method will add items to the precache list, removing duplicates\n * and ensuring the information is valid.\n *\n * @param {\n * Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>\n * } entries Array of entries to precache.\n */\n addToCacheList(entries) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(entries, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'addToCacheList',\n paramName: 'entries',\n });\n }\n for (const entry of entries) {\n const { cacheKey, url } = createCacheKey(entry);\n if (this._urlsToCacheKeys.has(url) &&\n this._urlsToCacheKeys.get(url) !== cacheKey) {\n throw new WorkboxError('add-to-cache-list-conflicting-entries', {\n firstEntry: this._urlsToCacheKeys.get(url),\n secondEntry: cacheKey,\n });\n }\n this._urlsToCacheKeys.set(url, cacheKey);\n }\n }\n /**\n * Precaches new and updated assets. Call this method from the service worker\n * install event.\n *\n * @param {Object} options\n * @param {Event} [options.event] The install event (if needed).\n * @param {Array<Object>} [options.plugins] Plugins to be used for fetching\n * and caching during install.\n * @return {Promise<workbox.precaching.InstallResult>}\n */\n async install({ event, plugins } = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (plugins) {\n assert.isArray(plugins, {\n moduleName: 'workbox-precaching',\n className: 'PrecacheController',\n funcName: 'install',\n paramName: 'plugins',\n });\n }\n }\n const urlsToPrecache = [];\n const urlsAlreadyPrecached = [];\n const cache = await caches.open(this._cacheName);\n const alreadyCachedRequests = await cache.keys();\n const alreadyCachedURLs = new Set(alreadyCachedRequests.map((request) => request.url));\n for (const cacheKey of this._urlsToCacheKeys.values()) {\n if (alreadyCachedURLs.has(cacheKey)) {\n urlsAlreadyPrecached.push(cacheKey);\n }\n else {\n urlsToPrecache.push(cacheKey);\n }\n }\n const precacheRequests = urlsToPrecache.map((url) => {\n return this._addURLToCache({ event, plugins, url });\n });\n await Promise.all(precacheRequests);\n if (process.env.NODE_ENV !== 'production') {\n printInstallDetails(urlsToPrecache, urlsAlreadyPrecached);\n }\n return {\n updatedURLs: urlsToPrecache,\n notUpdatedURLs: urlsAlreadyPrecached,\n };\n }\n /**\n * Deletes assets that are no longer present in the current precache manifest.\n * Call this method from the service worker activate event.\n *\n * @return {Promise<workbox.precaching.CleanupResult>}\n */\n async activate() {\n const cache = await caches.open(this._cacheName);\n const currentlyCachedRequests = await cache.keys();\n const expectedCacheKeys = new Set(this._urlsToCacheKeys.values());\n const deletedURLs = [];\n for (const request of currentlyCachedRequests) {\n if (!expectedCacheKeys.has(request.url)) {\n await cache.delete(request);\n deletedURLs.push(request.url);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n printCleanupDetails(deletedURLs);\n }\n return { deletedURLs };\n }\n /**\n * Requests the entry and saves it to the cache if the response is valid.\n * By default, any response with a status code of less than 400 (including\n * opaque responses) is considered valid.\n *\n * If you need to use custom criteria to determine what's valid and what\n * isn't, then pass in an item in `options.plugins` that implements the\n * `cacheWillUpdate()` lifecycle event.\n *\n * @private\n * @param {Object} options\n * @param {string} options.url The URL to fetch and cache.\n * @param {Event} [options.event] The install event (if passed).\n * @param {Array<Object>} [options.plugins] An array of plugins to apply to\n * fetch and caching.\n */\n async _addURLToCache({ url, event, plugins }) {\n const request = new Request(url, { credentials: 'same-origin' });\n let response = await fetchWrapper.fetch({\n event,\n plugins,\n request,\n });\n // Allow developers to override the default logic about what is and isn't\n // valid by passing in a plugin implementing cacheWillUpdate(), e.g.\n // a workbox.cacheableResponse.Plugin instance.\n let cacheWillUpdatePlugin;\n for (const plugin of (plugins || [])) {\n if ('cacheWillUpdate' in plugin) {\n cacheWillUpdatePlugin = plugin;\n }\n }\n const isValidResponse = cacheWillUpdatePlugin ?\n // Use a callback if provided. It returns a truthy value if valid.\n // NOTE: invoke the method on the plugin instance so the `this` context\n // is correct.\n cacheWillUpdatePlugin.cacheWillUpdate({ event, request, response }) :\n // Otherwise, default to considering any response status under 400 valid.\n // This includes, by default, considering opaque responses valid.\n response.status < 400;\n // Consider this a failure, leading to the `install` handler failing, if\n // we get back an invalid response.\n if (!isValidResponse) {\n throw new WorkboxError('bad-precaching-response', {\n url,\n status: response.status,\n });\n }\n if (response.redirected) {\n response = await cleanRedirect(response);\n }\n await cacheWrapper.put({\n event,\n plugins,\n request,\n response,\n cacheName: this._cacheName,\n matchOptions: {\n ignoreSearch: true,\n },\n });\n }\n /**\n * Returns a mapping of a precached URL to the corresponding cache key, taking\n * into account the revision information for the URL.\n *\n * @return {Map<string, string>} A URL to cache key mapping.\n */\n getURLsToCacheKeys() {\n return this._urlsToCacheKeys;\n }\n /**\n * Returns a list of all the URLs that have been precached by the current\n * service worker.\n *\n * @return {Array<string>} The precached URLs.\n */\n getCachedURLs() {\n return [...this._urlsToCacheKeys.keys()];\n }\n /**\n * Returns the cache key used for storing a given URL. If that URL is\n * unversioned, like `/index.html', then the cache key will be the original\n * URL with a search parameter appended to it.\n *\n * @param {string} url A URL whose cache key you want to look up.\n * @return {string} The versioned URL that corresponds to a cache key\n * for the original URL, or undefined if that URL isn't precached.\n */\n getCacheKeyForURL(url) {\n const urlObject = new URL(url, location.href);\n return this._urlsToCacheKeys.get(urlObject.href);\n }\n}\nexport { PrecacheController };\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 * @param {Response} response\n * @return {Response}\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport async function cleanRedirect(response) {\n const clonedResponse = response.clone();\n // Not all browsers support the Response.body stream, so fall back\n // to reading the entire body into memory as a blob.\n const bodyPromise = 'body' in clonedResponse ?\n Promise.resolve(clonedResponse.body) :\n clonedResponse.blob();\n const body = await bodyPromise;\n // new Response() is happy when passed either a stream or a Blob.\n return new Response(body, {\n headers: clonedResponse.headers,\n status: clonedResponse.status,\n statusText: clonedResponse.statusText,\n });\n}\n","/*\n Copyright 2019 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 { PrecacheController } from '../PrecacheController.js';\nimport '../_version.js';\nlet precacheController;\n/**\n * @return {PrecacheController}\n * @private\n */\nexport const getOrCreatePrecacheController = () => {\n if (!precacheController) {\n precacheController = new PrecacheController();\n }\n return precacheController;\n};\n","/*\n Copyright 2019 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 { getOrCreatePrecacheController } from './getOrCreatePrecacheController.js';\nimport { generateURLVariations } from './generateURLVariations.js';\nimport '../_version.js';\n/**\n * This function will take the request URL and manipulate it based on the\n * configuration options.\n *\n * @param {string} url\n * @param {Object} options\n * @return {string} Returns the URL in the cache that matches the request,\n * if possible.\n *\n * @private\n */\nexport const getCacheKeyForURL = (url, options) => {\n const precacheController = getOrCreatePrecacheController();\n const urlsToCacheKeys = precacheController.getURLsToCacheKeys();\n for (const possibleURL of generateURLVariations(url, options)) {\n const possibleCacheKey = urlsToCacheKeys.get(possibleURL);\n if (possibleCacheKey) {\n return possibleCacheKey;\n }\n }\n};\n","/*\n Copyright 2019 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 { removeIgnoredSearchParams } from './removeIgnoredSearchParams.js';\nimport '../_version.js';\n/**\n * Generator function that yields possible variations on the original URL to\n * check, one at a time.\n *\n * @param {string} url\n * @param {Object} options\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function* generateURLVariations(url, { ignoreURLParametersMatching, directoryIndex, cleanURLs, urlManipulation, } = {}) {\n const urlObject = new URL(url, location.href);\n urlObject.hash = '';\n yield urlObject.href;\n const urlWithoutIgnoredParams = removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching);\n yield urlWithoutIgnoredParams.href;\n if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) {\n const directoryURL = new URL(urlWithoutIgnoredParams.href);\n directoryURL.pathname += directoryIndex;\n yield directoryURL.href;\n }\n if (cleanURLs) {\n const cleanURL = new URL(urlWithoutIgnoredParams.href);\n cleanURL.pathname += '.html';\n yield cleanURL.href;\n }\n if (urlManipulation) {\n const additionalURLs = urlManipulation({ url: urlObject });\n for (const urlToAttempt of additionalURLs) {\n yield urlToAttempt.href;\n }\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * Removes any URL search parameters that should be ignored.\n *\n * @param {URL} urlObject The original URL.\n * @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against\n * each search parameter name. Matches mean that the search parameter should be\n * ignored.\n * @return {URL} The URL with any ignored search parameters removed.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nexport function removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching = []) {\n // Convert the iterable into an array at the start of the loop to make sure\n // deletion doesn't mess up iteration.\n for (const paramName of [...urlObject.searchParams.keys()]) {\n if (ignoreURLParametersMatching.some((regExp) => regExp.test(paramName))) {\n urlObject.searchParams.delete(paramName);\n }\n }\n return urlObject;\n}\n","/*\n Copyright 2019 Google LLC\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 { addFetchListener } from './utils/addFetchListener.js';\nimport './_version.js';\nlet listenerAdded = false;\n/**\n * Add a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n *\n * @alias workbox.precaching.addRoute\n */\nexport const addRoute = (options) => {\n if (!listenerAdded) {\n addFetchListener(options);\n listenerAdded = true;\n }\n};\n","/*\n Copyright 2019 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 { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { getCacheKeyForURL } from './getCacheKeyForURL.js';\nimport '../_version.js';\n/**\n * Adds a `fetch` listener to the service worker that will\n * respond to\n * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests}\n * with precached assets.\n *\n * Requests for assets that aren't precached, the `FetchEvent` will not be\n * responded to, allowing the event to fall through to other `fetch` event\n * listeners.\n *\n * NOTE: when called more than once this method will replace the previously set\n * configuration options. Calling it more than once is not recommended outside\n * of tests.\n *\n * @private\n * @param {Object} options\n * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will\n * check cache entries for a URLs ending with '/' to see if there is a hit when\n * appending the `directoryIndex` value.\n * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/]] An\n * array of regex's to remove search params when looking for a cache match.\n * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will\n * check the cache for the URL with a `.html` added to the end of the end.\n * @param {workbox.precaching~urlManipulation} [options.urlManipulation]\n * This is a function that should take a URL and return an array of\n * alternative URL's that should be checked for precache matches.\n */\nexport const addFetchListener = ({ ignoreURLParametersMatching = [/^utm_/], directoryIndex = 'index.html', cleanURLs = true, urlManipulation, } = {}) => {\n const cacheName = cacheNames.getPrecacheName();\n addEventListener('fetch', (event) => {\n const precachedURL = getCacheKeyForURL(event.request.url, {\n cleanURLs,\n directoryIndex,\n ignoreURLParametersMatching,\n urlManipulation,\n });\n if (!precachedURL) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Precaching did not find a match for ` +\n getFriendlyURL(event.request.url));\n }\n return;\n }\n let responsePromise = caches.open(cacheName).then((cache) => {\n return cache.match(precachedURL);\n }).then((cachedResponse) => {\n if (cachedResponse) {\n return cachedResponse;\n }\n // Fall back to the network if we don't have a cached response\n // (perhaps due to manual cache cleanup).\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`The precached response for ` +\n `${getFriendlyURL(precachedURL)} in ${cacheName} was not found. ` +\n `Falling back to the network instead.`);\n }\n return fetch(precachedURL);\n });\n if (process.env.NODE_ENV !== 'production') {\n responsePromise = responsePromise.then((response) => {\n // Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Precaching is responding to: ` +\n getFriendlyURL(event.request.url));\n logger.log(`Serving the precached url: ${precachedURL}`);\n logger.groupCollapsed(`View request details here.`);\n logger.log(event.request);\n logger.groupEnd();\n logger.groupCollapsed(`View response details here.`);\n logger.log(response);\n logger.groupEnd();\n logger.groupEnd();\n return response;\n });\n }\n event.respondWith(responsePromise);\n });\n};\n","/*\n Copyright 2019 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 { getOrCreatePrecacheController } from './utils/getOrCreatePrecacheController.js';\nimport { precachePlugins } from './utils/precachePlugins.js';\nimport './_version.js';\nconst installListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n const plugins = precachePlugins.get();\n event.waitUntil(precacheController.install({ event, plugins })\n .catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(`Service worker installation failed. It will ` +\n `be retried automatically during the next navigation.`);\n }\n // Re-throw the error to ensure installation fails.\n throw error;\n }));\n};\nconst activateListener = (event) => {\n const precacheController = getOrCreatePrecacheController();\n event.waitUntil(precacheController.activate());\n};\n/**\n * Adds items to the precache list, removing any duplicates and\n * stores the files in the\n * [\"precache cache\"]{@link module:workbox-core.cacheNames} when the service\n * worker installs.\n *\n * This method can be called multiple times.\n *\n * Please note: This method **will not** serve any of the cached files for you.\n * It only precaches files. To respond to a network request you call\n * [addRoute()]{@link module:workbox-precaching.addRoute}.\n *\n * If you have a single array of files to precache, you can just call\n * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}.\n *\n * @param {Array<Object|string>} [entries=[]] Array of entries to precache.\n *\n * @alias workbox.precaching.precache\n */\nexport const precache = (entries) => {\n const precacheController = getOrCreatePrecacheController();\n precacheController.addToCacheList(entries);\n if (entries.length > 0) {\n // NOTE: these listeners will only be added once (even if the `precache()`\n // method is called multiple times) because event listeners are implemented\n // as a set, where each listener must be unique.\n addEventListener('install', installListener);\n addEventListener('activate', activateListener);\n }\n};\n","/*\n Copyright 2019 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 { precachePlugins } from './utils/precachePlugins.js';\nimport './_version.js';\n/**\n * Adds plugins to precaching.\n *\n * @param {Array<Object>} newPlugins\n *\n * @alias workbox.precaching.addPlugins\n */\nconst addPlugins = (newPlugins) => {\n precachePlugins.add(newPlugins);\n};\nexport { addPlugins };\n","/*\n Copyright 2019 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 { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { deleteOutdatedCaches } from './utils/deleteOutdatedCaches.js';\nimport './_version.js';\n/**\n * Adds an `activate` event listener which will clean up incompatible\n * precaches that were created by older versions of Workbox.\n *\n * @alias workbox.precaching.cleanupOutdatedCaches\n */\nexport const cleanupOutdatedCaches = () => {\n addEventListener('activate', (event) => {\n const cacheName = cacheNames.getPrecacheName();\n event.waitUntil(deleteOutdatedCaches(cacheName).then((cachesDeleted) => {\n if (process.env.NODE_ENV !== 'production') {\n if (cachesDeleted.length > 0) {\n logger.log(`The following out-of-date precaches were cleaned up ` +\n `automatically:`, cachesDeleted);\n }\n }\n }));\n });\n};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\nconst SUBSTRING_TO_FIND = '-precache-';\n/**\n * Cleans up incompatible precaches that were created by older versions of\n * Workbox, by a service worker registered under the current scope.\n *\n * This is meant to be called as part of the `activate` event.\n *\n * This should be safe to use as long as you don't include `substringToFind`\n * (defaulting to `-precache-`) in your non-precache cache names.\n *\n * @param {string} currentPrecacheName The cache name currently in use for\n * precaching. This cache won't be deleted.\n * @param {string} [substringToFind='-precache-'] Cache names which include this\n * substring will be deleted (excluding `currentPrecacheName`).\n * @return {Array<string>} A list of all the cache names that were deleted.\n *\n * @private\n * @memberof module:workbox-precaching\n */\nconst deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => {\n const cacheNames = await caches.keys();\n const cacheNamesToDelete = cacheNames.filter((cacheName) => {\n return cacheName.includes(substringToFind) &&\n cacheName.includes(self.registration.scope) &&\n cacheName !== currentPrecacheName;\n });\n await Promise.all(cacheNamesToDelete.map((cacheName) => caches.delete(cacheName)));\n return cacheNamesToDelete;\n};\nexport { deleteOutdatedCaches };\n","/*\n Copyright 2019 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 { getOrCreatePrecacheController } from './utils/getOrCreatePrecacheController.js';\nimport './_version.js';\n/**\n * Takes in a URL, and returns the corresponding URL that could be used to\n * lookup the entry in the precache.\n *\n * If a relative URL is provided, the location of the service worker file will\n * be used as the base.\n *\n * For precached entries without revision information, the cache key will be the\n * same as the original URL.\n *\n * For precached entries with revision information, the cache key will be the\n * original URL with the addition of a query parameter used for keeping track of\n * the revision info.\n *\n * @param {string} url The URL whose cache key to look up.\n * @return {string} The cache key that corresponds to that URL.\n *\n * @alias workbox.precaching.getCacheKeyForURL\n */\nexport const getCacheKeyForURL = (url) => {\n const precacheController = getOrCreatePrecacheController();\n return precacheController.getCacheKeyForURL(url);\n};\n","/*\n Copyright 2019 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 { addRoute } from './addRoute.js';\nimport { precache } from './precache.js';\nimport './_version.js';\n/**\n * This method will add entries to the precache list and add a route to\n * respond to fetch events.\n *\n * This is a convenience method that will call\n * [precache()]{@link module:workbox-precaching.precache} and\n * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call.\n *\n * @param {Array<Object|string>} entries Array of entries to precache.\n * @param {Object} options See\n * [addRoute() options]{@link module:workbox-precaching.addRoute}.\n *\n * @alias workbox.precaching.precacheAndRoute\n */\nexport const precacheAndRoute = (entries, options) => {\n precache(entries);\n addRoute(options);\n};\n"],"names":["self","_","e","plugins","precachePlugins","get","add","newPlugins","push","REVISION_SEARCH_PARAM","createCacheKey","entry","WorkboxError","urlObject","URL","location","href","cacheKey","url","revision","cacheKeyURL","originalURL","searchParams","set","PrecacheController","constructor","cacheName","_cacheName","cacheNames","getPrecacheName","_urlsToCacheKeys","Map","addToCacheList","entries","this","has","firstEntry","secondEntry","event","urlsToPrecache","urlsAlreadyPrecached","cache","caches","open","alreadyCachedRequests","keys","alreadyCachedURLs","Set","map","request","values","precacheRequests","_addURLToCache","Promise","all","updatedURLs","notUpdatedURLs","currentlyCachedRequests","expectedCacheKeys","deletedURLs","delete","Request","credentials","cacheWillUpdatePlugin","response","fetchWrapper","fetch","plugin","cacheWillUpdate","status","redirected","async","clonedResponse","clone","bodyPromise","resolve","body","blob","Response","headers","statusText","cleanRedirect","cacheWrapper","put","matchOptions","ignoreSearch","getURLsToCacheKeys","getCachedURLs","getCacheKeyForURL","precacheController","getOrCreatePrecacheController","options","urlsToCacheKeys","possibleURL","ignoreURLParametersMatching","directoryIndex","cleanURLs","urlManipulation","hash","urlWithoutIgnoredParams","paramName","some","regExp","test","removeIgnoredSearchParams","pathname","endsWith","directoryURL","cleanURL","additionalURLs","urlToAttempt","generateURLVariations","possibleCacheKey","listenerAdded","addRoute","addEventListener","precachedURL","responsePromise","then","match","cachedResponse","respondWith","addFetchListener","installListener","waitUntil","install","catch","error","activateListener","activate","precache","length","currentPrecacheName","substringToFind","cacheNamesToDelete","filter","includes","registration","scope","deleteOutdatedCaches","cachesDeleted"],"mappings":"uFACA,IACIA,KAAK,qCAAuCC,IAEhD,MAAOC,ICIP,MAAMC,EAAU,GACHC,EAAkB,CAK3BC,IAAG,IACQF,EAMXG,IAAIC,GACAJ,EAAQK,QAAQD,KCZxB,MAAME,EAAwB,kBAUvB,SAASC,EAAeC,OACtBA,QACK,IAAIC,eAAa,oCAAqC,CAAED,MAAAA,OAI7C,iBAAVA,EAAoB,OACrBE,EAAY,IAAIC,IAAIH,EAAOI,SAASC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AAkB3E,OAAOC,KAAKjB,GAAW4F,KAAM7E,GACxCA,EAAM8E,MAAMH,IACpBE,KAAME,GACDA,GAUGtD,MAAMkD,IAmBjB9E,EAAMmF,YAAYJ,MDpDlBK,CAAiB/B,GACjBsB,GAAgB,IEzBlBU,EAAmBrF,UACfmD,EAAqBC,IACrBvF,EAAUC,EAAgBC,MAChCiC,EAAMsF,UAAUnC,EAAmBoC,QAAQ,CAAEvF,MAAAA,EAAOnC,QAAAA,IAC/C2H,MAAOC,UAMFA,MAGRC,EAAoB1F,UAChBmD,EAAqBC,IAC3BpD,EAAMsF,UAAUnC,EAAmBwC,aAqB1BC,EAAYjG,IACMyD,IACR1D,eAAeC,GAC9BA,EAAQkG,OAAS,IAIjBhB,iBAAiB,UAAWQ,GAC5BR,iBAAiB,WAAYa,gDCvCjBzH,CAAAA,IAChBH,EAAgBE,IAAIC,0CCAa,MACjC4G,iBAAiB,WAAa7E,UACpBZ,EAAYE,aAAWC,kBAC7BS,EAAMsF,UCOerD,OAAO6D,EAAqBC,EAnB/B,sBAqBhBC,SADmB5F,OAAOG,QACM0F,OAAQ7G,GACnCA,EAAU8G,SAASH,IACtB3G,EAAU8G,SAASxI,KAAKyI,aAAaC,QACrChH,IAAc0G,gBAEhB/E,QAAQC,IAAIgF,EAAmBtF,IAAKtB,GAAcgB,OAAOkB,OAAOlC,KAC/D4G,GDfaK,CAAqBjH,GAAW4F,KAAMsB,gCEQ5B1H,CAAAA,WACHwE,IACDF,kBAAkBtE,qCCNhB,EAACe,EAAS0D,KACtCuC,EAASjG,GACTiF,EAASvB"}
@@ -0,0 +1,263 @@
1
+ this.workbox = this.workbox || {};
2
+ this.workbox.rangeRequests = (function (exports, WorkboxError_js, assert_js, logger_js) {
3
+ 'use strict';
4
+
5
+ // @ts-ignore
6
+ try {
7
+ self['workbox:range-requests: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
+ * @param {Blob} blob A source blob.
19
+ * @param {number} [start] The offset to use as the start of the
20
+ * slice.
21
+ * @param {number} [end] The offset to use as the end of the slice.
22
+ * @return {Object} An object with `start` and `end` properties, reflecting
23
+ * the effective boundaries to use given the size of the blob.
24
+ *
25
+ * @private
26
+ */
27
+
28
+ function calculateEffectiveBoundaries(blob, start, end) {
29
+ {
30
+ assert_js.assert.isInstance(blob, Blob, {
31
+ moduleName: 'workbox-range-requests',
32
+ funcName: 'calculateEffectiveBoundaries',
33
+ paramName: 'blob'
34
+ });
35
+ }
36
+
37
+ const blobSize = blob.size;
38
+
39
+ if (end && end > blobSize || start && start < 0) {
40
+ throw new WorkboxError_js.WorkboxError('range-not-satisfiable', {
41
+ size: blobSize,
42
+ end,
43
+ start
44
+ });
45
+ }
46
+
47
+ let effectiveStart;
48
+ let effectiveEnd;
49
+
50
+ if (start && end) {
51
+ effectiveStart = start; // Range values are inclusive, so add 1 to the value.
52
+
53
+ effectiveEnd = end + 1;
54
+ } else if (start && !end) {
55
+ effectiveStart = start;
56
+ effectiveEnd = blobSize;
57
+ } else if (end && !start) {
58
+ effectiveStart = blobSize - end;
59
+ effectiveEnd = blobSize;
60
+ }
61
+
62
+ return {
63
+ start: effectiveStart,
64
+ end: effectiveEnd
65
+ };
66
+ }
67
+
68
+ /*
69
+ Copyright 2018 Google LLC
70
+
71
+ Use of this source code is governed by an MIT-style
72
+ license that can be found in the LICENSE file or at
73
+ https://opensource.org/licenses/MIT.
74
+ */
75
+ /**
76
+ * @param {string} rangeHeader A Range: header value.
77
+ * @return {Object} An object with `start` and `end` properties, reflecting
78
+ * the parsed value of the Range: header. If either the `start` or `end` are
79
+ * omitted, then `null` will be returned.
80
+ *
81
+ * @private
82
+ */
83
+
84
+ function parseRangeHeader(rangeHeader) {
85
+ {
86
+ assert_js.assert.isType(rangeHeader, 'string', {
87
+ moduleName: 'workbox-range-requests',
88
+ funcName: 'parseRangeHeader',
89
+ paramName: 'rangeHeader'
90
+ });
91
+ }
92
+
93
+ const normalizedRangeHeader = rangeHeader.trim().toLowerCase();
94
+
95
+ if (!normalizedRangeHeader.startsWith('bytes=')) {
96
+ throw new WorkboxError_js.WorkboxError('unit-must-be-bytes', {
97
+ normalizedRangeHeader
98
+ });
99
+ } // Specifying multiple ranges separate by commas is valid syntax, but this
100
+ // library only attempts to handle a single, contiguous sequence of bytes.
101
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax
102
+
103
+
104
+ if (normalizedRangeHeader.includes(',')) {
105
+ throw new WorkboxError_js.WorkboxError('single-range-only', {
106
+ normalizedRangeHeader
107
+ });
108
+ }
109
+
110
+ const rangeParts = /(\d*)-(\d*)/.exec(normalizedRangeHeader); // We need either at least one of the start or end values.
111
+
112
+ if (!rangeParts || !(rangeParts[1] || rangeParts[2])) {
113
+ throw new WorkboxError_js.WorkboxError('invalid-range-values', {
114
+ normalizedRangeHeader
115
+ });
116
+ }
117
+
118
+ return {
119
+ start: rangeParts[1] === '' ? undefined : Number(rangeParts[1]),
120
+ end: rangeParts[2] === '' ? undefined : Number(rangeParts[2])
121
+ };
122
+ }
123
+
124
+ /*
125
+ Copyright 2018 Google LLC
126
+
127
+ Use of this source code is governed by an MIT-style
128
+ license that can be found in the LICENSE file or at
129
+ https://opensource.org/licenses/MIT.
130
+ */
131
+ /**
132
+ * Given a `Request` and `Response` objects as input, this will return a
133
+ * promise for a new `Response`.
134
+ *
135
+ * If the original `Response` already contains partial content (i.e. it has
136
+ * a status of 206), then this assumes it already fulfills the `Range:`
137
+ * requirements, and will return it as-is.
138
+ *
139
+ * @param {Request} request A request, which should contain a Range:
140
+ * header.
141
+ * @param {Response} originalResponse A response.
142
+ * @return {Promise<Response>} Either a `206 Partial Content` response, with
143
+ * the response body set to the slice of content specified by the request's
144
+ * `Range:` header, or a `416 Range Not Satisfiable` response if the
145
+ * conditions of the `Range:` header can't be met.
146
+ *
147
+ * @memberof workbox.rangeRequests
148
+ */
149
+
150
+ async function createPartialResponse(request, originalResponse) {
151
+ try {
152
+ if ("dev" !== 'production') {
153
+ assert_js.assert.isInstance(request, Request, {
154
+ moduleName: 'workbox-range-requests',
155
+ funcName: 'createPartialResponse',
156
+ paramName: 'request'
157
+ });
158
+ assert_js.assert.isInstance(originalResponse, Response, {
159
+ moduleName: 'workbox-range-requests',
160
+ funcName: 'createPartialResponse',
161
+ paramName: 'originalResponse'
162
+ });
163
+ }
164
+
165
+ if (originalResponse.status === 206) {
166
+ // If we already have a 206, then just pass it through as-is;
167
+ // see https://github.com/GoogleChrome/workbox/issues/1720
168
+ return originalResponse;
169
+ }
170
+
171
+ const rangeHeader = request.headers.get('range');
172
+
173
+ if (!rangeHeader) {
174
+ throw new WorkboxError_js.WorkboxError('no-range-header');
175
+ }
176
+
177
+ const boundaries = parseRangeHeader(rangeHeader);
178
+ const originalBlob = await originalResponse.blob();
179
+ const effectiveBoundaries = calculateEffectiveBoundaries(originalBlob, boundaries.start, boundaries.end);
180
+ const slicedBlob = originalBlob.slice(effectiveBoundaries.start, effectiveBoundaries.end);
181
+ const slicedBlobSize = slicedBlob.size;
182
+ const slicedResponse = new Response(slicedBlob, {
183
+ // Status code 206 is for a Partial Content response.
184
+ // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206
185
+ status: 206,
186
+ statusText: 'Partial Content',
187
+ headers: originalResponse.headers
188
+ });
189
+ slicedResponse.headers.set('Content-Length', String(slicedBlobSize));
190
+ slicedResponse.headers.set('Content-Range', `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` + originalBlob.size);
191
+ return slicedResponse;
192
+ } catch (error) {
193
+ {
194
+ logger_js.logger.warn(`Unable to construct a partial response; returning a ` + `416 Range Not Satisfiable response instead.`);
195
+ logger_js.logger.groupCollapsed(`View details here.`);
196
+ logger_js.logger.log(error);
197
+ logger_js.logger.log(request);
198
+ logger_js.logger.log(originalResponse);
199
+ logger_js.logger.groupEnd();
200
+ }
201
+
202
+ return new Response('', {
203
+ status: 416,
204
+ statusText: 'Range Not Satisfiable'
205
+ });
206
+ }
207
+ }
208
+
209
+ /*
210
+ Copyright 2018 Google LLC
211
+
212
+ Use of this source code is governed by an MIT-style
213
+ license that can be found in the LICENSE file or at
214
+ https://opensource.org/licenses/MIT.
215
+ */
216
+ /**
217
+ * The range request plugin makes it easy for a request with a 'Range' header to
218
+ * be fulfilled by a cached response.
219
+ *
220
+ * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback
221
+ * and returning the appropriate subset of the cached response body.
222
+ *
223
+ * @memberof workbox.rangeRequests
224
+ */
225
+
226
+ class Plugin {
227
+ constructor() {
228
+ /**
229
+ * @param {Object} options
230
+ * @param {Request} options.request The original request, which may or may not
231
+ * contain a Range: header.
232
+ * @param {Response} options.cachedResponse The complete cached response.
233
+ * @return {Promise<Response>} If request contains a 'Range' header, then a
234
+ * new response with status 206 whose body is a subset of `cachedResponse` is
235
+ * returned. Otherwise, `cachedResponse` is returned as-is.
236
+ *
237
+ * @private
238
+ */
239
+ this.cachedResponseWillBeUsed = async ({
240
+ request,
241
+ cachedResponse
242
+ }) => {
243
+ // Only return a sliced response if there's something valid in the cache,
244
+ // and there's a Range: header in the request.
245
+ if (cachedResponse && request.headers.has('range')) {
246
+ return await createPartialResponse(request, cachedResponse);
247
+ } // If there was no Range: header, or if cachedResponse wasn't valid, just
248
+ // pass it through as-is.
249
+
250
+
251
+ return cachedResponse;
252
+ };
253
+ }
254
+
255
+ }
256
+
257
+ exports.Plugin = Plugin;
258
+ exports.createPartialResponse = createPartialResponse;
259
+
260
+ return exports;
261
+
262
+ }({}, workbox.core._private, workbox.core._private, workbox.core._private));
263
+ //# sourceMappingURL=workbox-range-requests.dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-range-requests.dev.js","sources":["../_version.js","../utils/calculateEffectiveBoundaries.js","../utils/parseRangeHeader.js","../createPartialResponse.js","../Plugin.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:range-requests: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 { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\n/**\n * @param {Blob} blob A source blob.\n * @param {number} [start] The offset to use as the start of the\n * slice.\n * @param {number} [end] The offset to use as the end of the slice.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the effective boundaries to use given the size of the blob.\n *\n * @private\n */\nfunction calculateEffectiveBoundaries(blob, start, end) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(blob, Blob, {\n moduleName: 'workbox-range-requests',\n funcName: 'calculateEffectiveBoundaries',\n paramName: 'blob',\n });\n }\n const blobSize = blob.size;\n if ((end && end > blobSize) || (start && start < 0)) {\n throw new WorkboxError('range-not-satisfiable', {\n size: blobSize,\n end,\n start,\n });\n }\n let effectiveStart;\n let effectiveEnd;\n if (start && end) {\n effectiveStart = start;\n // Range values are inclusive, so add 1 to the value.\n effectiveEnd = end + 1;\n }\n else if (start && !end) {\n effectiveStart = start;\n effectiveEnd = blobSize;\n }\n else if (end && !start) {\n effectiveStart = blobSize - end;\n effectiveEnd = blobSize;\n }\n return {\n start: effectiveStart,\n end: effectiveEnd,\n };\n}\nexport { calculateEffectiveBoundaries };\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 { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\n/**\n * @param {string} rangeHeader A Range: header value.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the parsed value of the Range: header. If either the `start` or `end` are\n * omitted, then `null` will be returned.\n *\n * @private\n */\nfunction parseRangeHeader(rangeHeader) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(rangeHeader, 'string', {\n moduleName: 'workbox-range-requests',\n funcName: 'parseRangeHeader',\n paramName: 'rangeHeader',\n });\n }\n const normalizedRangeHeader = rangeHeader.trim().toLowerCase();\n if (!normalizedRangeHeader.startsWith('bytes=')) {\n throw new WorkboxError('unit-must-be-bytes', { normalizedRangeHeader });\n }\n // Specifying multiple ranges separate by commas is valid syntax, but this\n // library only attempts to handle a single, contiguous sequence of bytes.\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax\n if (normalizedRangeHeader.includes(',')) {\n throw new WorkboxError('single-range-only', { normalizedRangeHeader });\n }\n const rangeParts = /(\\d*)-(\\d*)/.exec(normalizedRangeHeader);\n // We need either at least one of the start or end values.\n if (!rangeParts || !(rangeParts[1] || rangeParts[2])) {\n throw new WorkboxError('invalid-range-values', { normalizedRangeHeader });\n }\n return {\n start: rangeParts[1] === '' ? undefined : Number(rangeParts[1]),\n end: rangeParts[2] === '' ? undefined : Number(rangeParts[2]),\n };\n}\nexport { parseRangeHeader };\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 { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { calculateEffectiveBoundaries } from './utils/calculateEffectiveBoundaries.js';\nimport { parseRangeHeader } from './utils/parseRangeHeader.js';\nimport './_version.js';\n/**\n * Given a `Request` and `Response` objects as input, this will return a\n * promise for a new `Response`.\n *\n * If the original `Response` already contains partial content (i.e. it has\n * a status of 206), then this assumes it already fulfills the `Range:`\n * requirements, and will return it as-is.\n *\n * @param {Request} request A request, which should contain a Range:\n * header.\n * @param {Response} originalResponse A response.\n * @return {Promise<Response>} Either a `206 Partial Content` response, with\n * the response body set to the slice of content specified by the request's\n * `Range:` header, or a `416 Range Not Satisfiable` response if the\n * conditions of the `Range:` header can't be met.\n *\n * @memberof workbox.rangeRequests\n */\nasync function createPartialResponse(request, originalResponse) {\n try {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'request',\n });\n assert.isInstance(originalResponse, Response, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'originalResponse',\n });\n }\n if (originalResponse.status === 206) {\n // If we already have a 206, then just pass it through as-is;\n // see https://github.com/GoogleChrome/workbox/issues/1720\n return originalResponse;\n }\n const rangeHeader = request.headers.get('range');\n if (!rangeHeader) {\n throw new WorkboxError('no-range-header');\n }\n const boundaries = parseRangeHeader(rangeHeader);\n const originalBlob = await originalResponse.blob();\n const effectiveBoundaries = calculateEffectiveBoundaries(originalBlob, boundaries.start, boundaries.end);\n const slicedBlob = originalBlob.slice(effectiveBoundaries.start, effectiveBoundaries.end);\n const slicedBlobSize = slicedBlob.size;\n const slicedResponse = new Response(slicedBlob, {\n // Status code 206 is for a Partial Content response.\n // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206\n status: 206,\n statusText: 'Partial Content',\n headers: originalResponse.headers,\n });\n slicedResponse.headers.set('Content-Length', String(slicedBlobSize));\n slicedResponse.headers.set('Content-Range', `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` +\n originalBlob.size);\n return slicedResponse;\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to construct a partial response; returning a ` +\n `416 Range Not Satisfiable response instead.`);\n logger.groupCollapsed(`View details here.`);\n logger.log(error);\n logger.log(request);\n logger.log(originalResponse);\n logger.groupEnd();\n }\n return new Response('', {\n status: 416,\n statusText: 'Range Not Satisfiable',\n });\n }\n}\nexport { createPartialResponse };\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 { createPartialResponse } from './createPartialResponse.js';\nimport './_version.js';\n/**\n * The range request plugin makes it easy for a request with a 'Range' header to\n * be fulfilled by a cached response.\n *\n * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback\n * and returning the appropriate subset of the cached response body.\n *\n * @memberof workbox.rangeRequests\n */\nclass Plugin {\n constructor() {\n /**\n * @param {Object} options\n * @param {Request} options.request The original request, which may or may not\n * contain a Range: header.\n * @param {Response} options.cachedResponse The complete cached response.\n * @return {Promise<Response>} If request contains a 'Range' header, then a\n * new response with status 206 whose body is a subset of `cachedResponse` is\n * returned. Otherwise, `cachedResponse` is returned as-is.\n *\n * @private\n */\n this.cachedResponseWillBeUsed = async ({ request, cachedResponse }) => {\n // Only return a sliced response if there's something valid in the cache,\n // and there's a Range: header in the request.\n if (cachedResponse && request.headers.has('range')) {\n return await createPartialResponse(request, cachedResponse);\n }\n // If there was no Range: header, or if cachedResponse wasn't valid, just\n // pass it through as-is.\n return cachedResponse;\n };\n }\n}\nexport { Plugin };\n"],"names":["self","_","e","calculateEffectiveBoundaries","blob","start","end","assert","isInstance","Blob","moduleName","funcName","paramName","blobSize","size","WorkboxError","effectiveStart","effectiveEnd","parseRangeHeader","rangeHeader","isType","normalizedRangeHeader","trim","toLowerCase","startsWith","includes","rangeParts","exec","undefined","Number","createPartialResponse","request","originalResponse","process","Request","Response","status","headers","get","boundaries","originalBlob","effectiveBoundaries","slicedBlob","slice","slicedBlobSize","slicedResponse","statusText","set","String","error","logger","warn","groupCollapsed","log","groupEnd","Plugin","constructor","cachedResponseWillBeUsed","cachedResponse","has"],"mappings":";;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,sCAAD,CAAJ,IAAgDC,CAAC,EAAjD;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IAGA;;;;;;;;;;;IAUA,SAASC,4BAAT,CAAsCC,IAAtC,EAA4CC,KAA5C,EAAmDC,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.workbox=this.workbox||{},this.workbox.rangeRequests=function(t,e,n){"use strict";try{self["workbox:range-requests:5.0.0-alpha.0"]&&_()}catch(t){}async function r(t,n){try{if(206===n.status)return n;const r=t.headers.get("range");if(!r)throw new e.WorkboxError("no-range-header");const s=function(t){const n=t.trim().toLowerCase();if(!n.startsWith("bytes="))throw new e.WorkboxError("unit-must-be-bytes",{normalizedRangeHeader:n});if(n.includes(","))throw new e.WorkboxError("single-range-only",{normalizedRangeHeader:n});const r=/(\d*)-(\d*)/.exec(n);if(!r||!r[1]&&!r[2])throw new e.WorkboxError("invalid-range-values",{normalizedRangeHeader:n});return{start:""===r[1]?void 0:Number(r[1]),end:""===r[2]?void 0:Number(r[2])}}(r),a=await n.blob(),o=function(t,n,r){const s=t.size;if(r&&r>s||n&&n<0)throw new e.WorkboxError("range-not-satisfiable",{size:s,end:r,start:n});let a,o;return n&&r?(a=n,o=r+1):n&&!r?(a=n,o=s):r&&!n&&(a=s-r,o=s),{start:a,end:o}}(a,s.start,s.end),i=a.slice(o.start,o.end),u=i.size,c=new Response(i,{status:206,statusText:"Partial Content",headers:n.headers});return c.headers.set("Content-Length",String(u)),c.headers.set("Content-Range",`bytes ${o.start}-${o.end-1}/`+a.size),c}catch(t){return new Response("",{status:416,statusText:"Range Not Satisfiable"})}}return t.Plugin=class{constructor(){this.cachedResponseWillBeUsed=(async({request:t,cachedResponse:e})=>e&&t.headers.has("range")?await r(t,e):e)}},t.createPartialResponse=r,t}({},workbox.core._private,workbox.core._private);
2
+ //# sourceMappingURL=workbox-range-requests.prod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-range-requests.prod.js","sources":["../_version.js","../createPartialResponse.js","../utils/parseRangeHeader.js","../utils/calculateEffectiveBoundaries.js","../Plugin.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:range-requests: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 { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { calculateEffectiveBoundaries } from './utils/calculateEffectiveBoundaries.js';\nimport { parseRangeHeader } from './utils/parseRangeHeader.js';\nimport './_version.js';\n/**\n * Given a `Request` and `Response` objects as input, this will return a\n * promise for a new `Response`.\n *\n * If the original `Response` already contains partial content (i.e. it has\n * a status of 206), then this assumes it already fulfills the `Range:`\n * requirements, and will return it as-is.\n *\n * @param {Request} request A request, which should contain a Range:\n * header.\n * @param {Response} originalResponse A response.\n * @return {Promise<Response>} Either a `206 Partial Content` response, with\n * the response body set to the slice of content specified by the request's\n * `Range:` header, or a `416 Range Not Satisfiable` response if the\n * conditions of the `Range:` header can't be met.\n *\n * @memberof workbox.rangeRequests\n */\nasync function createPartialResponse(request, originalResponse) {\n try {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'request',\n });\n assert.isInstance(originalResponse, Response, {\n moduleName: 'workbox-range-requests',\n funcName: 'createPartialResponse',\n paramName: 'originalResponse',\n });\n }\n if (originalResponse.status === 206) {\n // If we already have a 206, then just pass it through as-is;\n // see https://github.com/GoogleChrome/workbox/issues/1720\n return originalResponse;\n }\n const rangeHeader = request.headers.get('range');\n if (!rangeHeader) {\n throw new WorkboxError('no-range-header');\n }\n const boundaries = parseRangeHeader(rangeHeader);\n const originalBlob = await originalResponse.blob();\n const effectiveBoundaries = calculateEffectiveBoundaries(originalBlob, boundaries.start, boundaries.end);\n const slicedBlob = originalBlob.slice(effectiveBoundaries.start, effectiveBoundaries.end);\n const slicedBlobSize = slicedBlob.size;\n const slicedResponse = new Response(slicedBlob, {\n // Status code 206 is for a Partial Content response.\n // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206\n status: 206,\n statusText: 'Partial Content',\n headers: originalResponse.headers,\n });\n slicedResponse.headers.set('Content-Length', String(slicedBlobSize));\n slicedResponse.headers.set('Content-Range', `bytes ${effectiveBoundaries.start}-${effectiveBoundaries.end - 1}/` +\n originalBlob.size);\n return slicedResponse;\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to construct a partial response; returning a ` +\n `416 Range Not Satisfiable response instead.`);\n logger.groupCollapsed(`View details here.`);\n logger.log(error);\n logger.log(request);\n logger.log(originalResponse);\n logger.groupEnd();\n }\n return new Response('', {\n status: 416,\n statusText: 'Range Not Satisfiable',\n });\n }\n}\nexport { createPartialResponse };\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 { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\n/**\n * @param {string} rangeHeader A Range: header value.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the parsed value of the Range: header. If either the `start` or `end` are\n * omitted, then `null` will be returned.\n *\n * @private\n */\nfunction parseRangeHeader(rangeHeader) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(rangeHeader, 'string', {\n moduleName: 'workbox-range-requests',\n funcName: 'parseRangeHeader',\n paramName: 'rangeHeader',\n });\n }\n const normalizedRangeHeader = rangeHeader.trim().toLowerCase();\n if (!normalizedRangeHeader.startsWith('bytes=')) {\n throw new WorkboxError('unit-must-be-bytes', { normalizedRangeHeader });\n }\n // Specifying multiple ranges separate by commas is valid syntax, but this\n // library only attempts to handle a single, contiguous sequence of bytes.\n // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range#Syntax\n if (normalizedRangeHeader.includes(',')) {\n throw new WorkboxError('single-range-only', { normalizedRangeHeader });\n }\n const rangeParts = /(\\d*)-(\\d*)/.exec(normalizedRangeHeader);\n // We need either at least one of the start or end values.\n if (!rangeParts || !(rangeParts[1] || rangeParts[2])) {\n throw new WorkboxError('invalid-range-values', { normalizedRangeHeader });\n }\n return {\n start: rangeParts[1] === '' ? undefined : Number(rangeParts[1]),\n end: rangeParts[2] === '' ? undefined : Number(rangeParts[2]),\n };\n}\nexport { parseRangeHeader };\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 { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\n/**\n * @param {Blob} blob A source blob.\n * @param {number} [start] The offset to use as the start of the\n * slice.\n * @param {number} [end] The offset to use as the end of the slice.\n * @return {Object} An object with `start` and `end` properties, reflecting\n * the effective boundaries to use given the size of the blob.\n *\n * @private\n */\nfunction calculateEffectiveBoundaries(blob, start, end) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(blob, Blob, {\n moduleName: 'workbox-range-requests',\n funcName: 'calculateEffectiveBoundaries',\n paramName: 'blob',\n });\n }\n const blobSize = blob.size;\n if ((end && end > blobSize) || (start && start < 0)) {\n throw new WorkboxError('range-not-satisfiable', {\n size: blobSize,\n end,\n start,\n });\n }\n let effectiveStart;\n let effectiveEnd;\n if (start && end) {\n effectiveStart = start;\n // Range values are inclusive, so add 1 to the value.\n effectiveEnd = end + 1;\n }\n else if (start && !end) {\n effectiveStart = start;\n effectiveEnd = blobSize;\n }\n else if (end && !start) {\n effectiveStart = blobSize - end;\n effectiveEnd = blobSize;\n }\n return {\n start: effectiveStart,\n end: effectiveEnd,\n };\n}\nexport { calculateEffectiveBoundaries };\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 { createPartialResponse } from './createPartialResponse.js';\nimport './_version.js';\n/**\n * The range request plugin makes it easy for a request with a 'Range' header to\n * be fulfilled by a cached response.\n *\n * It does this by intercepting the `cachedResponseWillBeUsed` plugin callback\n * and returning the appropriate subset of the cached response body.\n *\n * @memberof workbox.rangeRequests\n */\nclass Plugin {\n constructor() {\n /**\n * @param {Object} options\n * @param {Request} options.request The original request, which may or may not\n * contain a Range: header.\n * @param {Response} options.cachedResponse The complete cached response.\n * @return {Promise<Response>} If request contains a 'Range' header, then a\n * new response with status 206 whose body is a subset of `cachedResponse` is\n * returned. Otherwise, `cachedResponse` is returned as-is.\n *\n * @private\n */\n this.cachedResponseWillBeUsed = async ({ request, cachedResponse }) => {\n // Only return a sliced response if there's something valid in the cache,\n // and there's a Range: header in the request.\n if (cachedResponse && request.headers.has('range')) {\n return await createPartialResponse(request, cachedResponse);\n }\n // If there was no Range: header, or if cachedResponse wasn't valid, just\n // pass it through as-is.\n return cachedResponse;\n };\n }\n}\nexport { Plugin };\n"],"names":["self","_","e","async","createPartialResponse","request","originalResponse","status","rangeHeader","headers","get","WorkboxError","boundaries","normalizedRangeHeader","trim","toLowerCase","startsWith","includes","rangeParts","exec","start","undefined","Number","end","parseRangeHeader","originalBlob","blob","effectiveBoundaries","blobSize","size","effectiveStart","effectiveEnd","calculateEffectiveBoundaries","slicedBlob","slice","slicedBlobSize","slicedResponse","Response","statusText","set","String","error","constructor","cachedResponseWillBeUsed","cachedResponse","has"],"mappings":"sFACA,IACIA,KAAK,yCAA2CC,IAEpD,MAAOC,IC2BPC,eAAeC,EAAsBC,EAASC,UAcN,MAA5BA,EAAiBC,cAGVD,QAELE,EAAcH,EAAQI,QAAQC,IAAI,aACnCF,QACK,IAAIG,eAAa,yBAErBC,ECpCd,SAA0BJ,SAQhBK,EAAwBL,EAAYM,OAAOC,kBAC5CF,EAAsBG,WAAW,gBAC5B,IAAIL,eAAa,qBAAsB,CAAEE,sBAAAA,OAK/CA,EAAsBI,SAAS,WACzB,IAAIN,eAAa,oBAAqB,CAAEE,sBAAAA,UAE5CK,EAAa,cAAcC,KAAKN,OAEjCK,IAAgBA,EAAW,KAAMA,EAAW,SACvC,IAAIP,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FriendlyURL_js) {
3
+ 'use strict';
4
+
5
+ // @ts-ignore
6
+ try {
7
+ self['workbox:routing: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
+ * The default HTTP method, 'GET', used when there's no specific method
19
+ * configured for a route.
20
+ *
21
+ * @type {string}
22
+ *
23
+ * @private
24
+ */
25
+
26
+ const defaultMethod = 'GET';
27
+ /**
28
+ * The list of valid HTTP methods associated with requests that could be routed.
29
+ *
30
+ * @type {Array<string>}
31
+ *
32
+ * @private
33
+ */
34
+
35
+ const validMethods = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT'];
36
+
37
+ /*
38
+ Copyright 2018 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
+ * @param {function()|Object} handler Either a function, or an object with a
46
+ * 'handle' method.
47
+ * @return {Object} An object with a handle method.
48
+ *
49
+ * @private
50
+ */
51
+
52
+ const normalizeHandler = handler => {
53
+ if (handler && typeof handler === 'object') {
54
+ {
55
+ assert_js.assert.hasMethod(handler, 'handle', {
56
+ moduleName: 'workbox-routing',
57
+ className: 'Route',
58
+ funcName: 'constructor',
59
+ paramName: 'handler'
60
+ });
61
+ }
62
+
63
+ return handler;
64
+ } else {
65
+ {
66
+ assert_js.assert.isType(handler, 'function', {
67
+ moduleName: 'workbox-routing',
68
+ className: 'Route',
69
+ funcName: 'constructor',
70
+ paramName: 'handler'
71
+ });
72
+ }
73
+
74
+ return {
75
+ handle: handler
76
+ };
77
+ }
78
+ };
79
+
80
+ /*
81
+ Copyright 2018 Google LLC
82
+
83
+ Use of this source code is governed by an MIT-style
84
+ license that can be found in the LICENSE file or at
85
+ https://opensource.org/licenses/MIT.
86
+ */
87
+ /**
88
+ * A `Route` consists of a pair of callback functions, "match" and "handler".
89
+ * The "match" callback determine if a route should be used to "handle" a
90
+ * request by returning a non-falsy value if it can. The "handler" callback
91
+ * is called when there is a match and should return a Promise that resolves
92
+ * to a `Response`.
93
+ *
94
+ * @memberof workbox.routing
95
+ */
96
+
97
+ class Route {
98
+ /**
99
+ * Constructor for Route class.
100
+ *
101
+ * @param {workbox.routing.Route~matchCallback} match
102
+ * A callback function that determines whether the route matches a given
103
+ * `fetch` event by returning a non-falsy value.
104
+ * @param {workbox.routing.Route~handlerCallback} handler A callback
105
+ * function that returns a Promise resolving to a Response.
106
+ * @param {string} [method='GET'] The HTTP method to match the Route
107
+ * against.
108
+ */
109
+ constructor(match, handler, method = defaultMethod) {
110
+ {
111
+ assert_js.assert.isType(match, 'function', {
112
+ moduleName: 'workbox-routing',
113
+ className: 'Route',
114
+ funcName: 'constructor',
115
+ paramName: 'match'
116
+ });
117
+
118
+ if (method) {
119
+ assert_js.assert.isOneOf(method, validMethods, {
120
+ paramName: 'method'
121
+ });
122
+ }
123
+ } // These values are referenced directly by Router so cannot be
124
+ // altered by minifification.
125
+
126
+
127
+ this.handler = normalizeHandler(handler);
128
+ this.match = match;
129
+ this.method = method;
130
+ }
131
+
132
+ }
133
+
134
+ /*
135
+ Copyright 2018 Google LLC
136
+
137
+ Use of this source code is governed by an MIT-style
138
+ license that can be found in the LICENSE file or at
139
+ https://opensource.org/licenses/MIT.
140
+ */
141
+ /**
142
+ * NavigationRoute makes it easy to create a [Route]{@link
143
+ * workbox.routing.Route} that matches for browser
144
+ * [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}.
145
+ *
146
+ * It will only match incoming Requests whose
147
+ * [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode}
148
+ * is set to `navigate`.
149
+ *
150
+ * You can optionally only apply this route to a subset of navigation requests
151
+ * by using one or both of the `blacklist` and `whitelist` parameters.
152
+ *
153
+ * @memberof workbox.routing
154
+ * @extends workbox.routing.Route
155
+ */
156
+
157
+ class NavigationRoute extends Route {
158
+ /**
159
+ * If both `blacklist` and `whiltelist` are provided, the `blacklist` will
160
+ * take precedence and the request will not match this route.
161
+ *
162
+ * The regular expressions in `whitelist` and `blacklist`
163
+ * are matched against the concatenated
164
+ * [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname}
165
+ * and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search}
166
+ * portions of the requested URL.
167
+ *
168
+ * @param {workbox.routing.Route~handlerCallback} handler A callback
169
+ * function that returns a Promise resulting in a Response.
170
+ * @param {Object} options
171
+ * @param {Array<RegExp>} [options.blacklist] If any of these patterns match,
172
+ * the route will not handle the request (even if a whitelist RegExp matches).
173
+ * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns
174
+ * match the URL's pathname and search parameter, the route will handle the
175
+ * request (assuming the blacklist doesn't match).
176
+ */
177
+ constructor(handler, {
178
+ whitelist = [/./],
179
+ blacklist = []
180
+ } = {}) {
181
+ {
182
+ assert_js.assert.isArrayOfClass(whitelist, RegExp, {
183
+ moduleName: 'workbox-routing',
184
+ className: 'NavigationRoute',
185
+ funcName: 'constructor',
186
+ paramName: 'options.whitelist'
187
+ });
188
+ assert_js.assert.isArrayOfClass(blacklist, RegExp, {
189
+ moduleName: 'workbox-routing',
190
+ className: 'NavigationRoute',
191
+ funcName: 'constructor',
192
+ paramName: 'options.blacklist'
193
+ });
194
+ }
195
+
196
+ super(options => this._match(options), handler);
197
+ this._whitelist = whitelist;
198
+ this._blacklist = blacklist;
199
+ }
200
+ /**
201
+ * Routes match handler.
202
+ *
203
+ * @param {Object} options
204
+ * @param {URL} options.url
205
+ * @param {Request} options.request
206
+ * @return {boolean}
207
+ *
208
+ * @private
209
+ */
210
+
211
+
212
+ _match({
213
+ url,
214
+ request
215
+ }) {
216
+ if (request && request.mode !== 'navigate') {
217
+ return false;
218
+ }
219
+
220
+ const pathnameAndSearch = url.pathname + url.search;
221
+
222
+ for (const regExp of this._blacklist) {
223
+ if (regExp.test(pathnameAndSearch)) {
224
+ {
225
+ logger_js.logger.log(`The navigation route ${pathnameAndSearch} is not ` + `being used, since the URL matches this blacklist pattern: ` + `${regExp}`);
226
+ }
227
+
228
+ return false;
229
+ }
230
+ }
231
+
232
+ if (this._whitelist.some(regExp => regExp.test(pathnameAndSearch))) {
233
+ {
234
+ logger_js.logger.debug(`The navigation route ${pathnameAndSearch} ` + `is being used.`);
235
+ }
236
+
237
+ return true;
238
+ }
239
+
240
+ {
241
+ logger_js.logger.log(`The navigation route ${pathnameAndSearch} is not ` + `being used, since the URL being navigated to doesn't ` + `match the whitelist.`);
242
+ }
243
+
244
+ return false;
245
+ }
246
+
247
+ }
248
+
249
+ /*
250
+ Copyright 2018 Google LLC
251
+
252
+ Use of this source code is governed by an MIT-style
253
+ license that can be found in the LICENSE file or at
254
+ https://opensource.org/licenses/MIT.
255
+ */
256
+ /**
257
+ * RegExpRoute makes it easy to create a regular expression based
258
+ * [Route]{@link workbox.routing.Route}.
259
+ *
260
+ * For same-origin requests the RegExp only needs to match part of the URL. For
261
+ * requests against third-party servers, you must define a RegExp that matches
262
+ * the start of the URL.
263
+ *
264
+ * [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing}
265
+ *
266
+ * @memberof workbox.routing
267
+ * @extends workbox.routing.Route
268
+ */
269
+
270
+ class RegExpRoute extends Route {
271
+ /**
272
+ * If the regulard expression contains
273
+ * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},
274
+ * th ecaptured values will be passed to the
275
+ * [handler's]{@link workbox.routing.Route~handlerCallback} `params`
276
+ * argument.
277
+ *
278
+ * @param {RegExp} regExp The regular expression to match against URLs.
279
+ * @param {workbox.routing.Route~handlerCallback} handler A callback
280
+ * function that returns a Promise resulting in a Response.
281
+ * @param {string} [method='GET'] The HTTP method to match the Route
282
+ * against.
283
+ */
284
+ constructor(regExp, handler, method) {
285
+ {
286
+ assert_js.assert.isInstance(regExp, RegExp, {
287
+ moduleName: 'workbox-routing',
288
+ className: 'RegExpRoute',
289
+ funcName: 'constructor',
290
+ paramName: 'pattern'
291
+ });
292
+ }
293
+
294
+ const match = ({
295
+ url
296
+ }) => {
297
+ const result = regExp.exec(url.href); // Return immediately if there's no match.
298
+
299
+ if (!result) {
300
+ return;
301
+ } // Require that the match start at the first character in the URL string
302
+ // if it's a cross-origin request.
303
+ // See https://github.com/GoogleChrome/workbox/issues/281 for the context
304
+ // behind this behavior.
305
+
306
+
307
+ if (url.origin !== location.origin && result.index !== 0) {
308
+ {
309
+ logger_js.logger.debug(`The regular expression '${regExp}' only partially matched ` + `against the cross-origin URL '${url}'. RegExpRoute's will only ` + `handle cross-origin requests if they match the entire URL.`);
310
+ }
311
+
312
+ return;
313
+ } // If the route matches, but there aren't any capture groups defined, then
314
+ // this will return [], which is truthy and therefore sufficient to
315
+ // indicate a match.
316
+ // If there are capture groups, then it will return their values.
317
+
318
+
319
+ return result.slice(1);
320
+ };
321
+
322
+ super(match, handler, method);
323
+ }
324
+
325
+ }
326
+
327
+ /*
328
+ Copyright 2018 Google LLC
329
+
330
+ Use of this source code is governed by an MIT-style
331
+ license that can be found in the LICENSE file or at
332
+ https://opensource.org/licenses/MIT.
333
+ */
334
+ /**
335
+ * The Router can be used to process a FetchEvent through one or more
336
+ * [Routes]{@link workbox.routing.Route} responding with a Request if
337
+ * a matching route exists.
338
+ *
339
+ * If no route matches a given a request, the Router will use a "default"
340
+ * handler if one is defined.
341
+ *
342
+ * Should the matching Route throw an error, the Router will use a "catch"
343
+ * handler if one is defined to gracefully deal with issues and respond with a
344
+ * Request.
345
+ *
346
+ * If a request matches multiple routes, the **earliest** registered route will
347
+ * be used to respond to the request.
348
+ *
349
+ * @memberof workbox.routing
350
+ */
351
+
352
+ class Router {
353
+ /**
354
+ * Initializes a new Router.
355
+ */
356
+ constructor() {
357
+ this._routes = new Map();
358
+ }
359
+ /**
360
+ * @return {Map<string, Array<workbox.routing.Route>>} routes A `Map` of HTTP
361
+ * method name ('GET', etc.) to an array of all the corresponding `Route`
362
+ * instances that are registered.
363
+ */
364
+
365
+
366
+ get routes() {
367
+ return this._routes;
368
+ }
369
+ /**
370
+ * Adds a fetch event listener to respond to events when a route matches
371
+ * the event's request.
372
+ */
373
+
374
+
375
+ addFetchListener() {
376
+ self.addEventListener('fetch', event => {
377
+ const {
378
+ request
379
+ } = event;
380
+ const responsePromise = this.handleRequest({
381
+ request,
382
+ event
383
+ });
384
+
385
+ if (responsePromise) {
386
+ event.respondWith(responsePromise);
387
+ }
388
+ });
389
+ }
390
+ /**
391
+ * Adds a message event listener for URLs to cache from the window.
392
+ * This is useful to cache resources loaded on the page prior to when the
393
+ * service worker started controlling it.
394
+ *
395
+ * The format of the message data sent from the window should be as follows.
396
+ * Where the `urlsToCache` array may consist of URL strings or an array of
397
+ * URL string + `requestInit` object (the same as you'd pass to `fetch()`).
398
+ *
399
+ * ```
400
+ * {
401
+ * type: 'CACHE_URLS',
402
+ * payload: {
403
+ * urlsToCache: [
404
+ * './script1.js',
405
+ * './script2.js',
406
+ * ['./script3.js', {mode: 'no-cors'}],
407
+ * ],
408
+ * },
409
+ * }
410
+ * ```
411
+ */
412
+
413
+
414
+ addCacheListener() {
415
+ self.addEventListener('message', async event => {
416
+ if (event.data && event.data.type === 'CACHE_URLS') {
417
+ const {
418
+ payload
419
+ } = event.data;
420
+
421
+ {
422
+ logger_js.logger.debug(`Caching URLs from the window`, payload.urlsToCache);
423
+ }
424
+
425
+ const requestPromises = Promise.all(payload.urlsToCache.map(entry => {
426
+ if (typeof entry === 'string') {
427
+ entry = [entry];
428
+ }
429
+
430
+ const request = new Request(...entry);
431
+ return this.handleRequest({
432
+ request
433
+ }); // TODO(philipwalton): Typescript errors without this typecast for
434
+ // some reason (probably a bug). The real type here should work but
435
+ // doesn't: `Array<Promise<Response> | undefined>`.
436
+ })); // Typescript
437
+
438
+ event.waitUntil(requestPromises); // If a MessageChannel was used, reply to the message on success.
439
+
440
+ if (event.ports && event.ports[0]) {
441
+ await requestPromises;
442
+ event.ports[0].postMessage(true);
443
+ }
444
+ }
445
+ });
446
+ }
447
+ /**
448
+ * Apply the routing rules to a FetchEvent object to get a Response from an
449
+ * appropriate Route's handler.
450
+ *
451
+ * @param {Object} options
452
+ * @param {Request} options.request The request to handle (this is usually
453
+ * from a fetch event, but it does not have to be).
454
+ * @param {FetchEvent} [options.event] The event that triggered the request,
455
+ * if applicable.
456
+ * @return {Promise<Response>|undefined} A promise is returned if a
457
+ * registered route can handle the request. If there is no matching
458
+ * route and there's no `defaultHandler`, `undefined` is returned.
459
+ */
460
+
461
+
462
+ handleRequest({
463
+ request,
464
+ event
465
+ }) {
466
+ {
467
+ assert_js.assert.isInstance(request, Request, {
468
+ moduleName: 'workbox-routing',
469
+ className: 'Router',
470
+ funcName: 'handleRequest',
471
+ paramName: 'options.request'
472
+ });
473
+ }
474
+
475
+ const url = new URL(request.url, location.href);
476
+
477
+ if (!url.protocol.startsWith('http')) {
478
+ {
479
+ logger_js.logger.debug(`Workbox Router only supports URLs that start with 'http'.`);
480
+ }
481
+
482
+ return;
483
+ }
484
+
485
+ let {
486
+ params,
487
+ route
488
+ } = this.findMatchingRoute({
489
+ url,
490
+ request,
491
+ event
492
+ });
493
+ let handler = route && route.handler;
494
+ let debugMessages = [];
495
+
496
+ {
497
+ if (handler) {
498
+ debugMessages.push([`Found a route to handle this request:`, route]);
499
+
500
+ if (params) {
501
+ debugMessages.push([`Passing the following params to the route's handler:`, params]);
502
+ }
503
+ }
504
+ } // If we don't have a handler because there was no matching route, then
505
+ // fall back to defaultHandler if that's defined.
506
+
507
+
508
+ if (!handler && this._defaultHandler) {
509
+ {
510
+ debugMessages.push(`Failed to find a matching route. Falling ` + `back to the default handler.`);
511
+ }
512
+
513
+ handler = this._defaultHandler;
514
+ }
515
+
516
+ if (!handler) {
517
+ {
518
+ // No handler so Workbox will do nothing. If logs is set of debug
519
+ // i.e. verbose, we should print out this information.
520
+ logger_js.logger.debug(`No route found for: ${getFriendlyURL_js.getFriendlyURL(url)}`);
521
+ }
522
+
523
+ return;
524
+ }
525
+
526
+ {
527
+ // We have a handler, meaning Workbox is going to handle the route.
528
+ // print the routing details to the console.
529
+ logger_js.logger.groupCollapsed(`Router is responding to: ${getFriendlyURL_js.getFriendlyURL(url)}`);
530
+ debugMessages.forEach(msg => {
531
+ if (Array.isArray(msg)) {
532
+ logger_js.logger.log(...msg);
533
+ } else {
534
+ logger_js.logger.log(msg);
535
+ }
536
+ }); // The Request and Response objects contains a great deal of information,
537
+ // hide it under a group in case developers want to see it.
538
+
539
+ logger_js.logger.groupCollapsed(`View request details here.`);
540
+ logger_js.logger.log(request);
541
+ logger_js.logger.groupEnd();
542
+ logger_js.logger.groupEnd();
543
+ } // Wrap in try and catch in case the handle method throws a synchronous
544
+ // error. It should still callback to the catch handler.
545
+
546
+
547
+ let responsePromise;
548
+
549
+ try {
550
+ responsePromise = handler.handle({
551
+ url,
552
+ request,
553
+ event,
554
+ params
555
+ });
556
+ } catch (err) {
557
+ responsePromise = Promise.reject(err);
558
+ }
559
+
560
+ if (responsePromise && this._catchHandler) {
561
+ responsePromise = responsePromise.catch(err => {
562
+ {
563
+ // Still include URL here as it will be async from the console group
564
+ // and may not make sense without the URL
565
+ logger_js.logger.groupCollapsed(`Error thrown when responding to: ` + ` ${getFriendlyURL_js.getFriendlyURL(url)}. Falling back to Catch Handler.`);
566
+ logger_js.logger.error(`Error thrown by:`, route);
567
+ logger_js.logger.error(err);
568
+ logger_js.logger.groupEnd();
569
+ }
570
+
571
+ return this._catchHandler.handle({
572
+ url,
573
+ request,
574
+ event
575
+ });
576
+ });
577
+ }
578
+
579
+ return responsePromise;
580
+ }
581
+ /**
582
+ * Checks a request and URL (and optionally an event) against the list of
583
+ * registered routes, and if there's a match, returns the corresponding
584
+ * route along with any params generated by the match.
585
+ *
586
+ * @param {Object} options
587
+ * @param {URL} options.url
588
+ * @param {Request} options.request The request to match.
589
+ * @param {Event} [options.event] The corresponding event (unless N/A).
590
+ * @return {Object} An object with `route` and `params` properties.
591
+ * They are populated if a matching route was found or `undefined`
592
+ * otherwise.
593
+ */
594
+
595
+
596
+ findMatchingRoute({
597
+ url,
598
+ request,
599
+ event
600
+ }) {
601
+ {
602
+ assert_js.assert.isInstance(url, URL, {
603
+ moduleName: 'workbox-routing',
604
+ className: 'Router',
605
+ funcName: 'findMatchingRoute',
606
+ paramName: 'options.url'
607
+ });
608
+ assert_js.assert.isInstance(request, Request, {
609
+ moduleName: 'workbox-routing',
610
+ className: 'Router',
611
+ funcName: 'findMatchingRoute',
612
+ paramName: 'options.request'
613
+ });
614
+ }
615
+
616
+ const routes = this._routes.get(request.method) || [];
617
+
618
+ for (const route of routes) {
619
+ let params;
620
+ let matchResult = route.match({
621
+ url,
622
+ request,
623
+ event
624
+ });
625
+
626
+ if (matchResult) {
627
+ if (Array.isArray(matchResult) && matchResult.length > 0) {
628
+ // Instead of passing an empty array in as params, use undefined.
629
+ params = matchResult;
630
+ } else if (matchResult.constructor === Object && Object.keys(matchResult).length > 0) {
631
+ // Instead of passing an empty object in as params, use undefined.
632
+ params = matchResult;
633
+ } // Return early if have a match.
634
+
635
+
636
+ return {
637
+ route,
638
+ params
639
+ };
640
+ }
641
+ } // If no match was found above, return and empty object.
642
+
643
+
644
+ return {};
645
+ }
646
+ /**
647
+ * Define a default `handler` that's called when no routes explicitly
648
+ * match the incoming request.
649
+ *
650
+ * Without a default handler, unmatched requests will go against the
651
+ * network as if there were no service worker present.
652
+ *
653
+ * @param {workbox.routing.Route~handlerCallback} handler A callback
654
+ * function that returns a Promise resulting in a Response.
655
+ */
656
+
657
+
658
+ setDefaultHandler(handler) {
659
+ this._defaultHandler = normalizeHandler(handler);
660
+ }
661
+ /**
662
+ * If a Route throws an error while handling a request, this `handler`
663
+ * will be called and given a chance to provide a response.
664
+ *
665
+ * @param {workbox.routing.Route~handlerCallback} handler A callback
666
+ * function that returns a Promise resulting in a Response.
667
+ */
668
+
669
+
670
+ setCatchHandler(handler) {
671
+ this._catchHandler = normalizeHandler(handler);
672
+ }
673
+ /**
674
+ * Registers a route with the router.
675
+ *
676
+ * @param {workbox.routing.Route} route The route to register.
677
+ */
678
+
679
+
680
+ registerRoute(route) {
681
+ {
682
+ assert_js.assert.isType(route, 'object', {
683
+ moduleName: 'workbox-routing',
684
+ className: 'Router',
685
+ funcName: 'registerRoute',
686
+ paramName: 'route'
687
+ });
688
+ assert_js.assert.hasMethod(route, 'match', {
689
+ moduleName: 'workbox-routing',
690
+ className: 'Router',
691
+ funcName: 'registerRoute',
692
+ paramName: 'route'
693
+ });
694
+ assert_js.assert.isType(route.handler, 'object', {
695
+ moduleName: 'workbox-routing',
696
+ className: 'Router',
697
+ funcName: 'registerRoute',
698
+ paramName: 'route'
699
+ });
700
+ assert_js.assert.hasMethod(route.handler, 'handle', {
701
+ moduleName: 'workbox-routing',
702
+ className: 'Router',
703
+ funcName: 'registerRoute',
704
+ paramName: 'route.handler'
705
+ });
706
+ assert_js.assert.isType(route.method, 'string', {
707
+ moduleName: 'workbox-routing',
708
+ className: 'Router',
709
+ funcName: 'registerRoute',
710
+ paramName: 'route.method'
711
+ });
712
+ }
713
+
714
+ if (!this._routes.has(route.method)) {
715
+ this._routes.set(route.method, []);
716
+ } // Give precedence to all of the earlier routes by adding this additional
717
+ // route to the end of the array.
718
+
719
+
720
+ this._routes.get(route.method).push(route);
721
+ }
722
+ /**
723
+ * Unregisters a route with the router.
724
+ *
725
+ * @param {workbox.routing.Route} route The route to unregister.
726
+ */
727
+
728
+
729
+ unregisterRoute(route) {
730
+ if (!this._routes.has(route.method)) {
731
+ throw new WorkboxError_js.WorkboxError('unregister-route-but-not-found-with-method', {
732
+ method: route.method
733
+ });
734
+ }
735
+
736
+ const routeIndex = this._routes.get(route.method).indexOf(route);
737
+
738
+ if (routeIndex > -1) {
739
+ this._routes.get(route.method).splice(routeIndex, 1);
740
+ } else {
741
+ throw new WorkboxError_js.WorkboxError('unregister-route-route-not-registered');
742
+ }
743
+ }
744
+
745
+ }
746
+
747
+ /*
748
+ Copyright 2019 Google LLC
749
+
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 defaultRouter;
755
+ /**
756
+ * Creates a new, singleton Router instance if one does not exist. If one
757
+ * does already exist, that instance is returned.
758
+ *
759
+ * @private
760
+ * @return {Router}
761
+ */
762
+
763
+ const getOrCreateDefaultRouter = () => {
764
+ if (!defaultRouter) {
765
+ defaultRouter = new Router(); // The helpers that use the default Router assume these listeners exist.
766
+
767
+ defaultRouter.addFetchListener();
768
+ defaultRouter.addCacheListener();
769
+ }
770
+
771
+ return defaultRouter;
772
+ };
773
+
774
+ /*
775
+ Copyright 2019 Google LLC
776
+
777
+ Use of this source code is governed by an MIT-style
778
+ license that can be found in the LICENSE file or at
779
+ https://opensource.org/licenses/MIT.
780
+ */
781
+ /**
782
+ * Registers a route that will return a precached file for a navigation
783
+ * request. This is useful for the
784
+ * [application shell pattern]{@link https://developers.google.com/web/fundamentals/architecture/app-shell}.
785
+ *
786
+ * When determining the URL of the precached HTML document, you will likely need
787
+ * to call `workbox.precaching.getCacheKeyForURL(originalUrl)`, to account for
788
+ * the fact that Workbox's precaching naming conventions often results in URL
789
+ * cache keys that contain extra revisioning info.
790
+ *
791
+ * This method will generate a
792
+ * [NavigationRoute]{@link workbox.routing.NavigationRoute}
793
+ * and call
794
+ * [Router.registerRoute()]{@link workbox.routing.Router#registerRoute} on a
795
+ * singleton Router instance.
796
+ *
797
+ * @param {string} cachedAssetUrl The cache key to use for the HTML file.
798
+ * @param {Object} [options]
799
+ * @param {string} [options.cacheName] Cache name to store and retrieve
800
+ * requests. Defaults to precache cache name provided by
801
+ * [workbox-core.cacheNames]{@link workbox.core.cacheNames}.
802
+ * @param {Array<RegExp>} [options.blacklist=[]] If any of these patterns
803
+ * match, the route will not handle the request (even if a whitelist entry
804
+ * matches).
805
+ * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns
806
+ * match the URL's pathname and search parameter, the route will handle the
807
+ * request (assuming the blacklist doesn't match).
808
+ * @return {workbox.routing.NavigationRoute} Returns the generated
809
+ * Route.
810
+ *
811
+ * @alias workbox.routing.registerNavigationRoute
812
+ */
813
+
814
+ const registerNavigationRoute = (cachedAssetUrl, options = {}) => {
815
+ {
816
+ assert_js.assert.isType(cachedAssetUrl, 'string', {
817
+ moduleName: 'workbox-routing',
818
+ funcName: 'registerNavigationRoute',
819
+ paramName: 'cachedAssetUrl'
820
+ });
821
+ }
822
+
823
+ const cacheName = cacheNames_js.cacheNames.getPrecacheName(options.cacheName);
824
+
825
+ const handler = async () => {
826
+ try {
827
+ const response = await caches.match(cachedAssetUrl, {
828
+ cacheName
829
+ });
830
+
831
+ if (response) {
832
+ return response;
833
+ } // This shouldn't normally happen, but there are edge cases:
834
+ // https://github.com/GoogleChrome/workbox/issues/1441
835
+
836
+
837
+ throw new Error(`The cache ${cacheName} did not have an entry for ` + `${cachedAssetUrl}.`);
838
+ } catch (error) {
839
+ // If there's either a cache miss, or the caches.match() call threw
840
+ // an exception, then attempt to fulfill the navigation request with
841
+ // a response from the network rather than leaving the user with a
842
+ // failed navigation.
843
+ {
844
+ logger_js.logger.debug(`Unable to respond to navigation request with ` + `cached response. Falling back to network.`, error);
845
+ } // This might still fail if the browser is offline...
846
+
847
+
848
+ return fetch(cachedAssetUrl);
849
+ }
850
+ };
851
+
852
+ const route = new NavigationRoute(handler, {
853
+ whitelist: options.whitelist,
854
+ blacklist: options.blacklist
855
+ });
856
+ const defaultRouter = getOrCreateDefaultRouter();
857
+ defaultRouter.registerRoute(route);
858
+ return route;
859
+ };
860
+
861
+ /*
862
+ Copyright 2019 Google LLC
863
+
864
+ Use of this source code is governed by an MIT-style
865
+ license that can be found in the LICENSE file or at
866
+ https://opensource.org/licenses/MIT.
867
+ */
868
+ /**
869
+ * Easily register a RegExp, string, or function with a caching
870
+ * strategy to a singleton Router instance.
871
+ *
872
+ * This method will generate a Route for you if needed and
873
+ * call [Router.registerRoute()]{@link
874
+ * workbox.routing.Router#registerRoute}.
875
+ *
876
+ * @param {
877
+ * RegExp|
878
+ * string|
879
+ * workbox.routing.Route~matchCallback|
880
+ * workbox.routing.Route
881
+ * } capture
882
+ * If the capture param is a `Route`, all other arguments will be ignored.
883
+ * @param {workbox.routing.Route~handlerCallback} [handler] A callback
884
+ * function that returns a Promise resulting in a Response. This parameter
885
+ * is required if `capture` is not a `Route` object.
886
+ * @param {string} [method='GET'] The HTTP method to match the Route
887
+ * against.
888
+ * @return {workbox.routing.Route} The generated `Route`(Useful for
889
+ * unregistering).
890
+ *
891
+ * @alias workbox.routing.registerRoute
892
+ */
893
+
894
+ const registerRoute = (capture, handler, method) => {
895
+ let route;
896
+
897
+ if (typeof capture === 'string') {
898
+ const captureUrl = new URL(capture, location.href);
899
+
900
+ {
901
+ if (!(capture.startsWith('/') || capture.startsWith('http'))) {
902
+ throw new WorkboxError_js.WorkboxError('invalid-string', {
903
+ moduleName: 'workbox-routing',
904
+ funcName: 'registerRoute',
905
+ paramName: 'capture'
906
+ });
907
+ } // We want to check if Express-style wildcards are in the pathname only.
908
+ // TODO: Remove this log message in v4.
909
+
910
+
911
+ const valueToCheck = capture.startsWith('http') ? captureUrl.pathname : capture; // See https://github.com/pillarjs/path-to-regexp#parameters
912
+
913
+ const wildcards = '[*:?+]';
914
+
915
+ if (valueToCheck.match(new RegExp(`${wildcards}`))) {
916
+ logger_js.logger.debug(`The '$capture' parameter contains an Express-style wildcard ` + `character (${wildcards}). Strings are now always interpreted as ` + `exact matches; use a RegExp for partial or wildcard matches.`);
917
+ }
918
+ }
919
+
920
+ const matchCallback = ({
921
+ url
922
+ }) => {
923
+ {
924
+ if (url.pathname === captureUrl.pathname && url.origin !== captureUrl.origin) {
925
+ logger_js.logger.debug(`${capture} only partially matches the cross-origin URL ` + `${url}. This route will only handle cross-origin requests ` + `if they match the entire URL.`);
926
+ }
927
+ }
928
+
929
+ return url.href === captureUrl.href;
930
+ }; // If `capture` is a string then `handler` and `method` must be present.
931
+
932
+
933
+ route = new Route(matchCallback, handler, method);
934
+ } else if (capture instanceof RegExp) {
935
+ // If `capture` is a `RegExp` then `handler` and `method` must be present.
936
+ route = new RegExpRoute(capture, handler, method);
937
+ } else if (typeof capture === 'function') {
938
+ // If `capture` is a function then `handler` and `method` must be present.
939
+ route = new Route(capture, handler, method);
940
+ } else if (capture instanceof Route) {
941
+ route = capture;
942
+ } else {
943
+ throw new WorkboxError_js.WorkboxError('unsupported-route-type', {
944
+ moduleName: 'workbox-routing',
945
+ funcName: 'registerRoute',
946
+ paramName: 'capture'
947
+ });
948
+ }
949
+
950
+ const defaultRouter = getOrCreateDefaultRouter();
951
+ defaultRouter.registerRoute(route);
952
+ return route;
953
+ };
954
+
955
+ /*
956
+ Copyright 2019 Google LLC
957
+
958
+ Use of this source code is governed by an MIT-style
959
+ license that can be found in the LICENSE file or at
960
+ https://opensource.org/licenses/MIT.
961
+ */
962
+ /**
963
+ * If a Route throws an error while handling a request, this `handler`
964
+ * will be called and given a chance to provide a response.
965
+ *
966
+ * @param {workbox.routing.Route~handlerCallback} handler A callback
967
+ * function that returns a Promise resulting in a Response.
968
+ *
969
+ * @alias workbox.routing.setCatchHandler
970
+ */
971
+
972
+ const setCatchHandler = handler => {
973
+ const defaultRouter = getOrCreateDefaultRouter();
974
+ defaultRouter.setCatchHandler(handler);
975
+ };
976
+
977
+ /*
978
+ Copyright 2019 Google LLC
979
+
980
+ Use of this source code is governed by an MIT-style
981
+ license that can be found in the LICENSE file or at
982
+ https://opensource.org/licenses/MIT.
983
+ */
984
+ /**
985
+ * Define a default `handler` that's called when no routes explicitly
986
+ * match the incoming request.
987
+ *
988
+ * Without a default handler, unmatched requests will go against the
989
+ * network as if there were no service worker present.
990
+ *
991
+ * @param {workbox.routing.Route~handlerCallback} handler A callback
992
+ * function that returns a Promise resulting in a Response.
993
+ *
994
+ * @alias workbox.routing.setDefaultHandler
995
+ */
996
+
997
+ const setDefaultHandler = handler => {
998
+ const defaultRouter = getOrCreateDefaultRouter();
999
+ defaultRouter.setDefaultHandler(handler);
1000
+ };
1001
+
1002
+ /*
1003
+ Copyright 2018 Google LLC
1004
+
1005
+ Use of this source code is governed by an MIT-style
1006
+ license that can be found in the LICENSE file or at
1007
+ https://opensource.org/licenses/MIT.
1008
+ */
1009
+
1010
+ {
1011
+ assert_js.assert.isSWEnv('workbox-routing');
1012
+ }
1013
+
1014
+ exports.NavigationRoute = NavigationRoute;
1015
+ exports.RegExpRoute = RegExpRoute;
1016
+ exports.Route = Route;
1017
+ exports.Router = Router;
1018
+ exports.registerNavigationRoute = registerNavigationRoute;
1019
+ exports.registerRoute = registerRoute;
1020
+ exports.setCatchHandler = setCatchHandler;
1021
+ exports.setDefaultHandler = setDefaultHandler;
1022
+
1023
+ return exports;
1024
+
1025
+ }({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
1026
+ //# sourceMappingURL=workbox-routing.dev.js.map