jekyll-pwa-workbox 0.0.6 → 0.0.7.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll-pwa-workbox.rb +1 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-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
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-routing.dev.js","sources":["../_version.js","../utils/constants.js","../utils/normalizeHandler.js","../Route.js","../NavigationRoute.js","../RegExpRoute.js","../Router.js","../utils/getOrCreateDefaultRouter.js","../registerNavigationRoute.js","../registerRoute.js","../setCatchHandler.js","../setDefaultHandler.js","../index.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:routing:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\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 * 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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\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 }\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { defaultMethod, validMethods } from './utils/constants.js';\nimport { normalizeHandler } from './utils/normalizeHandler.js';\nimport './_version.js';\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 = defaultMethod) {\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 if (method) {\n assert.isOneOf(method, validMethods, { paramName: 'method' });\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;\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { Route } from './Route.js';\nimport './_version.js';\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 super((options) => this._match(options), handler);\n this._whitelist = whitelist;\n this._blacklist = blacklist;\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 && request.mode !== 'navigate') {\n return false;\n }\n const pathnameAndSearch = url.pathname + url.search;\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 ${pathnameAndSearch} is not ` +\n `being used, since the URL matches this blacklist pattern: ` +\n `${regExp}`);\n }\n return false;\n }\n }\n if (this._whitelist.some((regExp) => regExp.test(pathnameAndSearch))) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`The navigation route ${pathnameAndSearch} ` +\n `is being used.`);\n }\n return true;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route ${pathnameAndSearch} is not ` +\n `being used, since the URL being navigated to doesn't ` +\n `match the whitelist.`);\n }\n return false;\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { Route } from './Route.js';\nimport './_version.js';\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 const match = ({ url }) => {\n const result = regExp.exec(url.href);\n // Return immediately if there's no match.\n if (!result) {\n return;\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(`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 return;\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 super(match, handler, method);\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { normalizeHandler } from './utils/normalizeHandler.js';\nimport './_version.js';\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 * @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 * 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 * 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 if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Caching URLs from the window`, payload.urlsToCache);\n }\n const requestPromises = Promise.all(payload.urlsToCache.map((entry) => {\n if (typeof entry === 'string') {\n entry = [entry];\n }\n const request = new Request(...entry);\n return this.handleRequest({ request });\n // TODO(philipwalton): Typescript errors without this typecast for\n // some reason (probably a bug). The real type here should work but\n // doesn't: `Array<Promise<Response> | undefined>`.\n })); // Typescript\n event.waitUntil(requestPromises);\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 * 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 const url = new URL(request.url, location.href);\n if (!url.protocol.startsWith('http')) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Workbox Router only supports URLs that start with 'http'.`);\n }\n return;\n }\n let { params, route } = this.findMatchingRoute({ url, request, event });\n let handler = route && route.handler;\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 if (params) {\n debugMessages.push([\n `Passing the following params to the route's handler:`, params,\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 handler = this._defaultHandler;\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 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 }\n else {\n logger.log(msg);\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 logger.groupEnd();\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 }\n catch (err) {\n responsePromise = Promise.reject(err);\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, request, event });\n });\n }\n return responsePromise;\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 {Event} [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 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 }\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 // 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 * 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 * 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 * 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 assert.hasMethod(route, 'match', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n assert.isType(route.handler, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n assert.hasMethod(route.handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.handler',\n });\n assert.isType(route.method, 'string', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.method',\n });\n }\n if (!this._routes.has(route.method)) {\n this._routes.set(route.method, []);\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 * 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('unregister-route-but-not-found-with-method', {\n method: route.method,\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 }\n else {\n throw new WorkboxError('unregister-route-route-not-registered');\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*/\nimport { Router } from '../Router.js';\nimport '../_version.js';\nlet defaultRouter;\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 // 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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { NavigationRoute } from './NavigationRoute.js';\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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 const cacheName = cacheNames.getPrecacheName(options.cacheName);\n const handler = async () => {\n try {\n const response = await caches.match(cachedAssetUrl, { cacheName });\n if (response) {\n return response;\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 }\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 // This might still fail if the browser is offline...\n return fetch(cachedAssetUrl);\n }\n };\n const route = new NavigationRoute(handler, {\n whitelist: options.whitelist,\n blacklist: options.blacklist,\n });\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\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*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { Route } from './Route.js';\nimport { RegExpRoute } from './RegExpRoute.js';\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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. This parameter\n * is required if `capture` is not a `Route` object.\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) => {\n let route;\n if (typeof capture === 'string') {\n const captureUrl = new URL(capture, location.href);\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 // 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 // See https://github.com/pillarjs/path-to-regexp#parameters\n const wildcards = '[*:?+]';\n if (valueToCheck.match(new RegExp(`${wildcards}`))) {\n logger.debug(`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 const matchCallback = ({ url }) => {\n if (process.env.NODE_ENV !== 'production') {\n if ((url.pathname === captureUrl.pathname) &&\n (url.origin !== captureUrl.origin)) {\n logger.debug(`${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 return url.href === captureUrl.href;\n };\n // If `capture` is a string then `handler` and `method` must be present.\n route = new Route(matchCallback, handler, method);\n }\n else if (capture instanceof RegExp) {\n // If `capture` is a `RegExp` then `handler` and `method` must be present.\n route = new RegExpRoute(capture, handler, method);\n }\n else if (typeof capture === 'function') {\n // If `capture` is a function then `handler` and `method` must be present.\n route = new Route(capture, handler, method);\n }\n else if (capture instanceof Route) {\n route = capture;\n }\n else {\n throw new WorkboxError('unsupported-route-type', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\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*/\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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*/\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { NavigationRoute } from './NavigationRoute.js';\nimport { RegExpRoute } from './RegExpRoute.js';\nimport { registerNavigationRoute } from './registerNavigationRoute.js';\nimport { registerRoute } from './registerRoute.js';\nimport { Route } from './Route.js';\nimport { Router } from './Router.js';\nimport { setCatchHandler } from './setCatchHandler.js';\nimport { setDefaultHandler } from './setDefaultHandler.js';\nimport './_version.js';\nif (process.env.NODE_ENV !== 'production') {\n assert.isSWEnv('workbox-routing');\n}\n/**\n * @namespace workbox.routing\n */\nexport { NavigationRoute, RegExpRoute, registerNavigationRoute, registerRoute, Route, Router, setCatchHandler, setDefaultHandler, };\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":";;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,+BAAD,CAAJ,IAAyCC,CAAC,EAA1C;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IACA;;;;;;;;;AAQA,IAAO,MAAMC,aAAa,GAAG,KAAtB;IACP;;;;;;;;AAOA,IAAO,MAAMC,YAAY,GAAG,CACxB,QADwB,EAExB,KAFwB,EAGxB,MAHwB,EAIxB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E7CE,MAAAA,QAAQ,EAAE,eAFmC;IAG7CC,MAAAA,SAAS,EAAE;IAHkC,KAA3C,CAAN;IAKH;;IACD,QAAMkG,aAAa,GAAGC,wBAAwB,EAA9C;IACAD,EAAAA,aAAa,CAACR,aAAd,CAA4BxB,KAA5B;IACA,SAAOA,KAAP;IACH,CA3DM;;ICtCP;;;;;;;AAOA,IAEA;;;;;;;;;;AASA,UAAauB,eAAe,GAAI/F,OAAD,IAAa;IACxC,QAAMwG,aAAa,GAAGC,wBAAwB,EAA9C;IACAD,EAAAA,aAAa,CAACT,eAAd,CAA8B/F,OAA9B;IACH,CAHM;;IClBP;;;;;;;AAOA,IAEA;;;;;;;;;;;;;AAYA,UAAa8F,iBAAiB,GAAI9F,OAAD,IAAa;IAC1C,QAAMwG,aAAa,GAAGC,wBAAwB,EAA9C;IACAD,EAAAA,aAAa,CAACV,iBAAd,CAAgC9F,OAAhC;IACH,CAHM;;ICrBP;;;;;;;AAOA;AAUA,IAA2C;IACvCC,EAAAA,gBAAM,CAACuH,OAAP,CAAe,iBAAf;IACH;;;;;;;;;;;;;;;;;"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
this.workbox=this.workbox||{},this.workbox.routing=function(t,e,r){"use strict";try{self["workbox:routing:5.0.0-alpha.0"]&&_()}catch(t){}const s="GET",n=t=>t&&"object"==typeof t?t:{handle:t};class i{constructor(t,e,r=s){this.handler=n(e),this.match=t,this.method=r}}class o extends i{constructor(t,{whitelist:e=[/./],blacklist:r=[]}={}){super(t=>this.t(t),t),this.s=e,this.i=r}t({url:t,request:e}){if(e&&"navigate"!==e.mode)return!1;const r=t.pathname+t.search;for(const t of this.i)if(t.test(r))return!1;return!!this.s.some(t=>t.test(r))}}class u extends i{constructor(t,e,r){super(({url:e})=>{const r=t.exec(e.href);if(r&&(e.origin===location.origin||0===r.index))return r.slice(1)},e,r)}}class c{constructor(){this.o=new Map}get routes(){return this.o}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.href);if(!r.protocol.startsWith("http"))return;let s,{params:n,route:i}=this.findMatchingRoute({url:r,request:t,event:e}),o=i&&i.handler;if(!o&&this.u&&(o=this.u),o){try{s=o.handle({url:r,request:t,event:e,params:n})}catch(t){s=Promise.reject(t)}return s&&this.h&&(s=s.catch(s=>this.h.handle({url:r,request:t,event:e}))),s}}findMatchingRoute({url:t,request:e,event:r}){const s=this.o.get(e.method)||[];for(const n of s){let s,i=n.match({url:t,request:e,event:r});if(i)return Array.isArray(i)&&i.length>0?s=i:i.constructor===Object&&Object.keys(i).length>0&&(s=i),{route:n,params:s}}return{}}setDefaultHandler(t){this.u=n(t)}setCatchHandler(t){this.h=n(t)}registerRoute(t){this.o.has(t.method)||this.o.set(t.method,[]),this.o.get(t.method).push(t)}unregisterRoute(t){if(!this.o.has(t.method))throw new r.WorkboxError("unregister-route-but-not-found-with-method",{method:t.method});const e=this.o.get(t.method).indexOf(t);if(!(e>-1))throw new r.WorkboxError("unregister-route-route-not-registered");this.o.get(t.method).splice(e,1)}}let a;const h=()=>(a||((a=new c).addFetchListener(),a.addCacheListener()),a);return t.NavigationRoute=o,t.RegExpRoute=u,t.Route=i,t.Router=c,t.registerNavigationRoute=((t,r={})=>{const s=e.cacheNames.getPrecacheName(r.cacheName),n=new o(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)=>{let n;if("string"==typeof t){const r=new URL(t,location.href);n=new i(({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 i(t,e,s);else{if(!(t instanceof i))throw new r.WorkboxError("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});n=t}return h().registerRoute(n),n}),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
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-routing.prod.js","sources":["../_version.js","../utils/constants.js","../utils/normalizeHandler.js","../Route.js","../NavigationRoute.js","../RegExpRoute.js","../Router.js","../utils/getOrCreateDefaultRouter.js","../registerNavigationRoute.js","../registerRoute.js","../setCatchHandler.js","../setDefaultHandler.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:routing:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\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 * 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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\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 }\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { defaultMethod, validMethods } from './utils/constants.js';\nimport { normalizeHandler } from './utils/normalizeHandler.js';\nimport './_version.js';\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 = defaultMethod) {\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 if (method) {\n assert.isOneOf(method, validMethods, { paramName: 'method' });\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;\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { Route } from './Route.js';\nimport './_version.js';\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 super((options) => this._match(options), handler);\n this._whitelist = whitelist;\n this._blacklist = blacklist;\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 && request.mode !== 'navigate') {\n return false;\n }\n const pathnameAndSearch = url.pathname + url.search;\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 ${pathnameAndSearch} is not ` +\n `being used, since the URL matches this blacklist pattern: ` +\n `${regExp}`);\n }\n return false;\n }\n }\n if (this._whitelist.some((regExp) => regExp.test(pathnameAndSearch))) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`The navigation route ${pathnameAndSearch} ` +\n `is being used.`);\n }\n return true;\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`The navigation route ${pathnameAndSearch} is not ` +\n `being used, since the URL being navigated to doesn't ` +\n `match the whitelist.`);\n }\n return false;\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { Route } from './Route.js';\nimport './_version.js';\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 const match = ({ url }) => {\n const result = regExp.exec(url.href);\n // Return immediately if there's no match.\n if (!result) {\n return;\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(`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 return;\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 super(match, handler, method);\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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { normalizeHandler } from './utils/normalizeHandler.js';\nimport './_version.js';\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 * @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 * 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 * 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 if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Caching URLs from the window`, payload.urlsToCache);\n }\n const requestPromises = Promise.all(payload.urlsToCache.map((entry) => {\n if (typeof entry === 'string') {\n entry = [entry];\n }\n const request = new Request(...entry);\n return this.handleRequest({ request });\n // TODO(philipwalton): Typescript errors without this typecast for\n // some reason (probably a bug). The real type here should work but\n // doesn't: `Array<Promise<Response> | undefined>`.\n })); // Typescript\n event.waitUntil(requestPromises);\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 * 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 const url = new URL(request.url, location.href);\n if (!url.protocol.startsWith('http')) {\n if (process.env.NODE_ENV !== 'production') {\n logger.debug(`Workbox Router only supports URLs that start with 'http'.`);\n }\n return;\n }\n let { params, route } = this.findMatchingRoute({ url, request, event });\n let handler = route && route.handler;\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 if (params) {\n debugMessages.push([\n `Passing the following params to the route's handler:`, params,\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 handler = this._defaultHandler;\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 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 }\n else {\n logger.log(msg);\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 logger.groupEnd();\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 }\n catch (err) {\n responsePromise = Promise.reject(err);\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, request, event });\n });\n }\n return responsePromise;\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 {Event} [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 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 }\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 // 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 * 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 * 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 * 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 assert.hasMethod(route, 'match', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n assert.isType(route.handler, 'object', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route',\n });\n assert.hasMethod(route.handler, 'handle', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.handler',\n });\n assert.isType(route.method, 'string', {\n moduleName: 'workbox-routing',\n className: 'Router',\n funcName: 'registerRoute',\n paramName: 'route.method',\n });\n }\n if (!this._routes.has(route.method)) {\n this._routes.set(route.method, []);\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 * 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('unregister-route-but-not-found-with-method', {\n method: route.method,\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 }\n else {\n throw new WorkboxError('unregister-route-route-not-registered');\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*/\nimport { Router } from '../Router.js';\nimport '../_version.js';\nlet defaultRouter;\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 // 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*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { cacheNames } from 'workbox-core/_private/cacheNames.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { NavigationRoute } from './NavigationRoute.js';\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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 const cacheName = cacheNames.getPrecacheName(options.cacheName);\n const handler = async () => {\n try {\n const response = await caches.match(cachedAssetUrl, { cacheName });\n if (response) {\n return response;\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 }\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 // This might still fail if the browser is offline...\n return fetch(cachedAssetUrl);\n }\n };\n const route = new NavigationRoute(handler, {\n whitelist: options.whitelist,\n blacklist: options.blacklist,\n });\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\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*/\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { Route } from './Route.js';\nimport { RegExpRoute } from './RegExpRoute.js';\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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. This parameter\n * is required if `capture` is not a `Route` object.\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) => {\n let route;\n if (typeof capture === 'string') {\n const captureUrl = new URL(capture, location.href);\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 // 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 // See https://github.com/pillarjs/path-to-regexp#parameters\n const wildcards = '[*:?+]';\n if (valueToCheck.match(new RegExp(`${wildcards}`))) {\n logger.debug(`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 const matchCallback = ({ url }) => {\n if (process.env.NODE_ENV !== 'production') {\n if ((url.pathname === captureUrl.pathname) &&\n (url.origin !== captureUrl.origin)) {\n logger.debug(`${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 return url.href === captureUrl.href;\n };\n // If `capture` is a string then `handler` and `method` must be present.\n route = new Route(matchCallback, handler, method);\n }\n else if (capture instanceof RegExp) {\n // If `capture` is a `RegExp` then `handler` and `method` must be present.\n route = new RegExpRoute(capture, handler, method);\n }\n else if (typeof capture === 'function') {\n // If `capture` is a function then `handler` and `method` must be present.\n route = new Route(capture, handler, method);\n }\n else if (capture instanceof Route) {\n route = capture;\n }\n else {\n throw new WorkboxError('unsupported-route-type', {\n moduleName: 'workbox-routing',\n funcName: 'registerRoute',\n paramName: 'capture',\n });\n }\n const defaultRouter = getOrCreateDefaultRouter();\n defaultRouter.registerRoute(route);\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*/\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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*/\nimport { getOrCreateDefaultRouter } from './utils/getOrCreateDefaultRouter.js';\nimport './_version.js';\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":"gFACA,IACIA,KAAK,kCAAoCC,IAE7C,MAAOC,ICYA,MAAMC,EAAgB,MCAhBC,EAAoBC,GACzBA,GAA8B,iBAAZA,EASXA,EAWA,CAAEC,OAAQD,GCjBzB,MAAME,EAYFC,YAAYC,EAAOJ,EAASK,EAASP,QAc5BE,QAAUD,EAAiBC,QAC3BI,MAAQA,OACRC,OAASA,GCtBtB,MAAMC,UAAwBJ,EAoB1BC,YAAYH,GAASO,UAAEA,EAAY,CAAC,KAAfC,UAAqBA,EAAY,IAAO,UAelDC,GAAYC,KAAKC,EAAOF,GAAUT,QACpCY,EAAaL,OACbM,EAAaL,EAYtBG,GAAOG,IAAEA,EAAFC,QAAOA,OACNA,GAA4B,aAAjBA,EAAQC,YACZ,QAELC,EAAoBH,EAAII,SAAWJ,EAAIK,WACxC,MAAMC,KAAUV,KAAKG,KAClBO,EAAOC,KAAKJ,UAML,UAGXP,KAAKE,EAAWU,KAAMF,GAAWA,EAAOC,KAAKJ,KClEzD,MAAMM,UAAoBrB,EActBC,YAAYiB,EAAQpB,EAASK,SASX,EAAGS,IAAAA,YACPU,EAASJ,EAAOK,KAAKX,EAAIY,SAE1BF,IAOAV,EAAIa,SAAWC,SAASD,QAA6B,IAAjBH,EAAOK,cAYzCL,EAAOM,MAAM,IAEX9B,EAASK,ICzC9B,MAAM0B,EAIF5B,mBACS6B,EAAU,IAAIC,wBAQZvB,KAAKsB,EAMhBE,mBACIvC,KAAKwC,iBAAiB,QAAUC,UACtBrB,QAAEA,GAAYqB,EACdC,EAAkB3B,KAAK4B,cAAc,CAAEvB,QAAAA,EAASqB,M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E,SAASF,MAiC7CiC,EAAQ,IAAIzD,EAZU,EAAGY,IAAAA,KASdA,EAAIY,OAASuE,EAAWvE,KAGF1B,EAASK,QAEzC,GAAI2F,aAAmBE,OAExBvC,EAAQ,IAAIpC,EAAYyE,EAAShG,EAASK,QAEzC,GAAuB,mBAAZ2F,EAEZrC,EAAQ,IAAIzD,EAAM8F,EAAShG,EAASK,OAEnC,CAAA,KAAI2F,aAAmB9F,SAIlB,IAAI+E,eAAa,yBAA0B,CAC7CkB,WAAY,kBACZC,SAAU,gBACVC,UAAW,YANf1C,EAAQqC,SASUV,IACRV,cAAcjB,GACrBA,sBC9EqB3D,CAAAA,IACNsF,IACRX,gBAAgB3E,yBCCAA,CAAAA,IACRsF,IACRZ,kBAAkB1E"}
|
@@ -0,0 +1,1127 @@
|
|
1
|
+
this.workbox = this.workbox || {};
|
2
|
+
this.workbox.strategies = (function (exports, logger_js, assert_js, cacheNames_js, cacheWrapper_js, fetchWrapper_js, getFriendlyURL_js, WorkboxError_js) {
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
// @ts-ignore
|
6
|
+
try {
|
7
|
+
self['workbox:strategies:5.0.0-alpha.0'] && _();
|
8
|
+
} catch (e) {}
|
9
|
+
|
10
|
+
/*
|
11
|
+
Copyright 2018 Google LLC
|
12
|
+
|
13
|
+
Use of this source code is governed by an MIT-style
|
14
|
+
license that can be found in the LICENSE file or at
|
15
|
+
https://opensource.org/licenses/MIT.
|
16
|
+
*/
|
17
|
+
const messages = {
|
18
|
+
strategyStart: (strategyName, request) => `Using ${strategyName} to respond to '${getFriendlyURL_js.getFriendlyURL(request.url)}'`,
|
19
|
+
printFinalResponse: response => {
|
20
|
+
if (response) {
|
21
|
+
logger_js.logger.groupCollapsed(`View the final response here.`);
|
22
|
+
logger_js.logger.log(response || '[No response returned]');
|
23
|
+
logger_js.logger.groupEnd();
|
24
|
+
}
|
25
|
+
}
|
26
|
+
};
|
27
|
+
|
28
|
+
/*
|
29
|
+
Copyright 2018 Google LLC
|
30
|
+
|
31
|
+
Use of this source code is governed by an MIT-style
|
32
|
+
license that can be found in the LICENSE file or at
|
33
|
+
https://opensource.org/licenses/MIT.
|
34
|
+
*/
|
35
|
+
/**
|
36
|
+
* An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network}
|
37
|
+
* request strategy.
|
38
|
+
*
|
39
|
+
* A cache first strategy is useful for assets that have been revisioned,
|
40
|
+
* such as URLs like `/styles/example.a8f5f1.css`, since they
|
41
|
+
* can be cached for long periods of time.
|
42
|
+
*
|
43
|
+
* If the network request fails, and there is no cache match, this will throw
|
44
|
+
* a `WorkboxError` exception.
|
45
|
+
*
|
46
|
+
* @memberof workbox.strategies
|
47
|
+
*/
|
48
|
+
|
49
|
+
class CacheFirst {
|
50
|
+
/**
|
51
|
+
* @param {Object} options
|
52
|
+
* @param {string} options.cacheName Cache name to store and retrieve
|
53
|
+
* requests. Defaults to cache names provided by
|
54
|
+
* [workbox-core]{@link workbox.core.cacheNames}.
|
55
|
+
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
56
|
+
* to use in conjunction with this caching strategy.
|
57
|
+
* @param {Object} options.fetchOptions Values passed along to the
|
58
|
+
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
59
|
+
* of all fetch() requests made by this strategy.
|
60
|
+
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
61
|
+
*/
|
62
|
+
constructor(options = {}) {
|
63
|
+
this._cacheName = cacheNames_js.cacheNames.getRuntimeName(options.cacheName);
|
64
|
+
this._plugins = options.plugins || [];
|
65
|
+
this._fetchOptions = options.fetchOptions;
|
66
|
+
this._matchOptions = options.matchOptions;
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* This method will perform a request strategy and follows an API that
|
70
|
+
* will work with the
|
71
|
+
* [Workbox Router]{@link workbox.routing.Router}.
|
72
|
+
*
|
73
|
+
* @param {Object} options
|
74
|
+
* @param {Request} options.request The request to run this strategy for.
|
75
|
+
* @param {Event} [options.event] The event that triggered the request.
|
76
|
+
* @return {Promise<Response>}
|
77
|
+
*/
|
78
|
+
|
79
|
+
|
80
|
+
async handle({
|
81
|
+
event,
|
82
|
+
request
|
83
|
+
}) {
|
84
|
+
return this.makeRequest({
|
85
|
+
event,
|
86
|
+
request: request || event.request
|
87
|
+
});
|
88
|
+
}
|
89
|
+
/**
|
90
|
+
* This method can be used to perform a make a standalone request outside the
|
91
|
+
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
92
|
+
*
|
93
|
+
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
94
|
+
* for more usage information.
|
95
|
+
*
|
96
|
+
* @param {Object} options
|
97
|
+
* @param {Request|string} options.request Either a
|
98
|
+
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
99
|
+
* object, or a string URL, corresponding to the request to be made.
|
100
|
+
* @param {Event} [options.event] If provided, `event.waitUntil()` will
|
101
|
+
be called automatically to extend the service worker's lifetime.
|
102
|
+
* @return {Promise<Response>}
|
103
|
+
*/
|
104
|
+
|
105
|
+
|
106
|
+
async makeRequest({
|
107
|
+
event,
|
108
|
+
request
|
109
|
+
}) {
|
110
|
+
const logs = [];
|
111
|
+
|
112
|
+
if (typeof request === 'string') {
|
113
|
+
request = new Request(request);
|
114
|
+
}
|
115
|
+
|
116
|
+
{
|
117
|
+
assert_js.assert.isInstance(request, Request, {
|
118
|
+
moduleName: 'workbox-strategies',
|
119
|
+
className: 'CacheFirst',
|
120
|
+
funcName: 'makeRequest',
|
121
|
+
paramName: 'request'
|
122
|
+
});
|
123
|
+
}
|
124
|
+
|
125
|
+
let response = await cacheWrapper_js.cacheWrapper.match({
|
126
|
+
cacheName: this._cacheName,
|
127
|
+
request,
|
128
|
+
event,
|
129
|
+
matchOptions: this._matchOptions,
|
130
|
+
plugins: this._plugins
|
131
|
+
});
|
132
|
+
let error;
|
133
|
+
|
134
|
+
if (!response) {
|
135
|
+
{
|
136
|
+
logs.push(`No response found in the '${this._cacheName}' cache. ` + `Will respond with a network request.`);
|
137
|
+
}
|
138
|
+
|
139
|
+
try {
|
140
|
+
response = await this._getFromNetwork(request, event);
|
141
|
+
} catch (err) {
|
142
|
+
error = err;
|
143
|
+
}
|
144
|
+
|
145
|
+
{
|
146
|
+
if (response) {
|
147
|
+
logs.push(`Got response from network.`);
|
148
|
+
} else {
|
149
|
+
logs.push(`Unable to get a response from the network.`);
|
150
|
+
}
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
{
|
154
|
+
logs.push(`Found a cached response in the '${this._cacheName}' cache.`);
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
{
|
159
|
+
logger_js.logger.groupCollapsed(messages.strategyStart('CacheFirst', request));
|
160
|
+
|
161
|
+
for (let log of logs) {
|
162
|
+
logger_js.logger.log(log);
|
163
|
+
}
|
164
|
+
|
165
|
+
messages.printFinalResponse(response);
|
166
|
+
logger_js.logger.groupEnd();
|
167
|
+
}
|
168
|
+
|
169
|
+
if (!response) {
|
170
|
+
throw new WorkboxError_js.WorkboxError('no-response', {
|
171
|
+
url: request.url,
|
172
|
+
error
|
173
|
+
});
|
174
|
+
}
|
175
|
+
|
176
|
+
return response;
|
177
|
+
}
|
178
|
+
/**
|
179
|
+
* Handles the network and cache part of CacheFirst.
|
180
|
+
*
|
181
|
+
* @param {Request} request
|
182
|
+
* @param {Event} [event]
|
183
|
+
* @return {Promise<Response>}
|
184
|
+
*
|
185
|
+
* @private
|
186
|
+
*/
|
187
|
+
|
188
|
+
|
189
|
+
async _getFromNetwork(request, event) {
|
190
|
+
const response = await fetchWrapper_js.fetchWrapper.fetch({
|
191
|
+
request,
|
192
|
+
event,
|
193
|
+
fetchOptions: this._fetchOptions,
|
194
|
+
plugins: this._plugins
|
195
|
+
}); // Keep the service worker while we put the request to the cache
|
196
|
+
|
197
|
+
const responseClone = response.clone();
|
198
|
+
const cachePutPromise = cacheWrapper_js.cacheWrapper.put({
|
199
|
+
cacheName: this._cacheName,
|
200
|
+
request,
|
201
|
+
response: responseClone,
|
202
|
+
event,
|
203
|
+
plugins: this._plugins
|
204
|
+
});
|
205
|
+
|
206
|
+
if (event) {
|
207
|
+
try {
|
208
|
+
event.waitUntil(cachePutPromise);
|
209
|
+
} catch (error) {
|
210
|
+
{
|
211
|
+
logger_js.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_js.getFriendlyURL(request.url)}'.`);
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
return response;
|
217
|
+
}
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
/*
|
222
|
+
Copyright 2018 Google LLC
|
223
|
+
|
224
|
+
Use of this source code is governed by an MIT-style
|
225
|
+
license that can be found in the LICENSE file or at
|
226
|
+
https://opensource.org/licenses/MIT.
|
227
|
+
*/
|
228
|
+
/**
|
229
|
+
* An implementation of a
|
230
|
+
* [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only}
|
231
|
+
* request strategy.
|
232
|
+
*
|
233
|
+
* This class is useful if you want to take advantage of any
|
234
|
+
* [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
|
235
|
+
*
|
236
|
+
* If there is no cache match, this will throw a `WorkboxError` exception.
|
237
|
+
*
|
238
|
+
* @memberof workbox.strategies
|
239
|
+
*/
|
240
|
+
|
241
|
+
class CacheOnly {
|
242
|
+
/**
|
243
|
+
* @param {Object} options
|
244
|
+
* @param {string} options.cacheName Cache name to store and retrieve
|
245
|
+
* requests. Defaults to cache names provided by
|
246
|
+
* [workbox-core]{@link workbox.core.cacheNames}.
|
247
|
+
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
248
|
+
* to use in conjunction with this caching strategy.
|
249
|
+
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
250
|
+
*/
|
251
|
+
constructor(options = {}) {
|
252
|
+
this._cacheName = cacheNames_js.cacheNames.getRuntimeName(options.cacheName);
|
253
|
+
this._plugins = options.plugins || [];
|
254
|
+
this._matchOptions = options.matchOptions;
|
255
|
+
}
|
256
|
+
/**
|
257
|
+
* This method will perform a request strategy and follows an API that
|
258
|
+
* will work with the
|
259
|
+
* [Workbox Router]{@link workbox.routing.Router}.
|
260
|
+
*
|
261
|
+
* @param {Object} options
|
262
|
+
* @param {Request} options.request The request to run this strategy for.
|
263
|
+
* @param {Event} [options.event] The event that triggered the request.
|
264
|
+
* @return {Promise<Response>}
|
265
|
+
*/
|
266
|
+
|
267
|
+
|
268
|
+
async handle({
|
269
|
+
event,
|
270
|
+
request
|
271
|
+
}) {
|
272
|
+
return this.makeRequest({
|
273
|
+
event,
|
274
|
+
request: request || event.request
|
275
|
+
});
|
276
|
+
}
|
277
|
+
/**
|
278
|
+
* This method can be used to perform a make a standalone request outside the
|
279
|
+
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
280
|
+
*
|
281
|
+
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
282
|
+
* for more usage information.
|
283
|
+
*
|
284
|
+
* @param {Object} options
|
285
|
+
* @param {Request|string} options.request Either a
|
286
|
+
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
287
|
+
* object, or a string URL, corresponding to the request to be made.
|
288
|
+
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
289
|
+
* be called automatically to extend the service worker's lifetime.
|
290
|
+
* @return {Promise<Response>}
|
291
|
+
*/
|
292
|
+
|
293
|
+
|
294
|
+
async makeRequest({
|
295
|
+
event,
|
296
|
+
request
|
297
|
+
}) {
|
298
|
+
if (typeof request === 'string') {
|
299
|
+
request = new Request(request);
|
300
|
+
}
|
301
|
+
|
302
|
+
{
|
303
|
+
assert_js.assert.isInstance(request, Request, {
|
304
|
+
moduleName: 'workbox-strategies',
|
305
|
+
className: 'CacheOnly',
|
306
|
+
funcName: 'makeRequest',
|
307
|
+
paramName: 'request'
|
308
|
+
});
|
309
|
+
}
|
310
|
+
|
311
|
+
const response = await cacheWrapper_js.cacheWrapper.match({
|
312
|
+
cacheName: this._cacheName,
|
313
|
+
request,
|
314
|
+
event,
|
315
|
+
matchOptions: this._matchOptions,
|
316
|
+
plugins: this._plugins
|
317
|
+
});
|
318
|
+
|
319
|
+
{
|
320
|
+
logger_js.logger.groupCollapsed(messages.strategyStart('CacheOnly', request));
|
321
|
+
|
322
|
+
if (response) {
|
323
|
+
logger_js.logger.log(`Found a cached response in the '${this._cacheName}'` + ` cache.`);
|
324
|
+
messages.printFinalResponse(response);
|
325
|
+
} else {
|
326
|
+
logger_js.logger.log(`No response found in the '${this._cacheName}' cache.`);
|
327
|
+
}
|
328
|
+
|
329
|
+
logger_js.logger.groupEnd();
|
330
|
+
}
|
331
|
+
|
332
|
+
if (!response) {
|
333
|
+
throw new WorkboxError_js.WorkboxError('no-response', {
|
334
|
+
url: request.url
|
335
|
+
});
|
336
|
+
}
|
337
|
+
|
338
|
+
return response;
|
339
|
+
}
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
/*
|
344
|
+
Copyright 2018 Google LLC
|
345
|
+
|
346
|
+
Use of this source code is governed by an MIT-style
|
347
|
+
license that can be found in the LICENSE file or at
|
348
|
+
https://opensource.org/licenses/MIT.
|
349
|
+
*/
|
350
|
+
const cacheOkAndOpaquePlugin = {
|
351
|
+
/**
|
352
|
+
* Returns a valid response (to allow caching) if the status is 200 (OK) or
|
353
|
+
* 0 (opaque).
|
354
|
+
*
|
355
|
+
* @param {Object} options
|
356
|
+
* @param {Response} options.response
|
357
|
+
* @return {Response|null}
|
358
|
+
*
|
359
|
+
* @private
|
360
|
+
*/
|
361
|
+
cacheWillUpdate: async ({
|
362
|
+
response
|
363
|
+
}) => {
|
364
|
+
if (response.status === 200 || response.status === 0) {
|
365
|
+
return response;
|
366
|
+
}
|
367
|
+
|
368
|
+
return null;
|
369
|
+
}
|
370
|
+
};
|
371
|
+
|
372
|
+
/*
|
373
|
+
Copyright 2018 Google LLC
|
374
|
+
|
375
|
+
Use of this source code is governed by an MIT-style
|
376
|
+
license that can be found in the LICENSE file or at
|
377
|
+
https://opensource.org/licenses/MIT.
|
378
|
+
*/
|
379
|
+
/**
|
380
|
+
* An implementation of a
|
381
|
+
* [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache}
|
382
|
+
* request strategy.
|
383
|
+
*
|
384
|
+
* By default, this strategy will cache responses with a 200 status code as
|
385
|
+
* well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.
|
386
|
+
* Opaque responses are are cross-origin requests where the response doesn't
|
387
|
+
* support [CORS]{@link https://enable-cors.org/}.
|
388
|
+
*
|
389
|
+
* If the network request fails, and there is no cache match, this will throw
|
390
|
+
* a `WorkboxError` exception.
|
391
|
+
*
|
392
|
+
* @memberof workbox.strategies
|
393
|
+
*/
|
394
|
+
|
395
|
+
class NetworkFirst {
|
396
|
+
/**
|
397
|
+
* @param {Object} options
|
398
|
+
* @param {string} options.cacheName Cache name to store and retrieve
|
399
|
+
* requests. Defaults to cache names provided by
|
400
|
+
* [workbox-core]{@link workbox.core.cacheNames}.
|
401
|
+
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
402
|
+
* to use in conjunction with this caching strategy.
|
403
|
+
* @param {Object} options.fetchOptions Values passed along to the
|
404
|
+
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
405
|
+
* of all fetch() requests made by this strategy.
|
406
|
+
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
407
|
+
* @param {number} options.networkTimeoutSeconds If set, any network requests
|
408
|
+
* that fail to respond within the timeout will fallback to the cache.
|
409
|
+
*
|
410
|
+
* This option can be used to combat
|
411
|
+
* "[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}"
|
412
|
+
* scenarios.
|
413
|
+
*/
|
414
|
+
constructor(options = {}) {
|
415
|
+
this._cacheName = cacheNames_js.cacheNames.getRuntimeName(options.cacheName);
|
416
|
+
|
417
|
+
if (options.plugins) {
|
418
|
+
let isUsingCacheWillUpdate = options.plugins.some(plugin => !!plugin.cacheWillUpdate);
|
419
|
+
this._plugins = isUsingCacheWillUpdate ? options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];
|
420
|
+
} else {
|
421
|
+
// No plugins passed in, use the default plugin.
|
422
|
+
this._plugins = [cacheOkAndOpaquePlugin];
|
423
|
+
}
|
424
|
+
|
425
|
+
this._networkTimeoutSeconds = options.networkTimeoutSeconds || 0;
|
426
|
+
|
427
|
+
{
|
428
|
+
if (this._networkTimeoutSeconds) {
|
429
|
+
assert_js.assert.isType(this._networkTimeoutSeconds, 'number', {
|
430
|
+
moduleName: 'workbox-strategies',
|
431
|
+
className: 'NetworkFirst',
|
432
|
+
funcName: 'constructor',
|
433
|
+
paramName: 'networkTimeoutSeconds'
|
434
|
+
});
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
this._fetchOptions = options.fetchOptions;
|
439
|
+
this._matchOptions = options.matchOptions;
|
440
|
+
}
|
441
|
+
/**
|
442
|
+
* This method will perform a request strategy and follows an API that
|
443
|
+
* will work with the
|
444
|
+
* [Workbox Router]{@link workbox.routing.Router}.
|
445
|
+
*
|
446
|
+
* @param {Object} options
|
447
|
+
* @param {Request} options.request The request to run this strategy for.
|
448
|
+
* @param {Event} [options.event] The event that triggered the request.
|
449
|
+
* @return {Promise<Response>}
|
450
|
+
*/
|
451
|
+
|
452
|
+
|
453
|
+
async handle({
|
454
|
+
event,
|
455
|
+
request
|
456
|
+
}) {
|
457
|
+
return this.makeRequest({
|
458
|
+
event,
|
459
|
+
request: request || event.request
|
460
|
+
});
|
461
|
+
}
|
462
|
+
/**
|
463
|
+
* This method can be used to perform a make a standalone request outside the
|
464
|
+
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
465
|
+
*
|
466
|
+
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
467
|
+
* for more usage information.
|
468
|
+
*
|
469
|
+
* @param {Object} options
|
470
|
+
* @param {Request|string} options.request Either a
|
471
|
+
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
472
|
+
* object, or a string URL, corresponding to the request to be made.
|
473
|
+
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
474
|
+
* be called automatically to extend the service worker's lifetime.
|
475
|
+
* @return {Promise<Response>}
|
476
|
+
*/
|
477
|
+
|
478
|
+
|
479
|
+
async makeRequest({
|
480
|
+
event,
|
481
|
+
request
|
482
|
+
}) {
|
483
|
+
const logs = [];
|
484
|
+
|
485
|
+
if (typeof request === 'string') {
|
486
|
+
request = new Request(request);
|
487
|
+
}
|
488
|
+
|
489
|
+
{
|
490
|
+
assert_js.assert.isInstance(request, Request, {
|
491
|
+
moduleName: 'workbox-strategies',
|
492
|
+
className: 'NetworkFirst',
|
493
|
+
funcName: 'handle',
|
494
|
+
paramName: 'makeRequest'
|
495
|
+
});
|
496
|
+
}
|
497
|
+
|
498
|
+
const promises = [];
|
499
|
+
let timeoutId;
|
500
|
+
|
501
|
+
if (this._networkTimeoutSeconds) {
|
502
|
+
const {
|
503
|
+
id,
|
504
|
+
promise
|
505
|
+
} = this._getTimeoutPromise({
|
506
|
+
request,
|
507
|
+
event,
|
508
|
+
logs
|
509
|
+
});
|
510
|
+
|
511
|
+
timeoutId = id;
|
512
|
+
promises.push(promise);
|
513
|
+
}
|
514
|
+
|
515
|
+
const networkPromise = this._getNetworkPromise({
|
516
|
+
timeoutId,
|
517
|
+
request,
|
518
|
+
event,
|
519
|
+
logs
|
520
|
+
});
|
521
|
+
|
522
|
+
promises.push(networkPromise); // Promise.race() will resolve as soon as the first promise resolves.
|
523
|
+
|
524
|
+
let response = await Promise.race(promises); // If Promise.race() resolved with null, it might be due to a network
|
525
|
+
// timeout + a cache miss. If that were to happen, we'd rather wait until
|
526
|
+
// the networkPromise resolves instead of returning null.
|
527
|
+
// Note that it's fine to await an already-resolved promise, so we don't
|
528
|
+
// have to check to see if it's still "in flight".
|
529
|
+
|
530
|
+
if (!response) {
|
531
|
+
response = await networkPromise;
|
532
|
+
}
|
533
|
+
|
534
|
+
{
|
535
|
+
logger_js.logger.groupCollapsed(messages.strategyStart('NetworkFirst', request));
|
536
|
+
|
537
|
+
for (let log of logs) {
|
538
|
+
logger_js.logger.log(log);
|
539
|
+
}
|
540
|
+
|
541
|
+
messages.printFinalResponse(response);
|
542
|
+
logger_js.logger.groupEnd();
|
543
|
+
}
|
544
|
+
|
545
|
+
if (!response) {
|
546
|
+
throw new WorkboxError_js.WorkboxError('no-response', {
|
547
|
+
url: request.url
|
548
|
+
});
|
549
|
+
}
|
550
|
+
|
551
|
+
return response;
|
552
|
+
}
|
553
|
+
/**
|
554
|
+
* @param {Object} options
|
555
|
+
* @param {Request} options.request
|
556
|
+
* @param {Array} options.logs A reference to the logs array
|
557
|
+
* @param {Event} [options.event]
|
558
|
+
* @return {Promise<Response>}
|
559
|
+
*
|
560
|
+
* @private
|
561
|
+
*/
|
562
|
+
|
563
|
+
|
564
|
+
_getTimeoutPromise({
|
565
|
+
request,
|
566
|
+
logs,
|
567
|
+
event
|
568
|
+
}) {
|
569
|
+
let timeoutId;
|
570
|
+
const timeoutPromise = new Promise(resolve => {
|
571
|
+
const onNetworkTimeout = async () => {
|
572
|
+
{
|
573
|
+
logs.push(`Timing out the network response at ` + `${this._networkTimeoutSeconds} seconds.`);
|
574
|
+
}
|
575
|
+
|
576
|
+
resolve((await this._respondFromCache({
|
577
|
+
request,
|
578
|
+
event
|
579
|
+
})));
|
580
|
+
};
|
581
|
+
|
582
|
+
timeoutId = setTimeout(onNetworkTimeout, this._networkTimeoutSeconds * 1000);
|
583
|
+
});
|
584
|
+
return {
|
585
|
+
promise: timeoutPromise,
|
586
|
+
id: timeoutId
|
587
|
+
};
|
588
|
+
}
|
589
|
+
/**
|
590
|
+
* @param {Object} options
|
591
|
+
* @param {number|undefined} options.timeoutId
|
592
|
+
* @param {Request} options.request
|
593
|
+
* @param {Array} options.logs A reference to the logs Array.
|
594
|
+
* @param {Event} [options.event]
|
595
|
+
* @return {Promise<Response>}
|
596
|
+
*
|
597
|
+
* @private
|
598
|
+
*/
|
599
|
+
|
600
|
+
|
601
|
+
async _getNetworkPromise({
|
602
|
+
timeoutId,
|
603
|
+
request,
|
604
|
+
logs,
|
605
|
+
event
|
606
|
+
}) {
|
607
|
+
let error;
|
608
|
+
let response;
|
609
|
+
|
610
|
+
try {
|
611
|
+
response = await fetchWrapper_js.fetchWrapper.fetch({
|
612
|
+
request,
|
613
|
+
event,
|
614
|
+
fetchOptions: this._fetchOptions,
|
615
|
+
plugins: this._plugins
|
616
|
+
});
|
617
|
+
} catch (err) {
|
618
|
+
error = err;
|
619
|
+
}
|
620
|
+
|
621
|
+
if (timeoutId) {
|
622
|
+
clearTimeout(timeoutId);
|
623
|
+
}
|
624
|
+
|
625
|
+
{
|
626
|
+
if (response) {
|
627
|
+
logs.push(`Got response from network.`);
|
628
|
+
} else {
|
629
|
+
logs.push(`Unable to get a response from the network. Will respond ` + `with a cached response.`);
|
630
|
+
}
|
631
|
+
}
|
632
|
+
|
633
|
+
if (error || !response) {
|
634
|
+
response = await this._respondFromCache({
|
635
|
+
request,
|
636
|
+
event
|
637
|
+
});
|
638
|
+
|
639
|
+
{
|
640
|
+
if (response) {
|
641
|
+
logs.push(`Found a cached response in the '${this._cacheName}'` + ` cache.`);
|
642
|
+
} else {
|
643
|
+
logs.push(`No response found in the '${this._cacheName}' cache.`);
|
644
|
+
}
|
645
|
+
}
|
646
|
+
} else {
|
647
|
+
// Keep the service worker alive while we put the request in the cache
|
648
|
+
const responseClone = response.clone();
|
649
|
+
const cachePut = cacheWrapper_js.cacheWrapper.put({
|
650
|
+
cacheName: this._cacheName,
|
651
|
+
request,
|
652
|
+
response: responseClone,
|
653
|
+
event,
|
654
|
+
plugins: this._plugins
|
655
|
+
});
|
656
|
+
|
657
|
+
if (event) {
|
658
|
+
try {
|
659
|
+
// The event has been responded to so we can keep the SW alive to
|
660
|
+
// respond to the request
|
661
|
+
event.waitUntil(cachePut);
|
662
|
+
} catch (err) {
|
663
|
+
{
|
664
|
+
logger_js.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_js.getFriendlyURL(request.url)}'.`);
|
665
|
+
}
|
666
|
+
}
|
667
|
+
}
|
668
|
+
}
|
669
|
+
|
670
|
+
return response;
|
671
|
+
}
|
672
|
+
/**
|
673
|
+
* Used if the network timeouts or fails to make the request.
|
674
|
+
*
|
675
|
+
* @param {Object} options
|
676
|
+
* @param {Request} request The request to match in the cache
|
677
|
+
* @param {Event} [options.event]
|
678
|
+
* @return {Promise<Object>}
|
679
|
+
*
|
680
|
+
* @private
|
681
|
+
*/
|
682
|
+
|
683
|
+
|
684
|
+
_respondFromCache({
|
685
|
+
event,
|
686
|
+
request
|
687
|
+
}) {
|
688
|
+
return cacheWrapper_js.cacheWrapper.match({
|
689
|
+
cacheName: this._cacheName,
|
690
|
+
request,
|
691
|
+
event,
|
692
|
+
matchOptions: this._matchOptions,
|
693
|
+
plugins: this._plugins
|
694
|
+
});
|
695
|
+
}
|
696
|
+
|
697
|
+
}
|
698
|
+
|
699
|
+
/*
|
700
|
+
Copyright 2018 Google LLC
|
701
|
+
|
702
|
+
Use of this source code is governed by an MIT-style
|
703
|
+
license that can be found in the LICENSE file or at
|
704
|
+
https://opensource.org/licenses/MIT.
|
705
|
+
*/
|
706
|
+
/**
|
707
|
+
* An implementation of a
|
708
|
+
* [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only}
|
709
|
+
* request strategy.
|
710
|
+
*
|
711
|
+
* This class is useful if you want to take advantage of any
|
712
|
+
* [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}.
|
713
|
+
*
|
714
|
+
* If the network request fails, this will throw a `WorkboxError` exception.
|
715
|
+
*
|
716
|
+
* @memberof workbox.strategies
|
717
|
+
*/
|
718
|
+
|
719
|
+
class NetworkOnly {
|
720
|
+
/**
|
721
|
+
* @param {Object} options
|
722
|
+
* @param {string} options.cacheName Cache name to store and retrieve
|
723
|
+
* requests. Defaults to cache names provided by
|
724
|
+
* [workbox-core]{@link workbox.core.cacheNames}.
|
725
|
+
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
726
|
+
* to use in conjunction with this caching strategy.
|
727
|
+
* @param {Object} options.fetchOptions Values passed along to the
|
728
|
+
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
729
|
+
* of all fetch() requests made by this strategy.
|
730
|
+
*/
|
731
|
+
constructor(options = {}) {
|
732
|
+
this._plugins = options.plugins || [];
|
733
|
+
this._fetchOptions = options.fetchOptions;
|
734
|
+
}
|
735
|
+
/**
|
736
|
+
* This method will perform a request strategy and follows an API that
|
737
|
+
* will work with the
|
738
|
+
* [Workbox Router]{@link workbox.routing.Router}.
|
739
|
+
*
|
740
|
+
* @param {Object} options
|
741
|
+
* @param {Request} options.request The request to run this strategy for.
|
742
|
+
* @param {Event} [options.event] The event that triggered the request.
|
743
|
+
* @return {Promise<Response>}
|
744
|
+
*/
|
745
|
+
|
746
|
+
|
747
|
+
async handle({
|
748
|
+
event,
|
749
|
+
request
|
750
|
+
}) {
|
751
|
+
return this.makeRequest({
|
752
|
+
event,
|
753
|
+
request: request || event.request
|
754
|
+
});
|
755
|
+
}
|
756
|
+
/**
|
757
|
+
* This method can be used to perform a make a standalone request outside the
|
758
|
+
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
759
|
+
*
|
760
|
+
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
761
|
+
* for more usage information.
|
762
|
+
*
|
763
|
+
* @param {Object} options
|
764
|
+
* @param {Request|string} options.request Either a
|
765
|
+
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
766
|
+
* object, or a string URL, corresponding to the request to be made.
|
767
|
+
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
768
|
+
* be called automatically to extend the service worker's lifetime.
|
769
|
+
* @return {Promise<Response>}
|
770
|
+
*/
|
771
|
+
|
772
|
+
|
773
|
+
async makeRequest({
|
774
|
+
event,
|
775
|
+
request
|
776
|
+
}) {
|
777
|
+
if (typeof request === 'string') {
|
778
|
+
request = new Request(request);
|
779
|
+
}
|
780
|
+
|
781
|
+
{
|
782
|
+
assert_js.assert.isInstance(request, Request, {
|
783
|
+
moduleName: 'workbox-strategies',
|
784
|
+
className: 'NetworkOnly',
|
785
|
+
funcName: 'handle',
|
786
|
+
paramName: 'request'
|
787
|
+
});
|
788
|
+
}
|
789
|
+
|
790
|
+
let error;
|
791
|
+
let response;
|
792
|
+
|
793
|
+
try {
|
794
|
+
response = await fetchWrapper_js.fetchWrapper.fetch({
|
795
|
+
request,
|
796
|
+
event,
|
797
|
+
fetchOptions: this._fetchOptions,
|
798
|
+
plugins: this._plugins
|
799
|
+
});
|
800
|
+
} catch (err) {
|
801
|
+
error = err;
|
802
|
+
}
|
803
|
+
|
804
|
+
{
|
805
|
+
logger_js.logger.groupCollapsed(messages.strategyStart('NetworkOnly', request));
|
806
|
+
|
807
|
+
if (response) {
|
808
|
+
logger_js.logger.log(`Got response from network.`);
|
809
|
+
} else {
|
810
|
+
logger_js.logger.log(`Unable to get a response from the network.`);
|
811
|
+
}
|
812
|
+
|
813
|
+
messages.printFinalResponse(response);
|
814
|
+
logger_js.logger.groupEnd();
|
815
|
+
}
|
816
|
+
|
817
|
+
if (!response) {
|
818
|
+
throw new WorkboxError_js.WorkboxError('no-response', {
|
819
|
+
url: request.url,
|
820
|
+
error
|
821
|
+
});
|
822
|
+
}
|
823
|
+
|
824
|
+
return response;
|
825
|
+
}
|
826
|
+
|
827
|
+
}
|
828
|
+
|
829
|
+
/*
|
830
|
+
Copyright 2018 Google LLC
|
831
|
+
|
832
|
+
Use of this source code is governed by an MIT-style
|
833
|
+
license that can be found in the LICENSE file or at
|
834
|
+
https://opensource.org/licenses/MIT.
|
835
|
+
*/
|
836
|
+
/**
|
837
|
+
* An implementation of a
|
838
|
+
* [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate}
|
839
|
+
* request strategy.
|
840
|
+
*
|
841
|
+
* Resources are requested from both the cache and the network in parallel.
|
842
|
+
* The strategy will respond with the cached version if available, otherwise
|
843
|
+
* wait for the network response. The cache is updated with the network response
|
844
|
+
* with each successful request.
|
845
|
+
*
|
846
|
+
* By default, this strategy will cache responses with a 200 status code as
|
847
|
+
* well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}.
|
848
|
+
* Opaque responses are are cross-origin requests where the response doesn't
|
849
|
+
* support [CORS]{@link https://enable-cors.org/}.
|
850
|
+
*
|
851
|
+
* If the network request fails, and there is no cache match, this will throw
|
852
|
+
* a `WorkboxError` exception.
|
853
|
+
*
|
854
|
+
* @memberof workbox.strategies
|
855
|
+
*/
|
856
|
+
|
857
|
+
class StaleWhileRevalidate {
|
858
|
+
/**
|
859
|
+
* @param {Object} options
|
860
|
+
* @param {string} options.cacheName Cache name to store and retrieve
|
861
|
+
* requests. Defaults to cache names provided by
|
862
|
+
* [workbox-core]{@link workbox.core.cacheNames}.
|
863
|
+
* @param {Array<Object>} options.plugins [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}
|
864
|
+
* to use in conjunction with this caching strategy.
|
865
|
+
* @param {Object} options.fetchOptions Values passed along to the
|
866
|
+
* [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters)
|
867
|
+
* of all fetch() requests made by this strategy.
|
868
|
+
* @param {Object} options.matchOptions [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions)
|
869
|
+
*/
|
870
|
+
constructor(options = {}) {
|
871
|
+
this._cacheName = cacheNames_js.cacheNames.getRuntimeName(options.cacheName);
|
872
|
+
this._plugins = options.plugins || [];
|
873
|
+
|
874
|
+
if (options.plugins) {
|
875
|
+
let isUsingCacheWillUpdate = options.plugins.some(plugin => !!plugin.cacheWillUpdate);
|
876
|
+
this._plugins = isUsingCacheWillUpdate ? options.plugins : [cacheOkAndOpaquePlugin, ...options.plugins];
|
877
|
+
} else {
|
878
|
+
// No plugins passed in, use the default plugin.
|
879
|
+
this._plugins = [cacheOkAndOpaquePlugin];
|
880
|
+
}
|
881
|
+
|
882
|
+
this._fetchOptions = options.fetchOptions;
|
883
|
+
this._matchOptions = options.matchOptions;
|
884
|
+
}
|
885
|
+
/**
|
886
|
+
* This method will perform a request strategy and follows an API that
|
887
|
+
* will work with the
|
888
|
+
* [Workbox Router]{@link workbox.routing.Router}.
|
889
|
+
*
|
890
|
+
* @param {Object} options
|
891
|
+
* @param {Request} options.request The request to run this strategy for.
|
892
|
+
* @param {Event} [options.event] The event that triggered the request.
|
893
|
+
* @return {Promise<Response>}
|
894
|
+
*/
|
895
|
+
|
896
|
+
|
897
|
+
async handle({
|
898
|
+
event,
|
899
|
+
request
|
900
|
+
}) {
|
901
|
+
return this.makeRequest({
|
902
|
+
event,
|
903
|
+
request: request || event.request
|
904
|
+
});
|
905
|
+
}
|
906
|
+
/**
|
907
|
+
* This method can be used to perform a make a standalone request outside the
|
908
|
+
* context of the [Workbox Router]{@link workbox.routing.Router}.
|
909
|
+
*
|
910
|
+
* See "[Advanced Recipes](https://developers.google.com/web/tools/workbox/guides/advanced-recipes#make-requests)"
|
911
|
+
* for more usage information.
|
912
|
+
*
|
913
|
+
* @param {Object} options
|
914
|
+
* @param {Request|string} options.request Either a
|
915
|
+
* [`Request`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Request}
|
916
|
+
* object, or a string URL, corresponding to the request to be made.
|
917
|
+
* @param {FetchEvent} [options.event] If provided, `event.waitUntil()` will
|
918
|
+
* be called automatically to extend the service worker's lifetime.
|
919
|
+
* @return {Promise<Response>}
|
920
|
+
*/
|
921
|
+
|
922
|
+
|
923
|
+
async makeRequest({
|
924
|
+
event,
|
925
|
+
request
|
926
|
+
}) {
|
927
|
+
const logs = [];
|
928
|
+
|
929
|
+
if (typeof request === 'string') {
|
930
|
+
request = new Request(request);
|
931
|
+
}
|
932
|
+
|
933
|
+
{
|
934
|
+
assert_js.assert.isInstance(request, Request, {
|
935
|
+
moduleName: 'workbox-strategies',
|
936
|
+
className: 'StaleWhileRevalidate',
|
937
|
+
funcName: 'handle',
|
938
|
+
paramName: 'request'
|
939
|
+
});
|
940
|
+
}
|
941
|
+
|
942
|
+
const fetchAndCachePromise = this._getFromNetwork({
|
943
|
+
request,
|
944
|
+
event
|
945
|
+
});
|
946
|
+
|
947
|
+
let response = await cacheWrapper_js.cacheWrapper.match({
|
948
|
+
cacheName: this._cacheName,
|
949
|
+
request,
|
950
|
+
event,
|
951
|
+
matchOptions: this._matchOptions,
|
952
|
+
plugins: this._plugins
|
953
|
+
});
|
954
|
+
let error;
|
955
|
+
|
956
|
+
if (response) {
|
957
|
+
{
|
958
|
+
logs.push(`Found a cached response in the '${this._cacheName}'` + ` cache. Will update with the network response in the background.`);
|
959
|
+
}
|
960
|
+
|
961
|
+
if (event) {
|
962
|
+
try {
|
963
|
+
event.waitUntil(fetchAndCachePromise);
|
964
|
+
} catch (error) {
|
965
|
+
{
|
966
|
+
logger_js.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_js.getFriendlyURL(request.url)}'.`);
|
967
|
+
}
|
968
|
+
}
|
969
|
+
}
|
970
|
+
} else {
|
971
|
+
{
|
972
|
+
logs.push(`No response found in the '${this._cacheName}' cache. ` + `Will wait for the network response.`);
|
973
|
+
}
|
974
|
+
|
975
|
+
try {
|
976
|
+
response = await fetchAndCachePromise;
|
977
|
+
} catch (err) {
|
978
|
+
error = err;
|
979
|
+
}
|
980
|
+
}
|
981
|
+
|
982
|
+
{
|
983
|
+
logger_js.logger.groupCollapsed(messages.strategyStart('StaleWhileRevalidate', request));
|
984
|
+
|
985
|
+
for (let log of logs) {
|
986
|
+
logger_js.logger.log(log);
|
987
|
+
}
|
988
|
+
|
989
|
+
messages.printFinalResponse(response);
|
990
|
+
logger_js.logger.groupEnd();
|
991
|
+
}
|
992
|
+
|
993
|
+
if (!response) {
|
994
|
+
throw new WorkboxError_js.WorkboxError('no-response', {
|
995
|
+
url: request.url,
|
996
|
+
error
|
997
|
+
});
|
998
|
+
}
|
999
|
+
|
1000
|
+
return response;
|
1001
|
+
}
|
1002
|
+
/**
|
1003
|
+
* @param {Object} options
|
1004
|
+
* @param {Request} options.request
|
1005
|
+
* @param {Event} [options.event]
|
1006
|
+
* @return {Promise<Response>}
|
1007
|
+
*
|
1008
|
+
* @private
|
1009
|
+
*/
|
1010
|
+
|
1011
|
+
|
1012
|
+
async _getFromNetwork({
|
1013
|
+
request,
|
1014
|
+
event
|
1015
|
+
}) {
|
1016
|
+
const response = await fetchWrapper_js.fetchWrapper.fetch({
|
1017
|
+
request,
|
1018
|
+
event,
|
1019
|
+
fetchOptions: this._fetchOptions,
|
1020
|
+
plugins: this._plugins
|
1021
|
+
});
|
1022
|
+
const cachePutPromise = cacheWrapper_js.cacheWrapper.put({
|
1023
|
+
cacheName: this._cacheName,
|
1024
|
+
request,
|
1025
|
+
response: response.clone(),
|
1026
|
+
event,
|
1027
|
+
plugins: this._plugins
|
1028
|
+
});
|
1029
|
+
|
1030
|
+
if (event) {
|
1031
|
+
try {
|
1032
|
+
event.waitUntil(cachePutPromise);
|
1033
|
+
} catch (error) {
|
1034
|
+
{
|
1035
|
+
logger_js.logger.warn(`Unable to ensure service worker stays alive when ` + `updating cache for '${getFriendlyURL_js.getFriendlyURL(request.url)}'.`);
|
1036
|
+
}
|
1037
|
+
}
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
return response;
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
/*
|
1046
|
+
Copyright 2018 Google LLC
|
1047
|
+
|
1048
|
+
Use of this source code is governed by an MIT-style
|
1049
|
+
license that can be found in the LICENSE file or at
|
1050
|
+
https://opensource.org/licenses/MIT.
|
1051
|
+
*/
|
1052
|
+
const mapping = {
|
1053
|
+
cacheFirst: CacheFirst,
|
1054
|
+
cacheOnly: CacheOnly,
|
1055
|
+
networkFirst: NetworkFirst,
|
1056
|
+
networkOnly: NetworkOnly,
|
1057
|
+
staleWhileRevalidate: StaleWhileRevalidate
|
1058
|
+
};
|
1059
|
+
|
1060
|
+
const deprecate = strategy => {
|
1061
|
+
const StrategyCtr = mapping[strategy];
|
1062
|
+
return options => {
|
1063
|
+
{
|
1064
|
+
const strategyCtrName = strategy[0].toUpperCase() + strategy.slice(1);
|
1065
|
+
logger_js.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.`);
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
return new StrategyCtr(options);
|
1069
|
+
};
|
1070
|
+
};
|
1071
|
+
/**
|
1072
|
+
* @function workbox.strategies.cacheFirst
|
1073
|
+
* @param {Object} options See the {@link workbox.strategies.CacheFirst}
|
1074
|
+
* constructor for more info.
|
1075
|
+
* @deprecated since v4.0.0
|
1076
|
+
*/
|
1077
|
+
|
1078
|
+
|
1079
|
+
const cacheFirst = deprecate('cacheFirst');
|
1080
|
+
/**
|
1081
|
+
* @function workbox.strategies.cacheOnly
|
1082
|
+
* @param {Object} options See the {@link workbox.strategies.CacheOnly}
|
1083
|
+
* constructor for more info.
|
1084
|
+
* @deprecated since v4.0.0
|
1085
|
+
*/
|
1086
|
+
|
1087
|
+
const cacheOnly = deprecate('cacheOnly');
|
1088
|
+
/**
|
1089
|
+
* @function workbox.strategies.networkFirst
|
1090
|
+
* @param {Object} options See the {@link workbox.strategies.NetworkFirst}
|
1091
|
+
* constructor for more info.
|
1092
|
+
* @deprecated since v4.0.0
|
1093
|
+
*/
|
1094
|
+
|
1095
|
+
const networkFirst = deprecate('networkFirst');
|
1096
|
+
/**
|
1097
|
+
* @function workbox.strategies.networkOnly
|
1098
|
+
* @param {Object} options See the {@link workbox.strategies.NetworkOnly}
|
1099
|
+
* constructor for more info.
|
1100
|
+
* @deprecated since v4.0.0
|
1101
|
+
*/
|
1102
|
+
|
1103
|
+
const networkOnly = deprecate('networkOnly');
|
1104
|
+
/**
|
1105
|
+
* @function workbox.strategies.staleWhileRevalidate
|
1106
|
+
* @param {Object} options See the
|
1107
|
+
* {@link workbox.strategies.StaleWhileRevalidate} constructor for more info.
|
1108
|
+
* @deprecated since v4.0.0
|
1109
|
+
*/
|
1110
|
+
|
1111
|
+
const staleWhileRevalidate = deprecate('staleWhileRevalidate');
|
1112
|
+
|
1113
|
+
exports.CacheFirst = CacheFirst;
|
1114
|
+
exports.CacheOnly = CacheOnly;
|
1115
|
+
exports.NetworkFirst = NetworkFirst;
|
1116
|
+
exports.NetworkOnly = NetworkOnly;
|
1117
|
+
exports.StaleWhileRevalidate = StaleWhileRevalidate;
|
1118
|
+
exports.cacheFirst = cacheFirst;
|
1119
|
+
exports.cacheOnly = cacheOnly;
|
1120
|
+
exports.networkFirst = networkFirst;
|
1121
|
+
exports.networkOnly = networkOnly;
|
1122
|
+
exports.staleWhileRevalidate = staleWhileRevalidate;
|
1123
|
+
|
1124
|
+
return exports;
|
1125
|
+
|
1126
|
+
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
|
1127
|
+
//# sourceMappingURL=workbox-strategies.dev.js.map
|