1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3/******/ var __webpack_modules__ = ({ 4 5/***/ 913: 6/***/ (() => { 7 8 9// @ts-ignore 10try { 11 self['workbox:core:6.1.5'] && _(); 12} 13catch (e) { } 14 15 16/***/ }), 17 18/***/ 550: 19/***/ (() => { 20 21 22// @ts-ignore 23try { 24 self['workbox:expiration:6.1.5'] && _(); 25} 26catch (e) { } 27 28 29/***/ }), 30 31/***/ 977: 32/***/ (() => { 33 34 35// @ts-ignore 36try { 37 self['workbox:precaching:6.1.5'] && _(); 38} 39catch (e) { } 40 41 42/***/ }), 43 44/***/ 80: 45/***/ (() => { 46 47 48// @ts-ignore 49try { 50 self['workbox:routing:6.1.5'] && _(); 51} 52catch (e) { } 53 54 55/***/ }), 56 57/***/ 873: 58/***/ (() => { 59 60 61// @ts-ignore 62try { 63 self['workbox:strategies:6.1.5'] && _(); 64} 65catch (e) { } 66 67 68/***/ }) 69 70/******/ }); 71/************************************************************************/ 72/******/ // The module cache 73/******/ var __webpack_module_cache__ = {}; 74/******/ 75/******/ // The require function 76/******/ function __webpack_require__(moduleId) { 77/******/ // Check if module is in cache 78/******/ var cachedModule = __webpack_module_cache__[moduleId]; 79/******/ if (cachedModule !== undefined) { 80/******/ return cachedModule.exports; 81/******/ } 82/******/ // Create a new module (and put it into the cache) 83/******/ var module = __webpack_module_cache__[moduleId] = { 84/******/ // no module.id needed 85/******/ // no module.loaded needed 86/******/ exports: {} 87/******/ }; 88/******/ 89/******/ // Execute the module function 90/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 91/******/ 92/******/ // Return the exports of the module 93/******/ return module.exports; 94/******/ } 95/******/ 96/************************************************************************/ 97var __webpack_exports__ = {}; 98// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 99(() => { 100 101// EXTERNAL MODULE: ./node_modules/workbox-core/_version.js 102var _version = __webpack_require__(913); 103;// CONCATENATED MODULE: ./node_modules/workbox-core/models/messages/messages.js 104/* 105 Copyright 2018 Google LLC 106 107 Use of this source code is governed by an MIT-style 108 license that can be found in the LICENSE file or at 109 https://opensource.org/licenses/MIT. 110*/ 111 112const messages_messages = { 113 'invalid-value': ({ paramName, validValueDescription, value }) => { 114 if (!paramName || !validValueDescription) { 115 throw new Error(`Unexpected input to 'invalid-value' error.`); 116 } 117 return `The '${paramName}' parameter was given a value with an ` + 118 `unexpected value. ${validValueDescription} Received a value of ` + 119 `${JSON.stringify(value)}.`; 120 }, 121 'not-an-array': ({ moduleName, className, funcName, paramName }) => { 122 if (!moduleName || !className || !funcName || !paramName) { 123 throw new Error(`Unexpected input to 'not-an-array' error.`); 124 } 125 return `The parameter '${paramName}' passed into ` + 126 `'${moduleName}.${className}.${funcName}()' must be an array.`; 127 }, 128 'incorrect-type': ({ expectedType, paramName, moduleName, className, funcName }) => { 129 if (!expectedType || !paramName || !moduleName || !funcName) { 130 throw new Error(`Unexpected input to 'incorrect-type' error.`); 131 } 132 return `The parameter '${paramName}' passed into ` + 133 `'${moduleName}.${className ? (className + '.') : ''}` + 134 `${funcName}()' must be of type ${expectedType}.`; 135 }, 136 'incorrect-class': ({ expectedClass, paramName, moduleName, className, funcName, isReturnValueProblem }) => { 137 if (!expectedClass || !moduleName || !funcName) { 138 throw new Error(`Unexpected input to 'incorrect-class' error.`); 139 } 140 if (isReturnValueProblem) { 141 return `The return value from ` + 142 `'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` + 143 `must be an instance of class ${expectedClass.name}.`; 144 } 145 return `The parameter '${paramName}' passed into ` + 146 `'${moduleName}.${className ? (className + '.') : ''}${funcName}()' ` + 147 `must be an instance of class ${expectedClass.name}.`; 148 }, 149 'missing-a-method': ({ expectedMethod, paramName, moduleName, className, funcName }) => { 150 if (!expectedMethod || !paramName || !moduleName || !className 151 || !funcName) { 152 throw new Error(`Unexpected input to 'missing-a-method' error.`); 153 } 154 return `${moduleName}.${className}.${funcName}() expected the ` + 155 `'${paramName}' parameter to expose a '${expectedMethod}' method.`; 156 }, 157 'add-to-cache-list-unexpected-type': ({ entry }) => { 158 return `An unexpected entry was passed to ` +
vendor: 7,469 bytes, lines 159-308
159 `'workbox-precaching.PrecacheController.addToCacheList()' The entry ` + 160 `'${JSON.stringify(entry)}' isn't supported. You must supply an array of ` + 161 `strings with one or more characters, objects with a url property or ` + 162 `Request objects.`; 163 }, 164 'add-to-cache-list-conflicting-entries': ({ firstEntry, secondEntry }) => { 165 if (!firstEntry || !secondEntry) { 166 throw new Error(`Unexpected input to ` + 167 `'add-to-cache-list-duplicate-entries' error.`); 168 } 169 return `Two of the entries passed to ` + 170 `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + 171 `${firstEntry._entryId} but different revision details. Workbox is ` + 172 `unable to cache and version the asset correctly. Please remove one ` + 173 `of the entries.`; 174 }, 175 'plugin-error-request-will-fetch': ({ thrownError }) => { 176 if (!thrownError) { 177 throw new Error(`Unexpected input to ` + 178 `'plugin-error-request-will-fetch', error.`); 179 } 180 return `An error was thrown by a plugins 'requestWillFetch()' method. ` + 181 `The thrown error message was: '${thrownError.message}'.`; 182 }, 183 'invalid-cache-name': ({ cacheNameId, value }) => { 184 if (!cacheNameId) { 185 throw new Error(`Expected a 'cacheNameId' for error 'invalid-cache-name'`); 186 } 187 return `You must provide a name containing at least one character for ` + 188 `setCacheDetails({${cacheNameId}: '...'}). Received a value of ` + 189 `'${JSON.stringify(value)}'`; 190 }, 191 'unregister-route-but-not-found-with-method': ({ method }) => { 192 if (!method) { 193 throw new Error(`Unexpected input to ` + 194 `'unregister-route-but-not-found-with-method' error.`); 195 } 196 return `The route you're trying to unregister was not previously ` + 197 `registered for the method type '${method}'.`; 198 }, 199 'unregister-route-route-not-registered': () => { 200 return `The route you're trying to unregister was not previously ` + 201 `registered.`; 202 }, 203 'queue-replay-failed': ({ name }) => { 204 return `Replaying the background sync queue '${name}' failed.`; 205 }, 206 'duplicate-queue-name': ({ name }) => { 207 return `The Queue name '${name}' is already being used. ` + 208 `All instances of backgroundSync.Queue must be given unique names.`; 209 }, 210 'expired-test-without-max-age': ({ methodName, paramName }) => { 211 return `The '${methodName}()' method can only be used when the ` + 212 `'${paramName}' is used in the constructor.`; 213 }, 214 'unsupported-route-type': ({ moduleName, className, funcName, paramName }) => { 215 return `The supplied '${paramName}' parameter was an unsupported type. ` + 216 `Please check the docs for ${moduleName}.${className}.${funcName} for ` + 217 `valid input types.`; 218 }, 219 'not-array-of-class': ({ value, expectedClass, moduleName, className, funcName, paramName }) => { 220 return `The supplied '${paramName}' parameter must be an array of ` + 221 `'${expectedClass}' objects. Received '${JSON.stringify(value)},'. ` + 222 `Please check the call to ${moduleName}.${className}.${funcName}() ` + 223 `to fix the issue.`; 224 }, 225 'max-entries-or-age-required': ({ moduleName, className, funcName }) => { 226 return `You must define either config.maxEntries or config.maxAgeSeconds` + 227 `in ${moduleName}.${className}.${funcName}`; 228 }, 229 'statuses-or-headers-required': ({ moduleName, className, funcName }) => { 230 return `You must define either config.statuses or config.headers` + 231 `in ${moduleName}.${className}.${funcName}`; 232 }, 233 'invalid-string': ({ moduleName, funcName, paramName }) => { 234 if (!paramName || !moduleName || !funcName) { 235 throw new Error(`Unexpected input to 'invalid-string' error.`); 236 } 237 return `When using strings, the '${paramName}' parameter must start with ` + 238 `'http' (for cross-origin matches) or '/' (for same-origin matches). ` + 239 `Please see the docs for ${moduleName}.${funcName}() for ` + 240 `more info.`; 241 }, 242 'channel-name-required': () => { 243 return `You must provide a channelName to construct a ` + 244 `BroadcastCacheUpdate instance.`; 245 }, 246 'invalid-responses-are-same-args': () => { 247 return `The arguments passed into responsesAreSame() appear to be ` + 248 `invalid. Please ensure valid Responses are used.`; 249 }, 250 'expire-custom-caches-only': () => { 251 return `You must provide a 'cacheName' property when using the ` + 252 `expiration plugin with a runtime caching strategy.`; 253 }, 254 'unit-must-be-bytes': ({ normalizedRangeHeader }) => { 255 if (!normalizedRangeHeader) { 256 throw new Error(`Unexpected input to 'unit-must-be-bytes' error.`); 257 } 258 return `The 'unit' portion of the Range header must be set to 'bytes'. ` + 259 `The Range header provided was "${normalizedRangeHeader}"`; 260 }, 261 'single-range-only': ({ normalizedRangeHeader }) => { 262 if (!normalizedRangeHeader) { 263 throw new Error(`Unexpected input to 'single-range-only' error.`); 264 } 265 return `Multiple ranges are not supported. Please use a single start ` + 266 `value, and optional end value. The Range header provided was ` + 267 `"${normalizedRangeHeader}"`; 268 }, 269 'invalid-range-values': ({ normalizedRangeHeader }) => { 270 if (!normalizedRangeHeader) { 271 throw new Error(`Unexpected input to 'invalid-range-values' error.`); 272 } 273 return `The Range header is missing both start and end values. At least ` + 274 `one of those values is needed. The Range header provided was ` + 275 `"${normalizedRangeHeader}"`; 276 }, 277 'no-range-header': () => { 278 return `No Range header was found in the Request provided.`; 279 }, 280 'range-not-satisfiable': ({ size, start, end }) => { 281 return `The start (${start}) and end (${end}) values in the Range are ` + 282 `not satisfiable by the cached response, which is ${size} bytes.`; 283 }, 284 'attempt-to-cache-non-get-request': ({ url, method }) => { 285 return `Unable to cache '${url}' because it is a '${method}' request and ` + 286 `only 'GET' requests can be cached.`; 287 }, 288 'cache-put-with-no-response': ({ url }) => { 289 return `There was an attempt to cache '${url}' but the response was not ` + 290 `defined.`; 291 }, 292 'no-response': ({ url, error }) => { 293 let message = `The strategy could not generate a response for '${url}'.`; 294 if (error) { 295 message += ` The underlying error is ${error}.`; 296 } 297 return message; 298 }, 299 'bad-precaching-response': ({ url, status }) => { 300 return `The precaching request for '${url}' failed` + 301 (status ? ` with an HTTP status of ${status}.` : `.`); 302 }, 303 'non-precached-url': ({ url }) => { 304 return `createHandlerBoundToURL('${url}') was called, but that URL is ` + 305 `not precached. Please pass in a URL that is precached instead.`; 306 }, 307 'add-to-cache-list-conflicting-integrities': ({ url }) => { 308 return `Two of the entries passed to ` +
309 `'workbox-precaching.PrecacheController.addToCacheList()' had the URL ` + 310 `${url} with different integrity values. Please remove one of them.`; 311 }, 312 'missing-precache-entry': ({ cacheName, url }) => { 313 return `Unable to find a precached response in ${cacheName} for ${url}.`; 314 }, 315 'cross-origin-copy-response': ({ origin }) => { 316 return `workbox-core.copyResponse() can only be used with same-origin ` + 317 `responses. It was passed a response with origin ${origin}.`; 318 }, 319}; 320 321;// CONCATENATED MODULE: ./node_modules/workbox-core/models/messages/messageGenerator.js 322/* 323 Copyright 2018 Google LLC 324 325 Use of this source code is governed by an MIT-style 326 license that can be found in the LICENSE file or at 327 https://opensource.org/licenses/MIT. 328*/ 329 330 331const fallback = (code, ...args) => { 332 let msg = code; 333 if (args.length > 0) { 334 msg += ` :: ${JSON.stringify(args)}`; 335 } 336 return msg; 337}; 338const generatorFunction = (code, details = {}) => { 339 const message = messages[code]; 340 if (!message) { 341 throw new Error(`Unable to find message for code '${code}'.`); 342 } 343 return message(details); 344}; 345const messageGenerator = ( true) ? 346 fallback : 0; 347 348;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/WorkboxError.js 349/* 350 Copyright 2018 Google LLC 351 352 Use of this source code is governed by an MIT-style 353 license that can be found in the LICENSE file or at 354 https://opensource.org/licenses/MIT. 355*/ 356 357 358/** 359 * Workbox errors should be thrown with this class. 360 * This allows use to ensure the type easily in tests, 361 * helps developers identify errors from workbox 362 * easily and allows use to optimise error 363 * messages correctly. 364 * 365 * @private 366 */ 367class WorkboxError_WorkboxError extends Error { 368 /** 369 * 370 * @param {string} errorCode The error code that 371 * identifies this particular error. 372 * @param {Object=} details Any relevant arguments 373 * that will help developers identify issues should 374 * be added as a key on the context object. 375 */ 376 constructor(errorCode, details) { 377 const message = messageGenerator(errorCode, details); 378 super(message); 379 this.name = errorCode; 380 this.details = details; 381 } 382} 383 384 385;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/assert.js 386/* 387 Copyright 2018 Google LLC 388 389 Use of this source code is governed by an MIT-style 390 license that can be found in the LICENSE file or at 391 https://opensource.org/licenses/MIT. 392*/ 393 394 395/* 396 * This method throws if the supplied value is not an array. 397 * The destructed values are required to produce a meaningful error for users. 398 * The destructed and restructured object is so it's clear what is 399 * needed. 400 */ 401const isArray = (value, details) => { 402 if (!Array.isArray(value)) { 403 throw new WorkboxError('not-an-array', details); 404 } 405}; 406const hasMethod = (object, expectedMethod, details) => { 407 const type = typeof object[expectedMethod]; 408 if (type !== 'function') { 409 details['expectedMethod'] = expectedMethod; 410 throw new WorkboxError('missing-a-method', details); 411 } 412}; 413const isType = (object, expectedType, details) => { 414 if (typeof object !== expectedType) { 415 details['expectedType'] = expectedType; 416 throw new WorkboxError('incorrect-type', details); 417 } 418}; 419const isInstance = (object, expectedClass, details) => { 420 if (!(object instanceof expectedClass)) { 421 details['expectedClass'] = expectedClass; 422 throw new WorkboxError('incorrect-class', details); 423 } 424}; 425const isOneOf = (value, validValues, details) => { 426 if (!validValues.includes(value)) { 427 details['validValueDescription'] = 428 `Valid values are ${JSON.stringify(validValues)}.`; 429 throw new WorkboxError('invalid-value', details); 430 } 431}; 432const isArrayOfClass = (value, expectedClass, details) => { 433 const error = new WorkboxError('not-array-of-class', details); 434 if (!Array.isArray(value)) { 435 throw error; 436 } 437 for (const item of value) { 438 if (!(item instanceof expectedClass)) { 439 throw error; 440 } 441 } 442}; 443const finalAssertExports = true ? null : 0; 444 445 446;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/cacheNames.js 447/* 448 Copyright 2018 Google LLC 449 450 Use of this source code is governed by an MIT-style 451 license that can be found in the LICENSE file or at 452 https://opensource.org/licenses/MIT.
453*/ 454 455const _cacheNameDetails = { 456 googleAnalytics: 'googleAnalytics', 457 precache: 'precache-v2', 458 prefix: 'workbox', 459 runtime: 'runtime', 460 suffix: typeof registration !== 'undefined' ? registration.scope : '', 461}; 462const _createCacheName = (cacheName) => { 463 return [_cacheNameDetails.prefix, cacheName, _cacheNameDetails.suffix] 464 .filter((value) => value && value.length > 0) 465 .join('-'); 466}; 467const eachCacheNameDetail = (fn) => { 468 for (const key of Object.keys(_cacheNameDetails)) { 469 fn(key); 470 } 471}; 472const cacheNames_cacheNames = { 473 updateDetails: (details) => { 474 eachCacheNameDetail((key) => { 475 if (typeof details[key] === 'string') { 476 _cacheNameDetails[key] = details[key]; 477 } 478 }); 479 }, 480 getGoogleAnalyticsName: (userCacheName) => { 481 return userCacheName || _createCacheName(_cacheNameDetails.googleAnalytics); 482 }, 483 getPrecacheName: (userCacheName) => { 484 return userCacheName || _createCacheName(_cacheNameDetails.precache); 485 }, 486 getPrefix: () => { 487 return _cacheNameDetails.prefix; 488 }, 489 getRuntimeName: (userCacheName) => { 490 return userCacheName || _createCacheName(_cacheNameDetails.runtime); 491 }, 492 getSuffix: () => { 493 return _cacheNameDetails.suffix; 494 }, 495}; 496 497;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/logger.js 498/* 499 Copyright 2019 Google LLC 500 Use of this source code is governed by an MIT-style 501 license that can be found in the LICENSE file or at 502 https://opensource.org/licenses/MIT. 503*/ 504 505const logger_logger = ( true ? null : 0); 506 507 508;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/waitUntil.js 509/* 510 Copyright 2020 Google LLC 511 Use of this source code is governed by an MIT-style 512 license that can be found in the LICENSE file or at 513 https://opensource.org/licenses/MIT. 514*/ 515 516/** 517 * A utility method that makes it easier to use `event.waitUntil` with 518 * async functions and return the result. 519 * 520 * @param {ExtendableEvent} event 521 * @param {Function} asyncFn 522 * @return {Function} 523 * @private 524 */ 525function waitUntil(event, asyncFn) { 526 const returnPromise = asyncFn(); 527 event.waitUntil(returnPromise); 528 return returnPromise; 529} 530 531 532// EXTERNAL MODULE: ./node_modules/workbox-precaching/_version.js 533var workbox_precaching_version = __webpack_require__(977); 534;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/createCacheKey.js 535/* 536 Copyright 2018 Google LLC 537 538 Use of this source code is governed by an MIT-style 539 license that can be found in the LICENSE file or at 540 https://opensource.org/licenses/MIT. 541*/ 542 543 544// Name of the search parameter used to store revision info. 545const REVISION_SEARCH_PARAM = '__WB_REVISION__'; 546/** 547 * Converts a manifest entry into a versioned URL suitable for precaching. 548 * 549 * @param {Object|string} entry 550 * @return {string} A URL with versioning info. 551 * 552 * @private 553 * @memberof module:workbox-precaching 554 */ 555function createCacheKey(entry) { 556 if (!entry) { 557 throw new WorkboxError_WorkboxError('add-to-cache-list-unexpected-type', { entry }); 558 } 559 // If a precache manifest entry is a string, it's assumed to be a versioned 560 // URL, like '/app.abcd1234.js'. Return as-is. 561 if (typeof entry === 'string') { 562 const urlObject = new URL(entry, location.href); 563 return { 564 cacheKey: urlObject.href, 565 url: urlObject.href, 566 }; 567 } 568 const { revision, url } = entry; 569 if (!url) { 570 throw new WorkboxError_WorkboxError('add-to-cache-list-unexpected-type', { entry }); 571 } 572 // If there's just a URL and no revision, then it's also assumed to be a 573 // versioned URL. 574 if (!revision) { 575 const urlObject = new URL(url, location.href); 576 return { 577 cacheKey: urlObject.href, 578 url: urlObject.href, 579 }; 580 } 581 // Otherwise, construct a properly versioned URL using the custom Workbox 582 // search parameter along with the revision info. 583 const cacheKeyURL = new URL(url, location.href); 584 const originalURL = new URL(url, location.href); 585 cacheKeyURL.searchParams.set(REVISION_SEARCH_PARAM, revision); 586 return { 587 cacheKey: cacheKeyURL.href, 588 url: originalURL.href, 589 }; 590} 591 592;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/PrecacheInstallReportPlugin.js 593/* 594 Copyright 2020 Google LLC 595 596 Use of this source code is governed by an MIT-style 597 license that can be found in the LICENSE file or at 598 https://opensource.org/licenses/MIT.
599*/ 600 601/** 602 * A plugin, designed to be used with PrecacheController, to determine the 603 * of assets that were updated (or not updated) during the install event. 604 * 605 * @private 606 */ 607class PrecacheInstallReportPlugin { 608 constructor() { 609 this.updatedURLs = []; 610 this.notUpdatedURLs = []; 611 this.handlerWillStart = async ({ request, state, }) => { 612 // TODO: `state` should never be undefined... 613 if (state) { 614 state.originalRequest = request; 615 } 616 }; 617 this.cachedResponseWillBeUsed = async ({ event, state, cachedResponse, }) => { 618 if (event.type === 'install') { 619 // TODO: `state` should never be undefined... 620 const url = state.originalRequest.url; 621 if (cachedResponse) { 622 this.notUpdatedURLs.push(url); 623 } 624 else { 625 this.updatedURLs.push(url); 626 } 627 } 628 return cachedResponse; 629 }; 630 } 631} 632 633 634;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/PrecacheCacheKeyPlugin.js 635/* 636 Copyright 2020 Google LLC 637 638 Use of this source code is governed by an MIT-style 639 license that can be found in the LICENSE file or at 640 https://opensource.org/licenses/MIT. 641*/ 642 643/** 644 * A plugin, designed to be used with PrecacheController, to translate URLs into 645 * the corresponding cache key, based on the current revision info. 646 * 647 * @private 648 */ 649class PrecacheCacheKeyPlugin { 650 constructor({ precacheController }) { 651 this.cacheKeyWillBeUsed = async ({ request, params, }) => { 652 const cacheKey = params && params.cacheKey || 653 this._precacheController.getCacheKeyForURL(request.url); 654 return cacheKey ? new Request(cacheKey) : request; 655 }; 656 this._precacheController = precacheController; 657 } 658} 659 660 661;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/printCleanupDetails.js 662/* 663 Copyright 2018 Google LLC 664 665 Use of this source code is governed by an MIT-style 666 license that can be found in the LICENSE file or at 667 https://opensource.org/licenses/MIT. 668*/ 669 670 671/** 672 * @param {string} groupTitle 673 * @param {Array<string>} deletedURLs 674 * 675 * @private 676 */ 677const logGroup = (groupTitle, deletedURLs) => { 678 logger.groupCollapsed(groupTitle); 679 for (const url of deletedURLs) { 680 logger.log(url); 681 } 682 logger.groupEnd(); 683}; 684/** 685 * @param {Array<string>} deletedURLs 686 * 687 * @private 688 * @memberof module:workbox-precaching 689 */ 690function printCleanupDetails(deletedURLs) { 691 const deletionCount = deletedURLs.length; 692 if (deletionCount > 0) { 693 logger.groupCollapsed(`During precaching cleanup, ` + 694 `${deletionCount} cached ` + 695 `request${deletionCount === 1 ? ' was' : 's were'} deleted.`); 696 logGroup('Deleted Cache Requests', deletedURLs); 697 logger.groupEnd(); 698 } 699} 700 701;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/printInstallDetails.js 702/* 703 Copyright 2018 Google LLC 704 705 Use of this source code is governed by an MIT-style 706 license that can be found in the LICENSE file or at 707 https://opensource.org/licenses/MIT. 708*/ 709 710 711/** 712 * @param {string} groupTitle 713 * @param {Array<string>} urls 714 * 715 * @private 716 */ 717function _nestedGroup(groupTitle, urls) { 718 if (urls.length === 0) { 719 return; 720 } 721 logger.groupCollapsed(groupTitle); 722 for (const url of urls) { 723 logger.log(url); 724 } 725 logger.groupEnd(); 726} 727/** 728 * @param {Array<string>} urlsToPrecache 729 * @param {Array<string>} urlsAlreadyPrecached 730 * 731 * @private 732 * @memberof module:workbox-precaching 733 */ 734function printInstallDetails(urlsToPrecache, urlsAlreadyPrecached) { 735 const precachedCount = urlsToPrecache.length; 736 const alreadyPrecachedCount = urlsAlreadyPrecached.length; 737 if (precachedCount || alreadyPrecachedCount) { 738 let message = `Precaching ${precachedCount} file${precachedCount === 1 ? '' : 's'}.`; 739 if (alreadyPrecachedCount > 0) { 740 message += ` ${alreadyPrecachedCount} ` + 741 `file${alreadyPrecachedCount === 1 ? ' is' : 's are'} already cached.`; 742 } 743 logger.groupCollapsed(message); 744 _nestedGroup(`View newly precached URLs.`, urlsToPrecache); 745 _nestedGroup(`View previously precached URLs.`, urlsAlreadyPrecached); 746 logger.groupEnd(); 747 } 748} 749 750;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/canConstructResponseFromBodyStream.js 751/* 752 Copyright 2019 Google LLC 753 754 Use of this source code is governed by an MIT-style 755 license that can be found in the LICENSE file or at 756 https://opensource.org/licenses/MIT.
vendor: 4,093 bytes, lines 757-872
757*/ 758 759let supportStatus; 760/** 761 * A utility function that determines whether the current browser supports 762 * constructing a new `Response` from a `response.body` stream. 763 * 764 * @return {boolean} `true`, if the current browser can successfully 765 * construct a `Response` from a `response.body` stream, `false` otherwise. 766 * 767 * @private 768 */ 769function canConstructResponseFromBodyStream() { 770 if (supportStatus === undefined) { 771 const testResponse = new Response(''); 772 if ('body' in testResponse) { 773 try { 774 new Response(testResponse.body); 775 supportStatus = true; 776 } 777 catch (error) { 778 supportStatus = false; 779 } 780 } 781 supportStatus = false; 782 } 783 return supportStatus; 784} 785 786 787;// CONCATENATED MODULE: ./node_modules/workbox-core/copyResponse.js 788/* 789 Copyright 2019 Google LLC 790 791 Use of this source code is governed by an MIT-style 792 license that can be found in the LICENSE file or at 793 https://opensource.org/licenses/MIT. 794*/ 795 796 797 798/** 799 * Allows developers to copy a response and modify its `headers`, `status`, 800 * or `statusText` values (the values settable via a 801 * [`ResponseInit`]{@link https://developer.mozilla.org/en-US/docs/Web/API/Response/Response#Syntax} 802 * object in the constructor). 803 * To modify these values, pass a function as the second argument. That 804 * function will be invoked with a single object with the response properties 805 * `{headers, status, statusText}`. The return value of this function will 806 * be used as the `ResponseInit` for the new `Response`. To change the values 807 * either modify the passed parameter(s) and return it, or return a totally 808 * new object. 809 * 810 * This method is intentionally limited to same-origin responses, regardless of 811 * whether CORS was used or not. 812 * 813 * @param {Response} response 814 * @param {Function} modifier 815 * @memberof module:workbox-core 816 */ 817async function copyResponse(response, modifier) { 818 let origin = null; 819 // If response.url isn't set, assume it's cross-origin and keep origin null. 820 if (response.url) { 821 const responseURL = new URL(response.url); 822 origin = responseURL.origin; 823 } 824 if (origin !== self.location.origin) { 825 throw new WorkboxError_WorkboxError('cross-origin-copy-response', { origin }); 826 } 827 const clonedResponse = response.clone(); 828 // Create a fresh `ResponseInit` object by cloning the headers. 829 const responseInit = { 830 headers: new Headers(clonedResponse.headers), 831 status: clonedResponse.status, 832 statusText: clonedResponse.statusText, 833 }; 834 // Apply any user modifications. 835 const modifiedResponseInit = modifier ? modifier(responseInit) : responseInit; 836 // Create the new response from the body stream and `ResponseInit` 837 // modifications. Note: not all browsers support the Response.body stream, 838 // so fall back to reading the entire body into memory as a blob. 839 const body = canConstructResponseFromBodyStream() ? 840 clonedResponse.body : await clonedResponse.blob(); 841 return new Response(body, modifiedResponseInit); 842} 843 844 845;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/getFriendlyURL.js 846/* 847 Copyright 2018 Google LLC 848 849 Use of this source code is governed by an MIT-style 850 license that can be found in the LICENSE file or at 851 https://opensource.org/licenses/MIT. 852*/ 853 854const getFriendlyURL = (url) => { 855 const urlObj = new URL(String(url), location.href); 856 // See https://github.com/GoogleChrome/workbox/issues/2323 857 // We want to include everything, except for the origin if it's same-origin. 858 return urlObj.href.replace(new RegExp(`^${location.origin}`), ''); 859}; 860 861 862;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/cacheMatchIgnoreParams.js 863/* 864 Copyright 2020 Google LLC 865 Use of this source code is governed by an MIT-style 866 license that can be found in the LICENSE file or at 867 https://opensource.org/licenses/MIT. 868*/ 869 870function stripParams(fullURL, ignoreParams) { 871 const strippedURL = new URL(fullURL); 872 for (const param of ignoreParams) {
873 strippedURL.searchParams.delete(param); 874 } 875 return strippedURL.href; 876} 877/** 878 * Matches an item in the cache, ignoring specific URL params. This is similar 879 * to the `ignoreSearch` option, but it allows you to ignore just specific 880 * params (while continuing to match on the others). 881 * 882 * @private 883 * @param {Cache} cache 884 * @param {Request} request 885 * @param {Object} matchOptions 886 * @param {Array<string>} ignoreParams 887 * @return {Promise<Response|undefined>} 888 */ 889async function cacheMatchIgnoreParams(cache, request, ignoreParams, matchOptions) { 890 const strippedRequestURL = stripParams(request.url, ignoreParams); 891 // If the request doesn't include any ignored params, match as normal. 892 if (request.url === strippedRequestURL) { 893 return cache.match(request, matchOptions); 894 } 895 // Otherwise, match by comparing keys 896 const keysOptions = { ...matchOptions, ignoreSearch: true }; 897 const cacheKeys = await cache.keys(request, keysOptions); 898 for (const cacheKey of cacheKeys) { 899 const strippedCacheKeyURL = stripParams(cacheKey.url, ignoreParams); 900 if (strippedRequestURL === strippedCacheKeyURL) { 901 return cache.match(cacheKey, matchOptions); 902 } 903 } 904 return; 905} 906 907 908;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/Deferred.js 909/* 910 Copyright 2018 Google LLC 911 912 Use of this source code is governed by an MIT-style 913 license that can be found in the LICENSE file or at 914 https://opensource.org/licenses/MIT. 915*/ 916 917/** 918 * The Deferred class composes Promises in a way that allows for them to be 919 * resolved or rejected from outside the constructor. In most cases promises 920 * should be used directly, but Deferreds can be necessary when the logic to 921 * resolve a promise must be separate. 922 * 923 * @private 924 */ 925class Deferred { 926 /** 927 * Creates a promise and exposes its resolve and reject functions as methods. 928 */ 929 constructor() { 930 this.promise = new Promise((resolve, reject) => { 931 this.resolve = resolve; 932 this.reject = reject; 933 }); 934 } 935} 936 937 938;// CONCATENATED MODULE: ./node_modules/workbox-core/models/quotaErrorCallbacks.js 939/* 940 Copyright 2018 Google LLC 941 942 Use of this source code is governed by an MIT-style 943 license that can be found in the LICENSE file or at 944 https://opensource.org/licenses/MIT. 945*/ 946 947// Callbacks to be executed whenever there's a quota error. 948const quotaErrorCallbacks = new Set(); 949 950 951;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/executeQuotaErrorCallbacks.js 952/* 953 Copyright 2018 Google LLC 954 955 Use of this source code is governed by an MIT-style 956 license that can be found in the LICENSE file or at 957 https://opensource.org/licenses/MIT. 958*/ 959 960 961 962/** 963 * Runs all of the callback functions, one at a time sequentially, in the order 964 * in which they were registered. 965 * 966 * @memberof module:workbox-core 967 * @private 968 */ 969async function executeQuotaErrorCallbacks() { 970 if (false) {} 971 for (const callback of quotaErrorCallbacks) { 972 await callback(); 973 if (false) {} 974 } 975 if (false) {} 976} 977 978 979;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/timeout.js 980/* 981 Copyright 2019 Google LLC 982 Use of this source code is governed by an MIT-style 983 license that can be found in the LICENSE file or at 984 https://opensource.org/licenses/MIT. 985*/ 986 987/** 988 * Returns a promise that resolves and the passed number of milliseconds. 989 * This utility is an async/await-friendly version of `setTimeout`. 990 * 991 * @param {number} ms 992 * @return {Promise} 993 * @private 994 */ 995function timeout_timeout(ms) { 996 return new Promise((resolve) => setTimeout(resolve, ms)); 997} 998 999// EXTERNAL MODULE: ./node_modules/workbox-strategies/_version.js 1000var workbox_strategies_version = __webpack_require__(873); 1001;// CONCATENATED MODULE: ./node_modules/workbox-strategies/StrategyHandler.js 1002/* 1003 Copyright 2020 Google LLC 1004 1005 Use of this source code is governed by an MIT-style 1006 license that can be found in the LICENSE file or at 1007 https://opensource.org/licenses/MIT. 1008*/ 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018function toRequest(input) {
1019 return (typeof input === 'string') ? new Request(input) : input; 1020} 1021/** 1022 * A class created every time a Strategy instance instance calls 1023 * [handle()]{@link module:workbox-strategies.Strategy~handle} or 1024 * [handleAll()]{@link module:workbox-strategies.Strategy~handleAll} that wraps all fetch and 1025 * cache actions around plugin callbacks and keeps track of when the strategy 1026 * is "done" (i.e. all added `event.waitUntil()` promises have resolved). 1027 * 1028 * @memberof module:workbox-strategies 1029 */ 1030class StrategyHandler { 1031 /** 1032 * Creates a new instance associated with the passed strategy and event 1033 * that's handling the request. 1034 * 1035 * The constructor also initializes the state that will be passed to each of 1036 * the plugins handling this request. 1037 * 1038 * @param {module:workbox-strategies.Strategy} strategy 1039 * @param {Object} options 1040 * @param {Request|string} options.request A request to run this strategy for. 1041 * @param {ExtendableEvent} options.event The event associated with the 1042 * request. 1043 * @param {URL} [options.url] 1044 * @param {*} [options.params] 1045 * [match callback]{@link module:workbox-routing~matchCallback}, 1046 * (if applicable). 1047 */ 1048 constructor(strategy, options) { 1049 this._cacheKeys = {}; 1050 /** 1051 * The request the strategy is performing (passed to the strategy's 1052 * `handle()` or `handleAll()` method). 1053 * @name request 1054 * @instance 1055 * @type {Request} 1056 * @memberof module:workbox-strategies.StrategyHandler 1057 */ 1058 /** 1059 * The event associated with this request. 1060 * @name event 1061 * @instance 1062 * @type {ExtendableEvent} 1063 * @memberof module:workbox-strategies.StrategyHandler 1064 */ 1065 /** 1066 * A `URL` instance of `request.url` (if passed to the strategy's 1067 * `handle()` or `handleAll()` method). 1068 * Note: the `url` param will be present if the strategy was invoked 1069 * from a workbox `Route` object. 1070 * @name url 1071 * @instance 1072 * @type {URL|undefined} 1073 * @memberof module:workbox-strategies.StrategyHandler 1074 */ 1075 /** 1076 * A `param` value (if passed to the strategy's 1077 * `handle()` or `handleAll()` method). 1078 * Note: the `param` param will be present if the strategy was invoked 1079 * from a workbox `Route` object and the 1080 * [match callback]{@link module:workbox-routing~matchCallback} returned 1081 * a truthy value (it will be that value). 1082 * @name params 1083 * @instance 1084 * @type {*|undefined} 1085 * @memberof module:workbox-strategies.StrategyHandler 1086 */ 1087 if (false) {} 1088 Object.assign(this, options); 1089 this.event = options.event; 1090 this._strategy = strategy; 1091 this._handlerDeferred = new Deferred(); 1092 this._extendLifetimePromises = []; 1093 // Copy the plugins list (since it's mutable on the strategy), 1094 // so any mutations don't affect this handler instance. 1095 this._plugins = [...strategy.plugins]; 1096 this._pluginStateMap = new Map(); 1097 for (const plugin of this._plugins) { 1098 this._pluginStateMap.set(plugin, {}); 1099 } 1100 this.event.waitUntil(this._handlerDeferred.promise); 1101 } 1102 /** 1103 * Fetches a given request (and invokes any applicable plugin callback 1104 * methods) using the `fetchOptions` (for non-navigation requests) and 1105 * `plugins` defined on the `Strategy` object. 1106 * 1107 * The following plugin lifecycle methods are invoked when using this method: 1108 * - `requestWillFetch()` 1109 * - `fetchDidSucceed()` 1110 * - `fetchDidFail()` 1111 * 1112 * @param {Request|string} input The URL or request to fetch. 1113 * @return {Promise<Response>} 1114 */ 1115 async fetch(input) { 1116 const { event } = this; 1117 let request = toRequest(input); 1118 if (request.mode === 'navigate' && 1119 event instanceof FetchEvent && 1120 event.preloadResponse) { 1121 const possiblePreloadResponse = await event.preloadResponse; 1122 if (possiblePreloadResponse) { 1123 if (false) {} 1124 return possiblePreloadResponse; 1125 } 1126 } 1127 // If there is a fetchDidFail plugin, we need to save a clone of the 1128 // original request before it's either modified by a requestWillFetch 1129 // plugin or before the original request's body is consumed via fetch(). 1130 const originalRequest = this.hasCallback('fetchDidFail') ? 1131 request.clone() : null; 1132 try { 1133 for (const cb of this.iterateCallbacks('requestWillFetch')) { 1134 request = await cb({ request: request.clone(), event }); 1135 } 1136 } 1137 catch (err) { 1138 throw new WorkboxError_WorkboxError('plugin-error-request-will-fetch', { 1139 thrownError: err, 1140 }); 1141 } 1142 // The request can be altered by plugins with `requestWillFetch` making 1143 // the original request (most likely from a `fetch` event) different 1144 // from the Request we make. Pass both to `fetchDidFail` to aid debugging. 1145 const pluginFilteredRequest = request.clone(); 1146 try { 1147 let fetchResponse; 1148 // See https://github.com/GoogleChrome/workbox/issues/1796 1149 fetchResponse = await fetch(request, request.mode === 'navigate' ? 1150 undefined : this._strategy.fetchOptions); 1151 if (false) {} 1152 for (const callback of this.iterateCallbacks('fetchDidSucceed')) { 1153 fetchResponse = await callback({ 1154 event, 1155 request: pluginFilteredRequest, 1156 response: fetchResponse, 1157 }); 1158 } 1159 return fetchResponse; 1160 } 1161 catch (error) { 1162 if (false) {} 1163 // `originalRequest` will only exist if a `fetchDidFail` callback 1164 // is being used (see above). 1165 if (originalRequest) { 1166 await this.runCallbacks('fetchDidFail', { 1167 error, 1168 event, 1169 originalRequest: originalRequest.clone(), 1170 request: pluginFilteredRequest.clone(), 1171 }); 1172 } 1173 throw error; 1174 } 1175 } 1176 /** 1177 * Calls `this.fetch()` and (in the background) runs `this.cachePut()` on 1178 * the response generated by `this.fetch()`. 1179 * 1180 * The call to `this.cachePut()` automatically invokes `this.waitUntil()`, 1181 * so you do not have to manually call `waitUntil()` on the event. 1182 * 1183 * @param {Request|string} input The request or URL to fetch and cache. 1184 * @return {Promise<Response>} 1185 */ 1186 async fetchAndCachePut(input) { 1187 const response = await this.fetch(input); 1188 const responseClone = response.clone(); 1189 this.waitUntil(this.cachePut(input, responseClone)); 1190 return response; 1191 } 1192 /** 1193 * Matches a request from the cache (and invokes any applicable plugin 1194 * callback methods) using the `cacheName`, `matchOptions`, and `plugins` 1195 * defined on the strategy object. 1196 * 1197 * The following plugin lifecycle methods are invoked when using this method: 1198 * - cacheKeyWillByUsed() 1199 * - cachedResponseWillByUsed() 1200 * 1201 * @param {Request|string} key The Request or URL to use as the cache key. 1202 * @return {Promise<Response|undefined>} A matching response, if found. 1203 */ 1204 async cacheMatch(key) { 1205 const request = toRequest(key); 1206 let cachedResponse; 1207 const { cacheName, matchOptions } = this._strategy; 1208 const effectiveRequest = await this.getCacheKey(request, 'read'); 1209 const multiMatchOptions = { ...matchOptions, ...{ cacheName } }; 1210 cachedResponse = await caches.match(effectiveRequest, multiMatchOptions); 1211 if (false) {} 1212 for (const callback of this.iterateCallbacks('cachedResponseWillBeUsed')) { 1213 cachedResponse = (await callback({ 1214 cacheName, 1215 matchOptions, 1216 cachedResponse, 1217 request: effectiveRequest, 1218 event: this.event, 1219 })) || undefined; 1220 } 1221 return cachedResponse; 1222 } 1223 /** 1224 * Puts a request/response pair in the cache (and invokes any applicable 1225 * plugin callback methods) using the `cacheName` and `plugins` defined on 1226 * the strategy object. 1227 * 1228 * The following plugin lifecycle methods are invoked when using this method: 1229 * - cacheKeyWillByUsed() 1230 * - cacheWillUpdate() 1231 * - cacheDidUpdate() 1232 * 1233 * @param {Request|string} key The request or URL to use as the cache key. 1234 * @param {Response} response The response to cache. 1235 * @return {Promise<boolean>} `false` if a cacheWillUpdate caused the response 1236 * not be cached, and `true` otherwise. 1237 */ 1238 async cachePut(key, response) { 1239 const request = toRequest(key); 1240 // Run in the next task to avoid blocking other cache reads. 1241 // https://github.com/w3c/ServiceWorker/issues/1397 1242 await timeout_timeout(0); 1243 const effectiveRequest = await this.getCacheKey(request, 'write'); 1244 if (false) {} 1245 if (!response) { 1246 if (false) {} 1247 throw new WorkboxError_WorkboxError('cache-put-with-no-response', { 1248 url: getFriendlyURL(effectiveRequest.url), 1249 }); 1250 } 1251 const responseToCache = await this._ensureResponseSafeToCache(response); 1252 if (!responseToCache) { 1253 if (false) {} 1254 return false;
1255 } 1256 const { cacheName, matchOptions } = this._strategy; 1257 const cache = await self.caches.open(cacheName); 1258 const hasCacheUpdateCallback = this.hasCallback('cacheDidUpdate'); 1259 const oldResponse = hasCacheUpdateCallback ? await cacheMatchIgnoreParams( 1260 // TODO(philipwalton): the `__WB_REVISION__` param is a precaching 1261 // feature. Consider into ways to only add this behavior if using 1262 // precaching. 1263 cache, effectiveRequest.clone(), ['__WB_REVISION__'], matchOptions) : 1264 null; 1265 if (false) {} 1266 try { 1267 await cache.put(effectiveRequest, hasCacheUpdateCallback ? 1268 responseToCache.clone() : responseToCache); 1269 } 1270 catch (error) { 1271 // See https://developer.mozilla.org/en-US/docs/Web/API/DOMException#exception-QuotaExceededError 1272 if (error.name === 'QuotaExceededError') { 1273 await executeQuotaErrorCallbacks(); 1274 } 1275 throw error; 1276 } 1277 for (const callback of this.iterateCallbacks('cacheDidUpdate')) { 1278 await callback({ 1279 cacheName, 1280 oldResponse, 1281 newResponse: responseToCache.clone(), 1282 request: effectiveRequest, 1283 event: this.event, 1284 }); 1285 } 1286 return true; 1287 } 1288 /** 1289 * Checks the list of plugins for the `cacheKeyWillBeUsed` callback, and 1290 * executes any of those callbacks found in sequence. The final `Request` 1291 * object returned by the last plugin is treated as the cache key for cache 1292 * reads and/or writes. If no `cacheKeyWillBeUsed` plugin callbacks have 1293 * been registered, the passed request is returned unmodified 1294 * 1295 * @param {Request} request 1296 * @param {string} mode 1297 * @return {Promise<Request>} 1298 */ 1299 async getCacheKey(request, mode) { 1300 if (!this._cacheKeys[mode]) { 1301 let effectiveRequest = request; 1302 for (const callback of this.iterateCallbacks('cacheKeyWillBeUsed')) { 1303 effectiveRequest = toRequest(await callback({ 1304 mode, 1305 request: effectiveRequest, 1306 event: this.event, 1307 params: this.params, 1308 })); 1309 } 1310 this._cacheKeys[mode] = effectiveRequest; 1311 } 1312 return this._cacheKeys[mode]; 1313 } 1314 /** 1315 * Returns true if the strategy has at least one plugin with the given 1316 * callback. 1317 * 1318 * @param {string} name The name of the callback to check for. 1319 * @return {boolean} 1320 */ 1321 hasCallback(name) { 1322 for (const plugin of this._strategy.plugins) { 1323 if (name in plugin) { 1324 return true; 1325 } 1326 } 1327 return false; 1328 } 1329 /** 1330 * Runs all plugin callbacks matching the given name, in order, passing the 1331 * given param object (merged ith the current plugin state) as the only 1332 * argument. 1333 * 1334 * Note: since this method runs all plugins, it's not suitable for cases 1335 * where the return value of a callback needs to be applied prior to calling 1336 * the next callback. See 1337 * [`iterateCallbacks()`]{@link module:workbox-strategies.StrategyHandler#iterateCallbacks} 1338 * below for how to handle that case. 1339 * 1340 * @param {string} name The name of the callback to run within each plugin. 1341 * @param {Object} param The object to pass as the first (and only) param 1342 * when executing each callback. This object will be merged with the 1343 * current plugin state prior to callback execution. 1344 */ 1345 async runCallbacks(name, param) { 1346 for (const callback of this.iterateCallbacks(name)) { 1347 // TODO(philipwalton): not sure why `any` is needed. It seems like 1348 // this should work with `as WorkboxPluginCallbackParam[C]`. 1349 await callback(param); 1350 } 1351 } 1352 /** 1353 * Accepts a callback and returns an iterable of matching plugin callbacks, 1354 * where each callback is wrapped with the current handler state (i.e. when 1355 * you call each callback, whatever object parameter you pass it will 1356 * be merged with the plugin's current state). 1357 * 1358 * @param {string} name The name fo the callback to run 1359 * @return {Array<Function>} 1360 */ 1361 *iterateCallbacks(name) { 1362 for (const plugin of this._strategy.plugins) { 1363 if (typeof plugin[name] === 'function') { 1364 const state = this._pluginStateMap.get(plugin); 1365 const statefulCallback = (param) => { 1366 const statefulParam = { ...param, state }; 1367 // TODO(philipwalton): not sure why `any` is needed. It seems like 1368 // this should work with `as WorkboxPluginCallbackParam[C]`. 1369 return plugin[name](statefulParam); 1370 }; 1371 yield statefulCallback; 1372 } 1373 } 1374 } 1375 /** 1376 * Adds a promise to the 1377 * [extend lifetime promises]{@link https://w3c.github.io/ServiceWorker/#extendableevent-extend-lifetime-promises} 1378 * of the event event associated with the request being handled (usually a 1379 * `FetchEvent`). 1380 * 1381 * Note: you can await 1382 * [`doneWaiting()`]{@link module:workbox-strategies.StrategyHandler~doneWaiting} 1383 * to know when all added promises have settled. 1384 * 1385 * @param {Promise} promise A promise to add to the extend lifetime promises 1386 * of the event that triggered the request. 1387 */ 1388 waitUntil(promise) { 1389 this._extendLifetimePromises.push(promise); 1390 return promise; 1391 } 1392 /** 1393 * Returns a promise that resolves once all promises passed to 1394 * [`waitUntil()`]{@link module:workbox-strategies.StrategyHandler~waitUntil} 1395 * have settled. 1396 * 1397 * Note: any work done after `doneWaiting()` settles should be manually 1398 * passed to an event's `waitUntil()` method (not this handler's 1399 * `waitUntil()` method), otherwise the service worker thread my be killed 1400 * prior to your work completing. 1401 */ 1402 async doneWaiting() { 1403 let promise; 1404 while (promise = this._extendLifetimePromises.shift()) { 1405 await promise; 1406 } 1407 } 1408 /** 1409 * Stops running the strategy and immediately resolves any pending 1410 * `waitUntil()` promises. 1411 */ 1412 destroy() { 1413 this._handlerDeferred.resolve(); 1414 } 1415 /** 1416 * This method will call cacheWillUpdate on the available plugins (or use 1417 * status === 200) to determine if the Response is safe and valid to cache. 1418 * 1419 * @param {Request} options.request 1420 * @param {Response} options.response 1421 * @return {Promise<Response|undefined>} 1422 * 1423 * @private 1424 */ 1425 async _ensureResponseSafeToCache(response) { 1426 let responseToCache = response; 1427 let pluginsUsed = false;
1428 for (const callback of this.iterateCallbacks('cacheWillUpdate')) { 1429 responseToCache = (await callback({ 1430 request: this.request, 1431 response: responseToCache, 1432 event: this.event, 1433 })) || undefined; 1434 pluginsUsed = true; 1435 if (!responseToCache) { 1436 break; 1437 } 1438 } 1439 if (!pluginsUsed) { 1440 if (responseToCache && responseToCache.status !== 200) { 1441 responseToCache = undefined; 1442 } 1443 if (false) {} 1444 } 1445 return responseToCache; 1446 } 1447} 1448 1449 1450;// CONCATENATED MODULE: ./node_modules/workbox-strategies/Strategy.js 1451/* 1452 Copyright 2020 Google LLC 1453 1454 Use of this source code is governed by an MIT-style 1455 license that can be found in the LICENSE file or at 1456 https://opensource.org/licenses/MIT. 1457*/ 1458 1459 1460 1461 1462 1463 1464/** 1465 * An abstract base class that all other strategy classes must extend from: 1466 * 1467 * @memberof module:workbox-strategies 1468 */ 1469class Strategy_Strategy { 1470 /** 1471 * Creates a new instance of the strategy and sets all documented option 1472 * properties as public instance properties. 1473 * 1474 * Note: if a custom strategy class extends the base Strategy class and does 1475 * not need more than these properties, it does not need to define its own 1476 * constructor. 1477 * 1478 * @param {Object} [options] 1479 * @param {string} [options.cacheName] Cache name to store and retrieve 1480 * requests. Defaults to the cache names provided by 1481 * [workbox-core]{@link module:workbox-core.cacheNames}. 1482 * @param {Array<Object>} [options.plugins] [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins} 1483 * to use in conjunction with this caching strategy. 1484 * @param {Object} [options.fetchOptions] Values passed along to the 1485 * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) 1486 * of [non-navigation](https://github.com/GoogleChrome/workbox/issues/1796) 1487 * `fetch()` requests made by this strategy. 1488 * @param {Object} [options.matchOptions] The 1489 * [`CacheQueryOptions`]{@link https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions} 1490 * for any `cache.match()` or `cache.put()` calls made by this strategy. 1491 */ 1492 constructor(options = {}) { 1493 /** 1494 * Cache name to store and retrieve 1495 * requests. Defaults to the cache names provided by 1496 * [workbox-core]{@link module:workbox-core.cacheNames}. 1497 * 1498 * @type {string} 1499 */ 1500 this.cacheName = cacheNames_cacheNames.getRuntimeName(options.cacheName); 1501 /** 1502 * The list 1503 * [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins} 1504 * used by this strategy. 1505 * 1506 * @type {Array<Object>} 1507 */ 1508 this.plugins = options.plugins || []; 1509 /** 1510 * Values passed along to the 1511 * [`init`]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters} 1512 * of all fetch() requests made by this strategy. 1513 * 1514 * @type {Object} 1515 */ 1516 this.fetchOptions = options.fetchOptions; 1517 /** 1518 * The 1519 * [`CacheQueryOptions`]{@link https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions} 1520 * for any `cache.match()` or `cache.put()` calls made by this strategy. 1521 * 1522 * @type {Object} 1523 */ 1524 this.matchOptions = options.matchOptions; 1525 } 1526 /** 1527 * Perform a request strategy and returns a `Promise` that will resolve with 1528 * a `Response`, invoking all relevant plugin callbacks. 1529 * 1530 * When a strategy instance is registered with a Workbox 1531 * [route]{@link module:workbox-routing.Route}, this method is automatically 1532 * called when the route matches. 1533 * 1534 * Alternatively, this method can be used in a standalone `FetchEvent` 1535 * listener by passing it to `event.respondWith()`. 1536 * 1537 * @param {FetchEvent|Object} options A `FetchEvent` or an object with the 1538 * properties listed below. 1539 * @param {Request|string} options.request A request to run this strategy for. 1540 * @param {ExtendableEvent} options.event The event associated with the 1541 * request. 1542 * @param {URL} [options.url] 1543 * @param {*} [options.params] 1544 */ 1545 handle(options) {
1546 const [responseDone] = this.handleAll(options); 1547 return responseDone; 1548 } 1549 /** 1550 * Similar to [`handle()`]{@link module:workbox-strategies.Strategy~handle}, but 1551 * instead of just returning a `Promise` that resolves to a `Response` it 1552 * it will return an tuple of [response, done] promises, where the former 1553 * (`response`) is equivalent to what `handle()` returns, and the latter is a 1554 * Promise that will resolve once any promises that were added to 1555 * `event.waitUntil()` as part of performing the strategy have completed. 1556 * 1557 * You can await the `done` promise to ensure any extra work performed by 1558 * the strategy (usually caching responses) completes successfully. 1559 * 1560 * @param {FetchEvent|Object} options A `FetchEvent` or an object with the 1561 * properties listed below. 1562 * @param {Request|string} options.request A request to run this strategy for. 1563 * @param {ExtendableEvent} options.event The event associated with the 1564 * request. 1565 * @param {URL} [options.url] 1566 * @param {*} [options.params] 1567 * @return {Array<Promise>} A tuple of [response, done] 1568 * promises that can be used to determine when the response resolves as 1569 * well as when the handler has completed all its work. 1570 */ 1571 handleAll(options) { 1572 // Allow for flexible options to be passed. 1573 if (options instanceof FetchEvent) { 1574 options = { 1575 event: options, 1576 request: options.request, 1577 }; 1578 } 1579 const event = options.event; 1580 const request = typeof options.request === 'string' ? 1581 new Request(options.request) : 1582 options.request; 1583 const params = 'params' in options ? options.params : undefined; 1584 const handler = new StrategyHandler(this, { event, request, params }); 1585 const responseDone = this._getResponse(handler, request, event); 1586 const handlerDone = this._awaitComplete(responseDone, handler, request, event); 1587 // Return an array of promises, suitable for use with Promise.all(). 1588 return [responseDone, handlerDone]; 1589 } 1590 async _getResponse(handler, request, event) { 1591 await handler.runCallbacks('handlerWillStart', { event, request }); 1592 let response = undefined; 1593 try { 1594 response = await this._handle(request, handler); 1595 // The "official" Strategy subclasses all throw this error automatically, 1596 // but in case a third-party Strategy doesn't, ensure that we have a 1597 // consistent failure when there's no response or an error response. 1598 if (!response || response.type === 'error') { 1599 throw new WorkboxError_WorkboxError('no-response', { url: request.url }); 1600 } 1601 } 1602 catch (error) { 1603 for (const callback of handler.iterateCallbacks('handlerDidError')) { 1604 response = await callback({ error, event, request }); 1605 if (response) { 1606 break; 1607 } 1608 } 1609 if (!response) { 1610 throw error; 1611 } 1612 else if (false) {} 1613 } 1614 for (const callback of handler.iterateCallbacks('handlerWillRespond')) { 1615 response = await callback({ event, request, response }); 1616 } 1617 return response; 1618 } 1619 async _awaitComplete(responseDone, handler, request, event) { 1620 let response; 1621 let error; 1622 try { 1623 response = await responseDone; 1624 } 1625 catch (error) { 1626 // Ignore errors, as response errors should be caught via the `response` 1627 // promise above. The `done` promise will only throw for errors in 1628 // promises passed to `handler.waitUntil()`. 1629 } 1630 try { 1631 await handler.runCallbacks('handlerDidRespond', { 1632 event, 1633 request, 1634 response, 1635 }); 1636 await handler.doneWaiting(); 1637 } 1638 catch (waitUntilError) { 1639 error = waitUntilError; 1640 } 1641 await handler.runCallbacks('handlerDidComplete', { 1642 event, 1643 request, 1644 response, 1645 error, 1646 }); 1647 handler.destroy(); 1648 if (error) { 1649 throw error; 1650 } 1651 } 1652} 1653 1654/** 1655 * Classes extending the `Strategy` based class should implement this method, 1656 * and leverage the [`handler`]{@link module:workbox-strategies.StrategyHandler} 1657 * arg to perform all fetching and cache logic, which will ensure all relevant 1658 * cache, cache options, fetch options and plugins are used (per the current 1659 * strategy instance). 1660 * 1661 * @name _handle 1662 * @instance 1663 * @abstract 1664 * @function 1665 * @param {Request} request 1666 * @param {module:workbox-strategies.StrategyHandler} handler 1667 * @return {Promise<Response>} 1668 * 1669 * @memberof module:workbox-strategies.Strategy 1670 */ 1671 1672;// CONCATENATED MODULE: ./node_modules/workbox-precaching/PrecacheStrategy.js 1673/* 1674 Copyright 2020 Google LLC 1675 1676 Use of this source code is governed by an MIT-style 1677 license that can be found in the LICENSE file or at 1678 https://opensource.org/licenses/MIT.
1679*/ 1680 1681 1682 1683 1684 1685 1686 1687/** 1688 * A [Strategy]{@link module:workbox-strategies.Strategy} implementation 1689 * specifically designed to work with 1690 * [PrecacheController]{@link module:workbox-precaching.PrecacheController} 1691 * to both cache and fetch precached assets. 1692 * 1693 * Note: an instance of this class is created automatically when creating a 1694 * `PrecacheController`; it's generally not necessary to create this yourself. 1695 * 1696 * @extends module:workbox-strategies.Strategy 1697 * @memberof module:workbox-precaching 1698 */ 1699class PrecacheStrategy extends Strategy_Strategy { 1700 /** 1701 * 1702 * @param {Object} [options] 1703 * @param {string} [options.cacheName] Cache name to store and retrieve 1704 * requests. Defaults to the cache names provided by 1705 * [workbox-core]{@link module:workbox-core.cacheNames}. 1706 * @param {Array<Object>} [options.plugins] [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins} 1707 * to use in conjunction with this caching strategy. 1708 * @param {Object} [options.fetchOptions] Values passed along to the 1709 * [`init`]{@link https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters} 1710 * of all fetch() requests made by this strategy. 1711 * @param {Object} [options.matchOptions] The 1712 * [`CacheQueryOptions`]{@link https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions} 1713 * for any `cache.match()` or `cache.put()` calls made by this strategy. 1714 * @param {boolean} [options.fallbackToNetwork=true] Whether to attempt to 1715 * get the response from the network if there's a precache miss. 1716 */ 1717 constructor(options = {}) { 1718 options.cacheName = cacheNames_cacheNames.getPrecacheName(options.cacheName); 1719 super(options); 1720 this._fallbackToNetwork = options.fallbackToNetwork === false ? false : true; 1721 // Redirected responses cannot be used to satisfy a navigation request, so 1722 // any redirected response must be "copied" rather than cloned, so the new 1723 // response doesn't contain the `redirected` flag. See: 1724 // https://bugs.chromium.org/p/chromium/issues/detail?id=669363&desc=2#c1 1725 this.plugins.push(PrecacheStrategy.copyRedirectedCacheableResponsesPlugin); 1726 } 1727 /** 1728 * @private 1729 * @param {Request|string} request A request to run this strategy for. 1730 * @param {module:workbox-strategies.StrategyHandler} handler The event that 1731 * triggered the request. 1732 * @return {Promise<Response>} 1733 */ 1734 async _handle(request, handler) { 1735 const response = await handler.cacheMatch(request); 1736 if (!response) { 1737 // If this is an `install` event then populate the cache. If this is a 1738 // `fetch` event (or any other event) then respond with the cached 1739 // response. 1740 if (handler.event && handler.event.type === 'install') { 1741 return await this._handleInstall(request, handler); 1742 } 1743 return await this._handleFetch(request, handler); 1744 } 1745 return response; 1746 } 1747 async _handleFetch(request, handler) { 1748 let response; 1749 // Fall back to the network if we don't have a cached response 1750 // (perhaps due to manual cache cleanup). 1751 if (this._fallbackToNetwork) { 1752 if (false) {} 1753 response = await handler.fetch(request); 1754 } 1755 else { 1756 // This shouldn't normally happen, but there are edge cases: 1757 // https://github.com/GoogleChrome/workbox/issues/1441 1758 throw new WorkboxError_WorkboxError('missing-precache-entry', { 1759 cacheName: this.cacheName, 1760 url: request.url, 1761 }); 1762 } 1763 if (false) {} 1764 return response; 1765 } 1766 async _handleInstall(request, handler) { 1767 this._useDefaultCacheabilityPluginIfNeeded(); 1768 const response = await handler.fetch(request); 1769 // Make sure we defer cachePut() until after we know the response 1770 // should be cached; see https://github.com/GoogleChrome/workbox/issues/2737 1771 const wasCached = await handler.cachePut(request, response.clone()); 1772 if (!wasCached) { 1773 // Throwing here will lead to the `install` handler failing, which 1774 // we want to do if *any* of the responses aren't safe to cache. 1775 throw new WorkboxError_WorkboxError('bad-precaching-response', { 1776 url: request.url, 1777 status: response.status, 1778 }); 1779 } 1780 return response; 1781 } 1782 /** 1783 * This method is complex, as there a number of things to account for: 1784 * 1785 * The `plugins` array can be set at construction, and/or it might be added to 1786 * to at any time before the strategy is used. 1787 * 1788 * At the time the strategy is used (i.e. during an `install` event), there 1789 * needs to be at least one plugin that implements `cacheWillUpdate` in the 1790 * array, other than `copyRedirectedCacheableResponsesPlugin`. 1791 * 1792 * - If this method is called and there are no suitable `cacheWillUpdate` 1793 * plugins, we need to add `defaultPrecacheCacheabilityPlugin`. 1794 * 1795 * - If this method is called and there is exactly one `cacheWillUpdate`, then 1796 * we don't have to do anything (this might be a previously added 1797 * `defaultPrecacheCacheabilityPlugin`, or it might be a custom plugin). 1798 * 1799 * - If this method is called and there is more than one `cacheWillUpdate`, 1800 * then we need to check if one is `defaultPrecacheCacheabilityPlugin`. If so, 1801 * we need to remove it. (This situation is unlikely, but it could happen if 1802 * the strategy is used multiple times, the first without a `cacheWillUpdate`, 1803 * and then later on after manually adding a custom `cacheWillUpdate`.) 1804 * 1805 * See https://github.com/GoogleChrome/workbox/issues/2737 for more context. 1806 * 1807 * @private 1808 */ 1809 _useDefaultCacheabilityPluginIfNeeded() { 1810 let defaultPluginIndex = null; 1811 let cacheWillUpdatePluginCount = 0; 1812 for (const [index, plugin] of this.plugins.entries()) { 1813 // Ignore the copy redirected plugin when determining what to do. 1814 if (plugin === PrecacheStrategy.copyRedirectedCacheableResponsesPlugin) { 1815 continue; 1816 } 1817 // Save the default plugin's index, in case it needs to be removed. 1818 if (plugin === PrecacheStrategy.defaultPrecacheCacheabilityPlugin) { 1819 defaultPluginIndex = index; 1820 } 1821 if (plugin.cacheWillUpdate) { 1822 cacheWillUpdatePluginCount++; 1823 } 1824 } 1825 if (cacheWillUpdatePluginCount === 0) { 1826 this.plugins.push(PrecacheStrategy.defaultPrecacheCacheabilityPlugin); 1827 } 1828 else if (cacheWillUpdatePluginCount > 1 && defaultPluginIndex !== null) { 1829 // Only remove the default plugin; multiple custom plugins are allowed. 1830 this.plugins.splice(defaultPluginIndex, 1); 1831 } 1832 // Nothing needs to be done if cacheWillUpdatePluginCount is 1 1833 } 1834} 1835PrecacheStrategy.defaultPrecacheCacheabilityPlugin = { 1836 async cacheWillUpdate({ response }) { 1837 if (!response || response.status >= 400) { 1838 return null; 1839 } 1840 return response; 1841 } 1842}; 1843PrecacheStrategy.copyRedirectedCacheableResponsesPlugin = { 1844 async cacheWillUpdate({ response }) { 1845 return response.redirected ? await copyResponse(response)
1845: response; 1846 } 1847}; 1848 1849 1850;// CONCATENATED MODULE: ./node_modules/workbox-precaching/PrecacheController.js 1851/* 1852 Copyright 2019 Google LLC 1853 1854 Use of this source code is governed by an MIT-style 1855 license that can be found in the LICENSE file or at 1856 https://opensource.org/licenses/MIT. 1857*/ 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870/** 1871 * Performs efficient precaching of assets. 1872 * 1873 * @memberof module:workbox-precaching 1874 */ 1875class PrecacheController { 1876 /** 1877 * Create a new PrecacheController. 1878 * 1879 * @param {Object} [options] 1880 * @param {string} [options.cacheName] The cache to use for precaching. 1881 * @param {string} [options.plugins] Plugins to use when precaching as well 1882 * as responding to fetch events for precached assets. 1883 * @param {boolean} [options.fallbackToNetwork=true] Whether to attempt to 1884 * get the response from the network if there's a precache miss. 1885 */ 1886 constructor({ cacheName, plugins = [], fallbackToNetwork = true } = {}) { 1887 this._urlsToCacheKeys = new Map(); 1888 this._urlsToCacheModes = new Map(); 1889 this._cacheKeysToIntegrities = new Map(); 1890 this._strategy = new PrecacheStrategy({ 1891 cacheName: cacheNames_cacheNames.getPrecacheName(cacheName), 1892 plugins: [ 1893 ...plugins, 1894 new PrecacheCacheKeyPlugin({ precacheController: this }), 1895 ], 1896 fallbackToNetwork, 1897 }); 1898 // Bind the install and activate methods to the instance. 1899 this.install = this.install.bind(this); 1900 this.activate = this.activate.bind(this); 1901 } 1902 /** 1903 * @type {module:workbox-precaching.PrecacheStrategy} The strategy created by this controller and 1904 * used to cache assets and respond to fetch events. 1905 */ 1906 get strategy() { 1907 return this._strategy; 1908 } 1909 /** 1910 * Adds items to the precache list, removing any duplicates and 1911 * stores the files in the 1912 * ["precache cache"]{@link module:workbox-core.cacheNames} when the service 1913 * worker installs. 1914 * 1915 * This method can be called multiple times. 1916 * 1917 * @param {Array<Object|string>} [entries=[]] Array of entries to precache. 1918 */ 1919 precache(entries) { 1920 this.addToCacheList(entries); 1921 if (!this._installAndActiveListenersAdded) { 1922 self.addEventListener('install', this.install); 1923 self.addEventListener('activate', this.activate); 1924 this._installAndActiveListenersAdded = true; 1925 } 1926 } 1927 /** 1928 * This method will add items to the precache list, removing duplicates 1929 * and ensuring the information is valid. 1930 * 1931 * @param {Array<module:workbox-precaching.PrecacheController.PrecacheEntry|string>} entries 1932 * Array of entries to precache. 1933 */ 1934 addToCacheList(entries) { 1935 if (false) {} 1936 const urlsToWarnAbout = []; 1937 for (const entry of entries) { 1938 // See https://github.com/GoogleChrome/workbox/issues/2259 1939 if (typeof entry === 'string') { 1940 urlsToWarnAbout.push(entry); 1941 } 1942 else if (entry && entry.revision === undefined) { 1943 urlsToWarnAbout.push(entry.url); 1944 } 1945 const { cacheKey, url } = createCacheKey(entry); 1946 const cacheMode = (typeof entry !== 'string' && entry.revision) ? 1947 'reload' : 'default'; 1948 if (this._urlsToCacheKeys.has(url) && 1949 this._urlsToCacheKeys.get(url) !== cacheKey) { 1950 throw new WorkboxError_WorkboxError('add-to-cache-list-conflicting-entries', { 1951 firstEntry: this._urlsToCacheKeys.get(url), 1952 secondEntry: cacheKey, 1953 }); 1954 } 1955 if (typeof entry !== 'string' && entry.integrity) { 1956 if (this._cacheKeysToIntegrities.has(cacheKey) && 1957 this._cacheKeysToIntegrities.get(cacheKey) !== entry.integrity) { 1958 throw new WorkboxError_WorkboxError('add-to-cache-list-conflicting-integrities', { 1959 url, 1960 }); 1961 } 1962 this._cacheKeysToIntegrities.set(cacheKey, entry.integrity); 1963 } 1964 this._urlsToCacheKeys.set(url, cacheKey); 1965 this._urlsToCacheModes.set(url, cacheMode); 1966 if (urlsToWarnAbout.length > 0) { 1967 const warningMessage = `Workbox is precaching URLs without revision ` + 1968 `info: ${urlsToWarnAbout.join(', ')}\nThis is generally NOT safe. ` + 1969 `Learn more at https://bit.ly/wb-precache`; 1970 if (true) { 1971 // Use console directly to display this warning without bloating 1972 // bundle sizes by pulling in all of the logger codebase in prod. 1973 console.warn(warningMessage); 1974 } 1975 else {} 1976 } 1977 } 1978 } 1979 /** 1980 * Precaches new and updated assets. Call this method from the service worker 1981 * install event. 1982 * 1983 * Note: this method calls `event.waitUntil()` for you, so you do not need 1984 * to call it yourself in your event handlers. 1985 * 1986 * @param {ExtendableEvent} event 1987 * @return {Promise<module:workbox-precaching.InstallResult>} 1988 */ 1989 install(event) { 1990 return waitUntil(event, async () => { 1991 const installReportPlugin = new PrecacheInstallReportPlugin(); 1992 this.strategy.plugins.push(installReportPlugin); 1993 // Cache entries one at a time. 1994 // See https://github.com/GoogleChrome/workbox/issues/2528 1995 for (const [url, cacheKey] of this._urlsToCacheKeys) { 1996 const integrity = this._cacheKeysToIntegrities.get(cacheKey); 1997 const cacheMode = this._urlsToCacheModes.get(url);
1998 const request = new Request(url, { 1999 integrity, 2000 cache: cacheMode, 2001 credentials: 'same-origin', 2002 }); 2003 await Promise.all(this.strategy.handleAll({ 2004 params: { cacheKey }, 2005 request, 2006 event, 2007 })); 2008 } 2009 const { updatedURLs, notUpdatedURLs } = installReportPlugin; 2010 if (false) {} 2011 return { updatedURLs, notUpdatedURLs }; 2012 }); 2013 } 2014 /** 2015 * Deletes assets that are no longer present in the current precache manifest. 2016 * Call this method from the service worker activate event. 2017 * 2018 * Note: this method calls `event.waitUntil()` for you, so you do not need 2019 * to call it yourself in your event handlers. 2020 * 2021 * @param {ExtendableEvent} event 2022 * @return {Promise<module:workbox-precaching.CleanupResult>} 2023 */ 2024 activate(event) { 2025 return waitUntil(event, async () => { 2026 const cache = await self.caches.open(this.strategy.cacheName); 2027 const currentlyCachedRequests = await cache.keys(); 2028 const expectedCacheKeys = new Set(this._urlsToCacheKeys.values()); 2029 const deletedURLs = []; 2030 for (const request of currentlyCachedRequests) { 2031 if (!expectedCacheKeys.has(request.url)) { 2032 await cache.delete(request); 2033 deletedURLs.push(request.url); 2034 } 2035 } 2036 if (false) {} 2037 return { deletedURLs }; 2038 }); 2039 } 2040 /** 2041 * Returns a mapping of a precached URL to the corresponding cache key, taking 2042 * into account the revision information for the URL. 2043 * 2044 * @return {Map<string, string>} A URL to cache key mapping. 2045 */ 2046 getURLsToCacheKeys() { 2047 return this._urlsToCacheKeys; 2048 } 2049 /** 2050 * Returns a list of all the URLs that have been precached by the current 2051 * service worker. 2052 * 2053 * @return {Array<string>} The precached URLs. 2054 */ 2055 getCachedURLs() { 2056 return [...this._urlsToCacheKeys.keys()]; 2057 } 2058 /** 2059 * Returns the cache key used for storing a given URL. If that URL is 2060 * unversioned, like `/index.html', then the cache key will be the original 2061 * URL with a search parameter appended to it. 2062 * 2063 * @param {string} url A URL whose cache key you want to look up. 2064 * @return {string} The versioned URL that corresponds to a cache key 2065 * for the original URL, or undefined if that URL isn't precached. 2066 */ 2067 getCacheKeyForURL(url) { 2068 const urlObject = new URL(url, location.href); 2069 return this._urlsToCacheKeys.get(urlObject.href); 2070 } 2071 /** 2072 * This acts as a drop-in replacement for 2073 * [`cache.match()`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/match) 2074 * with the following differences: 2075 * 2076 * - It knows what the name of the precache is, and only checks in that cache. 2077 * - It allows you to pass in an "original" URL without versioning parameters, 2078 * and it will automatically look up the correct cache key for the currently 2079 * active revision of that URL. 2080 * 2081 * E.g., `matchPrecache('index.html')` will find the correct precached 2082 * response for the currently active service worker, even if the actual cache 2083 * key is `'/index.html?__WB_REVISION__=1234abcd'`. 2084 * 2085 * @param {string|Request} request The key (without revisioning parameters) 2086 * to look up in the precache. 2087 * @return {Promise<Response|undefined>} 2088 */ 2089 async matchPrecache(request) { 2090 const url = request instanceof Request ? request.url : request; 2091 const cacheKey = this.getCacheKeyForURL(url); 2092 if (cacheKey) { 2093 const cache = await self.caches.open(this.strategy.cacheName); 2094 return cache.match(cacheKey); 2095 } 2096 return undefined; 2097 } 2098 /** 2099 * Returns a function that looks up `url` in the precache (taking into 2100 * account revision information), and returns the corresponding `Response`. 2101 * 2102 * @param {string} url The precached URL which will be used to lookup the 2103 * `Response`. 2104 * @return {module:workbox-routing~handlerCallback} 2105 */ 2106 createHandlerBoundToURL(url) { 2107 const cacheKey = this.getCacheKeyForURL(url); 2108 if (!cacheKey) { 2109 throw new WorkboxError_WorkboxError('non-precached-url', { url }); 2110 } 2111 return (options) => {
2112 options.request = new Request(url); 2113 options.params = { cacheKey, ...options.params }; 2114 return this.strategy.handle(options); 2115 }; 2116 } 2117} 2118 2119 2120;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/getOrCreatePrecacheController.js 2121/* 2122 Copyright 2019 Google LLC 2123 2124 Use of this source code is governed by an MIT-style 2125 license that can be found in the LICENSE file or at 2126 https://opensource.org/licenses/MIT. 2127*/ 2128 2129 2130let precacheController; 2131/** 2132 * @return {PrecacheController} 2133 * @private 2134 */ 2135const getOrCreatePrecacheController_getOrCreatePrecacheController = () => { 2136 if (!precacheController) { 2137 precacheController = new PrecacheController(); 2138 } 2139 return precacheController; 2140}; 2141 2142;// CONCATENATED MODULE: ./node_modules/workbox-precaching/addPlugins.js 2143/* 2144 Copyright 2019 Google LLC 2145 2146 Use of this source code is governed by an MIT-style 2147 license that can be found in the LICENSE file or at 2148 https://opensource.org/licenses/MIT. 2149*/ 2150 2151 2152/** 2153 * Adds plugins to the precaching strategy. 2154 * 2155 * @param {Array<Object>} plugins 2156 * 2157 * @memberof module:workbox-precaching 2158 */ 2159function addPlugins(plugins) { 2160 const precacheController = getOrCreatePrecacheController(); 2161 precacheController.strategy.plugins.push(...plugins); 2162} 2163 2164 2165// EXTERNAL MODULE: ./node_modules/workbox-routing/_version.js 2166var workbox_routing_version = __webpack_require__(80); 2167;// CONCATENATED MODULE: ./node_modules/workbox-routing/utils/constants.js 2168/* 2169 Copyright 2018 Google LLC 2170 2171 Use of this source code is governed by an MIT-style 2172 license that can be found in the LICENSE file or at 2173 https://opensource.org/licenses/MIT. 2174*/ 2175 2176/** 2177 * The default HTTP method, 'GET', used when there's no specific method 2178 * configured for a route. 2179 * 2180 * @type {string} 2181 * 2182 * @private 2183 */ 2184const defaultMethod = 'GET'; 2185/** 2186 * The list of valid HTTP methods associated with requests that could be routed. 2187 * 2188 * @type {Array<string>} 2189 * 2190 * @private 2191 */ 2192const validMethods = (/* unused pure expression or super */ null && ([ 2193 'DELETE', 2194 'GET', 2195 'HEAD', 2196 'PATCH', 2197 'POST', 2198 'PUT', 2199])); 2200 2201;// CONCATENATED MODULE: ./node_modules/workbox-routing/utils/normalizeHandler.js 2202/* 2203 Copyright 2018 Google LLC 2204 2205 Use of this source code is governed by an MIT-style 2206 license that can be found in the LICENSE file or at 2207 https://opensource.org/licenses/MIT. 2208*/ 2209 2210 2211/** 2212 * @param {function()|Object} handler Either a function, or an object with a 2213 * 'handle' method. 2214 * @return {Object} An object with a handle method. 2215 * 2216 * @private 2217 */ 2218const normalizeHandler = (handler) => { 2219 if (handler && typeof handler === 'object') { 2220 if (false) {} 2221 return handler; 2222 } 2223 else { 2224 if (false) {} 2225 return { handle: handler }; 2226 } 2227}; 2228 2229;// CONCATENATED MODULE: ./node_modules/workbox-routing/Route.js 2230/* 2231 Copyright 2018 Google LLC 2232 2233 Use of this source code is governed by an MIT-style 2234 license that can be found in the LICENSE file or at 2235 https://opensource.org/licenses/MIT. 2236*/ 2237 2238 2239 2240 2241/** 2242 * A `Route` consists of a pair of callback functions, "match" and "handler". 2243 * The "match" callback determine if a route should be used to "handle" a 2244 * request by returning a non-falsy value if it can. The "handler" callback 2245 * is called when there is a match and should return a Promise that resolves 2246 * to a `Response`. 2247 * 2248 * @memberof module:workbox-routing 2249 */ 2250class Route_Route { 2251 /** 2252 * Constructor for Route class. 2253 * 2254 * @param {module:workbox-routing~matchCallback} match 2255 * A callback function that determines whether the route matches a given 2256 * `fetch` event by returning a non-falsy value. 2257 * @param {module:workbox-routing~handlerCallback} handler A callback 2258 * function that returns a Promise resolving to a Response. 2259 * @param {string} [method='GET'] The HTTP method to match the Route 2260 * against. 2261 */ 2262 constructor(match, handler, method = defaultMethod) { 2263 if (false) {} 2264 // These values are referenced directly by Router so cannot be 2265 // altered by minificaton. 2266 this.handler = normalizeHandler(handler); 2267 this.match = match; 2268 this.method = method; 2269 } 2270 /** 2271 * 2272 * @param {module:workbox-routing-handlerCallback}
2272 handler A callback 2273 * function that returns a Promise resolving to a Response 2274 */ 2275 setCatchHandler(handler) { 2276 this.catchHandler = normalizeHandler(handler); 2277 } 2278} 2279 2280 2281;// CONCATENATED MODULE: ./node_modules/workbox-routing/RegExpRoute.js 2282/* 2283 Copyright 2018 Google LLC 2284 2285 Use of this source code is governed by an MIT-style 2286 license that can be found in the LICENSE file or at 2287 https://opensource.org/licenses/MIT. 2288*/ 2289 2290 2291 2292 2293/** 2294 * RegExpRoute makes it easy to create a regular expression based 2295 * [Route]{@link module:workbox-routing.Route}. 2296 * 2297 * For same-origin requests the RegExp only needs to match part of the URL. For 2298 * requests against third-party servers, you must define a RegExp that matches 2299 * the start of the URL. 2300 * 2301 * [See the module docs for info.]{@link https://developers.google.com/web/tools/workbox/modules/workbox-routing} 2302 * 2303 * @memberof module:workbox-routing 2304 * @extends module:workbox-routing.Route 2305 */ 2306class RegExpRoute extends Route_Route { 2307 /** 2308 * If the regular expression contains 2309 * [capture groups]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#grouping-back-references}, 2310 * the captured values will be passed to the 2311 * [handler's]{@link module:workbox-routing~handlerCallback} `params` 2312 * argument. 2313 * 2314 * @param {RegExp} regExp The regular expression to match against URLs. 2315 * @param {module:workbox-routing~handlerCallback} handler A callback 2316 * function that returns a Promise resulting in a Response. 2317 * @param {string} [method='GET'] The HTTP method to match the Route 2318 * against. 2319 */ 2320 constructor(regExp, handler, method) { 2321 if (false) {} 2322 const match = ({ url }) => { 2323 const result = regExp.exec(url.href); 2324 // Return immediately if there's no match. 2325 if (!result) { 2326 return; 2327 } 2328 // Require that the match start at the first character in the URL string 2329 // if it's a cross-origin request. 2330 // See https://github.com/GoogleChrome/workbox/issues/281 for the context 2331 // behind this behavior. 2332 if ((url.origin !== location.origin) && (result.index !== 0)) { 2333 if (false) {} 2334 return; 2335 } 2336 // If the route matches, but there aren't any capture groups defined, then 2337 // this will return [], which is truthy and therefore sufficient to 2338 // indicate a match. 2339 // If there are capture groups, then it will return their values. 2340 return result.slice(1); 2341 }; 2342 super(match, handler, method); 2343 } 2344} 2345 2346 2347;// CONCATENATED MODULE: ./node_modules/workbox-routing/Router.js 2348/* 2349 Copyright 2018 Google LLC 2350 2351 Use of this source code is governed by an MIT-style 2352 license that can be found in the LICENSE file or at 2353 https://opensource.org/licenses/MIT. 2354*/ 2355 2356 2357 2358 2359 2360 2361 2362/** 2363 * The Router can be used to process a FetchEvent through one or more 2364 * [Routes]{@link module:workbox-routing.Route} responding with a Request if 2365 * a matching route exists. 2366 * 2367 * If no route matches a given a request, the Router will use a "default" 2368 * handler if one is defined. 2369 * 2370 * Should the matching Route throw an error, the Router will use a "catch" 2371 * handler if one is defined to gracefully deal with issues and respond with a 2372 * Request. 2373 * 2374 * If a request matches multiple routes, the **earliest** registered route will 2375 * be used to respond to the request. 2376 * 2377 * @memberof module:workbox-routing 2378 */ 2379class Router { 2380 /** 2381 * Initializes a new Router. 2382 */ 2383 constructor() { 2384 this._routes = new Map(); 2385 this._defaultHandlerMap = new Map(); 2386 } 2387 /** 2388 * @return {Map<string, Array<module:workbox-routing.Route>>} routes A `Map` of HTTP 2389 * method name ('GET', etc.) to an array of all the corresponding `Route` 2390 * instances that are registered. 2391 */ 2392 get routes() { 2393 return this._routes; 2394 } 2395 /** 2396 * Adds a fetch event listener to respond to events when a route matches 2397 * the event's request. 2398 */ 2399 addFetchListener() { 2400 // See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 2401 self.addEventListener('fetch', ((event) => { 2402 const { request } = event; 2403 const responsePromise = this.handleRequest({ request, event }); 2404 if (responsePromise) { 2405 event.respondWith(responsePromise); 2406 } 2407 })); 2408 } 2409 /** 2410 * Adds a message event listener for URLs to cache from the window. 2411 * This is useful to cache resources loaded on the page prior to when the 2412 * service worker started controlling it. 2413 * 2414 * The format of the message data sent from the window should be as follows. 2415 * Where the `urlsToCache` array may consist of URL strings or an array of 2416 * URL string + `requestInit` object (the same as you'd pass to `fetch()`). 2417 * 2418 * ``` 2419 * { 2420 * type: 'CACHE_URLS', 2421 * payload: { 2422 * urlsToCache: [ 2423 * './script1.js', 2424 * './script2.js', 2425 * ['./script3.js', {mode: 'no-cors'}], 2426 * ], 2427 * }, 2428 * } 2429 * ``` 2430 */ 2431 addCacheListener() { 2432 // See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 2433 self.addEventListener('message', ((event) => { 2434 if (event.data && event.data.type === 'CACHE_URLS') { 2435 const { payload } = event.data; 2436 if (false) {} 2437 const requestPromises = Promise.all(payload.urlsToCache.map((entry) => { 2438 if (typeof entry === 'string') { 2439 entry = [entry]; 2440 }
2441 const request = new Request(...entry); 2442 return this.handleRequest({ request, event }); 2443 // TODO(philipwalton): TypeScript errors without this typecast for 2444 // some reason (probably a bug). The real type here should work but 2445 // doesn't: `Array<Promise<Response> | undefined>`. 2446 })); // TypeScript 2447 event.waitUntil(requestPromises); 2448 // If a MessageChannel was used, reply to the message on success. 2449 if (event.ports && event.ports[0]) { 2450 requestPromises.then(() => event.ports[0].postMessage(true)); 2451 } 2452 } 2453 })); 2454 } 2455 /** 2456 * Apply the routing rules to a FetchEvent object to get a Response from an 2457 * appropriate Route's handler. 2458 * 2459 * @param {Object} options 2460 * @param {Request} options.request The request to handle. 2461 * @param {ExtendableEvent} options.event The event that triggered the 2462 * request. 2463 * @return {Promise<Response>|undefined} A promise is returned if a 2464 * registered route can handle the request. If there is no matching 2465 * route and there's no `defaultHandler`, `undefined` is returned. 2466 */ 2467 handleRequest({ request, event }) { 2468 if (false) {} 2469 const url = new URL(request.url, location.href); 2470 if (!url.protocol.startsWith('http')) { 2471 if (false) {} 2472 return; 2473 } 2474 const sameOrigin = url.origin === location.origin; 2475 const { params, route } = this.findMatchingRoute({ 2476 event, 2477 request, 2478 sameOrigin, 2479 url, 2480 }); 2481 let handler = route && route.handler; 2482 const debugMessages = []; 2483 if (false) {} 2484 // If we don't have a handler because there was no matching route, then 2485 // fall back to defaultHandler if that's defined. 2486 const method = request.method; 2487 if (!handler && this._defaultHandlerMap.has(method)) { 2488 if (false) {} 2489 handler = this._defaultHandlerMap.get(method); 2490 } 2491 if (!handler) { 2492 if (false) {} 2493 return; 2494 } 2495 if (false) {} 2496 // Wrap in try and catch in case the handle method throws a synchronous 2497 // error. It should still callback to the catch handler. 2498 let responsePromise; 2499 try { 2500 responsePromise = handler.handle({ url, request, event, params }); 2501 } 2502 catch (err) { 2503 responsePromise = Promise.reject(err); 2504 } 2505 // Get route's catch handler, if it exists 2506 const catchHandler = route && route.catchHandler; 2507 if (responsePromise instanceof Promise && (this._catchHandler || catchHandler)) { 2508 responsePromise = responsePromise.catch(async (err) => { 2509 // If there's a route catch handler, process that first 2510 if (catchHandler) { 2511 if (false) {} 2512 try { 2513 return await catchHandler.handle({ url, request, event, params }); 2514 } 2515 catch (catchErr) { 2516 err = catchErr; 2517 } 2518 } 2519 if (this._catchHandler) { 2520 if (false) {} 2521 return this._catchHandler.handle({ url, request, event }); 2522 } 2523 throw err; 2524 }); 2525 } 2526 return responsePromise; 2527 } 2528 /** 2529 * Checks a request and URL (and optionally an event) against the list of 2530 * registered routes, and if there's a match, returns the corresponding 2531 * route along with any params generated by the match. 2532 * 2533 * @param {Object} options 2534 * @param {URL} options.url 2535 * @param {boolean} options.sameOrigin The result of comparing `url.origin` 2536 * against the current origin. 2537 * @param {Request} options.request The request to match. 2538 * @param {Event} options.event The corresponding event. 2539 * @return {Object} An object with `route` and `params` properties. 2540 * They are populated if a matching route was found or `undefined` 2541 * otherwise. 2542 */ 2543 findMatchingRoute({ url, sameOrigin, request, event }) { 2544 const routes = this._routes.get(request.method) || []; 2545 for (const route of routes) { 2546 let params; 2547 const matchResult = route.match({ url, sameOrigin, request, event }); 2548 if (matchResult) { 2549 if (false) {} 2550 // See https://github.com/GoogleChrome/workbox/issues/2079 2551 params = matchResult; 2552 if (Array.isArray(matchResult) && matchResult.length === 0) { 2553 // Instead of passing an empty array in as params, use undefined. 2554 params = undefined; 2555 } 2556 else if ((matchResult.constructor === Object && 2557 Object.keys(matchResult).length === 0)) { 2558 // Instead of passing an empty object in as params, use undefined. 2559 params = undefined; 2560 } 2561 else if (typeof matchResult === 'boolean') { 2562 // For the boolean value true (rather than just something truth-y), 2563 // don't set params. 2564 // See https://github.com/GoogleChrome/workbox/pull/2134#issuecomment-513924353 2565 params = undefined; 2566 } 2567 // Return early if have a match. 2568 return { route, params }; 2569 } 2570 } 2571 // If no match was found above, return and empty object. 2572 return {}; 2573 } 2574 /** 2575 * Define a default `handler` that's called when no routes explicitly 2576 * match the incoming request. 2577 * 2578 * Each HTTP method ('GET', 'POST', etc.) gets its own default handler. 2579 * 2580 * Without a default handler, unmatched requests will go against the 2581 * network as if there were no service worker present. 2582 * 2583 * @param {module:workbox-routing~handlerCallback}
2583 handler A callback 2584 * function that returns a Promise resulting in a Response. 2585 * @param {string} [method='GET'] The HTTP method to associate with this 2586 * default handler. Each method has its own default. 2587 */ 2588 setDefaultHandler(handler, method = defaultMethod) { 2589 this._defaultHandlerMap.set(method, normalizeHandler(handler)); 2590 } 2591 /** 2592 * If a Route throws an error while handling a request, this `handler` 2593 * will be called and given a chance to provide a response. 2594 * 2595 * @param {module:workbox-routing~handlerCallback} handler A callback 2596 * function that returns a Promise resulting in a Response. 2597 */ 2598 setCatchHandler(handler) { 2599 this._catchHandler = normalizeHandler(handler); 2600 } 2601 /** 2602 * Registers a route with the router. 2603 * 2604 * @param {module:workbox-routing.Route} route The route to register. 2605 */ 2606 registerRoute(route) { 2607 if (false) {} 2608 if (!this._routes.has(route.method)) { 2609 this._routes.set(route.method, []); 2610 } 2611 // Give precedence to all of the earlier routes by adding this additional 2612 // route to the end of the array. 2613 this._routes.get(route.method).push(route); 2614 } 2615 /** 2616 * Unregisters a route with the router. 2617 * 2618 * @param {module:workbox-routing.Route} route The route to unregister. 2619 */ 2620 unregisterRoute(route) { 2621 if (!this._routes.has(route.method)) { 2622 throw new WorkboxError_WorkboxError('unregister-route-but-not-found-with-method', { 2623 method: route.method, 2624 }); 2625 } 2626 const routeIndex = this._routes.get(route.method).indexOf(route); 2627 if (routeIndex > -1) { 2628 this._routes.get(route.method).splice(routeIndex, 1); 2629 } 2630 else { 2631 throw new WorkboxError_WorkboxError('unregister-route-route-not-registered'); 2632 } 2633 } 2634} 2635 2636 2637;// CONCATENATED MODULE: ./node_modules/workbox-routing/utils/getOrCreateDefaultRouter.js 2638/* 2639 Copyright 2019 Google LLC 2640 2641 Use of this source code is governed by an MIT-style 2642 license that can be found in the LICENSE file or at 2643 https://opensource.org/licenses/MIT. 2644*/ 2645 2646 2647let defaultRouter; 2648/** 2649 * Creates a new, singleton Router instance if one does not exist. If one 2650 * does already exist, that instance is returned. 2651 * 2652 * @private 2653 * @return {Router} 2654 */ 2655const getOrCreateDefaultRouter_getOrCreateDefaultRouter = () => { 2656 if (!defaultRouter) { 2657 defaultRouter = new Router(); 2658 // The helpers that use the default Router assume these listeners exist. 2659 defaultRouter.addFetchListener(); 2660 defaultRouter.addCacheListener(); 2661 } 2662 return defaultRouter; 2663}; 2664 2665;// CONCATENATED MODULE: ./node_modules/workbox-routing/registerRoute.js 2666/* 2667 Copyright 2019 Google LLC 2668 2669 Use of this source code is governed by an MIT-style 2670 license that can be found in the LICENSE file or at 2671 https://opensource.org/licenses/MIT. 2672*/ 2673 2674 2675 2676 2677 2678 2679/** 2680 * Easily register a RegExp, string, or function with a caching 2681 * strategy to a singleton Router instance. 2682 * 2683 * This method will generate a Route for you if needed and 2684 * call [registerRoute()]{@link module:workbox-routing.Router#registerRoute}. 2685 * 2686 * @param {RegExp|string|module:workbox-routing.Route~matchCallback|module:workbox-routing.Route} capture 2687 * If the capture param is a `Route`, all other arguments will be ignored. 2688 * @param {module:workbox-routing~handlerCallback} [handler] A callback 2689 * function that returns a Promise resulting in a Response. This parameter 2690 * is required if `capture` is not a `Route` object. 2691 * @param {string} [method='GET'] The HTTP method to match the Route 2692 * against. 2693 * @return {module:workbox-routing.Route} The generated `Route`(Useful for 2694 * unregistering). 2695 * 2696 * @memberof module:workbox-routing 2697 */ 2698function registerRoute(capture, handler, method) { 2699 let route; 2700 if (typeof capture === 'string') { 2701 const captureUrl = new URL(capture, location.href); 2702 if (false) {} 2703 const matchCallback = ({ url }) => { 2704 if (false) {} 2705 return url.href === captureUrl.href; 2706 }; 2707 // If `capture` is a string then `handler` and `method` must be present. 2708 route = new Route_Route(matchCallback, handler, method); 2709 } 2710 else if (capture instanceof RegExp) { 2711 // If `capture` is a `RegExp` then `handler` and `method` must be present. 2712 route = new RegExpRoute(capture, handler, method); 2713 } 2714 else if (typeof capture === 'function') { 2715 // If `capture` is a function then `handler` and `method` must be present. 2716 route = new Route_Route(capture, handler, method); 2717 } 2718 else if (capture instanceof Route_Route) { 2719 route = capture; 2720 } 2721 else { 2722 throw new WorkboxError_WorkboxError('unsupported-route-type', { 2723 moduleName: 'workbox-routing', 2724 funcName: 'registerRoute', 2725 paramName: 'capture', 2726 }); 2727 } 2728 const defaultRouter = getOrCreateDefaultRouter_getOrCreateDefaultRouter(); 2729 defaultRouter.registerRoute(route); 2730 return route; 2731} 2732 2733 2734;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/removeIgnoredSearchParams.js 2735/* 2736 Copyright 2018 Google LLC 2737 2738 Use of this source code is governed by an MIT-style 2739 license that can be found in the LICENSE file or at 2740 https://opensource.org/licenses/MIT.
2741*/ 2742 2743/** 2744 * Removes any URL search parameters that should be ignored. 2745 * 2746 * @param {URL} urlObject The original URL. 2747 * @param {Array<RegExp>} ignoreURLParametersMatching RegExps to test against 2748 * each search parameter name. Matches mean that the search parameter should be 2749 * ignored. 2750 * @return {URL} The URL with any ignored search parameters removed. 2751 * 2752 * @private 2753 * @memberof module:workbox-precaching 2754 */ 2755function removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching = []) { 2756 // Convert the iterable into an array at the start of the loop to make sure 2757 // deletion doesn't mess up iteration. 2758 for (const paramName of [...urlObject.searchParams.keys()]) { 2759 if (ignoreURLParametersMatching.some((regExp) => regExp.test(paramName))) { 2760 urlObject.searchParams.delete(paramName); 2761 } 2762 } 2763 return urlObject; 2764} 2765 2766;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/generateURLVariations.js 2767/* 2768 Copyright 2019 Google LLC 2769 2770 Use of this source code is governed by an MIT-style 2771 license that can be found in the LICENSE file or at 2772 https://opensource.org/licenses/MIT. 2773*/ 2774 2775 2776/** 2777 * Generator function that yields possible variations on the original URL to 2778 * check, one at a time. 2779 * 2780 * @param {string} url 2781 * @param {Object} options 2782 * 2783 * @private 2784 * @memberof module:workbox-precaching 2785 */ 2786function* generateURLVariations(url, { ignoreURLParametersMatching = [/^utm_/, /^fbclid$/], directoryIndex = 'index.html', cleanURLs = true, urlManipulation, } = {}) { 2787 const urlObject = new URL(url, location.href); 2788 urlObject.hash = ''; 2789 yield urlObject.href; 2790 const urlWithoutIgnoredParams = removeIgnoredSearchParams(urlObject, ignoreURLParametersMatching); 2791 yield urlWithoutIgnoredParams.href; 2792 if (directoryIndex && urlWithoutIgnoredParams.pathname.endsWith('/')) { 2793 const directoryURL = new URL(urlWithoutIgnoredParams.href); 2794 directoryURL.pathname += directoryIndex; 2795 yield directoryURL.href; 2796 } 2797 if (cleanURLs) { 2798 const cleanURL = new URL(urlWithoutIgnoredParams.href); 2799 cleanURL.pathname += '.html'; 2800 yield cleanURL.href; 2801 } 2802 if (urlManipulation) { 2803 const additionalURLs = urlManipulation({ url: urlObject }); 2804 for (const urlToAttempt of additionalURLs) { 2805 yield urlToAttempt.href; 2806 } 2807 } 2808} 2809 2810;// CONCATENATED MODULE: ./node_modules/workbox-precaching/PrecacheRoute.js 2811/* 2812 Copyright 2020 Google LLC 2813 2814 Use of this source code is governed by an MIT-style 2815 license that can be found in the LICENSE file or at 2816 https://opensource.org/licenses/MIT. 2817*/ 2818 2819 2820 2821 2822 2823/** 2824 * A subclass of [Route]{@link module:workbox-routing.Route} that takes a 2825 * [PrecacheController]{@link module:workbox-precaching.PrecacheController} 2826 * instance and uses it to match incoming requests and handle fetching 2827 * responses from the precache. 2828 * 2829 * @memberof module:workbox-precaching 2830 * @extends module:workbox-routing.Route 2831 */ 2832class PrecacheRoute extends Route_Route { 2833 /** 2834 * @param {PrecacheController} precacheController A `PrecacheController` 2835 * instance used to both match requests and respond to fetch events. 2836 * @param {Object} [options] Options to control how requests are matched 2837 * against the list of precached URLs. 2838 * @param {string} [options.directoryIndex=index.html] The `directoryIndex` will 2839 * check cache entries for a URLs ending with '/' to see if there is a hit when 2840 * appending the `directoryIndex` value. 2841 * @param {Array<RegExp>} [options.ignoreURLParametersMatching=[/^utm_/, /^fbclid$/]] An 2842 * array of regex's to remove search params when looking for a cache match. 2843 * @param {boolean} [options.cleanURLs=true] The `cleanURLs` option will 2844 * check the cache for the URL with a `.html` added to the end of the end. 2845 * @param {module:workbox-precaching~urlManipulation} [options.urlManipulation] 2846 * This is a function that should take a URL and return an array of 2847 * alternative URLs that should be checked for precache matches. 2848 */ 2849 constructor(precacheController, options) { 2850 const match = ({ request }) => {
2851 const urlsToCacheKeys = precacheController.getURLsToCacheKeys(); 2852 for (const possibleURL of generateURLVariations(request.url, options)) { 2853 const cacheKey = urlsToCacheKeys.get(possibleURL); 2854 if (cacheKey) { 2855 return { cacheKey }; 2856 } 2857 } 2858 if (false) {} 2859 return; 2860 }; 2861 super(match, precacheController.strategy); 2862 } 2863} 2864 2865 2866;// CONCATENATED MODULE: ./node_modules/workbox-precaching/addRoute.js 2867/* 2868 Copyright 2019 Google LLC 2869 Use of this source code is governed by an MIT-style 2870 license that can be found in the LICENSE file or at 2871 https://opensource.org/licenses/MIT. 2872*/ 2873 2874 2875 2876 2877/** 2878 * Add a `fetch` listener to the service worker that will 2879 * respond to 2880 * [network requests]{@link https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Custom_responses_to_requests} 2881 * with precached assets. 2882 * 2883 * Requests for assets that aren't precached, the `FetchEvent` will not be 2884 * responded to, allowing the event to fall through to other `fetch` event 2885 * listeners. 2886 * 2887 * @param {Object} [options] See 2888 * [PrecacheRoute options]{@link module:workbox-precaching.PrecacheRoute}. 2889 * 2890 * @memberof module:workbox-precaching 2891 */ 2892function addRoute(options) { 2893 const precacheController = getOrCreatePrecacheController_getOrCreatePrecacheController(); 2894 const precacheRoute = new PrecacheRoute(precacheController, options); 2895 registerRoute(precacheRoute); 2896} 2897 2898 2899;// CONCATENATED MODULE: ./node_modules/workbox-precaching/utils/deleteOutdatedCaches.js 2900/* 2901 Copyright 2018 Google LLC 2902 2903 Use of this source code is governed by an MIT-style 2904 license that can be found in the LICENSE file or at 2905 https://opensource.org/licenses/MIT. 2906*/ 2907 2908const SUBSTRING_TO_FIND = '-precache-'; 2909/** 2910 * Cleans up incompatible precaches that were created by older versions of 2911 * Workbox, by a service worker registered under the current scope. 2912 * 2913 * This is meant to be called as part of the `activate` event. 2914 * 2915 * This should be safe to use as long as you don't include `substringToFind` 2916 * (defaulting to `-precache-`) in your non-precache cache names. 2917 * 2918 * @param {string} currentPrecacheName The cache name currently in use for 2919 * precaching. This cache won't be deleted. 2920 * @param {string} [substringToFind='-precache-'] Cache names which include this 2921 * substring will be deleted (excluding `currentPrecacheName`). 2922 * @return {Array<string>} A list of all the cache names that were deleted. 2923 * 2924 * @private 2925 * @memberof module:workbox-precaching 2926 */ 2927const deleteOutdatedCaches_deleteOutdatedCaches = async (currentPrecacheName, substringToFind = SUBSTRING_TO_FIND) => { 2928 const cacheNames = await self.caches.keys(); 2929 const cacheNamesToDelete = cacheNames.filter((cacheName) => { 2930 return cacheName.includes(substringToFind) && 2931 cacheName.includes(self.registration.scope) && 2932 cacheName !== currentPrecacheName; 2933 }); 2934 await Promise.all(cacheNamesToDelete.map((cacheName) => self.caches.delete(cacheName))); 2935 return cacheNamesToDelete; 2936}; 2937 2938 2939;// CONCATENATED MODULE: ./node_modules/workbox-precaching/cleanupOutdatedCaches.js 2940/* 2941 Copyright 2019 Google LLC 2942 2943 Use of this source code is governed by an MIT-style 2944 license that can be found in the LICENSE file or at 2945 https://opensource.org/licenses/MIT. 2946*/ 2947 2948 2949 2950 2951/** 2952 * Adds an `activate` event listener which will clean up incompatible 2953 * precaches that were created by older versions of Workbox. 2954 * 2955 * @memberof module:workbox-precaching 2956 */ 2957function cleanupOutdatedCaches() { 2958 // See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705 2959 self.addEventListener('activate', ((event) => { 2960 const cacheName = cacheNames.getPrecacheName(); 2961 event.waitUntil(deleteOutdatedCaches(cacheName).then((cachesDeleted) => { 2962 if (false) {} 2963 })); 2964 })); 2965} 2966 2967 2968;// CONCATENATED MODULE: ./node_modules/workbox-precaching/createHandlerBoundToURL.js 2969/* 2970 Copyright 2019 Google LLC 2971 2972 Use of this source code is governed by an MIT-style 2973 license that can be found in the LICENSE file or at 2974 https://opensource.org/licenses/MIT.
2975*/ 2976 2977 2978/** 2979 * Helper function that calls 2980 * {@link PrecacheController#createHandlerBoundToURL} on the default 2981 * {@link PrecacheController} instance. 2982 * 2983 * If you are creating your own {@link PrecacheController}, then call the 2984 * {@link PrecacheController#createHandlerBoundToURL} on that instance, 2985 * instead of using this function. 2986 * 2987 * @param {string} url The precached URL which will be used to lookup the 2988 * `Response`. 2989 * @param {boolean} [fallbackToNetwork=true] Whether to attempt to get the 2990 * response from the network if there's a precache miss. 2991 * @return {module:workbox-routing~handlerCallback} 2992 * 2993 * @memberof module:workbox-precaching 2994 */ 2995function createHandlerBoundToURL(url) { 2996 const precacheController = getOrCreatePrecacheController(); 2997 return precacheController.createHandlerBoundToURL(url); 2998} 2999 3000 3001;// CONCATENATED MODULE: ./node_modules/workbox-precaching/getCacheKeyForURL.js 3002/* 3003 Copyright 2019 Google LLC 3004 3005 Use of this source code is governed by an MIT-style 3006 license that can be found in the LICENSE file or at 3007 https://opensource.org/licenses/MIT. 3008*/ 3009 3010 3011/** 3012 * Takes in a URL, and returns the corresponding URL that could be used to 3013 * lookup the entry in the precache. 3014 * 3015 * If a relative URL is provided, the location of the service worker file will 3016 * be used as the base. 3017 * 3018 * For precached entries without revision information, the cache key will be the 3019 * same as the original URL. 3020 * 3021 * For precached entries with revision information, the cache key will be the 3022 * original URL with the addition of a query parameter used for keeping track of 3023 * the revision info. 3024 * 3025 * @param {string} url The URL whose cache key to look up. 3026 * @return {string} The cache key that corresponds to that URL. 3027 * 3028 * @memberof module:workbox-precaching 3029 */ 3030function getCacheKeyForURL(url) { 3031 const precacheController = getOrCreatePrecacheController(); 3032 return precacheController.getCacheKeyForURL(url); 3033} 3034 3035 3036;// CONCATENATED MODULE: ./node_modules/workbox-precaching/matchPrecache.js 3037/* 3038 Copyright 2019 Google LLC 3039 3040 Use of this source code is governed by an MIT-style 3041 license that can be found in the LICENSE file or at 3042 https://opensource.org/licenses/MIT. 3043*/ 3044 3045 3046/** 3047 * Helper function that calls 3048 * {@link PrecacheController#matchPrecache} on the default 3049 * {@link PrecacheController} instance. 3050 * 3051 * If you are creating your own {@link PrecacheController}, then call 3052 * {@link PrecacheController#matchPrecache} on that instance, 3053 * instead of using this function. 3054 * 3055 * @param {string|Request} request The key (without revisioning parameters) 3056 * to look up in the precache. 3057 * @return {Promise<Response|undefined>} 3058 * 3059 * @memberof module:workbox-precaching 3060 */ 3061function matchPrecache(request) { 3062 const precacheController = getOrCreatePrecacheController(); 3063 return precacheController.matchPrecache(request); 3064} 3065 3066 3067;// CONCATENATED MODULE: ./node_modules/workbox-precaching/precache.js 3068/* 3069 Copyright 2019 Google LLC 3070 3071 Use of this source code is governed by an MIT-style 3072 license that can be found in the LICENSE file or at 3073 https://opensource.org/licenses/MIT. 3074*/ 3075 3076 3077/** 3078 * Adds items to the precache list, removing any duplicates and 3079 * stores the files in the 3080 * ["precache cache"]{@link module:workbox-core.cacheNames} when the service 3081 * worker installs. 3082 * 3083 * This method can be called multiple times. 3084 * 3085 * Please note: This method **will not** serve any of the cached files for you. 3086 * It only precaches files. To respond to a network request you call 3087 * [addRoute()]{@link module:workbox-precaching.addRoute}. 3088 * 3089 * If you have a single array of files to precache, you can just call 3090 * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute}. 3091 * 3092 * @param {Array<Object|string>} [entries=[]] Array of entries to precache. 3093 * 3094 * @memberof module:workbox-precaching 3095 */ 3096function precache(entries) { 3097 const precacheController = getOrCreatePrecacheController_getOrCreatePrecacheController(); 3098 precacheController.precache(entries); 3099} 3100 3101 3102;// CONCATENATED MODULE: ./node_modules/workbox-precaching/precacheAndRoute.js 3103/* 3104 Copyright 2019 Google LLC 3105 3106 Use of this source code is governed by an MIT-style 3107 license that can be found in the LICENSE file or at 3108 https://opensource.org/licenses/MIT.
3109*/ 3110 3111 3112 3113/** 3114 * This method will add entries to the precache list and add a route to 3115 * respond to fetch events. 3116 * 3117 * This is a convenience method that will call 3118 * [precache()]{@link module:workbox-precaching.precache} and 3119 * [addRoute()]{@link module:workbox-precaching.addRoute} in a single call. 3120 * 3121 * @param {Array<Object|string>} entries Array of entries to precache. 3122 * @param {Object} [options] See 3123 * [PrecacheRoute options]{@link module:workbox-precaching.PrecacheRoute}. 3124 * 3125 * @memberof module:workbox-precaching 3126 */ 3127function precacheAndRoute(entries, options) { 3128 precache(entries); 3129 addRoute(options); 3130} 3131 3132 3133;// CONCATENATED MODULE: ./node_modules/workbox-precaching/PrecacheFallbackPlugin.js 3134/* 3135 Copyright 2020 Google LLC 3136 3137 Use of this source code is governed by an MIT-style 3138 license that can be found in the LICENSE file or at 3139 https://opensource.org/licenses/MIT. 3140*/ 3141 3142 3143/** 3144 * `PrecacheFallbackPlugin` allows you to specify an "offline fallback" 3145 * response to be used when a given strategy is unable to generate a response. 3146 * 3147 * It does this by intercepting the `handlerDidError` plugin callback 3148 * and returning a precached response, taking the expected revision parameter 3149 * into account automatically. 3150 * 3151 * Unless you explicitly pass in a `PrecacheController` instance to the 3152 * constructor, the default instance will be used. Generally speaking, most 3153 * developers will end up using the default. 3154 * 3155 * @memberof module:workbox-precaching 3156 */ 3157class PrecacheFallbackPlugin { 3158 /** 3159 * Constructs a new PrecacheFallbackPlugin with the associated fallbackURL. 3160 * 3161 * @param {Object} config 3162 * @param {string} config.fallbackURL A precached URL to use as the fallback 3163 * if the associated strategy can't generate a response. 3164 * @param {PrecacheController} [config.precacheController] An optional 3165 * PrecacheController instance. If not provided, the default 3166 * PrecacheController will be used. 3167 */ 3168 constructor({ fallbackURL, precacheController }) { 3169 /** 3170 * @return {Promise<Response>} The precache response for the fallback URL. 3171 * 3172 * @private 3173 */ 3174 this.handlerDidError = () => this._precacheController.matchPrecache(this._fallbackURL); 3175 this._fallbackURL = fallbackURL; 3176 this._precacheController = precacheController || 3177 getOrCreatePrecacheController(); 3178 } 3179} 3180 3181 3182;// CONCATENATED MODULE: ./node_modules/workbox-precaching/index.js 3183/* 3184 Copyright 2018 Google LLC 3185 3186 Use of this source code is governed by an MIT-style 3187 license that can be found in the LICENSE file or at 3188 https://opensource.org/licenses/MIT. 3189*/ 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203/** 3204 * Most consumers of this module will want to use the 3205 * [precacheAndRoute()]{@link module:workbox-precaching.precacheAndRoute} 3206 * method to add assets to the cache and respond to network requests with these 3207 * cached assets. 3208 * 3209 * If you require more control over caching and routing, you can use the 3210 * [PrecacheController]{@link module:workbox-precaching.PrecacheController} 3211 * interface. 3212 * 3213 * @module workbox-precaching 3214 */ 3215 3216 3217;// CONCATENATED MODULE: ./node_modules/workbox-precaching/index.mjs 3218 3219;// CONCATENATED MODULE: ./node_modules/workbox-routing/NavigationRoute.js 3220/* 3221 Copyright 2018 Google LLC 3222 3223 Use of this source code is governed by an MIT-style 3224 license that can be found in the LICENSE file or at 3225 https://opensource.org/licenses/MIT. 3226*/ 3227 3228 3229 3230 3231/** 3232 * NavigationRoute makes it easy to create a 3233 * [Route]{@link module:workbox-routing.Route} that matches for browser 3234 * [navigation requests]{@link https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests}. 3235 * 3236 * It will only match incoming Requests whose 3237 * [`mode`]{@link https://fetch.spec.whatwg.org/#concept-request-mode} 3238 * is set to `navigate`. 3239 * 3240 * You can optionally only apply this route to a subset of navigation requests 3241 * by using one or both of the `denylist` and `allowlist` parameters. 3242 * 3243 * @memberof module:workbox-routing 3244 * @extends module:workbox-routing.Route 3245 */ 3246class NavigationRoute extends (/* unused pure expression or super */ null && (Route)) { 3247 /** 3248 * If both `denylist` and `allowlist` are provided, the `denylist` will 3249 * take precedence and the request will not match this route. 3250 * 3251 * The regular expressions in `allowlist` and `denylist` 3252 * are matched against the concatenated 3253 * [`pathname`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname} 3254 * and [`search`]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/search} 3255 * portions of the requested URL. 3256 * 3257 * @param {module:workbox-routing~handlerCallback}
3257 handler A callback 3258 * function that returns a Promise resulting in a Response. 3259 * @param {Object} options 3260 * @param {Array<RegExp>} [options.denylist] If any of these patterns match, 3261 * the route will not handle the request (even if a allowlist RegExp matches). 3262 * @param {Array<RegExp>} [options.allowlist=[/./]] If any of these patterns 3263 * match the URL's pathname and search parameter, the route will handle the 3264 * request (assuming the denylist doesn't match). 3265 */ 3266 constructor(handler, { allowlist = [/./], denylist = [] } = {}) { 3267 if (false) {} 3268 super((options) => this._match(options), handler); 3269 this._allowlist = allowlist; 3270 this._denylist = denylist; 3271 } 3272 /** 3273 * Routes match handler. 3274 * 3275 * @param {Object} options 3276 * @param {URL} options.url 3277 * @param {Request} options.request 3278 * @return {boolean} 3279 * 3280 * @private 3281 */ 3282 _match({ url, request }) { 3283 if (request && request.mode !== 'navigate') { 3284 return false; 3285 } 3286 const pathnameAndSearch = url.pathname + url.search; 3287 for (const regExp of this._denylist) { 3288 if (regExp.test(pathnameAndSearch)) { 3289 if (false) {} 3290 return false; 3291 } 3292 } 3293 if (this._allowlist.some((regExp) => regExp.test(pathnameAndSearch))) { 3294 if (false) {} 3295 return true; 3296 } 3297 if (false) {} 3298 return false; 3299 } 3300} 3301 3302 3303;// CONCATENATED MODULE: ./node_modules/workbox-routing/setCatchHandler.js 3304/* 3305 Copyright 2019 Google LLC 3306 3307 Use of this source code is governed by an MIT-style 3308 license that can be found in the LICENSE file or at 3309 https://opensource.org/licenses/MIT. 3310*/ 3311 3312 3313/** 3314 * If a Route throws an error while handling a request, this `handler` 3315 * will be called and given a chance to provide a response. 3316 * 3317 * @param {module:workbox-routing~handlerCallback} handler A callback 3318 * function that returns a Promise resulting in a Response. 3319 * 3320 * @memberof module:workbox-routing 3321 */ 3322function setCatchHandler(handler) { 3323 const defaultRouter = getOrCreateDefaultRouter(); 3324 defaultRouter.setCatchHandler(handler); 3325} 3326 3327 3328;// CONCATENATED MODULE: ./node_modules/workbox-routing/setDefaultHandler.js 3329/* 3330 Copyright 2019 Google LLC 3331 3332 Use of this source code is governed by an MIT-style 3333 license that can be found in the LICENSE file or at 3334 https://opensource.org/licenses/MIT. 3335*/ 3336 3337 3338/** 3339 * Define a default `handler` that's called when no routes explicitly 3340 * match the incoming request. 3341 * 3342 * Without a default handler, unmatched requests will go against the 3343 * network as if there were no service worker present. 3344 * 3345 * @param {module:workbox-routing~handlerCallback} handler A callback 3346 * function that returns a Promise resulting in a Response. 3347 * 3348 * @memberof module:workbox-routing 3349 */ 3350function setDefaultHandler(handler) { 3351 const defaultRouter = getOrCreateDefaultRouter(); 3352 defaultRouter.setDefaultHandler(handler); 3353} 3354 3355 3356;// CONCATENATED MODULE: ./node_modules/workbox-routing/index.js 3357/* 3358 Copyright 2018 Google LLC 3359 3360 Use of this source code is governed by an MIT-style 3361 license that can be found in the LICENSE file or at 3362 https://opensource.org/licenses/MIT. 3363*/ 3364 3365 3366 3367 3368 3369 3370 3371 3372/** 3373 * @module workbox-routing 3374 */ 3375 3376 3377;// CONCATENATED MODULE: ./node_modules/workbox-routing/index.mjs 3378 3379;// CONCATENATED MODULE: ./node_modules/workbox-strategies/utils/messages.js 3380/* 3381 Copyright 2018 Google LLC 3382 3383 Use of this source code is governed by an MIT-style 3384 license that can be found in the LICENSE file or at 3385 https://opensource.org/licenses/MIT. 3386*/ 3387 3388 3389 3390const utils_messages_messages = { 3391 strategyStart: (strategyName, request) => `Using ${strategyName} to respond to '${getFriendlyURL(request.url)}'`, 3392 printFinalResponse: (response) => { 3393 if (response) { 3394 logger_logger.groupCollapsed(`View the final response here.`); 3395 logger_logger.log(response || '[No response returned]'); 3396 logger_logger.groupEnd(); 3397 } 3398 }, 3399}; 3400 3401;// CONCATENATED MODULE: ./node_modules/workbox-strategies/CacheFirst.js 3402/* 3403 Copyright 2018 Google LLC 3404 3405 Use of this source code is governed by an MIT-style 3406 license that can be found in the LICENSE file or at 3407 https://opensource.org/licenses/MIT.
3408*/ 3409 3410 3411 3412 3413 3414 3415/** 3416 * An implementation of a [cache-first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network} 3417 * request strategy. 3418 * 3419 * A cache first strategy is useful for assets that have been revisioned, 3420 * such as URLs like `/styles/example.a8f5f1.css`, since they 3421 * can be cached for long periods of time. 3422 * 3423 * If the network request fails, and there is no cache match, this will throw 3424 * a `WorkboxError` exception. 3425 * 3426 * @extends module:workbox-strategies.Strategy 3427 * @memberof module:workbox-strategies 3428 */ 3429class CacheFirst extends Strategy_Strategy { 3430 /** 3431 * @private 3432 * @param {Request|string} request A request to run this strategy for. 3433 * @param {module:workbox-strategies.StrategyHandler} handler The event that 3434 * triggered the request. 3435 * @return {Promise<Response>} 3436 */ 3437 async _handle(request, handler) { 3438 const logs = []; 3439 if (false) {} 3440 let response = await handler.cacheMatch(request); 3441 let error; 3442 if (!response) { 3443 if (false) {} 3444 try { 3445 response = await handler.fetchAndCachePut(request); 3446 } 3447 catch (err) { 3448 error = err; 3449 } 3450 if (false) {} 3451 } 3452 else { 3453 if (false) {} 3454 } 3455 if (false) {} 3456 if (!response) { 3457 throw new WorkboxError_WorkboxError('no-response', { url: request.url, error }); 3458 } 3459 return response; 3460 } 3461} 3462 3463 3464;// CONCATENATED MODULE: ./node_modules/workbox-strategies/CacheOnly.js 3465/* 3466 Copyright 2018 Google LLC 3467 3468 Use of this source code is governed by an MIT-style 3469 license that can be found in the LICENSE file or at 3470 https://opensource.org/licenses/MIT. 3471*/ 3472 3473 3474 3475 3476 3477 3478/** 3479 * An implementation of a 3480 * [cache-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-only} 3481 * request strategy. 3482 * 3483 * This class is useful if you want to take advantage of any 3484 * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}. 3485 * 3486 * If there is no cache match, this will throw a `WorkboxError` exception. 3487 * 3488 * @extends module:workbox-strategies.Strategy 3489 * @memberof module:workbox-strategies 3490 */ 3491class CacheOnly extends (/* unused pure expression or super */ null && (Strategy)) { 3492 /** 3493 * @private 3494 * @param {Request|string} request A request to run this strategy for. 3495 * @param {module:workbox-strategies.StrategyHandler} handler The event that 3496 * triggered the request. 3497 * @return {Promise<Response>} 3498 */ 3499 async _handle(request, handler) { 3500 if (false) {} 3501 const response = await handler.cacheMatch(request); 3502 if (false) {} 3503 if (!response) { 3504 throw new WorkboxError('no-response', { url: request.url }); 3505 } 3506 return response; 3507 } 3508} 3509 3510 3511;// CONCATENATED MODULE: ./node_modules/workbox-strategies/plugins/cacheOkAndOpaquePlugin.js 3512/* 3513 Copyright 2018 Google LLC 3514 3515 Use of this source code is governed by an MIT-style 3516 license that can be found in the LICENSE file or at 3517 https://opensource.org/licenses/MIT. 3518*/ 3519 3520const cacheOkAndOpaquePlugin_cacheOkAndOpaquePlugin = { 3521 /** 3522 * Returns a valid response (to allow caching) if the status is 200 (OK) or 3523 * 0 (opaque). 3524 * 3525 * @param {Object} options 3526 * @param {Response} options.response 3527 * @return {Response|null} 3528 * 3529 * @private 3530 */ 3531 cacheWillUpdate: async ({ response }) => { 3532 if (response.status === 200 || response.status === 0) { 3533 return response; 3534 } 3535 return null; 3536 }, 3537}; 3538 3539;// CONCATENATED MODULE: ./node_modules/workbox-strategies/NetworkFirst.js 3540/* 3541 Copyright 2018 Google LLC 3542 3543 Use of this source code is governed by an MIT-style 3544 license that can be found in the LICENSE file or at 3545 https://opensource.org/licenses/MIT. 3546*/ 3547 3548 3549 3550 3551 3552 3553 3554/** 3555 * An implementation of a 3556 * [network first]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-falling-back-to-cache} 3557 * request strategy. 3558 * 3559 * By default, this strategy will cache responses with a 200 status code as 3560 * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}. 3561 * Opaque responses are are cross-origin requests where the response doesn't 3562 * support [CORS]{@link https://enable-cors.org/}. 3563 * 3564 * If the network request fails, and there is no cache match, this will throw 3565 * a `WorkboxError` exception. 3566 * 3567 * @extends module:workbox-strategies.Strategy 3568 * @memberof module:workbox-strategies 3569 */ 3570class NetworkFirst extends (/* unused pure expression or super */ null && (Strategy)) { 3571 /** 3572 * @param {Object} [options] 3573 * @param {string} [options.cacheName] Cache name to store and retrieve 3574 * requests. Defaults to cache names provided by 3575 * [workbox-core]{@link module:workbox-core.cacheNames}. 3576 * @param {Array<Object>} [options.plugins] [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins} 3577 * to use in conjunction with this caching strategy. 3578 * @param {Object} [options.fetchOptions] Values passed along to the 3579 * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) 3580 * of [non-navigation](https://github.com/GoogleChrome/workbox/issues/1796)
3581 * `fetch()` requests made by this strategy. 3582 * @param {Object} [options.matchOptions] [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions) 3583 * @param {number} [options.networkTimeoutSeconds] If set, any network requests 3584 * that fail to respond within the timeout will fallback to the cache. 3585 * 3586 * This option can be used to combat 3587 * "[lie-fi]{@link https://developers.google.com/web/fundamentals/performance/poor-connectivity/#lie-fi}" 3588 * scenarios. 3589 */ 3590 constructor(options = {}) { 3591 super(options); 3592 // If this instance contains no plugins with a 'cacheWillUpdate' callback, 3593 // prepend the `cacheOkAndOpaquePlugin` plugin to the plugins list. 3594 if (!this.plugins.some((p) => 'cacheWillUpdate' in p)) { 3595 this.plugins.unshift(cacheOkAndOpaquePlugin); 3596 } 3597 this._networkTimeoutSeconds = options.networkTimeoutSeconds || 0; 3598 if (false) {} 3599 } 3600 /** 3601 * @private 3602 * @param {Request|string} request A request to run this strategy for. 3603 * @param {module:workbox-strategies.StrategyHandler} handler The event that 3604 * triggered the request. 3605 * @return {Promise<Response>} 3606 */ 3607 async _handle(request, handler) { 3608 const logs = []; 3609 if (false) {} 3610 const promises = []; 3611 let timeoutId; 3612 if (this._networkTimeoutSeconds) { 3613 const { id, promise } = this._getTimeoutPromise({ request, logs, handler }); 3614 timeoutId = id; 3615 promises.push(promise); 3616 } 3617 const networkPromise = this._getNetworkPromise({ timeoutId, request, logs, handler }); 3618 promises.push(networkPromise); 3619 const response = await handler.waitUntil((async () => { 3620 // Promise.race() will resolve as soon as the first promise resolves. 3621 return await handler.waitUntil(Promise.race(promises)) || 3622 // If Promise.race() resolved with null, it might be due to a network 3623 // timeout + a cache miss. If that were to happen, we'd rather wait until 3624 // the networkPromise resolves instead of returning null. 3625 // Note that it's fine to await an already-resolved promise, so we don't 3626 // have to check to see if it's still "in flight". 3627 await networkPromise; 3628 })()); 3629 if (false) {} 3630 if (!response) { 3631 throw new WorkboxError('no-response', { url: request.url }); 3632 } 3633 return response; 3634 } 3635 /** 3636 * @param {Object} options 3637 * @param {Request} options.request 3638 * @param {Array} options.logs A reference to the logs array 3639 * @param {Event} options.event 3640 * @return {Promise<Response>} 3641 * 3642 * @private 3643 */ 3644 _getTimeoutPromise({ request, logs, handler }) { 3645 let timeoutId; 3646 const timeoutPromise = new Promise((resolve) => { 3647 const onNetworkTimeout = async () => { 3648 if (false) {} 3649 resolve(await handler.cacheMatch(request)); 3650 }; 3651 timeoutId = setTimeout(onNetworkTimeout, this._networkTimeoutSeconds * 1000); 3652 }); 3653 return { 3654 promise: timeoutPromise, 3655 id: timeoutId, 3656 }; 3657 } 3658 /** 3659 * @param {Object} options 3660 * @param {number|undefined} options.timeoutId 3661 * @param {Request} options.request 3662 * @param {Array} options.logs A reference to the logs Array. 3663 * @param {Event} options.event 3664 * @return {Promise<Response>} 3665 * 3666 * @private 3667 */ 3668 async _getNetworkPromise({ timeoutId, request, logs, handler }) { 3669 let error; 3670 let response; 3671 try { 3672 response = await handler.fetchAndCachePut(request); 3673 } 3674 catch (fetchError) { 3675 error = fetchError; 3676 } 3677 if (timeoutId) { 3678 clearTimeout(timeoutId); 3679 } 3680 if (false) {} 3681 if (error || !response) { 3682 response = await handler.cacheMatch(request); 3683 if (false) {} 3684 } 3685 return response; 3686 } 3687} 3688 3689 3690;// CONCATENATED MODULE: ./node_modules/workbox-strategies/NetworkOnly.js 3691/* 3692 Copyright 2018 Google LLC 3693 3694 Use of this source code is governed by an MIT-style 3695 license that can be found in the LICENSE file or at 3696 https://opensource.org/licenses/MIT.
3697*/ 3698 3699 3700 3701 3702 3703 3704 3705/** 3706 * An implementation of a 3707 * [network-only]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#network-only} 3708 * request strategy. 3709 * 3710 * This class is useful if you want to take advantage of any 3711 * [Workbox plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins}. 3712 * 3713 * If the network request fails, this will throw a `WorkboxError` exception. 3714 * 3715 * @extends module:workbox-strategies.Strategy 3716 * @memberof module:workbox-strategies 3717 */ 3718class NetworkOnly extends (/* unused pure expression or super */ null && (Strategy)) { 3719 /** 3720 * @param {Object} [options] 3721 * @param {Array<Object>} [options.plugins] [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins} 3722 * to use in conjunction with this caching strategy. 3723 * @param {Object} [options.fetchOptions] Values passed along to the 3724 * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) 3725 * of [non-navigation](https://github.com/GoogleChrome/workbox/issues/1796) 3726 * `fetch()` requests made by this strategy. 3727 * @param {number} [options.networkTimeoutSeconds] If set, any network requests 3728 * that fail to respond within the timeout will result in a network error. 3729 */ 3730 constructor(options = {}) { 3731 super(options); 3732 this._networkTimeoutSeconds = options.networkTimeoutSeconds || 0; 3733 } 3734 /** 3735 * @private 3736 * @param {Request|string} request A request to run this strategy for. 3737 * @param {module:workbox-strategies.StrategyHandler} handler The event that 3738 * triggered the request. 3739 * @return {Promise<Response>} 3740 */ 3741 async _handle(request, handler) { 3742 if (false) {} 3743 let error = undefined; 3744 let response; 3745 try { 3746 const promises = [handler.fetch(request)]; 3747 if (this._networkTimeoutSeconds) { 3748 const timeoutPromise = timeout(this._networkTimeoutSeconds * 1000); 3749 promises.push(timeoutPromise); 3750 } 3751 response = await Promise.race(promises); 3752 if (!response) { 3753 throw new Error(`Timed out the network response after ` + 3754 `${this._networkTimeoutSeconds} seconds.`); 3755 } 3756 } 3757 catch (err) { 3758 error = err; 3759 } 3760 if (false) {} 3761 if (!response) { 3762 throw new WorkboxError('no-response', { url: request.url, error }); 3763 } 3764 return response; 3765 } 3766} 3767 3768 3769;// CONCATENATED MODULE: ./node_modules/workbox-strategies/StaleWhileRevalidate.js 3770/* 3771 Copyright 2018 Google LLC 3772 3773 Use of this source code is governed by an MIT-style 3774 license that can be found in the LICENSE file or at 3775 https://opensource.org/licenses/MIT. 3776*/ 3777 3778 3779 3780 3781 3782 3783 3784/** 3785 * An implementation of a 3786 * [stale-while-revalidate]{@link https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#stale-while-revalidate} 3787 * request strategy. 3788 * 3789 * Resources are requested from both the cache and the network in parallel. 3790 * The strategy will respond with the cached version if available, otherwise 3791 * wait for the network response. The cache is updated with the network response 3792 * with each successful request. 3793 * 3794 * By default, this strategy will cache responses with a 200 status code as 3795 * well as [opaque responses]{@link https://developers.google.com/web/tools/workbox/guides/handle-third-party-requests}. 3796 * Opaque responses are cross-origin requests where the response doesn't 3797 * support [CORS]{@link https://enable-cors.org/}. 3798 * 3799 * If the network request fails, and there is no cache match, this will throw 3800 * a `WorkboxError` exception. 3801 * 3802 * @extends module:workbox-strategies.Strategy 3803 * @memberof module:workbox-strategies 3804 */ 3805class StaleWhileRevalidate extends (/* unused pure expression or super */ null && (Strategy)) { 3806 /** 3807 * @param {Object} [options] 3808 * @param {string} [options.cacheName] Cache name to store and retrieve 3809 * requests. Defaults to cache names provided by 3810 * [workbox-core]{@link module:workbox-core.cacheNames}. 3811 * @param {Array<Object>} [options.plugins] [Plugins]{@link https://developers.google.com/web/tools/workbox/guides/using-plugins} 3812 * to use in conjunction with this caching strategy. 3813 * @param {Object} [options.fetchOptions] Values passed along to the 3814 * [`init`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters) 3815 * of [non-navigation](https://github.com/GoogleChrome/workbox/issues/1796)
3816 * `fetch()` requests made by this strategy. 3817 * @param {Object} [options.matchOptions] [`CacheQueryOptions`](https://w3c.github.io/ServiceWorker/#dictdef-cachequeryoptions) 3818 */ 3819 constructor(options) { 3820 super(options); 3821 // If this instance contains no plugins with a 'cacheWillUpdate' callback, 3822 // prepend the `cacheOkAndOpaquePlugin` plugin to the plugins list. 3823 if (!this.plugins.some((p) => 'cacheWillUpdate' in p)) { 3824 this.plugins.unshift(cacheOkAndOpaquePlugin); 3825 } 3826 } 3827 /** 3828 * @private 3829 * @param {Request|string} request A request to run this strategy for. 3830 * @param {module:workbox-strategies.StrategyHandler} handler The event that 3831 * triggered the request. 3832 * @return {Promise<Response>} 3833 */ 3834 async _handle(request, handler) { 3835 const logs = []; 3836 if (false) {} 3837 const fetchAndCachePromise = handler 3838 .fetchAndCachePut(request) 3839 .catch(() => { 3840 // Swallow this error because a 'no-response' error will be thrown in 3841 // main handler return flow. This will be in the `waitUntil()` flow. 3842 }); 3843 let response = await handler.cacheMatch(request); 3844 let error; 3845 if (response) { 3846 if (false) {} 3847 } 3848 else { 3849 if (false) {} 3850 try { 3851 // NOTE(philipwalton): Really annoying that we have to type cast here. 3852 // https://github.com/microsoft/TypeScript/issues/20006 3853 response = await fetchAndCachePromise; 3854 } 3855 catch (err) { 3856 error = err; 3857 } 3858 } 3859 if (false) {} 3860 if (!response) { 3861 throw new WorkboxError('no-response', { url: request.url, error }); 3862 } 3863 return response; 3864 } 3865} 3866 3867 3868;// CONCATENATED MODULE: ./node_modules/workbox-strategies/index.js 3869/* 3870 Copyright 2018 Google LLC 3871 3872 Use of this source code is governed by an MIT-style 3873 license that can be found in the LICENSE file or at 3874 https://opensource.org/licenses/MIT. 3875*/ 3876 3877 3878 3879 3880 3881 3882 3883 3884/** 3885 * There are common caching strategies that most service workers will need 3886 * and use. This module provides simple implementations of these strategies. 3887 * 3888 * @module workbox-strategies 3889 */ 3890 3891 3892;// CONCATENATED MODULE: ./node_modules/workbox-strategies/index.mjs 3893 3894;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/dontWaitFor.js 3895/* 3896 Copyright 2019 Google LLC 3897 Use of this source code is governed by an MIT-style 3898 license that can be found in the LICENSE file or at 3899 https://opensource.org/licenses/MIT. 3900*/ 3901 3902/** 3903 * A helper function that prevents a promise from being flagged as unused. 3904 * 3905 * @private 3906 **/ 3907function dontWaitFor(promise) { 3908 // Effective no-op. 3909 promise.then(() => { }); 3910} 3911 3912;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/DBWrapper.js 3913/* 3914 Copyright 2018 Google LLC 3915 3916 Use of this source code is governed by an MIT-style 3917 license that can be found in the LICENSE file or at 3918 https://opensource.org/licenses/MIT. 3919*/ 3920 3921/** 3922 * A class that wraps common IndexedDB functionality in a promise-based API. 3923 * It exposes all the underlying power and functionality of IndexedDB, but 3924 * wraps the most commonly used features in a way that's much simpler to use. 3925 * 3926 * @private 3927 */ 3928class DBWrapper { 3929 /** 3930 * @param {string} name 3931 * @param {number} version 3932 * @param {Object=} [callback] 3933 * @param {!Function} [callbacks.onupgradeneeded] 3934 * @param {!Function} [callbacks.onversionchange] Defaults to 3935 * DBWrapper.prototype._onversionchange when not specified. 3936 * @private 3937 */ 3938 constructor(name, version, { onupgradeneeded, onversionchange, } = {}) { 3939 this._db = null; 3940 this._name = name; 3941 this._version = version; 3942 this._onupgradeneeded = onupgradeneeded; 3943 this._onversionchange = onversionchange || (() => this.close()); 3944 } 3945 /** 3946 * Returns the IDBDatabase instance (not normally needed). 3947 * @return {IDBDatabase|undefined} 3948 * 3949 * @private 3950 */ 3951 get db() { 3952 return this._db; 3953 } 3954 /** 3955 * Opens a connected to an IDBDatabase, invokes any onupgradedneeded
3956 * callback, and added an onversionchange callback to the database. 3957 * 3958 * @return {IDBDatabase} 3959 * @private 3960 */ 3961 async open() { 3962 if (this._db) 3963 return; 3964 this._db = await new Promise((resolve, reject) => { 3965 // This flag is flipped to true if the timeout callback runs prior 3966 // to the request failing or succeeding. Note: we use a timeout instead 3967 // of an onblocked handler since there are cases where onblocked will 3968 // never never run. A timeout better handles all possible scenarios: 3969 // https://github.com/w3c/IndexedDB/issues/223 3970 let openRequestTimedOut = false; 3971 setTimeout(() => { 3972 openRequestTimedOut = true; 3973 reject(new Error('The open request was blocked and timed out')); 3974 }, this.OPEN_TIMEOUT); 3975 const openRequest = indexedDB.open(this._name, this._version); 3976 openRequest.onerror = () => reject(openRequest.error); 3977 openRequest.onupgradeneeded = (evt) => { 3978 if (openRequestTimedOut) { 3979 openRequest.transaction.abort(); 3980 openRequest.result.close(); 3981 } 3982 else if (typeof this._onupgradeneeded === 'function') { 3983 this._onupgradeneeded(evt); 3984 } 3985 }; 3986 openRequest.onsuccess = () => { 3987 const db = openRequest.result; 3988 if (openRequestTimedOut) { 3989 db.close(); 3990 } 3991 else { 3992 db.onversionchange = this._onversionchange.bind(this); 3993 resolve(db); 3994 } 3995 }; 3996 }); 3997 return this; 3998 } 3999 /** 4000 * Polyfills the native `getKey()` method. Note, this is overridden at 4001 * runtime if the browser supports the native method. 4002 * 4003 * @param {string} storeName 4004 * @param {*} query 4005 * @return {Array} 4006 * @private 4007 */ 4008 async getKey(storeName, query) { 4009 return (await this.getAllKeys(storeName, query, 1))[0]; 4010 } 4011 /** 4012 * Polyfills the native `getAll()` method. Note, this is overridden at 4013 * runtime if the browser supports the native method. 4014 * 4015 * @param {string} storeName 4016 * @param {*} query 4017 * @param {number} count 4018 * @return {Array} 4019 * @private 4020 */ 4021 async getAll(storeName, query, count) { 4022 return await this.getAllMatching(storeName, { query, count }); 4023 } 4024 /** 4025 * Polyfills the native `getAllKeys()` method. Note, this is overridden at 4026 * runtime if the browser supports the native method. 4027 * 4028 * @param {string} storeName 4029 * @param {*} query 4030 * @param {number} count 4031 * @return {Array} 4032 * @private 4033 */ 4034 async getAllKeys(storeName, query, count) { 4035 const entries = await this.getAllMatching(storeName, { query, count, includeKeys: true }); 4036 return entries.map((entry) => entry.key); 4037 } 4038 /** 4039 * Supports flexible lookup in an object store by specifying an index, 4040 * query, direction, and count. This method returns an array of objects 4041 * with the signature . 4042 * 4043 * @param {string} storeName 4044 * @param {Object} [opts] 4045 * @param {string} [opts.index] The index to use (if specified). 4046 * @param {*} [opts.query] 4047 * @param {IDBCursorDirection} [opts.direction] 4048 * @param {number} [opts.count] The max number of results to return. 4049 * @param {boolean} [opts.includeKeys] When true, the structure of the 4050 * returned objects is changed from an array of values to an array of 4051 * objects in the form {key, primaryKey, value}. 4052 * @return {Array} 4053 * @private 4054 */ 4055 async getAllMatching(storeName, { index, query = null, // IE/Edge errors if query === `undefined`. 4056 direction = 'next', count, includeKeys = false, } = {}) { 4057 return await this.transaction([storeName], 'readonly', (txn, done) => { 4058 const store = txn.objectStore(storeName); 4059 const target = index ? store.index(index) : store; 4060 const results = []; 4061 const request = target.openCursor(query, direction); 4062 request.onsuccess = () => { 4063 const cursor = request.result; 4064 if (cursor) {
4065 results.push(includeKeys ? cursor : cursor.value); 4066 if (count && results.length >= count) { 4067 done(results); 4068 } 4069 else { 4070 cursor.continue(); 4071 } 4072 } 4073 else { 4074 done(results); 4075 } 4076 }; 4077 }); 4078 } 4079 /** 4080 * Accepts a list of stores, a transaction type, and a callback and 4081 * performs a transaction. A promise is returned that resolves to whatever 4082 * value the callback chooses. The callback holds all the transaction logic 4083 * and is invoked with two arguments: 4084 * 1. The IDBTransaction object 4085 * 2. A `done` function, that's used to resolve the promise when 4086 * when the transaction is done, if passed a value, the promise is 4087 * resolved to that value. 4088 * 4089 * @param {Array<string>} storeNames An array of object store names 4090 * involved in the transaction. 4091 * @param {string} type Can be `readonly` or `readwrite`. 4092 * @param {!Function} callback 4093 * @return {*} The result of the transaction ran by the callback. 4094 * @private 4095 */ 4096 async transaction(storeNames, type, callback) { 4097 await this.open(); 4098 return await new Promise((resolve, reject) => { 4099 const txn = this._db.transaction(storeNames, type); 4100 txn.onabort = () => reject(txn.error); 4101 txn.oncomplete = () => resolve(); 4102 callback(txn, (value) => resolve(value)); 4103 }); 4104 } 4105 /** 4106 * Delegates async to a native IDBObjectStore method. 4107 * 4108 * @param {string} method The method name. 4109 * @param {string} storeName The object store name. 4110 * @param {string} type Can be `readonly` or `readwrite`. 4111 * @param {...*} args The list of args to pass to the native method. 4112 * @return {*} The result of the transaction. 4113 * @private 4114 */ 4115 async _call(method, storeName, type, ...args) { 4116 const callback = (txn, done) => { 4117 const objStore = txn.objectStore(storeName); 4118 // TODO(philipwalton): Fix this underlying TS2684 error. 4119 // @ts-ignore 4120 const request = objStore[method].apply(objStore, args); 4121 request.onsuccess = () => done(request.result); 4122 }; 4123 return await this.transaction([storeName], type, callback); 4124 } 4125 /** 4126 * Closes the connection opened by `DBWrapper.open()`. Generally this method 4127 * doesn't need to be called since: 4128 * 1. It's usually better to keep a connection open since opening 4129 * a new connection is somewhat slow. 4130 * 2. Connections are automatically closed when the reference is 4131 * garbage collected. 4132 * The primary use case for needing to close a connection is when another 4133 * reference (typically in another tab) needs to upgrade it and would be 4134 * blocked by the current, open connection. 4135 * 4136 * @private 4137 */ 4138 close() { 4139 if (this._db) { 4140 this._db.close(); 4141 this._db = null; 4142 } 4143 } 4144} 4145// Exposed on the prototype to let users modify the default timeout on a 4146// per-instance or global basis. 4147DBWrapper.prototype.OPEN_TIMEOUT = 2000; 4148// Wrap native IDBObjectStore methods according to their mode. 4149const methodsToWrap = { 4150 readonly: ['get', 'count', 'getKey', 'getAll', 'getAllKeys'], 4151 readwrite: ['add', 'put', 'clear', 'delete'], 4152}; 4153for (const [mode, methods] of Object.entries(methodsToWrap)) { 4154 for (const method of methods) { 4155 if (method in IDBObjectStore.prototype) { 4156 // Don't use arrow functions here since we're outside of the class. 4157 DBWrapper.prototype[method] = 4158 async function (storeName, ...args) { 4159 return await this._call(method, storeName, mode, ...args); 4160 }; 4161 } 4162 } 4163} 4164 4165;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/deleteDatabase.js 4166/* 4167 Copyright 2018 Google LLC 4168 4169 Use of this source code is governed by an MIT-style 4170 license that can be found in the LICENSE file or at 4171 https://opensource.org/licenses/MIT.
4172*/ 4173 4174/** 4175 * Deletes the database. 4176 * Note: this is exported separately from the DBWrapper module because most 4177 * usages of IndexedDB in workbox dont need deleting, and this way it can be 4178 * reused in tests to delete databases without creating DBWrapper instances. 4179 * 4180 * @param {string} name The database name. 4181 * @private 4182 */ 4183const deleteDatabase = async (name) => { 4184 await new Promise((resolve, reject) => { 4185 const request = indexedDB.deleteDatabase(name); 4186 request.onerror = () => { 4187 reject(request.error); 4188 }; 4189 request.onblocked = () => { 4190 reject(new Error('Delete blocked')); 4191 }; 4192 request.onsuccess = () => { 4193 resolve(); 4194 }; 4195 }); 4196}; 4197 4198// EXTERNAL MODULE: ./node_modules/workbox-expiration/_version.js 4199var workbox_expiration_version = __webpack_require__(550); 4200;// CONCATENATED MODULE: ./node_modules/workbox-expiration/models/CacheTimestampsModel.js 4201/* 4202 Copyright 2018 Google LLC 4203 4204 Use of this source code is governed by an MIT-style 4205 license that can be found in the LICENSE file or at 4206 https://opensource.org/licenses/MIT. 4207*/ 4208 4209 4210 4211const DB_NAME = 'workbox-expiration'; 4212const OBJECT_STORE_NAME = 'cache-entries'; 4213const normalizeURL = (unNormalizedUrl) => { 4214 const url = new URL(unNormalizedUrl, location.href); 4215 url.hash = ''; 4216 return url.href; 4217}; 4218/** 4219 * Returns the timestamp model. 4220 * 4221 * @private 4222 */ 4223class CacheTimestampsModel { 4224 /** 4225 * 4226 * @param {string} cacheName 4227 * 4228 * @private 4229 */ 4230 constructor(cacheName) { 4231 this._cacheName = cacheName; 4232 this._db = new DBWrapper(DB_NAME, 1, { 4233 onupgradeneeded: (event) => this._handleUpgrade(event), 4234 }); 4235 } 4236 /** 4237 * Should perform an upgrade of indexedDB. 4238 * 4239 * @param {Event} event 4240 * 4241 * @private 4242 */ 4243 _handleUpgrade(event) { 4244 const db = event.target.result; 4245 // TODO(philipwalton): EdgeHTML doesn't support arrays as a keyPath, so we 4246 // have to use the `id` keyPath here and create our own values (a 4247 // concatenation of `url + cacheName`) instead of simply using 4248 // `keyPath: ['url', 'cacheName']`, which is supported in other browsers. 4249 const objStore = db.createObjectStore(OBJECT_STORE_NAME, { keyPath: 'id' });
4250 // TODO(philipwalton): once we don't have to support EdgeHTML, we can 4251 // create a single index with the keyPath `['cacheName', 'timestamp']` 4252 // instead of doing both these indexes. 4253 objStore.createIndex('cacheName', 'cacheName', { unique: false }); 4254 objStore.createIndex('timestamp', 'timestamp', { unique: false }); 4255 // Previous versions of `workbox-expiration` used `this._cacheName` 4256 // as the IDBDatabase name. 4257 deleteDatabase(this._cacheName); 4258 } 4259 /** 4260 * @param {string} url 4261 * @param {number} timestamp 4262 * 4263 * @private 4264 */ 4265 async setTimestamp(url, timestamp) { 4266 url = normalizeURL(url); 4267 const entry = { 4268 url, 4269 timestamp, 4270 cacheName: this._cacheName, 4271 // Creating an ID from the URL and cache name won't be necessary once 4272 // Edge switches to Chromium and all browsers we support work with 4273 // array keyPaths. 4274 id: this._getId(url), 4275 }; 4276 await this._db.put(OBJECT_STORE_NAME, entry); 4277 } 4278 /** 4279 * Returns the timestamp stored for a given URL. 4280 * 4281 * @param {string} url 4282 * @return {number} 4283 * 4284 * @private 4285 */ 4286 async getTimestamp(url) { 4287 const entry = await this._db.get(OBJECT_STORE_NAME, this._getId(url)); 4288 return entry.timestamp; 4289 } 4290 /** 4291 * Iterates through all the entries in the object store (from newest to 4292 * oldest) and removes entries once either `maxCount` is reached or the 4293 * entry's timestamp is less than `minTimestamp`. 4294 * 4295 * @param {number} minTimestamp 4296 * @param {number} maxCount 4297 * @return {Array<string>} 4298 * 4299 * @private 4300 */ 4301 async expireEntries(minTimestamp, maxCount) { 4302 const entriesToDelete = await this._db.transaction(OBJECT_STORE_NAME, 'readwrite', (txn, done) => { 4303 const store = txn.objectStore(OBJECT_STORE_NAME); 4304 const request = store.index('timestamp').openCursor(null, 'prev'); 4305 const entriesToDelete = []; 4306 let entriesNotDeletedCount = 0; 4307 request.onsuccess = () => { 4308 const cursor = request.result; 4309 if (cursor) { 4310 const result = cursor.value; 4311 // TODO(philipwalton): once we can use a multi-key index, we 4312 // won't have to check `cacheName` here. 4313 if (result.cacheName === this._cacheName) { 4314 // Delete an entry if it's older than the max age or 4315 // if we already have the max number allowed. 4316 if ((minTimestamp && result.timestamp < minTimestamp) || 4317 (maxCount && entriesNotDeletedCount >= maxCount)) { 4318 // TODO(philipwalton): we should be able to delete the 4319 // entry right here, but doing so causes an iteration 4320 // bug in Safari stable (fixed in TP). Instead we can 4321 // store the keys of the entries to delete, and then 4322 // delete the separate transactions. 4323 // https://github.com/GoogleChrome/workbox/issues/1978 4324 // cursor.delete(); 4325 // We only need to return the URL, not the whole entry. 4326 entriesToDelete.push(cursor.value); 4327 } 4328 else { 4329 entriesNotDeletedCount++; 4330 } 4331 } 4332 cursor.continue(); 4333 } 4334 else { 4335 done(entriesToDelete); 4336 } 4337 }; 4338 }); 4339 // TODO(philipwalton): once the Safari bug in the following issue is fixed, 4340 // we should be able to remove this loop and do the entry deletion in the 4341 // cursor loop above: 4342 // https://github.com/GoogleChrome/workbox/issues/1978 4343 const urlsDeleted = [];
4344 for (const entry of entriesToDelete) { 4345 await this._db.delete(OBJECT_STORE_NAME, entry.id); 4346 urlsDeleted.push(entry.url); 4347 } 4348 return urlsDeleted; 4349 } 4350 /** 4351 * Takes a URL and returns an ID that will be unique in the object store. 4352 * 4353 * @param {string} url 4354 * @return {string} 4355 * 4356 * @private 4357 */ 4358 _getId(url) { 4359 // Creating an ID from the URL and cache name won't be necessary once 4360 // Edge switches to Chromium and all browsers we support work with 4361 // array keyPaths. 4362 return this._cacheName + '|' + normalizeURL(url); 4363 } 4364} 4365 4366 4367;// CONCATENATED MODULE: ./node_modules/workbox-expiration/CacheExpiration.js 4368/* 4369 Copyright 2018 Google LLC 4370 4371 Use of this source code is governed by an MIT-style 4372 license that can be found in the LICENSE file or at 4373 https://opensource.org/licenses/MIT. 4374*/ 4375 4376 4377 4378 4379 4380 4381/** 4382 * The `CacheExpiration` class allows you define an expiration and / or 4383 * limit on the number of responses stored in a 4384 * [`Cache`](https://developer.mozilla.org/en-US/docs/Web/API/Cache). 4385 * 4386 * @memberof module:workbox-expiration 4387 */ 4388class CacheExpiration { 4389 /** 4390 * To construct a new CacheExpiration instance you must provide at least 4391 * one of the `config` properties. 4392 * 4393 * @param {string} cacheName Name of the cache to apply restrictions to. 4394 * @param {Object} config 4395 * @param {number} [config.maxEntries] The maximum number of entries to cache. 4396 * Entries used the least will be removed as the maximum is reached. 4397 * @param {number} [config.maxAgeSeconds] The maximum age of an entry before 4398 * it's treated as stale and removed. 4399 * @param {Object} [config.matchOptions] The [`CacheQueryOptions`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/delete#Parameters) 4400 * that will be used when calling `delete()` on the cache. 4401 */ 4402 constructor(cacheName, config = {}) { 4403 this._isRunning = false; 4404 this._rerunRequested = false; 4405 if (false) {} 4406 this._maxEntries = config.maxEntries; 4407 this._maxAgeSeconds = config.maxAgeSeconds; 4408 this._matchOptions = config.matchOptions; 4409 this._cacheName = cacheName; 4410 this._timestampModel = new CacheTimestampsModel(cacheName); 4411 } 4412 /** 4413 * Expires entries for the given cache and given criteria. 4414 */ 4415 async expireEntries() { 4416 if (this._isRunning) { 4417 this._rerunRequested = true; 4418 return; 4419 } 4420 this._isRunning = true; 4421 const minTimestamp = this._maxAgeSeconds ? 4422 Date.now() - (this._maxAgeSeconds * 1000) : 0; 4423 const urlsExpired = await this._timestampModel.expireEntries(minTimestamp, this._maxEntries); 4424 // Delete URLs from the cache 4425 const cache = await self.caches.open(this._cacheName); 4426 for (const url of urlsExpired) { 4427 await cache.delete(url, this._matchOptions); 4428 } 4429 if (false) {} 4430 this._isRunning = false; 4431 if (this._rerunRequested) { 4432 this._rerunRequested = false; 4433 dontWaitFor(this.expireEntries()); 4434 } 4435 } 4436 /** 4437 * Update the timestamp for the given URL. This ensures the when 4438 * removing entries based on maximum entries, most recently used 4439 * is accurate or when expiring, the timestamp is up-to-date. 4440 * 4441 * @param {string} url 4442 */ 4443 async updateTimestamp(url) { 4444 if (false) {} 4445 await this._timestampModel.setTimestamp(url, Date.now()); 4446 } 4447 /** 4448 * Can be used to check if a URL has expired or not before it's used. 4449 * 4450 * This requires a look up from IndexedDB, so can be slow. 4451 * 4452 * Note: This method will not remove the cached entry, call 4453 * `expireEntries()` to remove indexedDB and Cache entries. 4454 * 4455 * @param {string} url 4456 * @return {boolean} 4457 */ 4458 async isURLExpired(url) { 4459 if (!this._maxAgeSeconds) { 4460 if (false) {} 4461 return false; 4462 } 4463 else { 4464 const timestamp = await this._timestampModel.getTimestamp(url); 4465 const expireOlderThan = Date.now() - (this._maxAgeSeconds * 1000); 4466 return (timestamp < expireOlderThan); 4467 } 4468 } 4469 /** 4470 * Removes the IndexedDB object store used to keep track of cache expiration 4471 * metadata. 4472 */ 4473 async delete() { 4474 // Make sure we don't attempt another rerun if we're called in the middle of 4475 // a cache expiration. 4476 this._rerunRequested = false;
4477 await this._timestampModel.expireEntries(Infinity); // Expires all. 4478 } 4479} 4480 4481 4482;// CONCATENATED MODULE: ./node_modules/workbox-core/registerQuotaErrorCallback.js 4483/* 4484 Copyright 2019 Google LLC 4485 4486 Use of this source code is governed by an MIT-style 4487 license that can be found in the LICENSE file or at 4488 https://opensource.org/licenses/MIT. 4489*/ 4490 4491 4492 4493 4494/** 4495 * Adds a function to the set of quotaErrorCallbacks that will be executed if 4496 * there's a quota error. 4497 * 4498 * @param {Function} callback 4499 * @memberof module:workbox-core 4500 */ 4501function registerQuotaErrorCallback(callback) { 4502 if (false) {} 4503 quotaErrorCallbacks.add(callback); 4504 if (false) {} 4505} 4506 4507 4508;// CONCATENATED MODULE: ./node_modules/workbox-expiration/ExpirationPlugin.js 4509/* 4510 Copyright 2018 Google LLC 4511 4512 Use of this source code is governed by an MIT-style 4513 license that can be found in the LICENSE file or at 4514 https://opensource.org/licenses/MIT. 4515*/ 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525/** 4526 * This plugin can be used in a `workbox-strategy` to regularly enforce a 4527 * limit on the age and / or the number of cached requests. 4528 * 4529 * It can only be used with `workbox-strategy` instances that have a 4530 * [custom `cacheName` property set](/web/tools/workbox/guides/configure-workbox#custom_cache_names_in_strategies). 4531 * In other words, it can't be used to expire entries in strategy that uses the 4532 * default runtime cache name. 4533 * 4534 * Whenever a cached request is used or updated, this plugin will look 4535 * at the associated cache and remove any old or extra requests. 4536 * 4537 * When using `maxAgeSeconds`, requests may be used *once* after expiring 4538 * because the expiration clean up will not have occurred until *after* the 4539 * cached request has been used. If the request has a "Date" header, then 4540 * a light weight expiration check is performed and the request will not be 4541 * used immediately. 4542 * 4543 * When using `maxEntries`, the entry least-recently requested will be removed 4544 * from the cache first. 4545 * 4546 * @memberof module:workbox-expiration 4547 */ 4548class ExpirationPlugin { 4549 /** 4550 * @param {Object} config 4551 * @param {number} [config.maxEntries] The maximum number of entries to cache. 4552 * Entries used the least will be removed as the maximum is reached. 4553 * @param {number} [config.maxAgeSeconds] The maximum age of an entry before 4554 * it's treated as stale and removed. 4555 * @param {Object} [config.matchOptions] The [`CacheQueryOptions`](https://developer.mozilla.org/en-US/docs/Web/API/Cache/delete#Parameters) 4556 * that will be used when calling `delete()` on the cache. 4557 * @param {boolean} [config.purgeOnQuotaError] Whether to opt this cache in to 4558 * automatic deletion if the available storage quota has been exceeded. 4559 */ 4560 constructor(config = {}) { 4561 /** 4562 * A "lifecycle" callback that will be triggered automatically by the 4563 * `workbox-strategies` handlers when a `Response` is about to be returned 4564 * from a [Cache](https://developer.mozilla.org/en-US/docs/Web/API/Cache) to 4565 * the handler. It allows the `Response` to be inspected for freshness and 4566 * prevents it from being used if the `Response`'s `Date` header value is 4567 * older than the configured `maxAgeSeconds`. 4568 * 4569 * @param {Object} options 4570 * @param {string} options.cacheName Name of the cache the response is in. 4571 * @param {Response} options.cachedResponse The `Response` object that's been 4572 * read from a cache and whose freshness should be checked. 4573 * @return {Response} Either the `cachedResponse`, if it's 4574 * fresh, or `null` if the `Response` is older than `maxAgeSeconds`. 4575 * 4576 * @private 4577 */ 4578 this.cachedResponseWillBeUsed = async ({ event, request, cacheName, cachedResponse }) => { 4579 if (!cachedResponse) { 4580 return null; 4581 } 4582 const isFresh = this._isResponseDateFresh(cachedResponse); 4583 // Expire entries to ensure that even if the expiration date has 4584 // expired, it'll only be used once. 4585 const cacheExpiration = this._getCacheExpiration(cacheName); 4586 dontWaitFor(cacheExpiration.expireEntries()); 4587 // Update the metadata for the request URL to the current timestamp, 4588 // but don't `await` it as we don't want to block the response. 4589 const updateTimestampDone = cacheExpiration.updateTimestamp(request.url); 4590 if (event) { 4591 try { 4592 event.waitUntil(updateTimestampDone); 4593 } 4594 catch (error) { 4595 if (false) {} 4596 } 4597 } 4598 return isFresh ? cachedResponse : null; 4599 }; 4600 /** 4601 * A "lifecycle" callback that will be triggered automatically by the 4602 * `workbox-strategies` handlers when an entry is added to a cache. 4603 * 4604 * @param {Object} options 4605 * @param {string} options.cacheName Name of the cache that was updated. 4606 * @param {string} options.request The Request for the cached entry. 4607 * 4608 * @private 4609 */ 4610 this.cacheDidUpdate = async ({ cacheName, request }) => { 4611 if (false) {} 4612 const cacheExpiration = this._getCacheExpiration(cacheName); 4613 await cacheExpiration.updateTimestamp(request.url); 4614 await cacheExpiration.expireEntries(); 4615 }; 4616 if (false) {} 4617 this._config = config; 4618 this._maxAgeSeconds = config.maxAgeSeconds; 4619 this._cacheExpirations = new Map(); 4620 if (config.purgeOnQuotaError) { 4621 registerQuotaErrorCallback(() =>
4621 this.deleteCacheAndMetadata()); 4622 } 4623 } 4624 /** 4625 * A simple helper method to return a CacheExpiration instance for a given 4626 * cache name. 4627 * 4628 * @param {string} cacheName 4629 * @return {CacheExpiration} 4630 * 4631 * @private 4632 */ 4633 _getCacheExpiration(cacheName) { 4634 if (cacheName === cacheNames_cacheNames.getRuntimeName()) { 4635 throw new WorkboxError_WorkboxError('expire-custom-caches-only'); 4636 } 4637 let cacheExpiration = this._cacheExpirations.get(cacheName); 4638 if (!cacheExpiration) { 4639 cacheExpiration = new CacheExpiration(cacheName, this._config); 4640 this._cacheExpirations.set(cacheName, cacheExpiration); 4641 } 4642 return cacheExpiration; 4643 } 4644 /** 4645 * @param {Response} cachedResponse 4646 * @return {boolean} 4647 * 4648 * @private 4649 */ 4650 _isResponseDateFresh(cachedResponse) { 4651 if (!this._maxAgeSeconds) { 4652 // We aren't expiring by age, so return true, it's fresh 4653 return true; 4654 } 4655 // Check if the 'date' header will suffice a quick expiration check. 4656 // See https://github.com/GoogleChromeLabs/sw-toolbox/issues/164 for 4657 // discussion. 4658 const dateHeaderTimestamp = this._getDateHeaderTimestamp(cachedResponse); 4659 if (dateHeaderTimestamp === null) { 4660 // Unable to parse date, so assume it's fresh. 4661 return true; 4662 } 4663 // If we have a valid headerTime, then our response is fresh iff the 4664 // headerTime plus maxAgeSeconds is greater than the current time. 4665 const now = Date.now(); 4666 return dateHeaderTimestamp >= now - (this._maxAgeSeconds * 1000); 4667 } 4668 /** 4669 * This method will extract the data header and parse it into a useful 4670 * value. 4671 * 4672 * @param {Response} cachedResponse 4673 * @return {number|null} 4674 * 4675 * @private 4676 */ 4677 _getDateHeaderTimestamp(cachedResponse) { 4678 if (!cachedResponse.headers.has('date')) { 4679 return null; 4680 } 4681 const dateHeader = cachedResponse.headers.get('date'); 4682 const parsedDate = new Date(dateHeader); 4683 const headerTime = parsedDate.getTime(); 4684 // If the Date header was invalid for some reason, parsedDate.getTime() 4685 // will return NaN. 4686 if (isNaN(headerTime)) { 4687 return null; 4688 } 4689 return headerTime; 4690 } 4691 /** 4692 * This is a helper method that performs two operations: 4693 * 4694 * - Deletes *all* the underlying Cache instances associated with this plugin 4695 * instance, by calling caches.delete() on your behalf. 4696 * - Deletes the metadata from IndexedDB used to keep track of expiration 4697 * details for each Cache instance. 4698 * 4699 * When using cache expiration, calling this method is preferable to calling 4700 * `caches.delete()` directly, since this will ensure that the IndexedDB 4701 * metadata is also cleanly removed and open IndexedDB instances are deleted. 4702 * 4703 * Note that if you're *not* using cache expiration for a given cache, calling 4704 * `caches.delete()` and passing in the cache's name should be sufficient. 4705 * There is no Workbox-specific method needed for cleanup in that case. 4706 */ 4707 async deleteCacheAndMetadata() { 4708 // Do this one at a time instead of all at once via `Promise.all()` to 4709 // reduce the chance of inconsistency if a promise rejects. 4710 for (const [cacheName, cacheExpiration] of this._cacheExpirations) { 4711 await self.caches.delete(cacheName); 4712 await cacheExpiration.delete(); 4713 } 4714 // Reset this._cacheExpirations to its initial state. 4715 this._cacheExpirations = new Map(); 4716 } 4717} 4718 4719 4720;// CONCATENATED MODULE: ./node_modules/workbox-expiration/index.js 4721/* 4722 Copyright 2018 Google LLC 4723 4724 Use of this source code is governed by an MIT-style 4725 license that can be found in the LICENSE file or at 4726 https://opensource.org/licenses/MIT. 4727*/ 4728 4729 4730 4731/** 4732 * @module workbox-expiration 4733 */ 4734 4735 4736;// CONCATENATED MODULE: ./node_modules/workbox-expiration/index.mjs 4737 4738;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/canConstructReadableStream.js 4739/* 4740 Copyright 2019 Google LLC 4741 4742 Use of this source code is governed by an MIT-style 4743 license that can be found in the LICENSE file or at 4744 https://opensource.org/licenses/MIT.
vendor: 4,502 bytes, lines 4745-4901
4745*/ 4746 4747let canConstructReadableStream_supportStatus; 4748/** 4749 * A utility function that determines whether the current browser supports 4750 * constructing a [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream) 4751 * object. 4752 * 4753 * @return {boolean} `true`, if the current browser can successfully 4754 * construct a `ReadableStream`, `false` otherwise. 4755 * 4756 * @private 4757 */ 4758function canConstructReadableStream() { 4759 if (canConstructReadableStream_supportStatus === undefined) { 4760 // See https://github.com/GoogleChrome/workbox/issues/1473 4761 try { 4762 new ReadableStream({ start() { } }); 4763 canConstructReadableStream_supportStatus = true; 4764 } 4765 catch (error) { 4766 canConstructReadableStream_supportStatus = false; 4767 } 4768 } 4769 return canConstructReadableStream_supportStatus; 4770} 4771 4772 4773;// CONCATENATED MODULE: ./node_modules/workbox-core/_private/resultingClientExists.js 4774/* 4775 Copyright 2019 Google LLC 4776 Use of this source code is governed by an MIT-style 4777 license that can be found in the LICENSE file or at 4778 https://opensource.org/licenses/MIT. 4779*/ 4780 4781 4782const MAX_RETRY_TIME = 2000; 4783/** 4784 * Returns a promise that resolves to a window client matching the passed 4785 * `resultingClientId`. For browsers that don't support `resultingClientId` 4786 * or if waiting for the resulting client to apper takes too long, resolve to 4787 * `undefined`. 4788 * 4789 * @param {string} [resultingClientId] 4790 * @return {Promise<Client|undefined>} 4791 * @private 4792 */ 4793async function resultingClientExists(resultingClientId) { 4794 if (!resultingClientId) { 4795 return; 4796 } 4797 let existingWindows = await self.clients.matchAll({ type: 'window' }); 4798 const existingWindowIds = new Set(existingWindows.map((w) => w.id)); 4799 let resultingWindow; 4800 const startTime = performance.now(); 4801 // Only wait up to `MAX_RETRY_TIME` to find a matching client. 4802 while (performance.now() - startTime < MAX_RETRY_TIME) { 4803 existingWindows = await self.clients.matchAll({ type: 'window' }); 4804 resultingWindow = existingWindows.find((w) => { 4805 if (resultingClientId) { 4806 // If we have a `resultingClientId`, we can match on that. 4807 return w.id === resultingClientId; 4808 } 4809 else { 4810 // Otherwise match on finding a window not in `existingWindowIds`. 4811 return !existingWindowIds.has(w.id); 4812 } 4813 }); 4814 if (resultingWindow) { 4815 break; 4816 } 4817 // Sleep for 100ms and retry. 4818 await timeout(100); 4819 } 4820 return resultingWindow; 4821} 4822 4823;// CONCATENATED MODULE: ./node_modules/workbox-core/_private.js 4824/* 4825 Copyright 2018 Google LLC 4826 4827 Use of this source code is governed by an MIT-style 4828 license that can be found in the LICENSE file or at 4829 https://opensource.org/licenses/MIT. 4830*/ 4831// We either expose defaults or we expose every named export. 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851;// CONCATENATED MODULE: ./node_modules/workbox-core/cacheNames.js 4852/* 4853 Copyright 2019 Google LLC 4854 4855 Use of this source code is governed by an MIT-style 4856 license that can be found in the LICENSE file or at 4857 https://opensource.org/licenses/MIT. 4858*/ 4859 4860 4861/** 4862 * Get the current cache names and prefix/suffix used by Workbox. 4863 * 4864 * `cacheNames.precache` is used for precached assets, 4865 * `cacheNames.googleAnalytics` is used by `workbox-google-analytics` to 4866 * store `analytics.js`, and `cacheNames.runtime` is used for everything else. 4867 * 4868 * `cacheNames.prefix` can be used to retrieve just the current prefix value. 4869 * `cacheNames.suffix` can be used to retrieve just the current suffix value. 4870 * 4871 * @return {Object} An object with `precache`, `runtime`, `prefix`, and 4872 * `googleAnalytics` properties. 4873 * 4874 * @memberof module:workbox-core 4875 */ 4876const workbox_core_cacheNames_cacheNames = { 4877 get googleAnalytics() { 4878 return cacheNames_cacheNames.getGoogleAnalyticsName(); 4879 }, 4880 get precache() { 4881 return cacheNames_cacheNames.getPrecacheName(); 4882 }, 4883 get prefix() { 4884 return cacheNames_cacheNames.getPrefix(); 4885 }, 4886 get runtime() { 4887 return cacheNames_cacheNames.getRuntimeName(); 4888 }, 4889 get suffix() { 4890 return cacheNames_cacheNames.getSuffix(); 4891 }, 4892}; 4893 4894 4895;// CONCATENATED MODULE: ./node_modules/workbox-core/clientsClaim.js 4896/* 4897 Copyright 2019 Google LLC 4898 4899 Use of this source code is governed by an MIT-style 4900 license that can be found in the LICENSE file or at 4901 https://opensource.org/licenses/MIT.
4902*/ 4903 4904/** 4905 * Claim any currently available clients once the service worker 4906 * becomes active. This is normally used in conjunction with `skipWaiting()`. 4907 * 4908 * @memberof module:workbox-core 4909 */ 4910function clientsClaim() { 4911 self.addEventListener('activate', () => self.clients.claim()); 4912} 4913 4914 4915;// CONCATENATED MODULE: ./node_modules/workbox-core/setCacheNameDetails.js 4916/* 4917 Copyright 2019 Google LLC 4918 4919 Use of this source code is governed by an MIT-style 4920 license that can be found in the LICENSE file or at 4921 https://opensource.org/licenses/MIT. 4922*/ 4923 4924 4925 4926 4927/** 4928 * Modifies the default cache names used by the Workbox packages. 4929 * Cache names are generated as `<prefix>-<Cache Name>-<suffix>`. 4930 * 4931 * @param {Object} details 4932 * @param {Object} [details.prefix] The string to add to the beginning of 4933 * the precache and runtime cache names. 4934 * @param {Object} [details.suffix] The string to add to the end of 4935 * the precache and runtime cache names. 4936 * @param {Object} [details.precache] The cache name to use for precache 4937 * caching. 4938 * @param {Object} [details.runtime] The cache name to use for runtime caching. 4939 * @param {Object} [details.googleAnalytics] The cache name to use for 4940 * `workbox-google-analytics` caching. 4941 * 4942 * @memberof module:workbox-core 4943 */ 4944function setCacheNameDetails(details) { 4945 if (false) {} 4946 cacheNames.updateDetails(details); 4947} 4948 4949 4950;// CONCATENATED MODULE: ./node_modules/workbox-core/skipWaiting.js 4951/* 4952 Copyright 2019 Google LLC 4953 4954 Use of this source code is governed by an MIT-style 4955 license that can be found in the LICENSE file or at 4956 https://opensource.org/licenses/MIT. 4957*/ 4958 4959 4960/** 4961 * This method is deprecated, and will be removed in Workbox v7. 4962 * 4963 * Calling self.skipWaiting() is equivalent, and should be used instead. 4964 * 4965 * @memberof module:workbox-core 4966 */ 4967function skipWaiting() { 4968 // Just call self.skipWaiting() directly. 4969 // See https://github.com/GoogleChrome/workbox/issues/2525 4970 if (false) {} 4971 self.skipWaiting(); 4972} 4973 4974 4975;// CONCATENATED MODULE: ./node_modules/workbox-core/types.js 4976/* 4977 Copyright 2019 Google LLC 4978 4979 Use of this source code is governed by an MIT-style 4980 license that can be found in the LICENSE file or at 4981 https://opensource.org/licenses/MIT. 4982*/ 4983 4984 4985;// CONCATENATED MODULE: ./node_modules/workbox-core/index.js 4986/* 4987 Copyright 2018 Google LLC 4988 4989 Use of this source code is governed by an MIT-style 4990 license that can be found in the LICENSE file or at 4991 https://opensource.org/licenses/MIT. 4992*/ 4993 4994 4995 4996 4997 4998 4999 5000 5001/** 5002 * All of the Workbox service worker libraries use workbox-core for shared 5003 * code as well as setting default values that need to be shared (like cache 5004 * names). 5005 * 5006 * @module workbox-core 5007 */ 5008 5009 5010 5011;// CONCATENATED MODULE: ./node_modules/workbox-core/index.mjs 5012 5013;// CONCATENATED MODULE: ./src/sw-src.js 5014 5015 5016 5017 5018 5019precacheAndRoute([{'revision':'c026001eb1ba318fa08658772b15a0e8','url':'/404.html'},{'revision':null,'url':'/images/banner-girl-1.24e9b8f48d5a0ac32680edd194503695.png'},{'revision':null,'url':'/images/banner-girl.789f1fa6f451ad26c5039fcbc049ace7.png'},{'revision':null,'url':'/images/banner-guy.fbf4f0f7396fe31ca288dc1dd9822342.png'},{'revision':null,'url':'/images/creditcards.9024dc86450bbd2666b162083f5f91dd.png'},{'revision':null,'url':'/images/defaultAvatar.4e9edb2a624547982816014bf128fcd5.jpg'},{'revision':null,'url':'/images/defaultBanner.accdc757f2c48d61f24c4fbcef2742fd.jpg'},{'revision':null,'url':'/images/logo-full.059e10fa5fedbfb65165e7565ed3936f.png'},{'revision':null,'url':'/images/logo-wordmark.c9095b79e4c1cb5d9f82799542443b19.png'},{'revision':'c026001eb1ba318fa08658772b15a0e8','url':'/index.html'},{'revision':null,'url':'/js/404.a5635b6b5c21c5065022.js'},{'revision':null,'url':'/js/503.59b6e0f338ad629c8285.js'},{'revision':null,'url':'/js/99.20f09d34c40cc767ae8a.js'},{'revision':null,'url':'/js/main.d2396263f50d632d158f.js'},{'revision':null,'url':'/js/vendor.f42d28005320a0b72169.js'},{'revision':'f2bf0f24470da4cdb9b70601464c4387','url':'/main.css'},{'revision':'b127f7589a1b597b853947114cce97f1','url':'/static/banner.jpg'},{'revision':'f866913f47c4b6b837a6920189f8b265','url':'/static/creditcards.png'},{'revision':'c1558c012afbfb5c95a86f1a99786826','url':'/static/favicon.png'},{'revision':'0fe515be36c779c448b8099a43c48aea','url':'/static/logo-full.png'},{'revision':'6cb5664eba350b2d6c6bd0c25ad53d08','url':'/static/logo-wordmark.png'},{'revision':'9e041348b72afb7287a8074e1f9ee9c2','url':'/static/profile.jpg'},{'revision':'2e88ba459d46a9001f05b408b3058809','url':'/static/salt-image-1.png'},{'revision':'b920335ece6eef0cac097dabef93b4a1','url':'/static/salt-image-10.png'},{'revision':'cf3804871087b1f605cdb983702a0b02','url':'/static/salt-image-2.png'},{'revision':'66524363461b77249e983bb30dd3894f','url':'/static/salt-image-3.png'},{'revision':'afb2bd6986a1e26cb9341e1feb6f0aa3','url':'/static/salt-image-4.png'},{'revision':'c0833c0f6e8bd9be978827cc8754e4d8','url':'/static/salt-image-5.png'},{'revision':'04c3a5f007cc5877607ad4412ab05342','url':'/static/salt-image-7.png'},{'revision':'47f60be69484dc71192b465f37776861','url':'/static/screeny1.png'},{'revision':'cf5ae31f6e8fad6040284b96181420ab','url':'/static/screeny2.png'},{'revision':'b3fe41604e587c865e0f5b60e410c040','url':'/static/screeny3.png'},{'revision':'a18ae486f9c28c584e43d130f0d705bf','url':'/static/screeny4.png'},{'revision':'9c3a19c74ae80e4932bc8931755613a6','url':'/static/screeny5.png'},{'revision':'7909f7f1c602912af6c46c8ccd5c5ca7','url':'/static/screeny6.png'},{'revision':'56e89aa2ffa41af611af0f27052a7d22','url':'/static/screeny7.png'},{'revision':'dada1fb3d0791f3615f6b2e8782026e1','url':'/static/screeny8.png'},{'revision':'b5c8bb366fedd517ef17750883c3061e','url':'/static/screeny9.png'},{'revision':'b1e0a283928cc4ce2a1b8b77c0163933','url':'/vendor.css'}]); 5020var currentCacheNames = Object.assign({ 5021 precacheTemp: workbox_core_cacheNames_cacheNames.precache + "-temp" 5022}, workbox_core_cacheNames_cacheNames); 5023currentCacheNames.fonts = "googlefonts"; 5024registerRoute(/https:\/\/fonts.(?:googleapis|gstatic).com\/(.*)/, new CacheFirst({ 5025 cacheName: currentCacheNames.fonts, 5026 plugins: [new ExpirationPlugin({ 5027 maxEntries: 30 5028 })] 5029}), "GET"); // clean up old SW caches 5030 5031self.addEventListener("activate", function (event) { 5032 event.waitUntil(caches.keys().then(function (cacheNames) {
5033 var validCacheSet = new Set(Object.values(currentCacheNames)); 5034 return Promise.all(cacheNames.filter(function (cacheName) { 5035 return !validCacheSet.has(cacheName); 5036 }).map(function (cacheName) { 5037 console.log("deleting cache", cacheName); 5038 return caches["delete"](cacheName); 5039 })); 5040 })); 5041}); 5042})(); 5043 5044/******/ })() 5045; 5046//# sourceMappingURL=sw.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.