jekyll-pwa-workbox 0.0.7 → 0.0.8

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 +1 -1
  3. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-background-sync.dev.js +818 -818
  4. data/lib/vendor/workbox-v5.1.1/workbox-background-sync.dev.js.map +1 -0
  5. data/lib/vendor/workbox-v5.1.1/workbox-background-sync.prod.js +2 -0
  6. data/lib/vendor/workbox-v5.1.1/workbox-background-sync.prod.js.map +1 -0
  7. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-broadcast-update.dev.js +288 -288
  8. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-broadcast-update.dev.js.map +1 -1
  9. data/lib/vendor/workbox-v5.1.1/workbox-broadcast-update.prod.js +2 -0
  10. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-broadcast-update.prod.js.map +1 -1
  11. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.dev.js +191 -191
  12. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.dev.js.map +1 -1
  13. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.prod.js +2 -2
  14. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.prod.js.map +1 -1
  15. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-core.dev.js +1880 -1882
  16. data/lib/vendor/workbox-v5.1.1/workbox-core.dev.js.map +1 -0
  17. data/lib/vendor/workbox-v5.1.1/workbox-core.prod.js +2 -0
  18. data/lib/vendor/workbox-v5.1.1/workbox-core.prod.js.map +1 -0
  19. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-expiration.dev.js +649 -651
  20. data/lib/vendor/workbox-v5.1.1/workbox-expiration.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v5.1.1/workbox-expiration.prod.js +2 -0
  22. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-expiration.prod.js.map +1 -1
  23. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.dev.js +102 -102
  24. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.dev.js.map +1 -1
  25. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.prod.js +2 -2
  26. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.prod.js.map +1 -1
  27. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-offline-ga.dev.js +235 -235
  28. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-offline-ga.dev.js.map +1 -1
  29. data/lib/vendor/workbox-v5.1.1/workbox-offline-ga.prod.js +2 -0
  30. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-offline-ga.prod.js.map +1 -1
  31. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-precaching.dev.js +1222 -1222
  32. data/lib/vendor/workbox-v5.1.1/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v5.1.1/workbox-precaching.prod.js +2 -0
  34. data/lib/vendor/workbox-v5.1.1/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.dev.js +262 -262
  36. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.dev.js.map +1 -1
  37. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.prod.js +2 -2
  38. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.prod.js.map +1 -1
  39. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-routing.dev.js +923 -923
  40. data/lib/vendor/workbox-v5.1.1/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/workbox-v5.1.1/workbox-routing.prod.js +2 -0
  42. data/lib/vendor/workbox-v5.1.1/workbox-routing.prod.js.map +1 -0
  43. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-strategies.dev.js +923 -923
  44. data/lib/vendor/workbox-v5.1.1/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v5.1.1/workbox-strategies.prod.js +2 -0
  46. data/lib/vendor/workbox-v5.1.1/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-streams.dev.js +318 -318
  48. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-streams.dev.js.map +1 -1
  49. data/lib/vendor/workbox-v5.1.1/workbox-streams.prod.js +2 -0
  50. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-streams.prod.js.map +1 -1
  51. data/lib/vendor/workbox-v5.1.1/workbox-sw.js +2 -0
  52. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-sw.js.map +1 -1
  53. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-window.dev.es5.mjs +1094 -1075
  54. data/lib/vendor/workbox-v5.1.1/workbox-window.dev.es5.mjs.map +1 -0
  55. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-window.dev.mjs +943 -943
  56. data/lib/vendor/workbox-v5.1.1/workbox-window.dev.mjs.map +1 -0
  57. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-window.dev.umd.js +1105 -1086
  58. data/lib/vendor/workbox-v5.1.1/workbox-window.dev.umd.js.map +1 -0
  59. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.es5.mjs +2 -0
  60. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.es5.mjs.map +1 -0
  61. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.mjs +2 -0
  62. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.mjs.map +1 -0
  63. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.umd.js +2 -0
  64. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.umd.js.map +1 -0
  65. metadata +65 -65
  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":";;;;IAEA,IAAI;IACAA,EAAAA,IAAI,CAAC,uBAAD,CAAJ,IAAiCC,CAAC,EAAlC;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICLV;;;;;;;AAOA,IAIA;;;;;;;;;;IASA,SAASC,oBAAT,CAA8BC,MAA9B,EAAsC;IAClC,MAAIA,MAAM,YAAYC,QAAtB,EAAgC;IAC5B,WAAOD,MAAM,CAACE,IAAP,CAAYC,SAAZ,EAAP;IACH;;IACD,MAAIH,MAAM,YAAYI,cAAtB,EAAsC;IAClC,WAAOJ,MAAM,CAACG,SAAP,EAAP;IACH;;IACD,SAAO,IAAIF,QAAJ,CAAaD,MAAb,EAAqBE,IAArB,CAA0BC,SAA1B,EAAP;IACH;IACD;;;;;;;;;;;;;;;IAaA,SAASE,WAAT,CAAqBC,cAArB,EAAqC;IACjC,EAA2C;IACvCC,IAAAA,gBAAM,CAACC,OAAP,CAAeF,cAAf,EAA+B;IAC3BG,MAAAA,UAAU,EAAE,iBADe;IAE3BC,MAAAA,QAAQ,EAAE,aAFiB;IAG3BC,MAAAA,SAAS,EAAE;IAHgB,KAA/B;IAKH;;IACD,QAAMC,cAAc,GAAGN,cAAc,CAACO,GAAf,CAAoBC,aAAD,IAAmB;IACzD,WAAOC,OAAO,CAACC,OAAR,CAAgBF,aAAhB,EAA+BG,IAA/B,CAAqCjB,MAAD,IAAY;IACnD,aAAOD,oBAAoB,CAACC,MAAD,CAA3B;IACH,KAFM,CAAP;IAGH,GAJsB,CAAvB;IAKA,QAAMkB,cAAc,GAAG,IAAIC,oBAAJ,EAAvB;IACA,MAAIC,CAAC,GAAG,CAAR;IACA,QAAMC,WAAW,GAAG,EAApB;IACA,QAAMC,MAAM,GAAG,IAAIlB,cAAJ,CAAmB;IAC9BmB,IAAAA,IAAI,CAACC,UAAD,EAAa;IACb,aAAOZ,cAAc,CAACQ,CAAD,CAAd,CACFH,IADE,CACIQ,MAAD,IAAYA,MAAM,CAACC,IAAP,EADf,EAEFT,IAFE,CAEIU,MAAD,IAAY;IAClB,YAAIA,MAAM,CAACC,IAAX,EAAiB;IACb,UAA2C;IACvCP,YAAAA,WAAW,CAACQ,IAAZ,CAAiB,CAAC,4BAAD,EACbvB,cAAc,CAACc,CAAD,CADD,CAAjB;IAEH;;IACDA,UAAAA,CAAC;;IACD,cAAIA,CAAC,IAAIR,cAAc,CAACkB,MAAxB,EAAgC;IAC5B;IACA,YAA2C;IACvCC,cAAAA,gBAAM,CAACC,cAAP,CAAuB,iBAAgBpB,cAAc,CAACkB,MAAO,WAA7D;;IACA,mBAAK,MAAMG,OAAX,IAAsBZ,WAAtB,EAAmC;IAC/B,oBAAIa,KAAK,CAAC1B,OAAN,CAAcyB,OAAd,CAAJ,EAA4B;IACxBF,kBAAAA,gBAAM,CAACI,GAAP,CAAW,GAAGF,OAAd;IACH,iBAFD,MAGK;IACDF,kBAAAA,gBAAM,CAACI,GAAP,CAAWF,OAAX;IACH;IACJ;;IACDF,cAAAA,gBAAM,CAACI,GAAP,CAAW,+BAAX;IACAJ,cAAAA,gBAAM,CAACK,QAAP;IACH;;IACDZ,YAAAA,UAAU,CAACa,KAAX;IACAnB,YAAAA,cAAc,CAACF,OAAf;IACA;IACH,WAxBY;;;IA0Bb,iBAAO,KAAKO,IAAL,CAAUC,UAAV,CAAP;IACH,SA3BD,MA4BK;IACDA,UAAAA,UAAU,CAACc,OAAX,CAAmBX,MAAM,CAACY,KAA1B;IACH;IACJ,OAlCM,EAkCJC,KAlCI,CAkCGC,KAAD,IAAW;IAChB,QAA2C;IACvCV,UAAAA,gBAAM,CAACU,KAAP,CAAa,oBAAb,EAAmCA,KAAnC;IACH;;IACDvB,QAAAA,cAAc,CAACwB,MAAf,CAAsBD,KAAtB;IACA,cAAMA,KAAN;IACH,OAxCM,CAAP;IAyCH,KA3C6B;;IA4C9BE,IAAAA,MAAM,GAAG;IACL,MAA2C;IACvCZ,QAAAA,gBAAM,CAACa,IAAP,CAAY,mCAAZ;IACH;;IACD1B,MAAAA,cAAc,CAACF,OAAf;IACH;;IAjD6B,GAAnB,CAAf;IAmDA,SAAO;IAAEY,IAAAA,IAAI,EAAEV,cAAc,CAAC2B,OAAvB;IAAgCvB,IAAAA;IAAhC,GAAP;IACH;;IC9GD;;;;;;;AAOA,IACA;;;;;;;;;;;;;;;IAcA,SAASwB,aAAT,CAAuBC,WAAW,GAAG,EAArC,EAAyC;IACrC;IACA,QAAMC,OAAO,GAAG,IAAIC,OAAJ,CAAYF,WAAZ,CAAhB;;IACA,MAAI,CAACC,OAAO,CAACE,GAAR,CAAY,cAAZ,CAAL,EAAkC;IAC9BF,IAAAA,OAAO,CAACG,GAAR,CAAY,cAAZ,EAA4B,WAA5B;IACH;;IACD,SAAOH,OAAP;IACH;;IC7BD;;;;;;;AAOA,IAGA;;;;;;;;;;;;;;;;;;IAiBA,SAASI,qBAAT,CAA+B9C,cAA/B,EAA+CyC,WAA/C,EAA4D;IACxD,QAAM;IAAEnB,IAAAA,IAAF;IAAQN,IAAAA;IAAR,MAAmBjB,WAAW,CAACC,cAAD,CAApC;IACA,QAAM0C,OAAO,GAAGF,aAAa,CAACC,WAAD,CAA7B;IACA,QAAMM,QAAQ,GAAG,IAAIpD,QAAJ,CAAaqB,MAAb,EAAqB;IAAE0B,IAAAA;IAAF,GAArB,CAAjB;IACA,SAAO;IAAEpB,IAAAA,IAAF;IAAQyB,IAAAA;IAAR,GAAP;IACH;;IChCD;;;;;;;AAOA,IAEA;;;;;;;;;;;;IAWA,SAASC,WAAT,GAAuB;IACnB,SAAOC,wDAA0B,EAAjC;IACH;;ICtBD;;;;;;;AAOA,IAKA;;;;;;;;;;;;;;;;;IAgBA,SAASC,QAAT,CAAkBC,eAAlB,EAAmCV,WAAnC,EAAgD;IAC5C,SAAO,OAAO;IAAEW,IAAAA,KAAF;IAASC,IAAAA,OAAT;IAAkBC,IAAAA,GAAlB;IAAuBC,IAAAA;IAAvB,GAAP,KAA2C;IAC9C,UAAMvD,cAAc,GAAGmD,eAAe,CAAC5C,GAAhB,CAAqBiD,EAAD,IAAQ;IAC/C;IACA,aAAO/C,OAAO,CAACC,OAAR,CAAgB8C,EAAE,CAAC;IAAEJ,QAAAA,KAAF;IAASC,QAAAA,OAAT;IAAkBC,QAAAA,GAAlB;IAAuBC,QAAAA;IAAvB,OAAD,CAAlB,CAAP;IACH,KAHsB,CAAvB;;IAIA,QAAIP,WAAW,EAAf,EAAmB;IACf,YAAM;IAAE1B,QAAAA,IAAF;IAAQyB,QAAAA;IAAR,UAAqBD,qBAAqB,CAAC9C,cAAD,EAAiByC,WAAjB,CAAhD;;IACA,UAAIW,KAAJ,EAAW;IACPA,QAAAA,KAAK,CAACK,SAAN,CAAgBnC,IAAhB;IACH;;IACD,aAAOyB,QAAP;IACH;;IACD,IAA2C;IACvCtB,MAAAA,gBAAM,CAACI,GAAP,CAAY,wDAAD,GACN,0DADL;IAEH,KAf6C;IAiB9C;;;IACA,UAAM6B,iBAAiB,GAAG1D,cAAc,CAACO,GAAf,CAAmB,MAAOC,aAAP,IAAyB;IAClE,YAAMd,MAAM,GAAG,MAAMc,aAArB;;IACA,UAAId,MAAM,YAAYC,QAAtB,EAAgC;IAC5B,eAAOD,MAAM,CAACiE,IAAP,EAAP;IACH,OAFD,MAGK;IACD;IACA;IACA;IACA;IACA,eAAO,IAAIhE,QAAJ,CAAaD,MAAb,EAAqBiE,IAArB,EAAP;IACH;IACJ,KAZyB,CAA1B;IAaA,UAAMC,SAAS,GAAG,MAAMnD,OAAO,CAACoD,GAAR,CAAYH,iBAAZ,CAAxB;IACA,UAAMhB,OAAO,GAAGF,aAAa,CAACC,WAAD,CAA7B,CAhC8C;IAkC9C;;IACA,WAAO,IAAI9C,QAAJ,CAAa,IAAImE,IAAJ,CAASF,SAAT,CAAb,EAAkC;IAAElB,MAAAA;IAAF,KAAlC,CAAP;IACH,GApCD;IAqCH;;;;;;;;;;;;;"}
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.1'] && _();\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.1"]&&_()}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.1'] && _();\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.1"]&&_()}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.1"];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.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\nconst CDN_PATH = `WORKBOX_CDN_ROOT_URL`;\n\nconst MODULE_KEY_TO_NAME_MAPPING = {\n /**\n * @name backgroundSync\n * @memberof workbox\n * @see module:workbox-background-sync\n */\n backgroundSync: 'background-sync',\n /**\n * @name broadcastUpdate\n * @memberof workbox\n * @see module:workbox-broadcast-update\n */\n broadcastUpdate: 'broadcast-update',\n /**\n * @name cacheableResponse\n * @memberof workbox\n * @see module:workbox-cacheable-response\n */\n cacheableResponse: 'cacheable-response',\n /**\n * @name core\n * @memberof workbox\n * @see module:workbox-core\n */\n core: 'core',\n /**\n * @name expiration\n * @memberof workbox\n * @see module:workbox-expiration\n */\n expiration: 'expiration',\n /**\n * @name googleAnalytics\n * @memberof workbox\n * @see module:workbox-google-analytics\n */\n googleAnalytics: 'offline-ga',\n /**\n * @name navigationPreload\n * @memberof workbox\n * @see module:workbox-navigation-preload\n */\n navigationPreload: 'navigation-preload',\n /**\n * @name precaching\n * @memberof workbox\n * @see module:workbox-precaching\n */\n precaching: 'precaching',\n /**\n * @name rangeRequests\n * @memberof workbox\n * @see module:workbox-range-requests\n */\n rangeRequests: 'range-requests',\n /**\n * @name routing\n * @memberof workbox\n * @see module:workbox-routing\n */\n routing: 'routing',\n /**\n * @name strategies\n * @memberof workbox\n * @see module:workbox-strategies\n */\n strategies: 'strategies',\n /**\n * @name streams\n * @memberof workbox\n * @see module:workbox-streams\n */\n streams: 'streams',\n};\n\n/**\n * This class can be used to make it easy to use the various parts of\n * Workbox.\n *\n * @private\n */\nexport class WorkboxSW {\n /**\n * Creates a proxy that automatically loads workbox namespaces on demand.\n *\n * @private\n */\n constructor() {\n this.v = {};\n this._options = {\n debug: self.location.hostname === 'localhost',\n modulePathPrefix: null,\n modulePathCb: null,\n };\n\n this._env = this._options.debug ? 'dev' : 'prod';\n this._modulesLoaded = false;\n\n return new Proxy(this, {\n get(target, key) {\n if (target[key]) {\n return target[key];\n }\n\n const moduleName = MODULE_KEY_TO_NAME_MAPPING[key];\n if (moduleName) {\n target.loadModule(`workbox-${moduleName}`);\n }\n\n return target[key];\n },\n });\n }\n\n /**\n * Updates the configuration options. You can specify whether to treat as a\n * debug build and whether to use a CDN or a specific path when importing\n * other workbox-modules\n *\n * @param {Object} [options]\n * @param {boolean} [options.debug] If true, `dev` builds are using, otherwise\n * `prod` builds are used. By default, `prod` is used unless on localhost.\n * @param {Function} [options.modulePathPrefix] To avoid using the CDN with\n * `workbox-sw` set the path prefix of where modules should be loaded from.\n * For example `modulePathPrefix: '/third_party/workbox/v3.0.0/'`.\n * @param {workbox~ModulePathCallback} [options.modulePathCb] If defined,\n * this callback will be responsible for determining the path of each\n * workbox module.\n *\n * @alias workbox.setConfig\n */\n setConfig(options = {}) {\n if (!this._modulesLoaded) {\n Object.assign(this._options, options);\n this._env = this._options.debug ? 'dev' : 'prod';\n } else {\n throw new Error('Config must be set before accessing workbox.* modules');\n }\n }\n\n /**\n * Load a Workbox module by passing in the appropriate module name.\n *\n * This is not generally needed unless you know there are modules that are\n * dynamically used and you want to safe guard use of the module while the\n * user may be offline.\n *\n * @param {string} moduleName\n *\n * @alias workbox.loadModule\n */\n loadModule(moduleName) {\n const modulePath = this._getImportPath(moduleName);\n try {\n importScripts(modulePath);\n this._modulesLoaded = true;\n } catch (err) {\n // TODO Add context of this error if using the CDN vs the local file.\n\n // We can't rely on workbox-core being loaded so using console\n // eslint-disable-next-line\n console.error(\n `Unable to import module '${moduleName}' from '${modulePath}'.`);\n throw err;\n }\n }\n\n /**\n * This method will get the path / CDN URL to be used for importScript calls.\n *\n * @param {string} moduleName\n * @return {string} URL to the desired module.\n *\n * @private\n */\n _getImportPath(moduleName) {\n if (this._options.modulePathCb) {\n return this._options.modulePathCb(moduleName, this._options.debug);\n }\n\n // TODO: This needs to be dynamic some how.\n let pathParts = [CDN_PATH];\n\n const fileName = `${moduleName}.${this._env}.js`;\n\n const pathPrefix = this._options.modulePathPrefix;\n if (pathPrefix) {\n // Split to avoid issues with developers ending / not ending with slash\n pathParts = pathPrefix.split('/');\n\n // We don't need a slash at the end as we will be adding\n // a filename regardless\n if (pathParts[pathParts.length - 1] === '') {\n pathParts.splice(pathParts.length - 1, 1);\n }\n }\n\n pathParts.push(fileName);\n\n return pathParts.join('/');\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxSW} from './controllers/WorkboxSW.mjs';\nimport './_version.mjs';\n\n/**\n * @namespace workbox\n */\n\n// Don't export anything, just expose a global.\nself.workbox = new WorkboxSW();\n"],"names":["self","_","e","MODULE_KEY_TO_NAME_MAPPING","backgroundSync","broadcastUpdate","cacheableResponse","core","expiration","googleAnalytics","navigationPreload","precaching","rangeRequests","routing","strategies","streams","workbox","constructor","v","_options","debug","location","hostname","modulePathPrefix","modulePathCb","_env","this","_modulesLoaded","Proxy","get","target","key","moduleName","loadModule","setConfig","options","Error","Object","assign","modulePath","_getImportPath","importScripts","err","console","error","pathParts","fileName","pathPrefix","split","length","splice","push","join"],"mappings":"yBAAA,IAAIA,KAAK,qBAAqBC,IAAI,MAAMC,ICUxC,MAEMC,EAA6B,CAMjCC,eAAgB,kBAMhBC,gBAAiB,mBAMjBC,kBAAmB,qBAMnBC,KAAM,OAMNC,WAAY,aAMZC,gBAAiB,aAMjBC,kBAAmB,qBAMnBC,WAAY,aAMZC,cAAe,iBAMfC,QAAS,UAMTC,WAAY,aAMZC,QAAS,WCpEXf,KAAKgB,QAAU,ID6ER,MAMLC,0BACOC,EAAI,QACJC,EAAW,CACdC,MAAkC,cAA3BpB,KAAKqB,SAASC,SACrBC,iBAAkB,KAClBC,aAAc,WAGXC,EAAOC,KAAKP,EAASC,MAAQ,MAAQ,YACrCO,GAAiB,EAEf,IAAIC,MAAMF,KAAM,CACrBG,IAAIC,EAAQC,MACND,EAAOC,UACFD,EAAOC,SAGVC,EAAa7B,EAA2B4B,UAC1CC,GACFF,EAAOG,WAAY,WAAUD,KAGxBF,EAAOC,MAsBpBG,UAAUC,EAAU,OACbT,KAAKC,QAIF,IAAIS,MAAM,yDAHhBC,OAAOC,OAAOZ,KAAKP,EAAUgB,QACxBV,EAAOC,KAAKP,EAASC,MAAQ,MAAQ,OAiB9Ca,WAAWD,SACHO,EAAab,KAAKc,EAAeR,OAErCS,cAAcF,QACTZ,GAAiB,EACtB,MAAOe,SAKPC,QAAQC,MACH,4BAA2BZ,YAAqBO,OAC/CG,GAYVF,EAAeR,MACTN,KAAKP,EAASK,oBACTE,KAAKP,EAASK,aAAaQ,EAAYN,KAAKP,EAASC,WAI1DyB,EAAY,CAvLF,mEAyLRC,EAAY,GAAEd,KAAcN,KAAKD,OAEjCsB,EAAarB,KAAKP,EAASI,wBAC7BwB,IAEFF,EAAYE,EAAWC,MAAM,KAIW,KAApCH,EAAUA,EAAUI,OAAS,IAC/BJ,EAAUK,OAAOL,EAAUI,OAAS,EAAG,IAI3CJ,EAAUM,KAAKL,GAERD,EAAUO,KAAK"}
@@ -1,1075 +1,1094 @@
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.1'] && _();
3
+ } catch (e) {}
4
+
5
+ /*
6
+ Copyright 2019 Google LLC
7
+
8
+ Use of this source code is governed by an MIT-style
9
+ license that can be found in the LICENSE file or at
10
+ https://opensource.org/licenses/MIT.
11
+ */
12
+ /**
13
+ * Sends a data object to a service worker via `postMessage` and resolves with
14
+ * a response (if any).
15
+ *
16
+ * A response can be set in a message handler in the service worker by
17
+ * calling `event.ports[0].postMessage(...)`, which will resolve the promise
18
+ * returned by `messageSW()`. If no response is set, the promise will not
19
+ * resolve.
20
+ *
21
+ * @param {ServiceWorker} sw The service worker to send the message to.
22
+ * @param {Object} data An object to send to the service worker.
23
+ * @return {Promise<Object|undefined>}
24
+ * @memberof module:workbox-window
25
+ */
26
+
27
+ function messageSW(sw, data) {
28
+ return new Promise(function (resolve) {
29
+ var messageChannel = new MessageChannel();
30
+
31
+ messageChannel.port1.onmessage = function (event) {
32
+ resolve(event.data);
33
+ };
34
+
35
+ sw.postMessage(data, [messageChannel.port2]);
36
+ });
37
+ }
38
+
39
+ function _defineProperties(target, props) {
40
+ for (var i = 0; i < props.length; i++) {
41
+ var descriptor = props[i];
42
+ descriptor.enumerable = descriptor.enumerable || false;
43
+ descriptor.configurable = true;
44
+ if ("value" in descriptor) descriptor.writable = true;
45
+ Object.defineProperty(target, descriptor.key, descriptor);
46
+ }
47
+ }
48
+
49
+ function _createClass(Constructor, protoProps, staticProps) {
50
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
51
+ if (staticProps) _defineProperties(Constructor, staticProps);
52
+ return Constructor;
53
+ }
54
+
55
+ function _inheritsLoose(subClass, superClass) {
56
+ subClass.prototype = Object.create(superClass.prototype);
57
+ subClass.prototype.constructor = subClass;
58
+ subClass.__proto__ = superClass;
59
+ }
60
+
61
+ try {
62
+ self['workbox:core:5.1.1'] && _();
63
+ } catch (e) {}
64
+
65
+ /*
66
+ Copyright 2018 Google LLC
67
+
68
+ Use of this source code is governed by an MIT-style
69
+ license that can be found in the LICENSE file or at
70
+ https://opensource.org/licenses/MIT.
71
+ */
72
+ /**
73
+ * The Deferred class composes Promises in a way that allows for them to be
74
+ * resolved or rejected from outside the constructor. In most cases promises
75
+ * should be used directly, but Deferreds can be necessary when the logic to
76
+ * resolve a promise must be separate.
77
+ *
78
+ * @private
79
+ */
80
+
81
+ var Deferred =
82
+ /**
83
+ * Creates a promise and exposes its resolve and reject functions as methods.
84
+ */
85
+ function Deferred() {
86
+ var _this = this;
87
+
88
+ this.promise = new Promise(function (resolve, reject) {
89
+ _this.resolve = resolve;
90
+ _this.reject = reject;
91
+ });
92
+ };
93
+
94
+ /*
95
+ Copyright 2019 Google LLC
96
+ Use of this source code is governed by an MIT-style
97
+ license that can be found in the LICENSE file or at
98
+ https://opensource.org/licenses/MIT.
99
+ */
100
+ /**
101
+ * A helper function that prevents a promise from being flagged as unused.
102
+ *
103
+ * @private
104
+ **/
105
+
106
+ function dontWaitFor(promise) {
107
+ // Effective no-op.
108
+ promise.then(function () {});
109
+ }
110
+
111
+ /*
112
+ Copyright 2019 Google LLC
113
+ Use of this source code is governed by an MIT-style
114
+ license that can be found in the LICENSE file or at
115
+ https://opensource.org/licenses/MIT.
116
+ */
117
+ var logger = function () {
118
+ // Don't overwrite this value if it's already set.
119
+ // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
120
+ if (!('__WB_DISABLE_DEV_LOGS' in self)) {
121
+ self.__WB_DISABLE_DEV_LOGS = false;
122
+ }
123
+
124
+ var inGroup = false;
125
+ var methodToColorMap = {
126
+ debug: "#7f8c8d",
127
+ log: "#2ecc71",
128
+ warn: "#f39c12",
129
+ error: "#c0392b",
130
+ groupCollapsed: "#3498db",
131
+ groupEnd: null
132
+ };
133
+
134
+ var print = function print(method, args) {
135
+ var _console2;
136
+
137
+ if (self.__WB_DISABLE_DEV_LOGS) {
138
+ return;
139
+ }
140
+
141
+ if (method === 'groupCollapsed') {
142
+ // Safari doesn't print all console.groupCollapsed() arguments:
143
+ // https://bugs.webkit.org/show_bug.cgi?id=182754
144
+ if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
145
+ var _console;
146
+
147
+ (_console = console)[method].apply(_console, args);
148
+
149
+ return;
150
+ }
151
+ }
152
+
153
+ var styles = ["background: " + methodToColorMap[method], "border-radius: 0.5em", "color: white", "font-weight: bold", "padding: 2px 0.5em"]; // When in a group, the workbox prefix is not displayed.
154
+
155
+ var logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
156
+
157
+ (_console2 = console)[method].apply(_console2, logPrefix.concat(args));
158
+
159
+ if (method === 'groupCollapsed') {
160
+ inGroup = true;
161
+ }
162
+
163
+ if (method === 'groupEnd') {
164
+ inGroup = false;
165
+ }
166
+ };
167
+
168
+ var api = {};
169
+ var loggerMethods = Object.keys(methodToColorMap);
170
+
171
+ var _loop = function _loop() {
172
+ var key = _loggerMethods[_i];
173
+ var method = key;
174
+
175
+ api[method] = function () {
176
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
177
+ args[_key] = arguments[_key];
178
+ }
179
+
180
+ print(method, args);
181
+ };
182
+ };
183
+
184
+ for (var _i = 0, _loggerMethods = loggerMethods; _i < _loggerMethods.length; _i++) {
185
+ _loop();
186
+ }
187
+
188
+ return api;
189
+ }();
190
+
191
+ /*
192
+ Copyright 2019 Google LLC
193
+
194
+ Use of this source code is governed by an MIT-style
195
+ license that can be found in the LICENSE file or at
196
+ https://opensource.org/licenses/MIT.
197
+ */
198
+
199
+ /**
200
+ * A minimal `EventTarget` shim.
201
+ * This is necessary because not all browsers support constructable
202
+ * `EventTarget`, so using a real `EventTarget` will error.
203
+ * @private
204
+ */
205
+ var WorkboxEventTarget = /*#__PURE__*/function () {
206
+ function WorkboxEventTarget() {
207
+ this._eventListenerRegistry = new Map();
208
+ }
209
+ /**
210
+ * @param {string} type
211
+ * @param {Function} listener
212
+ * @private
213
+ */
214
+
215
+
216
+ var _proto = WorkboxEventTarget.prototype;
217
+
218
+ _proto.addEventListener = function addEventListener(type, listener) {
219
+ var foo = this._getEventListenersByType(type);
220
+
221
+ foo.add(listener);
222
+ }
223
+ /**
224
+ * @param {string} type
225
+ * @param {Function} listener
226
+ * @private
227
+ */
228
+ ;
229
+
230
+ _proto.removeEventListener = function removeEventListener(type, listener) {
231
+ this._getEventListenersByType(type).delete(listener);
232
+ }
233
+ /**
234
+ * @param {Object} event
235
+ * @private
236
+ */
237
+ ;
238
+
239
+ _proto.dispatchEvent = function dispatchEvent(event) {
240
+ event.target = this;
241
+
242
+ var listeners = this._getEventListenersByType(event.type);
243
+
244
+ for (var _iterator = listeners, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
245
+ var _ref;
246
+
247
+ if (_isArray) {
248
+ if (_i >= _iterator.length) break;
249
+ _ref = _iterator[_i++];
250
+ } else {
251
+ _i = _iterator.next();
252
+ if (_i.done) break;
253
+ _ref = _i.value;
254
+ }
255
+
256
+ var listener = _ref;
257
+ listener(event);
258
+ }
259
+ }
260
+ /**
261
+ * Returns a Set of listeners associated with the passed event type.
262
+ * If no handlers have been registered, an empty Set is returned.
263
+ *
264
+ * @param {string} type The event type.
265
+ * @return {Set<ListenerCallback>} An array of handler functions.
266
+ * @private
267
+ */
268
+ ;
269
+
270
+ _proto._getEventListenersByType = function _getEventListenersByType(type) {
271
+ if (!this._eventListenerRegistry.has(type)) {
272
+ this._eventListenerRegistry.set(type, new Set());
273
+ }
274
+
275
+ return this._eventListenerRegistry.get(type);
276
+ };
277
+
278
+ return WorkboxEventTarget;
279
+ }();
280
+
281
+ /*
282
+ Copyright 2019 Google LLC
283
+
284
+ Use of this source code is governed by an MIT-style
285
+ license that can be found in the LICENSE file or at
286
+ https://opensource.org/licenses/MIT.
287
+ */
288
+ /**
289
+ * Returns true if two URLs have the same `.href` property. The URLS can be
290
+ * relative, and if they are the current location href is used to resolve URLs.
291
+ *
292
+ * @private
293
+ * @param {string} url1
294
+ * @param {string} url2
295
+ * @return {boolean}
296
+ */
297
+
298
+ function urlsMatch(url1, url2) {
299
+ var _location = location,
300
+ href = _location.href;
301
+ return new URL(url1, href).href === new URL(url2, href).href;
302
+ }
303
+
304
+ /*
305
+ Copyright 2019 Google LLC
306
+
307
+ Use of this source code is governed by an MIT-style
308
+ license that can be found in the LICENSE file or at
309
+ https://opensource.org/licenses/MIT.
310
+ */
311
+ /**
312
+ * A minimal `Event` subclass shim.
313
+ * This doesn't *actually* subclass `Event` because not all browsers support
314
+ * constructable `EventTarget`, and using a real `Event` will error.
315
+ * @private
316
+ */
317
+
318
+ var WorkboxEvent = function WorkboxEvent(type, props) {
319
+ this.type = type;
320
+ Object.assign(this, props);
321
+ };
322
+
323
+ // `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
324
+ // chosen, but it seems to avoid false positives in my testing.
325
+
326
+ function _await(value, then, direct) {
327
+ if (direct) {
328
+ return then ? then(value) : value;
329
+ }
330
+
331
+ if (!value || !value.then) {
332
+ value = Promise.resolve(value);
333
+ }
334
+
335
+ return then ? value.then(then) : value;
336
+ }
337
+
338
+ var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
339
+ // that the registration didn't trigger an update.
340
+
341
+ function _async(f) {
342
+ return function () {
343
+ for (var args = [], i = 0; i < arguments.length; i++) {
344
+ args[i] = arguments[i];
345
+ }
346
+
347
+ try {
348
+ return Promise.resolve(f.apply(this, args));
349
+ } catch (e) {
350
+ return Promise.reject(e);
351
+ }
352
+ };
353
+ }
354
+
355
+ var REGISTRATION_TIMEOUT_DURATION = 60000;
356
+ /**
357
+ * A class to aid in handling service worker registration, updates, and
358
+ * reacting to service worker lifecycle events.
359
+ *
360
+ * @fires [message]{@link module:workbox-window.Workbox#message}
361
+ * @fires [installed]{@link module:workbox-window.Workbox#installed}
362
+ * @fires [waiting]{@link module:workbox-window.Workbox#waiting}
363
+ * @fires [controlling]{@link module:workbox-window.Workbox#controlling}
364
+ * @fires [activated]{@link module:workbox-window.Workbox#activated}
365
+ * @fires [redundant]{@link module:workbox-window.Workbox#redundant}
366
+ * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
367
+ * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
368
+ * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
369
+ * @memberof module:workbox-window
370
+ */
371
+
372
+ function _empty() {}
373
+
374
+ var Workbox = /*#__PURE__*/function (_WorkboxEventTarget) {
375
+ _inheritsLoose(Workbox, _WorkboxEventTarget);
376
+
377
+ /**
378
+ * Creates a new Workbox instance with a script URL and service worker
379
+ * options. The script URL and options are the same as those used when
380
+ * calling `navigator.serviceWorker.register(scriptURL, options)`. See:
381
+ * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
382
+ *
383
+ * @param {string} scriptURL The service worker script associated with this
384
+ * instance.
385
+ * @param {Object} [registerOptions] The service worker options associated
386
+ * with this instance.
387
+ */
388
+ function Workbox(scriptURL, registerOptions) {
389
+ var _this;
390
+
391
+ if (registerOptions === void 0) {
392
+ registerOptions = {};
393
+ }
394
+
395
+ _this = _WorkboxEventTarget.call(this) || this;
396
+ _this._registerOptions = {};
397
+ _this._updateFoundCount = 0; // Deferreds we can resolve later.
398
+
399
+ _this._swDeferred = new Deferred();
400
+ _this._activeDeferred = new Deferred();
401
+ _this._controllingDeferred = new Deferred();
402
+ _this._registrationTime = 0;
403
+ _this._ownSWs = new Set();
404
+ /**
405
+ * @private
406
+ */
407
+
408
+ _this._onUpdateFound = function () {
409
+ // `this._registration` will never be `undefined` after an update is found.
410
+ var registration = _this._registration;
411
+ var installingSW = registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
412
+ // different from the current controlling SW's script URL, we know any
413
+ // successful registration calls will trigger an `updatefound` event.
414
+ // But if the registered script URL is the same as the current controlling
415
+ // SW's script URL, we'll only get an `updatefound` event if the file
416
+ // changed since it was last registered. This can be a problem if the user
417
+ // opens up the same page in a different tab, and that page registers
418
+ // a SW that triggers an update. It's a problem because this page has no
419
+ // good way of knowing whether the `updatefound` event came from the SW
420
+ // script it registered or from a registration attempt made by a newer
421
+ // version of the page running in another tab.
422
+ // To minimize the possibility of a false positive, we use the logic here:
423
+
424
+ var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
425
+ // add the `updatefound` event listener until the `register()` call, if
426
+ // `_updateFoundCount` is > 0 then it means this method has already
427
+ // been called, thus this SW must be external
428
+ _this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
429
+ // instance's script URL, we know it's definitely not from our
430
+ // registration.
431
+ !urlsMatch(installingSW.scriptURL, _this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
432
+ // Any `updatefound` event that occurs long after our registration is
433
+ // assumed to be external.
434
+ performance.now() > _this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
435
+ // triggered by this instance.
436
+ true : false;
437
+
438
+ if (updateLikelyTriggeredExternally) {
439
+ _this._externalSW = installingSW;
440
+ registration.removeEventListener('updatefound', _this._onUpdateFound);
441
+ } else {
442
+ // If the update was not triggered externally we know the installing
443
+ // SW is the one we registered, so we set it.
444
+ _this._sw = installingSW;
445
+
446
+ _this._ownSWs.add(installingSW);
447
+
448
+ _this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
449
+ // callback for, but we do log messages for it in development.
450
+
451
+
452
+ {
453
+ if (navigator.serviceWorker.controller) {
454
+ logger.log('Updated service worker found. Installing now...');
455
+ } else {
456
+ logger.log('Service worker is installing...');
457
+ }
458
+ }
459
+ } // Increment the `updatefound` count, so future invocations of this
460
+ // method can be sure they were triggered externally.
461
+
462
+
463
+ ++_this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
464
+ // triggered externally, since we have callbacks for both.
465
+
466
+ installingSW.addEventListener('statechange', _this._onStateChange);
467
+ };
468
+ /**
469
+ * @private
470
+ * @param {Event} originalEvent
471
+ */
472
+
473
+
474
+ _this._onStateChange = function (originalEvent) {
475
+ // `this._registration` will never be `undefined` after an update is found.
476
+ var registration = _this._registration;
477
+ var sw = originalEvent.target;
478
+ var state = sw.state;
479
+ var isExternal = sw === _this._externalSW;
480
+ var eventPrefix = isExternal ? 'external' : '';
481
+ var eventProps = {
482
+ sw: sw,
483
+ originalEvent: originalEvent
484
+ };
485
+
486
+ if (!isExternal && _this._isUpdate) {
487
+ eventProps.isUpdate = true;
488
+ }
489
+
490
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
491
+
492
+ if (state === 'installed') {
493
+ // This timeout is used to ignore cases where the service worker calls
494
+ // `skipWaiting()` in the install event, thus moving it directly in the
495
+ // activating state. (Since all service workers *must* go through the
496
+ // waiting phase, the only way to detect `skipWaiting()` called in the
497
+ // install event is to observe that the time spent in the waiting phase
498
+ // is very short.)
499
+ // NOTE: we don't need separate timeouts for the own and external SWs
500
+ // since they can't go through these phases at the same time.
501
+ _this._waitingTimeout = self.setTimeout(function () {
502
+ // Ensure the SW is still waiting (it may now be redundant).
503
+ if (state === 'installed' && registration.waiting === sw) {
504
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
505
+
506
+ {
507
+ if (isExternal) {
508
+ logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
509
+ } else {
510
+ logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
511
+ }
512
+ }
513
+ }
514
+ }, WAITING_TIMEOUT_DURATION);
515
+ } else if (state === 'activating') {
516
+ clearTimeout(_this._waitingTimeout);
517
+
518
+ if (!isExternal) {
519
+ _this._activeDeferred.resolve(sw);
520
+ }
521
+ }
522
+
523
+ {
524
+ switch (state) {
525
+ case 'installed':
526
+ if (isExternal) {
527
+ logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
528
+ } else {
529
+ logger.log('Registered service worker installed.');
530
+ }
531
+
532
+ break;
533
+
534
+ case 'activated':
535
+ if (isExternal) {
536
+ logger.warn('An external service worker has activated.');
537
+ } else {
538
+ logger.log('Registered service worker activated.');
539
+
540
+ if (sw !== navigator.serviceWorker.controller) {
541
+ logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
542
+ }
543
+ }
544
+
545
+ break;
546
+
547
+ case 'redundant':
548
+ if (sw === _this._compatibleControllingSW) {
549
+ logger.log('Previously controlling service worker now redundant!');
550
+ } else if (!isExternal) {
551
+ logger.log('Registered service worker now redundant!');
552
+ }
553
+
554
+ break;
555
+ }
556
+ }
557
+ };
558
+ /**
559
+ * @private
560
+ * @param {Event} originalEvent
561
+ */
562
+
563
+
564
+ _this._onControllerChange = function (originalEvent) {
565
+ var sw = _this._sw;
566
+
567
+ if (sw === navigator.serviceWorker.controller) {
568
+ _this.dispatchEvent(new WorkboxEvent('controlling', {
569
+ sw: sw,
570
+ originalEvent: originalEvent,
571
+ isUpdate: _this._isUpdate
572
+ }));
573
+
574
+ {
575
+ logger.log('Registered service worker now controlling this page.');
576
+ }
577
+
578
+ _this._controllingDeferred.resolve(sw);
579
+ }
580
+ };
581
+ /**
582
+ * @private
583
+ * @param {Event} originalEvent
584
+ */
585
+
586
+
587
+ _this._onMessage = _async(function (originalEvent) {
588
+ var data = originalEvent.data,
589
+ source = originalEvent.source; // Wait until there's an "own" service worker. This is used to buffer
590
+ // `message` events that may be received prior to calling `register()`.
591
+
592
+ return _await(_this.getSW(), function () {
593
+ if (_this._ownSWs.has(source)) {
594
+ _this.dispatchEvent(new WorkboxEvent('message', {
595
+ data: data,
596
+ sw: source,
597
+ originalEvent: originalEvent
598
+ }));
599
+ }
600
+ }); // If the service worker that sent the message is in the list of own
601
+ // service workers for this instance, dispatch a `message` event.
602
+ // NOTE: we check for all previously owned service workers rather than
603
+ // just the current one because some messages (e.g. cache updates) use
604
+ // a timeout when sent and may be delayed long enough for a service worker
605
+ // update to be found.
606
+ });
607
+ _this._scriptURL = scriptURL;
608
+ _this._registerOptions = registerOptions; // Add a message listener immediately since messages received during
609
+ // page load are buffered only until the DOMContentLoaded event:
610
+ // https://github.com/GoogleChrome/workbox/issues/2202
611
+
612
+ navigator.serviceWorker.addEventListener('message', _this._onMessage);
613
+ return _this;
614
+ }
615
+ /**
616
+ * Registers a service worker for this instances script URL and service
617
+ * worker options. By default this method delays registration until after
618
+ * the window has loaded.
619
+ *
620
+ * @param {Object} [options]
621
+ * @param {Function} [options.immediate=false] Setting this to true will
622
+ * register the service worker immediately, even if the window has
623
+ * not loaded (not recommended).
624
+ */
625
+
626
+
627
+ var _proto = Workbox.prototype;
628
+
629
+ _proto.register = function register(_temp) {
630
+ var _ref = _temp === void 0 ? {} : _temp,
631
+ _ref$immediate = _ref.immediate,
632
+ immediate = _ref$immediate === void 0 ? false : _ref$immediate;
633
+
634
+ try {
635
+ var _this3 = this;
636
+
637
+ if ("dev" !== 'production') {
638
+ if (_this3._registrationTime) {
639
+ logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
640
+ return;
641
+ }
642
+ }
643
+
644
+ return _invoke(function () {
645
+ if (!immediate && document.readyState !== 'complete') {
646
+ return _awaitIgnored(new Promise(function (res) {
647
+ return window.addEventListener('load', res);
648
+ }));
649
+ }
650
+ }, function () {
651
+ // Set this flag to true if any service worker was controlling the page
652
+ // at registration time.
653
+ _this3._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
654
+ // the page, and if that SW script (and version, if specified) matches this
655
+ // instance's script.
656
+
657
+ _this3._compatibleControllingSW = _this3._getControllingSWIfCompatible();
658
+ return _await(_this3._registerScript(), function (_this2$_registerScrip) {
659
+ _this3._registration = _this2$_registerScrip;
660
+
661
+ // If we have a compatible controller, store the controller as the "own"
662
+ // SW, resolve active/controlling deferreds and add necessary listeners.
663
+ if (_this3._compatibleControllingSW) {
664
+ _this3._sw = _this3._compatibleControllingSW;
665
+
666
+ _this3._activeDeferred.resolve(_this3._compatibleControllingSW);
667
+
668
+ _this3._controllingDeferred.resolve(_this3._compatibleControllingSW);
669
+
670
+ _this3._compatibleControllingSW.addEventListener('statechange', _this3._onStateChange, {
671
+ once: true
672
+ });
673
+ } // If there's a waiting service worker with a matching URL before the
674
+ // `updatefound` event fires, it likely means that this site is open
675
+ // in another tab, or the user refreshed the page (and thus the previous
676
+ // page wasn't fully unloaded before this page started loading).
677
+ // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
678
+
679
+
680
+ var waitingSW = _this3._registration.waiting;
681
+
682
+ if (waitingSW && urlsMatch(waitingSW.scriptURL, _this3._scriptURL)) {
683
+ // Store the waiting SW as the "own" Sw, even if it means overwriting
684
+ // a compatible controller.
685
+ _this3._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
686
+ // listener after awaiting `register()` will get this event.
687
+
688
+ dontWaitFor(Promise.resolve().then(function () {
689
+ _this3.dispatchEvent(new WorkboxEvent('waiting', {
690
+ sw: waitingSW,
691
+ wasWaitingBeforeRegister: true
692
+ }));
693
+
694
+ if ("dev" !== 'production') {
695
+ logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
696
+ }
697
+ }));
698
+ } // If an "own" SW is already set, resolve the deferred.
699
+
700
+
701
+ if (_this3._sw) {
702
+ _this3._swDeferred.resolve(_this3._sw);
703
+
704
+ _this3._ownSWs.add(_this3._sw);
705
+ }
706
+
707
+ if ("dev" !== 'production') {
708
+ logger.log('Successfully registered service worker.', _this3._scriptURL);
709
+
710
+ if (navigator.serviceWorker.controller) {
711
+ if (_this3._compatibleControllingSW) {
712
+ logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
713
+ } else {
714
+ logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
715
+ }
716
+ }
717
+
718
+ var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
719
+ var scopeURL = new URL(_this3._registerOptions.scope || _this3._scriptURL, document.baseURI);
720
+ var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
721
+ return !location.pathname.startsWith(scopeURLBasePath);
722
+ };
723
+
724
+ if (currentPageIsOutOfScope()) {
725
+ logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
726
+ }
727
+ }
728
+
729
+ _this3._registration.addEventListener('updatefound', _this3._onUpdateFound);
730
+
731
+ navigator.serviceWorker.addEventListener('controllerchange', _this3._onControllerChange, {
732
+ once: true
733
+ });
734
+ return _this3._registration;
735
+ });
736
+ });
737
+ } catch (e) {
738
+ return Promise.reject(e);
739
+ }
740
+ }
741
+ /**
742
+ * Checks for updates of the registered service worker.
743
+ */
744
+ ;
745
+
746
+ _proto.update = function update() {
747
+ try {
748
+ var _this5 = this;
749
+
750
+ if (!_this5._registration) {
751
+ if ("dev" !== 'production') {
752
+ logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
753
+ }
754
+
755
+ return;
756
+ } // Try to update registration
757
+
758
+
759
+ return _awaitIgnored(_this5._registration.update());
760
+ } catch (e) {
761
+ return Promise.reject(e);
762
+ }
763
+ }
764
+ /**
765
+ * Resolves to the service worker registered by this instance as soon as it
766
+ * is active. If a service worker was already controlling at registration
767
+ * time then it will resolve to that if the script URLs (and optionally
768
+ * script versions) match, otherwise it will wait until an update is found
769
+ * and activates.
770
+ *
771
+ * @return {Promise<ServiceWorker>}
772
+ */
773
+ ;
774
+
775
+ /**
776
+ * Resolves with a reference to a service worker that matches the script URL
777
+ * of this instance, as soon as it's available.
778
+ *
779
+ * If, at registration time, there's already an active or waiting service
780
+ * worker with a matching script URL, it will be used (with the waiting
781
+ * service worker taking precedence over the active service worker if both
782
+ * match, since the waiting service worker would have been registered more
783
+ * recently).
784
+ * If there's no matching active or waiting service worker at registration
785
+ * time then the promise will not resolve until an update is found and starts
786
+ * installing, at which point the installing service worker is used.
787
+ *
788
+ * @return {Promise<ServiceWorker>}
789
+ */
790
+ _proto.getSW = function getSW() {
791
+ try {
792
+ var _this7 = this;
793
+
794
+ // If `this._sw` is set, resolve with that as we want `getSW()` to
795
+ // return the correct (new) service worker if an update is found.
796
+ return _this7._sw !== undefined ? _this7._sw : _this7._swDeferred.promise;
797
+ } catch (e) {
798
+ return Promise.reject(e);
799
+ }
800
+ }
801
+ /**
802
+ * Sends the passed data object to the service worker registered by this
803
+ * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
804
+ * with a response (if any).
805
+ *
806
+ * A response can be set in a message handler in the service worker by
807
+ * calling `event.ports[0].postMessage(...)`, which will resolve the promise
808
+ * returned by `messageSW()`. If no response is set, the promise will never
809
+ * resolve.
810
+ *
811
+ * @param {Object} data An object to send to the service worker
812
+ * @return {Promise<Object>}
813
+ */
814
+ ;
815
+
816
+ _proto.messageSW = function messageSW$1(data) {
817
+ try {
818
+ var _this9 = this;
819
+
820
+ return _await(_this9.getSW(), function (sw) {
821
+ return messageSW(sw, data);
822
+ });
823
+ } catch (e) {
824
+ return Promise.reject(e);
825
+ }
826
+ }
827
+ /**
828
+ * Checks for a service worker already controlling the page and returns
829
+ * it if its script URL matches.
830
+ *
831
+ * @private
832
+ * @return {ServiceWorker|undefined}
833
+ */
834
+ ;
835
+
836
+ _proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
837
+ var controller = navigator.serviceWorker.controller;
838
+
839
+ if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
840
+ return controller;
841
+ } else {
842
+ return undefined;
843
+ }
844
+ }
845
+ /**
846
+ * Registers a service worker for this instances script URL and register
847
+ * options and tracks the time registration was complete.
848
+ *
849
+ * @private
850
+ */
851
+ ;
852
+
853
+ _proto._registerScript = function _registerScript() {
854
+ try {
855
+ var _this11 = this;
856
+
857
+ return _catch(function () {
858
+ return _await(navigator.serviceWorker.register(_this11._scriptURL, _this11._registerOptions), function (reg) {
859
+ // Keep track of when registration happened, so it can be used in the
860
+ // `this._onUpdateFound` heuristic. Also use the presence of this
861
+ // property as a way to see if `.register()` has been called.
862
+ _this11._registrationTime = performance.now();
863
+ return reg;
864
+ });
865
+ }, function (error) {
866
+ if ("dev" !== 'production') {
867
+ logger.error(error);
868
+ } // Re-throw the error.
869
+
870
+
871
+ throw error;
872
+ });
873
+ } catch (e) {
874
+ return Promise.reject(e);
875
+ }
876
+ };
877
+
878
+ _createClass(Workbox, [{
879
+ key: "active",
880
+ get: function get() {
881
+ return this._activeDeferred.promise;
882
+ }
883
+ /**
884
+ * Resolves to the service worker registered by this instance as soon as it
885
+ * is controlling the page. If a service worker was already controlling at
886
+ * registration time then it will resolve to that if the script URLs (and
887
+ * optionally script versions) match, otherwise it will wait until an update
888
+ * is found and starts controlling the page.
889
+ * Note: the first time a service worker is installed it will active but
890
+ * not start controlling the page unless `clients.claim()` is called in the
891
+ * service worker.
892
+ *
893
+ * @return {Promise<ServiceWorker>}
894
+ */
895
+
896
+ }, {
897
+ key: "controlling",
898
+ get: function get() {
899
+ return this._controllingDeferred.promise;
900
+ }
901
+ }]);
902
+
903
+ return Workbox;
904
+ }(WorkboxEventTarget);
905
+
906
+ function _awaitIgnored(value, direct) {
907
+ if (!direct) {
908
+ return value && value.then ? value.then(_empty) : Promise.resolve();
909
+ }
910
+ } // The jsdoc comments below outline the events this instance may dispatch:
911
+ // -----------------------------------------------------------------------
912
+
913
+ /**
914
+ * The `message` event is dispatched any time a `postMessage` is received.
915
+ *
916
+ * @event module:workbox-window.Workbox#message
917
+ * @type {WorkboxEvent}
918
+ * @property {*} data The `data` property from the original `message` event.
919
+ * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}
920
+ * event.
921
+ * @property {string} type `message`.
922
+ * @property {Workbox} target The `Workbox` instance.
923
+ */
924
+
925
+ /**
926
+ * The `installed` event is dispatched if the state of a
927
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
928
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
929
+ * changes to `installed`.
930
+ *
931
+ * Then can happen either the very first time a service worker is installed,
932
+ * or after an update to the current service worker is found. In the case
933
+ * of an update being found, the event's `isUpdate` property will be `true`.
934
+ *
935
+ * @event module:workbox-window.Workbox#installed
936
+ * @type {WorkboxEvent}
937
+ * @property {ServiceWorker} sw The service worker instance.
938
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
939
+ * event.
940
+ * @property {boolean|undefined} isUpdate True if a service worker was already
941
+ * controlling when this `Workbox` instance called `register()`.
942
+ * @property {string} type `installed`.
943
+ * @property {Workbox} target The `Workbox` instance.
944
+ */
945
+
946
+ /**
947
+ * The `waiting` event is dispatched if the state of a
948
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
949
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
950
+ * changes to `installed` and then doesn't immediately change to `activating`.
951
+ * It may also be dispatched if a service worker with the same
952
+ * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
953
+ * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}
954
+ * method was called.
955
+ *
956
+ * @event module:workbox-window.Workbox#waiting
957
+ * @type {WorkboxEvent}
958
+ * @property {ServiceWorker} sw The service worker instance.
959
+ * @property {Event|undefined} originalEvent The original
960
+ * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
961
+ * event, or `undefined` in the case where the service worker was waiting
962
+ * to before `.register()` was called.
963
+ * @property {boolean|undefined} isUpdate True if a service worker was already
964
+ * controlling when this `Workbox` instance called `register()`.
965
+ * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with
966
+ * a matching `scriptURL` was already waiting when this `Workbox`
967
+ * instance called `register()`.
968
+ * @property {string} type `waiting`.
969
+ * @property {Workbox} target The `Workbox` instance.
970
+ */
971
+
972
+ /**
973
+ * The `controlling` event is dispatched if a
974
+ * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
975
+ * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}
976
+ * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
977
+ * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}
978
+ * matches the `scriptURL` of the `Workbox` instance's
979
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.
980
+ *
981
+ * @event module:workbox-window.Workbox#controlling
982
+ * @type {WorkboxEvent}
983
+ * @property {ServiceWorker} sw The service worker instance.
984
+ * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
985
+ * event.
986
+ * @property {boolean|undefined} isUpdate True if a service worker was already
987
+ * controlling when this service worker was registered.
988
+ * @property {string} type `controlling`.
989
+ * @property {Workbox} target The `Workbox` instance.
990
+ */
991
+
992
+ /**
993
+ * The `activated` event is dispatched if the state of a
994
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
995
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
996
+ * changes to `activated`.
997
+ *
998
+ * @event module:workbox-window.Workbox#activated
999
+ * @type {WorkboxEvent}
1000
+ * @property {ServiceWorker} sw The service worker instance.
1001
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1002
+ * event.
1003
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1004
+ * controlling when this `Workbox` instance called `register()`.
1005
+ * @property {string} type `activated`.
1006
+ * @property {Workbox} target The `Workbox` instance.
1007
+ */
1008
+
1009
+ /**
1010
+ * The `redundant` event is dispatched if the state of a
1011
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
1012
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
1013
+ * changes to `redundant`.
1014
+ *
1015
+ * @event module:workbox-window.Workbox#redundant
1016
+ * @type {WorkboxEvent}
1017
+ * @property {ServiceWorker} sw The service worker instance.
1018
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1019
+ * event.
1020
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1021
+ * controlling when this `Workbox` instance called `register()`.
1022
+ * @property {string} type `redundant`.
1023
+ * @property {Workbox} target The `Workbox` instance.
1024
+ */
1025
+
1026
+ /**
1027
+ * The `externalinstalled` event is dispatched if the state of an
1028
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1029
+ * changes to `installed`.
1030
+ *
1031
+ * @event module:workbox-window.Workbox#externalinstalled
1032
+ * @type {WorkboxEvent}
1033
+ * @property {ServiceWorker} sw The service worker instance.
1034
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1035
+ * event.
1036
+ * @property {string} type `externalinstalled`.
1037
+ * @property {Workbox} target The `Workbox` instance.
1038
+ */
1039
+
1040
+ /**
1041
+ * The `externalwaiting` event is dispatched if the state of an
1042
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1043
+ * changes to `waiting`.
1044
+ *
1045
+ * @event module:workbox-window.Workbox#externalwaiting
1046
+ * @type {WorkboxEvent}
1047
+ * @property {ServiceWorker} sw The service worker instance.
1048
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1049
+ * event.
1050
+ * @property {string} type `externalwaiting`.
1051
+ * @property {Workbox} target The `Workbox` instance.
1052
+ */
1053
+
1054
+ /**
1055
+ * The `externalactivated` event is dispatched if the state of an
1056
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1057
+ * changes to `activated`.
1058
+ *
1059
+ * @event module:workbox-window.Workbox#externalactivated
1060
+ * @type {WorkboxEvent}
1061
+ * @property {ServiceWorker} sw The service worker instance.
1062
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1063
+ * event.
1064
+ * @property {string} type `externalactivated`.
1065
+ * @property {Workbox} target The `Workbox` instance.
1066
+ */
1067
+
1068
+
1069
+ function _invoke(body, then) {
1070
+ var result = body();
1071
+
1072
+ if (result && result.then) {
1073
+ return result.then(then);
1074
+ }
1075
+
1076
+ return then(result);
1077
+ }
1078
+
1079
+ function _catch(body, recover) {
1080
+ try {
1081
+ var result = body();
1082
+ } catch (e) {
1083
+ return recover(e);
1084
+ }
1085
+
1086
+ if (result && result.then) {
1087
+ return result.then(void 0, recover);
1088
+ }
1089
+
1090
+ return result;
1091
+ }
1092
+
1093
+ export { Workbox, messageSW };
1094
+ //# sourceMappingURL=workbox-window.dev.es5.mjs.map