jekyll-pwa-workbox 0.0.6 → 0.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-pwa-workbox.rb +2 -2
  3. data/lib/vendor/workbox-v5.1.3/workbox-background-sync.dev.js +818 -0
  4. data/lib/vendor/workbox-v5.1.3/workbox-background-sync.dev.js.map +1 -0
  5. data/lib/vendor/workbox-v5.1.3/workbox-background-sync.prod.js +2 -0
  6. data/lib/vendor/workbox-v5.1.3/workbox-background-sync.prod.js.map +1 -0
  7. data/lib/vendor/workbox-v5.1.3/workbox-broadcast-update.dev.js +288 -0
  8. data/lib/vendor/workbox-v5.1.3/workbox-broadcast-update.dev.js.map +1 -0
  9. data/lib/vendor/workbox-v5.1.3/workbox-broadcast-update.prod.js +2 -0
  10. data/lib/vendor/workbox-v5.1.3/workbox-broadcast-update.prod.js.map +1 -0
  11. data/lib/vendor/workbox-v5.1.3/workbox-cacheable-response.dev.js +191 -0
  12. data/lib/vendor/workbox-v5.1.3/workbox-cacheable-response.dev.js.map +1 -0
  13. data/lib/vendor/workbox-v5.1.3/workbox-cacheable-response.prod.js +2 -0
  14. data/lib/vendor/workbox-v5.1.3/workbox-cacheable-response.prod.js.map +1 -0
  15. data/lib/vendor/workbox-v5.1.3/workbox-core.dev.js +1858 -0
  16. data/lib/vendor/workbox-v5.1.3/workbox-core.dev.js.map +1 -0
  17. data/lib/vendor/workbox-v5.1.3/workbox-core.prod.js +2 -0
  18. data/lib/vendor/workbox-v5.1.3/workbox-core.prod.js.map +1 -0
  19. data/lib/vendor/workbox-v5.1.3/workbox-expiration.dev.js +649 -0
  20. data/lib/vendor/workbox-v5.1.3/workbox-expiration.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v5.1.3/workbox-expiration.prod.js +2 -0
  22. data/lib/vendor/workbox-v5.1.3/workbox-expiration.prod.js.map +1 -0
  23. data/lib/vendor/workbox-v5.1.3/workbox-navigation-preload.dev.js +102 -0
  24. data/lib/vendor/workbox-v5.1.3/workbox-navigation-preload.dev.js.map +1 -0
  25. data/lib/vendor/{workbox-v4.3.1 → workbox-v5.1.3}/workbox-navigation-preload.prod.js +1 -1
  26. data/lib/vendor/workbox-v5.1.3/workbox-navigation-preload.prod.js.map +1 -0
  27. data/lib/vendor/workbox-v5.1.3/workbox-offline-ga.dev.js +235 -0
  28. data/lib/vendor/workbox-v5.1.3/workbox-offline-ga.dev.js.map +1 -0
  29. data/lib/vendor/workbox-v5.1.3/workbox-offline-ga.prod.js +2 -0
  30. data/lib/vendor/workbox-v5.1.3/workbox-offline-ga.prod.js.map +1 -0
  31. data/lib/vendor/workbox-v5.1.3/workbox-precaching.dev.js +1210 -0
  32. data/lib/vendor/workbox-v5.1.3/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v5.1.3/workbox-precaching.prod.js +2 -0
  34. data/lib/vendor/workbox-v5.1.3/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/workbox-v5.1.3/workbox-range-requests.dev.js +262 -0
  36. data/lib/vendor/workbox-v5.1.3/workbox-range-requests.dev.js.map +1 -0
  37. data/lib/vendor/workbox-v5.1.3/workbox-range-requests.prod.js +2 -0
  38. data/lib/vendor/workbox-v5.1.3/workbox-range-requests.prod.js.map +1 -0
  39. data/lib/vendor/workbox-v5.1.3/workbox-routing.dev.js +923 -0
  40. data/lib/vendor/workbox-v5.1.3/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/workbox-v5.1.3/workbox-routing.prod.js +2 -0
  42. data/lib/vendor/workbox-v5.1.3/workbox-routing.prod.js.map +1 -0
  43. data/lib/vendor/workbox-v5.1.3/workbox-strategies.dev.js +923 -0
  44. data/lib/vendor/workbox-v5.1.3/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v5.1.3/workbox-strategies.prod.js +2 -0
  46. data/lib/vendor/workbox-v5.1.3/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/workbox-v5.1.3/workbox-streams.dev.js +318 -0
  48. data/lib/vendor/workbox-v5.1.3/workbox-streams.dev.js.map +1 -0
  49. data/lib/vendor/workbox-v5.1.3/workbox-streams.prod.js +2 -0
  50. data/lib/vendor/workbox-v5.1.3/workbox-streams.prod.js.map +1 -0
  51. data/lib/vendor/workbox-v5.1.3/workbox-sw.js +2 -0
  52. data/lib/vendor/workbox-v5.1.3/workbox-sw.js.map +1 -0
  53. data/lib/vendor/workbox-v5.1.3/workbox-window.dev.es5.mjs +1094 -0
  54. data/lib/vendor/workbox-v5.1.3/workbox-window.dev.es5.mjs.map +1 -0
  55. data/lib/vendor/workbox-v5.1.3/workbox-window.dev.mjs +943 -0
  56. data/lib/vendor/workbox-v5.1.3/workbox-window.dev.mjs.map +1 -0
  57. data/lib/vendor/workbox-v5.1.3/workbox-window.dev.umd.js +1105 -0
  58. data/lib/vendor/workbox-v5.1.3/workbox-window.dev.umd.js.map +1 -0
  59. data/lib/vendor/workbox-v5.1.3/workbox-window.prod.es5.mjs +2 -0
  60. data/lib/vendor/workbox-v5.1.3/workbox-window.prod.es5.mjs.map +1 -0
  61. data/lib/vendor/workbox-v5.1.3/workbox-window.prod.mjs +2 -0
  62. data/lib/vendor/workbox-v5.1.3/workbox-window.prod.mjs.map +1 -0
  63. data/lib/vendor/workbox-v5.1.3/workbox-window.prod.umd.js +2 -0
  64. data/lib/vendor/workbox-v5.1.3/workbox-window.prod.umd.js.map +1 -0
  65. metadata +73 -78
  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.map +0 -1
  89. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js +0 -243
  90. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js.map +0 -1
  91. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js +0 -2
  92. data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js.map +0 -1
  93. data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js +0 -989
  94. data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js.map +0 -1
  95. data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js +0 -2
  96. data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js.map +0 -1
  97. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js +0 -268
  98. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js.map +0 -1
  99. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js +0 -2
  100. data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js.map +0 -1
  101. data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js +0 -1020
  102. data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js.map +0 -1
  103. data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js +0 -2
  104. data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js.map +0 -1
  105. data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js +0 -1138
  106. data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js.map +0 -1
  107. data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js +0 -2
  108. data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js.map +0 -1
  109. data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js +0 -337
  110. data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js.map +0 -1
  111. data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js +0 -2
  112. data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js.map +0 -1
  113. data/lib/vendor/workbox-v4.3.1/workbox-sw.js +0 -2
  114. data/lib/vendor/workbox-v4.3.1/workbox-sw.js.map +0 -1
  115. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.es5.mjs +0 -885
  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 +0 -751
  118. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.mjs.map +0 -1
  119. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js +0 -896
  120. data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js.map +0 -1
  121. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs +0 -2
  122. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs.map +0 -1
  123. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs +0 -2
  124. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs.map +0 -1
  125. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js +0 -2
  126. data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-strategies.dev.js","sources":["../_version.js","../utils/messages.js","../CacheFirst.js","../CacheOnly.js","../plugins/cacheOkAndOpaquePlugin.js","../NetworkFirst.js","../NetworkOnly.js","../StaleWhileRevalidate.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:strategies:5.1.3'] && _();\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 { logger } from 'workbox-core/_private/logger.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport '../_version.js';\nexport const messages = {\n strategyStart: (strategyName, request) => `Using ${strategyName} to respond to '${getFriendlyURL(request.url)}'`,\n printFinalResponse: (response) => {\n if (response) {\n logger.groupCollapsed(`View the final response here.`);\n logger.log(response || '[No response returned]');\n logger.groupEnd();\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 { 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 { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport './_version.js';\n/**\n * An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network}\n * request strategy.\n *\n * A cache first strategy is useful for assets that have been revisioned,\n * such as URLs like `/styles/example.a8f5f1.css`, since they\n * can be cached for long periods of time.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass CacheFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions;\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n const logs = [];\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheFirst',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n let error;\n if (!response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`No response found in the '${this._cacheName}' cache. ` +\n `Will respond with a network request.`);\n }\n try {\n response = await this._getFromNetwork(request, event);\n }\n catch (err) {\n error = err;\n }\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n }\n else {\n logs.push(`Unable to get a response from the network.`);\n }\n }\n }\n else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Found a cached response in the '${this._cacheName}' cache.`);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('CacheFirst', request));\n for (const log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url, error });\n }\n return response;\n }\n /**\n * Handles the network and cache part of CacheFirst.\n *\n * @param {Request} request\n * @param {Event} [event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork(request, event) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n // Keep the service worker while we put the request to the cache\n const responseClone = response.clone();\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n return response;\n }\n}\nexport { CacheFirst };\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 { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If there is no cache match, this will throw a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass CacheOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheOnly',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n const response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('CacheOnly', request));\n if (response) {\n logger.log(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n messages.printFinalResponse(response);\n }\n else {\n logger.log(`No response found in the '${this._cacheName}' cache.`);\n }\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url });\n }\n return response;\n }\n}\nexport { CacheOnly };\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\nexport const cacheOkAndOpaquePlugin = {\n /**\n * Returns a valid response (to allow caching) if the status is 200 (OK) or\n * 0 (opaque).\n *\n * @param {Object} options\n * @param {Response} options.response\n * @return {Response|null}\n *\n * @private\n */\n cacheWillUpdate: async ({ response }) => {\n if (response.status === 200 || response.status === 0) {\n return response;\n }\n return null;\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 { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport { cacheOkAndOpaquePlugin } from './plugins/cacheOkAndOpaquePlugin.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache}\n * request strategy.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass NetworkFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n * @param {number} options.networkTimeoutSeconds If set, any network requests\n * that fail to respond within the timeout will fallback to the cache.\n *\n * This option can be used to combat\n * \"[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}\"\n * scenarios.\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n if (options.plugins) {\n const isUsingCacheWillUpdate = options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n }\n else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n this._networkTimeoutSeconds = options.networkTimeoutSeconds || 0;\n if (process.env.NODE_ENV !== 'production') {\n if (this._networkTimeoutSeconds) {\n assert.isType(this._networkTimeoutSeconds, 'number', {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'constructor',\n paramName: 'networkTimeoutSeconds',\n });\n }\n }\n this._fetchOptions = options.fetchOptions;\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n const logs = [];\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'handle',\n paramName: 'makeRequest',\n });\n }\n const promises = [];\n let timeoutId;\n if (this._networkTimeoutSeconds) {\n const { id, promise } = this._getTimeoutPromise({ request, event, logs });\n timeoutId = id;\n promises.push(promise);\n }\n const networkPromise = this._getNetworkPromise({ timeoutId, request, event, logs });\n promises.push(networkPromise);\n // Promise.race() will resolve as soon as the first promise resolves.\n let response = await Promise.race(promises);\n // If Promise.race() resolved with null, it might be due to a network\n // timeout + a cache miss. If that were to happen, we'd rather wait until\n // the networkPromise resolves instead of returning null.\n // Note that it's fine to await an already-resolved promise, so we don't\n // have to check to see if it's still \"in flight\".\n if (!response) {\n response = await networkPromise;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('NetworkFirst', request));\n for (const log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url });\n }\n return response;\n }\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs array\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n _getTimeoutPromise({ request, logs, event }) {\n let timeoutId;\n const timeoutPromise = new Promise((resolve) => {\n const onNetworkTimeout = async () => {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Timing out the network response at ` +\n `${this._networkTimeoutSeconds} seconds.`);\n }\n resolve(await this._respondFromCache({ request, event }));\n };\n timeoutId = setTimeout(onNetworkTimeout, this._networkTimeoutSeconds * 1000);\n });\n return {\n promise: timeoutPromise,\n id: timeoutId,\n };\n }\n /**\n * @param {Object} options\n * @param {number|undefined} options.timeoutId\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs Array.\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getNetworkPromise({ timeoutId, request, logs, event }) {\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n }\n catch (err) {\n error = err;\n }\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n }\n else {\n logs.push(`Unable to get a response from the network. Will respond ` +\n `with a cached response.`);\n }\n }\n if (error || !response) {\n response = await this._respondFromCache({ request, event });\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n }\n else {\n logs.push(`No response found in the '${this._cacheName}' cache.`);\n }\n }\n }\n else {\n // Keep the service worker alive while we put the request in the cache\n const responseClone = response.clone();\n const cachePut = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n if (event) {\n try {\n // The event has been responded to so we can keep the SW alive to\n // respond to the request\n event.waitUntil(cachePut);\n }\n catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n }\n return response;\n }\n /**\n * Used if the network timeouts or fails to make the request.\n *\n * @param {Object} options\n * @param {Request} request The request to match in the cache\n * @param {Event} [options.event]\n * @return {Promise<Object>}\n *\n * @private\n */\n _respondFromCache({ event, request }) {\n return cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n }\n}\nexport { NetworkFirst };\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 { fetchWrapper } from 'workbox-core/_private/fetchWrapper.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If the network request fails, this will throw a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass NetworkOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n */\n constructor(options = {}) {\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkOnly',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n }\n catch (err) {\n error = err;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('NetworkOnly', request));\n if (response) {\n logger.log(`Got response from network.`);\n }\n else {\n logger.log(`Unable to get a response from the network.`);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url, error });\n }\n return response;\n }\n}\nexport { NetworkOnly };\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 { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport { cacheOkAndOpaquePlugin } from './plugins/cacheOkAndOpaquePlugin.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate}\n * request strategy.\n *\n * Resources are requested from both the cache and the network in parallel.\n * The strategy will respond with the cached version if available, otherwise\n * wait for the network response. The cache is updated with the network response\n * with each successful request.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass StaleWhileRevalidate {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n if (options.plugins) {\n const isUsingCacheWillUpdate = options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n }\n else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n this._fetchOptions = options.fetchOptions;\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n const logs = [];\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'StaleWhileRevalidate',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n const fetchAndCachePromise = this._getFromNetwork({ request, event });\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n let error;\n if (response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache. Will update with the network response in the background.`);\n }\n if (event) {\n try {\n event.waitUntil(fetchAndCachePromise);\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n }\n else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`No response found in the '${this._cacheName}' cache. ` +\n `Will wait for the network response.`);\n }\n try {\n response = await fetchAndCachePromise;\n }\n catch (err) {\n error = err;\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('StaleWhileRevalidate', request));\n for (const log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url, error });\n }\n return response;\n }\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork({ request, event }) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: response.clone(),\n event,\n plugins: this._plugins,\n });\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n return response;\n }\n}\nexport { StaleWhileRevalidate };\n"],"names":["self","_","e","messages","strategyStart","strategyName","request","getFriendlyURL","url","printFinalResponse","response","logger","groupCollapsed","log","groupEnd","CacheFirst","constructor","options","_cacheName","cacheNames","getRuntimeName","cacheName","_plugins","plugins","_fetchOptions","fetchOptions","_matchOptions","matchOptions","handle","event","logs","Request","assert","isInstance","moduleName","className","funcName","paramName","cacheWrapper","match","error","push","_getFromNetwork","err","WorkboxError","fetchWrapper","fetch","responseClone","clone","cachePutPromise","put","waitUntil","warn","CacheOnly","cacheOkAndOpaquePlugin","cacheWillUpdate","status","NetworkFirst","isUsingCacheWillUpdate","some","plugin","_networkTimeoutSeconds","networkTimeoutSeconds","isType","promises","timeoutId","id","promise","_getTimeoutPromise","networkPromise","_getNetworkPromise","Promise","race","timeoutPromise","resolve","onNetworkTimeout","_respondFromCache","setTimeout","clearTimeout","cachePut","NetworkOnly","StaleWhileRevalidate","fetchAndCachePromise"],"mappings":";;;;IAEA,IAAI;IACAA,EAAAA,IAAI,CAAC,0BAAD,CAAJ,IAAoCC,CAAC,EAArC;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICLV;;;;;;;AAOA,IAGO,MAAMC,QAAQ,GAAG;IACpBC,EAAAA,aAAa,EAAE,CAACC,YAAD,EAAeC,OAAf,KAA4B,SAAQD,YAAa,mBAAkBE,gCAAc,CAACD,OAAO,CAACE,GAAT,CAAc,GAD1F;IAEpBC,EAAAA,kBAAkB,EAAGC,QAAD,IAAc;IAC9B,QAAIA,QAAJ,EAAc;IACVC,MAAAA,gBAAM,CAACC,cAAP,CAAuB,+BAAvB;IACAD,MAAAA,gBAAM,CAACE,GAAP,CAAWH,QAAQ,IAAI,wBAAvB;IACAC,MAAAA,gBAAM,CAACG,QAAP;IACH;IACJ;IARmB,CAAjB;;ICVP;;;;;;;AAOA,IASA;;;;;;;;;;;;;;IAaA,MAAMC,UAAN,CAAiB;IACb;;;;;;;;;;;;IAYAC,EAAAA,WAAW,CAACC,OAAO,GAAG,EAAX,EAAe;IACtB,SAAKC,UAAL,GAAkBC,wBAAU,CAACC,cAAX,CAA0BH,OAAO,CAACI,SAAlC,CAAlB;IACA,SAAKC,QAAL,GAAgBL,OAAO,CAACM,OAAR,IAAmB,EAAnC;IACA,SAAKC,aAAL,GAAqBP,OAAO,CAACQ,YAA7B;IACA,SAAKC,aAAL,GAAqBT,OAAO,CAACU,YAA7B;IACH;IACD;;;;;;;;;;;;IAUA,QAAMC,MAAN,CAAa;IAAEC,IAAAA,KAAF;IAASvB,IAAAA;IAAT,GAAb,EAAiC;IAC7B,UAAMwB,IAAI,GAAG,EAAb;;IACA,QAAI,OAAOxB,OAAP,KAAmB,QAAvB,EAAiC;IAC7BA,MAAAA,OAAO,GAAG,IAAIyB,OAAJ,CAAYzB,OAAZ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P,UAAI;IACAA,QAAAA,KAAK,CAACsB,SAAN,CAAgBF,eAAhB;IACH,OAFD,CAGA,OAAOT,KAAP,EAAc;IACV,QAA2C;IACvC7B,UAAAA,gBAAM,CAACyC,IAAP,CAAa,mDAAD,GACP,uBAAsB7C,gCAAc,CAACD,OAAO,CAACE,GAAT,CAAc,IADvD;IAEH;IACJ;IACJ;;IACD,WAAOE,QAAP;IACH;;IAxIsB;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ this.workbox=this.workbox||{},this.workbox.strategies=function(t,e,s,i,n){"use strict";try{self["workbox:strategies:5.1.3"]&&_()}catch(t){}const r={cacheWillUpdate:async({response:t})=>200===t.status||0===t.status?t:null};return t.CacheFirst=class{constructor(t={}){this.t=e.cacheNames.getRuntimeName(t.cacheName),this.s=t.plugins||[],this.i=t.fetchOptions,this.h=t.matchOptions}async handle({event:t,request:e}){"string"==typeof e&&(e=new Request(e));let i,r=await s.cacheWrapper.match({cacheName:this.t,request:e,event:t,matchOptions:this.h,plugins:this.s});if(!r)try{r=await this.o(e,t)}catch(t){i=t}if(!r)throw new n.WorkboxError("no-response",{url:e.url,error:i});return r}async o(t,e){const n=await i.fetchWrapper.fetch({request:t,event:e,fetchOptions:this.i,plugins:this.s}),r=n.clone(),h=s.cacheWrapper.put({cacheName:this.t,request:t,response:r,event:e,plugins:this.s});if(e)try{e.waitUntil(h)}catch(t){}return n}},t.CacheOnly=class{constructor(t={}){this.t=e.cacheNames.getRuntimeName(t.cacheName),this.s=t.plugins||[],this.h=t.matchOptions}async handle({event:t,request:e}){"string"==typeof e&&(e=new Request(e));const i=await s.cacheWrapper.match({cacheName:this.t,request:e,event:t,matchOptions:this.h,plugins:this.s});if(!i)throw new n.WorkboxError("no-response",{url:e.url});return i}},t.NetworkFirst=class{constructor(t={}){if(this.t=e.cacheNames.getRuntimeName(t.cacheName),t.plugins){const e=t.plugins.some(t=>!!t.cacheWillUpdate);this.s=e?t.plugins:[r,...t.plugins]}else this.s=[r];this.u=t.networkTimeoutSeconds||0,this.i=t.fetchOptions,this.h=t.matchOptions}async handle({event:t,request:e}){const s=[];"string"==typeof e&&(e=new Request(e));const i=[];let r;if(this.u){const{id:n,promise:h}=this.l({request:e,event:t,logs:s});r=n,i.push(h)}const h=this.p({timeoutId:r,request:e,event:t,logs:s});i.push(h);let o=await Promise.race(i);if(o||(o=await h),!o)throw new n.WorkboxError("no-response",{url:e.url});return o}l({request:t,logs:e,event:s}){let i;return{promise:new Promise(e=>{i=setTimeout(async()=>{e(await this.q({request:t,event:s}))},1e3*this.u)}),id:i}}async p({timeoutId:t,request:e,logs:n,event:r}){let h,o;try{o=await i.fetchWrapper.fetch({request:e,event:r,fetchOptions:this.i,plugins:this.s})}catch(t){h=t}if(t&&clearTimeout(t),h||!o)o=await this.q({request:e,event:r});else{const t=o.clone(),i=s.cacheWrapper.put({cacheName:this.t,request:e,response:t,event:r,plugins:this.s});if(r)try{r.waitUntil(i)}catch(t){}}return o}q({event:t,request:e}){return s.cacheWrapper.match({cacheName:this.t,request:e,event:t,matchOptions:this.h,plugins:this.s})}},t.NetworkOnly=class{constructor(t={}){this.s=t.plugins||[],this.i=t.fetchOptions}async handle({event:t,request:e}){let s,r;"string"==typeof e&&(e=new Request(e));try{r=await i.fetchWrapper.fetch({request:e,event:t,fetchOptions:this.i,plugins:this.s})}catch(t){s=t}if(!r)throw new n.WorkboxError("no-response",{url:e.url,error:s});return r}},t.StaleWhileRevalidate=class{constructor(t={}){if(this.t=e.cacheNames.getRuntimeName(t.cacheName),this.s=t.plugins||[],t.plugins){const e=t.plugins.some(t=>!!t.cacheWillUpdate);this.s=e?t.plugins:[r,...t.plugins]}else this.s=[r];this.i=t.fetchOptions,this.h=t.matchOptions}async handle({event:t,request:e}){"string"==typeof e&&(e=new Request(e));const i=this.o({request:e,event:t});let r,h=await s.cacheWrapper.match({cacheName:this.t,request:e,event:t,matchOptions:this.h,plugins:this.s});if(h){if(t)try{t.waitUntil(i)}catch(r){}}else try{h=await i}catch(t){r=t}if(!h)throw new n.WorkboxError("no-response",{url:e.url,error:r});return h}async o({request:t,event:e}){const n=await i.fetchWrapper.fetch({request:t,event:e,fetchOptions:this.i,plugins:this.s}),r=s.cacheWrapper.put({cacheName:this.t,request:t,response:n.clone(),event:e,plugins:this.s});if(e)try{e.waitUntil(r)}catch(t){}return n}},t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
2
+ //# sourceMappingURL=workbox-strategies.prod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-strategies.prod.js","sources":["../_version.js","../plugins/cacheOkAndOpaquePlugin.js","../CacheFirst.js","../CacheOnly.js","../NetworkFirst.js","../NetworkOnly.js","../StaleWhileRevalidate.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:strategies:5.1.3'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\nexport const cacheOkAndOpaquePlugin = {\n /**\n * Returns a valid response (to allow caching) if the status is 200 (OK) or\n * 0 (opaque).\n *\n * @param {Object} options\n * @param {Response} options.response\n * @return {Response|null}\n *\n * @private\n */\n cacheWillUpdate: async ({ response }) => {\n if (response.status === 200 || response.status === 0) {\n return response;\n }\n return null;\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 { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport './_version.js';\n/**\n * An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network}\n * request strategy.\n *\n * A cache first strategy is useful for assets that have been revisioned,\n * such as URLs like `/styles/example.a8f5f1.css`, since they\n * can be cached for long periods of time.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass CacheFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions;\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n const logs = [];\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheFirst',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n let error;\n if (!response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`No response found in the '${this._cacheName}' cache. ` +\n `Will respond with a network request.`);\n }\n try {\n response = await this._getFromNetwork(request, event);\n }\n catch (err) {\n error = err;\n }\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n }\n else {\n logs.push(`Unable to get a response from the network.`);\n }\n }\n }\n else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Found a cached response in the '${this._cacheName}' cache.`);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('CacheFirst', request));\n for (const log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url, error });\n }\n return response;\n }\n /**\n * Handles the network and cache part of CacheFirst.\n *\n * @param {Request} request\n * @param {Event} [event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork(request, event) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n // Keep the service worker while we put the request to the cache\n const responseClone = response.clone();\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n return response;\n }\n}\nexport { CacheFirst };\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 { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If there is no cache match, this will throw a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass CacheOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'CacheOnly',\n funcName: 'makeRequest',\n paramName: 'request',\n });\n }\n const response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('CacheOnly', request));\n if (response) {\n logger.log(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n messages.printFinalResponse(response);\n }\n else {\n logger.log(`No response found in the '${this._cacheName}' cache.`);\n }\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url });\n }\n return response;\n }\n}\nexport { CacheOnly };\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 { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport { cacheOkAndOpaquePlugin } from './plugins/cacheOkAndOpaquePlugin.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache}\n * request strategy.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass NetworkFirst {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n * @param {number} options.networkTimeoutSeconds If set, any network requests\n * that fail to respond within the timeout will fallback to the cache.\n *\n * This option can be used to combat\n * \"[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}\"\n * scenarios.\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n if (options.plugins) {\n const isUsingCacheWillUpdate = options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n }\n else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n this._networkTimeoutSeconds = options.networkTimeoutSeconds || 0;\n if (process.env.NODE_ENV !== 'production') {\n if (this._networkTimeoutSeconds) {\n assert.isType(this._networkTimeoutSeconds, 'number', {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'constructor',\n paramName: 'networkTimeoutSeconds',\n });\n }\n }\n this._fetchOptions = options.fetchOptions;\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n const logs = [];\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkFirst',\n funcName: 'handle',\n paramName: 'makeRequest',\n });\n }\n const promises = [];\n let timeoutId;\n if (this._networkTimeoutSeconds) {\n const { id, promise } = this._getTimeoutPromise({ request, event, logs });\n timeoutId = id;\n promises.push(promise);\n }\n const networkPromise = this._getNetworkPromise({ timeoutId, request, event, logs });\n promises.push(networkPromise);\n // Promise.race() will resolve as soon as the first promise resolves.\n let response = await Promise.race(promises);\n // If Promise.race() resolved with null, it might be due to a network\n // timeout + a cache miss. If that were to happen, we'd rather wait until\n // the networkPromise resolves instead of returning null.\n // Note that it's fine to await an already-resolved promise, so we don't\n // have to check to see if it's still \"in flight\".\n if (!response) {\n response = await networkPromise;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('NetworkFirst', request));\n for (const log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url });\n }\n return response;\n }\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs array\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n _getTimeoutPromise({ request, logs, event }) {\n let timeoutId;\n const timeoutPromise = new Promise((resolve) => {\n const onNetworkTimeout = async () => {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Timing out the network response at ` +\n `${this._networkTimeoutSeconds} seconds.`);\n }\n resolve(await this._respondFromCache({ request, event }));\n };\n timeoutId = setTimeout(onNetworkTimeout, this._networkTimeoutSeconds * 1000);\n });\n return {\n promise: timeoutPromise,\n id: timeoutId,\n };\n }\n /**\n * @param {Object} options\n * @param {number|undefined} options.timeoutId\n * @param {Request} options.request\n * @param {Array} options.logs A reference to the logs Array.\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getNetworkPromise({ timeoutId, request, logs, event }) {\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n }\n catch (err) {\n error = err;\n }\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Got response from network.`);\n }\n else {\n logs.push(`Unable to get a response from the network. Will respond ` +\n `with a cached response.`);\n }\n }\n if (error || !response) {\n response = await this._respondFromCache({ request, event });\n if (process.env.NODE_ENV !== 'production') {\n if (response) {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache.`);\n }\n else {\n logs.push(`No response found in the '${this._cacheName}' cache.`);\n }\n }\n }\n else {\n // Keep the service worker alive while we put the request in the cache\n const responseClone = response.clone();\n const cachePut = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: responseClone,\n event,\n plugins: this._plugins,\n });\n if (event) {\n try {\n // The event has been responded to so we can keep the SW alive to\n // respond to the request\n event.waitUntil(cachePut);\n }\n catch (err) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n }\n return response;\n }\n /**\n * Used if the network timeouts or fails to make the request.\n *\n * @param {Object} options\n * @param {Request} request The request to match in the cache\n * @param {Event} [options.event]\n * @return {Promise<Object>}\n *\n * @private\n */\n _respondFromCache({ event, request }) {\n return cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n }\n}\nexport { NetworkFirst };\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 { fetchWrapper } from 'workbox-core/_private/fetchWrapper.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only}\n * request strategy.\n *\n * This class is useful if you want to take advantage of any\n * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.\n *\n * If the network request fails, this will throw a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass NetworkOnly {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n */\n constructor(options = {}) {\n this._plugins = options.plugins || [];\n this._fetchOptions = options.fetchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request The request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'NetworkOnly',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n let error;\n let response;\n try {\n response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n }\n catch (err) {\n error = err;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('NetworkOnly', request));\n if (response) {\n logger.log(`Got response from network.`);\n }\n else {\n logger.log(`Unable to get a response from the network.`);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url, error });\n }\n return response;\n }\n}\nexport { NetworkOnly };\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 { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { messages } from './utils/messages.js';\nimport { cacheOkAndOpaquePlugin } from './plugins/cacheOkAndOpaquePlugin.js';\nimport './_version.js';\n/**\n * An implementation of a\n * [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate}\n * request strategy.\n *\n * Resources are requested from both the cache and the network in parallel.\n * The strategy will respond with the cached version if available, otherwise\n * wait for the network response. The cache is updated with the network response\n * with each successful request.\n *\n * By default, this strategy will cache responses with a 200 status code as\n * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.\n * Opaque responses are cross-origin requests where the response doesn't\n * support [CORS]{@link https://enable-cors.org/}.\n *\n * If the network request fails, and there is no cache match, this will throw\n * a `WorkboxError` exception.\n *\n * @memberof module:workbox-strategies\n */\nclass StaleWhileRevalidate {\n /**\n * @param {Object} options\n * @param {string} options.cacheName Cache name to store and retrieve\n * requests. Defaults to cache names provided by\n * [workbox-core]{@link module:workbox-core.cacheNames}.\n * @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}\n * to use in conjunction with this caching strategy.\n * @param {Object} options.fetchOptions Values passed along to the\n * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)\n * of all fetch() requests made by this strategy.\n * @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)\n */\n constructor(options = {}) {\n this._cacheName = cacheNames.getRuntimeName(options.cacheName);\n this._plugins = options.plugins || [];\n if (options.plugins) {\n const isUsingCacheWillUpdate = options.plugins.some((plugin) => !!plugin.cacheWillUpdate);\n this._plugins = isUsingCacheWillUpdate ?\n options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];\n }\n else {\n // No plugins passed in, use the default plugin.\n this._plugins = [cacheOkAndOpaquePlugin];\n }\n this._fetchOptions = options.fetchOptions;\n this._matchOptions = options.matchOptions;\n }\n /**\n * This method will perform a request strategy and follows an API that\n * will work with the\n * [Workbox Router]{@link module:workbox-routing.Router}.\n *\n * @param {Object} options\n * @param {Request|string} options.request A request to run this strategy for.\n * @param {Event} [options.event] The event that triggered the request.\n * @return {Promise<Response>}\n */\n async handle({ event, request }) {\n const logs = [];\n if (typeof request === 'string') {\n request = new Request(request);\n }\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-strategies',\n className: 'StaleWhileRevalidate',\n funcName: 'handle',\n paramName: 'request',\n });\n }\n const fetchAndCachePromise = this._getFromNetwork({ request, event });\n let response = await cacheWrapper.match({\n cacheName: this._cacheName,\n request,\n event,\n matchOptions: this._matchOptions,\n plugins: this._plugins,\n });\n let error;\n if (response) {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`Found a cached response in the '${this._cacheName}'` +\n ` cache. Will update with the network response in the background.`);\n }\n if (event) {\n try {\n event.waitUntil(fetchAndCachePromise);\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n }\n else {\n if (process.env.NODE_ENV !== 'production') {\n logs.push(`No response found in the '${this._cacheName}' cache. ` +\n `Will wait for the network response.`);\n }\n try {\n response = await fetchAndCachePromise;\n }\n catch (err) {\n error = err;\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(messages.strategyStart('StaleWhileRevalidate', request));\n for (const log of logs) {\n logger.log(log);\n }\n messages.printFinalResponse(response);\n logger.groupEnd();\n }\n if (!response) {\n throw new WorkboxError('no-response', { url: request.url, error });\n }\n return response;\n }\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @param {Event} [options.event]\n * @return {Promise<Response>}\n *\n * @private\n */\n async _getFromNetwork({ request, event }) {\n const response = await fetchWrapper.fetch({\n request,\n event,\n fetchOptions: this._fetchOptions,\n plugins: this._plugins,\n });\n const cachePutPromise = cacheWrapper.put({\n cacheName: this._cacheName,\n request,\n response: response.clone(),\n event,\n plugins: this._plugins,\n });\n if (event) {\n try {\n event.waitUntil(cachePutPromise);\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to ensure service worker stays alive when ` +\n `updating cache for '${getFriendlyURL(request.url)}'.`);\n }\n }\n }\n return response;\n }\n}\nexport { StaleWhileRevalidate };\n"],"names":["self","_","e","cacheOkAndOpaquePlugin","cacheWillUpdate","async","response","status","constructor","options","_cacheName","cacheNames","getRuntimeName","cacheName","_plugins","plugins","_fetchOptions","fetchOptions","_matchOptions","matchOptions","event","request","Request","error","cacheWrapper","match","this","_getFromNetwork","err","WorkboxError","url","fetchWrapper","fetch","responseClone","clone","cachePutPromise","put","waitUntil","isUsingCacheWillUpdate","some","plugin","_networkTimeoutSeconds","networkTimeoutSeconds","logs","promises","timeoutId","id","promise","_getTimeoutPromise","push","networkPromise","_getNetworkPromise","Promise","race","resolve","setTimeout","_respondFromCache","clearTimeout","cachePut","fetchAndCachePromise"],"mappings":"uFAEA,IACIA,KAAK,6BAA+BC,IAExC,MAAOC,ICGA,MAAMC,EAAyB,CAWlCC,gBAAiBC,OAASC,SAAAA,KACE,MAApBA,EAASC,QAAsC,IAApBD,EAASC,OAC7BD,EAEJ,0BCMf,MAaIE,YAAYC,EAAU,SACbC,EAAaC,aAAWC,eAAeH,EAAQI,gBAC/CC,EAAWL,EAAQM,SAAW,QAC9BC,EAAgBP,EAAQQ,kBACxBC,EAAgBT,EAAQU,2BAYpBC,MAAEA,EAAFC,QAASA,IAEK,iBAAZA,IACPA,EAAU,IAAIC,QAAQD,QAiBtBE,EAPAjB,QAAiBkB,eAAaC,MAAM,CACpCZ,UAAWa,KAAKhB,EAChBW,QAAAA,EACAD,MAAAA,EACAD,aAAcO,KAAKR,EACnBH,QAASW,KAAKZ,QAGbR,MAMGA,QA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CACtCX,QAAAA,EACAD,MAAAA,EACAH,aAAcS,KAAKV,EACnBD,QAASW,KAAKZ,IAEZqB,EAAkBX,eAAaY,IAAI,CACrCvB,UAAWa,KAAKhB,EAChBW,QAAAA,EACAf,SAAUA,EAAS4B,QACnBd,MAAAA,EACAL,QAASW,KAAKZ,OAEdM,MAEIA,EAAMiB,UAAUF,GAEpB,MAAOZ,WAOJjB"}
@@ -0,0 +1,318 @@
1
+ this.workbox = this.workbox || {};
2
+ this.workbox.streams = (function (exports, logger_js, assert_js, Deferred_js, canConstructReadableStream_js) {
3
+ 'use strict';
4
+
5
+ try {
6
+ self['workbox:streams:5.1.3'] && _();
7
+ } catch (e) {}
8
+
9
+ /*
10
+ Copyright 2018 Google LLC
11
+
12
+ Use of this source code is governed by an MIT-style
13
+ license that can be found in the LICENSE file or at
14
+ https://opensource.org/licenses/MIT.
15
+ */
16
+ /**
17
+ * Takes either a Response, a ReadableStream, or a
18
+ * [BodyInit](https://fetch.spec.whatwg.org/#bodyinit) and returns the
19
+ * ReadableStreamReader object associated with it.
20
+ *
21
+ * @param {module:workbox-streams.StreamSource} source
22
+ * @return {ReadableStreamReader}
23
+ * @private
24
+ */
25
+
26
+ function _getReaderFromSource(source) {
27
+ if (source instanceof Response) {
28
+ return source.body.getReader();
29
+ }
30
+
31
+ if (source instanceof ReadableStream) {
32
+ return source.getReader();
33
+ }
34
+
35
+ return new Response(source).body.getReader();
36
+ }
37
+ /**
38
+ * Takes multiple source Promises, each of which could resolve to a Response, a
39
+ * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit).
40
+ *
41
+ * Returns an object exposing a ReadableStream with each individual stream's
42
+ * data returned in sequence, along with a Promise which signals when the
43
+ * stream is finished (useful for passing to a FetchEvent's waitUntil()).
44
+ *
45
+ * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromises
46
+ * @return {Object<{done: Promise, stream: ReadableStream}>}
47
+ *
48
+ * @memberof module:workbox-streams
49
+ */
50
+
51
+
52
+ function concatenate(sourcePromises) {
53
+ {
54
+ assert_js.assert.isArray(sourcePromises, {
55
+ moduleName: 'workbox-streams',
56
+ funcName: 'concatenate',
57
+ paramName: 'sourcePromises'
58
+ });
59
+ }
60
+
61
+ const readerPromises = sourcePromises.map(sourcePromise => {
62
+ return Promise.resolve(sourcePromise).then(source => {
63
+ return _getReaderFromSource(source);
64
+ });
65
+ });
66
+ const streamDeferred = new Deferred_js.Deferred();
67
+ let i = 0;
68
+ const logMessages = [];
69
+ const stream = new ReadableStream({
70
+ pull(controller) {
71
+ return readerPromises[i].then(reader => reader.read()).then(result => {
72
+ if (result.done) {
73
+ {
74
+ logMessages.push(['Reached the end of source:', sourcePromises[i]]);
75
+ }
76
+
77
+ i++;
78
+
79
+ if (i >= readerPromises.length) {
80
+ // Log all the messages in the group at once in a single group.
81
+ {
82
+ logger_js.logger.groupCollapsed(`Concatenating ${readerPromises.length} sources.`);
83
+
84
+ for (const message of logMessages) {
85
+ if (Array.isArray(message)) {
86
+ logger_js.logger.log(...message);
87
+ } else {
88
+ logger_js.logger.log(message);
89
+ }
90
+ }
91
+
92
+ logger_js.logger.log('Finished reading all sources.');
93
+ logger_js.logger.groupEnd();
94
+ }
95
+
96
+ controller.close();
97
+ streamDeferred.resolve();
98
+ return;
99
+ } // The `pull` method is defined because we're inside it.
100
+
101
+
102
+ return this.pull(controller);
103
+ } else {
104
+ controller.enqueue(result.value);
105
+ }
106
+ }).catch(error => {
107
+ {
108
+ logger_js.logger.error('An error occurred:', error);
109
+ }
110
+
111
+ streamDeferred.reject(error);
112
+ throw error;
113
+ });
114
+ },
115
+
116
+ cancel() {
117
+ {
118
+ logger_js.logger.warn('The ReadableStream was cancelled.');
119
+ }
120
+
121
+ streamDeferred.resolve();
122
+ }
123
+
124
+ });
125
+ return {
126
+ done: streamDeferred.promise,
127
+ stream
128
+ };
129
+ }
130
+
131
+ /*
132
+ Copyright 2018 Google LLC
133
+
134
+ Use of this source code is governed by an MIT-style
135
+ license that can be found in the LICENSE file or at
136
+ https://opensource.org/licenses/MIT.
137
+ */
138
+ /**
139
+ * This is a utility method that determines whether the current browser supports
140
+ * the features required to create streamed responses. Currently, it checks if
141
+ * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
142
+ * is available.
143
+ *
144
+ * @private
145
+ * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,
146
+ * `'text/html'` will be used by default.
147
+ * @return {boolean} `true`, if the current browser meets the requirements for
148
+ * streaming responses, and `false` otherwise.
149
+ *
150
+ * @memberof module:workbox-streams
151
+ */
152
+
153
+ function createHeaders(headersInit = {}) {
154
+ // See https://github.com/GoogleChrome/workbox/issues/1461
155
+ const headers = new Headers(headersInit);
156
+
157
+ if (!headers.has('content-type')) {
158
+ headers.set('content-type', 'text/html');
159
+ }
160
+
161
+ return headers;
162
+ }
163
+
164
+ /*
165
+ Copyright 2018 Google LLC
166
+
167
+ Use of this source code is governed by an MIT-style
168
+ license that can be found in the LICENSE file or at
169
+ https://opensource.org/licenses/MIT.
170
+ */
171
+ /**
172
+ * Takes multiple source Promises, each of which could resolve to a Response, a
173
+ * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit),
174
+ * along with a
175
+ * [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit).
176
+ *
177
+ * Returns an object exposing a Response whose body consists of each individual
178
+ * stream's data returned in sequence, along with a Promise which signals when
179
+ * the stream is finished (useful for passing to a FetchEvent's waitUntil()).
180
+ *
181
+ * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromises
182
+ * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,
183
+ * `'text/html'` will be used by default.
184
+ * @return {Object<{done: Promise, response: Response}>}
185
+ *
186
+ * @memberof module:workbox-streams
187
+ */
188
+
189
+ function concatenateToResponse(sourcePromises, headersInit) {
190
+ const {
191
+ done,
192
+ stream
193
+ } = concatenate(sourcePromises);
194
+ const headers = createHeaders(headersInit);
195
+ const response = new Response(stream, {
196
+ headers
197
+ });
198
+ return {
199
+ done,
200
+ response
201
+ };
202
+ }
203
+
204
+ /*
205
+ Copyright 2018 Google LLC
206
+
207
+ Use of this source code is governed by an MIT-style
208
+ license that can be found in the LICENSE file or at
209
+ https://opensource.org/licenses/MIT.
210
+ */
211
+ /**
212
+ * This is a utility method that determines whether the current browser supports
213
+ * the features required to create streamed responses. Currently, it checks if
214
+ * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
215
+ * can be created.
216
+ *
217
+ * @return {boolean} `true`, if the current browser meets the requirements for
218
+ * streaming responses, and `false` otherwise.
219
+ *
220
+ * @memberof module:workbox-streams
221
+ */
222
+
223
+ function isSupported() {
224
+ return canConstructReadableStream_js.canConstructReadableStream();
225
+ }
226
+
227
+ /*
228
+ Copyright 2018 Google LLC
229
+
230
+ Use of this source code is governed by an MIT-style
231
+ license that can be found in the LICENSE file or at
232
+ https://opensource.org/licenses/MIT.
233
+ */
234
+ /**
235
+ * A shortcut to create a strategy that could be dropped-in to Workbox's router.
236
+ *
237
+ * On browsers that do not support constructing new `ReadableStream`s, this
238
+ * strategy will automatically wait for all the `sourceFunctions` to complete,
239
+ * and create a final response that concatenates their values together.
240
+ *
241
+ * @param {Array<function({event, request, url, params})>} sourceFunctions
242
+ * An array of functions similar to {@link module:workbox-routing~handlerCallback}
243
+ * but that instead return a {@link module:workbox-streams.StreamSource} (or a
244
+ * Promise which resolves to one).
245
+ * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,
246
+ * `'text/html'` will be used by default.
247
+ * @return {module:workbox-routing~handlerCallback}
248
+ * @memberof module:workbox-streams
249
+ */
250
+
251
+ function strategy(sourceFunctions, headersInit) {
252
+ return async ({
253
+ event,
254
+ request,
255
+ url,
256
+ params
257
+ }) => {
258
+ const sourcePromises = sourceFunctions.map(fn => {
259
+ // Ensure the return value of the function is always a promise.
260
+ return Promise.resolve(fn({
261
+ event,
262
+ request,
263
+ url,
264
+ params
265
+ }));
266
+ });
267
+
268
+ if (isSupported()) {
269
+ const {
270
+ done,
271
+ response
272
+ } = concatenateToResponse(sourcePromises, headersInit);
273
+
274
+ if (event) {
275
+ event.waitUntil(done);
276
+ }
277
+
278
+ return response;
279
+ }
280
+
281
+ {
282
+ logger_js.logger.log(`The current browser doesn't support creating response ` + `streams. Falling back to non-streaming response instead.`);
283
+ } // Fallback to waiting for everything to finish, and concatenating the
284
+ // responses.
285
+
286
+
287
+ const blobPartsPromises = sourcePromises.map(async sourcePromise => {
288
+ const source = await sourcePromise;
289
+
290
+ if (source instanceof Response) {
291
+ return source.blob();
292
+ } else {
293
+ // Technically, a `StreamSource` object can include any valid
294
+ // `BodyInit` type, including `FormData` and `URLSearchParams`, which
295
+ // cannot be passed to the Blob constructor directly, so we have to
296
+ // convert them to actual Blobs first.
297
+ return new Response(source).blob();
298
+ }
299
+ });
300
+ const blobParts = await Promise.all(blobPartsPromises);
301
+ const headers = createHeaders(headersInit); // Constructing a new Response from a Blob source is well-supported.
302
+ // So is constructing a new Blob from multiple source Blobs or strings.
303
+
304
+ return new Response(new Blob(blobParts), {
305
+ headers
306
+ });
307
+ };
308
+ }
309
+
310
+ exports.concatenate = concatenate;
311
+ exports.concatenateToResponse = concatenateToResponse;
312
+ exports.isSupported = isSupported;
313
+ exports.strategy = strategy;
314
+
315
+ return exports;
316
+
317
+ }({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
318
+ //# sourceMappingURL=workbox-streams.dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-streams.dev.js","sources":["../_version.js","../concatenate.js","../utils/createHeaders.js","../concatenateToResponse.js","../isSupported.js","../strategy.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:streams:5.1.3'] && _();\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 { logger } from 'workbox-core/_private/logger.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\nimport './_version.js';\n/**\n * Takes either a Response, a ReadableStream, or a\n * [BodyInit](https://fetch.spec.whatwg.org/#bodyinit) and returns the\n * ReadableStreamReader object associated with it.\n *\n * @param {module:workbox-streams.StreamSource} source\n * @return {ReadableStreamReader}\n * @private\n */\nfunction _getReaderFromSource(source) {\n if (source instanceof Response) {\n return source.body.getReader();\n }\n if (source instanceof ReadableStream) {\n return source.getReader();\n }\n return new Response(source).body.getReader();\n}\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit).\n *\n * Returns an object exposing a ReadableStream with each individual stream's\n * data returned in sequence, along with a Promise which signals when the\n * stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromises\n * @return {Object<{done: Promise, stream: ReadableStream}>}\n *\n * @memberof module:workbox-streams\n */\nfunction concatenate(sourcePromises) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(sourcePromises, {\n moduleName: 'workbox-streams',\n funcName: 'concatenate',\n paramName: 'sourcePromises',\n });\n }\n const readerPromises = sourcePromises.map((sourcePromise) => {\n return Promise.resolve(sourcePromise).then((source) => {\n return _getReaderFromSource(source);\n });\n });\n const streamDeferred = new Deferred();\n let i = 0;\n const logMessages = [];\n const stream = new ReadableStream({\n pull(controller) {\n return readerPromises[i]\n .then((reader) => reader.read())\n .then((result) => {\n if (result.done) {\n if (process.env.NODE_ENV !== 'production') {\n logMessages.push(['Reached the end of source:',\n sourcePromises[i]]);\n }\n i++;\n if (i >= readerPromises.length) {\n // Log all the messages in the group at once in a single group.\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(`Concatenating ${readerPromises.length} sources.`);\n for (const message of logMessages) {\n if (Array.isArray(message)) {\n logger.log(...message);\n }\n else {\n logger.log(message);\n }\n }\n logger.log('Finished reading all sources.');\n logger.groupEnd();\n }\n controller.close();\n streamDeferred.resolve();\n return;\n }\n // The `pull` method is defined because we're inside it.\n return this.pull(controller);\n }\n else {\n controller.enqueue(result.value);\n }\n }).catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('An error occurred:', error);\n }\n streamDeferred.reject(error);\n throw error;\n });\n },\n cancel() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('The ReadableStream was cancelled.');\n }\n streamDeferred.resolve();\n },\n });\n return { done: streamDeferred.promise, stream };\n}\nexport { concatenate };\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 * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * is available.\n *\n * @private\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof module:workbox-streams\n */\nfunction createHeaders(headersInit = {}) {\n // See https://github.com/GoogleChrome/workbox/issues/1461\n const headers = new Headers(headersInit);\n if (!headers.has('content-type')) {\n headers.set('content-type', 'text/html');\n }\n return headers;\n}\nexport { createHeaders };\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 { createHeaders } from './utils/createHeaders.js';\nimport { concatenate } from './concatenate.js';\nimport './_version.js';\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit),\n * along with a\n * [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit).\n *\n * Returns an object exposing a Response whose body consists of each individual\n * stream's data returned in sequence, along with a Promise which signals when\n * the stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromises\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {Object<{done: Promise, response: Response}>}\n *\n * @memberof module:workbox-streams\n */\nfunction concatenateToResponse(sourcePromises, headersInit) {\n const { done, stream } = concatenate(sourcePromises);\n const headers = createHeaders(headersInit);\n const response = new Response(stream, { headers });\n return { done, response };\n}\nexport { concatenateToResponse };\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 { canConstructReadableStream } from 'workbox-core/_private/canConstructReadableStream.js';\nimport './_version.js';\n/**\n * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * can be created.\n *\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof module:workbox-streams\n */\nfunction isSupported() {\n return canConstructReadableStream();\n}\nexport { isSupported };\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { createHeaders } from './utils/createHeaders.js';\nimport { concatenateToResponse } from './concatenateToResponse.js';\nimport { isSupported } from './isSupported.js';\nimport './_version.js';\n/**\n * A shortcut to create a strategy that could be dropped-in to Workbox's router.\n *\n * On browsers that do not support constructing new `ReadableStream`s, this\n * strategy will automatically wait for all the `sourceFunctions` to complete,\n * and create a final response that concatenates their values together.\n *\n * @param {Array<function({event, request, url, params})>} sourceFunctions\n * An array of functions similar to {@link module:workbox-routing~handlerCallback}\n * but that instead return a {@link module:workbox-streams.StreamSource} (or a\n * Promise which resolves to one).\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {module:workbox-routing~handlerCallback}\n * @memberof module:workbox-streams\n */\nfunction strategy(sourceFunctions, headersInit) {\n return async ({ event, request, url, params }) => {\n const sourcePromises = sourceFunctions.map((fn) => {\n // Ensure the return value of the function is always a promise.\n return Promise.resolve(fn({ event, request, url, params }));\n });\n if (isSupported()) {\n const { done, response } = concatenateToResponse(sourcePromises, headersInit);\n if (event) {\n event.waitUntil(done);\n }\n return response;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The current browser doesn't support creating response ` +\n `streams. Falling back to non-streaming response instead.`);\n }\n // Fallback to waiting for everything to finish, and concatenating the\n // responses.\n const blobPartsPromises = sourcePromises.map(async (sourcePromise) => {\n const source = await sourcePromise;\n if (source instanceof Response) {\n return source.blob();\n }\n else {\n // Technically, a `StreamSource` object can include any valid\n // `BodyInit` type, including `FormData` and `URLSearchParams`, which\n // cannot be passed to the Blob constructor directly, so we have to\n // convert them to actual Blobs first.\n return new Response(source).blob();\n }\n });\n const blobParts = await Promise.all(blobPartsPromises);\n const headers = createHeaders(headersInit);\n // Constructing a new Response from a Blob source is well-supported.\n // So is constructing a new Blob from multiple source Blobs or strings.\n return new Response(new Blob(blobParts), { headers });\n };\n}\nexport { strategy };\n"],"names":["self","_","e","_getReaderFromSource","source","Response","body","getReader","ReadableStream","concatenate","sourcePromises","assert","isArray","moduleName","funcName","paramName","readerPromises","map","sourcePromise","Promise","resolve","then","streamDeferred","Deferred","i","logMessages","stream","pull","controller","reader","read","result","done","push","length","logger","groupCollapsed","message","Array","log","groupEnd","close","enqueue","value","catch","error","reject","cancel","warn","promise","createHeaders","headersInit","headers","Headers","has","set","concatenateToResponse","response","isSupported","canConstructReadableStream","strategy","sourceFunctions","event","request","url","params","fn","waitUntil","blobPartsPromises","blob","blobParts","all","Blob"],"mappings":";;;;IAEA,IAAI;IACAA,EAAAA,IAAI,CAAC,uBAAD,CAAJ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,OAAO,CAACC,OAAR,CAAgB8C,EAAE,CAAC;IAAEJ,QAAAA,KAAF;IAASC,QAAAA,OAAT;IAAkBC,QAAAA,GAAlB;IAAuBC,QAAAA;IAAvB,OAAD,CAAlB,CAAP;IACH,KAHsB,CAAvB;;IAIA,QAAIP,WAAW,EAAf,EAAmB;IACf,YAAM;IAAE1B,QAAAA,IAAF;IAAQyB,QAAAA;IAAR,UAAqBD,qBAAqB,CAAC9C,cAAD,EAAiByC,WAAjB,CAAhD;;IACA,UAAIW,KAAJ,EAAW;IACPA,QAAAA,KAAK,CAACK,SAAN,CAAgBnC,IAAhB;IACH;;IACD,aAAOyB,QAAP;IACH;;IACD,IAA2C;IACvCtB,MAAAA,gBAAM,CAACI,GAAP,CAAY,wDAAD,GACN,0DADL;IAEH,KAf6C;IAiB9C;;;IACA,UAAM6B,iBAAiB,GAAG1D,cAAc,CAACO,GAAf,CAAmB,MAAOC,aAAP,IAAyB;IAClE,YAAMd,MAAM,GAAG,MAAMc,aAArB;;IACA,UAAId,MAAM,YAAYC,QAAtB,EAAgC;IAC5B,eAAOD,MAAM,CAACiE,IAAP,EAAP;IACH,OAFD,MAGK;IACD;IACA;IACA;IACA;IACA,eAAO,IAAIhE,QAAJ,CAAaD,MAAb,EAAqBiE,IAArB,EAAP;IACH;IACJ,KAZyB,CAA1B;IAaA,UAAMC,SAAS,GAAG,MAAMnD,OAAO,CAACoD,GAAR,CAAYH,iBAAZ,CAAxB;IACA,UAAMhB,OAAO,GAAGF,aAAa,CAACC,WAAD,CAA7B,CAhC8C;IAkC9C;;IACA,WAAO,IAAI9C,QAAJ,CAAa,IAAImE,IAAJ,CAASF,SAAT,CAAb,EAAkC;IAAElB,MAAAA;IAAF,KAAlC,CAAP;IACH,GApCD;IAqCH;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ this.workbox=this.workbox||{},this.workbox.streams=function(e,n,t){"use strict";try{self["workbox:streams:5.1.3"]&&_()}catch(e){}function s(e){const t=e.map(e=>Promise.resolve(e).then(e=>function(e){return e instanceof Response?e.body.getReader():e instanceof ReadableStream?e.getReader():new Response(e).body.getReader()}(e))),s=new n.Deferred;let r=0;const o=new ReadableStream({pull(e){return t[r].then(e=>e.read()).then(n=>{if(n.done)return r++,r>=t.length?(e.close(),void s.resolve()):this.pull(e);e.enqueue(n.value)}).catch(e=>{throw s.reject(e),e})},cancel(){s.resolve()}});return{done:s.promise,stream:o}}function r(e={}){const n=new Headers(e);return n.has("content-type")||n.set("content-type","text/html"),n}function o(e,n){const{done:t,stream:o}=s(e),c=r(n);return{done:t,response:new Response(o,{headers:c})}}function c(){return t.canConstructReadableStream()}return e.concatenate=s,e.concatenateToResponse=o,e.isSupported=c,e.strategy=function(e,n){return async({event:t,request:s,url:a,params:u})=>{const i=e.map(e=>Promise.resolve(e({event:t,request:s,url:a,params:u})));if(c()){const{done:e,response:s}=o(i,n);return t&&t.waitUntil(e),s}const f=i.map(async e=>{const n=await e;return n instanceof Response?n.blob():new Response(n).blob()}),p=await Promise.all(f),w=r(n);return new Response(new Blob(p),{headers:w})}},e}({},workbox.core._private,workbox.core._private);
2
+ //# sourceMappingURL=workbox-streams.prod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-streams.prod.js","sources":["../_version.js","../concatenate.js","../utils/createHeaders.js","../concatenateToResponse.js","../isSupported.js","../strategy.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:streams:5.1.3'] && _();\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 { logger } from 'workbox-core/_private/logger.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\nimport './_version.js';\n/**\n * Takes either a Response, a ReadableStream, or a\n * [BodyInit](https://fetch.spec.whatwg.org/#bodyinit) and returns the\n * ReadableStreamReader object associated with it.\n *\n * @param {module:workbox-streams.StreamSource} source\n * @return {ReadableStreamReader}\n * @private\n */\nfunction _getReaderFromSource(source) {\n if (source instanceof Response) {\n return source.body.getReader();\n }\n if (source instanceof ReadableStream) {\n return source.getReader();\n }\n return new Response(source).body.getReader();\n}\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit).\n *\n * Returns an object exposing a ReadableStream with each individual stream's\n * data returned in sequence, along with a Promise which signals when the\n * stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromises\n * @return {Object<{done: Promise, stream: ReadableStream}>}\n *\n * @memberof module:workbox-streams\n */\nfunction concatenate(sourcePromises) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArray(sourcePromises, {\n moduleName: 'workbox-streams',\n funcName: 'concatenate',\n paramName: 'sourcePromises',\n });\n }\n const readerPromises = sourcePromises.map((sourcePromise) => {\n return Promise.resolve(sourcePromise).then((source) => {\n return _getReaderFromSource(source);\n });\n });\n const streamDeferred = new Deferred();\n let i = 0;\n const logMessages = [];\n const stream = new ReadableStream({\n pull(controller) {\n return readerPromises[i]\n .then((reader) => reader.read())\n .then((result) => {\n if (result.done) {\n if (process.env.NODE_ENV !== 'production') {\n logMessages.push(['Reached the end of source:',\n sourcePromises[i]]);\n }\n i++;\n if (i >= readerPromises.length) {\n // Log all the messages in the group at once in a single group.\n if (process.env.NODE_ENV !== 'production') {\n logger.groupCollapsed(`Concatenating ${readerPromises.length} sources.`);\n for (const message of logMessages) {\n if (Array.isArray(message)) {\n logger.log(...message);\n }\n else {\n logger.log(message);\n }\n }\n logger.log('Finished reading all sources.');\n logger.groupEnd();\n }\n controller.close();\n streamDeferred.resolve();\n return;\n }\n // The `pull` method is defined because we're inside it.\n return this.pull(controller);\n }\n else {\n controller.enqueue(result.value);\n }\n }).catch((error) => {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('An error occurred:', error);\n }\n streamDeferred.reject(error);\n throw error;\n });\n },\n cancel() {\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('The ReadableStream was cancelled.');\n }\n streamDeferred.resolve();\n },\n });\n return { done: streamDeferred.promise, stream };\n}\nexport { concatenate };\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 * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * is available.\n *\n * @private\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof module:workbox-streams\n */\nfunction createHeaders(headersInit = {}) {\n // See https://github.com/GoogleChrome/workbox/issues/1461\n const headers = new Headers(headersInit);\n if (!headers.has('content-type')) {\n headers.set('content-type', 'text/html');\n }\n return headers;\n}\nexport { createHeaders };\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 { createHeaders } from './utils/createHeaders.js';\nimport { concatenate } from './concatenate.js';\nimport './_version.js';\n/**\n * Takes multiple source Promises, each of which could resolve to a Response, a\n * ReadableStream, or a [BodyInit](https://fetch.spec.whatwg.org/#bodyinit),\n * along with a\n * [HeadersInit](https://fetch.spec.whatwg.org/#typedefdef-headersinit).\n *\n * Returns an object exposing a Response whose body consists of each individual\n * stream's data returned in sequence, along with a Promise which signals when\n * the stream is finished (useful for passing to a FetchEvent's waitUntil()).\n *\n * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromises\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {Object<{done: Promise, response: Response}>}\n *\n * @memberof module:workbox-streams\n */\nfunction concatenateToResponse(sourcePromises, headersInit) {\n const { done, stream } = concatenate(sourcePromises);\n const headers = createHeaders(headersInit);\n const response = new Response(stream, { headers });\n return { done, response };\n}\nexport { concatenateToResponse };\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 { canConstructReadableStream } from 'workbox-core/_private/canConstructReadableStream.js';\nimport './_version.js';\n/**\n * This is a utility method that determines whether the current browser supports\n * the features required to create streamed responses. Currently, it checks if\n * [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)\n * can be created.\n *\n * @return {boolean} `true`, if the current browser meets the requirements for\n * streaming responses, and `false` otherwise.\n *\n * @memberof module:workbox-streams\n */\nfunction isSupported() {\n return canConstructReadableStream();\n}\nexport { isSupported };\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { createHeaders } from './utils/createHeaders.js';\nimport { concatenateToResponse } from './concatenateToResponse.js';\nimport { isSupported } from './isSupported.js';\nimport './_version.js';\n/**\n * A shortcut to create a strategy that could be dropped-in to Workbox's router.\n *\n * On browsers that do not support constructing new `ReadableStream`s, this\n * strategy will automatically wait for all the `sourceFunctions` to complete,\n * and create a final response that concatenates their values together.\n *\n * @param {Array<function({event, request, url, params})>} sourceFunctions\n * An array of functions similar to {@link module:workbox-routing~handlerCallback}\n * but that instead return a {@link module:workbox-streams.StreamSource} (or a\n * Promise which resolves to one).\n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,\n * `'text/html'` will be used by default.\n * @return {module:workbox-routing~handlerCallback}\n * @memberof module:workbox-streams\n */\nfunction strategy(sourceFunctions, headersInit) {\n return async ({ event, request, url, params }) => {\n const sourcePromises = sourceFunctions.map((fn) => {\n // Ensure the return value of the function is always a promise.\n return Promise.resolve(fn({ event, request, url, params }));\n });\n if (isSupported()) {\n const { done, response } = concatenateToResponse(sourcePromises, headersInit);\n if (event) {\n event.waitUntil(done);\n }\n return response;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The current browser doesn't support creating response ` +\n `streams. Falling back to non-streaming response instead.`);\n }\n // Fallback to waiting for everything to finish, and concatenating the\n // responses.\n const blobPartsPromises = sourcePromises.map(async (sourcePromise) => {\n const source = await sourcePromise;\n if (source instanceof Response) {\n return source.blob();\n }\n else {\n // Technically, a `StreamSource` object can include any valid\n // `BodyInit` type, including `FormData` and `URLSearchParams`, which\n // cannot be passed to the Blob constructor directly, so we have to\n // convert them to actual Blobs first.\n return new Response(source).blob();\n }\n });\n const blobParts = await Promise.all(blobPartsPromises);\n const headers = createHeaders(headersInit);\n // Constructing a new Response from a Blob source is well-supported.\n // So is constructing a new Blob from multiple source Blobs or strings.\n return new Response(new Blob(blobParts), { headers });\n };\n}\nexport { strategy };\n"],"names":["self","_","e","concatenate","sourcePromises","readerPromises","map","sourcePromise","Promise","resolve","then","source","Response","body","getReader","ReadableStream","_getReaderFromSource","streamDeferred","Deferred","i","stream","pull","controller","reader","read","result","done","length","close","this","enqueue","value","catch","error","reject","cancel","promise","createHeaders","headersInit","headers","Headers","has","set","concatenateToResponse","response","isSupported","canConstructReadableStream","sourceFunctions","async","event","request","url","params","fn","waitUntil","blobPartsPromises","blob","blobParts","all","Blob"],"mappings":"gFAEA,IACIA,KAAK,0BAA4BC,IAErC,MAAOC,ICqCP,SAASC,EAAYC,SAQXC,EAAiBD,EAAeE,IAAKC,GAChCC,QAAQC,QAAQF,GAAeG,KAAMC,GA/BpD,SAA8BA,UACtBA,aAAkBC,SACXD,EAAOE,KAAKC,YAEnBH,aAAkBI,eACXJ,EAAOG,YAEX,IAAIF,SAASD,GAAQE,KAAKC,YAyBlBE,CAAqBL,KAG9BM,EAAiB,IAAIC,eACvBC,EAAI,QAEFC,EAAS,IAAIL,eAAe,CAC9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()}catch(t){}const t={backgroundSync:"background-sync",broadcastUpdate:"broadcast-update",cacheableResponse:"cacheable-response",core:"core",expiration:"expiration",googleAnalytics:"offline-ga",navigationPreload:"navigation-preload",precaching:"precaching",rangeRequests:"range-requests",routing:"routing",strategies:"strategies",streams:"streams"};self.workbox=new class{constructor(){return this.v={},this.t={debug:"localhost"===self.location.hostname,modulePathPrefix:null,modulePathCb:null},this.s=this.t.debug?"dev":"prod",this.o=!1,new Proxy(this,{get(e,s){if(e[s])return e[s];const o=t[s];return o&&e.loadModule(`workbox-${o}`),e[s]}})}setConfig(t={}){if(this.o)throw new Error("Config must be set before accessing workbox.* modules");Object.assign(this.t,t),this.s=this.t.debug?"dev":"prod"}loadModule(t){const e=this.i(t);try{importScripts(e),this.o=!0}catch(s){throw console.error(`Unable to import module '${t}' from '${e}'.`),s}}i(t){if(this.t.modulePathCb)return this.t.modulePathCb(t,this.t.debug);let e=["https://storage.googleapis.com/workbox-cdn/releases/5.1.3"];const s=`${t}.${this.s}.js`,o=this.t.modulePathPrefix;return o&&(e=o.split("/"),""===e[e.length-1]&&e.splice(e.length-1,1)),e.push(s),e.join("/")}}}();
2
+ //# sourceMappingURL=workbox-sw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-sw.js","sources":["../_version.mjs","../controllers/WorkboxSW.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:sw:5.1.3']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nconst CDN_PATH = `WORKBOX_CDN_ROOT_URL`;\n\nconst MODULE_KEY_TO_NAME_MAPPING = {\n /**\n * @name backgroundSync\n * @memberof workbox\n * @see module:workbox-background-sync\n */\n backgroundSync: 'background-sync',\n /**\n * @name broadcastUpdate\n * @memberof workbox\n * @see module:workbox-broadcast-update\n */\n broadcastUpdate: 'broadcast-update',\n /**\n * @name cacheableResponse\n * @memberof workbox\n * @see module:workbox-cacheable-response\n */\n cacheableResponse: 'cacheable-response',\n /**\n * @name core\n * @memberof workbox\n * @see module:workbox-core\n */\n core: 'core',\n /**\n * @name expiration\n * @memberof workbox\n * @see module:workbox-expiration\n */\n expiration: 'expiration',\n /**\n * @name googleAnalytics\n * @memberof workbox\n * @see module:workbox-google-analytics\n */\n googleAnalytics: 'offline-ga',\n /**\n * @name navigationPreload\n * @memberof workbox\n * @see module:workbox-navigation-preload\n */\n navigationPreload: 'navigation-preload',\n /**\n * @name precaching\n * @memberof workbox\n * @see module:workbox-precaching\n */\n precaching: 'precaching',\n /**\n * @name rangeRequests\n * @memberof workbox\n * @see module:workbox-range-requests\n */\n rangeRequests: 'range-requests',\n /**\n * @name routing\n * @memberof workbox\n * @see module:workbox-routing\n */\n routing: 'routing',\n /**\n * @name strategies\n * @memberof workbox\n * @see module:workbox-strategies\n */\n strategies: 'strategies',\n /**\n * @name streams\n * @memberof workbox\n * @see module:workbox-streams\n */\n streams: 'streams',\n};\n\n/**\n * This class can be used to make it easy to use the various parts of\n * Workbox.\n *\n * @private\n */\nexport class WorkboxSW {\n /**\n * Creates a proxy that automatically loads workbox namespaces on demand.\n *\n * @private\n */\n constructor() {\n this.v = {};\n this._options = {\n debug: self.location.hostname === 'localhost',\n modulePathPrefix: null,\n modulePathCb: null,\n };\n\n this._env = this._options.debug ? 'dev' : 'prod';\n this._modulesLoaded = false;\n\n return new Proxy(this, {\n get(target, key) {\n if (target[key]) {\n return target[key];\n }\n\n const moduleName = MODULE_KEY_TO_NAME_MAPPING[key];\n if (moduleName) {\n target.loadModule(`workbox-${moduleName}`);\n }\n\n return target[key];\n },\n });\n }\n\n /**\n * Updates the configuration options. You can specify whether to treat as a\n * debug build and whether to use a CDN or a specific path when importing\n * other workbox-modules\n *\n * @param {Object} [options]\n * @param {boolean} [options.debug] If true, `dev` builds are using, otherwise\n * `prod` builds are used. By default, `prod` is used unless on localhost.\n * @param {Function} [options.modulePathPrefix] To avoid using the CDN with\n * `workbox-sw` set the path prefix of where modules should be loaded from.\n * For example `modulePathPrefix: '/third_party/workbox/v3.0.0/'`.\n * @param {workbox~ModulePathCallback} [options.modulePathCb] If defined,\n * this callback will be responsible for determining the path of each\n * workbox module.\n *\n * @alias workbox.setConfig\n */\n setConfig(options = {}) {\n if (!this._modulesLoaded) {\n Object.assign(this._options, options);\n this._env = this._options.debug ? 'dev' : 'prod';\n } else {\n throw new Error('Config must be set before accessing workbox.* modules');\n }\n }\n\n /**\n * Load a Workbox module by passing in the appropriate module name.\n *\n * This is not generally needed unless you know there are modules that are\n * dynamically used and you want to safe guard use of the module while the\n * user may be offline.\n *\n * @param {string} moduleName\n *\n * @alias workbox.loadModule\n */\n loadModule(moduleName) {\n const modulePath = this._getImportPath(moduleName);\n try {\n importScripts(modulePath);\n this._modulesLoaded = true;\n } catch (err) {\n // TODO Add context of this error if using the CDN vs the local file.\n\n // We can't rely on workbox-core being loaded so using console\n // eslint-disable-next-line\n console.error(\n `Unable to import module '${moduleName}' from '${modulePath}'.`);\n throw err;\n }\n }\n\n /**\n * This method will get the path / CDN URL to be used for importScript calls.\n *\n * @param {string} moduleName\n * @return {string} URL to the desired module.\n *\n * @private\n */\n _getImportPath(moduleName) {\n if (this._options.modulePathCb) {\n return this._options.modulePathCb(moduleName, this._options.debug);\n }\n\n // TODO: This needs to be dynamic some how.\n let pathParts = [CDN_PATH];\n\n const fileName = `${moduleName}.${this._env}.js`;\n\n const pathPrefix = this._options.modulePathPrefix;\n if (pathPrefix) {\n // Split to avoid issues with developers ending / not ending with slash\n pathParts = pathPrefix.split('/');\n\n // We don't need a slash at the end as we will be adding\n // a filename regardless\n if (pathParts[pathParts.length - 1] === '') {\n pathParts.splice(pathParts.length - 1, 1);\n }\n }\n\n pathParts.push(fileName);\n\n return pathParts.join('/');\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*/\n\nimport {WorkboxSW} from './controllers/WorkboxSW.mjs';\nimport './_version.mjs';\n\n/**\n * @namespace workbox\n */\n\n// Don't export anything, just expose a global.\nself.workbox = new WorkboxSW();\n"],"names":["self","_","e","MODULE_KEY_TO_NAME_MAPPING","backgroundSync","broadcastUpdate","cacheableResponse","core","expiration","googleAnalytics","navigationPreload","precaching","rangeRequests","routing","strategies","streams","workbox","constructor","v","_options","debug","location","hostname","modulePathPrefix","modulePathCb","_env","this","_modulesLoaded","Proxy","get","target","key","moduleName","loadModule","setConfig","options","Error","Object","assign","modulePath","_getImportPath","importScripts","err","console","error","pathParts","fileName","pathPrefix","split","length","splice","push","join"],"mappings":"yBAAA,IAAIA,KAAK,qBAAqBC,IAAI,MAAMC,ICUxC,MAEMC,EAA6B,CAMjCC,eAAgB,kBAMhBC,gBAAiB,mBAMjBC,kBAAmB,qBAMnBC,KAAM,OAMNC,WAAY,aAMZC,gBAAiB,aAMjBC,kBAAmB,qBAMnBC,WAAY,aAMZC,cAAe,iBAMfC,QAAS,UAMTC,WAAY,aAMZC,QAAS,WCpEXf,KAAKgB,QAAU,ID6ER,MAMLC,0BACOC,EAAI,QACJC,EAAW,CACdC,MAAkC,cAA3BpB,KAAKqB,SAASC,SACrBC,iBAAkB,KAClBC,aAAc,WAGXC,EAAOC,KAAKP,EAASC,MAAQ,MAAQ,YACrCO,GAAiB,EAEf,IAAIC,MAAMF,KAAM,CACrBG,IAAIC,EAAQC,MACND,EAAOC,UACFD,EAAOC,SAGVC,EAAa7B,EAA2B4B,UAC1CC,GACFF,EAAOG,WAAY,WAAUD,KAGxBF,EAAOC,MAsBpBG,UAAUC,EAAU,OACbT,KAAKC,QAIF,IAAIS,MAAM,yDAHhBC,OAAOC,OAAOZ,KAAKP,EAAUgB,QACxBV,EAAOC,KAAKP,EAASC,MAAQ,MAAQ,OAiB9Ca,WAAWD,SACHO,EAAab,KAAKc,EAAeR,OAErCS,cAAcF,QACTZ,GAAiB,EACtB,MAAOe,SAKPC,QAAQC,MACH,4BAA2BZ,YAAqBO,OAC/CG,GAYVF,EAAeR,MACTN,KAAKP,EAASK,oBACTE,KAAKP,EAASK,aAAaQ,EAAYN,KAAKP,EAASC,WAI1DyB,EAAY,CAvLF,mEAyLRC,EAAY,GAAEd,KAAcN,KAAKD,OAEjCsB,EAAarB,KAAKP,EAASI,wBAC7BwB,IAEFF,EAAYE,EAAWC,MAAM,KAIW,KAApCH,EAAUA,EAAUI,OAAS,IAC/BJ,EAAUK,OAAOL,EAAUI,OAAS,EAAG,IAI3CJ,EAAUM,KAAKL,GAERD,EAAUO,KAAK"}
@@ -0,0 +1,1094 @@
1
+ try {
2
+ self['workbox:window:5.1.3'] && _();
3
+ } catch (e) {}
4
+
5
+ /*
6
+ Copyright 2019 Google LLC
7
+
8
+ Use of this source code is governed by an MIT-style
9
+ license that can be found in the LICENSE file or at
10
+ https://opensource.org/licenses/MIT.
11
+ */
12
+ /**
13
+ * Sends a data object to a service worker via `postMessage` and resolves with
14
+ * a response (if any).
15
+ *
16
+ * A response can be set in a message handler in the service worker by
17
+ * calling `event.ports[0].postMessage(...)`, which will resolve the promise
18
+ * returned by `messageSW()`. If no response is set, the promise will not
19
+ * resolve.
20
+ *
21
+ * @param {ServiceWorker} sw The service worker to send the message to.
22
+ * @param {Object} data An object to send to the service worker.
23
+ * @return {Promise<Object|undefined>}
24
+ * @memberof module:workbox-window
25
+ */
26
+
27
+ function messageSW(sw, data) {
28
+ return new Promise(function (resolve) {
29
+ var messageChannel = new MessageChannel();
30
+
31
+ messageChannel.port1.onmessage = function (event) {
32
+ resolve(event.data);
33
+ };
34
+
35
+ sw.postMessage(data, [messageChannel.port2]);
36
+ });
37
+ }
38
+
39
+ function _defineProperties(target, props) {
40
+ for (var i = 0; i < props.length; i++) {
41
+ var descriptor = props[i];
42
+ descriptor.enumerable = descriptor.enumerable || false;
43
+ descriptor.configurable = true;
44
+ if ("value" in descriptor) descriptor.writable = true;
45
+ Object.defineProperty(target, descriptor.key, descriptor);
46
+ }
47
+ }
48
+
49
+ function _createClass(Constructor, protoProps, staticProps) {
50
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
51
+ if (staticProps) _defineProperties(Constructor, staticProps);
52
+ return Constructor;
53
+ }
54
+
55
+ function _inheritsLoose(subClass, superClass) {
56
+ subClass.prototype = Object.create(superClass.prototype);
57
+ subClass.prototype.constructor = subClass;
58
+ subClass.__proto__ = superClass;
59
+ }
60
+
61
+ try {
62
+ self['workbox:core:5.1.3'] && _();
63
+ } catch (e) {}
64
+
65
+ /*
66
+ Copyright 2018 Google LLC
67
+
68
+ Use of this source code is governed by an MIT-style
69
+ license that can be found in the LICENSE file or at
70
+ https://opensource.org/licenses/MIT.
71
+ */
72
+ /**
73
+ * The Deferred class composes Promises in a way that allows for them to be
74
+ * resolved or rejected from outside the constructor. In most cases promises
75
+ * should be used directly, but Deferreds can be necessary when the logic to
76
+ * resolve a promise must be separate.
77
+ *
78
+ * @private
79
+ */
80
+
81
+ var Deferred =
82
+ /**
83
+ * Creates a promise and exposes its resolve and reject functions as methods.
84
+ */
85
+ function Deferred() {
86
+ var _this = this;
87
+
88
+ this.promise = new Promise(function (resolve, reject) {
89
+ _this.resolve = resolve;
90
+ _this.reject = reject;
91
+ });
92
+ };
93
+
94
+ /*
95
+ Copyright 2019 Google LLC
96
+ Use of this source code is governed by an MIT-style
97
+ license that can be found in the LICENSE file or at
98
+ https://opensource.org/licenses/MIT.
99
+ */
100
+ /**
101
+ * A helper function that prevents a promise from being flagged as unused.
102
+ *
103
+ * @private
104
+ **/
105
+
106
+ function dontWaitFor(promise) {
107
+ // Effective no-op.
108
+ promise.then(function () {});
109
+ }
110
+
111
+ /*
112
+ Copyright 2019 Google LLC
113
+ Use of this source code is governed by an MIT-style
114
+ license that can be found in the LICENSE file or at
115
+ https://opensource.org/licenses/MIT.
116
+ */
117
+ var logger = function () {
118
+ // Don't overwrite this value if it's already set.
119
+ // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
120
+ if (!('__WB_DISABLE_DEV_LOGS' in self)) {
121
+ self.__WB_DISABLE_DEV_LOGS = false;
122
+ }
123
+
124
+ var inGroup = false;
125
+ var methodToColorMap = {
126
+ debug: "#7f8c8d",
127
+ log: "#2ecc71",
128
+ warn: "#f39c12",
129
+ error: "#c0392b",
130
+ groupCollapsed: "#3498db",
131
+ groupEnd: null
132
+ };
133
+
134
+ var print = function print(method, args) {
135
+ var _console2;
136
+
137
+ if (self.__WB_DISABLE_DEV_LOGS) {
138
+ return;
139
+ }
140
+
141
+ if (method === 'groupCollapsed') {
142
+ // Safari doesn't print all console.groupCollapsed() arguments:
143
+ // https://bugs.webkit.org/show_bug.cgi?id=182754
144
+ if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
145
+ var _console;
146
+
147
+ (_console = console)[method].apply(_console, args);
148
+
149
+ return;
150
+ }
151
+ }
152
+
153
+ var styles = ["background: " + methodToColorMap[method], "border-radius: 0.5em", "color: white", "font-weight: bold", "padding: 2px 0.5em"]; // When in a group, the workbox prefix is not displayed.
154
+
155
+ var logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
156
+
157
+ (_console2 = console)[method].apply(_console2, logPrefix.concat(args));
158
+
159
+ if (method === 'groupCollapsed') {
160
+ inGroup = true;
161
+ }
162
+
163
+ if (method === 'groupEnd') {
164
+ inGroup = false;
165
+ }
166
+ };
167
+
168
+ var api = {};
169
+ var loggerMethods = Object.keys(methodToColorMap);
170
+
171
+ var _loop = function _loop() {
172
+ var key = _loggerMethods[_i];
173
+ var method = key;
174
+
175
+ api[method] = function () {
176
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
177
+ args[_key] = arguments[_key];
178
+ }
179
+
180
+ print(method, args);
181
+ };
182
+ };
183
+
184
+ for (var _i = 0, _loggerMethods = loggerMethods; _i < _loggerMethods.length; _i++) {
185
+ _loop();
186
+ }
187
+
188
+ return api;
189
+ }();
190
+
191
+ /*
192
+ Copyright 2019 Google LLC
193
+
194
+ Use of this source code is governed by an MIT-style
195
+ license that can be found in the LICENSE file or at
196
+ https://opensource.org/licenses/MIT.
197
+ */
198
+
199
+ /**
200
+ * A minimal `EventTarget` shim.
201
+ * This is necessary because not all browsers support constructable
202
+ * `EventTarget`, so using a real `EventTarget` will error.
203
+ * @private
204
+ */
205
+ var WorkboxEventTarget = /*#__PURE__*/function () {
206
+ function WorkboxEventTarget() {
207
+ this._eventListenerRegistry = new Map();
208
+ }
209
+ /**
210
+ * @param {string} type
211
+ * @param {Function} listener
212
+ * @private
213
+ */
214
+
215
+
216
+ var _proto = WorkboxEventTarget.prototype;
217
+
218
+ _proto.addEventListener = function addEventListener(type, listener) {
219
+ var foo = this._getEventListenersByType(type);
220
+
221
+ foo.add(listener);
222
+ }
223
+ /**
224
+ * @param {string} type
225
+ * @param {Function} listener
226
+ * @private
227
+ */
228
+ ;
229
+
230
+ _proto.removeEventListener = function removeEventListener(type, listener) {
231
+ this._getEventListenersByType(type).delete(listener);
232
+ }
233
+ /**
234
+ * @param {Object} event
235
+ * @private
236
+ */
237
+ ;
238
+
239
+ _proto.dispatchEvent = function dispatchEvent(event) {
240
+ event.target = this;
241
+
242
+ var listeners = this._getEventListenersByType(event.type);
243
+
244
+ for (var _iterator = listeners, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
245
+ var _ref;
246
+
247
+ if (_isArray) {
248
+ if (_i >= _iterator.length) break;
249
+ _ref = _iterator[_i++];
250
+ } else {
251
+ _i = _iterator.next();
252
+ if (_i.done) break;
253
+ _ref = _i.value;
254
+ }
255
+
256
+ var listener = _ref;
257
+ listener(event);
258
+ }
259
+ }
260
+ /**
261
+ * Returns a Set of listeners associated with the passed event type.
262
+ * If no handlers have been registered, an empty Set is returned.
263
+ *
264
+ * @param {string} type The event type.
265
+ * @return {Set<ListenerCallback>} An array of handler functions.
266
+ * @private
267
+ */
268
+ ;
269
+
270
+ _proto._getEventListenersByType = function _getEventListenersByType(type) {
271
+ if (!this._eventListenerRegistry.has(type)) {
272
+ this._eventListenerRegistry.set(type, new Set());
273
+ }
274
+
275
+ return this._eventListenerRegistry.get(type);
276
+ };
277
+
278
+ return WorkboxEventTarget;
279
+ }();
280
+
281
+ /*
282
+ Copyright 2019 Google LLC
283
+
284
+ Use of this source code is governed by an MIT-style
285
+ license that can be found in the LICENSE file or at
286
+ https://opensource.org/licenses/MIT.
287
+ */
288
+ /**
289
+ * Returns true if two URLs have the same `.href` property. The URLS can be
290
+ * relative, and if they are the current location href is used to resolve URLs.
291
+ *
292
+ * @private
293
+ * @param {string} url1
294
+ * @param {string} url2
295
+ * @return {boolean}
296
+ */
297
+
298
+ function urlsMatch(url1, url2) {
299
+ var _location = location,
300
+ href = _location.href;
301
+ return new URL(url1, href).href === new URL(url2, href).href;
302
+ }
303
+
304
+ /*
305
+ Copyright 2019 Google LLC
306
+
307
+ Use of this source code is governed by an MIT-style
308
+ license that can be found in the LICENSE file or at
309
+ https://opensource.org/licenses/MIT.
310
+ */
311
+ /**
312
+ * A minimal `Event` subclass shim.
313
+ * This doesn't *actually* subclass `Event` because not all browsers support
314
+ * constructable `EventTarget`, and using a real `Event` will error.
315
+ * @private
316
+ */
317
+
318
+ var WorkboxEvent = function WorkboxEvent(type, props) {
319
+ this.type = type;
320
+ Object.assign(this, props);
321
+ };
322
+
323
+ // `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
324
+ // chosen, but it seems to avoid false positives in my testing.
325
+
326
+ function _await(value, then, direct) {
327
+ if (direct) {
328
+ return then ? then(value) : value;
329
+ }
330
+
331
+ if (!value || !value.then) {
332
+ value = Promise.resolve(value);
333
+ }
334
+
335
+ return then ? value.then(then) : value;
336
+ }
337
+
338
+ var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
339
+ // that the registration didn't trigger an update.
340
+
341
+ function _async(f) {
342
+ return function () {
343
+ for (var args = [], i = 0; i < arguments.length; i++) {
344
+ args[i] = arguments[i];
345
+ }
346
+
347
+ try {
348
+ return Promise.resolve(f.apply(this, args));
349
+ } catch (e) {
350
+ return Promise.reject(e);
351
+ }
352
+ };
353
+ }
354
+
355
+ var REGISTRATION_TIMEOUT_DURATION = 60000;
356
+ /**
357
+ * A class to aid in handling service worker registration, updates, and
358
+ * reacting to service worker lifecycle events.
359
+ *
360
+ * @fires [message]{@link module:workbox-window.Workbox#message}
361
+ * @fires [installed]{@link module:workbox-window.Workbox#installed}
362
+ * @fires [waiting]{@link module:workbox-window.Workbox#waiting}
363
+ * @fires [controlling]{@link module:workbox-window.Workbox#controlling}
364
+ * @fires [activated]{@link module:workbox-window.Workbox#activated}
365
+ * @fires [redundant]{@link module:workbox-window.Workbox#redundant}
366
+ * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
367
+ * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
368
+ * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
369
+ * @memberof module:workbox-window
370
+ */
371
+
372
+ function _empty() {}
373
+
374
+ var Workbox = /*#__PURE__*/function (_WorkboxEventTarget) {
375
+ _inheritsLoose(Workbox, _WorkboxEventTarget);
376
+
377
+ /**
378
+ * Creates a new Workbox instance with a script URL and service worker
379
+ * options. The script URL and options are the same as those used when
380
+ * calling `navigator.serviceWorker.register(scriptURL, options)`. See:
381
+ * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
382
+ *
383
+ * @param {string} scriptURL The service worker script associated with this
384
+ * instance.
385
+ * @param {Object} [registerOptions] The service worker options associated
386
+ * with this instance.
387
+ */
388
+ function Workbox(scriptURL, registerOptions) {
389
+ var _this;
390
+
391
+ if (registerOptions === void 0) {
392
+ registerOptions = {};
393
+ }
394
+
395
+ _this = _WorkboxEventTarget.call(this) || this;
396
+ _this._registerOptions = {};
397
+ _this._updateFoundCount = 0; // Deferreds we can resolve later.
398
+
399
+ _this._swDeferred = new Deferred();
400
+ _this._activeDeferred = new Deferred();
401
+ _this._controllingDeferred = new Deferred();
402
+ _this._registrationTime = 0;
403
+ _this._ownSWs = new Set();
404
+ /**
405
+ * @private
406
+ */
407
+
408
+ _this._onUpdateFound = function () {
409
+ // `this._registration` will never be `undefined` after an update is found.
410
+ var registration = _this._registration;
411
+ var installingSW = registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
412
+ // different from the current controlling SW's script URL, we know any
413
+ // successful registration calls will trigger an `updatefound` event.
414
+ // But if the registered script URL is the same as the current controlling
415
+ // SW's script URL, we'll only get an `updatefound` event if the file
416
+ // changed since it was last registered. This can be a problem if the user
417
+ // opens up the same page in a different tab, and that page registers
418
+ // a SW that triggers an update. It's a problem because this page has no
419
+ // good way of knowing whether the `updatefound` event came from the SW
420
+ // script it registered or from a registration attempt made by a newer
421
+ // version of the page running in another tab.
422
+ // To minimize the possibility of a false positive, we use the logic here:
423
+
424
+ var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
425
+ // add the `updatefound` event listener until the `register()` call, if
426
+ // `_updateFoundCount` is > 0 then it means this method has already
427
+ // been called, thus this SW must be external
428
+ _this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
429
+ // instance's script URL, we know it's definitely not from our
430
+ // registration.
431
+ !urlsMatch(installingSW.scriptURL, _this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
432
+ // Any `updatefound` event that occurs long after our registration is
433
+ // assumed to be external.
434
+ performance.now() > _this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
435
+ // triggered by this instance.
436
+ true : false;
437
+
438
+ if (updateLikelyTriggeredExternally) {
439
+ _this._externalSW = installingSW;
440
+ registration.removeEventListener('updatefound', _this._onUpdateFound);
441
+ } else {
442
+ // If the update was not triggered externally we know the installing
443
+ // SW is the one we registered, so we set it.
444
+ _this._sw = installingSW;
445
+
446
+ _this._ownSWs.add(installingSW);
447
+
448
+ _this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
449
+ // callback for, but we do log messages for it in development.
450
+
451
+
452
+ {
453
+ if (navigator.serviceWorker.controller) {
454
+ logger.log('Updated service worker found. Installing now...');
455
+ } else {
456
+ logger.log('Service worker is installing...');
457
+ }
458
+ }
459
+ } // Increment the `updatefound` count, so future invocations of this
460
+ // method can be sure they were triggered externally.
461
+
462
+
463
+ ++_this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
464
+ // triggered externally, since we have callbacks for both.
465
+
466
+ installingSW.addEventListener('statechange', _this._onStateChange);
467
+ };
468
+ /**
469
+ * @private
470
+ * @param {Event} originalEvent
471
+ */
472
+
473
+
474
+ _this._onStateChange = function (originalEvent) {
475
+ // `this._registration` will never be `undefined` after an update is found.
476
+ var registration = _this._registration;
477
+ var sw = originalEvent.target;
478
+ var state = sw.state;
479
+ var isExternal = sw === _this._externalSW;
480
+ var eventPrefix = isExternal ? 'external' : '';
481
+ var eventProps = {
482
+ sw: sw,
483
+ originalEvent: originalEvent
484
+ };
485
+
486
+ if (!isExternal && _this._isUpdate) {
487
+ eventProps.isUpdate = true;
488
+ }
489
+
490
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
491
+
492
+ if (state === 'installed') {
493
+ // This timeout is used to ignore cases where the service worker calls
494
+ // `skipWaiting()` in the install event, thus moving it directly in the
495
+ // activating state. (Since all service workers *must* go through the
496
+ // waiting phase, the only way to detect `skipWaiting()` called in the
497
+ // install event is to observe that the time spent in the waiting phase
498
+ // is very short.)
499
+ // NOTE: we don't need separate timeouts for the own and external SWs
500
+ // since they can't go through these phases at the same time.
501
+ _this._waitingTimeout = self.setTimeout(function () {
502
+ // Ensure the SW is still waiting (it may now be redundant).
503
+ if (state === 'installed' && registration.waiting === sw) {
504
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
505
+
506
+ {
507
+ if (isExternal) {
508
+ logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
509
+ } else {
510
+ logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
511
+ }
512
+ }
513
+ }
514
+ }, WAITING_TIMEOUT_DURATION);
515
+ } else if (state === 'activating') {
516
+ clearTimeout(_this._waitingTimeout);
517
+
518
+ if (!isExternal) {
519
+ _this._activeDeferred.resolve(sw);
520
+ }
521
+ }
522
+
523
+ {
524
+ switch (state) {
525
+ case 'installed':
526
+ if (isExternal) {
527
+ logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
528
+ } else {
529
+ logger.log('Registered service worker installed.');
530
+ }
531
+
532
+ break;
533
+
534
+ case 'activated':
535
+ if (isExternal) {
536
+ logger.warn('An external service worker has activated.');
537
+ } else {
538
+ logger.log('Registered service worker activated.');
539
+
540
+ if (sw !== navigator.serviceWorker.controller) {
541
+ logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
542
+ }
543
+ }
544
+
545
+ break;
546
+
547
+ case 'redundant':
548
+ if (sw === _this._compatibleControllingSW) {
549
+ logger.log('Previously controlling service worker now redundant!');
550
+ } else if (!isExternal) {
551
+ logger.log('Registered service worker now redundant!');
552
+ }
553
+
554
+ break;
555
+ }
556
+ }
557
+ };
558
+ /**
559
+ * @private
560
+ * @param {Event} originalEvent
561
+ */
562
+
563
+
564
+ _this._onControllerChange = function (originalEvent) {
565
+ var sw = _this._sw;
566
+
567
+ if (sw === navigator.serviceWorker.controller) {
568
+ _this.dispatchEvent(new WorkboxEvent('controlling', {
569
+ sw: sw,
570
+ originalEvent: originalEvent,
571
+ isUpdate: _this._isUpdate
572
+ }));
573
+
574
+ {
575
+ logger.log('Registered service worker now controlling this page.');
576
+ }
577
+
578
+ _this._controllingDeferred.resolve(sw);
579
+ }
580
+ };
581
+ /**
582
+ * @private
583
+ * @param {Event} originalEvent
584
+ */
585
+
586
+
587
+ _this._onMessage = _async(function (originalEvent) {
588
+ var data = originalEvent.data,
589
+ source = originalEvent.source; // Wait until there's an "own" service worker. This is used to buffer
590
+ // `message` events that may be received prior to calling `register()`.
591
+
592
+ return _await(_this.getSW(), function () {
593
+ if (_this._ownSWs.has(source)) {
594
+ _this.dispatchEvent(new WorkboxEvent('message', {
595
+ data: data,
596
+ sw: source,
597
+ originalEvent: originalEvent
598
+ }));
599
+ }
600
+ }); // If the service worker that sent the message is in the list of own
601
+ // service workers for this instance, dispatch a `message` event.
602
+ // NOTE: we check for all previously owned service workers rather than
603
+ // just the current one because some messages (e.g. cache updates) use
604
+ // a timeout when sent and may be delayed long enough for a service worker
605
+ // update to be found.
606
+ });
607
+ _this._scriptURL = scriptURL;
608
+ _this._registerOptions = registerOptions; // Add a message listener immediately since messages received during
609
+ // page load are buffered only until the DOMContentLoaded event:
610
+ // https://github.com/GoogleChrome/workbox/issues/2202
611
+
612
+ navigator.serviceWorker.addEventListener('message', _this._onMessage);
613
+ return _this;
614
+ }
615
+ /**
616
+ * Registers a service worker for this instances script URL and service
617
+ * worker options. By default this method delays registration until after
618
+ * the window has loaded.
619
+ *
620
+ * @param {Object} [options]
621
+ * @param {Function} [options.immediate=false] Setting this to true will
622
+ * register the service worker immediately, even if the window has
623
+ * not loaded (not recommended).
624
+ */
625
+
626
+
627
+ var _proto = Workbox.prototype;
628
+
629
+ _proto.register = function register(_temp) {
630
+ var _ref = _temp === void 0 ? {} : _temp,
631
+ _ref$immediate = _ref.immediate,
632
+ immediate = _ref$immediate === void 0 ? false : _ref$immediate;
633
+
634
+ try {
635
+ var _this3 = this;
636
+
637
+ if ("dev" !== 'production') {
638
+ if (_this3._registrationTime) {
639
+ logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
640
+ return;
641
+ }
642
+ }
643
+
644
+ return _invoke(function () {
645
+ if (!immediate && document.readyState !== 'complete') {
646
+ return _awaitIgnored(new Promise(function (res) {
647
+ return window.addEventListener('load', res);
648
+ }));
649
+ }
650
+ }, function () {
651
+ // Set this flag to true if any service worker was controlling the page
652
+ // at registration time.
653
+ _this3._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
654
+ // the page, and if that SW script (and version, if specified) matches this
655
+ // instance's script.
656
+
657
+ _this3._compatibleControllingSW = _this3._getControllingSWIfCompatible();
658
+ return _await(_this3._registerScript(), function (_this2$_registerScrip) {
659
+ _this3._registration = _this2$_registerScrip;
660
+
661
+ // If we have a compatible controller, store the controller as the "own"
662
+ // SW, resolve active/controlling deferreds and add necessary listeners.
663
+ if (_this3._compatibleControllingSW) {
664
+ _this3._sw = _this3._compatibleControllingSW;
665
+
666
+ _this3._activeDeferred.resolve(_this3._compatibleControllingSW);
667
+
668
+ _this3._controllingDeferred.resolve(_this3._compatibleControllingSW);
669
+
670
+ _this3._compatibleControllingSW.addEventListener('statechange', _this3._onStateChange, {
671
+ once: true
672
+ });
673
+ } // If there's a waiting service worker with a matching URL before the
674
+ // `updatefound` event fires, it likely means that this site is open
675
+ // in another tab, or the user refreshed the page (and thus the previous
676
+ // page wasn't fully unloaded before this page started loading).
677
+ // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
678
+
679
+
680
+ var waitingSW = _this3._registration.waiting;
681
+
682
+ if (waitingSW && urlsMatch(waitingSW.scriptURL, _this3._scriptURL)) {
683
+ // Store the waiting SW as the "own" Sw, even if it means overwriting
684
+ // a compatible controller.
685
+ _this3._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
686
+ // listener after awaiting `register()` will get this event.
687
+
688
+ dontWaitFor(Promise.resolve().then(function () {
689
+ _this3.dispatchEvent(new WorkboxEvent('waiting', {
690
+ sw: waitingSW,
691
+ wasWaitingBeforeRegister: true
692
+ }));
693
+
694
+ if ("dev" !== 'production') {
695
+ logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
696
+ }
697
+ }));
698
+ } // If an "own" SW is already set, resolve the deferred.
699
+
700
+
701
+ if (_this3._sw) {
702
+ _this3._swDeferred.resolve(_this3._sw);
703
+
704
+ _this3._ownSWs.add(_this3._sw);
705
+ }
706
+
707
+ if ("dev" !== 'production') {
708
+ logger.log('Successfully registered service worker.', _this3._scriptURL);
709
+
710
+ if (navigator.serviceWorker.controller) {
711
+ if (_this3._compatibleControllingSW) {
712
+ logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
713
+ } else {
714
+ logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
715
+ }
716
+ }
717
+
718
+ var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
719
+ var scopeURL = new URL(_this3._registerOptions.scope || _this3._scriptURL, document.baseURI);
720
+ var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
721
+ return !location.pathname.startsWith(scopeURLBasePath);
722
+ };
723
+
724
+ if (currentPageIsOutOfScope()) {
725
+ logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
726
+ }
727
+ }
728
+
729
+ _this3._registration.addEventListener('updatefound', _this3._onUpdateFound);
730
+
731
+ navigator.serviceWorker.addEventListener('controllerchange', _this3._onControllerChange, {
732
+ once: true
733
+ });
734
+ return _this3._registration;
735
+ });
736
+ });
737
+ } catch (e) {
738
+ return Promise.reject(e);
739
+ }
740
+ }
741
+ /**
742
+ * Checks for updates of the registered service worker.
743
+ */
744
+ ;
745
+
746
+ _proto.update = function update() {
747
+ try {
748
+ var _this5 = this;
749
+
750
+ if (!_this5._registration) {
751
+ if ("dev" !== 'production') {
752
+ logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
753
+ }
754
+
755
+ return;
756
+ } // Try to update registration
757
+
758
+
759
+ return _awaitIgnored(_this5._registration.update());
760
+ } catch (e) {
761
+ return Promise.reject(e);
762
+ }
763
+ }
764
+ /**
765
+ * Resolves to the service worker registered by this instance as soon as it
766
+ * is active. If a service worker was already controlling at registration
767
+ * time then it will resolve to that if the script URLs (and optionally
768
+ * script versions) match, otherwise it will wait until an update is found
769
+ * and activates.
770
+ *
771
+ * @return {Promise<ServiceWorker>}
772
+ */
773
+ ;
774
+
775
+ /**
776
+ * Resolves with a reference to a service worker that matches the script URL
777
+ * of this instance, as soon as it's available.
778
+ *
779
+ * If, at registration time, there's already an active or waiting service
780
+ * worker with a matching script URL, it will be used (with the waiting
781
+ * service worker taking precedence over the active service worker if both
782
+ * match, since the waiting service worker would have been registered more
783
+ * recently).
784
+ * If there's no matching active or waiting service worker at registration
785
+ * time then the promise will not resolve until an update is found and starts
786
+ * installing, at which point the installing service worker is used.
787
+ *
788
+ * @return {Promise<ServiceWorker>}
789
+ */
790
+ _proto.getSW = function getSW() {
791
+ try {
792
+ var _this7 = this;
793
+
794
+ // If `this._sw` is set, resolve with that as we want `getSW()` to
795
+ // return the correct (new) service worker if an update is found.
796
+ return _this7._sw !== undefined ? _this7._sw : _this7._swDeferred.promise;
797
+ } catch (e) {
798
+ return Promise.reject(e);
799
+ }
800
+ }
801
+ /**
802
+ * Sends the passed data object to the service worker registered by this
803
+ * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
804
+ * with a response (if any).
805
+ *
806
+ * A response can be set in a message handler in the service worker by
807
+ * calling `event.ports[0].postMessage(...)`, which will resolve the promise
808
+ * returned by `messageSW()`. If no response is set, the promise will never
809
+ * resolve.
810
+ *
811
+ * @param {Object} data An object to send to the service worker
812
+ * @return {Promise<Object>}
813
+ */
814
+ ;
815
+
816
+ _proto.messageSW = function messageSW$1(data) {
817
+ try {
818
+ var _this9 = this;
819
+
820
+ return _await(_this9.getSW(), function (sw) {
821
+ return messageSW(sw, data);
822
+ });
823
+ } catch (e) {
824
+ return Promise.reject(e);
825
+ }
826
+ }
827
+ /**
828
+ * Checks for a service worker already controlling the page and returns
829
+ * it if its script URL matches.
830
+ *
831
+ * @private
832
+ * @return {ServiceWorker|undefined}
833
+ */
834
+ ;
835
+
836
+ _proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
837
+ var controller = navigator.serviceWorker.controller;
838
+
839
+ if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
840
+ return controller;
841
+ } else {
842
+ return undefined;
843
+ }
844
+ }
845
+ /**
846
+ * Registers a service worker for this instances script URL and register
847
+ * options and tracks the time registration was complete.
848
+ *
849
+ * @private
850
+ */
851
+ ;
852
+
853
+ _proto._registerScript = function _registerScript() {
854
+ try {
855
+ var _this11 = this;
856
+
857
+ return _catch(function () {
858
+ return _await(navigator.serviceWorker.register(_this11._scriptURL, _this11._registerOptions), function (reg) {
859
+ // Keep track of when registration happened, so it can be used in the
860
+ // `this._onUpdateFound` heuristic. Also use the presence of this
861
+ // property as a way to see if `.register()` has been called.
862
+ _this11._registrationTime = performance.now();
863
+ return reg;
864
+ });
865
+ }, function (error) {
866
+ if ("dev" !== 'production') {
867
+ logger.error(error);
868
+ } // Re-throw the error.
869
+
870
+
871
+ throw error;
872
+ });
873
+ } catch (e) {
874
+ return Promise.reject(e);
875
+ }
876
+ };
877
+
878
+ _createClass(Workbox, [{
879
+ key: "active",
880
+ get: function get() {
881
+ return this._activeDeferred.promise;
882
+ }
883
+ /**
884
+ * Resolves to the service worker registered by this instance as soon as it
885
+ * is controlling the page. If a service worker was already controlling at
886
+ * registration time then it will resolve to that if the script URLs (and
887
+ * optionally script versions) match, otherwise it will wait until an update
888
+ * is found and starts controlling the page.
889
+ * Note: the first time a service worker is installed it will active but
890
+ * not start controlling the page unless `clients.claim()` is called in the
891
+ * service worker.
892
+ *
893
+ * @return {Promise<ServiceWorker>}
894
+ */
895
+
896
+ }, {
897
+ key: "controlling",
898
+ get: function get() {
899
+ return this._controllingDeferred.promise;
900
+ }
901
+ }]);
902
+
903
+ return Workbox;
904
+ }(WorkboxEventTarget);
905
+
906
+ function _awaitIgnored(value, direct) {
907
+ if (!direct) {
908
+ return value && value.then ? value.then(_empty) : Promise.resolve();
909
+ }
910
+ } // The jsdoc comments below outline the events this instance may dispatch:
911
+ // -----------------------------------------------------------------------
912
+
913
+ /**
914
+ * The `message` event is dispatched any time a `postMessage` is received.
915
+ *
916
+ * @event module:workbox-window.Workbox#message
917
+ * @type {WorkboxEvent}
918
+ * @property {*} data The `data` property from the original `message` event.
919
+ * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}
920
+ * event.
921
+ * @property {string} type `message`.
922
+ * @property {Workbox} target The `Workbox` instance.
923
+ */
924
+
925
+ /**
926
+ * The `installed` event is dispatched if the state of a
927
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
928
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
929
+ * changes to `installed`.
930
+ *
931
+ * Then can happen either the very first time a service worker is installed,
932
+ * or after an update to the current service worker is found. In the case
933
+ * of an update being found, the event's `isUpdate` property will be `true`.
934
+ *
935
+ * @event module:workbox-window.Workbox#installed
936
+ * @type {WorkboxEvent}
937
+ * @property {ServiceWorker} sw The service worker instance.
938
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
939
+ * event.
940
+ * @property {boolean|undefined} isUpdate True if a service worker was already
941
+ * controlling when this `Workbox` instance called `register()`.
942
+ * @property {string} type `installed`.
943
+ * @property {Workbox} target The `Workbox` instance.
944
+ */
945
+
946
+ /**
947
+ * The `waiting` event is dispatched if the state of a
948
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
949
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
950
+ * changes to `installed` and then doesn't immediately change to `activating`.
951
+ * It may also be dispatched if a service worker with the same
952
+ * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
953
+ * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}
954
+ * method was called.
955
+ *
956
+ * @event module:workbox-window.Workbox#waiting
957
+ * @type {WorkboxEvent}
958
+ * @property {ServiceWorker} sw The service worker instance.
959
+ * @property {Event|undefined} originalEvent The original
960
+ * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
961
+ * event, or `undefined` in the case where the service worker was waiting
962
+ * to before `.register()` was called.
963
+ * @property {boolean|undefined} isUpdate True if a service worker was already
964
+ * controlling when this `Workbox` instance called `register()`.
965
+ * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with
966
+ * a matching `scriptURL` was already waiting when this `Workbox`
967
+ * instance called `register()`.
968
+ * @property {string} type `waiting`.
969
+ * @property {Workbox} target The `Workbox` instance.
970
+ */
971
+
972
+ /**
973
+ * The `controlling` event is dispatched if a
974
+ * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
975
+ * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}
976
+ * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
977
+ * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}
978
+ * matches the `scriptURL` of the `Workbox` instance's
979
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.
980
+ *
981
+ * @event module:workbox-window.Workbox#controlling
982
+ * @type {WorkboxEvent}
983
+ * @property {ServiceWorker} sw The service worker instance.
984
+ * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
985
+ * event.
986
+ * @property {boolean|undefined} isUpdate True if a service worker was already
987
+ * controlling when this service worker was registered.
988
+ * @property {string} type `controlling`.
989
+ * @property {Workbox} target The `Workbox` instance.
990
+ */
991
+
992
+ /**
993
+ * The `activated` event is dispatched if the state of a
994
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
995
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
996
+ * changes to `activated`.
997
+ *
998
+ * @event module:workbox-window.Workbox#activated
999
+ * @type {WorkboxEvent}
1000
+ * @property {ServiceWorker} sw The service worker instance.
1001
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1002
+ * event.
1003
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1004
+ * controlling when this `Workbox` instance called `register()`.
1005
+ * @property {string} type `activated`.
1006
+ * @property {Workbox} target The `Workbox` instance.
1007
+ */
1008
+
1009
+ /**
1010
+ * The `redundant` event is dispatched if the state of a
1011
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
1012
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
1013
+ * changes to `redundant`.
1014
+ *
1015
+ * @event module:workbox-window.Workbox#redundant
1016
+ * @type {WorkboxEvent}
1017
+ * @property {ServiceWorker} sw The service worker instance.
1018
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1019
+ * event.
1020
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1021
+ * controlling when this `Workbox` instance called `register()`.
1022
+ * @property {string} type `redundant`.
1023
+ * @property {Workbox} target The `Workbox` instance.
1024
+ */
1025
+
1026
+ /**
1027
+ * The `externalinstalled` event is dispatched if the state of an
1028
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1029
+ * changes to `installed`.
1030
+ *
1031
+ * @event module:workbox-window.Workbox#externalinstalled
1032
+ * @type {WorkboxEvent}
1033
+ * @property {ServiceWorker} sw The service worker instance.
1034
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1035
+ * event.
1036
+ * @property {string} type `externalinstalled`.
1037
+ * @property {Workbox} target The `Workbox` instance.
1038
+ */
1039
+
1040
+ /**
1041
+ * The `externalwaiting` event is dispatched if the state of an
1042
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1043
+ * changes to `waiting`.
1044
+ *
1045
+ * @event module:workbox-window.Workbox#externalwaiting
1046
+ * @type {WorkboxEvent}
1047
+ * @property {ServiceWorker} sw The service worker instance.
1048
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1049
+ * event.
1050
+ * @property {string} type `externalwaiting`.
1051
+ * @property {Workbox} target The `Workbox` instance.
1052
+ */
1053
+
1054
+ /**
1055
+ * The `externalactivated` event is dispatched if the state of an
1056
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1057
+ * changes to `activated`.
1058
+ *
1059
+ * @event module:workbox-window.Workbox#externalactivated
1060
+ * @type {WorkboxEvent}
1061
+ * @property {ServiceWorker} sw The service worker instance.
1062
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1063
+ * event.
1064
+ * @property {string} type `externalactivated`.
1065
+ * @property {Workbox} target The `Workbox` instance.
1066
+ */
1067
+
1068
+
1069
+ function _invoke(body, then) {
1070
+ var result = body();
1071
+
1072
+ if (result && result.then) {
1073
+ return result.then(then);
1074
+ }
1075
+
1076
+ return then(result);
1077
+ }
1078
+
1079
+ function _catch(body, recover) {
1080
+ try {
1081
+ var result = body();
1082
+ } catch (e) {
1083
+ return recover(e);
1084
+ }
1085
+
1086
+ if (result && result.then) {
1087
+ return result.then(void 0, recover);
1088
+ }
1089
+
1090
+ return result;
1091
+ }
1092
+
1093
+ export { Workbox, messageSW };
1094
+ //# sourceMappingURL=workbox-window.dev.es5.mjs.map