jekyll-pwa-workbox 0.0.7.alpha → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-pwa-workbox.rb +1 -1
  3. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-background-sync.dev.js +12 -13
  4. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.dev.js.map +1 -0
  5. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js +2 -0
  6. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js.map +1 -0
  7. data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js +288 -0
  8. data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js.map +1 -0
  9. data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js +2 -0
  10. data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js.map +1 -0
  11. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-cacheable-response.dev.js +6 -7
  12. data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.dev.js.map +1 -0
  13. data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js +2 -0
  14. data/lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js.map +1 -0
  15. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-core.dev.js +306 -67
  16. data/lib/vendor/workbox-v5.0.0/workbox-core.dev.js.map +1 -0
  17. data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js +2 -0
  18. data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js.map +1 -0
  19. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-expiration.dev.js +13 -14
  20. data/lib/vendor/workbox-v5.0.0/workbox-expiration.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js +2 -0
  22. data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js.map +1 -0
  23. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-navigation-preload.dev.js +4 -5
  24. data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.dev.js.map +1 -0
  25. data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js +2 -0
  26. data/lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js.map +1 -0
  27. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-offline-ga.dev.js +12 -13
  28. data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.dev.js.map +1 -0
  29. data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js +2 -0
  30. data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js.map +1 -0
  31. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-precaching.dev.js +314 -86
  32. data/lib/vendor/workbox-v5.0.0/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js +2 -0
  34. data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-range-requests.dev.js +8 -9
  36. data/lib/vendor/workbox-v5.0.0/workbox-range-requests.dev.js.map +1 -0
  37. data/lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js +2 -0
  38. data/lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js.map +1 -0
  39. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-routing.dev.js +79 -182
  40. data/lib/vendor/workbox-v5.0.0/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js +2 -0
  42. data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js.map +1 -0
  43. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-strategies.dev.js +23 -227
  44. data/lib/vendor/workbox-v5.0.0/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js +2 -0
  46. data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-streams.dev.js +16 -31
  48. data/lib/vendor/workbox-v5.0.0/workbox-streams.dev.js.map +1 -0
  49. data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js +2 -0
  50. data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js.map +1 -0
  51. data/lib/vendor/workbox-v5.0.0/workbox-sw.js +2 -0
  52. data/lib/vendor/workbox-v5.0.0/workbox-sw.js.map +1 -0
  53. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.es5.mjs +317 -113
  54. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.es5.mjs.map +1 -0
  55. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.mjs +244 -44
  56. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.mjs.map +1 -0
  57. data/lib/vendor/{workbox-v5.0.0.alpha1 → workbox-v5.0.0}/workbox-window.dev.umd.js +317 -113
  58. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.umd.js.map +1 -0
  59. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs +2 -0
  60. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs.map +1 -0
  61. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs +2 -0
  62. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs.map +1 -0
  63. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js +2 -0
  64. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js.map +1 -0
  65. metadata +70 -69
  66. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map +0 -1
  67. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js +0 -2
  68. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map +0 -1
  69. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js +0 -486
  70. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map +0 -1
  71. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js +0 -2
  72. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map +0 -1
  73. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map +0 -1
  74. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js +0 -2
  75. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map +0 -1
  76. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map +0 -1
  77. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js +0 -2
  78. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map +0 -1
  79. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map +0 -1
  80. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js +0 -2
  81. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map +0 -1
  82. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map +0 -1
  83. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js +0 -2
  84. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map +0 -1
  85. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map +0 -1
  86. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js +0 -2
  87. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map +0 -1
  88. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map +0 -1
  89. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js +0 -2
  90. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map +0 -1
  91. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map +0 -1
  92. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js +0 -2
  93. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map +0 -1
  94. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map +0 -1
  95. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js +0 -2
  96. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map +0 -1
  97. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map +0 -1
  98. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js +0 -2
  99. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map +0 -1
  100. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map +0 -1
  101. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js +0 -2
  102. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map +0 -1
  103. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js +0 -2
  104. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map +0 -1
  105. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map +0 -1
  106. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map +0 -1
  107. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map +0 -1
  108. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs +0 -2
  109. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map +0 -1
  110. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs +0 -2
  111. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map +0 -1
  112. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js +0 -2
  113. data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-window.dev.umd.js","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../../workbox-core/_private/dontWaitFor.js","../../workbox-core/_private/logger.js","../utils/WorkboxEventTarget.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:window:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport './_version.js';\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n * @memberof module:workbox-window\n */\nfunction messageSW(sw, data) {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (event) => {\n resolve(event.data);\n };\n sw.postMessage(data, [messageChannel.port2]);\n });\n}\n;\nexport { messageSW };\n","\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:core:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nclass Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\nexport { Deferred };\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A helper function that prevents a promise from being flagged as unused.\n *\n * @private\n **/\nexport function dontWaitFor(promise) {\n // Effective no-op.\n promise.then(() => { });\n}\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\nconst logger = (process.env.NODE_ENV === 'production' ? null : (() => {\n // Don't overwrite this value if it's already set.\n // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923\n if (!('__WB_DISABLE_DEV_LOGS' in self)) {\n self.__WB_DISABLE_DEV_LOGS = false;\n }\n let inGroup = false;\n const methodToColorMap = {\n debug: `#7f8c8d`,\n log: `#2ecc71`,\n warn: `#f39c12`,\n error: `#c0392b`,\n groupCollapsed: `#3498db`,\n groupEnd: null,\n };\n const print = function (method, args) {\n if (self.__WB_DISABLE_DEV_LOGS) {\n return;\n }\n if (method === 'groupCollapsed') {\n // Safari doesn't print all console.groupCollapsed() arguments:\n // https://bugs.webkit.org/show_bug.cgi?id=182754\n if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {\n console[method](...args);\n return;\n }\n }\n const styles = [\n `background: ${methodToColorMap[method]}`,\n `border-radius: 0.5em`,\n `color: white`,\n `font-weight: bold`,\n `padding: 2px 0.5em`,\n ];\n // When in a group, the workbox prefix is not displayed.\n const logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];\n console[method](...logPrefix, ...args);\n if (method === 'groupCollapsed') {\n inGroup = true;\n }\n if (method === 'groupEnd') {\n inGroup = false;\n }\n };\n const api = {};\n const loggerMethods = Object.keys(methodToColorMap);\n for (const key of loggerMethods) {\n const method = key;\n api[method] = (...args) => {\n print(method, args);\n };\n }\n return api;\n})());\nexport { logger };\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nexport class WorkboxEventTarget {\n constructor() {\n this._eventListenerRegistry = new Map();\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n const foo = this._getEventListenersByType(type);\n foo.add(listener);\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n /**\n * @param {Object} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n const listeners = this._getEventListenersByType(event.type);\n for (const listener of listeners) {\n listener(event);\n }\n }\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set<ListenerCallback>} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n if (!this._eventListenerRegistry.has(type)) {\n this._eventListenerRegistry.set(type, new Set());\n }\n return this._eventListenerRegistry.get(type);\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nexport function urlsMatch(url1, url2) {\n const { href } = location;\n return new URL(url1, href).href === new URL(url2, href).href;\n}\n;\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nexport class WorkboxEvent {\n constructor(type, props) {\n this.type = type;\n Object.assign(this, props);\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\nimport { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { messageSW } from './messageSW.js';\nimport { WorkboxEventTarget } from './utils/WorkboxEventTarget.js';\nimport { urlsMatch } from './utils/urlsMatch.js';\nimport { WorkboxEvent } from './utils/WorkboxEvent.js';\nimport './_version.js';\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n * @memberof module:workbox-window\n */\nclass Workbox extends WorkboxEventTarget {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n this._registerOptions = {};\n this._updateFoundCount = 0;\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n this._registrationTime = 0;\n this._ownSWs = new Set();\n /**\n * @private\n */\n this._onUpdateFound = () => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const installingSW = registration.installing;\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally = \n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n registration.removeEventListener('updatefound', this._onUpdateFound);\n }\n else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._ownSWs.add(installingSW);\n this._swDeferred.resolve(installingSW);\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n }\n else {\n logger.log('Service worker is installing...');\n }\n }\n }\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onStateChange = (originalEvent) => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const sw = originalEvent.target;\n const { state } = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n const eventProps = {\n sw,\n originalEvent\n };\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = self.setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n }\n else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n }\n else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n }\n else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n }\n else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n }\n else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onControllerChange = (originalEvent) => {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {\n sw,\n originalEvent,\n isUpdate: this._isUpdate,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onMessage = async (originalEvent) => {\n const { data, source } = originalEvent;\n // Wait until there's an \"own\" service worker. This is used to buffer\n // `message` events that may be received prior to calling `register()`.\n await this.getSW();\n // If the service worker that sent the message is in the list of own\n // service workers for this instance, dispatch a `message` event.\n // NOTE: we check for all previously owned service workers rather than\n // just the current one because some messages (e.g. cache updates) use\n // a timeout when sent and may be delayed long enough for a service worker\n // update to be found.\n if (this._ownSWs.has(source)) {\n this.dispatchEvent(new WorkboxEvent('message', {\n data,\n sw: source,\n originalEvent,\n }));\n }\n };\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n // Add a message listener immediately since messages received during\n // page load are buffered only until the DOMContentLoaded event:\n // https://github.com/GoogleChrome/workbox/issues/2202\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n }\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({ immediate = false } = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => window.addEventListener('load', res));\n }\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n this._registration = await this._registerScript();\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener('statechange', this._onStateChange, { once: true });\n }\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the previous\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n dontWaitFor(Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n }));\n }\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n this._ownSWs.add(this._sw);\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n }\n else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener('controllerchange', this._onControllerChange, { once: true });\n return this._registration;\n }\n /**\n * Checks for updates of the registered service worker.\n */\n async update() {\n if (!this._registration) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('Cannot update a Workbox instance without ' +\n 'being registered. Register the Workbox instance first.');\n }\n return;\n }\n // Try to update registration\n await this._registration.update();\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw !== undefined ? this._sw : this._swDeferred.promise;\n }\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matches.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n else {\n return undefined;\n }\n }\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(this._scriptURL, this._registerOptions);\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n return reg;\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n}\nexport { Workbox };\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n/**\n * The `message` event is dispatched any time a `postMessage` is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original\n * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event, or `undefined` in the case where the service worker was waiting\n * to before `.register()` was called.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","postMessage","port2","Deferred","promise","reject","dontWaitFor","then","logger","process","__WB_DISABLE_DEV_LOGS","inGroup","methodToColorMap","debug","log","warn","error","groupCollapsed","groupEnd","print","method","args","test","navigator","userAgent","console","styles","logPrefix","join","api","loggerMethods","Object","keys","key","WorkboxEventTarget","_eventListenerRegistry","Map","addEventListener","type","listener","foo","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","target","listeners","has","set","Set","get","urlsMatch","url1","url2","location","href","URL","WorkboxEvent","props","assign","_await","value","direct","WAITING_TIMEOUT_DURATION","_async","f","i","arguments","length","apply","REGISTRATION_TIMEOUT_DURATION","_empty","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_ownSWs","_onUpdateFound","registration","_registration","installingSW","installing","updateLikelyTriggeredExternally","_scriptURL","performance","now","_externalSW","_sw","serviceWorker","controller","_onStateChange","originalEvent","state","isExternal","eventPrefix","eventProps","_isUpdate","isUpdate","_waitingTimeout","setTimeout","waiting","clearTimeout","_compatibleControllingSW","_onControllerChange","_onMessage","source","getSW","register","immediate","document","readyState","res","window","Boolean","_getControllingSWIfCompatible","_registerScript","once","waitingSW","wasWaitingBeforeRegister","currentPageIsOutOfScope","scopeURL","scope","baseURI","scopeURLBasePath","pathname","starts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f,GAAsBuD,KAAK,CAACvD,IAAN,QAAtB,GAA2Cb,OAAO,CAACC,OAAR,EAAlD;IACA;IACD;IAmXD;;IACA;;;;;;;;;;;;IAWA;;;;;;;;;;;;;;;;;;;;;IAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;IAyBA;;;;;;;;;;;;;;;;;;;;IAmBA;;;;;;;;;;;;;;;;;IAgBA;;;;;;;;;;;;;;;;;IAgBA;;;;;;;;;;;;;;IAaA;;;;;;;;;;;;;;IAaA;;;;;;;;;;;;;;;IA3DO,iBAAiB4I,IAAjB,EAAuBhI,IAAvB,EAA6B;IACnC,MAAIiI,MAAM,GAAGD,IAAI,EAAjB;;IACA,MAAIC,MAAM,IAAIA,MAAM,CAACjI,IAArB,EAA2B;IAC1B,WAAOiI,MAAM,CAACjI,IAAP,CAAYA,IAAZ,CAAP;IACA;;IACD,SAAOA,IAAI,CAACiI,MAAD,CAAX;IACA;;IAWM,gBAAgBD,IAAhB,EAAsBE,OAAtB,EAA+B;IACrC,MAAI;IACH,QAAID,MAAM,GAAGD,IAAI,EAAjB;IACA,GAFD,CAEE,OAAMjJ,CAAN,EAAS;IACV,WAAOmJ,OAAO,CAACnJ,CAAD,CAAd;IACA;;IACD,MAAIkJ,MAAM,IAAIA,MAAM,CAACjI,IAArB,EAA2B;IAC1B,WAAOiI,MAAM,CAACjI,IAAP,CAAY,KAAK,CAAjB,EAAoBkI,OAApB,CAAP;IACA;;IACD,SAAOD,MAAP;IACA;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ try{self["workbox:window:5.0.0"]&&_()}catch(n){}function n(n,t){return new Promise(function(r){var i=new MessageChannel;i.port1.onmessage=function(n){r(n.data)},n.postMessage(t,[i.port2])})}function t(n,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}try{self["workbox:core:5.0.0"]&&_()}catch(n){}var r=function(){var n=this;this.promise=new Promise(function(t,r){n.resolve=t,n.reject=r})};function i(n,t){var r=location.href;return new URL(n,r).href===new URL(t,r).href}var e=function(n,t){this.type=n,Object.assign(this,t)};function o(n,t,r){return r?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}var u=200;function a(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}var c=6e4;function f(){}var s=function(f){var s,h;function w(n,t){var s;return void 0===t&&(t={}),(s=f.call(this)||this).t={},s.i=0,s.o=new r,s.u=new r,s.s=new r,s.v=0,s.h=new Set,s.l=function(){var n=s.g,t=n.installing;s.i>0||!i(t.scriptURL,s.m)||performance.now()>s.v+c?(s.p=t,n.removeEventListener("updatefound",s.l)):(s.P=t,s.h.add(t),s.o.resolve(t)),++s.i,t.addEventListener("statechange",s.k)},s.k=function(n){var t=s.g,r=n.target,i=r.state,o=r===s.p,a=o?"external":"",c={sw:r,originalEvent:n};!o&&s.j&&(c.isUpdate=!0),s.dispatchEvent(new e(a+i,c)),"installed"===i?s.O=self.setTimeout(function(){"installed"===i&&t.waiting===r&&s.dispatchEvent(new e(a+"waiting",c))},u):"activating"===i&&(clearTimeout(s.O),o||s.u.resolve(r))},s.R=function(n){var t=s.P;t===navigator.serviceWorker.controller&&(s.dispatchEvent(new e("controlling",{sw:t,originalEvent:n,isUpdate:s.j})),s.s.resolve(t))},s.S=a(function(n){var t=n.data,r=n.source;return o(s.getSW(),function(){s.h.has(r)&&s.dispatchEvent(new e("message",{data:t,sw:r,originalEvent:n}))})}),s.m=n,s.t=t,navigator.serviceWorker.addEventListener("message",s.S),s}h=f,(s=w).prototype=Object.create(h.prototype),s.prototype.constructor=s,s.__proto__=h;var l,g,d,m=w.prototype;return m.register=a(function(n){var t=this,r=(void 0===n?{}:n).immediate,u=void 0!==r&&r;return function(n,t){var r=n();if(r&&r.then)return r.then(t);return t(r)}(function(){if(!u&&"complete"!==document.readyState)return v(new Promise(function(n){return window.addEventListener("load",n)}))},function(){return t.j=Boolean(navigator.serviceWorker.controller),t.U=t.B(),o(t.L(),function(n){t.g=n,t.U&&(t.P=t.U,t.u.resolve(t.U),t.s.resolve(t.U),t.U.addEventListener("statechange",t.k,{once:!0}));var r=t.g.waiting;return r&&i(r.scriptURL,t.m)&&(t.P=r,Promise.resolve().then(function(){t.dispatchEvent(new e("waiting",{sw:r,wasWaitingBeforeRegister:!0}))}).then(function(){})),t.P&&(t.o.resolve(t.P),t.h.add(t.P)),t.g.addEventListener("updatefound",t.l),navigator.serviceWorker.addEventListener("controllerchange",t.R,{once:!0}),t.g})})}),m.update=a(function(){if(this.g)return v(this.g.update())}),m.getSW=a(function(){return void 0!==this.P?this.P:this.o.promise}),m.messageSW=a(function(t){return o(this.getSW(),function(r){return n(r,t)})}),m.B=function(){var n=navigator.serviceWorker.controller;return n&&i(n.scriptURL,this.m)?n:void 0},m.L=a(function(){var n=this;return function(n,t){try{var r=n()}catch(n){return t(n)}if(r&&r.then)return r.then(void 0,t);return r}(function(){return o(navigator.serviceWorker.register(n.m,n.t),function(t){return n.v=performance.now(),t})},function(n){throw n})}),l=w,(g=[{key:"active",get:function(){return this.u.promise}},{key:"controlling",get:function(){return this.s.promise}}])&&t(l.prototype,g),d&&t(l,d),w}(function(){function n(){this.M=new Map}var t=n.prototype;return t.addEventListener=function(n,t){this._(n).add(t)},t.removeEventListener=function(n,t){this._(n).delete(t)},t.dispatchEvent=function(n){n.target=this;var t=this._(n.type),r=Array.isArray(t),i=0;for(t=r?t:t[Symbol.iterator]();;){var e;if(r){if(i>=t.length)break;e=t[i++]}else{if((i=t.next()).done)break;e=i.value}e(n)}},t._=function(n){return this.M.has(n)||this.M.set(n,new Set),this.M.get(n)},n}());function v(n,t){if(!t)return n&&n.then?n.then(f):Promise.resolve()}export{s as Workbox,n as messageSW};
2
+ //# sourceMappingURL=workbox-window.prod.es5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-window.prod.es5.mjs","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js","../../workbox-core/_private/dontWaitFor.js","../utils/WorkboxEventTarget.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:window:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport './_version.js';\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n * @memberof module:workbox-window\n */\nfunction messageSW(sw, data) {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (event) => {\n resolve(event.data);\n };\n sw.postMessage(data, [messageChannel.port2]);\n });\n}\n;\nexport { messageSW };\n","\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:core:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nclass Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\nexport { Deferred };\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nexport function urlsMatch(url1, url2) {\n const { href } = location;\n return new URL(url1, href).href === new URL(url2, href).href;\n}\n;\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nexport class WorkboxEvent {\n constructor(type, props) {\n this.type = type;\n Object.assign(this, props);\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\nimport { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { messageSW } from './messageSW.js';\nimport { WorkboxEventTarget } from './utils/WorkboxEventTarget.js';\nimport { urlsMatch } from './utils/urlsMatch.js';\nimport { WorkboxEvent } from './utils/WorkboxEvent.js';\nimport './_version.js';\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n * @memberof module:workbox-window\n */\nclass Workbox extends WorkboxEventTarget {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n this._registerOptions = {};\n this._updateFoundCount = 0;\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n this._registrationTime = 0;\n this._ownSWs = new Set();\n /**\n * @private\n */\n this._onUpdateFound = () => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const installingSW = registration.installing;\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally = \n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n registration.removeEventListener('updatefound', this._onUpdateFound);\n }\n else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._ownSWs.add(installingSW);\n this._swDeferred.resolve(installingSW);\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n }\n else {\n logger.log('Service worker is installing...');\n }\n }\n }\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onStateChange = (originalEvent) => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const sw = originalEvent.target;\n const { state } = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n const eventProps = {\n sw,\n originalEvent\n };\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = self.setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n }\n else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n }\n else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n }\n else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n }\n else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n }\n else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onControllerChange = (originalEvent) => {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {\n sw,\n originalEvent,\n isUpdate: this._isUpdate,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onMessage = async (originalEvent) => {\n const { data, source } = originalEvent;\n // Wait until there's an \"own\" service worker. This is used to buffer\n // `message` events that may be received prior to calling `register()`.\n await this.getSW();\n // If the service worker that sent the message is in the list of own\n // service workers for this instance, dispatch a `message` event.\n // NOTE: we check for all previously owned service workers rather than\n // just the current one because some messages (e.g. cache updates) use\n // a timeout when sent and may be delayed long enough for a service worker\n // update to be found.\n if (this._ownSWs.has(source)) {\n this.dispatchEvent(new WorkboxEvent('message', {\n data,\n sw: source,\n originalEvent,\n }));\n }\n };\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n // Add a message listener immediately since messages received during\n // page load are buffered only until the DOMContentLoaded event:\n // https://github.com/GoogleChrome/workbox/issues/2202\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n }\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({ immediate = false } = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => window.addEventListener('load', res));\n }\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n this._registration = await this._registerScript();\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener('statechange', this._onStateChange, { once: true });\n }\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the previous\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n dontWaitFor(Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n }));\n }\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n this._ownSWs.add(this._sw);\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n }\n else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener('controllerchange', this._onControllerChange, { once: true });\n return this._registration;\n }\n /**\n * Checks for updates of the registered service worker.\n */\n async update() {\n if (!this._registration) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('Cannot update a Workbox instance without ' +\n 'being registered. Register the Workbox instance first.');\n }\n return;\n }\n // Try to update registration\n await this._registration.update();\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw !== undefined ? this._sw : this._swDeferred.promise;\n }\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matches.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n else {\n return undefined;\n }\n }\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(this._scriptURL, this._registerOptions);\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n return reg;\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n}\nexport { Workbox };\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n/**\n * The `message` event is dispatched any time a `postMessage` is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original\n * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event, or `undefined` in the case where the service worker was waiting\n * to before `.register()` was called.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A helper function that prevents a promise from being flagged as unused.\n *\n * @private\n **/\nexport function dontWaitFor(promise) {\n // Effective no-op.\n promise.then(() => { });\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nexport class WorkboxEventTarget {\n constructor() {\n this._eventListenerRegistry = new Map();\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n const foo = this._getEventListenersByType(type);\n foo.add(listener);\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n /**\n * @param {Object} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n const listeners = this._getEventListenersByType(event.type);\n for (const listener of listeners) {\n listener(event);\n }\n }\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set<ListenerCallback>} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n if (!this._eventListenerRegistry.has(type)) {\n this._eventListenerRegistry.set(type, new Set());\n }\n return this._eventListenerRegistry.get(type);\n }\n}\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","postMessage","port2","Deferred","promise","reject","_this","urlsMatch","url1","url2","href","location","URL","WorkboxEvent","type","props","Object","assign","this","_await","value","then","direct","WAITING_TIMEOUT_DURATION","_async","f","args","i","arguments","length","apply","REGISTRATION_TIMEOUT_DURATION","_empty","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_ownSWs","Set","_onUpdateFound","registration","_registration","installingSW","installing","_scriptURL","performance","now","_externalSW","removeEventListener","_sw","add","addEventListener","_onStateChange","originalEvent","target","state","isExternal","eventPrefix","eventProps","_isUpdate","isUpdate","dispatchEvent","_waitingTimeout","setTimeout","waiting","clearTimeout","_onControllerChange","navigator","serviceWorker","controller","_onMessage","source","getSW","has","register","immediate","body","result","document","readyState","res","window","Boolean","_compatibleControllingSW","_this2","_getControllingSWIfCompatible","_registerScript","once","waitingSW","wasWaitingBeforeRegister","update","undefined","recover","_this6","reg","error","_eventListenerRegistry","Map","listener","_getEventListenersByType","delete","set","get"],"mappings":"AAEA,IACIA,KAAK,yBAA2BC,IAEpC,MAAOC,ICiBP,SAASC,EAAUC,EAAIC,UACZ,IAAIC,QAAQ,SAACC,OACZC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAY,SAACC,GAC9BL,EAAQK,EAAMP,OAElBD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,gLC1B7C,IACId,KAAK,uBAAyBC,IAElC,MAAOC,QCWDa,EAIF,2BACSC,QAAU,IAAIV,QAAQ,S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6BAEaiG,EAAyB,IAAIC,+BAOtC9C,iBAAA,SAAiB1C,EAAMyF,GACPrF,KAAKsF,EAAyB1F,GACtCyC,IAAIgD,MAOZlD,oBAAA,SAAoBvC,EAAMyF,QACjBC,EAAyB1F,GAAM2F,OAAOF,MAM/CrC,cAAA,SAAclE,GACVA,EAAM2D,OAASzC,WACGA,KAAKsF,EAAyBxG,EAAMc,8DACpB,uFACrBd,OAWjBwG,EAAA,SAAyB1F,UAChBI,KAAKmF,EAAuBvB,IAAIhE,SAC5BuF,EAAuBK,IAAI5F,EAAM,IAAI6B,KAEvCzB,KAAKmF,EAAuBM,IAAI7F,MA5C/C,IFkFO,WAAuBM,EAAOE,OAC/BA,SACGF,GAASA,EAAMC,KAAOD,EAAMC,QAAe3B,QAAQC"}
@@ -0,0 +1,2 @@
1
+ try{self["workbox:window:5.0.0"]&&_()}catch(t){}function t(t,s){return new Promise(i=>{let e=new MessageChannel;e.port1.onmessage=(t=>{i(t.data)}),t.postMessage(s,[e.port2])})}try{self["workbox:core:5.0.0"]&&_()}catch(t){}class s{constructor(){this.promise=new Promise((t,s)=>{this.resolve=t,this.reject=s})}}class i{constructor(){this.t=new Map}addEventListener(t,s){this.s(t).add(s)}removeEventListener(t,s){this.s(t).delete(s)}dispatchEvent(t){t.target=this;const s=this.s(t.type);for(const i of s)i(t)}s(t){return this.t.has(t)||this.t.set(t,new Set),this.t.get(t)}}function e(t,s){const{href:i}=location;return new URL(t,i).href===new URL(s,i).href}class h{constructor(t,s){this.type=t,Object.assign(this,s)}}const n=200,a=6e4;class r extends i{constructor(t,i={}){super(),this.i={},this.h=0,this.o=new s,this.g=new s,this.l=new s,this.u=0,this.v=new Set,this.m=(()=>{const t=this.p,s=t.installing;this.h>0||!e(s.scriptURL,this.S)||performance.now()>this.u+a?(this.L=s,t.removeEventListener("updatefound",this.m)):(this._=s,this.v.add(s),this.o.resolve(s)),++this.h,s.addEventListener("statechange",this.P)}),this.P=(t=>{const s=this.p,i=t.target,{state:e}=i,a=i===this.L,r=a?"external":"",o={sw:i,originalEvent:t};!a&&this.W&&(o.isUpdate=!0),this.dispatchEvent(new h(r+e,o)),"installed"===e?this.B=self.setTimeout(()=>{"installed"===e&&s.waiting===i&&this.dispatchEvent(new h(r+"waiting",o))},n):"activating"===e&&(clearTimeout(this.B),a||this.g.resolve(i))}),this.C=(t=>{const s=this._;s===navigator.serviceWorker.controller&&(this.dispatchEvent(new h("controlling",{sw:s,originalEvent:t,isUpdate:this.W})),this.l.resolve(s))}),this.R=(async t=>{const{data:s,source:i}=t;await this.getSW(),this.v.has(i)&&this.dispatchEvent(new h("message",{data:s,sw:i,originalEvent:t}))}),this.S=t,this.i=i,navigator.serviceWorker.addEventListener("message",this.R)}async register({immediate:t=!1}={}){t||"complete"===document.readyState||await new Promise(t=>window.addEventListener("load",t)),this.W=Boolean(navigator.serviceWorker.controller),this.U=this.M(),this.p=await this.T(),this.U&&(this._=this.U,this.g.resolve(this.U),this.l.resolve(this.U),this.U.addEventListener("statechange",this.P,{once:!0}));const s=this.p.waiting;return s&&e(s.scriptURL,this.S)&&(this._=s,Promise.resolve().then(()=>{this.dispatchEvent(new h("waiting",{sw:s,wasWaitingBeforeRegister:!0}))}).then(()=>{})),this._&&(this.o.resolve(this._),this.v.add(this._)),this.p.addEventListener("updatefound",this.m),navigator.serviceWorker.addEventListener("controllerchange",this.C,{once:!0}),this.p}async update(){this.p&&await this.p.update()}get active(){return this.g.promise}get controlling(){return this.l.promise}async getSW(){return void 0!==this._?this._:this.o.promise}async messageSW(s){return t(await this.getSW(),s)}M(){const t=navigator.serviceWorker.controller;return t&&e(t.scriptURL,this.S)?t:void 0}async T(){try{const t=await navigator.serviceWorker.register(this.S,this.i);return this.u=performance.now(),t}catch(t){throw t}}}export{r as Workbox,t as messageSW};
2
+ //# sourceMappingURL=workbox-window.prod.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-window.prod.mjs","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../utils/WorkboxEventTarget.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js","../../workbox-core/_private/dontWaitFor.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:window:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport './_version.js';\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n * @memberof module:workbox-window\n */\nfunction messageSW(sw, data) {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (event) => {\n resolve(event.data);\n };\n sw.postMessage(data, [messageChannel.port2]);\n });\n}\n;\nexport { messageSW };\n","\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:core:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nclass Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\nexport { Deferred };\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nexport class WorkboxEventTarget {\n constructor() {\n this._eventListenerRegistry = new Map();\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n const foo = this._getEventListenersByType(type);\n foo.add(listener);\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n /**\n * @param {Object} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n const listeners = this._getEventListenersByType(event.type);\n for (const listener of listeners) {\n listener(event);\n }\n }\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set<ListenerCallback>} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n if (!this._eventListenerRegistry.has(type)) {\n this._eventListenerRegistry.set(type, new Set());\n }\n return this._eventListenerRegistry.get(type);\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nexport function urlsMatch(url1, url2) {\n const { href } = location;\n return new URL(url1, href).href === new URL(url2, href).href;\n}\n;\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nexport class WorkboxEvent {\n constructor(type, props) {\n this.type = type;\n Object.assign(this, props);\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\nimport { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { messageSW } from './messageSW.js';\nimport { WorkboxEventTarget } from './utils/WorkboxEventTarget.js';\nimport { urlsMatch } from './utils/urlsMatch.js';\nimport { WorkboxEvent } from './utils/WorkboxEvent.js';\nimport './_version.js';\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n * @memberof module:workbox-window\n */\nclass Workbox extends WorkboxEventTarget {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n this._registerOptions = {};\n this._updateFoundCount = 0;\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n this._registrationTime = 0;\n this._ownSWs = new Set();\n /**\n * @private\n */\n this._onUpdateFound = () => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const installingSW = registration.installing;\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally = \n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n registration.removeEventListener('updatefound', this._onUpdateFound);\n }\n else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._ownSWs.add(installingSW);\n this._swDeferred.resolve(installingSW);\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n }\n else {\n logger.log('Service worker is installing...');\n }\n }\n }\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onStateChange = (originalEvent) => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const sw = originalEvent.target;\n const { state } = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n const eventProps = {\n sw,\n originalEvent\n };\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = self.setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n }\n else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n }\n else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n }\n else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n }\n else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n }\n else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onControllerChange = (originalEvent) => {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {\n sw,\n originalEvent,\n isUpdate: this._isUpdate,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onMessage = async (originalEvent) => {\n const { data, source } = originalEvent;\n // Wait until there's an \"own\" service worker. This is used to buffer\n // `message` events that may be received prior to calling `register()`.\n await this.getSW();\n // If the service worker that sent the message is in the list of own\n // service workers for this instance, dispatch a `message` event.\n // NOTE: we check for all previously owned service workers rather than\n // just the current one because some messages (e.g. cache updates) use\n // a timeout when sent and may be delayed long enough for a service worker\n // update to be found.\n if (this._ownSWs.has(source)) {\n this.dispatchEvent(new WorkboxEvent('message', {\n data,\n sw: source,\n originalEvent,\n }));\n }\n };\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n // Add a message listener immediately since messages received during\n // page load are buffered only until the DOMContentLoaded event:\n // https://github.com/GoogleChrome/workbox/issues/2202\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n }\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({ immediate = false } = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => window.addEventListener('load', res));\n }\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n this._registration = await this._registerScript();\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener('statechange', this._onStateChange, { once: true });\n }\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the previous\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n dontWaitFor(Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n }));\n }\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n this._ownSWs.add(this._sw);\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n }\n else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener('controllerchange', this._onControllerChange, { once: true });\n return this._registration;\n }\n /**\n * Checks for updates of the registered service worker.\n */\n async update() {\n if (!this._registration) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('Cannot update a Workbox instance without ' +\n 'being registered. Register the Workbox instance first.');\n }\n return;\n }\n // Try to update registration\n await this._registration.update();\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw !== undefined ? this._sw : this._swDeferred.promise;\n }\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matches.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n else {\n return undefined;\n }\n }\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(this._scriptURL, this._registerOptions);\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n return reg;\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n}\nexport { Workbox };\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n/**\n * The `message` event is dispatched any time a `postMessage` is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original\n * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event, or `undefined` in the case where the service worker was waiting\n * to before `.register()` was called.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A helper function that prevents a promise from being flagged as unused.\n *\n * @private\n **/\nexport function dontWaitFor(promise) {\n // Effective no-op.\n promise.then(() => { });\n}\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","postMessage","port2","Deferred","constructor","promise","reject","WorkboxEventTarget","_eventListenerRegistry","Map","addEventListener","type","listener","this","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","target","listeners","has","set","Set","get","urlsMatch","url1","url2","href","location","URL","WorkboxEvent","props","Object","assign","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_ownSWs","_onUpdateFound","registration","_registration","installingSW","installing","_scriptURL","performance","now","_externalSW","_sw","_onStateChange","originalEvent","state","isExternal","eventPrefix","eventProps","_isUpdate","isUpdate","_waitingTimeout","setTimeout","waiting","clearTimeout","_onControllerChange","navigator","serviceWorker","controller","_onMessage","async","source","getSW","immediate","document","readyState","res","window","Boolean","_compatibleControllingSW","_getControllingSWIfCompatible","_registerScript","once","waitingSW","then","wasWaitingBeforeRegister","update","undefined","reg","register","error"],"mappings":"AAEA,IACIA,KAAK,yBAA2BC,IAEpC,MAAOC,ICiBP,SAASC,EAAUC,EAAIC,UACZ,IAAIC,QAASC,QACZC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAaC,CAAAA,IAC9BL,EAAQK,EAAMP,QAElBD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,UC1B7C,IACId,KAAK,uBAAyBC,IAElC,MAAOC,ICWP,MAAMa,EAIFC,mBACSC,QAAU,IAAIX,QAAQ,CAACC,EAASW,UAC5BX,QAAUA,OACVW,OAASA,KCV1B,MAAaC,EACTH,mBACSI,EAAyB,IAAIC,IAOt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KoC,EAAckB,eACjCoB,GAAa9D,EAAU8D,EAAUjD,UAAWzB,KAAKuC,UAG5CI,EAAM+B,EAGC7F,QAAQC,UAAU6F,KAAK,UAC1BtE,cAAc,IAAIa,EAAa,UAAW,CAC3CvC,GAAI+F,EACJE,0BAA0B,OCxSlCD,KAAK,SDiTL3E,KAAK2C,SACAd,EAAY/C,QAAQkB,KAAK2C,QACzBV,EAAQ/B,IAAIF,KAAK2C,SAyBrBP,EAAcvC,iBAAiB,cAAeG,KAAKkC,GACxDuB,UAAUC,cAAc7D,iBAAiB,mBAAoBG,KAAKwD,EAAqB,CAAEiB,MAAM,IACxFzE,KAAKoC,iBAMPpC,KAAKoC,SAQJpC,KAAKoC,EAAcyC,6BAYlB7E,KAAK8B,EAAgBtC,iCAerBQ,KAAK+B,EAAqBvC,kCAoBbsF,IAAb9E,KAAK2C,EAAoB3C,KAAK2C,EAAM3C,KAAK6B,EAAYrC,wBAehDZ,UAELF,QADUsB,KAAK+D,QACDnF,GASzB2F,UACUZ,EAAaF,UAAUC,cAAcC,kBACvCA,GAAc/C,EAAU+C,EAAWlC,UAAWzB,KAAKuC,GAC5CoB,6BAcDoB,QAAYtB,UAAUC,cAAcsB,SAAShF,KAAKuC,EAAYvC,KAAK2B,eAIpEK,EAAoBQ,YAAYC,MAC9BsC,EAEX,MAAOE,SAKGA"}
@@ -0,0 +1,2 @@
1
+ !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).workbox={})}(this,function(n){"use strict";try{self["workbox:window:5.0.0"]&&_()}catch(n){}function t(n,t){return new Promise(function(e){var r=new MessageChannel;r.port1.onmessage=function(n){e(n.data)},n.postMessage(t,[r.port2])})}function e(n,t){for(var e=0;e<t.length;e++){var r=t[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}try{self["workbox:core:5.0.0"]&&_()}catch(n){}var r=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})};function i(n,t){var e=location.href;return new URL(n,e).href===new URL(t,e).href}var o=function(n,t){this.type=n,Object.assign(this,t)};function u(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}var a=200;function c(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}var f=6e4;function s(){}var v=function(n){var s,v;function l(t,e){var s;return void 0===e&&(e={}),(s=n.call(this)||this).t={},s.i=0,s.o=new r,s.u=new r,s.s=new r,s.v=0,s.h=new Set,s.l=function(){var n=s.g,t=n.installing;s.i>0||!i(t.scriptURL,s.m)||performance.now()>s.v+f?(s.p=t,n.removeEventListener("updatefound",s.l)):(s.P=t,s.h.add(t),s.o.resolve(t)),++s.i,t.addEventListener("statechange",s.j)},s.j=function(n){var t=s.g,e=n.target,r=e.state,i=e===s.p,u=i?"external":"",c={sw:e,originalEvent:n};!i&&s.k&&(c.isUpdate=!0),s.dispatchEvent(new o(u+r,c)),"installed"===r?s.O=self.setTimeout(function(){"installed"===r&&t.waiting===e&&s.dispatchEvent(new o(u+"waiting",c))},a):"activating"===r&&(clearTimeout(s.O),i||s.u.resolve(e))},s._=function(n){var t=s.P;t===navigator.serviceWorker.controller&&(s.dispatchEvent(new o("controlling",{sw:t,originalEvent:n,isUpdate:s.k})),s.s.resolve(t))},s.M=c(function(n){var t=n.data,e=n.source;return u(s.getSW(),function(){s.h.has(e)&&s.dispatchEvent(new o("message",{data:t,sw:e,originalEvent:n}))})}),s.m=t,s.t=e,navigator.serviceWorker.addEventListener("message",s.M),s}v=n,(s=l).prototype=Object.create(v.prototype),s.prototype.constructor=s,s.__proto__=v;var w,d,g,m=l.prototype;return m.register=c(function(n){var t=this,e=(void 0===n?{}:n).immediate,r=void 0!==e&&e;return function(n,t){var e=n();if(e&&e.then)return e.then(t);return t(e)}(function(){if(!r&&"complete"!==document.readyState)return h(new Promise(function(n){return window.addEventListener("load",n)}))},function(){return t.k=Boolean(navigator.serviceWorker.controller),t.R=t.S(),u(t.U(),function(n){t.g=n,t.R&&(t.P=t.R,t.u.resolve(t.R),t.s.resolve(t.R),t.R.addEventListener("statechange",t.j,{once:!0}));var e=t.g.waiting;return e&&i(e.scriptURL,t.m)&&(t.P=e,Promise.resolve().then(function(){t.dispatchEvent(new o("waiting",{sw:e,wasWaitingBeforeRegister:!0}))}).then(function(){})),t.P&&(t.o.resolve(t.P),t.h.add(t.P)),t.g.addEventListener("updatefound",t.l),navigator.serviceWorker.addEventListener("controllerchange",t._,{once:!0}),t.g})})}),m.update=c(function(){if(this.g)return h(this.g.update())}),m.getSW=c(function(){return void 0!==this.P?this.P:this.o.promise}),m.messageSW=c(function(n){return u(this.getSW(),function(e){return t(e,n)})}),m.S=function(){var n=navigator.serviceWorker.controller;return n&&i(n.scriptURL,this.m)?n:void 0},m.U=c(function(){var n=this;return function(n,t){try{var e=n()}catch(n){return t(n)}if(e&&e.then)return e.then(void 0,t);return e}(function(){return u(navigator.serviceWorker.register(n.m,n.t),function(t){return n.v=performance.now(),t})},function(n){throw n})}),w=l,(d=[{key:"active",get:function(){return this.u.promise}},{key:"controlling",get:function(){return this.s.promise}}])&&e(w.prototype,d),g&&e(w,g),l}(function(){function n(){this.B=new Map}var t=n.prototype;return t.addEventListener=function(n,t){this.L(n).add(t)},t.removeEventListener=function(n,t){this.L(n).delete(t)},t.dispatchEvent=function(n){n.target=this;var t=this.L(n.type),e=Array.isArray(t),r=0;for(t=e?t:t[Symbol.iterator]();;){var i;if(e){if(r>=t.length)break;i=t[r++]}else{if((r=t.next()).done)break;i=r.value}i(n)}},t.L=function(n){return this.B.has(n)||this.B.set(n,new Set),this.B.get(n)},n}());function h(n,t){if(!t)return n&&n.then?n.then(s):Promise.resolve()}n.Workbox=v,n.messageSW=t,Object.defineProperty(n,"__esModule",{value:!0})});
2
+ //# sourceMappingURL=workbox-window.prod.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-window.prod.umd.js","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js","../../workbox-core/_private/dontWaitFor.js","../utils/WorkboxEventTarget.js"],"sourcesContent":["\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:window:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport './_version.js';\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n * @memberof module:workbox-window\n */\nfunction messageSW(sw, data) {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (event) => {\n resolve(event.data);\n };\n sw.postMessage(data, [messageChannel.port2]);\n });\n}\n;\nexport { messageSW };\n","\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:core:5.0.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * The Deferred class composes Promises in a way that allows for them to be\n * resolved or rejected from outside the constructor. In most cases promises\n * should be used directly, but Deferreds can be necessary when the logic to\n * resolve a promise must be separate.\n *\n * @private\n */\nclass Deferred {\n /**\n * Creates a promise and exposes its resolve and reject functions as methods.\n */\n constructor() {\n this.promise = new Promise((resolve, reject) => {\n this.resolve = resolve;\n this.reject = reject;\n });\n }\n}\nexport { Deferred };\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nexport function urlsMatch(url1, url2) {\n const { href } = location;\n return new URL(url1, href).href === new URL(url2, href).href;\n}\n;\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nexport class WorkboxEvent {\n constructor(type, props) {\n this.type = type;\n Object.assign(this, props);\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\nimport { dontWaitFor } from 'workbox-core/_private/dontWaitFor.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { messageSW } from './messageSW.js';\nimport { WorkboxEventTarget } from './utils/WorkboxEventTarget.js';\nimport { urlsMatch } from './utils/urlsMatch.js';\nimport { WorkboxEvent } from './utils/WorkboxEvent.js';\nimport './_version.js';\n// The time a SW must be in the waiting phase before we can conclude\n// `skipWaiting()` wasn't called. This 200 amount wasn't scientifically\n// chosen, but it seems to avoid false positives in my testing.\nconst WAITING_TIMEOUT_DURATION = 200;\n// The amount of time after a registration that we can reasonably conclude\n// that the registration didn't trigger an update.\nconst REGISTRATION_TIMEOUT_DURATION = 60000;\n/**\n * A class to aid in handling service worker registration, updates, and\n * reacting to service worker lifecycle events.\n *\n * @fires [message]{@link module:workbox-window.Workbox#message}\n * @fires [installed]{@link module:workbox-window.Workbox#installed}\n * @fires [waiting]{@link module:workbox-window.Workbox#waiting}\n * @fires [controlling]{@link module:workbox-window.Workbox#controlling}\n * @fires [activated]{@link module:workbox-window.Workbox#activated}\n * @fires [redundant]{@link module:workbox-window.Workbox#redundant}\n * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}\n * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}\n * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}\n * @memberof module:workbox-window\n */\nclass Workbox extends WorkboxEventTarget {\n /**\n * Creates a new Workbox instance with a script URL and service worker\n * options. The script URL and options are the same as those used when\n * calling `navigator.serviceWorker.register(scriptURL, options)`. See:\n * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register\n *\n * @param {string} scriptURL The service worker script associated with this\n * instance.\n * @param {Object} [registerOptions] The service worker options associated\n * with this instance.\n */\n constructor(scriptURL, registerOptions = {}) {\n super();\n this._registerOptions = {};\n this._updateFoundCount = 0;\n // Deferreds we can resolve later.\n this._swDeferred = new Deferred();\n this._activeDeferred = new Deferred();\n this._controllingDeferred = new Deferred();\n this._registrationTime = 0;\n this._ownSWs = new Set();\n /**\n * @private\n */\n this._onUpdateFound = () => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const installingSW = registration.installing;\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally = \n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n registration.removeEventListener('updatefound', this._onUpdateFound);\n }\n else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._ownSWs.add(installingSW);\n this._swDeferred.resolve(installingSW);\n // The `installing` state isn't something we have a dedicated\n // callback for, but we do log messages for it in development.\n if (process.env.NODE_ENV !== 'production') {\n if (navigator.serviceWorker.controller) {\n logger.log('Updated service worker found. Installing now...');\n }\n else {\n logger.log('Service worker is installing...');\n }\n }\n }\n // Increment the `updatefound` count, so future invocations of this\n // method can be sure they were triggered externally.\n ++this._updateFoundCount;\n // Add a `statechange` listener regardless of whether this update was\n // triggered externally, since we have callbacks for both.\n installingSW.addEventListener('statechange', this._onStateChange);\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onStateChange = (originalEvent) => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const sw = originalEvent.target;\n const { state } = sw;\n const isExternal = sw === this._externalSW;\n const eventPrefix = isExternal ? 'external' : '';\n const eventProps = {\n sw,\n originalEvent\n };\n if (!isExternal && this._isUpdate) {\n eventProps.isUpdate = true;\n }\n this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));\n if (state === 'installed') {\n // This timeout is used to ignore cases where the service worker calls\n // `skipWaiting()` in the install event, thus moving it directly in the\n // activating state. (Since all service workers *must* go through the\n // waiting phase, the only way to detect `skipWaiting()` called in the\n // install event is to observe that the time spent in the waiting phase\n // is very short.)\n // NOTE: we don't need separate timeouts for the own and external SWs\n // since they can't go through these phases at the same time.\n this._waitingTimeout = self.setTimeout(() => {\n // Ensure the SW is still waiting (it may now be redundant).\n if (state === 'installed' && registration.waiting === sw) {\n this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));\n if (process.env.NODE_ENV !== 'production') {\n if (isExternal) {\n logger.warn('An external service worker has installed but is ' +\n 'waiting for this client to close before activating...');\n }\n else {\n logger.warn('The service worker has installed but is waiting ' +\n 'for existing clients to close before activating...');\n }\n }\n }\n }, WAITING_TIMEOUT_DURATION);\n }\n else if (state === 'activating') {\n clearTimeout(this._waitingTimeout);\n if (!isExternal) {\n this._activeDeferred.resolve(sw);\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n switch (state) {\n case 'installed':\n if (isExternal) {\n logger.warn('An external service worker has installed. ' +\n 'You may want to suggest users reload this page.');\n }\n else {\n logger.log('Registered service worker installed.');\n }\n break;\n case 'activated':\n if (isExternal) {\n logger.warn('An external service worker has activated.');\n }\n else {\n logger.log('Registered service worker activated.');\n if (sw !== navigator.serviceWorker.controller) {\n logger.warn('The registered service worker is active but ' +\n 'not yet controlling the page. Reload or run ' +\n '`clients.claim()` in the service worker.');\n }\n }\n break;\n case 'redundant':\n if (sw === this._compatibleControllingSW) {\n logger.log('Previously controlling service worker now redundant!');\n }\n else if (!isExternal) {\n logger.log('Registered service worker now redundant!');\n }\n break;\n }\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onControllerChange = (originalEvent) => {\n const sw = this._sw;\n if (sw === navigator.serviceWorker.controller) {\n this.dispatchEvent(new WorkboxEvent('controlling', {\n sw,\n originalEvent,\n isUpdate: this._isUpdate,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Registered service worker now controlling this page.');\n }\n this._controllingDeferred.resolve(sw);\n }\n };\n /**\n * @private\n * @param {Event} originalEvent\n */\n this._onMessage = async (originalEvent) => {\n const { data, source } = originalEvent;\n // Wait until there's an \"own\" service worker. This is used to buffer\n // `message` events that may be received prior to calling `register()`.\n await this.getSW();\n // If the service worker that sent the message is in the list of own\n // service workers for this instance, dispatch a `message` event.\n // NOTE: we check for all previously owned service workers rather than\n // just the current one because some messages (e.g. cache updates) use\n // a timeout when sent and may be delayed long enough for a service worker\n // update to be found.\n if (this._ownSWs.has(source)) {\n this.dispatchEvent(new WorkboxEvent('message', {\n data,\n sw: source,\n originalEvent,\n }));\n }\n };\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\n // Add a message listener immediately since messages received during\n // page load are buffered only until the DOMContentLoaded event:\n // https://github.com/GoogleChrome/workbox/issues/2202\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n }\n /**\n * Registers a service worker for this instances script URL and service\n * worker options. By default this method delays registration until after\n * the window has loaded.\n *\n * @param {Object} [options]\n * @param {Function} [options.immediate=false] Setting this to true will\n * register the service worker immediately, even if the window has\n * not loaded (not recommended).\n */\n async register({ immediate = false } = {}) {\n if (process.env.NODE_ENV !== 'production') {\n if (this._registrationTime) {\n logger.error('Cannot re-register a Workbox instance after it has ' +\n 'been registered. Create a new instance instead.');\n return;\n }\n }\n if (!immediate && document.readyState !== 'complete') {\n await new Promise((res) => window.addEventListener('load', res));\n }\n // Set this flag to true if any service worker was controlling the page\n // at registration time.\n this._isUpdate = Boolean(navigator.serviceWorker.controller);\n // Before registering, attempt to determine if a SW is already controlling\n // the page, and if that SW script (and version, if specified) matches this\n // instance's script.\n this._compatibleControllingSW = this._getControllingSWIfCompatible();\n this._registration = await this._registerScript();\n // If we have a compatible controller, store the controller as the \"own\"\n // SW, resolve active/controlling deferreds and add necessary listeners.\n if (this._compatibleControllingSW) {\n this._sw = this._compatibleControllingSW;\n this._activeDeferred.resolve(this._compatibleControllingSW);\n this._controllingDeferred.resolve(this._compatibleControllingSW);\n this._compatibleControllingSW.addEventListener('statechange', this._onStateChange, { once: true });\n }\n // If there's a waiting service worker with a matching URL before the\n // `updatefound` event fires, it likely means that this site is open\n // in another tab, or the user refreshed the page (and thus the previous\n // page wasn't fully unloaded before this page started loading).\n // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting\n const waitingSW = this._registration.waiting;\n if (waitingSW && urlsMatch(waitingSW.scriptURL, this._scriptURL)) {\n // Store the waiting SW as the \"own\" Sw, even if it means overwriting\n // a compatible controller.\n this._sw = waitingSW;\n // Run this in the next microtask, so any code that adds an event\n // listener after awaiting `register()` will get this event.\n dontWaitFor(Promise.resolve().then(() => {\n this.dispatchEvent(new WorkboxEvent('waiting', {\n sw: waitingSW,\n wasWaitingBeforeRegister: true,\n }));\n if (process.env.NODE_ENV !== 'production') {\n logger.warn('A service worker was already waiting to activate ' +\n 'before this script was registered...');\n }\n }));\n }\n // If an \"own\" SW is already set, resolve the deferred.\n if (this._sw) {\n this._swDeferred.resolve(this._sw);\n this._ownSWs.add(this._sw);\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log('Successfully registered service worker.', this._scriptURL);\n if (navigator.serviceWorker.controller) {\n if (this._compatibleControllingSW) {\n logger.debug('A service worker with the same script URL ' +\n 'is already controlling this page.');\n }\n else {\n logger.debug('A service worker with a different script URL is ' +\n 'currently controlling the page. The browser is now fetching ' +\n 'the new script now...');\n }\n }\n const currentPageIsOutOfScope = () => {\n const scopeURL = new URL(this._registerOptions.scope || this._scriptURL, document.baseURI);\n const scopeURLBasePath = new URL('./', scopeURL.href).pathname;\n return !location.pathname.startsWith(scopeURLBasePath);\n };\n if (currentPageIsOutOfScope()) {\n logger.warn('The current page is not in scope for the registered ' +\n 'service worker. Was this a mistake?');\n }\n }\n this._registration.addEventListener('updatefound', this._onUpdateFound);\n navigator.serviceWorker.addEventListener('controllerchange', this._onControllerChange, { once: true });\n return this._registration;\n }\n /**\n * Checks for updates of the registered service worker.\n */\n async update() {\n if (!this._registration) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error('Cannot update a Workbox instance without ' +\n 'being registered. Register the Workbox instance first.');\n }\n return;\n }\n // Try to update registration\n await this._registration.update();\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is active. If a service worker was already controlling at registration\n * time then it will resolve to that if the script URLs (and optionally\n * script versions) match, otherwise it will wait until an update is found\n * and activates.\n *\n * @return {Promise<ServiceWorker>}\n */\n get active() {\n return this._activeDeferred.promise;\n }\n /**\n * Resolves to the service worker registered by this instance as soon as it\n * is controlling the page. If a service worker was already controlling at\n * registration time then it will resolve to that if the script URLs (and\n * optionally script versions) match, otherwise it will wait until an update\n * is found and starts controlling the page.\n * Note: the first time a service worker is installed it will active but\n * not start controlling the page unless `clients.claim()` is called in the\n * service worker.\n *\n * @return {Promise<ServiceWorker>}\n */\n get controlling() {\n return this._controllingDeferred.promise;\n }\n /**\n * Resolves with a reference to a service worker that matches the script URL\n * of this instance, as soon as it's available.\n *\n * If, at registration time, there's already an active or waiting service\n * worker with a matching script URL, it will be used (with the waiting\n * service worker taking precedence over the active service worker if both\n * match, since the waiting service worker would have been registered more\n * recently).\n * If there's no matching active or waiting service worker at registration\n * time then the promise will not resolve until an update is found and starts\n * installing, at which point the installing service worker is used.\n *\n * @return {Promise<ServiceWorker>}\n */\n async getSW() {\n // If `this._sw` is set, resolve with that as we want `getSW()` to\n // return the correct (new) service worker if an update is found.\n return this._sw !== undefined ? this._sw : this._swDeferred.promise;\n }\n /**\n * Sends the passed data object to the service worker registered by this\n * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves\n * with a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will never\n * resolve.\n *\n * @param {Object} data An object to send to the service worker\n * @return {Promise<Object>}\n */\n async messageSW(data) {\n const sw = await this.getSW();\n return messageSW(sw, data);\n }\n /**\n * Checks for a service worker already controlling the page and returns\n * it if its script URL matches.\n *\n * @private\n * @return {ServiceWorker|undefined}\n */\n _getControllingSWIfCompatible() {\n const controller = navigator.serviceWorker.controller;\n if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {\n return controller;\n }\n else {\n return undefined;\n }\n }\n /**\n * Registers a service worker for this instances script URL and register\n * options and tracks the time registration was complete.\n *\n * @private\n */\n async _registerScript() {\n try {\n const reg = await navigator.serviceWorker.register(this._scriptURL, this._registerOptions);\n // Keep track of when registration happened, so it can be used in the\n // `this._onUpdateFound` heuristic. Also use the presence of this\n // property as a way to see if `.register()` has been called.\n this._registrationTime = performance.now();\n return reg;\n }\n catch (error) {\n if (process.env.NODE_ENV !== 'production') {\n logger.error(error);\n }\n // Re-throw the error.\n throw error;\n }\n }\n}\nexport { Workbox };\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n/**\n * The `message` event is dispatched any time a `postMessage` is received.\n *\n * @event module:workbox-window.Workbox#message\n * @type {WorkboxEvent}\n * @property {*} data The `data` property from the original `message` event.\n * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}\n * event.\n * @property {string} type `message`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `installed` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed`.\n *\n * Then can happen either the very first time a service worker is installed,\n * or after an update to the current service worker is found. In the case\n * of an update being found, the event's `isUpdate` property will be `true`.\n *\n * @event module:workbox-window.Workbox#installed\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `installed`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `waiting` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `installed` and then doesn't immediately change to `activating`.\n * It may also be dispatched if a service worker with the same\n * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}\n * method was called.\n *\n * @event module:workbox-window.Workbox#waiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event|undefined} originalEvent The original\n * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event, or `undefined` in the case where the service worker was waiting\n * to before `.register()` was called.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with\n * a matching `scriptURL` was already waiting when this `Workbox`\n * instance called `register()`.\n * @property {string} type `waiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `controlling` event is dispatched if a\n * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}\n * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}\n * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}\n * matches the `scriptURL` of the `Workbox` instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.\n *\n * @event module:workbox-window.Workbox#controlling\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this service worker was registered.\n * @property {string} type `controlling`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `activated` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#activated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `activated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `redundant` event is dispatched if the state of a\n * [`Workbox`]{@link module:workbox-window.Workbox} instance's\n * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}\n * changes to `redundant`.\n *\n * @event module:workbox-window.Workbox#redundant\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {boolean|undefined} isUpdate True if a service worker was already\n * controlling when this `Workbox` instance called `register()`.\n * @property {string} type `redundant`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalinstalled` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `installed`.\n *\n * @event module:workbox-window.Workbox#externalinstalled\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalinstalled`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalwaiting` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `waiting`.\n *\n * @event module:workbox-window.Workbox#externalwaiting\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalwaiting`.\n * @property {Workbox} target The `Workbox` instance.\n */\n/**\n * The `externalactivated` event is dispatched if the state of an\n * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}\n * changes to `activated`.\n *\n * @event module:workbox-window.Workbox#externalactivated\n * @type {WorkboxEvent}\n * @property {ServiceWorker} sw The service worker instance.\n * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}\n * event.\n * @property {string} type `externalactivated`.\n * @property {Workbox} target The `Workbox` instance.\n */\n","/*\n Copyright 2019 Google LLC\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A helper function that prevents a promise from being flagged as unused.\n *\n * @private\n **/\nexport function dontWaitFor(promise) {\n // Effective no-op.\n promise.then(() => { });\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n/**\n * A minimal `EventTarget` shim.\n * This is necessary because not all browsers support constructable\n * `EventTarget`, so using a real `EventTarget` will error.\n * @private\n */\nexport class WorkboxEventTarget {\n constructor() {\n this._eventListenerRegistry = new Map();\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n const foo = this._getEventListenersByType(type);\n foo.add(listener);\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n removeEventListener(type, listener) {\n this._getEventListenersByType(type).delete(listener);\n }\n /**\n * @param {Object} event\n * @private\n */\n dispatchEvent(event) {\n event.target = this;\n const listeners = this._getEventListenersByType(event.type);\n for (const listener of listeners) {\n listener(event);\n }\n }\n /**\n * Returns a Set of listeners associated with the passed event type.\n * If no handlers have been registered, an empty Set is returned.\n *\n * @param {string} type The event type.\n * @return {Set<ListenerCallback>} An array of handler functions.\n * @private\n */\n _getEventListenersByType(type) {\n if (!this._eventListenerRegistry.has(type)) {\n this._eventListenerRegistry.set(type, new Set());\n }\n return this._eventListenerRegistry.get(type);\n }\n}\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","postMessage","port2","Deferred","promise","reject","_this","urlsMatch","url1","url2","href","location","URL","WorkboxEvent","type","props","Object","assign","this","_await","value","then","direct","WAITING_TIMEOUT_DURATION","_async","f","args","i","arguments","length","apply","REGISTRATION_TIMEOUT_DURATION","_empty","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_ownSWs","Set","_onUpdateFound","registration","_registration","installingSW","installing","_scriptURL","performance","now","_externalSW","removeEventListener","_sw","add","addEventListener","_onStateChange","originalEvent","target","state","isExternal","eventPrefix","eventProps","_isUpdate","isUpdate","dispatchEvent","_waitingTimeout","setTimeout","waiting","clearTimeout","_onControllerChange","navigator","serviceWorker","controller","_onMessage","source","getSW","has","register","immediate","body","result","document","readyState","res","window","Boolean","_compatibleControllingSW","_this2","_getControllingSWIfCompatible","_registerScript","once","waitingSW","wasWaitingBeforeRegister","update","undefined","recover","_this6","reg","error","_eventListenerRegistry","Map","listener","_getEventListenersByType","delete","set","get"],"mappings":"oMAEA,IACIA,KAAK,yBAA2BC,IAEpC,MAAOC,ICiBP,SAASC,EAAUC,EAAIC,UACZ,IAAIC,QAAQ,SAACC,OACZC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAY,SAACC,GAC9BL,EAAQK,EAAMP,OAElBD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,gLC1B7C,IACId,KAAK,uBAAyBC,IAElC,MAAOC,QCWDa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Bc,KAAKsB,EAAqBpC,2CExXzC,6BAEaiG,EAAyB,IAAIC,+BAOtC9C,iBAAA,SAAiB1C,EAAMyF,GACPrF,KAAKsF,EAAyB1F,GACtCyC,IAAIgD,MAOZlD,oBAAA,SAAoBvC,EAAMyF,QACjBC,EAAyB1F,GAAM2F,OAAOF,MAM/CrC,cAAA,SAAclE,GACVA,EAAM2D,OAASzC,WACGA,KAAKsF,EAAyBxG,EAAMc,8DACpB,uFACrBd,OAWjBwG,EAAA,SAAyB1F,UAChBI,KAAKmF,EAAuBvB,IAAIhE,SAC5BuF,EAAuBK,IAAI5F,EAAM,IAAI6B,KAEvCzB,KAAKmF,EAAuBM,IAAI7F,MA5C/C,IFkFO,WAAuBM,EAAOE,OAC/BA,SACGF,GAASA,EAAMC,KAAOD,EAAMC,QAAe3B,QAAQC"}
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-pwa-workbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7.alpha
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - souldanger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-20 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "A Jekyll plugin that makes your PWA / Website available offline and
14
14
  lets you install on desktop and mobile. \n\t\t\t\t\tIt generates and injects a precache
15
- list into a Workbox v5.0.0-alpha.1 service worker and handles the registration process
16
- in a secure way."
15
+ list into a Workbox v5.0.0 service worker and handles the registration process in
16
+ a secure way."
17
17
  email:
18
18
  - souldanger.industries@gmail.com
19
19
  executables: []
@@ -21,68 +21,68 @@ extensions: []
21
21
  extra_rdoc_files: []
22
22
  files:
23
23
  - lib/jekyll-pwa-workbox.rb
24
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js
25
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map
26
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js
27
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map
28
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js
29
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map
30
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js
31
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map
32
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js
33
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map
34
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js
35
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map
36
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js
37
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map
38
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js
39
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map
40
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js
41
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map
42
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js
43
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map
44
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js
45
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map
46
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js
47
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map
48
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js
49
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map
50
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js
51
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map
52
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js
53
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map
54
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js
55
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map
56
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js
57
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map
58
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js
59
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map
60
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js
61
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map
62
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js
63
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map
64
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js
65
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map
66
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js
67
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map
68
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js
69
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map
70
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js
71
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map
72
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js
73
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map
74
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs
75
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map
76
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs
77
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map
78
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js
79
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map
80
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs
81
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map
82
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs
83
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map
84
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js
85
- - lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map
24
+ - lib/vendor/workbox-v5.0.0/workbox-background-sync.dev.js
25
+ - lib/vendor/workbox-v5.0.0/workbox-background-sync.dev.js.map
26
+ - lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js
27
+ - lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js.map
28
+ - lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js
29
+ - lib/vendor/workbox-v5.0.0/workbox-broadcast-update.dev.js.map
30
+ - lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js
31
+ - lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js.map
32
+ - lib/vendor/workbox-v5.0.0/workbox-cacheable-response.dev.js
33
+ - lib/vendor/workbox-v5.0.0/workbox-cacheable-response.dev.js.map
34
+ - lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js
35
+ - lib/vendor/workbox-v5.0.0/workbox-cacheable-response.prod.js.map
36
+ - lib/vendor/workbox-v5.0.0/workbox-core.dev.js
37
+ - lib/vendor/workbox-v5.0.0/workbox-core.dev.js.map
38
+ - lib/vendor/workbox-v5.0.0/workbox-core.prod.js
39
+ - lib/vendor/workbox-v5.0.0/workbox-core.prod.js.map
40
+ - lib/vendor/workbox-v5.0.0/workbox-expiration.dev.js
41
+ - lib/vendor/workbox-v5.0.0/workbox-expiration.dev.js.map
42
+ - lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js
43
+ - lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js.map
44
+ - lib/vendor/workbox-v5.0.0/workbox-navigation-preload.dev.js
45
+ - lib/vendor/workbox-v5.0.0/workbox-navigation-preload.dev.js.map
46
+ - lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js
47
+ - lib/vendor/workbox-v5.0.0/workbox-navigation-preload.prod.js.map
48
+ - lib/vendor/workbox-v5.0.0/workbox-offline-ga.dev.js
49
+ - lib/vendor/workbox-v5.0.0/workbox-offline-ga.dev.js.map
50
+ - lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js
51
+ - lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js.map
52
+ - lib/vendor/workbox-v5.0.0/workbox-precaching.dev.js
53
+ - lib/vendor/workbox-v5.0.0/workbox-precaching.dev.js.map
54
+ - lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js
55
+ - lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js.map
56
+ - lib/vendor/workbox-v5.0.0/workbox-range-requests.dev.js
57
+ - lib/vendor/workbox-v5.0.0/workbox-range-requests.dev.js.map
58
+ - lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js
59
+ - lib/vendor/workbox-v5.0.0/workbox-range-requests.prod.js.map
60
+ - lib/vendor/workbox-v5.0.0/workbox-routing.dev.js
61
+ - lib/vendor/workbox-v5.0.0/workbox-routing.dev.js.map
62
+ - lib/vendor/workbox-v5.0.0/workbox-routing.prod.js
63
+ - lib/vendor/workbox-v5.0.0/workbox-routing.prod.js.map
64
+ - lib/vendor/workbox-v5.0.0/workbox-strategies.dev.js
65
+ - lib/vendor/workbox-v5.0.0/workbox-strategies.dev.js.map
66
+ - lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js
67
+ - lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js.map
68
+ - lib/vendor/workbox-v5.0.0/workbox-streams.dev.js
69
+ - lib/vendor/workbox-v5.0.0/workbox-streams.dev.js.map
70
+ - lib/vendor/workbox-v5.0.0/workbox-streams.prod.js
71
+ - lib/vendor/workbox-v5.0.0/workbox-streams.prod.js.map
72
+ - lib/vendor/workbox-v5.0.0/workbox-sw.js
73
+ - lib/vendor/workbox-v5.0.0/workbox-sw.js.map
74
+ - lib/vendor/workbox-v5.0.0/workbox-window.dev.es5.mjs
75
+ - lib/vendor/workbox-v5.0.0/workbox-window.dev.es5.mjs.map
76
+ - lib/vendor/workbox-v5.0.0/workbox-window.dev.mjs
77
+ - lib/vendor/workbox-v5.0.0/workbox-window.dev.mjs.map
78
+ - lib/vendor/workbox-v5.0.0/workbox-window.dev.umd.js
79
+ - lib/vendor/workbox-v5.0.0/workbox-window.dev.umd.js.map
80
+ - lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs
81
+ - lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs.map
82
+ - lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs
83
+ - lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs.map
84
+ - lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js
85
+ - lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js.map
86
86
  homepage: https://github.com/souldanger/jekyll-pwa-workbox
87
87
  licenses:
88
88
  - MIT
@@ -103,11 +103,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ">"
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
- version: 1.3.1
108
+ version: '0'
109
109
  requirements: []
110
- rubygems_version: 3.0.3
110
+ rubyforge_project:
111
+ rubygems_version: 2.7.6.2
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: PWA Workbox Service Worker for Jekyll.
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-background-sync.dev.js","sources":["../_version.js","../lib/QueueStore.js","../lib/StorableRequest.js","../Queue.js","../Plugin.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:background-sync:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { DBWrapper } from 'workbox-core/_private/DBWrapper.js';\nimport '../_version.js';\nconst DB_VERSION = 3;\nconst DB_NAME = 'workbox-background-sync';\nconst OBJECT_STORE_NAME = 'requests';\nconst INDEXED_PROP = 'queueName';\n/**\n * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\nexport class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {string} queueName\n * @private\n */\n constructor(queueName) {\n this._queueName = queueName;\n this._db = new DBWrapper(DB_NAME, DB_VERSION, {\n onupgradeneeded: this._upgradeDb,\n });\n }\n /**\n * Append an entry last in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async pushEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry.requestData',\n });\n }\n // Don't specify an ID since one is automatically generated.\n delete entry.id;\n entry.queueName = this._queueName;\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n /**\n * Preppend an entry first in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async unshiftEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry.requestData',\n });\n }\n const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n count: 1,\n });\n if (firstEntry) {\n // Pick an ID one less than the lowest ID in the object store.\n entry.id = firstEntry.id - 1;\n }\n else {\n // Otherwise let the auto-incrementor assign the ID.\n delete entry.id;\n }\n entry.queueName = this._queueName;\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n /**\n * Removes and returns the last entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async popEntry() {\n return this._removeEntry({ direction: 'prev' });\n }\n /**\n * Removes and returns the first entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async shiftEntry() {\n return this._removeEntry({ direction: 'next' });\n }\n /**\n * Returns all entries in the store matching the `queueName`.\n *\n * @param {Object} options See workbox.backgroundSync.Queue~getAll}\n * @return {Promise<Array<Object>>}\n * @private\n */\n async getAll() {\n return await this._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n });\n }\n /**\n * Deletes the entry for the given ID.\n *\n * WARNING: this method does not ensure the deleted enry belongs to this\n * queue (i.e. matches the `queueName`). But this limitation is acceptable\n * as this class is not publicly exposed. An additional check would make\n * this method slower than it needs to be.\n *\n * @private\n * @param {number} id\n */\n async deleteEntry(id) {\n await this._db.delete(OBJECT_STORE_NAME, id);\n }\n /**\n * Removes and returns the first or last entry in the queue (based on the\n * `direction` argument) matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async _removeEntry({ direction }) {\n const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n direction,\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n count: 1,\n });\n if (entry) {\n await this.deleteEntry(entry.id);\n return entry;\n }\n }\n /**\n * Upgrades the database given an `upgradeneeded` event.\n *\n * @param {Event} event\n * @private\n */\n _upgradeDb(event) {\n const db = event.target.result;\n if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {\n if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {\n db.deleteObjectStore(OBJECT_STORE_NAME);\n }\n }\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {\n autoIncrement: true,\n keyPath: 'id',\n });\n objStore.createIndex(INDEXED_PROP, INDEXED_PROP, { unique: false });\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\nconst serializableProperties = [\n 'method',\n 'referrer',\n 'referrerPolicy',\n 'mode',\n 'credentials',\n 'cache',\n 'redirect',\n 'integrity',\n 'keepalive',\n];\n/**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\nclass StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static async fromRequest(request) {\n const requestData = {\n url: request.url,\n headers: {},\n };\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use ArrayBuffer to support non-text request bodies.\n // NOTE: we can't use Blobs becuse Safari doesn't support storing\n // Blobs in IndexedDB in some cases:\n // https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457\n requestData.body = await request.clone().arrayBuffer();\n }\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestData.headers[key] = value;\n }\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestData[prop] = request[prop];\n }\n }\n return new StorableRequest(requestData);\n }\n /**\n * Accepts an object of request data that can be used to construct a\n * `Request` but can also be stored in IndexedDB.\n *\n * @param {Object} requestData An object of request data that includes the\n * `url` plus any relevant properties of\n * [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.\n * @private\n */\n constructor(requestData) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData',\n });\n assert.isType(requestData.url, 'string', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData.url',\n });\n }\n // If the request's mode is `navigate`, convert it to `same-origin` since\n // navigation requests can't be constructed via script.\n if (requestData.mode === 'navigate') {\n requestData.mode = 'same-origin';\n }\n this._requestData = requestData;\n }\n /**\n * Returns a deep clone of the instances `_requestData` object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n const requestData = Object.assign({}, this._requestData);\n requestData.headers = Object.assign({}, this._requestData.headers);\n if (requestData.body) {\n requestData.body = requestData.body.slice(0);\n }\n return requestData;\n }\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this._requestData.url, this._requestData);\n }\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n return new StorableRequest(this.toObject());\n }\n}\nexport { StorableRequest };\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { QueueStore } from './lib/QueueStore.js';\nimport { StorableRequest } from './lib/StorableRequest.js';\nimport './_version.js';\nconst TAG_PREFIX = 'workbox-background-sync';\nconst MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\nconst queueNames = new Set();\n/**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\nclass Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Function} [options.onSync] A function that gets invoked whenever\n * the 'sync' event fires. The function is invoked with an object\n * containing the `queue` property (referencing this instance), and you\n * can use the callback to customize the replay behavior of the queue.\n * When not set the `replayRequests()` method is called.\n * Note: if the replay fails after a sync event, make sure you throw an\n * error, so the browser knows to retry the sync event later.\n * @param {number} [options.maxRetentionTime=7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, { onSync, maxRetentionTime } = {}) {\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError('duplicate-queue-name', { name });\n }\n else {\n queueNames.add(name);\n }\n this._name = name;\n this._onSync = onSync || this.replayRequests;\n this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;\n this._queueStore = new QueueStore(this._name);\n this._addSyncListener();\n }\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the end of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async pushRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry.request',\n });\n }\n await this._addRequest(entry, 'push');\n }\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the beginning of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async unshiftRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry.request',\n });\n }\n await this._addRequest(entry, 'unshift');\n }\n /**\n * Removes and returns the last request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async popRequest() {\n return this._removeRequest('pop');\n }\n /**\n * Removes and returns the first request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async shiftRequest() {\n return this._removeRequest('shift');\n }\n /**\n * Returns all the entries that have not expired (per `maxRetentionTime`).\n * Any expired entries are removed from the queue.\n *\n * @return {Promise<Array<Object>>}\n */\n async getAll() {\n const allEntries = await this._queueStore.getAll();\n const now = Date.now();\n const unexpiredEntries = [];\n for (const entry of allEntries) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n await this._queueStore.deleteEntry(entry.id);\n }\n else {\n unexpiredEntries.push(convertEntry(entry));\n }\n }\n return unexpiredEntries;\n }\n /**\n * Adds the entry to the QueueStore and registers for a sync event.\n *\n * @param {Object} entry\n * @param {Request} entry.request\n * @param {Object} [entry.metadata]\n * @param {number} [entry.timestamp=Date.now()]\n * @param {string} operation ('push' or 'unshift')\n * @private\n */\n async _addRequest({ request, metadata, timestamp = Date.now(), }, operation) {\n const storableRequest = await StorableRequest.fromRequest(request.clone());\n const entry = {\n requestData: storableRequest.toObject(),\n timestamp,\n };\n // Only include metadata if it's present.\n if (metadata) {\n entry.metadata = metadata;\n }\n await this._queueStore[`${operation}Entry`](entry);\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(request.url)}' has ` +\n `been added to background sync queue '${this._name}'.`);\n }\n // Don't register for a sync if we're in the middle of a sync. Instead,\n // we wait until the sync is complete and call register if\n // `this._requestsAddedDuringSync` is true.\n if (this._syncInProgress) {\n this._requestsAddedDuringSync = true;\n }\n else {\n await this.registerSync();\n }\n }\n /**\n * Removes and returns the first or last (depending on `operation`) entry\n * from the QueueStore that's not older than the `maxRetentionTime`.\n *\n * @param {string} operation ('pop' or 'shift')\n * @return {Object|undefined}\n * @private\n */\n async _removeRequest(operation) {\n const now = Date.now();\n const entry = await this._queueStore[`${operation}Entry`]();\n if (entry) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n return this._removeRequest(operation);\n }\n return convertEntry(entry);\n }\n else {\n return undefined;\n }\n }\n /**\n * Loops through each request in the queue and attempts to re-fetch it.\n * If any request fails to re-fetch, it's put back in the same position in\n * the queue (which registers a retry for the next sync event).\n */\n async replayRequests() {\n let entry;\n while (entry = await this.shiftRequest()) {\n try {\n await fetch(entry.request.clone());\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `has been replayed in queue '${this._name}'`);\n }\n }\n catch (error) {\n await this.unshiftRequest(entry);\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `failed to replay, putting it back in queue '${this._name}'`);\n }\n throw new WorkboxError('queue-replay-failed', { name: this._name });\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All requests in queue '${this.name}' have successfully ` +\n `replayed; the queue is now empty!`);\n }\n }\n /**\n * Registers a sync event with a tag unique to this instance.\n */\n async registerSync() {\n if ('sync' in self.registration) {\n try {\n await self.registration.sync.register(`${TAG_PREFIX}:${this._name}`);\n }\n catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to register sync event for '${this._name}'.`, err);\n }\n }\n }\n }\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in self.registration) {\n self.addEventListener('sync', (event) => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync for tag '${event.tag}'` +\n `has been received`);\n }\n const syncComplete = async () => {\n this._syncInProgress = true;\n let syncError;\n try {\n await this._onSync({ queue: this });\n }\n catch (error) {\n syncError = error;\n // Rethrow the error. Note: the logic in the finally clause\n // will run before this gets rethrown.\n throw syncError;\n }\n finally {\n // New items may have been added to the queue during the sync,\n // so we need to register for a new sync if that's happened...\n // Unless there was an error during the sync, in which\n // case the browser will automatically retry later, as long\n // as `event.lastChance` is not true.\n if (this._requestsAddedDuringSync &&\n !(syncError && !event.lastChance)) {\n await this.registerSync();\n }\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n }\n };\n event.waitUntil(syncComplete());\n }\n });\n }\n else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this._onSync({ queue: this });\n }\n }\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n}\n/**\n * Converts a QueueStore entry into the format exposed by Queue. This entails\n * converting the request data into a real request and omitting the `id` and\n * `queueName` properties.\n *\n * @param {Object} queueStoreEntry\n * @return {Object}\n * @private\n */\nconst convertEntry = (queueStoreEntry) => {\n const queueEntry = {\n request: new StorableRequest(queueStoreEntry.requestData).toRequest(),\n timestamp: queueStoreEntry.timestamp,\n };\n if (queueStoreEntry.metadata) {\n queueEntry.metadata = queueStoreEntry.metadata;\n }\n return queueEntry;\n};\nexport { Queue };\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { Queue } from './Queue.js';\nimport './_version.js';\n/**\n * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\nclass Plugin {\n /**\n * @param {string} name See the [Queue]{@link workbox.backgroundSync.Queue}\n * documentation for parameter details.\n * @param {Object} [options] See the\n * [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(name, options) {\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n this.fetchDidFail = async ({ request }) => {\n await this._queue.pushRequest({ request });\n };\n this._queue = new Queue(name, options);\n }\n}\nexport { Plugin };\n"],"names":["self","_","e","DB_VERSION","DB_NAME","OBJECT_STORE_NAME","INDEXED_PROP","QueueStore","constructor","queueName","_queueName","_db","DBWrapper","onupgradeneeded","_upgradeDb","pushEntry","entry","assert","isType","moduleName","className","funcName","paramName","requestData","id","add","unshiftEntry","firstEntry","getAllMatching","count","popEntry","_removeEntry","direction","shiftEntry","getAll","index","query","IDBKeyRange","only","deleteEntry","delete","event","db","target","result","oldVersion","objectStoreNames","contains","deleteObjectStore","objStore","createObjectStore","autoIncrement","keyPath","createIndex","unique","serializableProperties","StorableRequest","fromRequest","request","url","headers","method","body","clone","arrayBuffer","key","value","entries","prop","undefined","mode","_requestData","toObject","Object","assign","slice","toRequest","Request","TAG_PREFIX","MAX_RETENTION_TIME","queueNames","Set","Queue","name","onSync","maxRetentionTime","_syncInProgress","_requestsAddedDuringSync","has","WorkboxError","_name","_onSync","replayRequests","_maxRetentionTime","_queueStore","_addSyncListener","pushRequest","isInstance","_addRequest","unshiftRequest","popRequest","_removeRequest","shiftRequest","allEntries","now","Date","unexpiredEntries","maxRetentionTimeInMs","timestamp","push","convertEntry","metadata","operation","storableRequest","logger","log","getFriendlyURL","registerSync","fetch","process","error","registration","sync","register","err","warn","addEventListener","tag","syncComplete","syncError","queue","lastChance","waitUntil","_queueNames","queueStoreEntry","queueEntry","Plugin","options","fetchDidFail","_queue"],"mappings":";;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,uCAAD,CAAJ,IAAiDC,CAAC,EAAlD;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IAGA,MAAMC,UAAU,GAAG,CAAnB;IACA,MAAMC,OAAO,GAAG,yBAAhB;IACA,MAAMC,iBAAiB,GAAG,UAA1B;IACA,MAAMC,YAAY,GAAG,WAArB;IACA;;;;;;;AAMA,IAAO,MAAMC,UAAN,CAAiB;IACpB;;;;;;;IAOAC,EAAAA,WAAW,CAACC,S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1
- this.workbox=this.workbox||{},this.workbox.backgroundSync=function(t,e,s,i,n){"use strict";try{self["workbox:background-sync:5.0.0-alpha.0"]&&_()}catch(t){}const a=3,r="workbox-background-sync",c="requests",h="queueName";class o{constructor(t){this.t=t,this.s=new n.DBWrapper(r,a,{onupgradeneeded:this.i})}async pushEntry(t){delete t.id,t.queueName=this.t,await this.s.add(c,t)}async unshiftEntry(t){const[e]=await this.s.getAllMatching(c,{count:1});e?t.id=e.id-1:delete t.id,t.queueName=this.t,await this.s.add(c,t)}async popEntry(){return this.h({direction:"prev"})}async shiftEntry(){return this.h({direction:"next"})}async getAll(){return await this.s.getAllMatching(c,{index:h,query:IDBKeyRange.only(this.t)})}async deleteEntry(t){await this.s.delete(c,t)}async h({direction:t}){const[e]=await this.s.getAllMatching(c,{direction:t,index:h,query:IDBKeyRange.only(this.t),count:1});if(e)return await this.deleteEntry(e.id),e}i(t){const e=t.target.result;t.oldVersion>0&&t.oldVersion<a&&e.objectStoreNames.contains(c)&&e.deleteObjectStore(c),e.createObjectStore(c,{autoIncrement:!0,keyPath:"id"}).createIndex(h,h,{unique:!1})}}const u=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class y{static async fromRequest(t){const e={url:t.url,headers:{}};"GET"!==t.method&&(e.body=await t.clone().arrayBuffer());for(const[s,i]of t.headers.entries())e.headers[s]=i;for(const s of u)void 0!==t[s]&&(e[s]=t[s]);return new y(e)}constructor(t){"navigate"===t.mode&&(t.mode="same-origin"),this.o=t}toObject(){const t=Object.assign({},this.o);return t.headers=Object.assign({},this.o.headers),t.body&&(t.body=t.body.slice(0)),t}toRequest(){return new Request(this.o.url,this.o)}clone(){return new y(this.toObject())}}const w="workbox-background-sync",f=10080,d=new Set;class l{constructor(t,{onSync:s,maxRetentionTime:i}={}){if(this.u=!1,this.l=!1,d.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});d.add(t),this.q=t,this.m=s||this.replayRequests,this.p=i||f,this.g=new o(this.q),this.R()}get name(){return this.q}async pushRequest(t){await this.k(t,"push")}async unshiftRequest(t){await this.k(t,"unshift")}async popRequest(){return this.D("pop")}async shiftRequest(){return this.D("shift")}async getAll(){const t=await this.g.getAll(),e=Date.now(),s=[];for(const i of t){const t=60*this.p*1e3;e-i.timestamp>t?await this.g.deleteEntry(i.id):s.push(q(i))}return s}async k({request:t,metadata:e,timestamp:s=Date.now()},i){const n={requestData:(await y.fromRequest(t.clone())).toObject(),timestamp:s};e&&(n.metadata=e),await this.g[`${i}Entry`](n),this.u?this.l=!0:await this.registerSync()}async D(t){const e=Date.now(),s=await this.g[`${t}Entry`]();if(s){const i=60*this.p*1e3;return e-s.timestamp>i?this.D(t):q(s)}}async replayRequests(){let t;for(;t=await this.shiftRequest();)try{await fetch(t.request.clone())}catch(s){throw await this.unshiftRequest(t),new e.WorkboxError("queue-replay-failed",{name:this.q})}}async registerSync(){if("sync"in self.registration)try{await self.registration.sync.register(`${w}:${this.q}`)}catch(t){}}R(){"sync"in self.registration?self.addEventListener("sync",t=>{if(t.tag===`${w}:${this.q}`){const e=async()=>{let e;this.u=!0;try{await this.m({queue:this})}catch(t){throw e=t}finally{!this.l||e&&!t.lastChance||await this.registerSync(),this.u=!1,this.l=!1}};t.waitUntil(e())}}):this.m({queue:this})}static get _(){return d}}const q=t=>{const e={request:new y(t.requestData).toRequest(),timestamp:t.timestamp};return t.metadata&&(e.metadata=t.metadata),e};return t.Plugin=class{constructor(t,e){this.fetchDidFail=(async({request:t})=>{await this.v.pushRequest({request:t})}),this.v=new l(t,e)}},t.Queue=l,t}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private);
2
- //# sourceMappingURL=workbox-background-sync.prod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workbox-background-sync.prod.js","sources":["../_version.js","../lib/QueueStore.js","../lib/StorableRequest.js","../Queue.js","../Plugin.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:background-sync:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { DBWrapper } from 'workbox-core/_private/DBWrapper.js';\nimport '../_version.js';\nconst DB_VERSION = 3;\nconst DB_NAME = 'workbox-background-sync';\nconst OBJECT_STORE_NAME = 'requests';\nconst INDEXED_PROP = 'queueName';\n/**\n * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\nexport class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {string} queueName\n * @private\n */\n constructor(queueName) {\n this._queueName = queueName;\n this._db = new DBWrapper(DB_NAME, DB_VERSION, {\n onupgradeneeded: this._upgradeDb,\n });\n }\n /**\n * Append an entry last in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async pushEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry.requestData',\n });\n }\n // Don't specify an ID since one is automatically generated.\n delete entry.id;\n entry.queueName = this._queueName;\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n /**\n * Preppend an entry first in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async unshiftEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry.requestData',\n });\n }\n const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n count: 1,\n });\n if (firstEntry) {\n // Pick an ID one less than the lowest ID in the object store.\n entry.id = firstEntry.id - 1;\n }\n else {\n // Otherwise let the auto-incrementor assign the ID.\n delete entry.id;\n }\n entry.queueName = this._queueName;\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n /**\n * Removes and returns the last entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async popEntry() {\n return this._removeEntry({ direction: 'prev' });\n }\n /**\n * Removes and returns the first entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async shiftEntry() {\n return this._removeEntry({ direction: 'next' });\n }\n /**\n * Returns all entries in the store matching the `queueName`.\n *\n * @param {Object} options See workbox.backgroundSync.Queue~getAll}\n * @return {Promise<Array<Object>>}\n * @private\n */\n async getAll() {\n return await this._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n });\n }\n /**\n * Deletes the entry for the given ID.\n *\n * WARNING: this method does not ensure the deleted enry belongs to this\n * queue (i.e. matches the `queueName`). But this limitation is acceptable\n * as this class is not publicly exposed. An additional check would make\n * this method slower than it needs to be.\n *\n * @private\n * @param {number} id\n */\n async deleteEntry(id) {\n await this._db.delete(OBJECT_STORE_NAME, id);\n }\n /**\n * Removes and returns the first or last entry in the queue (based on the\n * `direction` argument) matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async _removeEntry({ direction }) {\n const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n direction,\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n count: 1,\n });\n if (entry) {\n await this.deleteEntry(entry.id);\n return entry;\n }\n }\n /**\n * Upgrades the database given an `upgradeneeded` event.\n *\n * @param {Event} event\n * @private\n */\n _upgradeDb(event) {\n const db = event.target.result;\n if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {\n if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {\n db.deleteObjectStore(OBJECT_STORE_NAME);\n }\n }\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {\n autoIncrement: true,\n keyPath: 'id',\n });\n objStore.createIndex(INDEXED_PROP, INDEXED_PROP, { unique: false });\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { assert } from 'workbox-core/_private/assert.js';\nimport '../_version.js';\nconst serializableProperties = [\n 'method',\n 'referrer',\n 'referrerPolicy',\n 'mode',\n 'credentials',\n 'cache',\n 'redirect',\n 'integrity',\n 'keepalive',\n];\n/**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\nclass StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static async fromRequest(request) {\n const requestData = {\n url: request.url,\n headers: {},\n };\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use ArrayBuffer to support non-text request bodies.\n // NOTE: we can't use Blobs becuse Safari doesn't support storing\n // Blobs in IndexedDB in some cases:\n // https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457\n requestData.body = await request.clone().arrayBuffer();\n }\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestData.headers[key] = value;\n }\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestData[prop] = request[prop];\n }\n }\n return new StorableRequest(requestData);\n }\n /**\n * Accepts an object of request data that can be used to construct a\n * `Request` but can also be stored in IndexedDB.\n *\n * @param {Object} requestData An object of request data that includes the\n * `url` plus any relevant properties of\n * [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.\n * @private\n */\n constructor(requestData) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData',\n });\n assert.isType(requestData.url, 'string', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData.url',\n });\n }\n // If the request's mode is `navigate`, convert it to `same-origin` since\n // navigation requests can't be constructed via script.\n if (requestData.mode === 'navigate') {\n requestData.mode = 'same-origin';\n }\n this._requestData = requestData;\n }\n /**\n * Returns a deep clone of the instances `_requestData` object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n const requestData = Object.assign({}, this._requestData);\n requestData.headers = Object.assign({}, this._requestData.headers);\n if (requestData.body) {\n requestData.body = requestData.body.slice(0);\n }\n return requestData;\n }\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this._requestData.url, this._requestData);\n }\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n return new StorableRequest(this.toObject());\n }\n}\nexport { StorableRequest };\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { WorkboxError } from 'workbox-core/_private/WorkboxError.js';\nimport { logger } from 'workbox-core/_private/logger.js';\nimport { assert } from 'workbox-core/_private/assert.js';\nimport { getFriendlyURL } from 'workbox-core/_private/getFriendlyURL.js';\nimport { QueueStore } from './lib/QueueStore.js';\nimport { StorableRequest } from './lib/StorableRequest.js';\nimport './_version.js';\nconst TAG_PREFIX = 'workbox-background-sync';\nconst MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\nconst queueNames = new Set();\n/**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\nclass Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Function} [options.onSync] A function that gets invoked whenever\n * the 'sync' event fires. The function is invoked with an object\n * containing the `queue` property (referencing this instance), and you\n * can use the callback to customize the replay behavior of the queue.\n * When not set the `replayRequests()` method is called.\n * Note: if the replay fails after a sync event, make sure you throw an\n * error, so the browser knows to retry the sync event later.\n * @param {number} [options.maxRetentionTime=7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, { onSync, maxRetentionTime } = {}) {\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError('duplicate-queue-name', { name });\n }\n else {\n queueNames.add(name);\n }\n this._name = name;\n this._onSync = onSync || this.replayRequests;\n this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;\n this._queueStore = new QueueStore(this._name);\n this._addSyncListener();\n }\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the end of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async pushRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry.request',\n });\n }\n await this._addRequest(entry, 'push');\n }\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the beginning of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async unshiftRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry.request',\n });\n }\n await this._addRequest(entry, 'unshift');\n }\n /**\n * Removes and returns the last request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async popRequest() {\n return this._removeRequest('pop');\n }\n /**\n * Removes and returns the first request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async shiftRequest() {\n return this._removeRequest('shift');\n }\n /**\n * Returns all the entries that have not expired (per `maxRetentionTime`).\n * Any expired entries are removed from the queue.\n *\n * @return {Promise<Array<Object>>}\n */\n async getAll() {\n const allEntries = await this._queueStore.getAll();\n const now = Date.now();\n const unexpiredEntries = [];\n for (const entry of allEntries) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n await this._queueStore.deleteEntry(entry.id);\n }\n else {\n unexpiredEntries.push(convertEntry(entry));\n }\n }\n return unexpiredEntries;\n }\n /**\n * Adds the entry to the QueueStore and registers for a sync event.\n *\n * @param {Object} entry\n * @param {Request} entry.request\n * @param {Object} [entry.metadata]\n * @param {number} [entry.timestamp=Date.now()]\n * @param {string} operation ('push' or 'unshift')\n * @private\n */\n async _addRequest({ request, metadata, timestamp = Date.now(), }, operation) {\n const storableRequest = await StorableRequest.fromRequest(request.clone());\n const entry = {\n requestData: storableRequest.toObject(),\n timestamp,\n };\n // Only include metadata if it's present.\n if (metadata) {\n entry.metadata = metadata;\n }\n await this._queueStore[`${operation}Entry`](entry);\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(request.url)}' has ` +\n `been added to background sync queue '${this._name}'.`);\n }\n // Don't register for a sync if we're in the middle of a sync. Instead,\n // we wait until the sync is complete and call register if\n // `this._requestsAddedDuringSync` is true.\n if (this._syncInProgress) {\n this._requestsAddedDuringSync = true;\n }\n else {\n await this.registerSync();\n }\n }\n /**\n * Removes and returns the first or last (depending on `operation`) entry\n * from the QueueStore that's not older than the `maxRetentionTime`.\n *\n * @param {string} operation ('pop' or 'shift')\n * @return {Object|undefined}\n * @private\n */\n async _removeRequest(operation) {\n const now = Date.now();\n const entry = await this._queueStore[`${operation}Entry`]();\n if (entry) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n return this._removeRequest(operation);\n }\n return convertEntry(entry);\n }\n else {\n return undefined;\n }\n }\n /**\n * Loops through each request in the queue and attempts to re-fetch it.\n * If any request fails to re-fetch, it's put back in the same position in\n * the queue (which registers a retry for the next sync event).\n */\n async replayRequests() {\n let entry;\n while (entry = await this.shiftRequest()) {\n try {\n await fetch(entry.request.clone());\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `has been replayed in queue '${this._name}'`);\n }\n }\n catch (error) {\n await this.unshiftRequest(entry);\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `failed to replay, putting it back in queue '${this._name}'`);\n }\n throw new WorkboxError('queue-replay-failed', { name: this._name });\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All requests in queue '${this.name}' have successfully ` +\n `replayed; the queue is now empty!`);\n }\n }\n /**\n * Registers a sync event with a tag unique to this instance.\n */\n async registerSync() {\n if ('sync' in self.registration) {\n try {\n await self.registration.sync.register(`${TAG_PREFIX}:${this._name}`);\n }\n catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(`Unable to register sync event for '${this._name}'.`, err);\n }\n }\n }\n }\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in self.registration) {\n self.addEventListener('sync', (event) => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync for tag '${event.tag}'` +\n `has been received`);\n }\n const syncComplete = async () => {\n this._syncInProgress = true;\n let syncError;\n try {\n await this._onSync({ queue: this });\n }\n catch (error) {\n syncError = error;\n // Rethrow the error. Note: the logic in the finally clause\n // will run before this gets rethrown.\n throw syncError;\n }\n finally {\n // New items may have been added to the queue during the sync,\n // so we need to register for a new sync if that's happened...\n // Unless there was an error during the sync, in which\n // case the browser will automatically retry later, as long\n // as `event.lastChance` is not true.\n if (this._requestsAddedDuringSync &&\n !(syncError && !event.lastChance)) {\n await this.registerSync();\n }\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n }\n };\n event.waitUntil(syncComplete());\n }\n });\n }\n else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this._onSync({ queue: this });\n }\n }\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n}\n/**\n * Converts a QueueStore entry into the format exposed by Queue. This entails\n * converting the request data into a real request and omitting the `id` and\n * `queueName` properties.\n *\n * @param {Object} queueStoreEntry\n * @return {Object}\n * @private\n */\nconst convertEntry = (queueStoreEntry) => {\n const queueEntry = {\n request: new StorableRequest(queueStoreEntry.requestData).toRequest(),\n timestamp: queueStoreEntry.timestamp,\n };\n if (queueStoreEntry.metadata) {\n queueEntry.metadata = queueStoreEntry.metadata;\n }\n return queueEntry;\n};\nexport { Queue };\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { Queue } from './Queue.js';\nimport './_version.js';\n/**\n * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\nclass Plugin {\n /**\n * @param {string} name See the [Queue]{@link workbox.backgroundSync.Queue}\n * documentation for parameter details.\n * @param {Object} [options] See the\n * [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(name, options) {\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n this.fetchDidFail = async ({ request }) => {\n await this._queue.pushRequest({ request });\n };\n this._queue = new Queue(name, options);\n }\n}\nexport { Plugin };\n"],"names":["self","_","e","DB_VERSION","DB_NAME","OBJECT_STORE_NAME","INDEXED_PROP","QueueStore","constructor","queueName","_queueName","_db","DBWrapper","onupgradeneeded","this","_upgradeDb","entry","id","add","firstEntry","getAllMatching","count","_removeEntry","direction","index","query","IDBKeyRange","only","delete","deleteEntry","event","db","target","result","oldVersion","objectStoreNames","contains","deleteObjectStore","createObjectStore","autoIncrement","keyPath","createIndex","unique","serializableProperties","StorableRequest","request","requestData","url","headers","method","body","clone","arrayBuffer","key","value","entries","prop","undefined","mode","_requestData","toObject","Object","assign","slice","toRequest","Request","TAG_PREFIX","MAX_RETENTION_TIME","queueNames","Set","Queue","name","onSync","maxRetentionTime","_syncInProgress","_requestsAddedDuringSync","has","WorkboxError","_name","_onSync","replayRequests","_maxRetentionTime","_queueStore","_addSyncListener","_addRequest","_removeRequest","allEntries","getAll","now","Date","unexpiredEntries","maxRetentionTimeInMs","timestamp","push","convertEntry","metadata","operation","fromRequest","registerSync","shiftRequest","fetch","error","unshiftRequest","registration","sync","register","err","addEventListener","tag","syncComplete","async","syncError","queue","lastChance","waitUntil","queueStoreEntry","queueEntry","options","fetchDidFail","_queue","pushRequest"],"mappings":"2FACA,IACIA,KAAK,0CAA4CC,IAErD,MAAOC,ICMP,MAAMC,EAAa,EACbC,EAAU,0BACVC,EAAoB,WACpBC,EAAe,YAOd,MAAMC,EAQTC,YAAYC,QACHC,EAAaD,OACbE,EAAM,IAAIC,YAAUR,EAASD,EAAY,CAC1CU,gBAAiBC,KAAKC,oBAYdC,UAgBLA,EAAMC,GACbD,EAAMP,UAAYK,KAAKJ,QACjBI,KAAKH,EAAIO,IAAIb,EAAmBW,sBAWvBA,SAeRG,SAAoBL,KAAKH,EAAIS,eAAef,EAAmB,CAClEgB,MAAO,IAEPF,EAEAH,EAAMC,GAAKE,EAAWF,GAAK,SAIpBD,EAAMC,GAEjBD,EAAMP,UAAYK,KAAKJ,QACjBI,KAAKH,EAAIO,IAAIb,EAAmBW,2BAS/BF,KAAKQ,EAAa,CAAEC,UAAW,mCAS/BT,KAAKQ,EAAa,CAAEC,UAAW,qCAUzBT,KAAKH,EAAIS,eAAef,EAAmB,CACpDmB,MAAOlB,EACPmB,MAAOC,YAAYC,KAAKb,KAAKJ,uBAcnBO,SACRH,KAAKH,EAAIiB,OAAOvB,EAAm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F,GAKpB,IAAI6D,eAAa,sBAAuB,CAAEN,KAAMzD,KAAKgE,6BAY/D,SAAU9E,KAAKuG,uBAELvG,KAAKuG,aAAaC,KAAKC,YAAYvC,KAAcpD,KAAKgE,KAEhE,MAAO4B,KAgBfvB,IACQ,SAAUnF,KAAKuG,aACfvG,KAAK2G,iBAAiB,OAAS7E,OACvBA,EAAM8E,SAAW1C,KAAcpD,KAAKgE,IAAS,OAKvC+B,EAAeC,cAEbC,OADCrC,GAAkB,YAGb5D,KAAKiE,EAAQ,CAAEiC,MAAOlG,OAEhC,MAAOuF,SACHU,EAAYV,WAWRvF,KAAK6D,GACHoC,IAAcjF,EAAMmF,kBAChBnG,KAAKoF,oBAEVxB,GAAkB,OAClBC,GAA2B,IAGxC7C,EAAMoF,UAAUL,aAUnB9B,EAAQ,CAAEiC,MAAOlG,6BAYnBsD,GAYf,MAAM0B,EAAgBqB,UACZC,EAAa,CACfvE,QAAS,IAAID,EAAgBuE,EAAgBrE,aAAakB,YAC1D4B,UAAWuB,EAAgBvB,kBAE3BuB,EAAgBpB,WAChBqB,EAAWrB,SAAWoB,EAAgBpB,UAEnCqB,mBC5VX,MAQI5G,YAAY+D,EAAM8C,QAMTC,aAAeR,QAASjE,QAAAA,YACnB/B,KAAKyG,EAAOC,YAAY,CAAE3E,QAAAA,WAE/B0E,EAAS,IAAIjD,EAAMC,EAAM8C"}
@@ -1,486 +0,0 @@
1
- this.workbox = this.workbox || {};
2
- this.workbox.broadcastUpdate = (function (exports, assert_js, getFriendlyURL_js, logger_js, Deferred_js, WorkboxError_js) {
3
- 'use strict';
4
-
5
- // @ts-ignore
6
- try {
7
- self['workbox:broadcast-update:5.0.0-alpha.0'] && _();
8
- } catch (e) {}
9
-
10
- /*
11
- Copyright 2018 Google LLC
12
-
13
- Use of this source code is governed by an MIT-style
14
- license that can be found in the LICENSE file or at
15
- https://opensource.org/licenses/MIT.
16
- */
17
- /**
18
- * Given two `Response's`, compares several header values to see if they are
19
- * the same or not.
20
- *
21
- * @param {Response} firstResponse
22
- * @param {Response} secondResponse
23
- * @param {Array<string>} headersToCheck
24
- * @return {boolean}
25
- *
26
- * @memberof workbox.broadcastUpdate
27
- * @private
28
- */
29
-
30
- const responsesAreSame = (firstResponse, secondResponse, headersToCheck) => {
31
- {
32
- if (!(firstResponse instanceof Response && secondResponse instanceof Response)) {
33
- throw new WorkboxError_js.WorkboxError('invalid-responses-are-same-args');
34
- }
35
- }
36
-
37
- const atLeastOneHeaderAvailable = headersToCheck.some(header => {
38
- return firstResponse.headers.has(header) && secondResponse.headers.has(header);
39
- });
40
-
41
- if (!atLeastOneHeaderAvailable) {
42
- {
43
- logger_js.logger.warn(`Unable to determine where the response has been updated ` + `because none of the headers that would be checked are present.`);
44
- logger_js.logger.debug(`Attempting to compare the following: `, firstResponse, secondResponse, headersToCheck);
45
- } // Just return true, indicating the that responses are the same, since we
46
- // can't determine otherwise.
47
-
48
-
49
- return true;
50
- }
51
-
52
- return headersToCheck.every(header => {
53
- const headerStateComparison = firstResponse.headers.has(header) === secondResponse.headers.has(header);
54
- const headerValueComparison = firstResponse.headers.get(header) === secondResponse.headers.get(header);
55
- return headerStateComparison && headerValueComparison;
56
- });
57
- };
58
-
59
- /*
60
- Copyright 2018 Google LLC
61
-
62
- Use of this source code is governed by an MIT-style
63
- license that can be found in the LICENSE file or at
64
- https://opensource.org/licenses/MIT.
65
- */
66
- const CACHE_UPDATED_MESSAGE_TYPE = 'CACHE_UPDATED';
67
- const CACHE_UPDATED_MESSAGE_META = 'workbox-broadcast-update';
68
- const DEFAULT_BROADCAST_CHANNEL_NAME = 'workbox';
69
- const DEFAULT_DEFER_NOTIFICATION_TIMEOUT = 10000;
70
- const DEFAULT_HEADERS_TO_CHECK = ['content-length', 'etag', 'last-modified'];
71
-
72
- /*
73
- Copyright 2018 Google LLC
74
-
75
- Use of this source code is governed by an MIT-style
76
- license that can be found in the LICENSE file or at
77
- https://opensource.org/licenses/MIT.
78
- */
79
- /**
80
- * You would not normally call this method directly; it's called automatically
81
- * by an instance of the {@link BroadcastCacheUpdate} class. It's exposed here
82
- * for the benefit of developers who would rather not use the full
83
- * `BroadcastCacheUpdate` implementation.
84
- *
85
- * Calling this will dispatch a message on the provided
86
- * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel}
87
- * to notify interested subscribers about a change to a cached resource.
88
- *
89
- * The message that's posted has a formation inspired by the
90
- * [Flux standard action](https://github.com/acdlite/flux-standard-action#introduction)
91
- * format like so:
92
- *
93
- * ```
94
- * {
95
- * type: 'CACHE_UPDATED',
96
- * meta: 'workbox-broadcast-update',
97
- * payload: {
98
- * cacheName: 'the-cache-name',
99
- * updatedURL: 'https://example.com/'
100
- * }
101
- * }
102
- * ```
103
- *
104
- * (Usage of [Flux](https://facebook.github.io/flux/) itself is not at
105
- * all required.)
106
- *
107
- * @param {Object} options
108
- * @param {string} options.cacheName The name of the cache in which the updated
109
- * `Response` was stored.
110
- * @param {string} options.url The URL associated with the updated `Response`.
111
- * @param {BroadcastChannel} [options.channel] The `BroadcastChannel` to use.
112
- * If no channel is set or the browser doesn't support the BroadcastChannel
113
- * api, then an attempt will be made to `postMessage` each window client.
114
- *
115
- * @memberof workbox.broadcastUpdate
116
- */
117
-
118
- const broadcastUpdate = async ({
119
- channel,
120
- cacheName,
121
- url
122
- }) => {
123
- {
124
- assert_js.assert.isType(cacheName, 'string', {
125
- moduleName: 'workbox-broadcast-update',
126
- className: '~',
127
- funcName: 'broadcastUpdate',
128
- paramName: 'cacheName'
129
- });
130
- assert_js.assert.isType(url, 'string', {
131
- moduleName: 'workbox-broadcast-update',
132
- className: '~',
133
- funcName: 'broadcastUpdate',
134
- paramName: 'url'
135
- });
136
- }
137
-
138
- const data = {
139
- type: CACHE_UPDATED_MESSAGE_TYPE,
140
- meta: CACHE_UPDATED_MESSAGE_META,
141
- payload: {
142
- cacheName: cacheName,
143
- updatedURL: url
144
- }
145
- };
146
-
147
- if (channel) {
148
- channel.postMessage(data);
149
- } else {
150
- const windows = await self.clients.matchAll({
151
- type: 'window'
152
- });
153
-
154
- for (const win of windows) {
155
- win.postMessage(data);
156
- }
157
- }
158
- };
159
-
160
- /*
161
- Copyright 2018 Google LLC
162
-
163
- Use of this source code is governed by an MIT-style
164
- license that can be found in the LICENSE file or at
165
- https://opensource.org/licenses/MIT.
166
- */
167
- /**
168
- * Uses the [Broadcast Channel API]{@link https://developers.google.com/web/updates/2016/09/broadcastchannel}
169
- * to notify interested parties when a cached response has been updated.
170
- * In browsers that do not support the Broadcast Channel API, the instance
171
- * falls back to sending the update via `postMessage()` to all window clients.
172
- *
173
- * For efficiency's sake, the underlying response bodies are not compared;
174
- * only specific response headers are checked.
175
- *
176
- * @memberof workbox.broadcastUpdate
177
- */
178
-
179
- class BroadcastCacheUpdate {
180
- /**
181
- * Construct a BroadcastCacheUpdate instance with a specific `channelName` to
182
- * broadcast messages on
183
- *
184
- * @param {Object} options
185
- * @param {Array<string>}
186
- * [options.headersToCheck=['content-length', 'etag', 'last-modified']]
187
- * A list of headers that will be used to determine whether the responses
188
- * differ.
189
- * @param {string} [options.channelName='workbox'] The name that will be used
190
- *. when creating the `BroadcastChannel`, which defaults to 'workbox' (the
191
- * channel name used by the `workbox-window` package).
192
- * @param {string} [options.deferNoticationTimeout=10000] The amount of time
193
- * to wait for a ready message from the window on navigation requests
194
- * before sending the update.
195
- */
196
- constructor({
197
- headersToCheck,
198
- channelName,
199
- deferNoticationTimeout
200
- } = {}) {
201
- this._headersToCheck = headersToCheck || DEFAULT_HEADERS_TO_CHECK;
202
- this._channelName = channelName || DEFAULT_BROADCAST_CHANNEL_NAME;
203
- this._deferNoticationTimeout = deferNoticationTimeout || DEFAULT_DEFER_NOTIFICATION_TIMEOUT;
204
-
205
- {
206
- assert_js.assert.isType(this._channelName, 'string', {
207
- moduleName: 'workbox-broadcast-update',
208
- className: 'BroadcastCacheUpdate',
209
- funcName: 'constructor',
210
- paramName: 'channelName'
211
- });
212
- assert_js.assert.isArray(this._headersToCheck, {
213
- moduleName: 'workbox-broadcast-update',
214
- className: 'BroadcastCacheUpdate',
215
- funcName: 'constructor',
216
- paramName: 'headersToCheck'
217
- });
218
- }
219
-
220
- this._initWindowReadyDeferreds();
221
- }
222
- /**
223
- * Compare two [Responses](https://developer.mozilla.org/en-US/docs/Web/API/Response)
224
- * and send a message via the
225
- * {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel API}
226
- * if they differ.
227
- *
228
- * Neither of the Responses can be {@link http://stackoverflow.com/questions/39109789|opaque}.
229
- *
230
- * @param {Object} options
231
- * @param {Response} options.oldResponse Cached response to compare.
232
- * @param {Response} options.newResponse Possibly updated response to compare.
233
- * @param {string} options.url The URL of the request.
234
- * @param {string} options.cacheName Name of the cache the responses belong
235
- * to. This is included in the broadcast message.
236
- * @param {Event} [options.event] event An optional event that triggered
237
- * this possible cache update.
238
- * @return {Promise} Resolves once the update is sent.
239
- */
240
-
241
-
242
- notifyIfUpdated({
243
- oldResponse,
244
- newResponse,
245
- url,
246
- cacheName,
247
- event
248
- }) {
249
- if (!responsesAreSame(oldResponse, newResponse, this._headersToCheck)) {
250
- {
251
- logger_js.logger.log(`Newer response found (and cached) for:`, url);
252
- }
253
-
254
- const sendUpdate = async () => {
255
- // In the case of a navigation request, the requesting page will likely
256
- // not have loaded its JavaScript in time to recevied the update
257
- // notification, so we defer it until ready (or we timeout waiting).
258
- if (event && event.request && event.request.mode === 'navigate') {
259
- {
260
- logger_js.logger.debug(`Original request was a navigation request, ` + `waiting for a ready message from the window`, event.request);
261
- }
262
-
263
- await this._windowReadyOrTimeout(event);
264
- }
265
-
266
- await this._broadcastUpdate({
267
- channel: this._getChannel(),
268
- cacheName,
269
- url
270
- });
271
- }; // Send the update and ensure the SW stays alive until it's sent.
272
-
273
-
274
- const done = sendUpdate();
275
-
276
- if (event) {
277
- try {
278
- event.waitUntil(done);
279
- } catch (error) {
280
- {
281
- logger_js.logger.warn(`Unable to ensure service worker stays alive ` + `when broadcasting cache update for ` + `${getFriendlyURL_js.getFriendlyURL(event.request.url)}'.`);
282
- }
283
- }
284
- }
285
-
286
- return done;
287
- }
288
- }
289
- /**
290
- * NOTE: this is exposed on the instance primarily so it can be spied on
291
- * in tests.
292
- *
293
- * @param {Object} opts
294
- * @private
295
- */
296
-
297
-
298
- async _broadcastUpdate(opts) {
299
- await broadcastUpdate(opts);
300
- }
301
- /**
302
- * @return {BroadcastChannel|undefined} The BroadcastChannel instance used for
303
- * broadcasting updates, or undefined if the browser doesn't support the
304
- * Broadcast Channel API.
305
- *
306
- * @private
307
- */
308
-
309
-
310
- _getChannel() {
311
- if ('BroadcastChannel' in self && !this._channel) {
312
- this._channel = new BroadcastChannel(this._channelName);
313
- }
314
-
315
- return this._channel;
316
- }
317
- /**
318
- * Waits for a message from the window indicating that it's capable of
319
- * receiving broadcasts. By default, this will only wait for the amount of
320
- * time specified via the `deferNoticationTimeout` option.
321
- *
322
- * @param {Event} event The navigation fetch event.
323
- * @return {Promise}
324
- * @private
325
- */
326
-
327
-
328
- _windowReadyOrTimeout(event) {
329
- if (!this._navigationEventsDeferreds.has(event)) {
330
- const deferred = new Deferred_js.Deferred(); // Set the deferred on the `_navigationEventsDeferreds` map so it will
331
- // be resolved when the next ready message event comes.
332
-
333
- this._navigationEventsDeferreds.set(event, deferred); // But don't wait too long for the message since it may never come.
334
-
335
-
336
- const timeout = setTimeout(() => {
337
- {
338
- logger_js.logger.debug(`Timed out after ${this._deferNoticationTimeout}` + `ms waiting for message from window`);
339
- }
340
-
341
- deferred.resolve();
342
- }, this._deferNoticationTimeout); // Ensure the timeout is cleared if the deferred promise is resolved.
343
-
344
- deferred.promise.then(() => clearTimeout(timeout));
345
- }
346
-
347
- return this._navigationEventsDeferreds.get(event).promise;
348
- }
349
- /**
350
- * Creates a mapping between navigation fetch events and deferreds, and adds
351
- * a listener for message events from the window. When message events arrive,
352
- * all deferreds in the mapping are resolved.
353
- *
354
- * Note: it would be easier if we could only resolve the deferred of
355
- * navigation fetch event whose client ID matched the source ID of the
356
- * message event, but currently client IDs are not exposed on navigation
357
- * fetch events: https://www.chromestatus.com/feature/4846038800138240
358
- *
359
- * @private
360
- */
361
-
362
-
363
- _initWindowReadyDeferreds() {
364
- // A mapping between navigation events and their deferreds.
365
- this._navigationEventsDeferreds = new Map(); // The message listener needs to be added in the initial run of the
366
- // service worker, but since we don't actually need to be listening for
367
- // messages until the cache updates, we only invoke the callback if set.
368
-
369
- self.addEventListener('message', event => {
370
- if (event.data.type === 'WINDOW_READY' && event.data.meta === 'workbox-window' && this._navigationEventsDeferreds.size > 0) {
371
- {
372
- logger_js.logger.debug(`Received WINDOW_READY event: `, event);
373
- } // Resolve any pending deferreds.
374
-
375
-
376
- for (const deferred of this._navigationEventsDeferreds.values()) {
377
- deferred.resolve();
378
- }
379
-
380
- this._navigationEventsDeferreds.clear();
381
- }
382
- });
383
- }
384
-
385
- }
386
-
387
- /*
388
- Copyright 2018 Google LLC
389
-
390
- Use of this source code is governed by an MIT-style
391
- license that can be found in the LICENSE file or at
392
- https://opensource.org/licenses/MIT.
393
- */
394
- /**
395
- * This plugin will automatically broadcast a message whenever a cached response
396
- * is updated.
397
- *
398
- * @memberof workbox.broadcastUpdate
399
- */
400
-
401
- class Plugin {
402
- /**
403
- * Construct a BroadcastCacheUpdate instance with the passed options and
404
- * calls its `notifyIfUpdated()` method whenever the plugin's
405
- * `cacheDidUpdate` callback is invoked.
406
- *
407
- * @param {Object} options
408
- * @param {Array<string>}
409
- * [options.headersToCheck=['content-length', 'etag', 'last-modified']]
410
- * A list of headers that will be used to determine whether the responses
411
- * differ.
412
- * @param {string} [options.channelName='workbox'] The name that will be used
413
- *. when creating the `BroadcastChannel`, which defaults to 'workbox' (the
414
- * channel name used by the `workbox-window` package).
415
- * @param {string} [options.deferNoticationTimeout=10000] The amount of time
416
- * to wait for a ready message from the window on navigation requests
417
- * before sending the update.
418
- */
419
- constructor(options) {
420
- /**
421
- * A "lifecycle" callback that will be triggered automatically by the
422
- * `workbox-sw` and `workbox-runtime-caching` handlers when an entry is
423
- * added to a cache.
424
- *
425
- * @private
426
- * @param {Object} options The input object to this function.
427
- * @param {string} options.cacheName Name of the cache being updated.
428
- * @param {Response} [options.oldResponse] The previous cached value, if any.
429
- * @param {Response} options.newResponse The new value in the cache.
430
- * @param {Request} options.request The request that triggered the udpate.
431
- * @param {Request} [options.event] The event that triggered the update.
432
- */
433
- this.cacheDidUpdate = async ({
434
- cacheName,
435
- oldResponse,
436
- newResponse,
437
- request,
438
- event
439
- }) => {
440
- {
441
- assert_js.assert.isType(cacheName, 'string', {
442
- moduleName: 'workbox-broadcast-update',
443
- className: 'Plugin',
444
- funcName: 'cacheDidUpdate',
445
- paramName: 'cacheName'
446
- });
447
- assert_js.assert.isInstance(newResponse, Response, {
448
- moduleName: 'workbox-broadcast-update',
449
- className: 'Plugin',
450
- funcName: 'cacheDidUpdate',
451
- paramName: 'newResponse'
452
- });
453
- assert_js.assert.isInstance(request, Request, {
454
- moduleName: 'workbox-broadcast-update',
455
- className: 'Plugin',
456
- funcName: 'cacheDidUpdate',
457
- paramName: 'request'
458
- });
459
- } // Without a two responses there is nothing to compare.
460
-
461
-
462
- if (oldResponse) {
463
- this._broadcastUpdate.notifyIfUpdated({
464
- cacheName,
465
- oldResponse,
466
- newResponse,
467
- event,
468
- url: request.url
469
- });
470
- }
471
- };
472
-
473
- this._broadcastUpdate = new BroadcastCacheUpdate(options);
474
- }
475
-
476
- }
477
-
478
- exports.BroadcastCacheUpdate = BroadcastCacheUpdate;
479
- exports.Plugin = Plugin;
480
- exports.broadcastUpdate = broadcastUpdate;
481
- exports.responsesAreSame = responsesAreSame;
482
-
483
- return exports;
484
-
485
- }({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
486
- //# sourceMappingURL=workbox-broadcast-update.dev.js.map