jekyll-pwa-workbox 0.0.7.alpha → 0.0.7
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.
- checksums.yaml +4 -4
- data/lib/jekyll-pwa-workbox.rb +1 -1
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-background-sync.dev.js +12 -13
- data/lib/vendor/workbox-v5.0.0/workbox-background-sync.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js +288 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-cacheable-response.dev.js +6 -7
- data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-core.dev.js +306 -67
- data/lib/vendor/workbox-v5.0.0/workbox-core.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-expiration.dev.js +13 -14
- data/lib/vendor/workbox-v5.0.0/workbox-expiration.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-navigation-preload.dev.js +4 -5
- data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-offline-ga.dev.js +12 -13
- data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-precaching.dev.js +314 -86
- data/lib/vendor/workbox-v5.0.0/workbox-precaching.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-range-requests.dev.js +8 -9
- data/lib/vendor/workbox-v5.0.0/workbox-range-requests.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-routing.dev.js +79 -182
- data/lib/vendor/workbox-v5.0.0/workbox-routing.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-strategies.dev.js +23 -227
- data/lib/vendor/workbox-v5.0.0/workbox-strategies.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-streams.dev.js +16 -31
- data/lib/vendor/workbox-v5.0.0/workbox-streams.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-sw.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-sw.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.es5.mjs +317 -113
- data/lib/vendor/workbox-v5.0.0/workbox-window.dev.es5.mjs.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.mjs +244 -44
- data/lib/vendor/workbox-v5.0.0/workbox-window.dev.mjs.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.umd.js +317 -113
- data/lib/vendor/workbox-v5.0.0/workbox-window.dev.umd.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js.map +1 -0
- metadata +70 -69
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js +0 -486
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-streams.dev.js","sources":["../_version.js","../concatenate.js","../utils/createHeaders.js","../concatenateToResponse.js","../isSupported.js","../strategy.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:streams:5.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,GA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B;IACA,UAAMhB,OAAO,GAAGF,aAAa,CAACC,WAAD,CAA7B,CAhC8C;IAkC9C;;IACA,WAAO,IAAI9C,QAAJ,CAAa,IAAImE,IAAJ,CAASF,SAAT,CAAb,EAAkC;IAAElB,MAAAA;IAAF,KAAlC,CAAP;IACH,GApCD;IAqCH;;;;;;;;;;;;;"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
this.workbox=this.workbox||{},this.workbox.streams=function(e,n,t){"use strict";try{self["workbox:streams:5.0.0"]&&_()}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>=t.length?(e.close(),void s.resolve()):this.pull(e);e.enqueue(n.value)}).catch(e=>{throw s.reject(e),e})},cancel(){s.resolve()}});return{done:s.promise,stream:o}}function r(e={}){const n=new Headers(e);return n.has("content-type")||n.set("content-type","text/html"),n}function o(e,n){const{done:t,stream:o}=s(e),c=r(n);return{done:t,response:new Response(o,{headers:c})}}function c(){return t.canConstructReadableStream()}return e.concatenate=s,e.concatenateToResponse=o,e.isSupported=c,e.strategy=function(e,n){return async({event:t,request:s,url:a,params:u})=>{const i=e.map(e=>Promise.resolve(e({event:t,request:s,url:a,params:u})));if(c()){const{done:e,response:s}=o(i,n);return t&&t.waitUntil(e),s}const f=i.map(async e=>{const n=await e;return n instanceof Response?n.blob():new Response(n).blob()}),p=await Promise.all(f),w=r(n);return new Response(new Blob(p),{headers:w})}},e}({},workbox.core._private,workbox.core._private);
|
2
|
+
//# sourceMappingURL=workbox-streams.prod.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-streams.prod.js","sources":["../_version.js","../concatenate.js","../utils/createHeaders.js","../concatenateToResponse.js","../isSupported.js","../strategy.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:streams:5.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","bl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sBvC,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.0.0"]&&_()}catch(t){}const t="https://storage.googleapis.com/workbox-cdn/releases/5.0.0",e={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(t,s){if(t[s])return t[s];const o=e[s];return o&&t.loadModule(`workbox-${o}`),t[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(e){if(this.t.modulePathCb)return this.t.modulePathCb(e,this.t.debug);let s=[t];const o=`${e}.${this.s}.js`,r=this.t.modulePathPrefix;return r&&""===(s=r.split("/"))[s.length-1]&&s.splice(s.length-1,1),s.push(o),s.join("/")}}}();
|
2
|
+
//# sourceMappingURL=workbox-sw.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-sw.js","sources":["../_version.mjs","../controllers/WorkboxSW.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:sw:5.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,6 +1,5 @@
|
|
1
|
-
// @ts-ignore
|
2
1
|
try {
|
3
|
-
self['workbox:window:5.0.0
|
2
|
+
self['workbox:window:5.0.0'] && _();
|
4
3
|
} catch (e) {}
|
5
4
|
|
6
5
|
/*
|
@@ -22,7 +21,6 @@ try {
|
|
22
21
|
* @param {ServiceWorker} sw The service worker to send the message to.
|
23
22
|
* @param {Object} data An object to send to the service worker.
|
24
23
|
* @return {Promise<Object|undefined>}
|
25
|
-
*
|
26
24
|
* @memberof module:workbox-window
|
27
25
|
*/
|
28
26
|
|
@@ -60,9 +58,8 @@ function _inheritsLoose(subClass, superClass) {
|
|
60
58
|
subClass.__proto__ = superClass;
|
61
59
|
}
|
62
60
|
|
63
|
-
// @ts-ignore
|
64
61
|
try {
|
65
|
-
self['workbox:core:5.0.0
|
62
|
+
self['workbox:core:5.0.0'] && _();
|
66
63
|
} catch (e) {}
|
67
64
|
|
68
65
|
/*
|
@@ -94,6 +91,23 @@ function Deferred() {
|
|
94
91
|
});
|
95
92
|
};
|
96
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
|
+
|
97
111
|
/*
|
98
112
|
Copyright 2019 Google LLC
|
99
113
|
Use of this source code is governed by an MIT-style
|
@@ -101,6 +115,12 @@ function Deferred() {
|
|
101
115
|
https://opensource.org/licenses/MIT.
|
102
116
|
*/
|
103
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
|
+
|
104
124
|
var inGroup = false;
|
105
125
|
var methodToColorMap = {
|
106
126
|
debug: "#7f8c8d",
|
@@ -114,6 +134,10 @@ var logger = function () {
|
|
114
134
|
var print = function print(method, args) {
|
115
135
|
var _console2;
|
116
136
|
|
137
|
+
if (self.__WB_DISABLE_DEV_LOGS) {
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
|
117
141
|
if (method === 'groupCollapsed') {
|
118
142
|
// Safari doesn't print all console.groupCollapsed() arguments:
|
119
143
|
// https://bugs.webkit.org/show_bug.cgi?id=182754
|
@@ -145,7 +169,7 @@ var logger = function () {
|
|
145
169
|
var loggerMethods = Object.keys(methodToColorMap);
|
146
170
|
|
147
171
|
var _loop = function _loop() {
|
148
|
-
var key =
|
172
|
+
var key = _loggerMethods[_i];
|
149
173
|
var method = key;
|
150
174
|
|
151
175
|
api[method] = function () {
|
@@ -157,7 +181,7 @@ var logger = function () {
|
|
157
181
|
};
|
158
182
|
};
|
159
183
|
|
160
|
-
for (var _i = 0; _i <
|
184
|
+
for (var _i = 0, _loggerMethods = loggerMethods; _i < _loggerMethods.length; _i++) {
|
161
185
|
_loop();
|
162
186
|
}
|
163
187
|
|
@@ -171,18 +195,18 @@ var logger = function () {
|
|
171
195
|
license that can be found in the LICENSE file or at
|
172
196
|
https://opensource.org/licenses/MIT.
|
173
197
|
*/
|
198
|
+
|
174
199
|
/**
|
175
200
|
* A minimal `EventTarget` shim.
|
176
201
|
* This is necessary because not all browsers support constructable
|
177
202
|
* `EventTarget`, so using a real `EventTarget` will error.
|
178
203
|
* @private
|
179
204
|
*/
|
180
|
-
|
181
205
|
var WorkboxEventTarget =
|
182
206
|
/*#__PURE__*/
|
183
207
|
function () {
|
184
208
|
function WorkboxEventTarget() {
|
185
|
-
this._eventListenerRegistry =
|
209
|
+
this._eventListenerRegistry = new Map();
|
186
210
|
}
|
187
211
|
/**
|
188
212
|
* @param {string} type
|
@@ -194,23 +218,25 @@ function () {
|
|
194
218
|
var _proto = WorkboxEventTarget.prototype;
|
195
219
|
|
196
220
|
_proto.addEventListener = function addEventListener(type, listener) {
|
197
|
-
this._getEventListenersByType(type)
|
198
|
-
|
221
|
+
var foo = this._getEventListenersByType(type);
|
222
|
+
|
223
|
+
foo.add(listener);
|
224
|
+
}
|
199
225
|
/**
|
200
226
|
* @param {string} type
|
201
227
|
* @param {Function} listener
|
202
228
|
* @private
|
203
229
|
*/
|
204
|
-
|
230
|
+
;
|
205
231
|
|
206
232
|
_proto.removeEventListener = function removeEventListener(type, listener) {
|
207
233
|
this._getEventListenersByType(type).delete(listener);
|
208
|
-
}
|
234
|
+
}
|
209
235
|
/**
|
210
236
|
* @param {Object} event
|
211
237
|
* @private
|
212
238
|
*/
|
213
|
-
|
239
|
+
;
|
214
240
|
|
215
241
|
_proto.dispatchEvent = function dispatchEvent(event) {
|
216
242
|
event.target = this;
|
@@ -232,7 +258,7 @@ function () {
|
|
232
258
|
var listener = _ref;
|
233
259
|
listener(event);
|
234
260
|
}
|
235
|
-
}
|
261
|
+
}
|
236
262
|
/**
|
237
263
|
* Returns a Set of listeners associated with the passed event type.
|
238
264
|
* If no handlers have been registered, an empty Set is returned.
|
@@ -241,10 +267,14 @@ function () {
|
|
241
267
|
* @return {Set<ListenerCallback>} An array of handler functions.
|
242
268
|
* @private
|
243
269
|
*/
|
244
|
-
|
270
|
+
;
|
245
271
|
|
246
272
|
_proto._getEventListenersByType = function _getEventListenersByType(type) {
|
247
|
-
|
273
|
+
if (!this._eventListenerRegistry.has(type)) {
|
274
|
+
this._eventListenerRegistry.set(type, new Set());
|
275
|
+
}
|
276
|
+
|
277
|
+
return this._eventListenerRegistry.get(type);
|
248
278
|
};
|
249
279
|
|
250
280
|
return WorkboxEventTarget;
|
@@ -292,20 +322,24 @@ var WorkboxEvent = function WorkboxEvent(type, props) {
|
|
292
322
|
Object.assign(this, props);
|
293
323
|
};
|
294
324
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
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;
|
300
331
|
}
|
301
332
|
|
302
|
-
if (
|
303
|
-
|
333
|
+
if (!value || !value.then) {
|
334
|
+
value = Promise.resolve(value);
|
304
335
|
}
|
305
336
|
|
306
|
-
return
|
337
|
+
return then ? value.then(then) : value;
|
307
338
|
}
|
308
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
|
+
|
309
343
|
function _async(f) {
|
310
344
|
return function () {
|
311
345
|
for (var args = [], i = 0; i < arguments.length; i++) {
|
@@ -320,41 +354,6 @@ function _async(f) {
|
|
320
354
|
};
|
321
355
|
}
|
322
356
|
|
323
|
-
function _invoke(body, then) {
|
324
|
-
var result = body();
|
325
|
-
|
326
|
-
if (result && result.then) {
|
327
|
-
return result.then(then);
|
328
|
-
}
|
329
|
-
|
330
|
-
return then(result);
|
331
|
-
}
|
332
|
-
|
333
|
-
function _await(value, then, direct) {
|
334
|
-
if (direct) {
|
335
|
-
return then ? then(value) : value;
|
336
|
-
}
|
337
|
-
|
338
|
-
if (!value || !value.then) {
|
339
|
-
value = Promise.resolve(value);
|
340
|
-
}
|
341
|
-
|
342
|
-
return then ? value.then(then) : value;
|
343
|
-
}
|
344
|
-
|
345
|
-
function _awaitIgnored(value, direct) {
|
346
|
-
if (!direct) {
|
347
|
-
return value && value.then ? value.then(_empty) : Promise.resolve();
|
348
|
-
}
|
349
|
-
}
|
350
|
-
|
351
|
-
function _empty() {}
|
352
|
-
// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
|
353
|
-
// chosen, but it seems to avoid false positives in my testing.
|
354
|
-
|
355
|
-
var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
|
356
|
-
// that the registration didn't trigger an update.
|
357
|
-
|
358
357
|
var REGISTRATION_TIMEOUT_DURATION = 60000;
|
359
358
|
/**
|
360
359
|
* A class to aid in handling service worker registration, updates, and
|
@@ -369,10 +368,11 @@ var REGISTRATION_TIMEOUT_DURATION = 60000;
|
|
369
368
|
* @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
|
370
369
|
* @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
|
371
370
|
* @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
|
372
|
-
*
|
373
371
|
* @memberof module:workbox-window
|
374
372
|
*/
|
375
373
|
|
374
|
+
function _empty() {}
|
375
|
+
|
376
376
|
var Workbox =
|
377
377
|
/*#__PURE__*/
|
378
378
|
function (_WorkboxEventTarget) {
|
@@ -404,6 +404,7 @@ function (_WorkboxEventTarget) {
|
|
404
404
|
_this._activeDeferred = new Deferred();
|
405
405
|
_this._controllingDeferred = new Deferred();
|
406
406
|
_this._registrationTime = 0;
|
407
|
+
_this._ownSWs = new Set();
|
407
408
|
/**
|
408
409
|
* @private
|
409
410
|
*/
|
@@ -446,6 +447,8 @@ function (_WorkboxEventTarget) {
|
|
446
447
|
// SW is the one we registered, so we set it.
|
447
448
|
_this._sw = installingSW;
|
448
449
|
|
450
|
+
_this._ownSWs.add(installingSW);
|
451
|
+
|
449
452
|
_this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
|
450
453
|
// callback for, but we do log messages for it in development.
|
451
454
|
|
@@ -585,17 +588,32 @@ function (_WorkboxEventTarget) {
|
|
585
588
|
*/
|
586
589
|
|
587
590
|
|
588
|
-
_this._onMessage = function (originalEvent) {
|
589
|
-
var data = originalEvent.data
|
590
|
-
|
591
|
-
|
592
|
-
data: data,
|
593
|
-
originalEvent: originalEvent
|
594
|
-
}));
|
595
|
-
};
|
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()`.
|
596
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
|
+
});
|
597
611
|
_this._scriptURL = scriptURL;
|
598
|
-
_this._registerOptions = registerOptions;
|
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);
|
599
617
|
return _this;
|
600
618
|
}
|
601
619
|
/**
|
@@ -628,7 +646,7 @@ function (_WorkboxEventTarget) {
|
|
628
646
|
return _invoke(function () {
|
629
647
|
if (!immediate && document.readyState !== 'complete') {
|
630
648
|
return _awaitIgnored(new Promise(function (res) {
|
631
|
-
return addEventListener('load', res);
|
649
|
+
return window.addEventListener('load', res);
|
632
650
|
}));
|
633
651
|
}
|
634
652
|
}, function () {
|
@@ -651,14 +669,12 @@ function (_WorkboxEventTarget) {
|
|
651
669
|
|
652
670
|
_this2._controllingDeferred.resolve(_this2._compatibleControllingSW);
|
653
671
|
|
654
|
-
_this2._reportWindowReady(_this2._compatibleControllingSW);
|
655
|
-
|
656
672
|
_this2._compatibleControllingSW.addEventListener('statechange', _this2._onStateChange, {
|
657
673
|
once: true
|
658
674
|
});
|
659
675
|
} // If there's a waiting service worker with a matching URL before the
|
660
676
|
// `updatefound` event fires, it likely means that this site is open
|
661
|
-
// in another tab, or the user refreshed the page (and thus the
|
677
|
+
// in another tab, or the user refreshed the page (and thus the previous
|
662
678
|
// page wasn't fully unloaded before this page started loading).
|
663
679
|
// https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
|
664
680
|
|
@@ -671,7 +687,7 @@ function (_WorkboxEventTarget) {
|
|
671
687
|
_this2._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
|
672
688
|
// listener after awaiting `register()` will get this event.
|
673
689
|
|
674
|
-
Promise.resolve().then(function () {
|
690
|
+
dontWaitFor(Promise.resolve().then(function () {
|
675
691
|
_this2.dispatchEvent(new WorkboxEvent('waiting', {
|
676
692
|
sw: waitingSW,
|
677
693
|
wasWaitingBeforeRegister: true
|
@@ -680,12 +696,14 @@ function (_WorkboxEventTarget) {
|
|
680
696
|
{
|
681
697
|
logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
|
682
698
|
}
|
683
|
-
});
|
699
|
+
}));
|
684
700
|
} // If an "own" SW is already set, resolve the deferred.
|
685
701
|
|
686
702
|
|
687
703
|
if (_this2._sw) {
|
688
704
|
_this2._swDeferred.resolve(_this2._sw);
|
705
|
+
|
706
|
+
_this2._ownSWs.add(_this2._sw);
|
689
707
|
}
|
690
708
|
|
691
709
|
{
|
@@ -714,19 +732,29 @@ function (_WorkboxEventTarget) {
|
|
714
732
|
|
715
733
|
navigator.serviceWorker.addEventListener('controllerchange', _this2._onControllerChange, {
|
716
734
|
once: true
|
717
|
-
});
|
718
|
-
|
719
|
-
if ('BroadcastChannel' in self) {
|
720
|
-
_this2._broadcastChannel = new BroadcastChannel('workbox');
|
721
|
-
|
722
|
-
_this2._broadcastChannel.addEventListener('message', _this2._onMessage);
|
723
|
-
}
|
724
|
-
|
725
|
-
navigator.serviceWorker.addEventListener('message', _this2._onMessage);
|
735
|
+
});
|
726
736
|
return _this2._registration;
|
727
737
|
});
|
728
738
|
});
|
729
|
-
})
|
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
|
+
})
|
730
758
|
/**
|
731
759
|
* Resolves to the service worker registered by this instance as soon as it
|
732
760
|
* is active. If a service worker was already controlling at registration
|
@@ -736,6 +764,7 @@ function (_WorkboxEventTarget) {
|
|
736
764
|
*
|
737
765
|
* @return {Promise<ServiceWorker>}
|
738
766
|
*/
|
767
|
+
;
|
739
768
|
|
740
769
|
/**
|
741
770
|
* Resolves with a reference to a service worker that matches the script URL
|
@@ -753,12 +782,12 @@ function (_WorkboxEventTarget) {
|
|
753
782
|
* @return {Promise<ServiceWorker>}
|
754
783
|
*/
|
755
784
|
_proto.getSW = _async(function () {
|
756
|
-
var
|
785
|
+
var _this4 = this;
|
757
786
|
|
758
787
|
// If `this._sw` is set, resolve with that as we want `getSW()` to
|
759
788
|
// return the correct (new) service worker if an update is found.
|
760
|
-
return
|
761
|
-
})
|
789
|
+
return _this4._sw !== undefined ? _this4._sw : _this4._swDeferred.promise;
|
790
|
+
})
|
762
791
|
/**
|
763
792
|
* Sends the passed data object to the service worker registered by this
|
764
793
|
* instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
|
@@ -772,21 +801,22 @@ function (_WorkboxEventTarget) {
|
|
772
801
|
* @param {Object} data An object to send to the service worker
|
773
802
|
* @return {Promise<Object>}
|
774
803
|
*/
|
775
|
-
|
804
|
+
;
|
776
805
|
_proto.messageSW = _async(function (data) {
|
777
|
-
var
|
806
|
+
var _this5 = this;
|
778
807
|
|
779
|
-
return _await(
|
808
|
+
return _await(_this5.getSW(), function (sw) {
|
780
809
|
return messageSW(sw, data);
|
781
810
|
});
|
782
|
-
})
|
811
|
+
})
|
783
812
|
/**
|
784
813
|
* Checks for a service worker already controlling the page and returns
|
785
|
-
* it if its script URL
|
814
|
+
* it if its script URL matches.
|
786
815
|
*
|
787
816
|
* @private
|
788
817
|
* @return {ServiceWorker|undefined}
|
789
818
|
*/
|
819
|
+
;
|
790
820
|
|
791
821
|
_proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
|
792
822
|
var controller = navigator.serviceWorker.controller;
|
@@ -796,24 +826,24 @@ function (_WorkboxEventTarget) {
|
|
796
826
|
} else {
|
797
827
|
return undefined;
|
798
828
|
}
|
799
|
-
}
|
829
|
+
}
|
800
830
|
/**
|
801
831
|
* Registers a service worker for this instances script URL and register
|
802
832
|
* options and tracks the time registration was complete.
|
803
833
|
*
|
804
834
|
* @private
|
805
835
|
*/
|
806
|
-
|
836
|
+
;
|
807
837
|
|
808
838
|
_proto._registerScript = _async(function () {
|
809
|
-
var
|
839
|
+
var _this6 = this;
|
810
840
|
|
811
841
|
return _catch(function () {
|
812
|
-
return _await(navigator.serviceWorker.register(
|
842
|
+
return _await(navigator.serviceWorker.register(_this6._scriptURL, _this6._registerOptions), function (reg) {
|
813
843
|
// Keep track of when registration happened, so it can be used in the
|
814
844
|
// `this._onUpdateFound` heuristic. Also use the presence of this
|
815
845
|
// property as a way to see if `.register()` has been called.
|
816
|
-
|
846
|
+
_this6._registrationTime = performance.now();
|
817
847
|
return reg;
|
818
848
|
});
|
819
849
|
}, function (error) {
|
@@ -825,19 +855,6 @@ function (_WorkboxEventTarget) {
|
|
825
855
|
throw error;
|
826
856
|
});
|
827
857
|
});
|
828
|
-
/**
|
829
|
-
* Sends a message to the passed service worker that the window is ready.
|
830
|
-
*
|
831
|
-
* @param {ServiceWorker} sw
|
832
|
-
* @private
|
833
|
-
*/
|
834
|
-
|
835
|
-
_proto._reportWindowReady = function _reportWindowReady(sw) {
|
836
|
-
messageSW(sw, {
|
837
|
-
type: 'WINDOW_READY',
|
838
|
-
meta: 'workbox-window'
|
839
|
-
});
|
840
|
-
};
|
841
858
|
|
842
859
|
_createClass(Workbox, [{
|
843
860
|
key: "active",
|
@@ -865,7 +882,194 @@ function (_WorkboxEventTarget) {
|
|
865
882
|
}]);
|
866
883
|
|
867
884
|
return Workbox;
|
868
|
-
}(WorkboxEventTarget);
|
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
|
+
}
|
869
1073
|
|
870
1074
|
export { Workbox, messageSW };
|
871
1075
|
//# sourceMappingURL=workbox-window.dev.es5.mjs.map
|