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