jekyll-pwa-workbox 0.0.7 → 5.1.41

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-pwa-workbox.rb +5 -5
  3. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-background-sync.dev.js +818 -818
  4. data/lib/vendor/workbox-v5.1.4/workbox-background-sync.dev.js.map +1 -0
  5. data/lib/vendor/workbox-v5.1.4/workbox-background-sync.prod.js +2 -0
  6. data/lib/vendor/workbox-v5.1.4/workbox-background-sync.prod.js.map +1 -0
  7. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-broadcast-update.dev.js +288 -288
  8. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-broadcast-update.dev.js.map +1 -1
  9. data/lib/vendor/workbox-v5.1.4/workbox-broadcast-update.prod.js +2 -0
  10. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-broadcast-update.prod.js.map +1 -1
  11. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-cacheable-response.dev.js +191 -191
  12. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-cacheable-response.dev.js.map +1 -1
  13. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-cacheable-response.prod.js +2 -2
  14. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-cacheable-response.prod.js.map +1 -1
  15. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-core.dev.js +1858 -1882
  16. data/lib/vendor/workbox-v5.1.4/workbox-core.dev.js.map +1 -0
  17. data/lib/vendor/workbox-v5.1.4/workbox-core.prod.js +2 -0
  18. data/lib/vendor/workbox-v5.1.4/workbox-core.prod.js.map +1 -0
  19. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-expiration.dev.js +649 -651
  20. data/lib/vendor/workbox-v5.1.4/workbox-expiration.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v5.1.4/workbox-expiration.prod.js +2 -0
  22. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-expiration.prod.js.map +1 -1
  23. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-navigation-preload.dev.js +102 -102
  24. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-navigation-preload.dev.js.map +1 -1
  25. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-navigation-preload.prod.js +2 -2
  26. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-navigation-preload.prod.js.map +1 -1
  27. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-offline-ga.dev.js +235 -235
  28. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-offline-ga.dev.js.map +1 -1
  29. data/lib/vendor/workbox-v5.1.4/workbox-offline-ga.prod.js +2 -0
  30. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-offline-ga.prod.js.map +1 -1
  31. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-precaching.dev.js +1210 -1222
  32. data/lib/vendor/workbox-v5.1.4/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v5.1.4/workbox-precaching.prod.js +2 -0
  34. data/lib/vendor/workbox-v5.1.4/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-range-requests.dev.js +262 -262
  36. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-range-requests.dev.js.map +1 -1
  37. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-range-requests.prod.js +2 -2
  38. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-range-requests.prod.js.map +1 -1
  39. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-routing.dev.js +923 -923
  40. data/lib/vendor/workbox-v5.1.4/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/workbox-v5.1.4/workbox-routing.prod.js +2 -0
  42. data/lib/vendor/workbox-v5.1.4/workbox-routing.prod.js.map +1 -0
  43. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-strategies.dev.js +923 -923
  44. data/lib/vendor/workbox-v5.1.4/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v5.1.4/workbox-strategies.prod.js +2 -0
  46. data/lib/vendor/workbox-v5.1.4/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-streams.dev.js +318 -318
  48. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-streams.dev.js.map +1 -1
  49. data/lib/vendor/workbox-v5.1.4/workbox-streams.prod.js +2 -0
  50. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-streams.prod.js.map +1 -1
  51. data/lib/vendor/workbox-v5.1.4/workbox-sw.js +2 -0
  52. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-sw.js.map +1 -1
  53. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-window.dev.es5.mjs +1125 -1075
  54. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.es5.mjs.map +1 -0
  55. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-window.dev.mjs +943 -943
  56. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.mjs.map +1 -0
  57. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.4}/workbox-window.dev.umd.js +1136 -1086
  58. data/lib/vendor/workbox-v5.1.4/workbox-window.dev.umd.js.map +1 -0
  59. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.es5.mjs +2 -0
  60. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.es5.mjs.map +1 -0
  61. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.mjs +2 -0
  62. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.mjs.map +1 -0
  63. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.umd.js +2 -0
  64. data/lib/vendor/workbox-v5.1.4/workbox-window.prod.umd.js.map +1 -0
  65. metadata +66 -67
  66. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.dev.js.map +0 -1
  67. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js +0 -2
  68. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js.map +0 -1
  69. data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js +0 -2
  70. data/lib/vendor/workbox-v5.0.0/workbox-core.dev.js.map +0 -1
  71. data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js +0 -2
  72. data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js.map +0 -1
  73. data/lib/vendor/workbox-v5.0.0/workbox-expiration.dev.js.map +0 -1
  74. data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js +0 -2
  75. data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js +0 -2
  76. data/lib/vendor/workbox-v5.0.0/workbox-precaching.dev.js.map +0 -1
  77. data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js +0 -2
  78. data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js.map +0 -1
  79. data/lib/vendor/workbox-v5.0.0/workbox-routing.dev.js.map +0 -1
  80. data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js +0 -2
  81. data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js.map +0 -1
  82. data/lib/vendor/workbox-v5.0.0/workbox-strategies.dev.js.map +0 -1
  83. data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js +0 -2
  84. data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js.map +0 -1
  85. data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js +0 -2
  86. data/lib/vendor/workbox-v5.0.0/workbox-sw.js +0 -2
  87. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.es5.mjs.map +0 -1
  88. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.mjs.map +0 -1
  89. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.umd.js.map +0 -1
  90. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs +0 -2
  91. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs.map +0 -1
  92. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs +0 -2
  93. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs.map +0 -1
  94. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js +0 -2
  95. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js.map +0 -1
@@ -1 +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.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { 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":"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"}
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.4'] && _();\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":"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"}
@@ -0,0 +1,2 @@
1
+ this.workbox=this.workbox||{},this.workbox.streams=function(e,n,t){"use strict";try{self["workbox:streams:5.1.4"]&&_()}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
@@ -1 +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.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { 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,IA/BpD,SAA8BA,UACtBA,aAAkBC,SACXD,EAAOE,KAAKC,YAEnBH,aAAkBI,eACXJ,EAAOG,YAEX,IAAIF,SAASD,GAAQE,KAAKC,aAyBlBE,CAAqBL,KAG9BM,EAAiB,IAAIC,eACvBC,EAAI,QAEFC,EAAS,IAAIL,eAAe,CAC9BM,KAAKC,UACMjB,EAAec,GACjBT,KAAMa,GAAWA,EAAOC,QACxBd,KAAMe,OACHA,EAAOC,aAKPP,GACSd,EAAesB,QAepBL,EAAWM,aACXX,EAAeR,WAIZoB,KAAKR,KAAKC,GAGjBA,EAAWQ,QAAQL,EAAOM,SAE/BC,MAAOC,UAINhB,EAAeiB,OAAOD,GAChBA,KAGdE,SAIIlB,EAAeR,mBAGhB,CAAEiB,KAAMT,EAAemB,QAAShB,OAAAA,GCvF3C,SAASiB,EAAcC,EAAc,UAE3BC,EAAU,IAAIC,QAAQF,UACvBC,EAAQE,IAAI,iBACbF,EAAQG,IAAI,eAAgB,aAEzBH,ECDX,SAASI,EAAsBvC,EAAgBkC,SACrCZ,KAAEA,EAAFN,OAAQA,GAAWjB,EAAYC,GAC/BmC,EAAUF,EAAcC,SAEvB,CAAEZ,KAAAA,EAAMkB,SADE,IAAIhC,SAASQ,EAAQ,CAAEmB,QAAAA,KCV5C,SAASM,WACEC,2GCOX,SAAkBC,EAAiBT,UACxBU,OAASC,MAAAA,EAAOC,QAAAA,EAASC,IAAAA,EAAKC,OAAAA,YAC3BhD,EAAiB2C,EAAgBzC,IAAK+C,GAEjC7C,QAAQC,QAAQ4C,EAAG,CAAEJ,MAAAA,EAAOC,QAAAA,EAASC,IAAAA,EAAKC,OAAAA,SAEjDP,IAAe,OACTnB,KAAEA,EAAFkB,SAAQA,GAAaD,EAAsBvC,EAAgBkC,UAC7DW,GACAA,EAAMK,UAAU5B,GAEbkB,QAQLW,EAAoBnD,EAAeE,IAAI0C,MAAAA,UACnCrC,QAAeJ,SACjBI,aAAkBC,SACXD,EAAO6C,OAOP,IAAI5C,SAASD,GAAQ6C,SAG9BC,QAAkBjD,QAAQkD,IAAIH,GAC9BhB,EAAUF,EAAcC,UAGvB,IAAI1B,SAAS,IAAI+C,KAAKF,GAAY,CAAElB,QAAAA"}
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.4'] && _();\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,CAC9BM,KAAKC,UACMjB,EAAec,GACjBT,KAAMa,GAAWA,EAAOC,QACxBd,KAAMe,OACHA,EAAOC,YAKPP,IACIA,GAAKd,EAAesB,QAepBL,EAAWM,aACXX,EAAeR,WAIZoB,KAAKR,KAAKC,GAGjBA,EAAWQ,QAAQL,EAAOM,SAE/BC,MAAOC,UAINhB,EAAeiB,OAAOD,GAChBA,KAGdE,SAIIlB,EAAeR,mBAGhB,CAAEiB,KAAMT,EAAemB,QAAShB,OAAAA,GCvF3C,SAASiB,EAAcC,EAAc,UAE3BC,EAAU,IAAIC,QAAQF,UACvBC,EAAQE,IAAI,iBACbF,EAAQG,IAAI,eAAgB,aAEzBH,ECDX,SAASI,EAAsBvC,EAAgBkC,SACrCZ,KAAEA,EAAFN,OAAQA,GAAWjB,EAAYC,GAC/BmC,EAAUF,EAAcC,SAEvB,CAAEZ,KAAAA,EAAMkB,SADE,IAAIhC,SAASQ,EAAQ,CAAEmB,QAAAA,KCV5C,SAASM,WACEC,2GCOX,SAAkBC,EAAiBT,UACxBU,OAASC,MAAAA,EAAOC,QAAAA,EAASC,IAAAA,EAAKC,OAAAA,YAC3BhD,EAAiB2C,EAAgBzC,IAAK+C,GAEjC7C,QAAQC,QAAQ4C,EAAG,CAAEJ,MAAAA,EAAOC,QAAAA,EAASC,IAAAA,EAAKC,OAAAA,SAEjDP,IAAe,OACTnB,KAAEA,EAAFkB,SAAQA,GAAaD,EAAsBvC,EAAgBkC,UAC7DW,GACAA,EAAMK,UAAU5B,GAEbkB,QAQLW,EAAoBnD,EAAeE,IAAI0C,MAAAA,UACnCrC,QAAeJ,SACjBI,aAAkBC,SACXD,EAAO6C,OAOP,IAAI5C,SAASD,GAAQ6C,SAG9BC,QAAkBjD,QAAQkD,IAAIH,GAC9BhB,EAAUF,EAAcC,UAGvB,IAAI1B,SAAS,IAAI+C,KAAKF,GAAY,CAAElB,QAAAA"}
@@ -0,0 +1,2 @@
1
+ !function(){"use strict";try{self["workbox:sw:5.1.4"]&&_()}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.4"];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
@@ -1 +1 @@
1
- {"version":3,"file":"workbox-sw.js","sources":["../_version.mjs","../controllers/WorkboxSW.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:sw:5.0.0']&&_()}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","CDN_PATH","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,MAAMC,EAAY,4DAEZC,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,WCpEXhB,KAAKiB,QAAU,ID6ER,MAMLC,0BACOC,EAAI,QACJC,EAAW,CACdC,MAAkC,cAA3BrB,KAAKsB,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,sBAAsBD,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,kCACwBZ,YAAqBO,OAC/CG,GAYVF,EAAeR,MACTN,KAAKP,EAASK,oBACTE,KAAKP,EAASK,aAAaQ,EAAYN,KAAKP,EAASC,WAI1DyB,EAAY,CAAC3C,SAEX4C,KAAcd,KAAcN,KAAKD,OAEjCsB,EAAarB,KAAKP,EAASI,wBAC7BwB,GAMsC,MAJxCF,EAAYE,EAAWC,MAAM,MAIfH,EAAUI,OAAS,IAC/BJ,EAAUK,OAAOL,EAAUI,OAAS,EAAG,GAI3CJ,EAAUM,KAAKL,GAERD,EAAUO,KAAK"}
1
+ {"version":3,"file":"workbox-sw.js","sources":["../_version.mjs","../controllers/WorkboxSW.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:sw:5.1.4']&&_()}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,GAGxBF,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"}
@@ -1,1075 +1,1125 @@
1
- try {
2
- self['workbox:window:5.0.0'] && _();
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.0.0'] && _();
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 =
206
- /*#__PURE__*/
207
- function () {
208
- function WorkboxEventTarget() {
209
- this._eventListenerRegistry = new Map();
210
- }
211
- /**
212
- * @param {string} type
213
- * @param {Function} listener
214
- * @private
215
- */
216
-
217
-
218
- var _proto = WorkboxEventTarget.prototype;
219
-
220
- _proto.addEventListener = function addEventListener(type, listener) {
221
- var foo = this._getEventListenersByType(type);
222
-
223
- foo.add(listener);
224
- }
225
- /**
226
- * @param {string} type
227
- * @param {Function} listener
228
- * @private
229
- */
230
- ;
231
-
232
- _proto.removeEventListener = function removeEventListener(type, listener) {
233
- this._getEventListenersByType(type).delete(listener);
234
- }
235
- /**
236
- * @param {Object} event
237
- * @private
238
- */
239
- ;
240
-
241
- _proto.dispatchEvent = function dispatchEvent(event) {
242
- event.target = this;
243
-
244
- var listeners = this._getEventListenersByType(event.type);
245
-
246
- for (var _iterator = listeners, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
247
- var _ref;
248
-
249
- if (_isArray) {
250
- if (_i >= _iterator.length) break;
251
- _ref = _iterator[_i++];
252
- } else {
253
- _i = _iterator.next();
254
- if (_i.done) break;
255
- _ref = _i.value;
256
- }
257
-
258
- var listener = _ref;
259
- listener(event);
260
- }
261
- }
262
- /**
263
- * Returns a Set of listeners associated with the passed event type.
264
- * If no handlers have been registered, an empty Set is returned.
265
- *
266
- * @param {string} type The event type.
267
- * @return {Set<ListenerCallback>} An array of handler functions.
268
- * @private
269
- */
270
- ;
271
-
272
- _proto._getEventListenersByType = function _getEventListenersByType(type) {
273
- if (!this._eventListenerRegistry.has(type)) {
274
- this._eventListenerRegistry.set(type, new Set());
275
- }
276
-
277
- return this._eventListenerRegistry.get(type);
278
- };
279
-
280
- return WorkboxEventTarget;
281
- }();
282
-
283
- /*
284
- Copyright 2019 Google LLC
285
-
286
- Use of this source code is governed by an MIT-style
287
- license that can be found in the LICENSE file or at
288
- https://opensource.org/licenses/MIT.
289
- */
290
- /**
291
- * Returns true if two URLs have the same `.href` property. The URLS can be
292
- * relative, and if they are the current location href is used to resolve URLs.
293
- *
294
- * @private
295
- * @param {string} url1
296
- * @param {string} url2
297
- * @return {boolean}
298
- */
299
-
300
- function urlsMatch(url1, url2) {
301
- var _location = location,
302
- href = _location.href;
303
- return new URL(url1, href).href === new URL(url2, href).href;
304
- }
305
-
306
- /*
307
- Copyright 2019 Google LLC
308
-
309
- Use of this source code is governed by an MIT-style
310
- license that can be found in the LICENSE file or at
311
- https://opensource.org/licenses/MIT.
312
- */
313
- /**
314
- * A minimal `Event` subclass shim.
315
- * This doesn't *actually* subclass `Event` because not all browsers support
316
- * constructable `EventTarget`, and using a real `Event` will error.
317
- * @private
318
- */
319
-
320
- var WorkboxEvent = function WorkboxEvent(type, props) {
321
- this.type = type;
322
- Object.assign(this, props);
323
- };
324
-
325
- // `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
326
- // chosen, but it seems to avoid false positives in my testing.
327
-
328
- function _await(value, then, direct) {
329
- if (direct) {
330
- return then ? then(value) : value;
331
- }
332
-
333
- if (!value || !value.then) {
334
- value = Promise.resolve(value);
335
- }
336
-
337
- return then ? value.then(then) : value;
338
- }
339
-
340
- var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
341
- // that the registration didn't trigger an update.
342
-
343
- function _async(f) {
344
- return function () {
345
- for (var args = [], i = 0; i < arguments.length; i++) {
346
- args[i] = arguments[i];
347
- }
348
-
349
- try {
350
- return Promise.resolve(f.apply(this, args));
351
- } catch (e) {
352
- return Promise.reject(e);
353
- }
354
- };
355
- }
356
-
357
- var REGISTRATION_TIMEOUT_DURATION = 60000;
358
- /**
359
- * A class to aid in handling service worker registration, updates, and
360
- * reacting to service worker lifecycle events.
361
- *
362
- * @fires [message]{@link module:workbox-window.Workbox#message}
363
- * @fires [installed]{@link module:workbox-window.Workbox#installed}
364
- * @fires [waiting]{@link module:workbox-window.Workbox#waiting}
365
- * @fires [controlling]{@link module:workbox-window.Workbox#controlling}
366
- * @fires [activated]{@link module:workbox-window.Workbox#activated}
367
- * @fires [redundant]{@link module:workbox-window.Workbox#redundant}
368
- * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
369
- * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
370
- * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
371
- * @memberof module:workbox-window
372
- */
373
-
374
- function _empty() {}
375
-
376
- var Workbox =
377
- /*#__PURE__*/
378
- function (_WorkboxEventTarget) {
379
- _inheritsLoose(Workbox, _WorkboxEventTarget);
380
-
381
- /**
382
- * Creates a new Workbox instance with a script URL and service worker
383
- * options. The script URL and options are the same as those used when
384
- * calling `navigator.serviceWorker.register(scriptURL, options)`. See:
385
- * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
386
- *
387
- * @param {string} scriptURL The service worker script associated with this
388
- * instance.
389
- * @param {Object} [registerOptions] The service worker options associated
390
- * with this instance.
391
- */
392
- function Workbox(scriptURL, registerOptions) {
393
- var _this;
394
-
395
- if (registerOptions === void 0) {
396
- registerOptions = {};
397
- }
398
-
399
- _this = _WorkboxEventTarget.call(this) || this;
400
- _this._registerOptions = {};
401
- _this._updateFoundCount = 0; // Deferreds we can resolve later.
402
-
403
- _this._swDeferred = new Deferred();
404
- _this._activeDeferred = new Deferred();
405
- _this._controllingDeferred = new Deferred();
406
- _this._registrationTime = 0;
407
- _this._ownSWs = new Set();
408
- /**
409
- * @private
410
- */
411
-
412
- _this._onUpdateFound = function () {
413
- // `this._registration` will never be `undefined` after an update is found.
414
- var registration = _this._registration;
415
- var installingSW = registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
416
- // different from the current controlling SW's script URL, we know any
417
- // successful registration calls will trigger an `updatefound` event.
418
- // But if the registered script URL is the same as the current controlling
419
- // SW's script URL, we'll only get an `updatefound` event if the file
420
- // changed since it was last registered. This can be a problem if the user
421
- // opens up the same page in a different tab, and that page registers
422
- // a SW that triggers an update. It's a problem because this page has no
423
- // good way of knowing whether the `updatefound` event came from the SW
424
- // script it registered or from a registration attempt made by a newer
425
- // version of the page running in another tab.
426
- // To minimize the possibility of a false positive, we use the logic here:
427
-
428
- var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
429
- // add the `updatefound` event listener until the `register()` call, if
430
- // `_updateFoundCount` is > 0 then it means this method has already
431
- // been called, thus this SW must be external
432
- _this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
433
- // instance's script URL, we know it's definitely not from our
434
- // registration.
435
- !urlsMatch(installingSW.scriptURL, _this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
436
- // Any `updatefound` event that occurs long after our registration is
437
- // assumed to be external.
438
- performance.now() > _this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
439
- // triggered by this instance.
440
- true : false;
441
-
442
- if (updateLikelyTriggeredExternally) {
443
- _this._externalSW = installingSW;
444
- registration.removeEventListener('updatefound', _this._onUpdateFound);
445
- } else {
446
- // If the update was not triggered externally we know the installing
447
- // SW is the one we registered, so we set it.
448
- _this._sw = installingSW;
449
-
450
- _this._ownSWs.add(installingSW);
451
-
452
- _this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
453
- // callback for, but we do log messages for it in development.
454
-
455
-
456
- {
457
- if (navigator.serviceWorker.controller) {
458
- logger.log('Updated service worker found. Installing now...');
459
- } else {
460
- logger.log('Service worker is installing...');
461
- }
462
- }
463
- } // Increment the `updatefound` count, so future invocations of this
464
- // method can be sure they were triggered externally.
465
-
466
-
467
- ++_this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
468
- // triggered externally, since we have callbacks for both.
469
-
470
- installingSW.addEventListener('statechange', _this._onStateChange);
471
- };
472
- /**
473
- * @private
474
- * @param {Event} originalEvent
475
- */
476
-
477
-
478
- _this._onStateChange = function (originalEvent) {
479
- // `this._registration` will never be `undefined` after an update is found.
480
- var registration = _this._registration;
481
- var sw = originalEvent.target;
482
- var state = sw.state;
483
- var isExternal = sw === _this._externalSW;
484
- var eventPrefix = isExternal ? 'external' : '';
485
- var eventProps = {
486
- sw: sw,
487
- originalEvent: originalEvent
488
- };
489
-
490
- if (!isExternal && _this._isUpdate) {
491
- eventProps.isUpdate = true;
492
- }
493
-
494
- _this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
495
-
496
- if (state === 'installed') {
497
- // This timeout is used to ignore cases where the service worker calls
498
- // `skipWaiting()` in the install event, thus moving it directly in the
499
- // activating state. (Since all service workers *must* go through the
500
- // waiting phase, the only way to detect `skipWaiting()` called in the
501
- // install event is to observe that the time spent in the waiting phase
502
- // is very short.)
503
- // NOTE: we don't need separate timeouts for the own and external SWs
504
- // since they can't go through these phases at the same time.
505
- _this._waitingTimeout = self.setTimeout(function () {
506
- // Ensure the SW is still waiting (it may now be redundant).
507
- if (state === 'installed' && registration.waiting === sw) {
508
- _this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
509
-
510
- {
511
- if (isExternal) {
512
- logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
513
- } else {
514
- logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
515
- }
516
- }
517
- }
518
- }, WAITING_TIMEOUT_DURATION);
519
- } else if (state === 'activating') {
520
- clearTimeout(_this._waitingTimeout);
521
-
522
- if (!isExternal) {
523
- _this._activeDeferred.resolve(sw);
524
- }
525
- }
526
-
527
- {
528
- switch (state) {
529
- case 'installed':
530
- if (isExternal) {
531
- logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
532
- } else {
533
- logger.log('Registered service worker installed.');
534
- }
535
-
536
- break;
537
-
538
- case 'activated':
539
- if (isExternal) {
540
- logger.warn('An external service worker has activated.');
541
- } else {
542
- logger.log('Registered service worker activated.');
543
-
544
- if (sw !== navigator.serviceWorker.controller) {
545
- logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
546
- }
547
- }
548
-
549
- break;
550
-
551
- case 'redundant':
552
- if (sw === _this._compatibleControllingSW) {
553
- logger.log('Previously controlling service worker now redundant!');
554
- } else if (!isExternal) {
555
- logger.log('Registered service worker now redundant!');
556
- }
557
-
558
- break;
559
- }
560
- }
561
- };
562
- /**
563
- * @private
564
- * @param {Event} originalEvent
565
- */
566
-
567
-
568
- _this._onControllerChange = function (originalEvent) {
569
- var sw = _this._sw;
570
-
571
- if (sw === navigator.serviceWorker.controller) {
572
- _this.dispatchEvent(new WorkboxEvent('controlling', {
573
- sw: sw,
574
- originalEvent: originalEvent,
575
- isUpdate: _this._isUpdate
576
- }));
577
-
578
- {
579
- logger.log('Registered service worker now controlling this page.');
580
- }
581
-
582
- _this._controllingDeferred.resolve(sw);
583
- }
584
- };
585
- /**
586
- * @private
587
- * @param {Event} originalEvent
588
- */
589
-
590
-
591
- _this._onMessage = _async(function (originalEvent) {
592
- var data = originalEvent.data,
593
- source = originalEvent.source; // Wait until there's an "own" service worker. This is used to buffer
594
- // `message` events that may be received prior to calling `register()`.
595
-
596
- return _await(_this.getSW(), function () {
597
- if (_this._ownSWs.has(source)) {
598
- _this.dispatchEvent(new WorkboxEvent('message', {
599
- data: data,
600
- sw: source,
601
- originalEvent: originalEvent
602
- }));
603
- }
604
- }); // If the service worker that sent the message is in the list of own
605
- // service workers for this instance, dispatch a `message` event.
606
- // NOTE: we check for all previously owned service workers rather than
607
- // just the current one because some messages (e.g. cache updates) use
608
- // a timeout when sent and may be delayed long enough for a service worker
609
- // update to be found.
610
- });
611
- _this._scriptURL = scriptURL;
612
- _this._registerOptions = registerOptions; // Add a message listener immediately since messages received during
613
- // page load are buffered only until the DOMContentLoaded event:
614
- // https://github.com/GoogleChrome/workbox/issues/2202
615
-
616
- navigator.serviceWorker.addEventListener('message', _this._onMessage);
617
- return _this;
618
- }
619
- /**
620
- * Registers a service worker for this instances script URL and service
621
- * worker options. By default this method delays registration until after
622
- * the window has loaded.
623
- *
624
- * @param {Object} [options]
625
- * @param {Function} [options.immediate=false] Setting this to true will
626
- * register the service worker immediately, even if the window has
627
- * not loaded (not recommended).
628
- */
629
-
630
-
631
- var _proto = Workbox.prototype;
632
- _proto.register = _async(function (_temp) {
633
- var _this2 = this;
634
-
635
- var _ref = _temp === void 0 ? {} : _temp,
636
- _ref$immediate = _ref.immediate,
637
- immediate = _ref$immediate === void 0 ? false : _ref$immediate;
638
-
639
- {
640
- if (_this2._registrationTime) {
641
- logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
642
- return;
643
- }
644
- }
645
-
646
- return _invoke(function () {
647
- if (!immediate && document.readyState !== 'complete') {
648
- return _awaitIgnored(new Promise(function (res) {
649
- return window.addEventListener('load', res);
650
- }));
651
- }
652
- }, function () {
653
- // Set this flag to true if any service worker was controlling the page
654
- // at registration time.
655
- _this2._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
656
- // the page, and if that SW script (and version, if specified) matches this
657
- // instance's script.
658
-
659
- _this2._compatibleControllingSW = _this2._getControllingSWIfCompatible();
660
- return _await(_this2._registerScript(), function (_this2$_registerScrip) {
661
- _this2._registration = _this2$_registerScrip;
662
-
663
- // If we have a compatible controller, store the controller as the "own"
664
- // SW, resolve active/controlling deferreds and add necessary listeners.
665
- if (_this2._compatibleControllingSW) {
666
- _this2._sw = _this2._compatibleControllingSW;
667
-
668
- _this2._activeDeferred.resolve(_this2._compatibleControllingSW);
669
-
670
- _this2._controllingDeferred.resolve(_this2._compatibleControllingSW);
671
-
672
- _this2._compatibleControllingSW.addEventListener('statechange', _this2._onStateChange, {
673
- once: true
674
- });
675
- } // If there's a waiting service worker with a matching URL before the
676
- // `updatefound` event fires, it likely means that this site is open
677
- // in another tab, or the user refreshed the page (and thus the previous
678
- // page wasn't fully unloaded before this page started loading).
679
- // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
680
-
681
-
682
- var waitingSW = _this2._registration.waiting;
683
-
684
- if (waitingSW && urlsMatch(waitingSW.scriptURL, _this2._scriptURL)) {
685
- // Store the waiting SW as the "own" Sw, even if it means overwriting
686
- // a compatible controller.
687
- _this2._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
688
- // listener after awaiting `register()` will get this event.
689
-
690
- dontWaitFor(Promise.resolve().then(function () {
691
- _this2.dispatchEvent(new WorkboxEvent('waiting', {
692
- sw: waitingSW,
693
- wasWaitingBeforeRegister: true
694
- }));
695
-
696
- {
697
- logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
698
- }
699
- }));
700
- } // If an "own" SW is already set, resolve the deferred.
701
-
702
-
703
- if (_this2._sw) {
704
- _this2._swDeferred.resolve(_this2._sw);
705
-
706
- _this2._ownSWs.add(_this2._sw);
707
- }
708
-
709
- {
710
- logger.log('Successfully registered service worker.', _this2._scriptURL);
711
-
712
- if (navigator.serviceWorker.controller) {
713
- if (_this2._compatibleControllingSW) {
714
- logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
715
- } else {
716
- logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
717
- }
718
- }
719
-
720
- var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
721
- var scopeURL = new URL(_this2._registerOptions.scope || _this2._scriptURL, document.baseURI);
722
- var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
723
- return !location.pathname.startsWith(scopeURLBasePath);
724
- };
725
-
726
- if (currentPageIsOutOfScope()) {
727
- logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
728
- }
729
- }
730
-
731
- _this2._registration.addEventListener('updatefound', _this2._onUpdateFound);
732
-
733
- navigator.serviceWorker.addEventListener('controllerchange', _this2._onControllerChange, {
734
- once: true
735
- });
736
- return _this2._registration;
737
- });
738
- });
739
- })
740
- /**
741
- * Checks for updates of the registered service worker.
742
- */
743
- ;
744
- _proto.update = _async(function () {
745
- var _this3 = this;
746
-
747
- if (!_this3._registration) {
748
- {
749
- logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
750
- }
751
-
752
- return;
753
- } // Try to update registration
754
-
755
-
756
- return _awaitIgnored(_this3._registration.update());
757
- })
758
- /**
759
- * Resolves to the service worker registered by this instance as soon as it
760
- * is active. If a service worker was already controlling at registration
761
- * time then it will resolve to that if the script URLs (and optionally
762
- * script versions) match, otherwise it will wait until an update is found
763
- * and activates.
764
- *
765
- * @return {Promise<ServiceWorker>}
766
- */
767
- ;
768
-
769
- /**
770
- * Resolves with a reference to a service worker that matches the script URL
771
- * of this instance, as soon as it's available.
772
- *
773
- * If, at registration time, there's already an active or waiting service
774
- * worker with a matching script URL, it will be used (with the waiting
775
- * service worker taking precedence over the active service worker if both
776
- * match, since the waiting service worker would have been registered more
777
- * recently).
778
- * If there's no matching active or waiting service worker at registration
779
- * time then the promise will not resolve until an update is found and starts
780
- * installing, at which point the installing service worker is used.
781
- *
782
- * @return {Promise<ServiceWorker>}
783
- */
784
- _proto.getSW = _async(function () {
785
- var _this4 = this;
786
-
787
- // If `this._sw` is set, resolve with that as we want `getSW()` to
788
- // return the correct (new) service worker if an update is found.
789
- return _this4._sw !== undefined ? _this4._sw : _this4._swDeferred.promise;
790
- })
791
- /**
792
- * Sends the passed data object to the service worker registered by this
793
- * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
794
- * with a response (if any).
795
- *
796
- * A response can be set in a message handler in the service worker by
797
- * calling `event.ports[0].postMessage(...)`, which will resolve the promise
798
- * returned by `messageSW()`. If no response is set, the promise will never
799
- * resolve.
800
- *
801
- * @param {Object} data An object to send to the service worker
802
- * @return {Promise<Object>}
803
- */
804
- ;
805
- _proto.messageSW = _async(function (data) {
806
- var _this5 = this;
807
-
808
- return _await(_this5.getSW(), function (sw) {
809
- return messageSW(sw, data);
810
- });
811
- })
812
- /**
813
- * Checks for a service worker already controlling the page and returns
814
- * it if its script URL matches.
815
- *
816
- * @private
817
- * @return {ServiceWorker|undefined}
818
- */
819
- ;
820
-
821
- _proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
822
- var controller = navigator.serviceWorker.controller;
823
-
824
- if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
825
- return controller;
826
- } else {
827
- return undefined;
828
- }
829
- }
830
- /**
831
- * Registers a service worker for this instances script URL and register
832
- * options and tracks the time registration was complete.
833
- *
834
- * @private
835
- */
836
- ;
837
-
838
- _proto._registerScript = _async(function () {
839
- var _this6 = this;
840
-
841
- return _catch(function () {
842
- return _await(navigator.serviceWorker.register(_this6._scriptURL, _this6._registerOptions), function (reg) {
843
- // Keep track of when registration happened, so it can be used in the
844
- // `this._onUpdateFound` heuristic. Also use the presence of this
845
- // property as a way to see if `.register()` has been called.
846
- _this6._registrationTime = performance.now();
847
- return reg;
848
- });
849
- }, function (error) {
850
- {
851
- logger.error(error);
852
- } // Re-throw the error.
853
-
854
-
855
- throw error;
856
- });
857
- });
858
-
859
- _createClass(Workbox, [{
860
- key: "active",
861
- get: function get() {
862
- return this._activeDeferred.promise;
863
- }
864
- /**
865
- * Resolves to the service worker registered by this instance as soon as it
866
- * is controlling the page. If a service worker was already controlling at
867
- * registration time then it will resolve to that if the script URLs (and
868
- * optionally script versions) match, otherwise it will wait until an update
869
- * is found and starts controlling the page.
870
- * Note: the first time a service worker is installed it will active but
871
- * not start controlling the page unless `clients.claim()` is called in the
872
- * service worker.
873
- *
874
- * @return {Promise<ServiceWorker>}
875
- */
876
-
877
- }, {
878
- key: "controlling",
879
- get: function get() {
880
- return this._controllingDeferred.promise;
881
- }
882
- }]);
883
-
884
- return Workbox;
885
- }(WorkboxEventTarget);
886
-
887
- function _awaitIgnored(value, direct) {
888
- if (!direct) {
889
- return value && value.then ? value.then(_empty) : Promise.resolve();
890
- }
891
- } // The jsdoc comments below outline the events this instance may dispatch:
892
- // -----------------------------------------------------------------------
893
-
894
- /**
895
- * The `message` event is dispatched any time a `postMessage` is received.
896
- *
897
- * @event module:workbox-window.Workbox#message
898
- * @type {WorkboxEvent}
899
- * @property {*} data The `data` property from the original `message` event.
900
- * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}
901
- * event.
902
- * @property {string} type `message`.
903
- * @property {Workbox} target The `Workbox` instance.
904
- */
905
-
906
- /**
907
- * The `installed` event is dispatched if the state of a
908
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
909
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
910
- * changes to `installed`.
911
- *
912
- * Then can happen either the very first time a service worker is installed,
913
- * or after an update to the current service worker is found. In the case
914
- * of an update being found, the event's `isUpdate` property will be `true`.
915
- *
916
- * @event module:workbox-window.Workbox#installed
917
- * @type {WorkboxEvent}
918
- * @property {ServiceWorker} sw The service worker instance.
919
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
920
- * event.
921
- * @property {boolean|undefined} isUpdate True if a service worker was already
922
- * controlling when this `Workbox` instance called `register()`.
923
- * @property {string} type `installed`.
924
- * @property {Workbox} target The `Workbox` instance.
925
- */
926
-
927
- /**
928
- * The `waiting` event is dispatched if the state of a
929
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
930
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
931
- * changes to `installed` and then doesn't immediately change to `activating`.
932
- * It may also be dispatched if a service worker with the same
933
- * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
934
- * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}
935
- * method was called.
936
- *
937
- * @event module:workbox-window.Workbox#waiting
938
- * @type {WorkboxEvent}
939
- * @property {ServiceWorker} sw The service worker instance.
940
- * @property {Event|undefined} originalEvent The original
941
- * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
942
- * event, or `undefined` in the case where the service worker was waiting
943
- * to before `.register()` was called.
944
- * @property {boolean|undefined} isUpdate True if a service worker was already
945
- * controlling when this `Workbox` instance called `register()`.
946
- * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with
947
- * a matching `scriptURL` was already waiting when this `Workbox`
948
- * instance called `register()`.
949
- * @property {string} type `waiting`.
950
- * @property {Workbox} target The `Workbox` instance.
951
- */
952
-
953
- /**
954
- * The `controlling` event is dispatched if a
955
- * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
956
- * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}
957
- * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
958
- * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}
959
- * matches the `scriptURL` of the `Workbox` instance's
960
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.
961
- *
962
- * @event module:workbox-window.Workbox#controlling
963
- * @type {WorkboxEvent}
964
- * @property {ServiceWorker} sw The service worker instance.
965
- * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
966
- * event.
967
- * @property {boolean|undefined} isUpdate True if a service worker was already
968
- * controlling when this service worker was registered.
969
- * @property {string} type `controlling`.
970
- * @property {Workbox} target The `Workbox` instance.
971
- */
972
-
973
- /**
974
- * The `activated` event is dispatched if the state of a
975
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
976
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
977
- * changes to `activated`.
978
- *
979
- * @event module:workbox-window.Workbox#activated
980
- * @type {WorkboxEvent}
981
- * @property {ServiceWorker} sw The service worker instance.
982
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
983
- * event.
984
- * @property {boolean|undefined} isUpdate True if a service worker was already
985
- * controlling when this `Workbox` instance called `register()`.
986
- * @property {string} type `activated`.
987
- * @property {Workbox} target The `Workbox` instance.
988
- */
989
-
990
- /**
991
- * The `redundant` event is dispatched if the state of a
992
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
993
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
994
- * changes to `redundant`.
995
- *
996
- * @event module:workbox-window.Workbox#redundant
997
- * @type {WorkboxEvent}
998
- * @property {ServiceWorker} sw The service worker instance.
999
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1000
- * event.
1001
- * @property {boolean|undefined} isUpdate True if a service worker was already
1002
- * controlling when this `Workbox` instance called `register()`.
1003
- * @property {string} type `redundant`.
1004
- * @property {Workbox} target The `Workbox` instance.
1005
- */
1006
-
1007
- /**
1008
- * The `externalinstalled` event is dispatched if the state of an
1009
- * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1010
- * changes to `installed`.
1011
- *
1012
- * @event module:workbox-window.Workbox#externalinstalled
1013
- * @type {WorkboxEvent}
1014
- * @property {ServiceWorker} sw The service worker instance.
1015
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1016
- * event.
1017
- * @property {string} type `externalinstalled`.
1018
- * @property {Workbox} target The `Workbox` instance.
1019
- */
1020
-
1021
- /**
1022
- * The `externalwaiting` event is dispatched if the state of an
1023
- * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1024
- * changes to `waiting`.
1025
- *
1026
- * @event module:workbox-window.Workbox#externalwaiting
1027
- * @type {WorkboxEvent}
1028
- * @property {ServiceWorker} sw The service worker instance.
1029
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1030
- * event.
1031
- * @property {string} type `externalwaiting`.
1032
- * @property {Workbox} target The `Workbox` instance.
1033
- */
1034
-
1035
- /**
1036
- * The `externalactivated` event is dispatched if the state of an
1037
- * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1038
- * changes to `activated`.
1039
- *
1040
- * @event module:workbox-window.Workbox#externalactivated
1041
- * @type {WorkboxEvent}
1042
- * @property {ServiceWorker} sw The service worker instance.
1043
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1044
- * event.
1045
- * @property {string} type `externalactivated`.
1046
- * @property {Workbox} target The `Workbox` instance.
1047
- */
1048
-
1049
-
1050
- function _invoke(body, then) {
1051
- var result = body();
1052
-
1053
- if (result && result.then) {
1054
- return result.then(then);
1055
- }
1056
-
1057
- return then(result);
1058
- }
1059
-
1060
- function _catch(body, recover) {
1061
- try {
1062
- var result = body();
1063
- } catch (e) {
1064
- return recover(e);
1065
- }
1066
-
1067
- if (result && result.then) {
1068
- return result.then(void 0, recover);
1069
- }
1070
-
1071
- return result;
1072
- }
1073
-
1074
- export { Workbox, messageSW };
1075
- //# sourceMappingURL=workbox-window.dev.es5.mjs.map
1
+ try {
2
+ self['workbox:window:5.1.4'] && _();
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
+ function _unsupportedIterableToArray(o, minLen) {
62
+ if (!o) return;
63
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
64
+ var n = Object.prototype.toString.call(o).slice(8, -1);
65
+ if (n === "Object" && o.constructor) n = o.constructor.name;
66
+ if (n === "Map" || n === "Set") return Array.from(o);
67
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
68
+ }
69
+
70
+ function _arrayLikeToArray(arr, len) {
71
+ if (len == null || len > arr.length) len = arr.length;
72
+
73
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
74
+
75
+ return arr2;
76
+ }
77
+
78
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
79
+ var it;
80
+
81
+ if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
82
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
83
+ if (it) o = it;
84
+ var i = 0;
85
+ return function () {
86
+ if (i >= o.length) return {
87
+ done: true
88
+ };
89
+ return {
90
+ done: false,
91
+ value: o[i++]
92
+ };
93
+ };
94
+ }
95
+
96
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
97
+ }
98
+
99
+ it = o[Symbol.iterator]();
100
+ return it.next.bind(it);
101
+ }
102
+
103
+ try {
104
+ self['workbox:core:5.1.4'] && _();
105
+ } catch (e) {}
106
+
107
+ /*
108
+ Copyright 2018 Google LLC
109
+
110
+ Use of this source code is governed by an MIT-style
111
+ license that can be found in the LICENSE file or at
112
+ https://opensource.org/licenses/MIT.
113
+ */
114
+ /**
115
+ * The Deferred class composes Promises in a way that allows for them to be
116
+ * resolved or rejected from outside the constructor. In most cases promises
117
+ * should be used directly, but Deferreds can be necessary when the logic to
118
+ * resolve a promise must be separate.
119
+ *
120
+ * @private
121
+ */
122
+
123
+ var Deferred =
124
+ /**
125
+ * Creates a promise and exposes its resolve and reject functions as methods.
126
+ */
127
+ function Deferred() {
128
+ var _this = this;
129
+
130
+ this.promise = new Promise(function (resolve, reject) {
131
+ _this.resolve = resolve;
132
+ _this.reject = reject;
133
+ });
134
+ };
135
+
136
+ /*
137
+ Copyright 2019 Google LLC
138
+ Use of this source code is governed by an MIT-style
139
+ license that can be found in the LICENSE file or at
140
+ https://opensource.org/licenses/MIT.
141
+ */
142
+ /**
143
+ * A helper function that prevents a promise from being flagged as unused.
144
+ *
145
+ * @private
146
+ **/
147
+
148
+ function dontWaitFor(promise) {
149
+ // Effective no-op.
150
+ promise.then(function () {});
151
+ }
152
+
153
+ /*
154
+ Copyright 2019 Google LLC
155
+ Use of this source code is governed by an MIT-style
156
+ license that can be found in the LICENSE file or at
157
+ https://opensource.org/licenses/MIT.
158
+ */
159
+ var logger = function () {
160
+ // Don't overwrite this value if it's already set.
161
+ // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
162
+ if (!('__WB_DISABLE_DEV_LOGS' in self)) {
163
+ self.__WB_DISABLE_DEV_LOGS = false;
164
+ }
165
+
166
+ var inGroup = false;
167
+ var methodToColorMap = {
168
+ debug: "#7f8c8d",
169
+ log: "#2ecc71",
170
+ warn: "#f39c12",
171
+ error: "#c0392b",
172
+ groupCollapsed: "#3498db",
173
+ groupEnd: null
174
+ };
175
+
176
+ var print = function print(method, args) {
177
+ var _console2;
178
+
179
+ if (self.__WB_DISABLE_DEV_LOGS) {
180
+ return;
181
+ }
182
+
183
+ if (method === 'groupCollapsed') {
184
+ // Safari doesn't print all console.groupCollapsed() arguments:
185
+ // https://bugs.webkit.org/show_bug.cgi?id=182754
186
+ if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
187
+ var _console;
188
+
189
+ (_console = console)[method].apply(_console, args);
190
+
191
+ return;
192
+ }
193
+ }
194
+
195
+ 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.
196
+
197
+ var logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
198
+
199
+ (_console2 = console)[method].apply(_console2, logPrefix.concat(args));
200
+
201
+ if (method === 'groupCollapsed') {
202
+ inGroup = true;
203
+ }
204
+
205
+ if (method === 'groupEnd') {
206
+ inGroup = false;
207
+ }
208
+ };
209
+
210
+ var api = {};
211
+ var loggerMethods = Object.keys(methodToColorMap);
212
+
213
+ var _loop = function _loop() {
214
+ var key = _loggerMethods[_i];
215
+ var method = key;
216
+
217
+ api[method] = function () {
218
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
219
+ args[_key] = arguments[_key];
220
+ }
221
+
222
+ print(method, args);
223
+ };
224
+ };
225
+
226
+ for (var _i = 0, _loggerMethods = loggerMethods; _i < _loggerMethods.length; _i++) {
227
+ _loop();
228
+ }
229
+
230
+ return api;
231
+ }();
232
+
233
+ /*
234
+ Copyright 2019 Google LLC
235
+
236
+ Use of this source code is governed by an MIT-style
237
+ license that can be found in the LICENSE file or at
238
+ https://opensource.org/licenses/MIT.
239
+ */
240
+
241
+ /**
242
+ * A minimal `EventTarget` shim.
243
+ * This is necessary because not all browsers support constructable
244
+ * `EventTarget`, so using a real `EventTarget` will error.
245
+ * @private
246
+ */
247
+ var WorkboxEventTarget = /*#__PURE__*/function () {
248
+ function WorkboxEventTarget() {
249
+ this._eventListenerRegistry = new Map();
250
+ }
251
+ /**
252
+ * @param {string} type
253
+ * @param {Function} listener
254
+ * @private
255
+ */
256
+
257
+
258
+ var _proto = WorkboxEventTarget.prototype;
259
+
260
+ _proto.addEventListener = function addEventListener(type, listener) {
261
+ var foo = this._getEventListenersByType(type);
262
+
263
+ foo.add(listener);
264
+ }
265
+ /**
266
+ * @param {string} type
267
+ * @param {Function} listener
268
+ * @private
269
+ */
270
+ ;
271
+
272
+ _proto.removeEventListener = function removeEventListener(type, listener) {
273
+ this._getEventListenersByType(type).delete(listener);
274
+ }
275
+ /**
276
+ * @param {Object} event
277
+ * @private
278
+ */
279
+ ;
280
+
281
+ _proto.dispatchEvent = function dispatchEvent(event) {
282
+ event.target = this;
283
+
284
+ var listeners = this._getEventListenersByType(event.type);
285
+
286
+ for (var _iterator = _createForOfIteratorHelperLoose(listeners), _step; !(_step = _iterator()).done;) {
287
+ var listener = _step.value;
288
+ listener(event);
289
+ }
290
+ }
291
+ /**
292
+ * Returns a Set of listeners associated with the passed event type.
293
+ * If no handlers have been registered, an empty Set is returned.
294
+ *
295
+ * @param {string} type The event type.
296
+ * @return {Set<ListenerCallback>} An array of handler functions.
297
+ * @private
298
+ */
299
+ ;
300
+
301
+ _proto._getEventListenersByType = function _getEventListenersByType(type) {
302
+ if (!this._eventListenerRegistry.has(type)) {
303
+ this._eventListenerRegistry.set(type, new Set());
304
+ }
305
+
306
+ return this._eventListenerRegistry.get(type);
307
+ };
308
+
309
+ return WorkboxEventTarget;
310
+ }();
311
+
312
+ /*
313
+ Copyright 2019 Google LLC
314
+
315
+ Use of this source code is governed by an MIT-style
316
+ license that can be found in the LICENSE file or at
317
+ https://opensource.org/licenses/MIT.
318
+ */
319
+ /**
320
+ * Returns true if two URLs have the same `.href` property. The URLS can be
321
+ * relative, and if they are the current location href is used to resolve URLs.
322
+ *
323
+ * @private
324
+ * @param {string} url1
325
+ * @param {string} url2
326
+ * @return {boolean}
327
+ */
328
+
329
+ function urlsMatch(url1, url2) {
330
+ var _location = location,
331
+ href = _location.href;
332
+ return new URL(url1, href).href === new URL(url2, href).href;
333
+ }
334
+
335
+ /*
336
+ Copyright 2019 Google LLC
337
+
338
+ Use of this source code is governed by an MIT-style
339
+ license that can be found in the LICENSE file or at
340
+ https://opensource.org/licenses/MIT.
341
+ */
342
+ /**
343
+ * A minimal `Event` subclass shim.
344
+ * This doesn't *actually* subclass `Event` because not all browsers support
345
+ * constructable `EventTarget`, and using a real `Event` will error.
346
+ * @private
347
+ */
348
+
349
+ var WorkboxEvent = function WorkboxEvent(type, props) {
350
+ this.type = type;
351
+ Object.assign(this, props);
352
+ };
353
+
354
+ // `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
355
+ // chosen, but it seems to avoid false positives in my testing.
356
+
357
+ function _await(value, then, direct) {
358
+ if (direct) {
359
+ return then ? then(value) : value;
360
+ }
361
+
362
+ if (!value || !value.then) {
363
+ value = Promise.resolve(value);
364
+ }
365
+
366
+ return then ? value.then(then) : value;
367
+ }
368
+
369
+ var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
370
+ // that the registration didn't trigger an update.
371
+
372
+ function _async(f) {
373
+ return function () {
374
+ for (var args = [], i = 0; i < arguments.length; i++) {
375
+ args[i] = arguments[i];
376
+ }
377
+
378
+ try {
379
+ return Promise.resolve(f.apply(this, args));
380
+ } catch (e) {
381
+ return Promise.reject(e);
382
+ }
383
+ };
384
+ }
385
+
386
+ var REGISTRATION_TIMEOUT_DURATION = 60000;
387
+ /**
388
+ * A class to aid in handling service worker registration, updates, and
389
+ * reacting to service worker lifecycle events.
390
+ *
391
+ * @fires [message]{@link module:workbox-window.Workbox#message}
392
+ * @fires [installed]{@link module:workbox-window.Workbox#installed}
393
+ * @fires [waiting]{@link module:workbox-window.Workbox#waiting}
394
+ * @fires [controlling]{@link module:workbox-window.Workbox#controlling}
395
+ * @fires [activated]{@link module:workbox-window.Workbox#activated}
396
+ * @fires [redundant]{@link module:workbox-window.Workbox#redundant}
397
+ * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
398
+ * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
399
+ * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
400
+ * @memberof module:workbox-window
401
+ */
402
+
403
+ function _empty() {}
404
+
405
+ var Workbox = /*#__PURE__*/function (_WorkboxEventTarget) {
406
+ _inheritsLoose(Workbox, _WorkboxEventTarget);
407
+
408
+ /**
409
+ * Creates a new Workbox instance with a script URL and service worker
410
+ * options. The script URL and options are the same as those used when
411
+ * calling `navigator.serviceWorker.register(scriptURL, options)`. See:
412
+ * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
413
+ *
414
+ * @param {string} scriptURL The service worker script associated with this
415
+ * instance.
416
+ * @param {Object} [registerOptions] The service worker options associated
417
+ * with this instance.
418
+ */
419
+ function Workbox(scriptURL, registerOptions) {
420
+ var _this;
421
+
422
+ if (registerOptions === void 0) {
423
+ registerOptions = {};
424
+ }
425
+
426
+ _this = _WorkboxEventTarget.call(this) || this;
427
+ _this._registerOptions = {};
428
+ _this._updateFoundCount = 0; // Deferreds we can resolve later.
429
+
430
+ _this._swDeferred = new Deferred();
431
+ _this._activeDeferred = new Deferred();
432
+ _this._controllingDeferred = new Deferred();
433
+ _this._registrationTime = 0;
434
+ _this._ownSWs = new Set();
435
+ /**
436
+ * @private
437
+ */
438
+
439
+ _this._onUpdateFound = function () {
440
+ // `this._registration` will never be `undefined` after an update is found.
441
+ var registration = _this._registration;
442
+ var installingSW = registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
443
+ // different from the current controlling SW's script URL, we know any
444
+ // successful registration calls will trigger an `updatefound` event.
445
+ // But if the registered script URL is the same as the current controlling
446
+ // SW's script URL, we'll only get an `updatefound` event if the file
447
+ // changed since it was last registered. This can be a problem if the user
448
+ // opens up the same page in a different tab, and that page registers
449
+ // a SW that triggers an update. It's a problem because this page has no
450
+ // good way of knowing whether the `updatefound` event came from the SW
451
+ // script it registered or from a registration attempt made by a newer
452
+ // version of the page running in another tab.
453
+ // To minimize the possibility of a false positive, we use the logic here:
454
+
455
+ var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
456
+ // add the `updatefound` event listener until the `register()` call, if
457
+ // `_updateFoundCount` is > 0 then it means this method has already
458
+ // been called, thus this SW must be external
459
+ _this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
460
+ // instance's script URL, we know it's definitely not from our
461
+ // registration.
462
+ !urlsMatch(installingSW.scriptURL, _this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
463
+ // Any `updatefound` event that occurs long after our registration is
464
+ // assumed to be external.
465
+ performance.now() > _this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
466
+ // triggered by this instance.
467
+ true : false;
468
+
469
+ if (updateLikelyTriggeredExternally) {
470
+ _this._externalSW = installingSW;
471
+ registration.removeEventListener('updatefound', _this._onUpdateFound);
472
+ } else {
473
+ // If the update was not triggered externally we know the installing
474
+ // SW is the one we registered, so we set it.
475
+ _this._sw = installingSW;
476
+
477
+ _this._ownSWs.add(installingSW);
478
+
479
+ _this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
480
+ // callback for, but we do log messages for it in development.
481
+
482
+
483
+ {
484
+ if (navigator.serviceWorker.controller) {
485
+ logger.log('Updated service worker found. Installing now...');
486
+ } else {
487
+ logger.log('Service worker is installing...');
488
+ }
489
+ }
490
+ } // Increment the `updatefound` count, so future invocations of this
491
+ // method can be sure they were triggered externally.
492
+
493
+
494
+ ++_this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
495
+ // triggered externally, since we have callbacks for both.
496
+
497
+ installingSW.addEventListener('statechange', _this._onStateChange);
498
+ };
499
+ /**
500
+ * @private
501
+ * @param {Event} originalEvent
502
+ */
503
+
504
+
505
+ _this._onStateChange = function (originalEvent) {
506
+ // `this._registration` will never be `undefined` after an update is found.
507
+ var registration = _this._registration;
508
+ var sw = originalEvent.target;
509
+ var state = sw.state;
510
+ var isExternal = sw === _this._externalSW;
511
+ var eventPrefix = isExternal ? 'external' : '';
512
+ var eventProps = {
513
+ sw: sw,
514
+ originalEvent: originalEvent
515
+ };
516
+
517
+ if (!isExternal && _this._isUpdate) {
518
+ eventProps.isUpdate = true;
519
+ }
520
+
521
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
522
+
523
+ if (state === 'installed') {
524
+ // This timeout is used to ignore cases where the service worker calls
525
+ // `skipWaiting()` in the install event, thus moving it directly in the
526
+ // activating state. (Since all service workers *must* go through the
527
+ // waiting phase, the only way to detect `skipWaiting()` called in the
528
+ // install event is to observe that the time spent in the waiting phase
529
+ // is very short.)
530
+ // NOTE: we don't need separate timeouts for the own and external SWs
531
+ // since they can't go through these phases at the same time.
532
+ _this._waitingTimeout = self.setTimeout(function () {
533
+ // Ensure the SW is still waiting (it may now be redundant).
534
+ if (state === 'installed' && registration.waiting === sw) {
535
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
536
+
537
+ {
538
+ if (isExternal) {
539
+ logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
540
+ } else {
541
+ logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
542
+ }
543
+ }
544
+ }
545
+ }, WAITING_TIMEOUT_DURATION);
546
+ } else if (state === 'activating') {
547
+ clearTimeout(_this._waitingTimeout);
548
+
549
+ if (!isExternal) {
550
+ _this._activeDeferred.resolve(sw);
551
+ }
552
+ }
553
+
554
+ {
555
+ switch (state) {
556
+ case 'installed':
557
+ if (isExternal) {
558
+ logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
559
+ } else {
560
+ logger.log('Registered service worker installed.');
561
+ }
562
+
563
+ break;
564
+
565
+ case 'activated':
566
+ if (isExternal) {
567
+ logger.warn('An external service worker has activated.');
568
+ } else {
569
+ logger.log('Registered service worker activated.');
570
+
571
+ if (sw !== navigator.serviceWorker.controller) {
572
+ logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
573
+ }
574
+ }
575
+
576
+ break;
577
+
578
+ case 'redundant':
579
+ if (sw === _this._compatibleControllingSW) {
580
+ logger.log('Previously controlling service worker now redundant!');
581
+ } else if (!isExternal) {
582
+ logger.log('Registered service worker now redundant!');
583
+ }
584
+
585
+ break;
586
+ }
587
+ }
588
+ };
589
+ /**
590
+ * @private
591
+ * @param {Event} originalEvent
592
+ */
593
+
594
+
595
+ _this._onControllerChange = function (originalEvent) {
596
+ var sw = _this._sw;
597
+
598
+ if (sw === navigator.serviceWorker.controller) {
599
+ _this.dispatchEvent(new WorkboxEvent('controlling', {
600
+ sw: sw,
601
+ originalEvent: originalEvent,
602
+ isUpdate: _this._isUpdate
603
+ }));
604
+
605
+ {
606
+ logger.log('Registered service worker now controlling this page.');
607
+ }
608
+
609
+ _this._controllingDeferred.resolve(sw);
610
+ }
611
+ };
612
+ /**
613
+ * @private
614
+ * @param {Event} originalEvent
615
+ */
616
+
617
+
618
+ _this._onMessage = _async(function (originalEvent) {
619
+ var data = originalEvent.data,
620
+ source = originalEvent.source; // Wait until there's an "own" service worker. This is used to buffer
621
+ // `message` events that may be received prior to calling `register()`.
622
+
623
+ return _await(_this.getSW(), function () {
624
+ if (_this._ownSWs.has(source)) {
625
+ _this.dispatchEvent(new WorkboxEvent('message', {
626
+ data: data,
627
+ sw: source,
628
+ originalEvent: originalEvent
629
+ }));
630
+ }
631
+ }); // If the service worker that sent the message is in the list of own
632
+ // service workers for this instance, dispatch a `message` event.
633
+ // NOTE: we check for all previously owned service workers rather than
634
+ // just the current one because some messages (e.g. cache updates) use
635
+ // a timeout when sent and may be delayed long enough for a service worker
636
+ // update to be found.
637
+ });
638
+ _this._scriptURL = scriptURL;
639
+ _this._registerOptions = registerOptions; // Add a message listener immediately since messages received during
640
+ // page load are buffered only until the DOMContentLoaded event:
641
+ // https://github.com/GoogleChrome/workbox/issues/2202
642
+
643
+ navigator.serviceWorker.addEventListener('message', _this._onMessage);
644
+ return _this;
645
+ }
646
+ /**
647
+ * Registers a service worker for this instances script URL and service
648
+ * worker options. By default this method delays registration until after
649
+ * the window has loaded.
650
+ *
651
+ * @param {Object} [options]
652
+ * @param {Function} [options.immediate=false] Setting this to true will
653
+ * register the service worker immediately, even if the window has
654
+ * not loaded (not recommended).
655
+ */
656
+
657
+
658
+ var _proto = Workbox.prototype;
659
+
660
+ _proto.register = function register(_temp) {
661
+ var _ref = _temp === void 0 ? {} : _temp,
662
+ _ref$immediate = _ref.immediate,
663
+ immediate = _ref$immediate === void 0 ? false : _ref$immediate;
664
+
665
+ try {
666
+ var _this3 = this;
667
+
668
+ if ("dev" !== 'production') {
669
+ if (_this3._registrationTime) {
670
+ logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
671
+ return;
672
+ }
673
+ }
674
+
675
+ return _invoke(function () {
676
+ if (!immediate && document.readyState !== 'complete') {
677
+ return _awaitIgnored(new Promise(function (res) {
678
+ return window.addEventListener('load', res);
679
+ }));
680
+ }
681
+ }, function () {
682
+ // Set this flag to true if any service worker was controlling the page
683
+ // at registration time.
684
+ _this3._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
685
+ // the page, and if that SW script (and version, if specified) matches this
686
+ // instance's script.
687
+
688
+ _this3._compatibleControllingSW = _this3._getControllingSWIfCompatible();
689
+ return _await(_this3._registerScript(), function (_this2$_registerScrip) {
690
+ _this3._registration = _this2$_registerScrip;
691
+
692
+ // If we have a compatible controller, store the controller as the "own"
693
+ // SW, resolve active/controlling deferreds and add necessary listeners.
694
+ if (_this3._compatibleControllingSW) {
695
+ _this3._sw = _this3._compatibleControllingSW;
696
+
697
+ _this3._activeDeferred.resolve(_this3._compatibleControllingSW);
698
+
699
+ _this3._controllingDeferred.resolve(_this3._compatibleControllingSW);
700
+
701
+ _this3._compatibleControllingSW.addEventListener('statechange', _this3._onStateChange, {
702
+ once: true
703
+ });
704
+ } // If there's a waiting service worker with a matching URL before the
705
+ // `updatefound` event fires, it likely means that this site is open
706
+ // in another tab, or the user refreshed the page (and thus the previous
707
+ // page wasn't fully unloaded before this page started loading).
708
+ // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
709
+
710
+
711
+ var waitingSW = _this3._registration.waiting;
712
+
713
+ if (waitingSW && urlsMatch(waitingSW.scriptURL, _this3._scriptURL)) {
714
+ // Store the waiting SW as the "own" Sw, even if it means overwriting
715
+ // a compatible controller.
716
+ _this3._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
717
+ // listener after awaiting `register()` will get this event.
718
+
719
+ dontWaitFor(Promise.resolve().then(function () {
720
+ _this3.dispatchEvent(new WorkboxEvent('waiting', {
721
+ sw: waitingSW,
722
+ wasWaitingBeforeRegister: true
723
+ }));
724
+
725
+ if ("dev" !== 'production') {
726
+ logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
727
+ }
728
+ }));
729
+ } // If an "own" SW is already set, resolve the deferred.
730
+
731
+
732
+ if (_this3._sw) {
733
+ _this3._swDeferred.resolve(_this3._sw);
734
+
735
+ _this3._ownSWs.add(_this3._sw);
736
+ }
737
+
738
+ if ("dev" !== 'production') {
739
+ logger.log('Successfully registered service worker.', _this3._scriptURL);
740
+
741
+ if (navigator.serviceWorker.controller) {
742
+ if (_this3._compatibleControllingSW) {
743
+ logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
744
+ } else {
745
+ logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
746
+ }
747
+ }
748
+
749
+ var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
750
+ var scopeURL = new URL(_this3._registerOptions.scope || _this3._scriptURL, document.baseURI);
751
+ var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
752
+ return !location.pathname.startsWith(scopeURLBasePath);
753
+ };
754
+
755
+ if (currentPageIsOutOfScope()) {
756
+ logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
757
+ }
758
+ }
759
+
760
+ _this3._registration.addEventListener('updatefound', _this3._onUpdateFound);
761
+
762
+ navigator.serviceWorker.addEventListener('controllerchange', _this3._onControllerChange, {
763
+ once: true
764
+ });
765
+ return _this3._registration;
766
+ });
767
+ });
768
+ } catch (e) {
769
+ return Promise.reject(e);
770
+ }
771
+ }
772
+ /**
773
+ * Checks for updates of the registered service worker.
774
+ */
775
+ ;
776
+
777
+ _proto.update = function update() {
778
+ try {
779
+ var _this5 = this;
780
+
781
+ if (!_this5._registration) {
782
+ if ("dev" !== 'production') {
783
+ logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
784
+ }
785
+
786
+ return;
787
+ } // Try to update registration
788
+
789
+
790
+ return _awaitIgnored(_this5._registration.update());
791
+ } catch (e) {
792
+ return Promise.reject(e);
793
+ }
794
+ }
795
+ /**
796
+ * Resolves to the service worker registered by this instance as soon as it
797
+ * is active. If a service worker was already controlling at registration
798
+ * time then it will resolve to that if the script URLs (and optionally
799
+ * script versions) match, otherwise it will wait until an update is found
800
+ * and activates.
801
+ *
802
+ * @return {Promise<ServiceWorker>}
803
+ */
804
+ ;
805
+
806
+ /**
807
+ * Resolves with a reference to a service worker that matches the script URL
808
+ * of this instance, as soon as it's available.
809
+ *
810
+ * If, at registration time, there's already an active or waiting service
811
+ * worker with a matching script URL, it will be used (with the waiting
812
+ * service worker taking precedence over the active service worker if both
813
+ * match, since the waiting service worker would have been registered more
814
+ * recently).
815
+ * If there's no matching active or waiting service worker at registration
816
+ * time then the promise will not resolve until an update is found and starts
817
+ * installing, at which point the installing service worker is used.
818
+ *
819
+ * @return {Promise<ServiceWorker>}
820
+ */
821
+ _proto.getSW = function getSW() {
822
+ try {
823
+ var _this7 = this;
824
+
825
+ // If `this._sw` is set, resolve with that as we want `getSW()` to
826
+ // return the correct (new) service worker if an update is found.
827
+ return _this7._sw !== undefined ? _this7._sw : _this7._swDeferred.promise;
828
+ } catch (e) {
829
+ return Promise.reject(e);
830
+ }
831
+ }
832
+ /**
833
+ * Sends the passed data object to the service worker registered by this
834
+ * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
835
+ * with a response (if any).
836
+ *
837
+ * A response can be set in a message handler in the service worker by
838
+ * calling `event.ports[0].postMessage(...)`, which will resolve the promise
839
+ * returned by `messageSW()`. If no response is set, the promise will never
840
+ * resolve.
841
+ *
842
+ * @param {Object} data An object to send to the service worker
843
+ * @return {Promise<Object>}
844
+ */
845
+ ;
846
+
847
+ _proto.messageSW = function messageSW$1(data) {
848
+ try {
849
+ var _this9 = this;
850
+
851
+ return _await(_this9.getSW(), function (sw) {
852
+ return messageSW(sw, data);
853
+ });
854
+ } catch (e) {
855
+ return Promise.reject(e);
856
+ }
857
+ }
858
+ /**
859
+ * Checks for a service worker already controlling the page and returns
860
+ * it if its script URL matches.
861
+ *
862
+ * @private
863
+ * @return {ServiceWorker|undefined}
864
+ */
865
+ ;
866
+
867
+ _proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
868
+ var controller = navigator.serviceWorker.controller;
869
+
870
+ if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
871
+ return controller;
872
+ } else {
873
+ return undefined;
874
+ }
875
+ }
876
+ /**
877
+ * Registers a service worker for this instances script URL and register
878
+ * options and tracks the time registration was complete.
879
+ *
880
+ * @private
881
+ */
882
+ ;
883
+
884
+ _proto._registerScript = function _registerScript() {
885
+ try {
886
+ var _this11 = this;
887
+
888
+ return _catch(function () {
889
+ return _await(navigator.serviceWorker.register(_this11._scriptURL, _this11._registerOptions), function (reg) {
890
+ // Keep track of when registration happened, so it can be used in the
891
+ // `this._onUpdateFound` heuristic. Also use the presence of this
892
+ // property as a way to see if `.register()` has been called.
893
+ _this11._registrationTime = performance.now();
894
+ return reg;
895
+ });
896
+ }, function (error) {
897
+ if ("dev" !== 'production') {
898
+ logger.error(error);
899
+ } // Re-throw the error.
900
+
901
+
902
+ throw error;
903
+ });
904
+ } catch (e) {
905
+ return Promise.reject(e);
906
+ }
907
+ };
908
+
909
+ _createClass(Workbox, [{
910
+ key: "active",
911
+ get: function get() {
912
+ return this._activeDeferred.promise;
913
+ }
914
+ /**
915
+ * Resolves to the service worker registered by this instance as soon as it
916
+ * is controlling the page. If a service worker was already controlling at
917
+ * registration time then it will resolve to that if the script URLs (and
918
+ * optionally script versions) match, otherwise it will wait until an update
919
+ * is found and starts controlling the page.
920
+ * Note: the first time a service worker is installed it will active but
921
+ * not start controlling the page unless `clients.claim()` is called in the
922
+ * service worker.
923
+ *
924
+ * @return {Promise<ServiceWorker>}
925
+ */
926
+
927
+ }, {
928
+ key: "controlling",
929
+ get: function get() {
930
+ return this._controllingDeferred.promise;
931
+ }
932
+ }]);
933
+
934
+ return Workbox;
935
+ }(WorkboxEventTarget);
936
+
937
+ function _awaitIgnored(value, direct) {
938
+ if (!direct) {
939
+ return value && value.then ? value.then(_empty) : Promise.resolve();
940
+ }
941
+ } // The jsdoc comments below outline the events this instance may dispatch:
942
+ // -----------------------------------------------------------------------
943
+
944
+ /**
945
+ * The `message` event is dispatched any time a `postMessage` is received.
946
+ *
947
+ * @event module:workbox-window.Workbox#message
948
+ * @type {WorkboxEvent}
949
+ * @property {*} data The `data` property from the original `message` event.
950
+ * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}
951
+ * event.
952
+ * @property {string} type `message`.
953
+ * @property {Workbox} target The `Workbox` instance.
954
+ */
955
+
956
+ /**
957
+ * The `installed` event is dispatched if the state of a
958
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
959
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
960
+ * changes to `installed`.
961
+ *
962
+ * Then can happen either the very first time a service worker is installed,
963
+ * or after an update to the current service worker is found. In the case
964
+ * of an update being found, the event's `isUpdate` property will be `true`.
965
+ *
966
+ * @event module:workbox-window.Workbox#installed
967
+ * @type {WorkboxEvent}
968
+ * @property {ServiceWorker} sw The service worker instance.
969
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
970
+ * event.
971
+ * @property {boolean|undefined} isUpdate True if a service worker was already
972
+ * controlling when this `Workbox` instance called `register()`.
973
+ * @property {string} type `installed`.
974
+ * @property {Workbox} target The `Workbox` instance.
975
+ */
976
+
977
+ /**
978
+ * The `waiting` event is dispatched if the state of a
979
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
980
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
981
+ * changes to `installed` and then doesn't immediately change to `activating`.
982
+ * It may also be dispatched if a service worker with the same
983
+ * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
984
+ * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}
985
+ * method was called.
986
+ *
987
+ * @event module:workbox-window.Workbox#waiting
988
+ * @type {WorkboxEvent}
989
+ * @property {ServiceWorker} sw The service worker instance.
990
+ * @property {Event|undefined} originalEvent The original
991
+ * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
992
+ * event, or `undefined` in the case where the service worker was waiting
993
+ * to before `.register()` was called.
994
+ * @property {boolean|undefined} isUpdate True if a service worker was already
995
+ * controlling when this `Workbox` instance called `register()`.
996
+ * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with
997
+ * a matching `scriptURL` was already waiting when this `Workbox`
998
+ * instance called `register()`.
999
+ * @property {string} type `waiting`.
1000
+ * @property {Workbox} target The `Workbox` instance.
1001
+ */
1002
+
1003
+ /**
1004
+ * The `controlling` event is dispatched if a
1005
+ * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
1006
+ * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}
1007
+ * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
1008
+ * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}
1009
+ * matches the `scriptURL` of the `Workbox` instance's
1010
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.
1011
+ *
1012
+ * @event module:workbox-window.Workbox#controlling
1013
+ * @type {WorkboxEvent}
1014
+ * @property {ServiceWorker} sw The service worker instance.
1015
+ * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
1016
+ * event.
1017
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1018
+ * controlling when this service worker was registered.
1019
+ * @property {string} type `controlling`.
1020
+ * @property {Workbox} target The `Workbox` instance.
1021
+ */
1022
+
1023
+ /**
1024
+ * The `activated` event is dispatched if the state of a
1025
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
1026
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
1027
+ * changes to `activated`.
1028
+ *
1029
+ * @event module:workbox-window.Workbox#activated
1030
+ * @type {WorkboxEvent}
1031
+ * @property {ServiceWorker} sw The service worker instance.
1032
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1033
+ * event.
1034
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1035
+ * controlling when this `Workbox` instance called `register()`.
1036
+ * @property {string} type `activated`.
1037
+ * @property {Workbox} target The `Workbox` instance.
1038
+ */
1039
+
1040
+ /**
1041
+ * The `redundant` event is dispatched if the state of a
1042
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
1043
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
1044
+ * changes to `redundant`.
1045
+ *
1046
+ * @event module:workbox-window.Workbox#redundant
1047
+ * @type {WorkboxEvent}
1048
+ * @property {ServiceWorker} sw The service worker instance.
1049
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1050
+ * event.
1051
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1052
+ * controlling when this `Workbox` instance called `register()`.
1053
+ * @property {string} type `redundant`.
1054
+ * @property {Workbox} target The `Workbox` instance.
1055
+ */
1056
+
1057
+ /**
1058
+ * The `externalinstalled` event is dispatched if the state of an
1059
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1060
+ * changes to `installed`.
1061
+ *
1062
+ * @event module:workbox-window.Workbox#externalinstalled
1063
+ * @type {WorkboxEvent}
1064
+ * @property {ServiceWorker} sw The service worker instance.
1065
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1066
+ * event.
1067
+ * @property {string} type `externalinstalled`.
1068
+ * @property {Workbox} target The `Workbox` instance.
1069
+ */
1070
+
1071
+ /**
1072
+ * The `externalwaiting` event is dispatched if the state of an
1073
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1074
+ * changes to `waiting`.
1075
+ *
1076
+ * @event module:workbox-window.Workbox#externalwaiting
1077
+ * @type {WorkboxEvent}
1078
+ * @property {ServiceWorker} sw The service worker instance.
1079
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1080
+ * event.
1081
+ * @property {string} type `externalwaiting`.
1082
+ * @property {Workbox} target The `Workbox` instance.
1083
+ */
1084
+
1085
+ /**
1086
+ * The `externalactivated` event is dispatched if the state of an
1087
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1088
+ * changes to `activated`.
1089
+ *
1090
+ * @event module:workbox-window.Workbox#externalactivated
1091
+ * @type {WorkboxEvent}
1092
+ * @property {ServiceWorker} sw The service worker instance.
1093
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1094
+ * event.
1095
+ * @property {string} type `externalactivated`.
1096
+ * @property {Workbox} target The `Workbox` instance.
1097
+ */
1098
+
1099
+
1100
+ function _invoke(body, then) {
1101
+ var result = body();
1102
+
1103
+ if (result && result.then) {
1104
+ return result.then(then);
1105
+ }
1106
+
1107
+ return then(result);
1108
+ }
1109
+
1110
+ function _catch(body, recover) {
1111
+ try {
1112
+ var result = body();
1113
+ } catch (e) {
1114
+ return recover(e);
1115
+ }
1116
+
1117
+ if (result && result.then) {
1118
+ return result.then(void 0, recover);
1119
+ }
1120
+
1121
+ return result;
1122
+ }
1123
+
1124
+ export { Workbox, messageSW };
1125
+ //# sourceMappingURL=workbox-window.dev.es5.mjs.map