jekyll-pwa-workbox 0.0.7.alpha → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-pwa-workbox.rb +1 -1
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-background-sync.dev.js +12 -13
- data/lib/vendor/workbox-v5.0.0/workbox-background-sync.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js +288 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-cacheable-response.dev.js +6 -7
- data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-core.dev.js +306 -67
- data/lib/vendor/workbox-v5.0.0/workbox-core.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-expiration.dev.js +13 -14
- data/lib/vendor/workbox-v5.0.0/workbox-expiration.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-navigation-preload.dev.js +4 -5
- data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-offline-ga.dev.js +12 -13
- data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-precaching.dev.js +314 -86
- data/lib/vendor/workbox-v5.0.0/workbox-precaching.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-range-requests.dev.js +8 -9
- data/lib/vendor/workbox-v5.0.0/workbox-range-requests.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-routing.dev.js +79 -182
- data/lib/vendor/workbox-v5.0.0/workbox-routing.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-strategies.dev.js +23 -227
- data/lib/vendor/workbox-v5.0.0/workbox-strategies.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-streams.dev.js +16 -31
- data/lib/vendor/workbox-v5.0.0/workbox-streams.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-sw.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-sw.js.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.es5.mjs +317 -113
- data/lib/vendor/workbox-v5.0.0/workbox-window.dev.es5.mjs.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.mjs +244 -44
- data/lib/vendor/workbox-v5.0.0/workbox-window.dev.mjs.map +1 -0
- data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.umd.js +317 -113
- data/lib/vendor/workbox-v5.0.0/workbox-window.dev.umd.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js +2 -0
- data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js.map +1 -0
- metadata +70 -69
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js +0 -486
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map +0 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js +0 -2
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-cacheable-response.dev.js","sources":["../_version.js","../CacheableResponse.js","../CacheableResponsePlugin.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:cacheable-response:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport './_version.js';\n/**\n * This class allows you to set up rules determining what\n * status codes and/or headers need to be present in order for a\n * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * to be considered cacheable.\n *\n * @memberof module:workbox-cacheable-response\n */\nclass CacheableResponse {\n /**\n * To construct a new CacheableResponse instance you must provide at least\n * one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (!(config.statuses || config.headers)) {\n throw new WorkboxError('statuses-or-headers-required', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n });\n }\n if (config.statuses) {\n assert.isArray(config.statuses, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.statuses',\n });\n }\n if (config.headers) {\n assert.isType(config.headers, 'object', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.headers',\n });\n }\n }\n this._statuses = config.statuses;\n this._headers = config.headers;\n }\n /**\n * Checks a response to see whether it's cacheable or not, based on this\n * object's configuration.\n *\n * @param {Response} response The response whose cacheability is being\n * checked.\n * @return {boolean} `true` if the `Response` is cacheable, and `false`\n * otherwise.\n */\n isResponseCacheable(response) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(response, Response, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'isResponseCacheable',\n paramName: 'response',\n });\n }\n let cacheable = true;\n if (this._statuses) {\n cacheable = this._statuses.includes(response.status);\n }\n if (this._headers && cacheable) {\n cacheable = Object.keys(this._headers).some((headerName) => {\n return response.headers.get(headerName) === this._headers[headerName];\n });\n }\n if (process.env.NODE_ENV !== 'production') {\n if (!cacheable) {\n logger.groupCollapsed(`The request for ` +\n `'${getFriendlyURL(response.url)}' returned a response that does ` +\n `not meet the criteria for being cached.`);\n logger.groupCollapsed(`View cacheability criteria here.`);\n logger.log(`Cacheable statuses: ` +\n JSON.stringify(this._statuses));\n logger.log(`Cacheable headers: ` +\n JSON.stringify(this._headers, null, 2));\n logger.groupEnd();\n const logFriendlyHeaders = {};\n response.headers.forEach((value, key) => {\n logFriendlyHeaders[key] = value;\n });\n logger.groupCollapsed(`View response status and headers here.`);\n logger.log(`Response status: ` + response.status);\n logger.log(`Response headers: ` +\n JSON.stringify(logFriendlyHeaders, null, 2));\n logger.groupEnd();\n logger.groupCollapsed(`View full response details here.`);\n logger.log(response.headers);\n logger.log(response);\n logger.groupEnd();\n logger.groupEnd();\n }\n }\n return cacheable;\n }\n}\nexport { CacheableResponse };\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 { CacheableResponse } from './CacheableResponse.js';\nimport './_version.js';\n/**\n * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it\n * easier to add in cacheability checks to requests made via Workbox's built-in\n * strategies.\n *\n * @memberof module:workbox-cacheable-response\n */\nclass CacheableResponsePlugin {\n /**\n * To construct a new CacheableResponsePlugin instance you must provide at\n * least one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config) {\n /**\n * @param {Object} options\n * @param {Response} options.response\n * @return {Response|null}\n * @private\n */\n this.cacheWillUpdate = async ({ response }) => {\n if (this._cacheableResponse.isResponseCacheable(response)) {\n return response;\n }\n return null;\n };\n this._cacheableResponse = new CacheableResponse(config);\n }\n}\nexport { CacheableResponsePlugin };\n"],"names":["self","_","e","CacheableResponse","constructor","config","statuses","headers","WorkboxError","moduleName","className","funcName","assert","isArray","paramName","isType","_statuses","_headers","isResponseCacheable","response","isInstance","Response","cacheable","includes","status","Object","keys","some","headerName","get","logger","groupCollapsed","getFriendlyURL","url","log","JSON","stringify","groupEnd","logFriendlyHeaders","forEach","value","key","CacheableResponsePlugin","cacheWillUpdate","_cacheableResponse"],"mappings":"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"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
this.workbox=this.workbox||{},this.workbox.cacheableResponse=function(s){"use strict";try{self["workbox:cacheable-response:5.0.0"]&&_()}catch(s){}class t{constructor(s={}){this.s=s.statuses,this.t=s.headers}isResponseCacheable(s){let t=!0;return this.s&&(t=this.s.includes(s.status)),this.t&&t&&(t=Object.keys(this.t).some(t=>s.headers.get(t)===this.t[t])),t}}return s.CacheableResponse=t,s.CacheableResponsePlugin=class{constructor(s){this.cacheWillUpdate=(async({response:s})=>this.i.isResponseCacheable(s)?s:null),this.i=new t(s)}},s}({});
|
2
|
+
//# sourceMappingURL=workbox-cacheable-response.prod.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-cacheable-response.prod.js","sources":["../_version.js","../CacheableResponse.js","../CacheableResponsePlugin.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:cacheable-response:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport './_version.js';\n/**\n * This class allows you to set up rules determining what\n * status codes and/or headers need to be present in order for a\n * [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)\n * to be considered cacheable.\n *\n * @memberof module:workbox-cacheable-response\n */\nclass CacheableResponse {\n /**\n * To construct a new CacheableResponse instance you must provide at least\n * one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (!(config.statuses || config.headers)) {\n throw new WorkboxError('statuses-or-headers-required', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n });\n }\n if (config.statuses) {\n assert.isArray(config.statuses, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.statuses',\n });\n }\n if (config.headers) {\n assert.isType(config.headers, 'object', {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'constructor',\n paramName: 'config.headers',\n });\n }\n }\n this._statuses = config.statuses;\n this._headers = config.headers;\n }\n /**\n * Checks a response to see whether it's cacheable or not, based on this\n * object's configuration.\n *\n * @param {Response} response The response whose cacheability is being\n * checked.\n * @return {boolean} `true` if the `Response` is cacheable, and `false`\n * otherwise.\n */\n isResponseCacheable(response) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(response, Response, {\n moduleName: 'workbox-cacheable-response',\n className: 'CacheableResponse',\n funcName: 'isResponseCacheable',\n paramName: 'response',\n });\n }\n let cacheable = true;\n if (this._statuses) {\n cacheable = this._statuses.includes(response.status);\n }\n if (this._headers && cacheable) {\n cacheable = Object.keys(this._headers).some((headerName) => {\n return response.headers.get(headerName) === this._headers[headerName];\n });\n }\n if (process.env.NODE_ENV !== 'production') {\n if (!cacheable) {\n logger.groupCollapsed(`The request for ` +\n `'${getFriendlyURL(response.url)}' returned a response that does ` +\n `not meet the criteria for being cached.`);\n logger.groupCollapsed(`View cacheability criteria here.`);\n logger.log(`Cacheable statuses: ` +\n JSON.stringify(this._statuses));\n logger.log(`Cacheable headers: ` +\n JSON.stringify(this._headers, null, 2));\n logger.groupEnd();\n const logFriendlyHeaders = {};\n response.headers.forEach((value, key) => {\n logFriendlyHeaders[key] = value;\n });\n logger.groupCollapsed(`View response status and headers here.`);\n logger.log(`Response status: ` + response.status);\n logger.log(`Response headers: ` +\n JSON.stringify(logFriendlyHeaders, null, 2));\n logger.groupEnd();\n logger.groupCollapsed(`View full response details here.`);\n logger.log(response.headers);\n logger.log(response);\n logger.groupEnd();\n logger.groupEnd();\n }\n }\n return cacheable;\n }\n}\nexport { CacheableResponse };\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 { CacheableResponse } from './CacheableResponse.js';\nimport './_version.js';\n/**\n * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it\n * easier to add in cacheability checks to requests made via Workbox's built-in\n * strategies.\n *\n * @memberof module:workbox-cacheable-response\n */\nclass CacheableResponsePlugin {\n /**\n * To construct a new CacheableResponsePlugin instance you must provide at\n * least one of the `config` properties.\n *\n * If both `statuses` and `headers` are specified, then both conditions must\n * be met for the `Response` to be considered cacheable.\n *\n * @param {Object} config\n * @param {Array<number>} [config.statuses] One or more status codes that a\n * `Response` can have and be considered cacheable.\n * @param {Object<string,string>} [config.headers] A mapping of header names\n * and expected values that a `Response` can have and be considered cacheable.\n * If multiple headers are provided, only one needs to be present.\n */\n constructor(config) {\n /**\n * @param {Object} options\n * @param {Response} options.response\n * @return {Response|null}\n * @private\n */\n this.cacheWillUpdate = async ({ response }) => {\n if (this._cacheableResponse.isResponseCacheable(response)) {\n return response;\n }\n return null;\n };\n this._cacheableResponse = new CacheableResponse(config);\n }\n}\nexport { CacheableResponsePlugin };\n"],"names":["self","_","e","CacheableResponse","constructor","config","_statuses","statuses","_headers","headers","isResponseCacheable","response","cacheable","this","includes","status","Object","keys","some","headerName","get","cacheWillUpdate","async","_cacheableResponse"],"mappings":"sFAEA,IACIA,KAAK,qCAAuCC,IAEhD,MAAOC,ICeP,MAAMC,EAeFC,YAAYC,EAAS,SA0BZC,EAAYD,EAAOE,cACnBC,EAAWH,EAAOI,QAW3BC,oBAAoBC,OASZC,GAAY,SACZC,KAAKP,IACLM,EAAYC,KAAKP,EAAUQ,SAASH,EAASI,SAE7CF,KAAKL,GAAYI,IACjBA,EAAYI,OAAOC,KAAKJ,KAAKL,GAAUU,KAAMC,GAClCR,EAASF,QAAQW,IAAID,KAAgBN,KAAKL,EAASW,KA8B3DP,0DCtGf,MAeIR,YAAYC,QAOHgB,gBAAkBC,QAASX,SAAAA,KACxBE,KAAKU,EAAmBb,oBAAoBC,GACrCA,EAEJ,WAENY,EAAqB,IAAIpB,EAAkBE"}
|
@@ -2,9 +2,8 @@ this.workbox = this.workbox || {};
|
|
2
2
|
this.workbox.core = (function (exports) {
|
3
3
|
'use strict';
|
4
4
|
|
5
|
-
// @ts-ignore
|
6
5
|
try {
|
7
|
-
self['workbox:core:5.0.0
|
6
|
+
self['workbox:core:5.0.0'] && _();
|
8
7
|
} catch (e) {}
|
9
8
|
|
10
9
|
/*
|
@@ -14,6 +13,12 @@ this.workbox.core = (function (exports) {
|
|
14
13
|
https://opensource.org/licenses/MIT.
|
15
14
|
*/
|
16
15
|
const logger = (() => {
|
16
|
+
// Don't overwrite this value if it's already set.
|
17
|
+
// See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
|
18
|
+
if (!('__WB_DISABLE_DEV_LOGS' in self)) {
|
19
|
+
self.__WB_DISABLE_DEV_LOGS = false;
|
20
|
+
}
|
21
|
+
|
17
22
|
let inGroup = false;
|
18
23
|
const methodToColorMap = {
|
19
24
|
debug: `#7f8c8d`,
|
@@ -25,6 +30,10 @@ this.workbox.core = (function (exports) {
|
|
25
30
|
};
|
26
31
|
|
27
32
|
const print = function (method, args) {
|
33
|
+
if (self.__WB_DISABLE_DEV_LOGS) {
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
|
28
37
|
if (method === 'groupCollapsed') {
|
29
38
|
// Safari doesn't print all console.groupCollapsed() arguments:
|
30
39
|
// https://bugs.webkit.org/show_bug.cgi?id=182754
|
@@ -178,7 +187,7 @@ this.workbox.core = (function (exports) {
|
|
178
187
|
throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`);
|
179
188
|
}
|
180
189
|
|
181
|
-
return `You must provide a name containing at least one character for ` + `
|
190
|
+
return `You must provide a name containing at least one character for ` + `setCacheDetails({${cacheNameId}: '...'}). Received a value of ` + `'${JSON.stringify(value)}'`;
|
182
191
|
},
|
183
192
|
'unregister-route-but-not-found-with-method': ({
|
184
193
|
method
|
@@ -325,6 +334,22 @@ this.workbox.core = (function (exports) {
|
|
325
334
|
status
|
326
335
|
}) => {
|
327
336
|
return `The precaching request for '${url}' failed with an HTTP ` + `status of ${status}.`;
|
337
|
+
},
|
338
|
+
'non-precached-url': ({
|
339
|
+
url
|
340
|
+
}) => {
|
341
|
+
return `createHandlerBoundToURL('${url}') was called, but that URL is ` + `not precached. Please pass in a URL that is precached instead.`;
|
342
|
+
},
|
343
|
+
'add-to-cache-list-conflicting-integrities': ({
|
344
|
+
url
|
345
|
+
}) => {
|
346
|
+
return `Two of the entries passed to ` + `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + `${url} with different integrity values. Please remove one of them.`;
|
347
|
+
},
|
348
|
+
'missing-precache-entry': ({
|
349
|
+
cacheName,
|
350
|
+
url
|
351
|
+
}) => {
|
352
|
+
return `Unable to find a precached response in ${cacheName} for ${url}.`;
|
328
353
|
}
|
329
354
|
};
|
330
355
|
|
@@ -419,28 +444,28 @@ this.workbox.core = (function (exports) {
|
|
419
444
|
const type = typeof object[expectedMethod];
|
420
445
|
|
421
446
|
if (type !== 'function') {
|
422
|
-
details
|
447
|
+
details['expectedMethod'] = expectedMethod;
|
423
448
|
throw new WorkboxError('missing-a-method', details);
|
424
449
|
}
|
425
450
|
};
|
426
451
|
|
427
452
|
const isType = (object, expectedType, details) => {
|
428
453
|
if (typeof object !== expectedType) {
|
429
|
-
details
|
454
|
+
details['expectedType'] = expectedType;
|
430
455
|
throw new WorkboxError('incorrect-type', details);
|
431
456
|
}
|
432
457
|
};
|
433
458
|
|
434
459
|
const isInstance = (object, expectedClass, details) => {
|
435
460
|
if (!(object instanceof expectedClass)) {
|
436
|
-
details
|
461
|
+
details['expectedClass'] = expectedClass;
|
437
462
|
throw new WorkboxError('incorrect-class', details);
|
438
463
|
}
|
439
464
|
};
|
440
465
|
|
441
466
|
const isOneOf = (value, validValues, details) => {
|
442
467
|
if (!validValues.includes(value)) {
|
443
|
-
details
|
468
|
+
details['validValueDescription'] = `Valid values are ${JSON.stringify(validValues)}.`;
|
444
469
|
throw new WorkboxError('invalid-value', details);
|
445
470
|
}
|
446
471
|
};
|
@@ -491,7 +516,7 @@ this.workbox.core = (function (exports) {
|
|
491
516
|
* there's a quota error.
|
492
517
|
*
|
493
518
|
* @param {Function} callback
|
494
|
-
* @memberof workbox
|
519
|
+
* @memberof module:workbox-core
|
495
520
|
*/
|
496
521
|
|
497
522
|
function registerQuotaErrorCallback(callback) {
|
@@ -522,7 +547,7 @@ this.workbox.core = (function (exports) {
|
|
522
547
|
precache: 'precache-v2',
|
523
548
|
prefix: 'workbox',
|
524
549
|
runtime: 'runtime',
|
525
|
-
suffix: registration.scope
|
550
|
+
suffix: typeof registration !== 'undefined' ? registration.scope : ''
|
526
551
|
};
|
527
552
|
|
528
553
|
const _createCacheName = cacheName => {
|
@@ -560,24 +585,6 @@ this.workbox.core = (function (exports) {
|
|
560
585
|
}
|
561
586
|
};
|
562
587
|
|
563
|
-
/*
|
564
|
-
Copyright 2018 Google LLC
|
565
|
-
|
566
|
-
Use of this source code is governed by an MIT-style
|
567
|
-
license that can be found in the LICENSE file or at
|
568
|
-
https://opensource.org/licenses/MIT.
|
569
|
-
*/
|
570
|
-
|
571
|
-
const getFriendlyURL = url => {
|
572
|
-
const urlObj = new URL(String(url), location.href);
|
573
|
-
|
574
|
-
if (urlObj.origin === location.origin) {
|
575
|
-
return urlObj.pathname;
|
576
|
-
}
|
577
|
-
|
578
|
-
return urlObj.href;
|
579
|
-
};
|
580
|
-
|
581
588
|
/*
|
582
589
|
Copyright 2018 Google LLC
|
583
590
|
|
@@ -589,7 +596,7 @@ this.workbox.core = (function (exports) {
|
|
589
596
|
* Runs all of the callback functions, one at a time sequentially, in the order
|
590
597
|
* in which they were registered.
|
591
598
|
*
|
592
|
-
* @memberof workbox
|
599
|
+
* @memberof module:workbox-core
|
593
600
|
* @private
|
594
601
|
*/
|
595
602
|
|
@@ -611,6 +618,24 @@ this.workbox.core = (function (exports) {
|
|
611
618
|
}
|
612
619
|
}
|
613
620
|
|
621
|
+
/*
|
622
|
+
Copyright 2018 Google LLC
|
623
|
+
|
624
|
+
Use of this source code is governed by an MIT-style
|
625
|
+
license that can be found in the LICENSE file or at
|
626
|
+
https://opensource.org/licenses/MIT.
|
627
|
+
*/
|
628
|
+
|
629
|
+
const getFriendlyURL = url => {
|
630
|
+
const urlObj = new URL(String(url), location.href);
|
631
|
+
|
632
|
+
if (urlObj.origin === location.origin) {
|
633
|
+
return urlObj.pathname;
|
634
|
+
}
|
635
|
+
|
636
|
+
return urlObj.href;
|
637
|
+
};
|
638
|
+
|
614
639
|
/*
|
615
640
|
Copyright 2018 Google LLC
|
616
641
|
|
@@ -697,7 +722,7 @@ this.workbox.core = (function (exports) {
|
|
697
722
|
return;
|
698
723
|
}
|
699
724
|
|
700
|
-
const cache = await caches.open(cacheName);
|
725
|
+
const cache = await self.caches.open(cacheName);
|
701
726
|
const updatePlugins = pluginUtils.filter(plugins, "cacheDidUpdate"
|
702
727
|
/* CACHE_DID_UPDATE */
|
703
728
|
);
|
@@ -741,7 +766,7 @@ this.workbox.core = (function (exports) {
|
|
741
766
|
* @param {string} options.cacheName Name of the cache to match against.
|
742
767
|
* @param {Request} options.request The Request that will be used to look up
|
743
768
|
* cache entries.
|
744
|
-
* @param {Event} [options.event] The event that
|
769
|
+
* @param {Event} [options.event] The event that prompted the action.
|
745
770
|
* @param {Object} [options.matchOptions] Options passed to cache.match().
|
746
771
|
* @param {Array<Object>} [options.plugins=[]] Array of plugins.
|
747
772
|
* @return {Response} A cached response if available.
|
@@ -758,7 +783,7 @@ this.workbox.core = (function (exports) {
|
|
758
783
|
matchOptions,
|
759
784
|
plugins = []
|
760
785
|
}) => {
|
761
|
-
const cache = await caches.open(cacheName);
|
786
|
+
const cache = await self.caches.open(cacheName);
|
762
787
|
const effectiveRequest = await _getEffectiveRequest({
|
763
788
|
plugins,
|
764
789
|
request,
|
@@ -938,6 +963,96 @@ this.workbox.core = (function (exports) {
|
|
938
963
|
match: matchWrapper
|
939
964
|
};
|
940
965
|
|
966
|
+
/*
|
967
|
+
Copyright 2019 Google LLC
|
968
|
+
|
969
|
+
Use of this source code is governed by an MIT-style
|
970
|
+
license that can be found in the LICENSE file or at
|
971
|
+
https://opensource.org/licenses/MIT.
|
972
|
+
*/
|
973
|
+
let supportStatus;
|
974
|
+
/**
|
975
|
+
* A utility function that determines whether the current browser supports
|
976
|
+
* constructing a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)
|
977
|
+
* object.
|
978
|
+
*
|
979
|
+
* @return {boolean} `true`, if the current browser can successfully
|
980
|
+
* construct a `ReadableStream`, `false` otherwise.
|
981
|
+
*
|
982
|
+
* @private
|
983
|
+
*/
|
984
|
+
|
985
|
+
function canConstructReadableStream() {
|
986
|
+
if (supportStatus === undefined) {
|
987
|
+
// See https://github.com/GoogleChrome/workbox/issues/1473
|
988
|
+
try {
|
989
|
+
new ReadableStream({
|
990
|
+
start() {}
|
991
|
+
|
992
|
+
});
|
993
|
+
supportStatus = true;
|
994
|
+
} catch (error) {
|
995
|
+
supportStatus = false;
|
996
|
+
}
|
997
|
+
}
|
998
|
+
|
999
|
+
return supportStatus;
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
/*
|
1003
|
+
Copyright 2019 Google LLC
|
1004
|
+
|
1005
|
+
Use of this source code is governed by an MIT-style
|
1006
|
+
license that can be found in the LICENSE file or at
|
1007
|
+
https://opensource.org/licenses/MIT.
|
1008
|
+
*/
|
1009
|
+
let supportStatus$1;
|
1010
|
+
/**
|
1011
|
+
* A utility function that determines whether the current browser supports
|
1012
|
+
* constructing a new `Response` from a `response.body` stream.
|
1013
|
+
*
|
1014
|
+
* @return {boolean} `true`, if the current browser can successfully
|
1015
|
+
* construct a `Response` from a `response.body` stream, `false` otherwise.
|
1016
|
+
*
|
1017
|
+
* @private
|
1018
|
+
*/
|
1019
|
+
|
1020
|
+
function canConstructResponseFromBodyStream() {
|
1021
|
+
if (supportStatus$1 === undefined) {
|
1022
|
+
const testResponse = new Response('');
|
1023
|
+
|
1024
|
+
if ('body' in testResponse) {
|
1025
|
+
try {
|
1026
|
+
new Response(testResponse.body);
|
1027
|
+
supportStatus$1 = true;
|
1028
|
+
} catch (error) {
|
1029
|
+
supportStatus$1 = false;
|
1030
|
+
}
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
supportStatus$1 = false;
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
return supportStatus$1;
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
/*
|
1040
|
+
Copyright 2019 Google LLC
|
1041
|
+
Use of this source code is governed by an MIT-style
|
1042
|
+
license that can be found in the LICENSE file or at
|
1043
|
+
https://opensource.org/licenses/MIT.
|
1044
|
+
*/
|
1045
|
+
/**
|
1046
|
+
* A helper function that prevents a promise from being flagged as unused.
|
1047
|
+
*
|
1048
|
+
* @private
|
1049
|
+
**/
|
1050
|
+
|
1051
|
+
function dontWaitFor(promise) {
|
1052
|
+
// Effective no-op.
|
1053
|
+
promise.then(() => {});
|
1054
|
+
}
|
1055
|
+
|
941
1056
|
/*
|
942
1057
|
Copyright 2018 Google LLC
|
943
1058
|
|
@@ -1180,7 +1295,9 @@ this.workbox.core = (function (exports) {
|
|
1180
1295
|
|
1181
1296
|
async _call(method, storeName, type, ...args) {
|
1182
1297
|
const callback = (txn, done) => {
|
1183
|
-
const objStore = txn.objectStore(storeName);
|
1298
|
+
const objStore = txn.objectStore(storeName); // TODO(philipwalton): Fix this underlying TS2684 error.
|
1299
|
+
// @ts-ignore
|
1300
|
+
|
1184
1301
|
const request = objStore[method].apply(objStore, args);
|
1185
1302
|
|
1186
1303
|
request.onsuccess = () => done(request.result);
|
@@ -1311,7 +1428,7 @@ this.workbox.core = (function (exports) {
|
|
1311
1428
|
* @param {Object} options
|
1312
1429
|
* @param {Request|string} options.request
|
1313
1430
|
* @param {Object} [options.fetchOptions]
|
1314
|
-
* @param {
|
1431
|
+
* @param {ExtendableEvent} [options.event]
|
1315
1432
|
* @param {Array<Object>} [options.plugins=[]]
|
1316
1433
|
* @return {Promise<Response>}
|
1317
1434
|
*
|
@@ -1464,6 +1581,80 @@ this.workbox.core = (function (exports) {
|
|
1464
1581
|
fetch: wrappedFetch
|
1465
1582
|
};
|
1466
1583
|
|
1584
|
+
/*
|
1585
|
+
Copyright 2019 Google LLC
|
1586
|
+
Use of this source code is governed by an MIT-style
|
1587
|
+
license that can be found in the LICENSE file or at
|
1588
|
+
https://opensource.org/licenses/MIT.
|
1589
|
+
*/
|
1590
|
+
/**
|
1591
|
+
* Returns a promise that resolves and the passed number of milliseconds.
|
1592
|
+
* This utility is an async/await-friendly version of `setTimeout`.
|
1593
|
+
*
|
1594
|
+
* @param {number} ms
|
1595
|
+
* @return {Promise}
|
1596
|
+
* @private
|
1597
|
+
*/
|
1598
|
+
|
1599
|
+
function timeout(ms) {
|
1600
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
1601
|
+
}
|
1602
|
+
|
1603
|
+
/*
|
1604
|
+
Copyright 2019 Google LLC
|
1605
|
+
Use of this source code is governed by an MIT-style
|
1606
|
+
license that can be found in the LICENSE file or at
|
1607
|
+
https://opensource.org/licenses/MIT.
|
1608
|
+
*/
|
1609
|
+
const MAX_RETRY_TIME = 2000;
|
1610
|
+
/**
|
1611
|
+
* Returns a promise that resolves to a window client matching the passed
|
1612
|
+
* `resultingClientId`. For browsers that don't support `resultingClientId`
|
1613
|
+
* or if waiting for the resulting client to apper takes too long, resolve to
|
1614
|
+
* `undefined`.
|
1615
|
+
*
|
1616
|
+
* @param {string} [resultingClientId]
|
1617
|
+
* @return {Promise<Client|undefined>}
|
1618
|
+
* @private
|
1619
|
+
*/
|
1620
|
+
|
1621
|
+
async function resultingClientExists(resultingClientId) {
|
1622
|
+
if (!resultingClientId) {
|
1623
|
+
return;
|
1624
|
+
}
|
1625
|
+
|
1626
|
+
let existingWindows = await self.clients.matchAll({
|
1627
|
+
type: 'window'
|
1628
|
+
});
|
1629
|
+
const existingWindowIds = new Set(existingWindows.map(w => w.id));
|
1630
|
+
let resultingWindow;
|
1631
|
+
const startTime = performance.now(); // Only wait up to `MAX_RETRY_TIME` to find a matching client.
|
1632
|
+
|
1633
|
+
while (performance.now() - startTime < MAX_RETRY_TIME) {
|
1634
|
+
existingWindows = await self.clients.matchAll({
|
1635
|
+
type: 'window'
|
1636
|
+
});
|
1637
|
+
resultingWindow = existingWindows.find(w => {
|
1638
|
+
if (resultingClientId) {
|
1639
|
+
// If we have a `resultingClientId`, we can match on that.
|
1640
|
+
return w.id === resultingClientId;
|
1641
|
+
} else {
|
1642
|
+
// Otherwise match on finding a window not in `existingWindowIds`.
|
1643
|
+
return !existingWindowIds.has(w.id);
|
1644
|
+
}
|
1645
|
+
});
|
1646
|
+
|
1647
|
+
if (resultingWindow) {
|
1648
|
+
break;
|
1649
|
+
} // Sleep for 100ms and retry.
|
1650
|
+
|
1651
|
+
|
1652
|
+
await timeout(100);
|
1653
|
+
}
|
1654
|
+
|
1655
|
+
return resultingWindow;
|
1656
|
+
}
|
1657
|
+
|
1467
1658
|
/*
|
1468
1659
|
Copyright 2018 Google LLC
|
1469
1660
|
|
@@ -1476,6 +1667,9 @@ this.workbox.core = (function (exports) {
|
|
1476
1667
|
assert: finalAssertExports,
|
1477
1668
|
cacheNames: cacheNames,
|
1478
1669
|
cacheWrapper: cacheWrapper,
|
1670
|
+
canConstructReadableStream: canConstructReadableStream,
|
1671
|
+
canConstructResponseFromBodyStream: canConstructResponseFromBodyStream,
|
1672
|
+
dontWaitFor: dontWaitFor,
|
1479
1673
|
DBWrapper: DBWrapper,
|
1480
1674
|
Deferred: Deferred,
|
1481
1675
|
deleteDatabase: deleteDatabase,
|
@@ -1483,27 +1677,11 @@ this.workbox.core = (function (exports) {
|
|
1483
1677
|
fetchWrapper: fetchWrapper,
|
1484
1678
|
getFriendlyURL: getFriendlyURL,
|
1485
1679
|
logger: logger,
|
1680
|
+
resultingClientExists: resultingClientExists,
|
1681
|
+
timeout: timeout,
|
1486
1682
|
WorkboxError: WorkboxError
|
1487
1683
|
});
|
1488
1684
|
|
1489
|
-
/*
|
1490
|
-
Copyright 2019 Google LLC
|
1491
|
-
|
1492
|
-
Use of this source code is governed by an MIT-style
|
1493
|
-
license that can be found in the LICENSE file or at
|
1494
|
-
https://opensource.org/licenses/MIT.
|
1495
|
-
*/
|
1496
|
-
/**
|
1497
|
-
* Claim any currently available clients once the service worker
|
1498
|
-
* becomes active. This is normally used in conjunction with `skipWaiting()`.
|
1499
|
-
*
|
1500
|
-
* @alias workbox.core.clientsClaim
|
1501
|
-
*/
|
1502
|
-
|
1503
|
-
const clientsClaim = () => {
|
1504
|
-
addEventListener('activate', () => self.clients.claim());
|
1505
|
-
};
|
1506
|
-
|
1507
1685
|
/*
|
1508
1686
|
Copyright 2019 Google LLC
|
1509
1687
|
|
@@ -1524,7 +1702,7 @@ this.workbox.core = (function (exports) {
|
|
1524
1702
|
* @return {Object} An object with `precache`, `runtime`, `prefix`, and
|
1525
1703
|
* `googleAnalytics` properties.
|
1526
1704
|
*
|
1527
|
-
* @
|
1705
|
+
* @memberof module:workbox-core
|
1528
1706
|
*/
|
1529
1707
|
|
1530
1708
|
const cacheNames$1 = {
|
@@ -1550,6 +1728,65 @@ this.workbox.core = (function (exports) {
|
|
1550
1728
|
|
1551
1729
|
};
|
1552
1730
|
|
1731
|
+
/*
|
1732
|
+
Copyright 2019 Google LLC
|
1733
|
+
|
1734
|
+
Use of this source code is governed by an MIT-style
|
1735
|
+
license that can be found in the LICENSE file or at
|
1736
|
+
https://opensource.org/licenses/MIT.
|
1737
|
+
*/
|
1738
|
+
/**
|
1739
|
+
* Allows developers to copy a response and modify its `headers`, `status`,
|
1740
|
+
* or `statusText` values (the values settable via a
|
1741
|
+
* [`ResponseInit`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#Syntax}
|
1742
|
+
* object in the constructor).
|
1743
|
+
* To modify these values, pass a function as the second argument. That
|
1744
|
+
* function will be invoked with a single object with the response properties
|
1745
|
+
* `{headers, status, statusText}`. The return value of this function will
|
1746
|
+
* be used as the `ResponseInit` for the new `Response`. To change the values
|
1747
|
+
* either modify the passed parameter(s) and return it, or return a totally
|
1748
|
+
* new object.
|
1749
|
+
*
|
1750
|
+
* @param {Response} response
|
1751
|
+
* @param {Function} modifier
|
1752
|
+
* @memberof module:workbox-core
|
1753
|
+
*/
|
1754
|
+
|
1755
|
+
async function copyResponse(response, modifier) {
|
1756
|
+
const clonedResponse = response.clone(); // Create a fresh `ResponseInit` object by cloning the headers.
|
1757
|
+
|
1758
|
+
const responseInit = {
|
1759
|
+
headers: new Headers(clonedResponse.headers),
|
1760
|
+
status: clonedResponse.status,
|
1761
|
+
statusText: clonedResponse.statusText
|
1762
|
+
}; // Apply any user modifications.
|
1763
|
+
|
1764
|
+
const modifiedResponseInit = modifier ? modifier(responseInit) : responseInit; // Create the new response from the body stream and `ResponseInit`
|
1765
|
+
// modifications. Note: not all browsers support the Response.body stream,
|
1766
|
+
// so fall back to reading the entire body into memory as a blob.
|
1767
|
+
|
1768
|
+
const body = canConstructResponseFromBodyStream() ? clonedResponse.body : await clonedResponse.blob();
|
1769
|
+
return new Response(body, modifiedResponseInit);
|
1770
|
+
}
|
1771
|
+
|
1772
|
+
/*
|
1773
|
+
Copyright 2019 Google LLC
|
1774
|
+
|
1775
|
+
Use of this source code is governed by an MIT-style
|
1776
|
+
license that can be found in the LICENSE file or at
|
1777
|
+
https://opensource.org/licenses/MIT.
|
1778
|
+
*/
|
1779
|
+
/**
|
1780
|
+
* Claim any currently available clients once the service worker
|
1781
|
+
* becomes active. This is normally used in conjunction with `skipWaiting()`.
|
1782
|
+
*
|
1783
|
+
* @memberof module:workbox-core
|
1784
|
+
*/
|
1785
|
+
|
1786
|
+
function clientsClaim() {
|
1787
|
+
self.addEventListener('activate', () => self.clients.claim());
|
1788
|
+
}
|
1789
|
+
|
1553
1790
|
/*
|
1554
1791
|
Copyright 2019 Google LLC
|
1555
1792
|
|
@@ -1572,10 +1809,10 @@ this.workbox.core = (function (exports) {
|
|
1572
1809
|
* @param {Object} [details.googleAnalytics] The cache name to use for
|
1573
1810
|
* `workbox-google-analytics` caching.
|
1574
1811
|
*
|
1575
|
-
* @
|
1812
|
+
* @memberof module:workbox-core
|
1576
1813
|
*/
|
1577
1814
|
|
1578
|
-
|
1815
|
+
function setCacheNameDetails(details) {
|
1579
1816
|
{
|
1580
1817
|
Object.keys(details).forEach(key => {
|
1581
1818
|
finalAssertExports.isType(details[key], 'string', {
|
@@ -1585,30 +1822,30 @@ this.workbox.core = (function (exports) {
|
|
1585
1822
|
});
|
1586
1823
|
});
|
1587
1824
|
|
1588
|
-
if ('precache' in details && details
|
1825
|
+
if ('precache' in details && details['precache'].length === 0) {
|
1589
1826
|
throw new WorkboxError('invalid-cache-name', {
|
1590
1827
|
cacheNameId: 'precache',
|
1591
|
-
value: details
|
1828
|
+
value: details['precache']
|
1592
1829
|
});
|
1593
1830
|
}
|
1594
1831
|
|
1595
|
-
if ('runtime' in details && details
|
1832
|
+
if ('runtime' in details && details['runtime'].length === 0) {
|
1596
1833
|
throw new WorkboxError('invalid-cache-name', {
|
1597
1834
|
cacheNameId: 'runtime',
|
1598
|
-
value: details
|
1835
|
+
value: details['runtime']
|
1599
1836
|
});
|
1600
1837
|
}
|
1601
1838
|
|
1602
|
-
if ('googleAnalytics' in details && details
|
1839
|
+
if ('googleAnalytics' in details && details['googleAnalytics'].length === 0) {
|
1603
1840
|
throw new WorkboxError('invalid-cache-name', {
|
1604
1841
|
cacheNameId: 'googleAnalytics',
|
1605
|
-
value: details
|
1842
|
+
value: details['googleAnalytics']
|
1606
1843
|
});
|
1607
1844
|
}
|
1608
1845
|
}
|
1609
1846
|
|
1610
1847
|
cacheNames.updateDetails(details);
|
1611
|
-
}
|
1848
|
+
}
|
1612
1849
|
|
1613
1850
|
/*
|
1614
1851
|
Copyright 2019 Google LLC
|
@@ -1618,21 +1855,23 @@ this.workbox.core = (function (exports) {
|
|
1618
1855
|
https://opensource.org/licenses/MIT.
|
1619
1856
|
*/
|
1620
1857
|
/**
|
1621
|
-
* Force a service worker to
|
1622
|
-
*
|
1858
|
+
* Force a service worker to activate immediately, instead of
|
1859
|
+
* [waiting](https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting)
|
1860
|
+
* for existing clients to close.
|
1623
1861
|
*
|
1624
|
-
* @
|
1862
|
+
* @memberof module:workbox-core
|
1625
1863
|
*/
|
1626
1864
|
|
1627
|
-
|
1865
|
+
function skipWaiting() {
|
1628
1866
|
// We need to explicitly call `self.skipWaiting()` here because we're
|
1629
1867
|
// shadowing `skipWaiting` with this local function.
|
1630
|
-
addEventListener('install', () => self.skipWaiting());
|
1631
|
-
}
|
1868
|
+
self.addEventListener('install', () => self.skipWaiting());
|
1869
|
+
}
|
1632
1870
|
|
1633
1871
|
exports._private = _private;
|
1634
1872
|
exports.cacheNames = cacheNames$1;
|
1635
1873
|
exports.clientsClaim = clientsClaim;
|
1874
|
+
exports.copyResponse = copyResponse;
|
1636
1875
|
exports.registerQuotaErrorCallback = registerQuotaErrorCallback;
|
1637
1876
|
exports.setCacheNameDetails = setCacheNameDetails;
|
1638
1877
|
exports.skipWaiting = skipWaiting;
|