jekyll-pwa-workbox 0.0.6 → 0.0.7.alpha
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-background-sync.dev.js +819 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js +486 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js +192 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js +1643 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js +652 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js +103 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js +236 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js +994 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js +263 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js +1026 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js +1127 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js +333 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map +1 -0
- data/lib/vendor/{workbox-v4.3.1 → workbox-v5.0.0.alpha1}/workbox-window.dev.es5.mjs +248 -262
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map +1 -0
- data/lib/vendor/{workbox-v4.3.1 → workbox-v5.0.0.alpha1}/workbox-window.dev.mjs +234 -242
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js +882 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map +1 -0
- metadata +75 -80
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.dev.js +0 -822
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.dev.js +0 -496
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.dev.js +0 -200
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-core.dev.js +0 -1712
- data/lib/vendor/workbox-v4.3.1/workbox-core.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-core.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-core.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.dev.js +0 -652
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.dev.js +0 -110
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js +0 -243
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js +0 -989
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js +0 -268
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js +0 -1020
- data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js +0 -1138
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js +0 -337
- data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-sw.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-sw.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js +0 -896
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"workbox-routing.dev.js","sources":["../_version.mjs","../utils/constants.mjs","../utils/normalizeHandler.mjs","../Route.mjs","../NavigationRoute.mjs","../RegExpRoute.mjs","../Router.mjs","../utils/getOrCreateDefaultRouter.mjs","../registerNavigationRoute.mjs","../registerRoute.mjs","../setCatchHandler.mjs","../setDefaultHandler.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:routing:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * The default HTTP method, 'GET', used when there's no specific method\n * configured for a route.\n *\n * @type {string}\n *\n * @private\n */\nexport const defaultMethod = 'GET';\n\n/**\n * The list of valid HTTP methods associated with requests that could be routed.\n *\n * @type {Array<string>}\n *\n * @private\n */\nexport const validMethods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'PATCH',\n 'POST',\n 'PUT',\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n/**\n * @param {function()|Object} handler Either a function, or an object with a\n * 'handle' method.\n * @return {Object} An object with a handle method.\n *\n * @private\n */\nexport const normalizeHandler = (handler) => {\n if (handler && typeof handler === 'object') {\n if (process.env.NODE_ENV !== 'production') {\n assert.hasMethod(handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return handler;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(handler, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return {handle: handler};\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 {assert} from 'workbox-core/_private/assert.mjs';\n\nimport {defaultMethod, validMethods} from './utils/constants.mjs';\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * A `Route` consists of a pair of callback functions, \"match\" and \"handler\".\n * The \"match\" callback determine if a route should be used to \"handle\" a\n * request by returning a non-falsy value if it can. The \"handler\" callback\n * is called when there is a match and should return a Promise that resolves\n * to a `Response`.\n *\n * @memberof workbox.routing\n */\nclass Route {\n /**\n * Constructor for Route class.\n *\n * @param {workbox.routing.Route~matchCallback} match\n * A callback function that determines whether the route matches a given\n * `fetch` event by returning a non-falsy value.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resolving to a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(match, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(match, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'match',\n });\n\n if (method) {\n assert.isOneOf(method, validMethods, {paramName: 'method'});\n }\n }\n\n // These values are referenced directly by Router so cannot be\n // altered by minifification.\n this.handler = normalizeHandler(handler);\n this.match = match;\n this.method = method || defaultMethod;\n }\n}\n\nexport {Route};\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * NavigationRoute makes it easy to create a [Route]{@link\n * workbox.routing.Route} that matches for browser\n * [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}.\n *\n * It will only match incoming Requests whose\n * [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode}\n * is set to `navigate`.\n *\n * You can optionally only apply this route to a subset of navigation requests\n * by using one or both of the `blacklist` and `whitelist` parameters.\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass NavigationRoute extends Route {\n /**\n * If both `blacklist` and `whiltelist` are provided, the `blacklist` will\n * take precedence and the request will not match this route.\n *\n * The regular expressions in `whitelist` and `blacklist`\n * are matched against the concatenated\n * [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname}\n * and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search}\n * portions of the requested URL.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {Object} options\n * @param {Array<RegExp>} [options.blacklist] If any of these patterns match,\n * the route will not handle the request (even if a whitelist RegExp matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n */\n constructor(handler, {whitelist = [/./], blacklist = []} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArrayOfClass(whitelist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.whitelist',\n });\n assert.isArrayOfClass(blacklist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.blacklist',\n });\n }\n\n super((options) => this._match(options), handler);\n\n this._whitelist = whitelist;\n this._blacklist = blacklist;\n }\n\n /**\n * Routes match handler.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request\n * @return {boolean}\n *\n * @private\n */\n _match({url, request}) {\n if (request.mode !== 'navigate') {\n return false;\n }\n\n const pathnameAndSearch = url.pathname + url.search;\n\n for (const regExp of this._blacklist) {\n if (regExp.test(pathnameAndSearch)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the ` +\n `URL matches this blacklist pattern: ${regExp}`);\n }\n return false;\n }\n }\n\n if (this._whitelist.some((regExp) => regExp.test(pathnameAndSearch))) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`The navigation route is being used.`);\n }\n return true;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the URL ` +\n `being navigated to doesn't match the whitelist.`);\n }\n return false;\n }\n}\n\nexport {NavigationRoute};\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * RegExpRoute makes it easy to create a regular expression based\n * [Route]{@link workbox.routing.Route}.\n *\n * For same-origin requests the RegExp only needs to match part of the URL. For\n * requests against third-party servers, you must define a RegExp that matches\n * the start of the URL.\n *\n * [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing}\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass RegExpRoute extends Route {\n /**\n * If the regulard expression contains\n * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},\n * th ecaptured values will be passed to the\n * [handler's]{@link workbox.routing.Route~handlerCallback} `params`\n * argument.\n *\n * @param {RegExp} regExp The regular expression to match against URLs.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(regExp, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(regExp, RegExp, {\n moduleName: 'workbox-routing',\n className: 'RegExpRoute',\n funcName: 'constructor',\n paramName: 'pattern',\n });\n }\n\n const match = ({url}) => {\n const result = regExp.exec(url.href);\n\n // Return null immediately if there's no match.\n if (!result) {\n return null;\n }\n\n // Require that the match start at the first character in the URL string\n // if it's a cross-origin request.\n // See https://github.com/GoogleChrome/workbox/issues/281 for the context\n // behind this behavior.\n if ((url.origin !== location.origin) && (result.index !== 0)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `The regular expression '${regExp}' only partially matched ` +\n `against the cross-origin URL '${url}'. RegExpRoute's will only ` +\n `handle cross-origin requests if they match the entire URL.`\n );\n }\n\n return null;\n }\n\n // If the route matches, but there aren't any capture groups defined, then\n // this will return [], which is truthy and therefore sufficient to\n // indicate a match.\n // If there are capture groups, then it will return their values.\n return result.slice(1);\n };\n\n super(match, handler, method);\n }\n}\n\nexport {RegExpRoute};\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\n\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * The Router can be used to process a FetchEvent through one or more\n * [Routes]{@link workbox.routing.Route} responding with a Request if\n * a matching route exists.\n *\n * If no route matches a given a request, the Router will use a \"default\"\n * handler if one is defined.\n *\n * Should the matching Route throw an error, the Router will use a \"catch\"\n * handler if one is defined to gracefully deal with issues and respond with a\n * Request.\n *\n * If a request matches multiple routes, the **earliest** registered route will\n * be used to respond to the request.\n *\n * @memberof workbox.routing\n */\nclass Router {\n /**\n * Initializes a new Router.\n */\n constructor() {\n this._routes = new Map();\n }\n\n /**\n * @return {Map<string, Array<workbox.routing.Route>>} routes A `Map` of HTTP\n * method name ('GET', etc.) to an array of all the corresponding `Route`\n * instances that are registered.\n */\n get routes() {\n return this._routes;\n }\n\n /**\n * Adds a fetch event listener to respond to events when a route matches\n * the event's request.\n */\n addFetchListener() {\n self.addEventListener('fetch', (event) => {\n const {request} = event;\n const responsePromise = this.handleRequest({request, event});\n if (responsePromise) {\n event.respondWith(responsePromise);\n }\n });\n }\n\n /**\n * Adds a message event listener for URLs to cache from the window.\n * This is useful to cache resources loaded on the page prior to when the\n * service worker started controlling it.\n *\n * The format of the message data sent from the window should be as follows.\n * Where the `urlsToCache` array may consist of URL strings or an array of\n * URL string + `requestInit` object (the same as you'd pass to `fetch()`).\n *\n * ```\n * {\n * type: 'CACHE_URLS',\n * payload: {\n * urlsToCache: [\n * './script1.js',\n * './script2.js',\n * ['./script3.js', {mode: 'no-cors'}],\n * ],\n * },\n * }\n * ```\n */\n addCacheListener() {\n self.addEventListener('message', async (event) => {\n if (event.data && event.data.type === 'CACHE_URLS') {\n const {payload} = event.data;\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Caching URLs from the window`, payload.urlsToCache);\n }\n\n const requestPromises = Promise.all(payload.urlsToCache.map((entry) => {\n if (typeof entry === 'string') {\n entry = [entry];\n }\n\n const request = new Request(...entry);\n return this.handleRequest({request});\n }));\n\n event.waitUntil(requestPromises);\n\n // If a MessageChannel was used, reply to the message on success.\n if (event.ports && event.ports[0]) {\n await requestPromises;\n event.ports[0].postMessage(true);\n }\n }\n });\n }\n\n /**\n * Apply the routing rules to a FetchEvent object to get a Response from an\n * appropriate Route's handler.\n *\n * @param {Object} options\n * @param {Request} options.request The request to handle (this is usually\n * from a fetch event, but it does not have to be).\n * @param {FetchEvent} [options.event] The event that triggered the request,\n * if applicable.\n * @return {Promise<Response>|undefined} A promise is returned if a\n * registered route can handle the request. If there is no matching\n * route and there's no `defaultHandler`, `undefined` is returned.\n */\n handleRequest({request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'handleRequest',\n paramName: 'options.request',\n });\n }\n\n const url = new URL(request.url, location);\n if (!url.protocol.startsWith('http')) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `Workbox Router only supports URLs that start with 'http'.`);\n }\n return;\n }\n\n let {params, route} = this.findMatchingRoute({url, request, event});\n let handler = route && route.handler;\n\n let debugMessages = [];\n if (process.env.NODE_ENV !== 'production') {\n if (handler) {\n debugMessages.push([\n `Found a route to handle this request:`, route,\n ]);\n\n if (params) {\n debugMessages.push([\n `Passing the following params to the route's handler:`, params,\n ]);\n }\n }\n }\n\n // If we don't have a handler because there was no matching route, then\n // fall back to defaultHandler if that's defined.\n if (!handler && this._defaultHandler) {\n if (process.env.NODE_ENV !== 'production') {\n debugMessages.push(`Failed to find a matching route. Falling ` +\n `back to the default handler.`);\n\n // This is used for debugging in logs in the case of an error.\n route = '[Default Handler]';\n }\n handler = this._defaultHandler;\n }\n\n if (!handler) {\n if (process.env.NODE_ENV !== 'production') {\n // No handler so Workbox will do nothing. If logs is set of debug\n // i.e. verbose, we should print out this information.\n logger.debug(`No route found for: ${getFriendlyURL(url)}`);\n }\n return;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // We have a handler, meaning Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Router is responding to: ${getFriendlyURL(url)}`);\n debugMessages.forEach((msg) => {\n if (Array.isArray(msg)) {\n logger.log(...msg);\n } else {\n logger.log(msg);\n }\n });\n\n // The Request and Response objects contains a great deal of information,\n // hide it under a group in case developers want to see it.\n logger.groupCollapsed(`View request details here.`);\n logger.log(request);\n logger.groupEnd();\n\n logger.groupEnd();\n }\n\n // Wrap in try and catch in case the handle method throws a synchronous\n // error. It should still callback to the catch handler.\n let responsePromise;\n try {\n responsePromise = handler.handle({url, request, event, params});\n } catch (err) {\n responsePromise = Promise.reject(err);\n }\n\n if (responsePromise && this._catchHandler) {\n responsePromise = responsePromise.catch((err) => {\n if (process.env.NODE_ENV !== 'production') {\n // Still include URL here as it will be async from the console group\n // and may not make sense without the URL\n logger.groupCollapsed(`Error thrown when responding to: ` +\n ` ${getFriendlyURL(url)}. Falling back to Catch Handler.`);\n logger.error(`Error thrown by:`, route);\n logger.error(err);\n logger.groupEnd();\n }\n return this._catchHandler.handle({url, event, err});\n });\n }\n\n return responsePromise;\n }\n\n /**\n * Checks a request and URL (and optionally an event) against the list of\n * registered routes, and if there's a match, returns the corresponding\n * route along with any params generated by the match.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request The request to match.\n * @param {FetchEvent} [options.event] The corresponding event (unless N/A).\n * @return {Object} An object with `route` and `params` properties.\n * They are populated if a matching route was found or `undefined`\n * otherwise.\n */\n findMatchingRoute({url, request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(url, URL, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.url',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.request',\n });\n }\n\n const routes = this._routes.get(request.method) || [];\n for (const route of routes) {\n let params;\n let matchResult = route.match({url, request, event});\n if (matchResult) {\n if (Array.isArray(matchResult) && matchResult.length > 0) {\n // Instead of passing an empty array in as params, use undefined.\n params = matchResult;\n } else if ((matchResult.constructor === Object &&\n Object.keys(matchResult).length > 0)) {\n // Instead of passing an empty object in as params, use undefined.\n params = matchResult;\n }\n\n // Return early if have a match.\n return {route, params};\n }\n }\n // If no match was found above, return and empty object.\n return {};\n }\n\n /**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setDefaultHandler(handler) {\n this._defaultHandler = normalizeHandler(handler);\n }\n\n /**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setCatchHandler(handler) {\n this._catchHandler = normalizeHandler(handler);\n }\n\n /**\n * Registers a route with the router.\n *\n * @param {workbox.routing.Route} route The route to register.\n */\n registerRoute(route) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(route, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route, 'match', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.isType(route.handler, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route.handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.handler',\n });\n\n assert.isType(route.method, 'string', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.method',\n });\n }\n\n if (!this._routes.has(route.method)) {\n this._routes.set(route.method, []);\n }\n\n // Give precedence to all of the earlier routes by adding this additional\n // route to the end of the array.\n this._routes.get(route.method).push(route);\n }\n\n /**\n * Unregisters a route with the router.\n *\n * @param {workbox.routing.Route} route The route to unregister.\n */\n unregisterRoute(route) {\n if (!this._routes.has(route.method)) {\n throw new WorkboxError(\n 'unregister-route-but-not-found-with-method', {\n method: route.method,\n }\n );\n }\n\n const routeIndex = this._routes.get(route.method).indexOf(route);\n if (routeIndex > -1) {\n this._routes.get(route.method).splice(routeIndex, 1);\n } else {\n throw new WorkboxError('unregister-route-route-not-registered');\n }\n }\n}\n\nexport {Router};\n","/*\n Copyright 2019 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 {Router} from '../Router.mjs';\nimport '../_version.mjs';\n\nlet defaultRouter;\n\n/**\n * Creates a new, singleton Router instance if one does not exist. If one\n * does already exist, that instance is returned.\n *\n * @private\n * @return {Router}\n */\nexport const getOrCreateDefaultRouter = () => {\n if (!defaultRouter) {\n defaultRouter = new Router();\n\n // The helpers that use the default Router assume these listeners exist.\n defaultRouter.addFetchListener();\n defaultRouter.addCacheListener();\n }\n return defaultRouter;\n};\n","/*\n Copyright 2019 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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {NavigationRoute} from './NavigationRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Registers a route that will return a precached file for a navigation\n * request. This is useful for the\n * [application shell pattern]{@link https://developers.google.com/web/fundamentals/architecture/app-shell}.\n *\n * When determining the URL of the precached HTML document, you will likely need\n * to call `workbox.precaching.getCacheKeyForURL(originalUrl)`, to account for\n * the fact that Workbox's precaching naming conventions often results in URL\n * cache keys that contain extra revisioning info.\n *\n * This method will generate a\n * [NavigationRoute]{@link workbox.routing.NavigationRoute}\n * and call\n * [Router.registerRoute()]{@link workbox.routing.Router#registerRoute} on a\n * singleton Router instance.\n *\n * @param {string} cachedAssetUrl The cache key to use for the HTML file.\n * @param {Object} [options]\n * @param {string} [options.cacheName] Cache name to store and retrieve\n * requests. Defaults to precache cache name provided by\n * [workbox-core.cacheNames]{@link workbox.core.cacheNames}.\n * @param {Array<RegExp>} [options.blacklist=[]] If any of these patterns\n * match, the route will not handle the request (even if a whitelist entry\n * matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n * @return {workbox.routing.NavigationRoute} Returns the generated\n * Route.\n *\n * @alias workbox.routing.registerNavigationRoute\n */\nexport const registerNavigationRoute = (cachedAssetUrl, options = {}) => {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cachedAssetUrl, 'string', {\n moduleName: 'workbox-routing',\n funcName: 'registerNavigationRoute',\n paramName: 'cachedAssetUrl',\n });\n }\n\n const cacheName = cacheNames.getPrecacheName(options.cacheName);\n const handler = async () => {\n try {\n const response = await caches.match(cachedAssetUrl, {cacheName});\n\n if (response) {\n return response;\n }\n\n // This shouldn't normally happen, but there are edge cases:\n // https://github.com/GoogleChrome/workbox/issues/1441\n throw new Error(`The cache ${cacheName} did not have an entry for ` +\n `${cachedAssetUrl}.`);\n } catch (error) {\n // If there's either a cache miss, or the caches.match() call threw\n // an exception, then attempt to fulfill the navigation request with\n // a response from the network rather than leaving the user with a\n // failed navigation.\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Unable to respond to navigation request with ` +\n `cached response. Falling back to network.`, error);\n }\n\n // This might still fail if the browser is offline...\n return fetch(cachedAssetUrl);\n }\n };\n\n const route = new NavigationRoute(handler, {\n whitelist: options.whitelist,\n blacklist: options.blacklist,\n });\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 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 {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {Route} from './Route.mjs';\nimport {RegExpRoute} from './RegExpRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Easily register a RegExp, string, or function with a caching\n * strategy to a singleton Router instance.\n *\n * This method will generate a Route for you if needed and\n * call [Router.registerRoute()]{@link\n * workbox.routing.Router#registerRoute}.\n *\n * @param {\n * RegExp|\n * string|\n * workbox.routing.Route~matchCallback|\n * workbox.routing.Route\n * } capture\n * If the capture param is a `Route`, all other arguments will be ignored.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n * @return {workbox.routing.Route} The generated `Route`(Useful for\n * unregistering).\n *\n * @alias workbox.routing.registerRoute\n */\nexport const registerRoute = (capture, handler, method = 'GET') => {\n let route;\n\n if (typeof capture === 'string') {\n const captureUrl = new URL(capture, location);\n\n if (process.env.NODE_ENV !== 'production') {\n if (!(capture.startsWith('/') || capture.startsWith('http'))) {\n throw new WorkboxError('invalid-string', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n // We want to check if Express-style wildcards are in the pathname only.\n // TODO: Remove this log message in v4.\n const valueToCheck = capture.startsWith('http') ?\n captureUrl.pathname : capture;\n\n // See https://github.com/pillarjs/path-to-regexp#parameters\n const wildcards = '[*:?+]';\n if (valueToCheck.match(new RegExp(`${wildcards}`))) {\n logger.debug(\n `The '$capture' parameter contains an Express-style wildcard ` +\n `character (${wildcards}). Strings are now always interpreted as ` +\n `exact matches; use a RegExp for partial or wildcard matches.`\n );\n }\n }\n\n const matchCallback = ({url}) => {\n if (process.env.NODE_ENV !== 'production') {\n if ((url.pathname === captureUrl.pathname) &&\n (url.origin !== captureUrl.origin)) {\n logger.debug(\n `${capture} only partially matches the cross-origin URL ` +\n `${url}. This route will only handle cross-origin requests ` +\n `if they match the entire URL.`);\n }\n }\n\n return url.href === captureUrl.href;\n };\n\n route = new Route(matchCallback, handler, method);\n } else if (capture instanceof RegExp) {\n route = new RegExpRoute(capture, handler, method);\n } else if (typeof capture === 'function') {\n route = new Route(capture, handler, method);\n } else if (capture instanceof Route) {\n route = capture;\n } else {\n throw new WorkboxError('unsupported-route-type', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 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 {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setCatchHandler\n */\nexport const setCatchHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setCatchHandler(handler);\n};\n","/*\n Copyright 2019 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 {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setDefaultHandler\n */\nexport const setDefaultHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setDefaultHandler(handler);\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 {assert} from 'workbox-core/_private/assert.mjs';\n\nimport {NavigationRoute} from './NavigationRoute.mjs';\nimport {RegExpRoute} from './RegExpRoute.mjs';\nimport {registerNavigationRoute} from './registerNavigationRoute.mjs';\nimport {registerRoute} from './registerRoute.mjs';\nimport {Route} from './Route.mjs';\nimport {Router} from './Router.mjs';\nimport {setCatchHandler} from './setCatchHandler.mjs';\nimport {setDefaultHandler} from './setDefaultHandler.mjs';\n\nimport './_version.mjs';\n\nif (process.env.NODE_ENV !== 'production') {\n assert.isSWEnv('workbox-routing');\n}\n\n/**\n * @namespace workbox.routing\n */\n\nexport {\n NavigationRoute,\n RegExpRoute,\n registerNavigationRoute,\n registerRoute,\n Route,\n Router,\n setCatchHandler,\n setDefaultHandler,\n};\n"],"names":["self","_","e","defaultMethod","validMethods","normalizeHandler","handler","assert","hasMethod","moduleName","className","funcName","paramName","isType","handle","Route","constructor","match","method","isOneOf","NavigationRoute","whitelist","blacklist","isArrayOfClass","RegExp","options","_match","_whitelist","_blacklist","url","request","mode","pathnameAndSearch","pathname","search","regExp","test","logger","log","some","debug","RegExpRoute","isInstance","result","exec","href","origin","location","index","slice","Router","_routes","Map","routes","addFetchListener","addEventListener","event","responsePromise","handleRequest","respondWith","addCacheListener","data","type","payload","urlsToCache","requestPromises","Promise","all","map","entry","Request","waitUntil","ports","postMessage","URL","protocol","startsWith","params","route","findMatchingRoute","debugMessages","push","_defaultHandler","getFriendlyURL","groupCollapsed","forEach","msg","Array","isArray","groupEnd","err","reject","_catchHandler","catch","error","get","matchResult","length","Object","keys","setDefaultHandler","setCatchHandler","registerRoute","has","set","unregisterRoute","WorkboxError","routeIndex","indexOf","splice","defaultRouter","getOrCreateDefaultRouter","registerNavigationRoute","cachedAssetUrl","cacheName","cacheNames","getPrecacheName","response","caches","Error","fetch","capture","captureUrl","valueToCheck","wildcards","matchCallback","isSWEnv"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,uBAAD,CAAJ,IAA+BC,CAAC,EAAhC;EAAmC,CAAvC,CAAuC,OAAMC,CAAN,EAAQ;;ECA/C;;;;;;;AAQA,EAEA;;;;;;;;;AAQA,EAAO,MAAMC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E/CE,MAAAA,QAAQ,EAAE,eAFqC;EAG/CC,MAAAA,SAAS,EAAE;EAHoC,KAA3C,CAAN;EAKD;;EAED,QAAMkG,aAAa,GAAGC,wBAAwB,EAA9C;EACAD,EAAAA,aAAa,CAACR,aAAd,CAA4BxB,KAA5B;EAEA,SAAOA,KAAP;EACD,CAhEM;;ECxCP;;;;;;;AAQA,EAIA;;;;;;;;;;AASA,QAAauB,eAAe,GAAI/F,OAAD,IAAa;EAC1C,QAAMwG,aAAa,GAAGC,wBAAwB,EAA9C;EACAD,EAAAA,aAAa,CAACT,eAAd,CAA8B/F,OAA9B;EACD,CAHM;;ECrBP;;;;;;;AAQA,EAIA;;;;;;;;;;;;;AAYA,QAAa8F,iBAAiB,GAAI9F,OAAD,IAAa;EAC5C,QAAMwG,aAAa,GAAGC,wBAAwB,EAA9C;EACAD,EAAAA,aAAa,CAACV,iBAAd,CAAgC9F,OAAhC;EACD,CAHM;;ECxBP;;;;;;;AAQA;AAaA,EAA2C;EACzCC,EAAAA,iBAAM,CAACuH,OAAP,CAAe,iBAAf;EACD;;;;;;;;;;;;;;;;;"}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
this.workbox=this.workbox||{},this.workbox.routing=function(t,e,r){"use strict";try{self["workbox:routing:4.3.1"]&&_()}catch(t){}const s="GET",n=t=>t&&"object"==typeof t?t:{handle:t};class o{constructor(t,e,r){this.handler=n(e),this.match=t,this.method=r||s}}class i extends o{constructor(t,{whitelist:e=[/./],blacklist:r=[]}={}){super(t=>this.t(t),t),this.s=e,this.o=r}t({url:t,request:e}){if("navigate"!==e.mode)return!1;const r=t.pathname+t.search;for(const t of this.o)if(t.test(r))return!1;return!!this.s.some(t=>t.test(r))}}class u extends o{constructor(t,e,r){super(({url:e})=>{const r=t.exec(e.href);return r?e.origin!==location.origin&&0!==r.index?null:r.slice(1):null},e,r)}}class c{constructor(){this.i=new Map}get routes(){return this.i}addFetchListener(){self.addEventListener("fetch",t=>{const{request:e}=t,r=this.handleRequest({request:e,event:t});r&&t.respondWith(r)})}addCacheListener(){self.addEventListener("message",async t=>{if(t.data&&"CACHE_URLS"===t.data.type){const{payload:e}=t.data,r=Promise.all(e.urlsToCache.map(t=>{"string"==typeof t&&(t=[t]);const e=new Request(...t);return this.handleRequest({request:e})}));t.waitUntil(r),t.ports&&t.ports[0]&&(await r,t.ports[0].postMessage(!0))}})}handleRequest({request:t,event:e}){const r=new URL(t.url,location);if(!r.protocol.startsWith("http"))return;let s,{params:n,route:o}=this.findMatchingRoute({url:r,request:t,event:e}),i=o&&o.handler;if(!i&&this.u&&(i=this.u),i){try{s=i.handle({url:r,request:t,event:e,params:n})}catch(t){s=Promise.reject(t)}return s&&this.h&&(s=s.catch(t=>this.h.handle({url:r,event:e,err:t}))),s}}findMatchingRoute({url:t,request:e,event:r}){const s=this.i.get(e.method)||[];for(const n of s){let s,o=n.match({url:t,request:e,event:r});if(o)return Array.isArray(o)&&o.length>0?s=o:o.constructor===Object&&Object.keys(o).length>0&&(s=o),{route:n,params:s}}return{}}setDefaultHandler(t){this.u=n(t)}setCatchHandler(t){this.h=n(t)}registerRoute(t){this.i.has(t.method)||this.i.set(t.method,[]),this.i.get(t.method).push(t)}unregisterRoute(t){if(!this.i.has(t.method))throw new r.WorkboxError("unregister-route-but-not-found-with-method",{method:t.method});const e=this.i.get(t.method).indexOf(t);if(!(e>-1))throw new r.WorkboxError("unregister-route-route-not-registered");this.i.get(t.method).splice(e,1)}}let a;const h=()=>(a||((a=new c).addFetchListener(),a.addCacheListener()),a);return t.NavigationRoute=i,t.RegExpRoute=u,t.registerNavigationRoute=((t,r={})=>{const s=e.cacheNames.getPrecacheName(r.cacheName),n=new i(async()=>{try{const e=await caches.match(t,{cacheName:s});if(e)return e;throw new Error(`The cache ${s} did not have an entry for `+`${t}.`)}catch(e){return fetch(t)}},{whitelist:r.whitelist,blacklist:r.blacklist});return h().registerRoute(n),n}),t.registerRoute=((t,e,s="GET")=>{let n;if("string"==typeof t){const r=new URL(t,location);n=new o(({url:t})=>t.href===r.href,e,s)}else if(t instanceof RegExp)n=new u(t,e,s);else if("function"==typeof t)n=new o(t,e,s);else{if(!(t instanceof o))throw new r.WorkboxError("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});n=t}return h().registerRoute(n),n}),t.Route=o,t.Router=c,t.setCatchHandler=(t=>{h().setCatchHandler(t)}),t.setDefaultHandler=(t=>{h().setDefaultHandler(t)}),t}({},workbox.core._private,workbox.core._private);
|
2
|
-
//# sourceMappingURL=workbox-routing.prod.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"workbox-routing.prod.js","sources":["../_version.mjs","../utils/constants.mjs","../utils/normalizeHandler.mjs","../Route.mjs","../NavigationRoute.mjs","../RegExpRoute.mjs","../Router.mjs","../utils/getOrCreateDefaultRouter.mjs","../registerNavigationRoute.mjs","../registerRoute.mjs","../setCatchHandler.mjs","../setDefaultHandler.mjs"],"sourcesContent":["try{self['workbox:routing:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport '../_version.mjs';\n\n/**\n * The default HTTP method, 'GET', used when there's no specific method\n * configured for a route.\n *\n * @type {string}\n *\n * @private\n */\nexport const defaultMethod = 'GET';\n\n/**\n * The list of valid HTTP methods associated with requests that could be routed.\n *\n * @type {Array<string>}\n *\n * @private\n */\nexport const validMethods = [\n 'DELETE',\n 'GET',\n 'HEAD',\n 'PATCH',\n 'POST',\n 'PUT',\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n/**\n * @param {function()|Object} handler Either a function, or an object with a\n * 'handle' method.\n * @return {Object} An object with a handle method.\n *\n * @private\n */\nexport const normalizeHandler = (handler) => {\n if (handler && typeof handler === 'object') {\n if (process.env.NODE_ENV !== 'production') {\n assert.hasMethod(handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return handler;\n } else {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(handler, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'handler',\n });\n }\n return {handle: handler};\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 {assert} from 'workbox-core/_private/assert.mjs';\n\nimport {defaultMethod, validMethods} from './utils/constants.mjs';\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * A `Route` consists of a pair of callback functions, \"match\" and \"handler\".\n * The \"match\" callback determine if a route should be used to \"handle\" a\n * request by returning a non-falsy value if it can. The \"handler\" callback\n * is called when there is a match and should return a Promise that resolves\n * to a `Response`.\n *\n * @memberof workbox.routing\n */\nclass Route {\n /**\n * Constructor for Route class.\n *\n * @param {workbox.routing.Route~matchCallback} match\n * A callback function that determines whether the route matches a given\n * `fetch` event by returning a non-falsy value.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resolving to a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(match, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(match, 'function', {\n moduleName: 'workbox-routing',\n className: 'Route',\n funcName: 'constructor',\n paramName: 'match',\n });\n\n if (method) {\n assert.isOneOf(method, validMethods, {paramName: 'method'});\n }\n }\n\n // These values are referenced directly by Router so cannot be\n // altered by minifification.\n this.handler = normalizeHandler(handler);\n this.match = match;\n this.method = method || defaultMethod;\n }\n}\n\nexport {Route};\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * NavigationRoute makes it easy to create a [Route]{@link\n * workbox.routing.Route} that matches for browser\n * [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}.\n *\n * It will only match incoming Requests whose\n * [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode}\n * is set to `navigate`.\n *\n * You can optionally only apply this route to a subset of navigation requests\n * by using one or both of the `blacklist` and `whitelist` parameters.\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass NavigationRoute extends Route {\n /**\n * If both `blacklist` and `whiltelist` are provided, the `blacklist` will\n * take precedence and the request will not match this route.\n *\n * The regular expressions in `whitelist` and `blacklist`\n * are matched against the concatenated\n * [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname}\n * and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search}\n * portions of the requested URL.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {Object} options\n * @param {Array<RegExp>} [options.blacklist] If any of these patterns match,\n * the route will not handle the request (even if a whitelist RegExp matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n */\n constructor(handler, {whitelist = [/./], blacklist = []} = {}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isArrayOfClass(whitelist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.whitelist',\n });\n assert.isArrayOfClass(blacklist, RegExp, {\n moduleName: 'workbox-routing',\n className: 'NavigationRoute',\n funcName: 'constructor',\n paramName: 'options.blacklist',\n });\n }\n\n super((options) => this._match(options), handler);\n\n this._whitelist = whitelist;\n this._blacklist = blacklist;\n }\n\n /**\n * Routes match handler.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request\n * @return {boolean}\n *\n * @private\n */\n _match({url, request}) {\n if (request.mode !== 'navigate') {\n return false;\n }\n\n const pathnameAndSearch = url.pathname + url.search;\n\n for (const regExp of this._blacklist) {\n if (regExp.test(pathnameAndSearch)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the ` +\n `URL matches this blacklist pattern: ${regExp}`);\n }\n return false;\n }\n }\n\n if (this._whitelist.some((regExp) => regExp.test(pathnameAndSearch))) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`The navigation route is being used.`);\n }\n return true;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route is not being used, since the URL ` +\n `being navigated to doesn't match the whitelist.`);\n }\n return false;\n }\n}\n\nexport {NavigationRoute};\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {Route} from './Route.mjs';\nimport './_version.mjs';\n\n/**\n * RegExpRoute makes it easy to create a regular expression based\n * [Route]{@link workbox.routing.Route}.\n *\n * For same-origin requests the RegExp only needs to match part of the URL. For\n * requests against third-party servers, you must define a RegExp that matches\n * the start of the URL.\n *\n * [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing}\n *\n * @memberof workbox.routing\n * @extends workbox.routing.Route\n */\nclass RegExpRoute extends Route {\n /**\n * If the regulard expression contains\n * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references},\n * th ecaptured values will be passed to the\n * [handler's]{@link workbox.routing.Route~handlerCallback} `params`\n * argument.\n *\n * @param {RegExp} regExp The regular expression to match against URLs.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n */\n constructor(regExp, handler, method) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(regExp, RegExp, {\n moduleName: 'workbox-routing',\n className: 'RegExpRoute',\n funcName: 'constructor',\n paramName: 'pattern',\n });\n }\n\n const match = ({url}) => {\n const result = regExp.exec(url.href);\n\n // Return null immediately if there's no match.\n if (!result) {\n return null;\n }\n\n // Require that the match start at the first character in the URL string\n // if it's a cross-origin request.\n // See https://github.com/GoogleChrome/workbox/issues/281 for the context\n // behind this behavior.\n if ((url.origin !== location.origin) && (result.index !== 0)) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `The regular expression '${regExp}' only partially matched ` +\n `against the cross-origin URL '${url}'. RegExpRoute's will only ` +\n `handle cross-origin requests if they match the entire URL.`\n );\n }\n\n return null;\n }\n\n // If the route matches, but there aren't any capture groups defined, then\n // this will return [], which is truthy and therefore sufficient to\n // indicate a match.\n // If there are capture groups, then it will return their values.\n return result.slice(1);\n };\n\n super(match, handler, method);\n }\n}\n\nexport {RegExpRoute};\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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\n\nimport {normalizeHandler} from './utils/normalizeHandler.mjs';\nimport './_version.mjs';\n\n/**\n * The Router can be used to process a FetchEvent through one or more\n * [Routes]{@link workbox.routing.Route} responding with a Request if\n * a matching route exists.\n *\n * If no route matches a given a request, the Router will use a \"default\"\n * handler if one is defined.\n *\n * Should the matching Route throw an error, the Router will use a \"catch\"\n * handler if one is defined to gracefully deal with issues and respond with a\n * Request.\n *\n * If a request matches multiple routes, the **earliest** registered route will\n * be used to respond to the request.\n *\n * @memberof workbox.routing\n */\nclass Router {\n /**\n * Initializes a new Router.\n */\n constructor() {\n this._routes = new Map();\n }\n\n /**\n * @return {Map<string, Array<workbox.routing.Route>>} routes A `Map` of HTTP\n * method name ('GET', etc.) to an array of all the corresponding `Route`\n * instances that are registered.\n */\n get routes() {\n return this._routes;\n }\n\n /**\n * Adds a fetch event listener to respond to events when a route matches\n * the event's request.\n */\n addFetchListener() {\n self.addEventListener('fetch', (event) => {\n const {request} = event;\n const responsePromise = this.handleRequest({request, event});\n if (responsePromise) {\n event.respondWith(responsePromise);\n }\n });\n }\n\n /**\n * Adds a message event listener for URLs to cache from the window.\n * This is useful to cache resources loaded on the page prior to when the\n * service worker started controlling it.\n *\n * The format of the message data sent from the window should be as follows.\n * Where the `urlsToCache` array may consist of URL strings or an array of\n * URL string + `requestInit` object (the same as you'd pass to `fetch()`).\n *\n * ```\n * {\n * type: 'CACHE_URLS',\n * payload: {\n * urlsToCache: [\n * './script1.js',\n * './script2.js',\n * ['./script3.js', {mode: 'no-cors'}],\n * ],\n * },\n * }\n * ```\n */\n addCacheListener() {\n self.addEventListener('message', async (event) => {\n if (event.data && event.data.type === 'CACHE_URLS') {\n const {payload} = event.data;\n\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Caching URLs from the window`, payload.urlsToCache);\n }\n\n const requestPromises = Promise.all(payload.urlsToCache.map((entry) => {\n if (typeof entry === 'string') {\n entry = [entry];\n }\n\n const request = new Request(...entry);\n return this.handleRequest({request});\n }));\n\n event.waitUntil(requestPromises);\n\n // If a MessageChannel was used, reply to the message on success.\n if (event.ports && event.ports[0]) {\n await requestPromises;\n event.ports[0].postMessage(true);\n }\n }\n });\n }\n\n /**\n * Apply the routing rules to a FetchEvent object to get a Response from an\n * appropriate Route's handler.\n *\n * @param {Object} options\n * @param {Request} options.request The request to handle (this is usually\n * from a fetch event, but it does not have to be).\n * @param {FetchEvent} [options.event] The event that triggered the request,\n * if applicable.\n * @return {Promise<Response>|undefined} A promise is returned if a\n * registered route can handle the request. If there is no matching\n * route and there's no `defaultHandler`, `undefined` is returned.\n */\n handleRequest({request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'handleRequest',\n paramName: 'options.request',\n });\n }\n\n const url = new URL(request.url, location);\n if (!url.protocol.startsWith('http')) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(\n `Workbox Router only supports URLs that start with 'http'.`);\n }\n return;\n }\n\n let {params, route} = this.findMatchingRoute({url, request, event});\n let handler = route && route.handler;\n\n let debugMessages = [];\n if (process.env.NODE_ENV !== 'production') {\n if (handler) {\n debugMessages.push([\n `Found a route to handle this request:`, route,\n ]);\n\n if (params) {\n debugMessages.push([\n `Passing the following params to the route's handler:`, params,\n ]);\n }\n }\n }\n\n // If we don't have a handler because there was no matching route, then\n // fall back to defaultHandler if that's defined.\n if (!handler && this._defaultHandler) {\n if (process.env.NODE_ENV !== 'production') {\n debugMessages.push(`Failed to find a matching route. Falling ` +\n `back to the default handler.`);\n\n // This is used for debugging in logs in the case of an error.\n route = '[Default Handler]';\n }\n handler = this._defaultHandler;\n }\n\n if (!handler) {\n if (process.env.NODE_ENV !== 'production') {\n // No handler so Workbox will do nothing. If logs is set of debug\n // i.e. verbose, we should print out this information.\n logger.debug(`No route found for: ${getFriendlyURL(url)}`);\n }\n return;\n }\n\n if (process.env.NODE_ENV !== 'production') {\n // We have a handler, meaning Workbox is going to handle the route.\n // print the routing details to the console.\n logger.groupCollapsed(`Router is responding to: ${getFriendlyURL(url)}`);\n debugMessages.forEach((msg) => {\n if (Array.isArray(msg)) {\n logger.log(...msg);\n } else {\n logger.log(msg);\n }\n });\n\n // The Request and Response objects contains a great deal of information,\n // hide it under a group in case developers want to see it.\n logger.groupCollapsed(`View request details here.`);\n logger.log(request);\n logger.groupEnd();\n\n logger.groupEnd();\n }\n\n // Wrap in try and catch in case the handle method throws a synchronous\n // error. It should still callback to the catch handler.\n let responsePromise;\n try {\n responsePromise = handler.handle({url, request, event, params});\n } catch (err) {\n responsePromise = Promise.reject(err);\n }\n\n if (responsePromise && this._catchHandler) {\n responsePromise = responsePromise.catch((err) => {\n if (process.env.NODE_ENV !== 'production') {\n // Still include URL here as it will be async from the console group\n // and may not make sense without the URL\n logger.groupCollapsed(`Error thrown when responding to: ` +\n ` ${getFriendlyURL(url)}. Falling back to Catch Handler.`);\n logger.error(`Error thrown by:`, route);\n logger.error(err);\n logger.groupEnd();\n }\n return this._catchHandler.handle({url, event, err});\n });\n }\n\n return responsePromise;\n }\n\n /**\n * Checks a request and URL (and optionally an event) against the list of\n * registered routes, and if there's a match, returns the corresponding\n * route along with any params generated by the match.\n *\n * @param {Object} options\n * @param {URL} options.url\n * @param {Request} options.request The request to match.\n * @param {FetchEvent} [options.event] The corresponding event (unless N/A).\n * @return {Object} An object with `route` and `params` properties.\n * They are populated if a matching route was found or `undefined`\n * otherwise.\n */\n findMatchingRoute({url, request, event}) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isInstance(url, URL, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.url',\n });\n assert.isInstance(request, Request, {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'findMatchingRoute',\n paramName: 'options.request',\n });\n }\n\n const routes = this._routes.get(request.method) || [];\n for (const route of routes) {\n let params;\n let matchResult = route.match({url, request, event});\n if (matchResult) {\n if (Array.isArray(matchResult) && matchResult.length > 0) {\n // Instead of passing an empty array in as params, use undefined.\n params = matchResult;\n } else if ((matchResult.constructor === Object &&\n Object.keys(matchResult).length > 0)) {\n // Instead of passing an empty object in as params, use undefined.\n params = matchResult;\n }\n\n // Return early if have a match.\n return {route, params};\n }\n }\n // If no match was found above, return and empty object.\n return {};\n }\n\n /**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setDefaultHandler(handler) {\n this._defaultHandler = normalizeHandler(handler);\n }\n\n /**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n */\n setCatchHandler(handler) {\n this._catchHandler = normalizeHandler(handler);\n }\n\n /**\n * Registers a route with the router.\n *\n * @param {workbox.routing.Route} route The route to register.\n */\n registerRoute(route) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(route, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route, 'match', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.isType(route.handler, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n\n assert.hasMethod(route.handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.handler',\n });\n\n assert.isType(route.method, 'string', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.method',\n });\n }\n\n if (!this._routes.has(route.method)) {\n this._routes.set(route.method, []);\n }\n\n // Give precedence to all of the earlier routes by adding this additional\n // route to the end of the array.\n this._routes.get(route.method).push(route);\n }\n\n /**\n * Unregisters a route with the router.\n *\n * @param {workbox.routing.Route} route The route to unregister.\n */\n unregisterRoute(route) {\n if (!this._routes.has(route.method)) {\n throw new WorkboxError(\n 'unregister-route-but-not-found-with-method', {\n method: route.method,\n }\n );\n }\n\n const routeIndex = this._routes.get(route.method).indexOf(route);\n if (routeIndex > -1) {\n this._routes.get(route.method).splice(routeIndex, 1);\n } else {\n throw new WorkboxError('unregister-route-route-not-registered');\n }\n }\n}\n\nexport {Router};\n","/*\n Copyright 2019 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 {Router} from '../Router.mjs';\nimport '../_version.mjs';\n\nlet defaultRouter;\n\n/**\n * Creates a new, singleton Router instance if one does not exist. If one\n * does already exist, that instance is returned.\n *\n * @private\n * @return {Router}\n */\nexport const getOrCreateDefaultRouter = () => {\n if (!defaultRouter) {\n defaultRouter = new Router();\n\n // The helpers that use the default Router assume these listeners exist.\n defaultRouter.addFetchListener();\n defaultRouter.addCacheListener();\n }\n return defaultRouter;\n};\n","/*\n Copyright 2019 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 {assert} from 'workbox-core/_private/assert.mjs';\nimport {cacheNames} from 'workbox-core/_private/cacheNames.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {NavigationRoute} from './NavigationRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Registers a route that will return a precached file for a navigation\n * request. This is useful for the\n * [application shell pattern]{@link https://developers.google.com/web/fundamentals/architecture/app-shell}.\n *\n * When determining the URL of the precached HTML document, you will likely need\n * to call `workbox.precaching.getCacheKeyForURL(originalUrl)`, to account for\n * the fact that Workbox's precaching naming conventions often results in URL\n * cache keys that contain extra revisioning info.\n *\n * This method will generate a\n * [NavigationRoute]{@link workbox.routing.NavigationRoute}\n * and call\n * [Router.registerRoute()]{@link workbox.routing.Router#registerRoute} on a\n * singleton Router instance.\n *\n * @param {string} cachedAssetUrl The cache key to use for the HTML file.\n * @param {Object} [options]\n * @param {string} [options.cacheName] Cache name to store and retrieve\n * requests. Defaults to precache cache name provided by\n * [workbox-core.cacheNames]{@link workbox.core.cacheNames}.\n * @param {Array<RegExp>} [options.blacklist=[]] If any of these patterns\n * match, the route will not handle the request (even if a whitelist entry\n * matches).\n * @param {Array<RegExp>} [options.whitelist=[/./]] If any of these patterns\n * match the URL's pathname and search parameter, the route will handle the\n * request (assuming the blacklist doesn't match).\n * @return {workbox.routing.NavigationRoute} Returns the generated\n * Route.\n *\n * @alias workbox.routing.registerNavigationRoute\n */\nexport const registerNavigationRoute = (cachedAssetUrl, options = {}) => {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(cachedAssetUrl, 'string', {\n moduleName: 'workbox-routing',\n funcName: 'registerNavigationRoute',\n paramName: 'cachedAssetUrl',\n });\n }\n\n const cacheName = cacheNames.getPrecacheName(options.cacheName);\n const handler = async () => {\n try {\n const response = await caches.match(cachedAssetUrl, {cacheName});\n\n if (response) {\n return response;\n }\n\n // This shouldn't normally happen, but there are edge cases:\n // https://github.com/GoogleChrome/workbox/issues/1441\n throw new Error(`The cache ${cacheName} did not have an entry for ` +\n `${cachedAssetUrl}.`);\n } catch (error) {\n // If there's either a cache miss, or the caches.match() call threw\n // an exception, then attempt to fulfill the navigation request with\n // a response from the network rather than leaving the user with a\n // failed navigation.\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Unable to respond to navigation request with ` +\n `cached response. Falling back to network.`, error);\n }\n\n // This might still fail if the browser is offline...\n return fetch(cachedAssetUrl);\n }\n };\n\n const route = new NavigationRoute(handler, {\n whitelist: options.whitelist,\n blacklist: options.blacklist,\n });\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 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 {logger} from 'workbox-core/_private/logger.mjs';\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {Route} from './Route.mjs';\nimport {RegExpRoute} from './RegExpRoute.mjs';\nimport {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\nimport './_version.mjs';\n\n\n/**\n * Easily register a RegExp, string, or function with a caching\n * strategy to a singleton Router instance.\n *\n * This method will generate a Route for you if needed and\n * call [Router.registerRoute()]{@link\n * workbox.routing.Router#registerRoute}.\n *\n * @param {\n * RegExp|\n * string|\n * workbox.routing.Route~matchCallback|\n * workbox.routing.Route\n * } capture\n * If the capture param is a `Route`, all other arguments will be ignored.\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n * @param {string} [method='GET'] The HTTP method to match the Route\n * against.\n * @return {workbox.routing.Route} The generated `Route`(Useful for\n * unregistering).\n *\n * @alias workbox.routing.registerRoute\n */\nexport const registerRoute = (capture, handler, method = 'GET') => {\n let route;\n\n if (typeof capture === 'string') {\n const captureUrl = new URL(capture, location);\n\n if (process.env.NODE_ENV !== 'production') {\n if (!(capture.startsWith('/') || capture.startsWith('http'))) {\n throw new WorkboxError('invalid-string', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n // We want to check if Express-style wildcards are in the pathname only.\n // TODO: Remove this log message in v4.\n const valueToCheck = capture.startsWith('http') ?\n captureUrl.pathname : capture;\n\n // See https://github.com/pillarjs/path-to-regexp#parameters\n const wildcards = '[*:?+]';\n if (valueToCheck.match(new RegExp(`${wildcards}`))) {\n logger.debug(\n `The '$capture' parameter contains an Express-style wildcard ` +\n `character (${wildcards}). Strings are now always interpreted as ` +\n `exact matches; use a RegExp for partial or wildcard matches.`\n );\n }\n }\n\n const matchCallback = ({url}) => {\n if (process.env.NODE_ENV !== 'production') {\n if ((url.pathname === captureUrl.pathname) &&\n (url.origin !== captureUrl.origin)) {\n logger.debug(\n `${capture} only partially matches the cross-origin URL ` +\n `${url}. This route will only handle cross-origin requests ` +\n `if they match the entire URL.`);\n }\n }\n\n return url.href === captureUrl.href;\n };\n\n route = new Route(matchCallback, handler, method);\n } else if (capture instanceof RegExp) {\n route = new RegExpRoute(capture, handler, method);\n } else if (typeof capture === 'function') {\n route = new Route(capture, handler, method);\n } else if (capture instanceof Route) {\n route = capture;\n } else {\n throw new WorkboxError('unsupported-route-type', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\n\n return route;\n};\n","/*\n Copyright 2019 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 {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * If a Route throws an error while handling a request, this `handler`\n * will be called and given a chance to provide a response.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setCatchHandler\n */\nexport const setCatchHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setCatchHandler(handler);\n};\n","/*\n Copyright 2019 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 {getOrCreateDefaultRouter} from './utils/getOrCreateDefaultRouter.mjs';\n\nimport './_version.mjs';\n\n/**\n * Define a default `handler` that's called when no routes explicitly\n * match the incoming request.\n *\n * Without a default handler, unmatched requests will go against the\n * network as if there were no service worker present.\n *\n * @param {workbox.routing.Route~handlerCallback} handler A callback\n * function that returns a Promise resulting in a Response.\n *\n * @alias workbox.routing.setDefaultHandler\n */\nexport const setDefaultHandler = (handler) => {\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.setDefaultHandler(handler);\n};\n"],"names":["self","_","e","defaultMethod","normalizeHandler","handler","handle","Route","constructor","match","method","NavigationRoute","whitelist","blacklist","options","this","_match","_whitelist","_blacklist","url","request","mode","pathnameAndSearch","pathname","search","regExp","test","some","RegExpRoute","result","exec","href","origin","location","index","slice","Router","_routes","Map","addFetchListener","addEventListener","event","responsePromise","handleRequest","respondWith","addCacheListener","async","data","type","payload","requestPromises","Promise","all","urlsToCache","map","entry","Request","waitUntil","ports","postMessage","URL","protocol","startsWith","params","route","findMatchingRoute","_defaultHandler","err","reject","_catchHandler","catch","routes","get","matchResult","Array","isArray","length","Object","keys","setDefaultHandler","setCatchHandler","registerRoute","has","set","push","unregisterRoute","WorkboxError","routeIndex","indexOf","splice","defaultRouter","getOrCreateDefaultRouter","cachedAssetUrl","cacheName","cacheNames","getPrecacheName","response","caches","Error","error","fetch","capture","captureUrl","RegExp","moduleName","funcName","paramName"],"mappings":"gFAAA,IAAIA,KAAK,0BAA0BC,IAAI,MAAMC,ICkBtC,MAAMC,EAAgB,MCAhBC,EAAoBC,GAC3BA,GAA8B,iBAAZA,EASbA,EAUA,CAACC,OAAQD,GCfpB,MAAME,EAYJC,YAAYC,EAAOJ,EAASK,QAgBrBL,QAAUD,EAAiBC,QAC3BI,MAAQA,OACRC,OAASA,GAAUP,GCzB5B,MAAMQ,UAAwBJ,EAoB5BC,YAAYH,GAASO,UAACA,EAAY,CAAC,KAAdC,UAAoBA,EAAY,IAAM,UAgBlDC,GAAYC,KAAKC,EAAOF,GAAUT,QAEpCY,EAAaL,OACbM,EAAaL,EAapBG,GAAOG,IAACA,EAADC,QAAMA,OACU,aAAjBA,EAAQC,YACH,QAGHC,EAAoBH,EAAII,SAAWJ,EAAIK,WAExC,MAAMC,KAAUV,KAAKG,KACpBO,EAAOC,KAAKJ,UAKP,UAIPP,KAAKE,EAAWU,KAAMF,GAAWA,EAAOC,KAAKJ,KCvErD,MAAMM,UAAoBrB,EAcxBC,YAAYiB,EAAQpB,EAASK,SAUb,EAAES,IAAAA,YACRU,EAASJ,EAAOK,KAAKX,EAAIY,aAG1BF,EAQAV,EAAIa,SAAWC,SAASD,QAA6B,IAAjBH,EAAOK,MASvC,KAOFL,EAAOM,MAAM,GAvBX,MA0BE9B,EAASK,IChD1B,MAAM0B,EAIJ5B,mBACO6B,EAAU,IAAIC,wBASZvB,KAAKsB,EAOdE,mBACEvC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qC,EAAShG,EAASK,EAAS,aACnDsD,KAEmB,iBAAZqC,EAAsB,OACzBC,EAAa,IAAI1C,IAAIyC,EAASpE,UAyCpC+B,EAAQ,IAAIzD,EAdU,EAAEY,IAAAA,KAWfA,EAAIY,OAASuE,EAAWvE,KAGA1B,EAASK,QACrC,GAAI2F,aAAmBE,OAC5BvC,EAAQ,IAAIpC,EAAYyE,EAAShG,EAASK,QACrC,GAAuB,mBAAZ2F,EAChBrC,EAAQ,IAAIzD,EAAM8F,EAAShG,EAASK,OAC/B,CAAA,KAAI2F,aAAmB9F,SAGtB,IAAI+E,eAAa,yBAA0B,CAC/CkB,WAAY,kBACZC,SAAU,gBACVC,UAAW,YALb1C,EAAQqC,SASYV,IACRV,cAAcjB,GAErBA,2CClFuB3D,CAAAA,IACRsF,IACRX,gBAAgB3E,yBCCEA,CAAAA,IACVsF,IACRZ,kBAAkB1E"}
|
@@ -1,1138 +0,0 @@
|
|
1
|
-
this.workbox = this.workbox || {};
|
2
|
-
this.workbox.strategies = (function (exports, logger_mjs, assert_mjs, cacheNames_mjs, cacheWrapper_mjs, fetchWrapper_mjs, getFriendlyURL_mjs, WorkboxError_mjs) {
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
try {
|
6
|
-
self['workbox:strategies:4.3.1'] && _();
|
7
|
-
} catch (e) {} // eslint-disable-line
|
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
|
-
const getFriendlyURL = url => {
|
18
|
-
const urlObj = new URL(url, location);
|
19
|
-
|
20
|
-
if (urlObj.origin === location.origin) {
|
21
|
-
return urlObj.pathname;
|
22
|
-
}
|
23
|
-
|
24
|
-
return urlObj.href;
|
25
|
-
};
|
26
|
-
|
27
|
-
const messages = {
|
28
|
-
strategyStart: (strategyName, request) => `Using ${strategyName} to ` + `respond to '${getFriendlyURL(request.url)}'`,
|
29
|
-
printFinalResponse: response => {
|
30
|
-
if (response) {
|
31
|
-
logger_mjs.logger.groupCollapsed(`View the final response here.`);
|
32
|
-
logger_mjs.logger.log(response);
|
33
|
-
logger_mjs.logger.groupEnd();
|
34
|
-
}
|
35
|
-
}
|
36
|
-
};
|
37
|
-
|
38
|
-
/*
|
39
|
-
Copyright 2018 Google LLC
|
40
|
-
|
41
|
-
Use of this source code is governed by an MIT-style
|
42
|
-
license that can be found in the LICENSE file or at
|
43
|
-
https://opensource.org/licenses/MIT.
|
44
|
-
*/
|
45
|
-
/**
|
46
|
-
* An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network}
|
47
|
-
* request strategy.
|
48
|
-
*
|
49
|
-
* A cache first strategy is useful for assets that have been revisioned,
|
50
|
-
* such as URLs like `/styles/example.a8f5f1.css`, since they
|
51
|
-
* can be cached for long periods of time.
|
52
|
-
*
|
53
|
-
* If the network request fails, and there is no cache match, this will throw
|
54
|
-
* a `WorkboxError` exception.
|
55
|
-
*
|
56
|
-
* @memberof workbox.strategies
|
57
|
-
*/
|
58
|
-
|
59
|
-
class CacheFirst {
|
60
|
-
/**
|
61
|
-
* @param {Object} options
|
62
|
-
* @param {string} options.cacheName Cache name to store and retrieve
|
63
|
-
* requests. Defaults to cache names provided by
|
64
|
-
* [workbox-core]{@link workbox.core.cacheNames}.
|
65
|
-
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
66
|
-
* to use in conjunction with this caching strategy.
|
67
|
-
* @param {Object} options.fetchOptions Values passed along to the
|
68
|
-
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
69
|
-
* of all fetch() requests made by this strategy.
|
70
|
-
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
71
|
-
*/
|
72
|
-
constructor(options = {}) {
|
73
|
-
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
|
74
|
-
this._plugins = options.plugins || [];
|
75
|
-
this._fetchOptions = options.fetchOptions || null;
|
76
|
-
this._matchOptions = options.matchOptions || null;
|
77
|
-
}
|
78
|
-
/**
|
79
|
-
* This method will perform a request strategy and follows an API that
|
80
|
-
* will work with the
|
81
|
-
* [Workbox Router]{@link workbox.routing.Router}.
|
82
|
-
*
|
83
|
-
* @param {Object} options
|
84
|
-
* @param {Request} options.request The request to run this strategy for.
|
85
|
-
* @param {Event} [options.event] The event that triggered the request.
|
86
|
-
* @return {Promise<Response>}
|
87
|
-
*/
|
88
|
-
|
89
|
-
|
90
|
-
async handle({
|
91
|
-
event,
|
92
|
-
request
|
93
|
-
}) {
|
94
|
-
return this.makeRequest({
|
95
|
-
event,
|
96
|
-
request: request || event.request
|
97
|
-
});
|
98
|
-
}
|
99
|
-
/**
|
100
|
-
* This method can be used to perform a make a standalone request outside the
|
101
|
-
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
102
|
-
*
|
103
|
-
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
104
|
-
* for more usage information.
|
105
|
-
*
|
106
|
-
* @param {Object} options
|
107
|
-
* @param {Request|string} options.request Either a
|
108
|
-
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
109
|
-
* object, or a string URL, corresponding to the request to be made.
|
110
|
-
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
111
|
-
be called automatically to extend the service worker's lifetime.
|
112
|
-
* @return {Promise<Response>}
|
113
|
-
*/
|
114
|
-
|
115
|
-
|
116
|
-
async makeRequest({
|
117
|
-
event,
|
118
|
-
request
|
119
|
-
}) {
|
120
|
-
const logs = [];
|
121
|
-
|
122
|
-
if (typeof request === 'string') {
|
123
|
-
request = new Request(request);
|
124
|
-
}
|
125
|
-
|
126
|
-
{
|
127
|
-
assert_mjs.assert.isInstance(request, Request, {
|
128
|
-
moduleName: 'workbox-strategies',
|
129
|
-
className: 'CacheFirst',
|
130
|
-
funcName: 'makeRequest',
|
131
|
-
paramName: 'request'
|
132
|
-
});
|
133
|
-
}
|
134
|
-
|
135
|
-
let response = await cacheWrapper_mjs.cacheWrapper.match({
|
136
|
-
cacheName: this._cacheName,
|
137
|
-
request,
|
138
|
-
event,
|
139
|
-
matchOptions: this._matchOptions,
|
140
|
-
plugins: this._plugins
|
141
|
-
});
|
142
|
-
let error;
|
143
|
-
|
144
|
-
if (!response) {
|
145
|
-
{
|
146
|
-
logs.push(`No response found in the '${this._cacheName}' cache. ` + `Will respond with a network request.`);
|
147
|
-
}
|
148
|
-
|
149
|
-
try {
|
150
|
-
response = await this._getFromNetwork(request, event);
|
151
|
-
} catch (err) {
|
152
|
-
error = err;
|
153
|
-
}
|
154
|
-
|
155
|
-
{
|
156
|
-
if (response) {
|
157
|
-
logs.push(`Got response from network.`);
|
158
|
-
} else {
|
159
|
-
logs.push(`Unable to get a response from the network.`);
|
160
|
-
}
|
161
|
-
}
|
162
|
-
} else {
|
163
|
-
{
|
164
|
-
logs.push(`Found a cached response in the '${this._cacheName}' cache.`);
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
{
|
169
|
-
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheFirst', request));
|
170
|
-
|
171
|
-
for (let log of logs) {
|
172
|
-
logger_mjs.logger.log(log);
|
173
|
-
}
|
174
|
-
|
175
|
-
messages.printFinalResponse(response);
|
176
|
-
logger_mjs.logger.groupEnd();
|
177
|
-
}
|
178
|
-
|
179
|
-
if (!response) {
|
180
|
-
throw new WorkboxError_mjs.WorkboxError('no-response', {
|
181
|
-
url: request.url,
|
182
|
-
error
|
183
|
-
});
|
184
|
-
}
|
185
|
-
|
186
|
-
return response;
|
187
|
-
}
|
188
|
-
/**
|
189
|
-
* Handles the network and cache part of CacheFirst.
|
190
|
-
*
|
191
|
-
* @param {Request} request
|
192
|
-
* @param {FetchEvent} [event]
|
193
|
-
* @return {Promise<Response>}
|
194
|
-
*
|
195
|
-
* @private
|
196
|
-
*/
|
197
|
-
|
198
|
-
|
199
|
-
async _getFromNetwork(request, event) {
|
200
|
-
const response = await fetchWrapper_mjs.fetchWrapper.fetch({
|
201
|
-
request,
|
202
|
-
event,
|
203
|
-
fetchOptions: this._fetchOptions,
|
204
|
-
plugins: this._plugins
|
205
|
-
}); // Keep the service worker while we put the request to the cache
|
206
|
-
|
207
|
-
const responseClone = response.clone();
|
208
|
-
const cachePutPromise = cacheWrapper_mjs.cacheWrapper.put({
|
209
|
-
cacheName: this._cacheName,
|
210
|
-
request,
|
211
|
-
response: responseClone,
|
212
|
-
event,
|
213
|
-
plugins: this._plugins
|
214
|
-
});
|
215
|
-
|
216
|
-
if (event) {
|
217
|
-
try {
|
218
|
-
event.waitUntil(cachePutPromise);
|
219
|
-
} catch (error) {
|
220
|
-
{
|
221
|
-
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
|
222
|
-
}
|
223
|
-
}
|
224
|
-
}
|
225
|
-
|
226
|
-
return response;
|
227
|
-
}
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
/*
|
232
|
-
Copyright 2018 Google LLC
|
233
|
-
|
234
|
-
Use of this source code is governed by an MIT-style
|
235
|
-
license that can be found in the LICENSE file or at
|
236
|
-
https://opensource.org/licenses/MIT.
|
237
|
-
*/
|
238
|
-
/**
|
239
|
-
* An implementation of a
|
240
|
-
* [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only}
|
241
|
-
* request strategy.
|
242
|
-
*
|
243
|
-
* This class is useful if you want to take advantage of any
|
244
|
-
* [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
|
245
|
-
*
|
246
|
-
* If there is no cache match, this will throw a `WorkboxError` exception.
|
247
|
-
*
|
248
|
-
* @memberof workbox.strategies
|
249
|
-
*/
|
250
|
-
|
251
|
-
class CacheOnly {
|
252
|
-
/**
|
253
|
-
* @param {Object} options
|
254
|
-
* @param {string} options.cacheName Cache name to store and retrieve
|
255
|
-
* requests. Defaults to cache names provided by
|
256
|
-
* [workbox-core]{@link workbox.core.cacheNames}.
|
257
|
-
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
258
|
-
* to use in conjunction with this caching strategy.
|
259
|
-
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
260
|
-
*/
|
261
|
-
constructor(options = {}) {
|
262
|
-
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
|
263
|
-
this._plugins = options.plugins || [];
|
264
|
-
this._matchOptions = options.matchOptions || null;
|
265
|
-
}
|
266
|
-
/**
|
267
|
-
* This method will perform a request strategy and follows an API that
|
268
|
-
* will work with the
|
269
|
-
* [Workbox Router]{@link workbox.routing.Router}.
|
270
|
-
*
|
271
|
-
* @param {Object} options
|
272
|
-
* @param {Request} options.request The request to run this strategy for.
|
273
|
-
* @param {Event} [options.event] The event that triggered the request.
|
274
|
-
* @return {Promise<Response>}
|
275
|
-
*/
|
276
|
-
|
277
|
-
|
278
|
-
async handle({
|
279
|
-
event,
|
280
|
-
request
|
281
|
-
}) {
|
282
|
-
return this.makeRequest({
|
283
|
-
event,
|
284
|
-
request: request || event.request
|
285
|
-
});
|
286
|
-
}
|
287
|
-
/**
|
288
|
-
* This method can be used to perform a make a standalone request outside the
|
289
|
-
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
290
|
-
*
|
291
|
-
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
292
|
-
* for more usage information.
|
293
|
-
*
|
294
|
-
* @param {Object} options
|
295
|
-
* @param {Request|string} options.request Either a
|
296
|
-
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
297
|
-
* object, or a string URL, corresponding to the request to be made.
|
298
|
-
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
299
|
-
* be called automatically to extend the service worker's lifetime.
|
300
|
-
* @return {Promise<Response>}
|
301
|
-
*/
|
302
|
-
|
303
|
-
|
304
|
-
async makeRequest({
|
305
|
-
event,
|
306
|
-
request
|
307
|
-
}) {
|
308
|
-
if (typeof request === 'string') {
|
309
|
-
request = new Request(request);
|
310
|
-
}
|
311
|
-
|
312
|
-
{
|
313
|
-
assert_mjs.assert.isInstance(request, Request, {
|
314
|
-
moduleName: 'workbox-strategies',
|
315
|
-
className: 'CacheOnly',
|
316
|
-
funcName: 'makeRequest',
|
317
|
-
paramName: 'request'
|
318
|
-
});
|
319
|
-
}
|
320
|
-
|
321
|
-
const response = await cacheWrapper_mjs.cacheWrapper.match({
|
322
|
-
cacheName: this._cacheName,
|
323
|
-
request,
|
324
|
-
event,
|
325
|
-
matchOptions: this._matchOptions,
|
326
|
-
plugins: this._plugins
|
327
|
-
});
|
328
|
-
|
329
|
-
{
|
330
|
-
logger_mjs.logger.groupCollapsed(messages.strategyStart('CacheOnly', request));
|
331
|
-
|
332
|
-
if (response) {
|
333
|
-
logger_mjs.logger.log(`Found a cached response in the '${this._cacheName}'` + ` cache.`);
|
334
|
-
messages.printFinalResponse(response);
|
335
|
-
} else {
|
336
|
-
logger_mjs.logger.log(`No response found in the '${this._cacheName}' cache.`);
|
337
|
-
}
|
338
|
-
|
339
|
-
logger_mjs.logger.groupEnd();
|
340
|
-
}
|
341
|
-
|
342
|
-
if (!response) {
|
343
|
-
throw new WorkboxError_mjs.WorkboxError('no-response', {
|
344
|
-
url: request.url
|
345
|
-
});
|
346
|
-
}
|
347
|
-
|
348
|
-
return response;
|
349
|
-
}
|
350
|
-
|
351
|
-
}
|
352
|
-
|
353
|
-
/*
|
354
|
-
Copyright 2018 Google LLC
|
355
|
-
|
356
|
-
Use of this source code is governed by an MIT-style
|
357
|
-
license that can be found in the LICENSE file or at
|
358
|
-
https://opensource.org/licenses/MIT.
|
359
|
-
*/
|
360
|
-
const cacheOkAndOpaquePlugin = {
|
361
|
-
/**
|
362
|
-
* Returns a valid response (to allow caching) if the status is 200 (OK) or
|
363
|
-
* 0 (opaque).
|
364
|
-
*
|
365
|
-
* @param {Object} options
|
366
|
-
* @param {Response} options.response
|
367
|
-
* @return {Response|null}
|
368
|
-
*
|
369
|
-
* @private
|
370
|
-
*/
|
371
|
-
cacheWillUpdate: ({
|
372
|
-
response
|
373
|
-
}) => {
|
374
|
-
if (response.status === 200 || response.status === 0) {
|
375
|
-
return response;
|
376
|
-
}
|
377
|
-
|
378
|
-
return null;
|
379
|
-
}
|
380
|
-
};
|
381
|
-
|
382
|
-
/*
|
383
|
-
Copyright 2018 Google LLC
|
384
|
-
|
385
|
-
Use of this source code is governed by an MIT-style
|
386
|
-
license that can be found in the LICENSE file or at
|
387
|
-
https://opensource.org/licenses/MIT.
|
388
|
-
*/
|
389
|
-
/**
|
390
|
-
* An implementation of a
|
391
|
-
* [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache}
|
392
|
-
* request strategy.
|
393
|
-
*
|
394
|
-
* By default, this strategy will cache responses with a 200 status code as
|
395
|
-
* well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.
|
396
|
-
* Opaque responses are are cross-origin requests where the response doesn't
|
397
|
-
* support [CORS]{@link https://enable-cors.org/}.
|
398
|
-
*
|
399
|
-
* If the network request fails, and there is no cache match, this will throw
|
400
|
-
* a `WorkboxError` exception.
|
401
|
-
*
|
402
|
-
* @memberof workbox.strategies
|
403
|
-
*/
|
404
|
-
|
405
|
-
class NetworkFirst {
|
406
|
-
/**
|
407
|
-
* @param {Object} options
|
408
|
-
* @param {string} options.cacheName Cache name to store and retrieve
|
409
|
-
* requests. Defaults to cache names provided by
|
410
|
-
* [workbox-core]{@link workbox.core.cacheNames}.
|
411
|
-
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
412
|
-
* to use in conjunction with this caching strategy.
|
413
|
-
* @param {Object} options.fetchOptions Values passed along to the
|
414
|
-
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
415
|
-
* of all fetch() requests made by this strategy.
|
416
|
-
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
417
|
-
* @param {number} options.networkTimeoutSeconds If set, any network requests
|
418
|
-
* that fail to respond within the timeout will fallback to the cache.
|
419
|
-
*
|
420
|
-
* This option can be used to combat
|
421
|
-
* "[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}"
|
422
|
-
* scenarios.
|
423
|
-
*/
|
424
|
-
constructor(options = {}) {
|
425
|
-
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
|
426
|
-
|
427
|
-
if (options.plugins) {
|
428
|
-
let isUsingCacheWillUpdate = options.plugins.some(plugin => !!plugin.cacheWillUpdate);
|
429
|
-
this._plugins = isUsingCacheWillUpdate ? options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];
|
430
|
-
} else {
|
431
|
-
// No plugins passed in, use the default plugin.
|
432
|
-
this._plugins = [cacheOkAndOpaquePlugin];
|
433
|
-
}
|
434
|
-
|
435
|
-
this._networkTimeoutSeconds = options.networkTimeoutSeconds;
|
436
|
-
|
437
|
-
{
|
438
|
-
if (this._networkTimeoutSeconds) {
|
439
|
-
assert_mjs.assert.isType(this._networkTimeoutSeconds, 'number', {
|
440
|
-
moduleName: 'workbox-strategies',
|
441
|
-
className: 'NetworkFirst',
|
442
|
-
funcName: 'constructor',
|
443
|
-
paramName: 'networkTimeoutSeconds'
|
444
|
-
});
|
445
|
-
}
|
446
|
-
}
|
447
|
-
|
448
|
-
this._fetchOptions = options.fetchOptions || null;
|
449
|
-
this._matchOptions = options.matchOptions || null;
|
450
|
-
}
|
451
|
-
/**
|
452
|
-
* This method will perform a request strategy and follows an API that
|
453
|
-
* will work with the
|
454
|
-
* [Workbox Router]{@link workbox.routing.Router}.
|
455
|
-
*
|
456
|
-
* @param {Object} options
|
457
|
-
* @param {Request} options.request The request to run this strategy for.
|
458
|
-
* @param {Event} [options.event] The event that triggered the request.
|
459
|
-
* @return {Promise<Response>}
|
460
|
-
*/
|
461
|
-
|
462
|
-
|
463
|
-
async handle({
|
464
|
-
event,
|
465
|
-
request
|
466
|
-
}) {
|
467
|
-
return this.makeRequest({
|
468
|
-
event,
|
469
|
-
request: request || event.request
|
470
|
-
});
|
471
|
-
}
|
472
|
-
/**
|
473
|
-
* This method can be used to perform a make a standalone request outside the
|
474
|
-
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
475
|
-
*
|
476
|
-
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
477
|
-
* for more usage information.
|
478
|
-
*
|
479
|
-
* @param {Object} options
|
480
|
-
* @param {Request|string} options.request Either a
|
481
|
-
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
482
|
-
* object, or a string URL, corresponding to the request to be made.
|
483
|
-
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
484
|
-
* be called automatically to extend the service worker's lifetime.
|
485
|
-
* @return {Promise<Response>}
|
486
|
-
*/
|
487
|
-
|
488
|
-
|
489
|
-
async makeRequest({
|
490
|
-
event,
|
491
|
-
request
|
492
|
-
}) {
|
493
|
-
const logs = [];
|
494
|
-
|
495
|
-
if (typeof request === 'string') {
|
496
|
-
request = new Request(request);
|
497
|
-
}
|
498
|
-
|
499
|
-
{
|
500
|
-
assert_mjs.assert.isInstance(request, Request, {
|
501
|
-
moduleName: 'workbox-strategies',
|
502
|
-
className: 'NetworkFirst',
|
503
|
-
funcName: 'handle',
|
504
|
-
paramName: 'makeRequest'
|
505
|
-
});
|
506
|
-
}
|
507
|
-
|
508
|
-
const promises = [];
|
509
|
-
let timeoutId;
|
510
|
-
|
511
|
-
if (this._networkTimeoutSeconds) {
|
512
|
-
const {
|
513
|
-
id,
|
514
|
-
promise
|
515
|
-
} = this._getTimeoutPromise({
|
516
|
-
request,
|
517
|
-
event,
|
518
|
-
logs
|
519
|
-
});
|
520
|
-
|
521
|
-
timeoutId = id;
|
522
|
-
promises.push(promise);
|
523
|
-
}
|
524
|
-
|
525
|
-
const networkPromise = this._getNetworkPromise({
|
526
|
-
timeoutId,
|
527
|
-
request,
|
528
|
-
event,
|
529
|
-
logs
|
530
|
-
});
|
531
|
-
|
532
|
-
promises.push(networkPromise); // Promise.race() will resolve as soon as the first promise resolves.
|
533
|
-
|
534
|
-
let response = await Promise.race(promises); // If Promise.race() resolved with null, it might be due to a network
|
535
|
-
// timeout + a cache miss. If that were to happen, we'd rather wait until
|
536
|
-
// the networkPromise resolves instead of returning null.
|
537
|
-
// Note that it's fine to await an already-resolved promise, so we don't
|
538
|
-
// have to check to see if it's still "in flight".
|
539
|
-
|
540
|
-
if (!response) {
|
541
|
-
response = await networkPromise;
|
542
|
-
}
|
543
|
-
|
544
|
-
{
|
545
|
-
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkFirst', request));
|
546
|
-
|
547
|
-
for (let log of logs) {
|
548
|
-
logger_mjs.logger.log(log);
|
549
|
-
}
|
550
|
-
|
551
|
-
messages.printFinalResponse(response);
|
552
|
-
logger_mjs.logger.groupEnd();
|
553
|
-
}
|
554
|
-
|
555
|
-
if (!response) {
|
556
|
-
throw new WorkboxError_mjs.WorkboxError('no-response', {
|
557
|
-
url: request.url
|
558
|
-
});
|
559
|
-
}
|
560
|
-
|
561
|
-
return response;
|
562
|
-
}
|
563
|
-
/**
|
564
|
-
* @param {Object} options
|
565
|
-
* @param {Request} options.request
|
566
|
-
* @param {Array} options.logs A reference to the logs array
|
567
|
-
* @param {Event} [options.event]
|
568
|
-
* @return {Promise<Response>}
|
569
|
-
*
|
570
|
-
* @private
|
571
|
-
*/
|
572
|
-
|
573
|
-
|
574
|
-
_getTimeoutPromise({
|
575
|
-
request,
|
576
|
-
logs,
|
577
|
-
event
|
578
|
-
}) {
|
579
|
-
let timeoutId;
|
580
|
-
const timeoutPromise = new Promise(resolve => {
|
581
|
-
const onNetworkTimeout = async () => {
|
582
|
-
{
|
583
|
-
logs.push(`Timing out the network response at ` + `${this._networkTimeoutSeconds} seconds.`);
|
584
|
-
}
|
585
|
-
|
586
|
-
resolve((await this._respondFromCache({
|
587
|
-
request,
|
588
|
-
event
|
589
|
-
})));
|
590
|
-
};
|
591
|
-
|
592
|
-
timeoutId = setTimeout(onNetworkTimeout, this._networkTimeoutSeconds * 1000);
|
593
|
-
});
|
594
|
-
return {
|
595
|
-
promise: timeoutPromise,
|
596
|
-
id: timeoutId
|
597
|
-
};
|
598
|
-
}
|
599
|
-
/**
|
600
|
-
* @param {Object} options
|
601
|
-
* @param {number|undefined} options.timeoutId
|
602
|
-
* @param {Request} options.request
|
603
|
-
* @param {Array} options.logs A reference to the logs Array.
|
604
|
-
* @param {Event} [options.event]
|
605
|
-
* @return {Promise<Response>}
|
606
|
-
*
|
607
|
-
* @private
|
608
|
-
*/
|
609
|
-
|
610
|
-
|
611
|
-
async _getNetworkPromise({
|
612
|
-
timeoutId,
|
613
|
-
request,
|
614
|
-
logs,
|
615
|
-
event
|
616
|
-
}) {
|
617
|
-
let error;
|
618
|
-
let response;
|
619
|
-
|
620
|
-
try {
|
621
|
-
response = await fetchWrapper_mjs.fetchWrapper.fetch({
|
622
|
-
request,
|
623
|
-
event,
|
624
|
-
fetchOptions: this._fetchOptions,
|
625
|
-
plugins: this._plugins
|
626
|
-
});
|
627
|
-
} catch (err) {
|
628
|
-
error = err;
|
629
|
-
}
|
630
|
-
|
631
|
-
if (timeoutId) {
|
632
|
-
clearTimeout(timeoutId);
|
633
|
-
}
|
634
|
-
|
635
|
-
{
|
636
|
-
if (response) {
|
637
|
-
logs.push(`Got response from network.`);
|
638
|
-
} else {
|
639
|
-
logs.push(`Unable to get a response from the network. Will respond ` + `with a cached response.`);
|
640
|
-
}
|
641
|
-
}
|
642
|
-
|
643
|
-
if (error || !response) {
|
644
|
-
response = await this._respondFromCache({
|
645
|
-
request,
|
646
|
-
event
|
647
|
-
});
|
648
|
-
|
649
|
-
{
|
650
|
-
if (response) {
|
651
|
-
logs.push(`Found a cached response in the '${this._cacheName}'` + ` cache.`);
|
652
|
-
} else {
|
653
|
-
logs.push(`No response found in the '${this._cacheName}' cache.`);
|
654
|
-
}
|
655
|
-
}
|
656
|
-
} else {
|
657
|
-
// Keep the service worker alive while we put the request in the cache
|
658
|
-
const responseClone = response.clone();
|
659
|
-
const cachePut = cacheWrapper_mjs.cacheWrapper.put({
|
660
|
-
cacheName: this._cacheName,
|
661
|
-
request,
|
662
|
-
response: responseClone,
|
663
|
-
event,
|
664
|
-
plugins: this._plugins
|
665
|
-
});
|
666
|
-
|
667
|
-
if (event) {
|
668
|
-
try {
|
669
|
-
// The event has been responded to so we can keep the SW alive to
|
670
|
-
// respond to the request
|
671
|
-
event.waitUntil(cachePut);
|
672
|
-
} catch (err) {
|
673
|
-
{
|
674
|
-
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
|
675
|
-
}
|
676
|
-
}
|
677
|
-
}
|
678
|
-
}
|
679
|
-
|
680
|
-
return response;
|
681
|
-
}
|
682
|
-
/**
|
683
|
-
* Used if the network timeouts or fails to make the request.
|
684
|
-
*
|
685
|
-
* @param {Object} options
|
686
|
-
* @param {Request} request The request to match in the cache
|
687
|
-
* @param {Event} [options.event]
|
688
|
-
* @return {Promise<Object>}
|
689
|
-
*
|
690
|
-
* @private
|
691
|
-
*/
|
692
|
-
|
693
|
-
|
694
|
-
_respondFromCache({
|
695
|
-
event,
|
696
|
-
request
|
697
|
-
}) {
|
698
|
-
return cacheWrapper_mjs.cacheWrapper.match({
|
699
|
-
cacheName: this._cacheName,
|
700
|
-
request,
|
701
|
-
event,
|
702
|
-
matchOptions: this._matchOptions,
|
703
|
-
plugins: this._plugins
|
704
|
-
});
|
705
|
-
}
|
706
|
-
|
707
|
-
}
|
708
|
-
|
709
|
-
/*
|
710
|
-
Copyright 2018 Google LLC
|
711
|
-
|
712
|
-
Use of this source code is governed by an MIT-style
|
713
|
-
license that can be found in the LICENSE file or at
|
714
|
-
https://opensource.org/licenses/MIT.
|
715
|
-
*/
|
716
|
-
/**
|
717
|
-
* An implementation of a
|
718
|
-
* [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only}
|
719
|
-
* request strategy.
|
720
|
-
*
|
721
|
-
* This class is useful if you want to take advantage of any
|
722
|
-
* [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
|
723
|
-
*
|
724
|
-
* If the network request fails, this will throw a `WorkboxError` exception.
|
725
|
-
*
|
726
|
-
* @memberof workbox.strategies
|
727
|
-
*/
|
728
|
-
|
729
|
-
class NetworkOnly {
|
730
|
-
/**
|
731
|
-
* @param {Object} options
|
732
|
-
* @param {string} options.cacheName Cache name to store and retrieve
|
733
|
-
* requests. Defaults to cache names provided by
|
734
|
-
* [workbox-core]{@link workbox.core.cacheNames}.
|
735
|
-
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
736
|
-
* to use in conjunction with this caching strategy.
|
737
|
-
* @param {Object} options.fetchOptions Values passed along to the
|
738
|
-
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
739
|
-
* of all fetch() requests made by this strategy.
|
740
|
-
*/
|
741
|
-
constructor(options = {}) {
|
742
|
-
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
|
743
|
-
this._plugins = options.plugins || [];
|
744
|
-
this._fetchOptions = options.fetchOptions || null;
|
745
|
-
}
|
746
|
-
/**
|
747
|
-
* This method will perform a request strategy and follows an API that
|
748
|
-
* will work with the
|
749
|
-
* [Workbox Router]{@link workbox.routing.Router}.
|
750
|
-
*
|
751
|
-
* @param {Object} options
|
752
|
-
* @param {Request} options.request The request to run this strategy for.
|
753
|
-
* @param {Event} [options.event] The event that triggered the request.
|
754
|
-
* @return {Promise<Response>}
|
755
|
-
*/
|
756
|
-
|
757
|
-
|
758
|
-
async handle({
|
759
|
-
event,
|
760
|
-
request
|
761
|
-
}) {
|
762
|
-
return this.makeRequest({
|
763
|
-
event,
|
764
|
-
request: request || event.request
|
765
|
-
});
|
766
|
-
}
|
767
|
-
/**
|
768
|
-
* This method can be used to perform a make a standalone request outside the
|
769
|
-
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
770
|
-
*
|
771
|
-
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
772
|
-
* for more usage information.
|
773
|
-
*
|
774
|
-
* @param {Object} options
|
775
|
-
* @param {Request|string} options.request Either a
|
776
|
-
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
777
|
-
* object, or a string URL, corresponding to the request to be made.
|
778
|
-
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
779
|
-
* be called automatically to extend the service worker's lifetime.
|
780
|
-
* @return {Promise<Response>}
|
781
|
-
*/
|
782
|
-
|
783
|
-
|
784
|
-
async makeRequest({
|
785
|
-
event,
|
786
|
-
request
|
787
|
-
}) {
|
788
|
-
if (typeof request === 'string') {
|
789
|
-
request = new Request(request);
|
790
|
-
}
|
791
|
-
|
792
|
-
{
|
793
|
-
assert_mjs.assert.isInstance(request, Request, {
|
794
|
-
moduleName: 'workbox-strategies',
|
795
|
-
className: 'NetworkOnly',
|
796
|
-
funcName: 'handle',
|
797
|
-
paramName: 'request'
|
798
|
-
});
|
799
|
-
}
|
800
|
-
|
801
|
-
let error;
|
802
|
-
let response;
|
803
|
-
|
804
|
-
try {
|
805
|
-
response = await fetchWrapper_mjs.fetchWrapper.fetch({
|
806
|
-
request,
|
807
|
-
event,
|
808
|
-
fetchOptions: this._fetchOptions,
|
809
|
-
plugins: this._plugins
|
810
|
-
});
|
811
|
-
} catch (err) {
|
812
|
-
error = err;
|
813
|
-
}
|
814
|
-
|
815
|
-
{
|
816
|
-
logger_mjs.logger.groupCollapsed(messages.strategyStart('NetworkOnly', request));
|
817
|
-
|
818
|
-
if (response) {
|
819
|
-
logger_mjs.logger.log(`Got response from network.`);
|
820
|
-
} else {
|
821
|
-
logger_mjs.logger.log(`Unable to get a response from the network.`);
|
822
|
-
}
|
823
|
-
|
824
|
-
messages.printFinalResponse(response);
|
825
|
-
logger_mjs.logger.groupEnd();
|
826
|
-
}
|
827
|
-
|
828
|
-
if (!response) {
|
829
|
-
throw new WorkboxError_mjs.WorkboxError('no-response', {
|
830
|
-
url: request.url,
|
831
|
-
error
|
832
|
-
});
|
833
|
-
}
|
834
|
-
|
835
|
-
return response;
|
836
|
-
}
|
837
|
-
|
838
|
-
}
|
839
|
-
|
840
|
-
/*
|
841
|
-
Copyright 2018 Google LLC
|
842
|
-
|
843
|
-
Use of this source code is governed by an MIT-style
|
844
|
-
license that can be found in the LICENSE file or at
|
845
|
-
https://opensource.org/licenses/MIT.
|
846
|
-
*/
|
847
|
-
/**
|
848
|
-
* An implementation of a
|
849
|
-
* [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate}
|
850
|
-
* request strategy.
|
851
|
-
*
|
852
|
-
* Resources are requested from both the cache and the network in parallel.
|
853
|
-
* The strategy will respond with the cached version if available, otherwise
|
854
|
-
* wait for the network response. The cache is updated with the network response
|
855
|
-
* with each successful request.
|
856
|
-
*
|
857
|
-
* By default, this strategy will cache responses with a 200 status code as
|
858
|
-
* well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.
|
859
|
-
* Opaque responses are are cross-origin requests where the response doesn't
|
860
|
-
* support [CORS]{@link https://enable-cors.org/}.
|
861
|
-
*
|
862
|
-
* If the network request fails, and there is no cache match, this will throw
|
863
|
-
* a `WorkboxError` exception.
|
864
|
-
*
|
865
|
-
* @memberof workbox.strategies
|
866
|
-
*/
|
867
|
-
|
868
|
-
class StaleWhileRevalidate {
|
869
|
-
/**
|
870
|
-
* @param {Object} options
|
871
|
-
* @param {string} options.cacheName Cache name to store and retrieve
|
872
|
-
* requests. Defaults to cache names provided by
|
873
|
-
* [workbox-core]{@link workbox.core.cacheNames}.
|
874
|
-
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
875
|
-
* to use in conjunction with this caching strategy.
|
876
|
-
* @param {Object} options.fetchOptions Values passed along to the
|
877
|
-
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
878
|
-
* of all fetch() requests made by this strategy.
|
879
|
-
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
880
|
-
*/
|
881
|
-
constructor(options = {}) {
|
882
|
-
this._cacheName = cacheNames_mjs.cacheNames.getRuntimeName(options.cacheName);
|
883
|
-
this._plugins = options.plugins || [];
|
884
|
-
|
885
|
-
if (options.plugins) {
|
886
|
-
let isUsingCacheWillUpdate = options.plugins.some(plugin => !!plugin.cacheWillUpdate);
|
887
|
-
this._plugins = isUsingCacheWillUpdate ? options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];
|
888
|
-
} else {
|
889
|
-
// No plugins passed in, use the default plugin.
|
890
|
-
this._plugins = [cacheOkAndOpaquePlugin];
|
891
|
-
}
|
892
|
-
|
893
|
-
this._fetchOptions = options.fetchOptions || null;
|
894
|
-
this._matchOptions = options.matchOptions || null;
|
895
|
-
}
|
896
|
-
/**
|
897
|
-
* This method will perform a request strategy and follows an API that
|
898
|
-
* will work with the
|
899
|
-
* [Workbox Router]{@link workbox.routing.Router}.
|
900
|
-
*
|
901
|
-
* @param {Object} options
|
902
|
-
* @param {Request} options.request The request to run this strategy for.
|
903
|
-
* @param {Event} [options.event] The event that triggered the request.
|
904
|
-
* @return {Promise<Response>}
|
905
|
-
*/
|
906
|
-
|
907
|
-
|
908
|
-
async handle({
|
909
|
-
event,
|
910
|
-
request
|
911
|
-
}) {
|
912
|
-
return this.makeRequest({
|
913
|
-
event,
|
914
|
-
request: request || event.request
|
915
|
-
});
|
916
|
-
}
|
917
|
-
/**
|
918
|
-
* This method can be used to perform a make a standalone request outside the
|
919
|
-
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
920
|
-
*
|
921
|
-
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
922
|
-
* for more usage information.
|
923
|
-
*
|
924
|
-
* @param {Object} options
|
925
|
-
* @param {Request|string} options.request Either a
|
926
|
-
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
927
|
-
* object, or a string URL, corresponding to the request to be made.
|
928
|
-
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
929
|
-
* be called automatically to extend the service worker's lifetime.
|
930
|
-
* @return {Promise<Response>}
|
931
|
-
*/
|
932
|
-
|
933
|
-
|
934
|
-
async makeRequest({
|
935
|
-
event,
|
936
|
-
request
|
937
|
-
}) {
|
938
|
-
const logs = [];
|
939
|
-
|
940
|
-
if (typeof request === 'string') {
|
941
|
-
request = new Request(request);
|
942
|
-
}
|
943
|
-
|
944
|
-
{
|
945
|
-
assert_mjs.assert.isInstance(request, Request, {
|
946
|
-
moduleName: 'workbox-strategies',
|
947
|
-
className: 'StaleWhileRevalidate',
|
948
|
-
funcName: 'handle',
|
949
|
-
paramName: 'request'
|
950
|
-
});
|
951
|
-
}
|
952
|
-
|
953
|
-
const fetchAndCachePromise = this._getFromNetwork({
|
954
|
-
request,
|
955
|
-
event
|
956
|
-
});
|
957
|
-
|
958
|
-
let response = await cacheWrapper_mjs.cacheWrapper.match({
|
959
|
-
cacheName: this._cacheName,
|
960
|
-
request,
|
961
|
-
event,
|
962
|
-
matchOptions: this._matchOptions,
|
963
|
-
plugins: this._plugins
|
964
|
-
});
|
965
|
-
let error;
|
966
|
-
|
967
|
-
if (response) {
|
968
|
-
{
|
969
|
-
logs.push(`Found a cached response in the '${this._cacheName}'` + ` cache. Will update with the network response in the background.`);
|
970
|
-
}
|
971
|
-
|
972
|
-
if (event) {
|
973
|
-
try {
|
974
|
-
event.waitUntil(fetchAndCachePromise);
|
975
|
-
} catch (error) {
|
976
|
-
{
|
977
|
-
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
|
978
|
-
}
|
979
|
-
}
|
980
|
-
}
|
981
|
-
} else {
|
982
|
-
{
|
983
|
-
logs.push(`No response found in the '${this._cacheName}' cache. ` + `Will wait for the network response.`);
|
984
|
-
}
|
985
|
-
|
986
|
-
try {
|
987
|
-
response = await fetchAndCachePromise;
|
988
|
-
} catch (err) {
|
989
|
-
error = err;
|
990
|
-
}
|
991
|
-
}
|
992
|
-
|
993
|
-
{
|
994
|
-
logger_mjs.logger.groupCollapsed(messages.strategyStart('StaleWhileRevalidate', request));
|
995
|
-
|
996
|
-
for (let log of logs) {
|
997
|
-
logger_mjs.logger.log(log);
|
998
|
-
}
|
999
|
-
|
1000
|
-
messages.printFinalResponse(response);
|
1001
|
-
logger_mjs.logger.groupEnd();
|
1002
|
-
}
|
1003
|
-
|
1004
|
-
if (!response) {
|
1005
|
-
throw new WorkboxError_mjs.WorkboxError('no-response', {
|
1006
|
-
url: request.url,
|
1007
|
-
error
|
1008
|
-
});
|
1009
|
-
}
|
1010
|
-
|
1011
|
-
return response;
|
1012
|
-
}
|
1013
|
-
/**
|
1014
|
-
* @param {Object} options
|
1015
|
-
* @param {Request} options.request
|
1016
|
-
* @param {Event} [options.event]
|
1017
|
-
* @return {Promise<Response>}
|
1018
|
-
*
|
1019
|
-
* @private
|
1020
|
-
*/
|
1021
|
-
|
1022
|
-
|
1023
|
-
async _getFromNetwork({
|
1024
|
-
request,
|
1025
|
-
event
|
1026
|
-
}) {
|
1027
|
-
const response = await fetchWrapper_mjs.fetchWrapper.fetch({
|
1028
|
-
request,
|
1029
|
-
event,
|
1030
|
-
fetchOptions: this._fetchOptions,
|
1031
|
-
plugins: this._plugins
|
1032
|
-
});
|
1033
|
-
const cachePutPromise = cacheWrapper_mjs.cacheWrapper.put({
|
1034
|
-
cacheName: this._cacheName,
|
1035
|
-
request,
|
1036
|
-
response: response.clone(),
|
1037
|
-
event,
|
1038
|
-
plugins: this._plugins
|
1039
|
-
});
|
1040
|
-
|
1041
|
-
if (event) {
|
1042
|
-
try {
|
1043
|
-
event.waitUntil(cachePutPromise);
|
1044
|
-
} catch (error) {
|
1045
|
-
{
|
1046
|
-
logger_mjs.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}'.`);
|
1047
|
-
}
|
1048
|
-
}
|
1049
|
-
}
|
1050
|
-
|
1051
|
-
return response;
|
1052
|
-
}
|
1053
|
-
|
1054
|
-
}
|
1055
|
-
|
1056
|
-
/*
|
1057
|
-
Copyright 2018 Google LLC
|
1058
|
-
|
1059
|
-
Use of this source code is governed by an MIT-style
|
1060
|
-
license that can be found in the LICENSE file or at
|
1061
|
-
https://opensource.org/licenses/MIT.
|
1062
|
-
*/
|
1063
|
-
const mapping = {
|
1064
|
-
cacheFirst: CacheFirst,
|
1065
|
-
cacheOnly: CacheOnly,
|
1066
|
-
networkFirst: NetworkFirst,
|
1067
|
-
networkOnly: NetworkOnly,
|
1068
|
-
staleWhileRevalidate: StaleWhileRevalidate
|
1069
|
-
};
|
1070
|
-
|
1071
|
-
const deprecate = strategy => {
|
1072
|
-
const StrategyCtr = mapping[strategy];
|
1073
|
-
return options => {
|
1074
|
-
{
|
1075
|
-
const strategyCtrName = strategy[0].toUpperCase() + strategy.slice(1);
|
1076
|
-
logger_mjs.logger.warn(`The 'workbox.strategies.${strategy}()' function has been ` + `deprecated and will be removed in a future version of Workbox.\n` + `Please use 'new workbox.strategies.${strategyCtrName}()' instead.`);
|
1077
|
-
}
|
1078
|
-
|
1079
|
-
return new StrategyCtr(options);
|
1080
|
-
};
|
1081
|
-
};
|
1082
|
-
/**
|
1083
|
-
* @function workbox.strategies.cacheFirst
|
1084
|
-
* @param {Object} options See the {@link workbox.strategies.CacheFirst}
|
1085
|
-
* constructor for more info.
|
1086
|
-
* @deprecated since v4.0.0
|
1087
|
-
*/
|
1088
|
-
|
1089
|
-
|
1090
|
-
const cacheFirst = deprecate('cacheFirst');
|
1091
|
-
/**
|
1092
|
-
* @function workbox.strategies.cacheOnly
|
1093
|
-
* @param {Object} options See the {@link workbox.strategies.CacheOnly}
|
1094
|
-
* constructor for more info.
|
1095
|
-
* @deprecated since v4.0.0
|
1096
|
-
*/
|
1097
|
-
|
1098
|
-
const cacheOnly = deprecate('cacheOnly');
|
1099
|
-
/**
|
1100
|
-
* @function workbox.strategies.networkFirst
|
1101
|
-
* @param {Object} options See the {@link workbox.strategies.NetworkFirst}
|
1102
|
-
* constructor for more info.
|
1103
|
-
* @deprecated since v4.0.0
|
1104
|
-
*/
|
1105
|
-
|
1106
|
-
const networkFirst = deprecate('networkFirst');
|
1107
|
-
/**
|
1108
|
-
* @function workbox.strategies.networkOnly
|
1109
|
-
* @param {Object} options See the {@link workbox.strategies.NetworkOnly}
|
1110
|
-
* constructor for more info.
|
1111
|
-
* @deprecated since v4.0.0
|
1112
|
-
*/
|
1113
|
-
|
1114
|
-
const networkOnly = deprecate('networkOnly');
|
1115
|
-
/**
|
1116
|
-
* @function workbox.strategies.staleWhileRevalidate
|
1117
|
-
* @param {Object} options See the
|
1118
|
-
* {@link workbox.strategies.StaleWhileRevalidate} constructor for more info.
|
1119
|
-
* @deprecated since v4.0.0
|
1120
|
-
*/
|
1121
|
-
|
1122
|
-
const staleWhileRevalidate = deprecate('staleWhileRevalidate');
|
1123
|
-
|
1124
|
-
exports.CacheFirst = CacheFirst;
|
1125
|
-
exports.CacheOnly = CacheOnly;
|
1126
|
-
exports.NetworkFirst = NetworkFirst;
|
1127
|
-
exports.NetworkOnly = NetworkOnly;
|
1128
|
-
exports.StaleWhileRevalidate = StaleWhileRevalidate;
|
1129
|
-
exports.cacheFirst = cacheFirst;
|
1130
|
-
exports.cacheOnly = cacheOnly;
|
1131
|
-
exports.networkFirst = networkFirst;
|
1132
|
-
exports.networkOnly = networkOnly;
|
1133
|
-
exports.staleWhileRevalidate = staleWhileRevalidate;
|
1134
|
-
|
1135
|
-
return exports;
|
1136
|
-
|
1137
|
-
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
|
1138
|
-
//# sourceMappingURL=workbox-strategies.dev.js.map
|