jekyll-pwa-workbox 0.0.7 → 0.0.8

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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-pwa-workbox.rb +1 -1
  3. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-background-sync.dev.js +818 -818
  4. data/lib/vendor/workbox-v5.1.1/workbox-background-sync.dev.js.map +1 -0
  5. data/lib/vendor/workbox-v5.1.1/workbox-background-sync.prod.js +2 -0
  6. data/lib/vendor/workbox-v5.1.1/workbox-background-sync.prod.js.map +1 -0
  7. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-broadcast-update.dev.js +288 -288
  8. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-broadcast-update.dev.js.map +1 -1
  9. data/lib/vendor/workbox-v5.1.1/workbox-broadcast-update.prod.js +2 -0
  10. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-broadcast-update.prod.js.map +1 -1
  11. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.dev.js +191 -191
  12. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.dev.js.map +1 -1
  13. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.prod.js +2 -2
  14. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-cacheable-response.prod.js.map +1 -1
  15. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-core.dev.js +1880 -1882
  16. data/lib/vendor/workbox-v5.1.1/workbox-core.dev.js.map +1 -0
  17. data/lib/vendor/workbox-v5.1.1/workbox-core.prod.js +2 -0
  18. data/lib/vendor/workbox-v5.1.1/workbox-core.prod.js.map +1 -0
  19. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-expiration.dev.js +649 -651
  20. data/lib/vendor/workbox-v5.1.1/workbox-expiration.dev.js.map +1 -0
  21. data/lib/vendor/workbox-v5.1.1/workbox-expiration.prod.js +2 -0
  22. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-expiration.prod.js.map +1 -1
  23. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.dev.js +102 -102
  24. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.dev.js.map +1 -1
  25. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.prod.js +2 -2
  26. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-navigation-preload.prod.js.map +1 -1
  27. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-offline-ga.dev.js +235 -235
  28. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-offline-ga.dev.js.map +1 -1
  29. data/lib/vendor/workbox-v5.1.1/workbox-offline-ga.prod.js +2 -0
  30. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-offline-ga.prod.js.map +1 -1
  31. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-precaching.dev.js +1222 -1222
  32. data/lib/vendor/workbox-v5.1.1/workbox-precaching.dev.js.map +1 -0
  33. data/lib/vendor/workbox-v5.1.1/workbox-precaching.prod.js +2 -0
  34. data/lib/vendor/workbox-v5.1.1/workbox-precaching.prod.js.map +1 -0
  35. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.dev.js +262 -262
  36. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.dev.js.map +1 -1
  37. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.prod.js +2 -2
  38. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-range-requests.prod.js.map +1 -1
  39. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-routing.dev.js +923 -923
  40. data/lib/vendor/workbox-v5.1.1/workbox-routing.dev.js.map +1 -0
  41. data/lib/vendor/workbox-v5.1.1/workbox-routing.prod.js +2 -0
  42. data/lib/vendor/workbox-v5.1.1/workbox-routing.prod.js.map +1 -0
  43. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-strategies.dev.js +923 -923
  44. data/lib/vendor/workbox-v5.1.1/workbox-strategies.dev.js.map +1 -0
  45. data/lib/vendor/workbox-v5.1.1/workbox-strategies.prod.js +2 -0
  46. data/lib/vendor/workbox-v5.1.1/workbox-strategies.prod.js.map +1 -0
  47. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-streams.dev.js +318 -318
  48. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-streams.dev.js.map +1 -1
  49. data/lib/vendor/workbox-v5.1.1/workbox-streams.prod.js +2 -0
  50. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-streams.prod.js.map +1 -1
  51. data/lib/vendor/workbox-v5.1.1/workbox-sw.js +2 -0
  52. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-sw.js.map +1 -1
  53. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-window.dev.es5.mjs +1094 -1075
  54. data/lib/vendor/workbox-v5.1.1/workbox-window.dev.es5.mjs.map +1 -0
  55. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-window.dev.mjs +943 -943
  56. data/lib/vendor/workbox-v5.1.1/workbox-window.dev.mjs.map +1 -0
  57. data/lib/vendor/{workbox-v5.0.0 → workbox-v5.1.1}/workbox-window.dev.umd.js +1105 -1086
  58. data/lib/vendor/workbox-v5.1.1/workbox-window.dev.umd.js.map +1 -0
  59. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.es5.mjs +2 -0
  60. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.es5.mjs.map +1 -0
  61. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.mjs +2 -0
  62. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.mjs.map +1 -0
  63. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.umd.js +2 -0
  64. data/lib/vendor/workbox-v5.1.1/workbox-window.prod.umd.js.map +1 -0
  65. metadata +65 -65
  66. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.dev.js.map +0 -1
  67. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js +0 -2
  68. data/lib/vendor/workbox-v5.0.0/workbox-background-sync.prod.js.map +0 -1
  69. data/lib/vendor/workbox-v5.0.0/workbox-broadcast-update.prod.js +0 -2
  70. data/lib/vendor/workbox-v5.0.0/workbox-core.dev.js.map +0 -1
  71. data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js +0 -2
  72. data/lib/vendor/workbox-v5.0.0/workbox-core.prod.js.map +0 -1
  73. data/lib/vendor/workbox-v5.0.0/workbox-expiration.dev.js.map +0 -1
  74. data/lib/vendor/workbox-v5.0.0/workbox-expiration.prod.js +0 -2
  75. data/lib/vendor/workbox-v5.0.0/workbox-offline-ga.prod.js +0 -2
  76. data/lib/vendor/workbox-v5.0.0/workbox-precaching.dev.js.map +0 -1
  77. data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js +0 -2
  78. data/lib/vendor/workbox-v5.0.0/workbox-precaching.prod.js.map +0 -1
  79. data/lib/vendor/workbox-v5.0.0/workbox-routing.dev.js.map +0 -1
  80. data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js +0 -2
  81. data/lib/vendor/workbox-v5.0.0/workbox-routing.prod.js.map +0 -1
  82. data/lib/vendor/workbox-v5.0.0/workbox-strategies.dev.js.map +0 -1
  83. data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js +0 -2
  84. data/lib/vendor/workbox-v5.0.0/workbox-strategies.prod.js.map +0 -1
  85. data/lib/vendor/workbox-v5.0.0/workbox-streams.prod.js +0 -2
  86. data/lib/vendor/workbox-v5.0.0/workbox-sw.js +0 -2
  87. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.es5.mjs.map +0 -1
  88. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.mjs.map +0 -1
  89. data/lib/vendor/workbox-v5.0.0/workbox-window.dev.umd.js.map +0 -1
  90. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs +0 -2
  91. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.es5.mjs.map +0 -1
  92. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs +0 -2
  93. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.mjs.map +0 -1
  94. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js +0 -2
  95. data/lib/vendor/workbox-v5.0.0/workbox-window.prod.umd.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workbox-window.dev.mjs","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.1.1'] && _();\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 const messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (event) => {\n resolve(event.data);\n };\n sw.postMessage(data, [messageChannel.port2]);\n });\n}\nexport { messageSW };\n","\"use strict\";\n// @ts-ignore\ntry {\n self['workbox:core:5.1.1'] && _();\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 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 const 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","constructor","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","href","location","URL","WorkboxEvent","props","assign","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","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","startsWith","update","active","controlling","undefined","reg"],"mappings":"AAEA,IAAI;AACAA,EAAAA,IAAI,CAAC,sBAAD,CAAJ,IAAgCC,CAAC,EAAjC;AACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ACLV;;;;;;;AAOA,AACA;;;;;;;;;;;;;;;AAcA,SAASC,SAAT,CAAmBC,EAAnB,EAAuBC,IAAvB,EAA6B;AACzB,SAAO,IAAIC,OAAJ,CAAaC,OAAD,IAAa;AAC5B,UAAMC,cAAc,GAAG,IAAIC,cAAJ,EAAvB;;AACAD,IAAAA,cAAc,CAACE,KAAf,CAAqBC,SAArB,GAAkCC,KAAD,IAAW;AACxCL,MAAAA,OAAO,CAACK,KAAK,CAACP,IAAP,CAAP;AACH,KAFD;;AAGAD,IAAAA,EAAE,CAACS,WAAH,CAAeR,IAAf,EAAqB,CAACG,cAAc,CAACM,KAAhB,CAArB;AACH,GANM,CAAP;AAOH;;AC5BD,IAAI;AACAd,EAAAA,IAAI,CAAC,oBAAD,CAAJ,IAA8BC,CAAC,EAA/B;AACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ACLV;;;;;;;AAOA,AACA;;;;;;;;;AAQA,MAAMa,QAAN,CAAe;AACX;;;AAGAC,EAAAA,WAAW,GAAG;AACV,SAAKC,OAAL,GAAe,IAAIX,OAAJ,CAAY,CAACC,OAAD,EAAUW,MAAV,KAAqB;AAC5C,WAAKX,OAAL,GAAeA,OAAf;AACA,WAAKW,MAAL,GAAcA,MAAd;AACH,KAHc,CAAf;AAIH;;AATU;;AChBf;;;;;;AAMA,AACA;;;;;;AAKA,AAAO,SAASC,WAAT,CAAqBF,OAArB,EAA8B;AACjC;AACAA,EAAAA,OAAO,CAACG,IAAR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;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA;;;;;;;;;;;;;;;;;;;;AAmBA;;;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;AAaA;;;;;;;;;;;;;;;;"}
@@ -1,1086 +1,1105 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = global || self, factory(global.workbox = {}));
5
- }(this, function (exports) { 'use strict';
6
-
7
- try {
8
- self['workbox:window:5.0.0'] && _();
9
- } catch (e) {}
10
-
11
- /*
12
- Copyright 2019 Google LLC
13
-
14
- Use of this source code is governed by an MIT-style
15
- license that can be found in the LICENSE file or at
16
- https://opensource.org/licenses/MIT.
17
- */
18
- /**
19
- * Sends a data object to a service worker via `postMessage` and resolves with
20
- * a response (if any).
21
- *
22
- * A response can be set in a message handler in the service worker by
23
- * calling `event.ports[0].postMessage(...)`, which will resolve the promise
24
- * returned by `messageSW()`. If no response is set, the promise will not
25
- * resolve.
26
- *
27
- * @param {ServiceWorker} sw The service worker to send the message to.
28
- * @param {Object} data An object to send to the service worker.
29
- * @return {Promise<Object|undefined>}
30
- * @memberof module:workbox-window
31
- */
32
-
33
- function messageSW(sw, data) {
34
- return new Promise(function (resolve) {
35
- var messageChannel = new MessageChannel();
36
-
37
- messageChannel.port1.onmessage = function (event) {
38
- resolve(event.data);
39
- };
40
-
41
- sw.postMessage(data, [messageChannel.port2]);
42
- });
43
- }
44
-
45
- function _defineProperties(target, props) {
46
- for (var i = 0; i < props.length; i++) {
47
- var descriptor = props[i];
48
- descriptor.enumerable = descriptor.enumerable || false;
49
- descriptor.configurable = true;
50
- if ("value" in descriptor) descriptor.writable = true;
51
- Object.defineProperty(target, descriptor.key, descriptor);
52
- }
53
- }
54
-
55
- function _createClass(Constructor, protoProps, staticProps) {
56
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
57
- if (staticProps) _defineProperties(Constructor, staticProps);
58
- return Constructor;
59
- }
60
-
61
- function _inheritsLoose(subClass, superClass) {
62
- subClass.prototype = Object.create(superClass.prototype);
63
- subClass.prototype.constructor = subClass;
64
- subClass.__proto__ = superClass;
65
- }
66
-
67
- try {
68
- self['workbox:core:5.0.0'] && _();
69
- } catch (e) {}
70
-
71
- /*
72
- Copyright 2018 Google LLC
73
-
74
- Use of this source code is governed by an MIT-style
75
- license that can be found in the LICENSE file or at
76
- https://opensource.org/licenses/MIT.
77
- */
78
- /**
79
- * The Deferred class composes Promises in a way that allows for them to be
80
- * resolved or rejected from outside the constructor. In most cases promises
81
- * should be used directly, but Deferreds can be necessary when the logic to
82
- * resolve a promise must be separate.
83
- *
84
- * @private
85
- */
86
-
87
- var Deferred =
88
- /**
89
- * Creates a promise and exposes its resolve and reject functions as methods.
90
- */
91
- function Deferred() {
92
- var _this = this;
93
-
94
- this.promise = new Promise(function (resolve, reject) {
95
- _this.resolve = resolve;
96
- _this.reject = reject;
97
- });
98
- };
99
-
100
- /*
101
- Copyright 2019 Google LLC
102
- Use of this source code is governed by an MIT-style
103
- license that can be found in the LICENSE file or at
104
- https://opensource.org/licenses/MIT.
105
- */
106
- /**
107
- * A helper function that prevents a promise from being flagged as unused.
108
- *
109
- * @private
110
- **/
111
-
112
- function dontWaitFor(promise) {
113
- // Effective no-op.
114
- promise.then(function () {});
115
- }
116
-
117
- /*
118
- Copyright 2019 Google LLC
119
- Use of this source code is governed by an MIT-style
120
- license that can be found in the LICENSE file or at
121
- https://opensource.org/licenses/MIT.
122
- */
123
- var logger = function () {
124
- // Don't overwrite this value if it's already set.
125
- // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
126
- if (!('__WB_DISABLE_DEV_LOGS' in self)) {
127
- self.__WB_DISABLE_DEV_LOGS = false;
128
- }
129
-
130
- var inGroup = false;
131
- var methodToColorMap = {
132
- debug: "#7f8c8d",
133
- log: "#2ecc71",
134
- warn: "#f39c12",
135
- error: "#c0392b",
136
- groupCollapsed: "#3498db",
137
- groupEnd: null
138
- };
139
-
140
- var print = function print(method, args) {
141
- var _console2;
142
-
143
- if (self.__WB_DISABLE_DEV_LOGS) {
144
- return;
145
- }
146
-
147
- if (method === 'groupCollapsed') {
148
- // Safari doesn't print all console.groupCollapsed() arguments:
149
- // https://bugs.webkit.org/show_bug.cgi?id=182754
150
- if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
151
- var _console;
152
-
153
- (_console = console)[method].apply(_console, args);
154
-
155
- return;
156
- }
157
- }
158
-
159
- var styles = ["background: " + methodToColorMap[method], "border-radius: 0.5em", "color: white", "font-weight: bold", "padding: 2px 0.5em"]; // When in a group, the workbox prefix is not displayed.
160
-
161
- var logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
162
-
163
- (_console2 = console)[method].apply(_console2, logPrefix.concat(args));
164
-
165
- if (method === 'groupCollapsed') {
166
- inGroup = true;
167
- }
168
-
169
- if (method === 'groupEnd') {
170
- inGroup = false;
171
- }
172
- };
173
-
174
- var api = {};
175
- var loggerMethods = Object.keys(methodToColorMap);
176
-
177
- var _loop = function _loop() {
178
- var key = _loggerMethods[_i];
179
- var method = key;
180
-
181
- api[method] = function () {
182
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
183
- args[_key] = arguments[_key];
184
- }
185
-
186
- print(method, args);
187
- };
188
- };
189
-
190
- for (var _i = 0, _loggerMethods = loggerMethods; _i < _loggerMethods.length; _i++) {
191
- _loop();
192
- }
193
-
194
- return api;
195
- }();
196
-
197
- /*
198
- Copyright 2019 Google LLC
199
-
200
- Use of this source code is governed by an MIT-style
201
- license that can be found in the LICENSE file or at
202
- https://opensource.org/licenses/MIT.
203
- */
204
-
205
- /**
206
- * A minimal `EventTarget` shim.
207
- * This is necessary because not all browsers support constructable
208
- * `EventTarget`, so using a real `EventTarget` will error.
209
- * @private
210
- */
211
- var WorkboxEventTarget =
212
- /*#__PURE__*/
213
- function () {
214
- function WorkboxEventTarget() {
215
- this._eventListenerRegistry = new Map();
216
- }
217
- /**
218
- * @param {string} type
219
- * @param {Function} listener
220
- * @private
221
- */
222
-
223
-
224
- var _proto = WorkboxEventTarget.prototype;
225
-
226
- _proto.addEventListener = function addEventListener(type, listener) {
227
- var foo = this._getEventListenersByType(type);
228
-
229
- foo.add(listener);
230
- }
231
- /**
232
- * @param {string} type
233
- * @param {Function} listener
234
- * @private
235
- */
236
- ;
237
-
238
- _proto.removeEventListener = function removeEventListener(type, listener) {
239
- this._getEventListenersByType(type).delete(listener);
240
- }
241
- /**
242
- * @param {Object} event
243
- * @private
244
- */
245
- ;
246
-
247
- _proto.dispatchEvent = function dispatchEvent(event) {
248
- event.target = this;
249
-
250
- var listeners = this._getEventListenersByType(event.type);
251
-
252
- for (var _iterator = listeners, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
253
- var _ref;
254
-
255
- if (_isArray) {
256
- if (_i >= _iterator.length) break;
257
- _ref = _iterator[_i++];
258
- } else {
259
- _i = _iterator.next();
260
- if (_i.done) break;
261
- _ref = _i.value;
262
- }
263
-
264
- var listener = _ref;
265
- listener(event);
266
- }
267
- }
268
- /**
269
- * Returns a Set of listeners associated with the passed event type.
270
- * If no handlers have been registered, an empty Set is returned.
271
- *
272
- * @param {string} type The event type.
273
- * @return {Set<ListenerCallback>} An array of handler functions.
274
- * @private
275
- */
276
- ;
277
-
278
- _proto._getEventListenersByType = function _getEventListenersByType(type) {
279
- if (!this._eventListenerRegistry.has(type)) {
280
- this._eventListenerRegistry.set(type, new Set());
281
- }
282
-
283
- return this._eventListenerRegistry.get(type);
284
- };
285
-
286
- return WorkboxEventTarget;
287
- }();
288
-
289
- /*
290
- Copyright 2019 Google LLC
291
-
292
- Use of this source code is governed by an MIT-style
293
- license that can be found in the LICENSE file or at
294
- https://opensource.org/licenses/MIT.
295
- */
296
- /**
297
- * Returns true if two URLs have the same `.href` property. The URLS can be
298
- * relative, and if they are the current location href is used to resolve URLs.
299
- *
300
- * @private
301
- * @param {string} url1
302
- * @param {string} url2
303
- * @return {boolean}
304
- */
305
-
306
- function urlsMatch(url1, url2) {
307
- var _location = location,
308
- href = _location.href;
309
- return new URL(url1, href).href === new URL(url2, href).href;
310
- }
311
-
312
- /*
313
- Copyright 2019 Google LLC
314
-
315
- Use of this source code is governed by an MIT-style
316
- license that can be found in the LICENSE file or at
317
- https://opensource.org/licenses/MIT.
318
- */
319
- /**
320
- * A minimal `Event` subclass shim.
321
- * This doesn't *actually* subclass `Event` because not all browsers support
322
- * constructable `EventTarget`, and using a real `Event` will error.
323
- * @private
324
- */
325
-
326
- var WorkboxEvent = function WorkboxEvent(type, props) {
327
- this.type = type;
328
- Object.assign(this, props);
329
- };
330
-
331
- // `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
332
- // chosen, but it seems to avoid false positives in my testing.
333
-
334
- function _await(value, then, direct) {
335
- if (direct) {
336
- return then ? then(value) : value;
337
- }
338
-
339
- if (!value || !value.then) {
340
- value = Promise.resolve(value);
341
- }
342
-
343
- return then ? value.then(then) : value;
344
- }
345
-
346
- var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
347
- // that the registration didn't trigger an update.
348
-
349
- function _async(f) {
350
- return function () {
351
- for (var args = [], i = 0; i < arguments.length; i++) {
352
- args[i] = arguments[i];
353
- }
354
-
355
- try {
356
- return Promise.resolve(f.apply(this, args));
357
- } catch (e) {
358
- return Promise.reject(e);
359
- }
360
- };
361
- }
362
-
363
- var REGISTRATION_TIMEOUT_DURATION = 60000;
364
- /**
365
- * A class to aid in handling service worker registration, updates, and
366
- * reacting to service worker lifecycle events.
367
- *
368
- * @fires [message]{@link module:workbox-window.Workbox#message}
369
- * @fires [installed]{@link module:workbox-window.Workbox#installed}
370
- * @fires [waiting]{@link module:workbox-window.Workbox#waiting}
371
- * @fires [controlling]{@link module:workbox-window.Workbox#controlling}
372
- * @fires [activated]{@link module:workbox-window.Workbox#activated}
373
- * @fires [redundant]{@link module:workbox-window.Workbox#redundant}
374
- * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
375
- * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
376
- * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
377
- * @memberof module:workbox-window
378
- */
379
-
380
- function _empty() {}
381
-
382
- var Workbox =
383
- /*#__PURE__*/
384
- function (_WorkboxEventTarget) {
385
- _inheritsLoose(Workbox, _WorkboxEventTarget);
386
-
387
- /**
388
- * Creates a new Workbox instance with a script URL and service worker
389
- * options. The script URL and options are the same as those used when
390
- * calling `navigator.serviceWorker.register(scriptURL, options)`. See:
391
- * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
392
- *
393
- * @param {string} scriptURL The service worker script associated with this
394
- * instance.
395
- * @param {Object} [registerOptions] The service worker options associated
396
- * with this instance.
397
- */
398
- function Workbox(scriptURL, registerOptions) {
399
- var _this;
400
-
401
- if (registerOptions === void 0) {
402
- registerOptions = {};
403
- }
404
-
405
- _this = _WorkboxEventTarget.call(this) || this;
406
- _this._registerOptions = {};
407
- _this._updateFoundCount = 0; // Deferreds we can resolve later.
408
-
409
- _this._swDeferred = new Deferred();
410
- _this._activeDeferred = new Deferred();
411
- _this._controllingDeferred = new Deferred();
412
- _this._registrationTime = 0;
413
- _this._ownSWs = new Set();
414
- /**
415
- * @private
416
- */
417
-
418
- _this._onUpdateFound = function () {
419
- // `this._registration` will never be `undefined` after an update is found.
420
- var registration = _this._registration;
421
- var installingSW = registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
422
- // different from the current controlling SW's script URL, we know any
423
- // successful registration calls will trigger an `updatefound` event.
424
- // But if the registered script URL is the same as the current controlling
425
- // SW's script URL, we'll only get an `updatefound` event if the file
426
- // changed since it was last registered. This can be a problem if the user
427
- // opens up the same page in a different tab, and that page registers
428
- // a SW that triggers an update. It's a problem because this page has no
429
- // good way of knowing whether the `updatefound` event came from the SW
430
- // script it registered or from a registration attempt made by a newer
431
- // version of the page running in another tab.
432
- // To minimize the possibility of a false positive, we use the logic here:
433
-
434
- var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
435
- // add the `updatefound` event listener until the `register()` call, if
436
- // `_updateFoundCount` is > 0 then it means this method has already
437
- // been called, thus this SW must be external
438
- _this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
439
- // instance's script URL, we know it's definitely not from our
440
- // registration.
441
- !urlsMatch(installingSW.scriptURL, _this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
442
- // Any `updatefound` event that occurs long after our registration is
443
- // assumed to be external.
444
- performance.now() > _this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
445
- // triggered by this instance.
446
- true : false;
447
-
448
- if (updateLikelyTriggeredExternally) {
449
- _this._externalSW = installingSW;
450
- registration.removeEventListener('updatefound', _this._onUpdateFound);
451
- } else {
452
- // If the update was not triggered externally we know the installing
453
- // SW is the one we registered, so we set it.
454
- _this._sw = installingSW;
455
-
456
- _this._ownSWs.add(installingSW);
457
-
458
- _this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
459
- // callback for, but we do log messages for it in development.
460
-
461
-
462
- {
463
- if (navigator.serviceWorker.controller) {
464
- logger.log('Updated service worker found. Installing now...');
465
- } else {
466
- logger.log('Service worker is installing...');
467
- }
468
- }
469
- } // Increment the `updatefound` count, so future invocations of this
470
- // method can be sure they were triggered externally.
471
-
472
-
473
- ++_this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
474
- // triggered externally, since we have callbacks for both.
475
-
476
- installingSW.addEventListener('statechange', _this._onStateChange);
477
- };
478
- /**
479
- * @private
480
- * @param {Event} originalEvent
481
- */
482
-
483
-
484
- _this._onStateChange = function (originalEvent) {
485
- // `this._registration` will never be `undefined` after an update is found.
486
- var registration = _this._registration;
487
- var sw = originalEvent.target;
488
- var state = sw.state;
489
- var isExternal = sw === _this._externalSW;
490
- var eventPrefix = isExternal ? 'external' : '';
491
- var eventProps = {
492
- sw: sw,
493
- originalEvent: originalEvent
494
- };
495
-
496
- if (!isExternal && _this._isUpdate) {
497
- eventProps.isUpdate = true;
498
- }
499
-
500
- _this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
501
-
502
- if (state === 'installed') {
503
- // This timeout is used to ignore cases where the service worker calls
504
- // `skipWaiting()` in the install event, thus moving it directly in the
505
- // activating state. (Since all service workers *must* go through the
506
- // waiting phase, the only way to detect `skipWaiting()` called in the
507
- // install event is to observe that the time spent in the waiting phase
508
- // is very short.)
509
- // NOTE: we don't need separate timeouts for the own and external SWs
510
- // since they can't go through these phases at the same time.
511
- _this._waitingTimeout = self.setTimeout(function () {
512
- // Ensure the SW is still waiting (it may now be redundant).
513
- if (state === 'installed' && registration.waiting === sw) {
514
- _this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
515
-
516
- {
517
- if (isExternal) {
518
- logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
519
- } else {
520
- logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
521
- }
522
- }
523
- }
524
- }, WAITING_TIMEOUT_DURATION);
525
- } else if (state === 'activating') {
526
- clearTimeout(_this._waitingTimeout);
527
-
528
- if (!isExternal) {
529
- _this._activeDeferred.resolve(sw);
530
- }
531
- }
532
-
533
- {
534
- switch (state) {
535
- case 'installed':
536
- if (isExternal) {
537
- logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
538
- } else {
539
- logger.log('Registered service worker installed.');
540
- }
541
-
542
- break;
543
-
544
- case 'activated':
545
- if (isExternal) {
546
- logger.warn('An external service worker has activated.');
547
- } else {
548
- logger.log('Registered service worker activated.');
549
-
550
- if (sw !== navigator.serviceWorker.controller) {
551
- logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
552
- }
553
- }
554
-
555
- break;
556
-
557
- case 'redundant':
558
- if (sw === _this._compatibleControllingSW) {
559
- logger.log('Previously controlling service worker now redundant!');
560
- } else if (!isExternal) {
561
- logger.log('Registered service worker now redundant!');
562
- }
563
-
564
- break;
565
- }
566
- }
567
- };
568
- /**
569
- * @private
570
- * @param {Event} originalEvent
571
- */
572
-
573
-
574
- _this._onControllerChange = function (originalEvent) {
575
- var sw = _this._sw;
576
-
577
- if (sw === navigator.serviceWorker.controller) {
578
- _this.dispatchEvent(new WorkboxEvent('controlling', {
579
- sw: sw,
580
- originalEvent: originalEvent,
581
- isUpdate: _this._isUpdate
582
- }));
583
-
584
- {
585
- logger.log('Registered service worker now controlling this page.');
586
- }
587
-
588
- _this._controllingDeferred.resolve(sw);
589
- }
590
- };
591
- /**
592
- * @private
593
- * @param {Event} originalEvent
594
- */
595
-
596
-
597
- _this._onMessage = _async(function (originalEvent) {
598
- var data = originalEvent.data,
599
- source = originalEvent.source; // Wait until there's an "own" service worker. This is used to buffer
600
- // `message` events that may be received prior to calling `register()`.
601
-
602
- return _await(_this.getSW(), function () {
603
- if (_this._ownSWs.has(source)) {
604
- _this.dispatchEvent(new WorkboxEvent('message', {
605
- data: data,
606
- sw: source,
607
- originalEvent: originalEvent
608
- }));
609
- }
610
- }); // If the service worker that sent the message is in the list of own
611
- // service workers for this instance, dispatch a `message` event.
612
- // NOTE: we check for all previously owned service workers rather than
613
- // just the current one because some messages (e.g. cache updates) use
614
- // a timeout when sent and may be delayed long enough for a service worker
615
- // update to be found.
616
- });
617
- _this._scriptURL = scriptURL;
618
- _this._registerOptions = registerOptions; // Add a message listener immediately since messages received during
619
- // page load are buffered only until the DOMContentLoaded event:
620
- // https://github.com/GoogleChrome/workbox/issues/2202
621
-
622
- navigator.serviceWorker.addEventListener('message', _this._onMessage);
623
- return _this;
624
- }
625
- /**
626
- * Registers a service worker for this instances script URL and service
627
- * worker options. By default this method delays registration until after
628
- * the window has loaded.
629
- *
630
- * @param {Object} [options]
631
- * @param {Function} [options.immediate=false] Setting this to true will
632
- * register the service worker immediately, even if the window has
633
- * not loaded (not recommended).
634
- */
635
-
636
-
637
- var _proto = Workbox.prototype;
638
- _proto.register = _async(function (_temp) {
639
- var _this2 = this;
640
-
641
- var _ref = _temp === void 0 ? {} : _temp,
642
- _ref$immediate = _ref.immediate,
643
- immediate = _ref$immediate === void 0 ? false : _ref$immediate;
644
-
645
- {
646
- if (_this2._registrationTime) {
647
- logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
648
- return;
649
- }
650
- }
651
-
652
- return _invoke(function () {
653
- if (!immediate && document.readyState !== 'complete') {
654
- return _awaitIgnored(new Promise(function (res) {
655
- return window.addEventListener('load', res);
656
- }));
657
- }
658
- }, function () {
659
- // Set this flag to true if any service worker was controlling the page
660
- // at registration time.
661
- _this2._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
662
- // the page, and if that SW script (and version, if specified) matches this
663
- // instance's script.
664
-
665
- _this2._compatibleControllingSW = _this2._getControllingSWIfCompatible();
666
- return _await(_this2._registerScript(), function (_this2$_registerScrip) {
667
- _this2._registration = _this2$_registerScrip;
668
-
669
- // If we have a compatible controller, store the controller as the "own"
670
- // SW, resolve active/controlling deferreds and add necessary listeners.
671
- if (_this2._compatibleControllingSW) {
672
- _this2._sw = _this2._compatibleControllingSW;
673
-
674
- _this2._activeDeferred.resolve(_this2._compatibleControllingSW);
675
-
676
- _this2._controllingDeferred.resolve(_this2._compatibleControllingSW);
677
-
678
- _this2._compatibleControllingSW.addEventListener('statechange', _this2._onStateChange, {
679
- once: true
680
- });
681
- } // If there's a waiting service worker with a matching URL before the
682
- // `updatefound` event fires, it likely means that this site is open
683
- // in another tab, or the user refreshed the page (and thus the previous
684
- // page wasn't fully unloaded before this page started loading).
685
- // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
686
-
687
-
688
- var waitingSW = _this2._registration.waiting;
689
-
690
- if (waitingSW && urlsMatch(waitingSW.scriptURL, _this2._scriptURL)) {
691
- // Store the waiting SW as the "own" Sw, even if it means overwriting
692
- // a compatible controller.
693
- _this2._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
694
- // listener after awaiting `register()` will get this event.
695
-
696
- dontWaitFor(Promise.resolve().then(function () {
697
- _this2.dispatchEvent(new WorkboxEvent('waiting', {
698
- sw: waitingSW,
699
- wasWaitingBeforeRegister: true
700
- }));
701
-
702
- {
703
- logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
704
- }
705
- }));
706
- } // If an "own" SW is already set, resolve the deferred.
707
-
708
-
709
- if (_this2._sw) {
710
- _this2._swDeferred.resolve(_this2._sw);
711
-
712
- _this2._ownSWs.add(_this2._sw);
713
- }
714
-
715
- {
716
- logger.log('Successfully registered service worker.', _this2._scriptURL);
717
-
718
- if (navigator.serviceWorker.controller) {
719
- if (_this2._compatibleControllingSW) {
720
- logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
721
- } else {
722
- logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
723
- }
724
- }
725
-
726
- var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
727
- var scopeURL = new URL(_this2._registerOptions.scope || _this2._scriptURL, document.baseURI);
728
- var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
729
- return !location.pathname.startsWith(scopeURLBasePath);
730
- };
731
-
732
- if (currentPageIsOutOfScope()) {
733
- logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
734
- }
735
- }
736
-
737
- _this2._registration.addEventListener('updatefound', _this2._onUpdateFound);
738
-
739
- navigator.serviceWorker.addEventListener('controllerchange', _this2._onControllerChange, {
740
- once: true
741
- });
742
- return _this2._registration;
743
- });
744
- });
745
- })
746
- /**
747
- * Checks for updates of the registered service worker.
748
- */
749
- ;
750
- _proto.update = _async(function () {
751
- var _this3 = this;
752
-
753
- if (!_this3._registration) {
754
- {
755
- logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
756
- }
757
-
758
- return;
759
- } // Try to update registration
760
-
761
-
762
- return _awaitIgnored(_this3._registration.update());
763
- })
764
- /**
765
- * Resolves to the service worker registered by this instance as soon as it
766
- * is active. If a service worker was already controlling at registration
767
- * time then it will resolve to that if the script URLs (and optionally
768
- * script versions) match, otherwise it will wait until an update is found
769
- * and activates.
770
- *
771
- * @return {Promise<ServiceWorker>}
772
- */
773
- ;
774
-
775
- /**
776
- * Resolves with a reference to a service worker that matches the script URL
777
- * of this instance, as soon as it's available.
778
- *
779
- * If, at registration time, there's already an active or waiting service
780
- * worker with a matching script URL, it will be used (with the waiting
781
- * service worker taking precedence over the active service worker if both
782
- * match, since the waiting service worker would have been registered more
783
- * recently).
784
- * If there's no matching active or waiting service worker at registration
785
- * time then the promise will not resolve until an update is found and starts
786
- * installing, at which point the installing service worker is used.
787
- *
788
- * @return {Promise<ServiceWorker>}
789
- */
790
- _proto.getSW = _async(function () {
791
- var _this4 = this;
792
-
793
- // If `this._sw` is set, resolve with that as we want `getSW()` to
794
- // return the correct (new) service worker if an update is found.
795
- return _this4._sw !== undefined ? _this4._sw : _this4._swDeferred.promise;
796
- })
797
- /**
798
- * Sends the passed data object to the service worker registered by this
799
- * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
800
- * with a response (if any).
801
- *
802
- * A response can be set in a message handler in the service worker by
803
- * calling `event.ports[0].postMessage(...)`, which will resolve the promise
804
- * returned by `messageSW()`. If no response is set, the promise will never
805
- * resolve.
806
- *
807
- * @param {Object} data An object to send to the service worker
808
- * @return {Promise<Object>}
809
- */
810
- ;
811
- _proto.messageSW = _async(function (data) {
812
- var _this5 = this;
813
-
814
- return _await(_this5.getSW(), function (sw) {
815
- return messageSW(sw, data);
816
- });
817
- })
818
- /**
819
- * Checks for a service worker already controlling the page and returns
820
- * it if its script URL matches.
821
- *
822
- * @private
823
- * @return {ServiceWorker|undefined}
824
- */
825
- ;
826
-
827
- _proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
828
- var controller = navigator.serviceWorker.controller;
829
-
830
- if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
831
- return controller;
832
- } else {
833
- return undefined;
834
- }
835
- }
836
- /**
837
- * Registers a service worker for this instances script URL and register
838
- * options and tracks the time registration was complete.
839
- *
840
- * @private
841
- */
842
- ;
843
-
844
- _proto._registerScript = _async(function () {
845
- var _this6 = this;
846
-
847
- return _catch(function () {
848
- return _await(navigator.serviceWorker.register(_this6._scriptURL, _this6._registerOptions), function (reg) {
849
- // Keep track of when registration happened, so it can be used in the
850
- // `this._onUpdateFound` heuristic. Also use the presence of this
851
- // property as a way to see if `.register()` has been called.
852
- _this6._registrationTime = performance.now();
853
- return reg;
854
- });
855
- }, function (error) {
856
- {
857
- logger.error(error);
858
- } // Re-throw the error.
859
-
860
-
861
- throw error;
862
- });
863
- });
864
-
865
- _createClass(Workbox, [{
866
- key: "active",
867
- get: function get() {
868
- return this._activeDeferred.promise;
869
- }
870
- /**
871
- * Resolves to the service worker registered by this instance as soon as it
872
- * is controlling the page. If a service worker was already controlling at
873
- * registration time then it will resolve to that if the script URLs (and
874
- * optionally script versions) match, otherwise it will wait until an update
875
- * is found and starts controlling the page.
876
- * Note: the first time a service worker is installed it will active but
877
- * not start controlling the page unless `clients.claim()` is called in the
878
- * service worker.
879
- *
880
- * @return {Promise<ServiceWorker>}
881
- */
882
-
883
- }, {
884
- key: "controlling",
885
- get: function get() {
886
- return this._controllingDeferred.promise;
887
- }
888
- }]);
889
-
890
- return Workbox;
891
- }(WorkboxEventTarget);
892
-
893
- function _awaitIgnored(value, direct) {
894
- if (!direct) {
895
- return value && value.then ? value.then(_empty) : Promise.resolve();
896
- }
897
- } // The jsdoc comments below outline the events this instance may dispatch:
898
- // -----------------------------------------------------------------------
899
-
900
- /**
901
- * The `message` event is dispatched any time a `postMessage` is received.
902
- *
903
- * @event module:workbox-window.Workbox#message
904
- * @type {WorkboxEvent}
905
- * @property {*} data The `data` property from the original `message` event.
906
- * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}
907
- * event.
908
- * @property {string} type `message`.
909
- * @property {Workbox} target The `Workbox` instance.
910
- */
911
-
912
- /**
913
- * The `installed` event is dispatched if the state of a
914
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
915
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
916
- * changes to `installed`.
917
- *
918
- * Then can happen either the very first time a service worker is installed,
919
- * or after an update to the current service worker is found. In the case
920
- * of an update being found, the event's `isUpdate` property will be `true`.
921
- *
922
- * @event module:workbox-window.Workbox#installed
923
- * @type {WorkboxEvent}
924
- * @property {ServiceWorker} sw The service worker instance.
925
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
926
- * event.
927
- * @property {boolean|undefined} isUpdate True if a service worker was already
928
- * controlling when this `Workbox` instance called `register()`.
929
- * @property {string} type `installed`.
930
- * @property {Workbox} target The `Workbox` instance.
931
- */
932
-
933
- /**
934
- * The `waiting` event is dispatched if the state of a
935
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
936
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
937
- * changes to `installed` and then doesn't immediately change to `activating`.
938
- * It may also be dispatched if a service worker with the same
939
- * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
940
- * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}
941
- * method was called.
942
- *
943
- * @event module:workbox-window.Workbox#waiting
944
- * @type {WorkboxEvent}
945
- * @property {ServiceWorker} sw The service worker instance.
946
- * @property {Event|undefined} originalEvent The original
947
- * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
948
- * event, or `undefined` in the case where the service worker was waiting
949
- * to before `.register()` was called.
950
- * @property {boolean|undefined} isUpdate True if a service worker was already
951
- * controlling when this `Workbox` instance called `register()`.
952
- * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with
953
- * a matching `scriptURL` was already waiting when this `Workbox`
954
- * instance called `register()`.
955
- * @property {string} type `waiting`.
956
- * @property {Workbox} target The `Workbox` instance.
957
- */
958
-
959
- /**
960
- * The `controlling` event is dispatched if a
961
- * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
962
- * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}
963
- * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
964
- * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}
965
- * matches the `scriptURL` of the `Workbox` instance's
966
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.
967
- *
968
- * @event module:workbox-window.Workbox#controlling
969
- * @type {WorkboxEvent}
970
- * @property {ServiceWorker} sw The service worker instance.
971
- * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
972
- * event.
973
- * @property {boolean|undefined} isUpdate True if a service worker was already
974
- * controlling when this service worker was registered.
975
- * @property {string} type `controlling`.
976
- * @property {Workbox} target The `Workbox` instance.
977
- */
978
-
979
- /**
980
- * The `activated` event is dispatched if the state of a
981
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
982
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
983
- * changes to `activated`.
984
- *
985
- * @event module:workbox-window.Workbox#activated
986
- * @type {WorkboxEvent}
987
- * @property {ServiceWorker} sw The service worker instance.
988
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
989
- * event.
990
- * @property {boolean|undefined} isUpdate True if a service worker was already
991
- * controlling when this `Workbox` instance called `register()`.
992
- * @property {string} type `activated`.
993
- * @property {Workbox} target The `Workbox` instance.
994
- */
995
-
996
- /**
997
- * The `redundant` event is dispatched if the state of a
998
- * [`Workbox`]{@link module:workbox-window.Workbox} instance's
999
- * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
1000
- * changes to `redundant`.
1001
- *
1002
- * @event module:workbox-window.Workbox#redundant
1003
- * @type {WorkboxEvent}
1004
- * @property {ServiceWorker} sw The service worker instance.
1005
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1006
- * event.
1007
- * @property {boolean|undefined} isUpdate True if a service worker was already
1008
- * controlling when this `Workbox` instance called `register()`.
1009
- * @property {string} type `redundant`.
1010
- * @property {Workbox} target The `Workbox` instance.
1011
- */
1012
-
1013
- /**
1014
- * The `externalinstalled` event is dispatched if the state of an
1015
- * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1016
- * changes to `installed`.
1017
- *
1018
- * @event module:workbox-window.Workbox#externalinstalled
1019
- * @type {WorkboxEvent}
1020
- * @property {ServiceWorker} sw The service worker instance.
1021
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1022
- * event.
1023
- * @property {string} type `externalinstalled`.
1024
- * @property {Workbox} target The `Workbox` instance.
1025
- */
1026
-
1027
- /**
1028
- * The `externalwaiting` event is dispatched if the state of an
1029
- * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1030
- * changes to `waiting`.
1031
- *
1032
- * @event module:workbox-window.Workbox#externalwaiting
1033
- * @type {WorkboxEvent}
1034
- * @property {ServiceWorker} sw The service worker instance.
1035
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1036
- * event.
1037
- * @property {string} type `externalwaiting`.
1038
- * @property {Workbox} target The `Workbox` instance.
1039
- */
1040
-
1041
- /**
1042
- * The `externalactivated` event is dispatched if the state of an
1043
- * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1044
- * changes to `activated`.
1045
- *
1046
- * @event module:workbox-window.Workbox#externalactivated
1047
- * @type {WorkboxEvent}
1048
- * @property {ServiceWorker} sw The service worker instance.
1049
- * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1050
- * event.
1051
- * @property {string} type `externalactivated`.
1052
- * @property {Workbox} target The `Workbox` instance.
1053
- */
1054
-
1055
-
1056
- function _invoke(body, then) {
1057
- var result = body();
1058
-
1059
- if (result && result.then) {
1060
- return result.then(then);
1061
- }
1062
-
1063
- return then(result);
1064
- }
1065
-
1066
- function _catch(body, recover) {
1067
- try {
1068
- var result = body();
1069
- } catch (e) {
1070
- return recover(e);
1071
- }
1072
-
1073
- if (result && result.then) {
1074
- return result.then(void 0, recover);
1075
- }
1076
-
1077
- return result;
1078
- }
1079
-
1080
- exports.Workbox = Workbox;
1081
- exports.messageSW = messageSW;
1082
-
1083
- Object.defineProperty(exports, '__esModule', { value: true });
1084
-
1085
- }));
1086
- //# sourceMappingURL=workbox-window.dev.umd.js.map
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = global || self, factory(global.workbox = {}));
5
+ }(this, (function (exports) { 'use strict';
6
+
7
+ try {
8
+ self['workbox:window:5.1.1'] && _();
9
+ } catch (e) {}
10
+
11
+ /*
12
+ Copyright 2019 Google LLC
13
+
14
+ Use of this source code is governed by an MIT-style
15
+ license that can be found in the LICENSE file or at
16
+ https://opensource.org/licenses/MIT.
17
+ */
18
+ /**
19
+ * Sends a data object to a service worker via `postMessage` and resolves with
20
+ * a response (if any).
21
+ *
22
+ * A response can be set in a message handler in the service worker by
23
+ * calling `event.ports[0].postMessage(...)`, which will resolve the promise
24
+ * returned by `messageSW()`. If no response is set, the promise will not
25
+ * resolve.
26
+ *
27
+ * @param {ServiceWorker} sw The service worker to send the message to.
28
+ * @param {Object} data An object to send to the service worker.
29
+ * @return {Promise<Object|undefined>}
30
+ * @memberof module:workbox-window
31
+ */
32
+
33
+ function messageSW(sw, data) {
34
+ return new Promise(function (resolve) {
35
+ var messageChannel = new MessageChannel();
36
+
37
+ messageChannel.port1.onmessage = function (event) {
38
+ resolve(event.data);
39
+ };
40
+
41
+ sw.postMessage(data, [messageChannel.port2]);
42
+ });
43
+ }
44
+
45
+ function _defineProperties(target, props) {
46
+ for (var i = 0; i < props.length; i++) {
47
+ var descriptor = props[i];
48
+ descriptor.enumerable = descriptor.enumerable || false;
49
+ descriptor.configurable = true;
50
+ if ("value" in descriptor) descriptor.writable = true;
51
+ Object.defineProperty(target, descriptor.key, descriptor);
52
+ }
53
+ }
54
+
55
+ function _createClass(Constructor, protoProps, staticProps) {
56
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
57
+ if (staticProps) _defineProperties(Constructor, staticProps);
58
+ return Constructor;
59
+ }
60
+
61
+ function _inheritsLoose(subClass, superClass) {
62
+ subClass.prototype = Object.create(superClass.prototype);
63
+ subClass.prototype.constructor = subClass;
64
+ subClass.__proto__ = superClass;
65
+ }
66
+
67
+ try {
68
+ self['workbox:core:5.1.1'] && _();
69
+ } catch (e) {}
70
+
71
+ /*
72
+ Copyright 2018 Google LLC
73
+
74
+ Use of this source code is governed by an MIT-style
75
+ license that can be found in the LICENSE file or at
76
+ https://opensource.org/licenses/MIT.
77
+ */
78
+ /**
79
+ * The Deferred class composes Promises in a way that allows for them to be
80
+ * resolved or rejected from outside the constructor. In most cases promises
81
+ * should be used directly, but Deferreds can be necessary when the logic to
82
+ * resolve a promise must be separate.
83
+ *
84
+ * @private
85
+ */
86
+
87
+ var Deferred =
88
+ /**
89
+ * Creates a promise and exposes its resolve and reject functions as methods.
90
+ */
91
+ function Deferred() {
92
+ var _this = this;
93
+
94
+ this.promise = new Promise(function (resolve, reject) {
95
+ _this.resolve = resolve;
96
+ _this.reject = reject;
97
+ });
98
+ };
99
+
100
+ /*
101
+ Copyright 2019 Google LLC
102
+ Use of this source code is governed by an MIT-style
103
+ license that can be found in the LICENSE file or at
104
+ https://opensource.org/licenses/MIT.
105
+ */
106
+ /**
107
+ * A helper function that prevents a promise from being flagged as unused.
108
+ *
109
+ * @private
110
+ **/
111
+
112
+ function dontWaitFor(promise) {
113
+ // Effective no-op.
114
+ promise.then(function () {});
115
+ }
116
+
117
+ /*
118
+ Copyright 2019 Google LLC
119
+ Use of this source code is governed by an MIT-style
120
+ license that can be found in the LICENSE file or at
121
+ https://opensource.org/licenses/MIT.
122
+ */
123
+ var logger = function () {
124
+ // Don't overwrite this value if it's already set.
125
+ // See https://github.com/GoogleChrome/workbox/pull/2284#issuecomment-560470923
126
+ if (!('__WB_DISABLE_DEV_LOGS' in self)) {
127
+ self.__WB_DISABLE_DEV_LOGS = false;
128
+ }
129
+
130
+ var inGroup = false;
131
+ var methodToColorMap = {
132
+ debug: "#7f8c8d",
133
+ log: "#2ecc71",
134
+ warn: "#f39c12",
135
+ error: "#c0392b",
136
+ groupCollapsed: "#3498db",
137
+ groupEnd: null
138
+ };
139
+
140
+ var print = function print(method, args) {
141
+ var _console2;
142
+
143
+ if (self.__WB_DISABLE_DEV_LOGS) {
144
+ return;
145
+ }
146
+
147
+ if (method === 'groupCollapsed') {
148
+ // Safari doesn't print all console.groupCollapsed() arguments:
149
+ // https://bugs.webkit.org/show_bug.cgi?id=182754
150
+ if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
151
+ var _console;
152
+
153
+ (_console = console)[method].apply(_console, args);
154
+
155
+ return;
156
+ }
157
+ }
158
+
159
+ var styles = ["background: " + methodToColorMap[method], "border-radius: 0.5em", "color: white", "font-weight: bold", "padding: 2px 0.5em"]; // When in a group, the workbox prefix is not displayed.
160
+
161
+ var logPrefix = inGroup ? [] : ['%cworkbox', styles.join(';')];
162
+
163
+ (_console2 = console)[method].apply(_console2, logPrefix.concat(args));
164
+
165
+ if (method === 'groupCollapsed') {
166
+ inGroup = true;
167
+ }
168
+
169
+ if (method === 'groupEnd') {
170
+ inGroup = false;
171
+ }
172
+ };
173
+
174
+ var api = {};
175
+ var loggerMethods = Object.keys(methodToColorMap);
176
+
177
+ var _loop = function _loop() {
178
+ var key = _loggerMethods[_i];
179
+ var method = key;
180
+
181
+ api[method] = function () {
182
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
183
+ args[_key] = arguments[_key];
184
+ }
185
+
186
+ print(method, args);
187
+ };
188
+ };
189
+
190
+ for (var _i = 0, _loggerMethods = loggerMethods; _i < _loggerMethods.length; _i++) {
191
+ _loop();
192
+ }
193
+
194
+ return api;
195
+ }();
196
+
197
+ /*
198
+ Copyright 2019 Google LLC
199
+
200
+ Use of this source code is governed by an MIT-style
201
+ license that can be found in the LICENSE file or at
202
+ https://opensource.org/licenses/MIT.
203
+ */
204
+
205
+ /**
206
+ * A minimal `EventTarget` shim.
207
+ * This is necessary because not all browsers support constructable
208
+ * `EventTarget`, so using a real `EventTarget` will error.
209
+ * @private
210
+ */
211
+ var WorkboxEventTarget = /*#__PURE__*/function () {
212
+ function WorkboxEventTarget() {
213
+ this._eventListenerRegistry = new Map();
214
+ }
215
+ /**
216
+ * @param {string} type
217
+ * @param {Function} listener
218
+ * @private
219
+ */
220
+
221
+
222
+ var _proto = WorkboxEventTarget.prototype;
223
+
224
+ _proto.addEventListener = function addEventListener(type, listener) {
225
+ var foo = this._getEventListenersByType(type);
226
+
227
+ foo.add(listener);
228
+ }
229
+ /**
230
+ * @param {string} type
231
+ * @param {Function} listener
232
+ * @private
233
+ */
234
+ ;
235
+
236
+ _proto.removeEventListener = function removeEventListener(type, listener) {
237
+ this._getEventListenersByType(type).delete(listener);
238
+ }
239
+ /**
240
+ * @param {Object} event
241
+ * @private
242
+ */
243
+ ;
244
+
245
+ _proto.dispatchEvent = function dispatchEvent(event) {
246
+ event.target = this;
247
+
248
+ var listeners = this._getEventListenersByType(event.type);
249
+
250
+ for (var _iterator = listeners, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
251
+ var _ref;
252
+
253
+ if (_isArray) {
254
+ if (_i >= _iterator.length) break;
255
+ _ref = _iterator[_i++];
256
+ } else {
257
+ _i = _iterator.next();
258
+ if (_i.done) break;
259
+ _ref = _i.value;
260
+ }
261
+
262
+ var listener = _ref;
263
+ listener(event);
264
+ }
265
+ }
266
+ /**
267
+ * Returns a Set of listeners associated with the passed event type.
268
+ * If no handlers have been registered, an empty Set is returned.
269
+ *
270
+ * @param {string} type The event type.
271
+ * @return {Set<ListenerCallback>} An array of handler functions.
272
+ * @private
273
+ */
274
+ ;
275
+
276
+ _proto._getEventListenersByType = function _getEventListenersByType(type) {
277
+ if (!this._eventListenerRegistry.has(type)) {
278
+ this._eventListenerRegistry.set(type, new Set());
279
+ }
280
+
281
+ return this._eventListenerRegistry.get(type);
282
+ };
283
+
284
+ return WorkboxEventTarget;
285
+ }();
286
+
287
+ /*
288
+ Copyright 2019 Google LLC
289
+
290
+ Use of this source code is governed by an MIT-style
291
+ license that can be found in the LICENSE file or at
292
+ https://opensource.org/licenses/MIT.
293
+ */
294
+ /**
295
+ * Returns true if two URLs have the same `.href` property. The URLS can be
296
+ * relative, and if they are the current location href is used to resolve URLs.
297
+ *
298
+ * @private
299
+ * @param {string} url1
300
+ * @param {string} url2
301
+ * @return {boolean}
302
+ */
303
+
304
+ function urlsMatch(url1, url2) {
305
+ var _location = location,
306
+ href = _location.href;
307
+ return new URL(url1, href).href === new URL(url2, href).href;
308
+ }
309
+
310
+ /*
311
+ Copyright 2019 Google LLC
312
+
313
+ Use of this source code is governed by an MIT-style
314
+ license that can be found in the LICENSE file or at
315
+ https://opensource.org/licenses/MIT.
316
+ */
317
+ /**
318
+ * A minimal `Event` subclass shim.
319
+ * This doesn't *actually* subclass `Event` because not all browsers support
320
+ * constructable `EventTarget`, and using a real `Event` will error.
321
+ * @private
322
+ */
323
+
324
+ var WorkboxEvent = function WorkboxEvent(type, props) {
325
+ this.type = type;
326
+ Object.assign(this, props);
327
+ };
328
+
329
+ // `skipWaiting()` wasn't called. This 200 amount wasn't scientifically
330
+ // chosen, but it seems to avoid false positives in my testing.
331
+
332
+ function _await(value, then, direct) {
333
+ if (direct) {
334
+ return then ? then(value) : value;
335
+ }
336
+
337
+ if (!value || !value.then) {
338
+ value = Promise.resolve(value);
339
+ }
340
+
341
+ return then ? value.then(then) : value;
342
+ }
343
+
344
+ var WAITING_TIMEOUT_DURATION = 200; // The amount of time after a registration that we can reasonably conclude
345
+ // that the registration didn't trigger an update.
346
+
347
+ function _async(f) {
348
+ return function () {
349
+ for (var args = [], i = 0; i < arguments.length; i++) {
350
+ args[i] = arguments[i];
351
+ }
352
+
353
+ try {
354
+ return Promise.resolve(f.apply(this, args));
355
+ } catch (e) {
356
+ return Promise.reject(e);
357
+ }
358
+ };
359
+ }
360
+
361
+ var REGISTRATION_TIMEOUT_DURATION = 60000;
362
+ /**
363
+ * A class to aid in handling service worker registration, updates, and
364
+ * reacting to service worker lifecycle events.
365
+ *
366
+ * @fires [message]{@link module:workbox-window.Workbox#message}
367
+ * @fires [installed]{@link module:workbox-window.Workbox#installed}
368
+ * @fires [waiting]{@link module:workbox-window.Workbox#waiting}
369
+ * @fires [controlling]{@link module:workbox-window.Workbox#controlling}
370
+ * @fires [activated]{@link module:workbox-window.Workbox#activated}
371
+ * @fires [redundant]{@link module:workbox-window.Workbox#redundant}
372
+ * @fires [externalinstalled]{@link module:workbox-window.Workbox#externalinstalled}
373
+ * @fires [externalwaiting]{@link module:workbox-window.Workbox#externalwaiting}
374
+ * @fires [externalactivated]{@link module:workbox-window.Workbox#externalactivated}
375
+ * @memberof module:workbox-window
376
+ */
377
+
378
+ function _empty() {}
379
+
380
+ var Workbox = /*#__PURE__*/function (_WorkboxEventTarget) {
381
+ _inheritsLoose(Workbox, _WorkboxEventTarget);
382
+
383
+ /**
384
+ * Creates a new Workbox instance with a script URL and service worker
385
+ * options. The script URL and options are the same as those used when
386
+ * calling `navigator.serviceWorker.register(scriptURL, options)`. See:
387
+ * https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register
388
+ *
389
+ * @param {string} scriptURL The service worker script associated with this
390
+ * instance.
391
+ * @param {Object} [registerOptions] The service worker options associated
392
+ * with this instance.
393
+ */
394
+ function Workbox(scriptURL, registerOptions) {
395
+ var _this;
396
+
397
+ if (registerOptions === void 0) {
398
+ registerOptions = {};
399
+ }
400
+
401
+ _this = _WorkboxEventTarget.call(this) || this;
402
+ _this._registerOptions = {};
403
+ _this._updateFoundCount = 0; // Deferreds we can resolve later.
404
+
405
+ _this._swDeferred = new Deferred();
406
+ _this._activeDeferred = new Deferred();
407
+ _this._controllingDeferred = new Deferred();
408
+ _this._registrationTime = 0;
409
+ _this._ownSWs = new Set();
410
+ /**
411
+ * @private
412
+ */
413
+
414
+ _this._onUpdateFound = function () {
415
+ // `this._registration` will never be `undefined` after an update is found.
416
+ var registration = _this._registration;
417
+ var installingSW = registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
418
+ // different from the current controlling SW's script URL, we know any
419
+ // successful registration calls will trigger an `updatefound` event.
420
+ // But if the registered script URL is the same as the current controlling
421
+ // SW's script URL, we'll only get an `updatefound` event if the file
422
+ // changed since it was last registered. This can be a problem if the user
423
+ // opens up the same page in a different tab, and that page registers
424
+ // a SW that triggers an update. It's a problem because this page has no
425
+ // good way of knowing whether the `updatefound` event came from the SW
426
+ // script it registered or from a registration attempt made by a newer
427
+ // version of the page running in another tab.
428
+ // To minimize the possibility of a false positive, we use the logic here:
429
+
430
+ var updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
431
+ // add the `updatefound` event listener until the `register()` call, if
432
+ // `_updateFoundCount` is > 0 then it means this method has already
433
+ // been called, thus this SW must be external
434
+ _this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
435
+ // instance's script URL, we know it's definitely not from our
436
+ // registration.
437
+ !urlsMatch(installingSW.scriptURL, _this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
438
+ // Any `updatefound` event that occurs long after our registration is
439
+ // assumed to be external.
440
+ performance.now() > _this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
441
+ // triggered by this instance.
442
+ true : false;
443
+
444
+ if (updateLikelyTriggeredExternally) {
445
+ _this._externalSW = installingSW;
446
+ registration.removeEventListener('updatefound', _this._onUpdateFound);
447
+ } else {
448
+ // If the update was not triggered externally we know the installing
449
+ // SW is the one we registered, so we set it.
450
+ _this._sw = installingSW;
451
+
452
+ _this._ownSWs.add(installingSW);
453
+
454
+ _this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
455
+ // callback for, but we do log messages for it in development.
456
+
457
+
458
+ {
459
+ if (navigator.serviceWorker.controller) {
460
+ logger.log('Updated service worker found. Installing now...');
461
+ } else {
462
+ logger.log('Service worker is installing...');
463
+ }
464
+ }
465
+ } // Increment the `updatefound` count, so future invocations of this
466
+ // method can be sure they were triggered externally.
467
+
468
+
469
+ ++_this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
470
+ // triggered externally, since we have callbacks for both.
471
+
472
+ installingSW.addEventListener('statechange', _this._onStateChange);
473
+ };
474
+ /**
475
+ * @private
476
+ * @param {Event} originalEvent
477
+ */
478
+
479
+
480
+ _this._onStateChange = function (originalEvent) {
481
+ // `this._registration` will never be `undefined` after an update is found.
482
+ var registration = _this._registration;
483
+ var sw = originalEvent.target;
484
+ var state = sw.state;
485
+ var isExternal = sw === _this._externalSW;
486
+ var eventPrefix = isExternal ? 'external' : '';
487
+ var eventProps = {
488
+ sw: sw,
489
+ originalEvent: originalEvent
490
+ };
491
+
492
+ if (!isExternal && _this._isUpdate) {
493
+ eventProps.isUpdate = true;
494
+ }
495
+
496
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
497
+
498
+ if (state === 'installed') {
499
+ // This timeout is used to ignore cases where the service worker calls
500
+ // `skipWaiting()` in the install event, thus moving it directly in the
501
+ // activating state. (Since all service workers *must* go through the
502
+ // waiting phase, the only way to detect `skipWaiting()` called in the
503
+ // install event is to observe that the time spent in the waiting phase
504
+ // is very short.)
505
+ // NOTE: we don't need separate timeouts for the own and external SWs
506
+ // since they can't go through these phases at the same time.
507
+ _this._waitingTimeout = self.setTimeout(function () {
508
+ // Ensure the SW is still waiting (it may now be redundant).
509
+ if (state === 'installed' && registration.waiting === sw) {
510
+ _this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
511
+
512
+ {
513
+ if (isExternal) {
514
+ logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
515
+ } else {
516
+ logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
517
+ }
518
+ }
519
+ }
520
+ }, WAITING_TIMEOUT_DURATION);
521
+ } else if (state === 'activating') {
522
+ clearTimeout(_this._waitingTimeout);
523
+
524
+ if (!isExternal) {
525
+ _this._activeDeferred.resolve(sw);
526
+ }
527
+ }
528
+
529
+ {
530
+ switch (state) {
531
+ case 'installed':
532
+ if (isExternal) {
533
+ logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
534
+ } else {
535
+ logger.log('Registered service worker installed.');
536
+ }
537
+
538
+ break;
539
+
540
+ case 'activated':
541
+ if (isExternal) {
542
+ logger.warn('An external service worker has activated.');
543
+ } else {
544
+ logger.log('Registered service worker activated.');
545
+
546
+ if (sw !== navigator.serviceWorker.controller) {
547
+ logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
548
+ }
549
+ }
550
+
551
+ break;
552
+
553
+ case 'redundant':
554
+ if (sw === _this._compatibleControllingSW) {
555
+ logger.log('Previously controlling service worker now redundant!');
556
+ } else if (!isExternal) {
557
+ logger.log('Registered service worker now redundant!');
558
+ }
559
+
560
+ break;
561
+ }
562
+ }
563
+ };
564
+ /**
565
+ * @private
566
+ * @param {Event} originalEvent
567
+ */
568
+
569
+
570
+ _this._onControllerChange = function (originalEvent) {
571
+ var sw = _this._sw;
572
+
573
+ if (sw === navigator.serviceWorker.controller) {
574
+ _this.dispatchEvent(new WorkboxEvent('controlling', {
575
+ sw: sw,
576
+ originalEvent: originalEvent,
577
+ isUpdate: _this._isUpdate
578
+ }));
579
+
580
+ {
581
+ logger.log('Registered service worker now controlling this page.');
582
+ }
583
+
584
+ _this._controllingDeferred.resolve(sw);
585
+ }
586
+ };
587
+ /**
588
+ * @private
589
+ * @param {Event} originalEvent
590
+ */
591
+
592
+
593
+ _this._onMessage = _async(function (originalEvent) {
594
+ var data = originalEvent.data,
595
+ source = originalEvent.source; // Wait until there's an "own" service worker. This is used to buffer
596
+ // `message` events that may be received prior to calling `register()`.
597
+
598
+ return _await(_this.getSW(), function () {
599
+ if (_this._ownSWs.has(source)) {
600
+ _this.dispatchEvent(new WorkboxEvent('message', {
601
+ data: data,
602
+ sw: source,
603
+ originalEvent: originalEvent
604
+ }));
605
+ }
606
+ }); // If the service worker that sent the message is in the list of own
607
+ // service workers for this instance, dispatch a `message` event.
608
+ // NOTE: we check for all previously owned service workers rather than
609
+ // just the current one because some messages (e.g. cache updates) use
610
+ // a timeout when sent and may be delayed long enough for a service worker
611
+ // update to be found.
612
+ });
613
+ _this._scriptURL = scriptURL;
614
+ _this._registerOptions = registerOptions; // Add a message listener immediately since messages received during
615
+ // page load are buffered only until the DOMContentLoaded event:
616
+ // https://github.com/GoogleChrome/workbox/issues/2202
617
+
618
+ navigator.serviceWorker.addEventListener('message', _this._onMessage);
619
+ return _this;
620
+ }
621
+ /**
622
+ * Registers a service worker for this instances script URL and service
623
+ * worker options. By default this method delays registration until after
624
+ * the window has loaded.
625
+ *
626
+ * @param {Object} [options]
627
+ * @param {Function} [options.immediate=false] Setting this to true will
628
+ * register the service worker immediately, even if the window has
629
+ * not loaded (not recommended).
630
+ */
631
+
632
+
633
+ var _proto = Workbox.prototype;
634
+
635
+ _proto.register = function register(_temp) {
636
+ var _ref = _temp === void 0 ? {} : _temp,
637
+ _ref$immediate = _ref.immediate,
638
+ immediate = _ref$immediate === void 0 ? false : _ref$immediate;
639
+
640
+ try {
641
+ var _this3 = this;
642
+
643
+ if ("dev" !== 'production') {
644
+ if (_this3._registrationTime) {
645
+ logger.error('Cannot re-register a Workbox instance after it has ' + 'been registered. Create a new instance instead.');
646
+ return;
647
+ }
648
+ }
649
+
650
+ return _invoke(function () {
651
+ if (!immediate && document.readyState !== 'complete') {
652
+ return _awaitIgnored(new Promise(function (res) {
653
+ return window.addEventListener('load', res);
654
+ }));
655
+ }
656
+ }, function () {
657
+ // Set this flag to true if any service worker was controlling the page
658
+ // at registration time.
659
+ _this3._isUpdate = Boolean(navigator.serviceWorker.controller); // Before registering, attempt to determine if a SW is already controlling
660
+ // the page, and if that SW script (and version, if specified) matches this
661
+ // instance's script.
662
+
663
+ _this3._compatibleControllingSW = _this3._getControllingSWIfCompatible();
664
+ return _await(_this3._registerScript(), function (_this2$_registerScrip) {
665
+ _this3._registration = _this2$_registerScrip;
666
+
667
+ // If we have a compatible controller, store the controller as the "own"
668
+ // SW, resolve active/controlling deferreds and add necessary listeners.
669
+ if (_this3._compatibleControllingSW) {
670
+ _this3._sw = _this3._compatibleControllingSW;
671
+
672
+ _this3._activeDeferred.resolve(_this3._compatibleControllingSW);
673
+
674
+ _this3._controllingDeferred.resolve(_this3._compatibleControllingSW);
675
+
676
+ _this3._compatibleControllingSW.addEventListener('statechange', _this3._onStateChange, {
677
+ once: true
678
+ });
679
+ } // If there's a waiting service worker with a matching URL before the
680
+ // `updatefound` event fires, it likely means that this site is open
681
+ // in another tab, or the user refreshed the page (and thus the previous
682
+ // page wasn't fully unloaded before this page started loading).
683
+ // https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#waiting
684
+
685
+
686
+ var waitingSW = _this3._registration.waiting;
687
+
688
+ if (waitingSW && urlsMatch(waitingSW.scriptURL, _this3._scriptURL)) {
689
+ // Store the waiting SW as the "own" Sw, even if it means overwriting
690
+ // a compatible controller.
691
+ _this3._sw = waitingSW; // Run this in the next microtask, so any code that adds an event
692
+ // listener after awaiting `register()` will get this event.
693
+
694
+ dontWaitFor(Promise.resolve().then(function () {
695
+ _this3.dispatchEvent(new WorkboxEvent('waiting', {
696
+ sw: waitingSW,
697
+ wasWaitingBeforeRegister: true
698
+ }));
699
+
700
+ if ("dev" !== 'production') {
701
+ logger.warn('A service worker was already waiting to activate ' + 'before this script was registered...');
702
+ }
703
+ }));
704
+ } // If an "own" SW is already set, resolve the deferred.
705
+
706
+
707
+ if (_this3._sw) {
708
+ _this3._swDeferred.resolve(_this3._sw);
709
+
710
+ _this3._ownSWs.add(_this3._sw);
711
+ }
712
+
713
+ if ("dev" !== 'production') {
714
+ logger.log('Successfully registered service worker.', _this3._scriptURL);
715
+
716
+ if (navigator.serviceWorker.controller) {
717
+ if (_this3._compatibleControllingSW) {
718
+ logger.debug('A service worker with the same script URL ' + 'is already controlling this page.');
719
+ } else {
720
+ logger.debug('A service worker with a different script URL is ' + 'currently controlling the page. The browser is now fetching ' + 'the new script now...');
721
+ }
722
+ }
723
+
724
+ var currentPageIsOutOfScope = function currentPageIsOutOfScope() {
725
+ var scopeURL = new URL(_this3._registerOptions.scope || _this3._scriptURL, document.baseURI);
726
+ var scopeURLBasePath = new URL('./', scopeURL.href).pathname;
727
+ return !location.pathname.startsWith(scopeURLBasePath);
728
+ };
729
+
730
+ if (currentPageIsOutOfScope()) {
731
+ logger.warn('The current page is not in scope for the registered ' + 'service worker. Was this a mistake?');
732
+ }
733
+ }
734
+
735
+ _this3._registration.addEventListener('updatefound', _this3._onUpdateFound);
736
+
737
+ navigator.serviceWorker.addEventListener('controllerchange', _this3._onControllerChange, {
738
+ once: true
739
+ });
740
+ return _this3._registration;
741
+ });
742
+ });
743
+ } catch (e) {
744
+ return Promise.reject(e);
745
+ }
746
+ }
747
+ /**
748
+ * Checks for updates of the registered service worker.
749
+ */
750
+ ;
751
+
752
+ _proto.update = function update() {
753
+ try {
754
+ var _this5 = this;
755
+
756
+ if (!_this5._registration) {
757
+ if ("dev" !== 'production') {
758
+ logger.error('Cannot update a Workbox instance without ' + 'being registered. Register the Workbox instance first.');
759
+ }
760
+
761
+ return;
762
+ } // Try to update registration
763
+
764
+
765
+ return _awaitIgnored(_this5._registration.update());
766
+ } catch (e) {
767
+ return Promise.reject(e);
768
+ }
769
+ }
770
+ /**
771
+ * Resolves to the service worker registered by this instance as soon as it
772
+ * is active. If a service worker was already controlling at registration
773
+ * time then it will resolve to that if the script URLs (and optionally
774
+ * script versions) match, otherwise it will wait until an update is found
775
+ * and activates.
776
+ *
777
+ * @return {Promise<ServiceWorker>}
778
+ */
779
+ ;
780
+
781
+ /**
782
+ * Resolves with a reference to a service worker that matches the script URL
783
+ * of this instance, as soon as it's available.
784
+ *
785
+ * If, at registration time, there's already an active or waiting service
786
+ * worker with a matching script URL, it will be used (with the waiting
787
+ * service worker taking precedence over the active service worker if both
788
+ * match, since the waiting service worker would have been registered more
789
+ * recently).
790
+ * If there's no matching active or waiting service worker at registration
791
+ * time then the promise will not resolve until an update is found and starts
792
+ * installing, at which point the installing service worker is used.
793
+ *
794
+ * @return {Promise<ServiceWorker>}
795
+ */
796
+ _proto.getSW = function getSW() {
797
+ try {
798
+ var _this7 = this;
799
+
800
+ // If `this._sw` is set, resolve with that as we want `getSW()` to
801
+ // return the correct (new) service worker if an update is found.
802
+ return _this7._sw !== undefined ? _this7._sw : _this7._swDeferred.promise;
803
+ } catch (e) {
804
+ return Promise.reject(e);
805
+ }
806
+ }
807
+ /**
808
+ * Sends the passed data object to the service worker registered by this
809
+ * instance (via [`getSW()`]{@link module:workbox-window.Workbox#getSW}) and resolves
810
+ * with a response (if any).
811
+ *
812
+ * A response can be set in a message handler in the service worker by
813
+ * calling `event.ports[0].postMessage(...)`, which will resolve the promise
814
+ * returned by `messageSW()`. If no response is set, the promise will never
815
+ * resolve.
816
+ *
817
+ * @param {Object} data An object to send to the service worker
818
+ * @return {Promise<Object>}
819
+ */
820
+ ;
821
+
822
+ _proto.messageSW = function messageSW$1(data) {
823
+ try {
824
+ var _this9 = this;
825
+
826
+ return _await(_this9.getSW(), function (sw) {
827
+ return messageSW(sw, data);
828
+ });
829
+ } catch (e) {
830
+ return Promise.reject(e);
831
+ }
832
+ }
833
+ /**
834
+ * Checks for a service worker already controlling the page and returns
835
+ * it if its script URL matches.
836
+ *
837
+ * @private
838
+ * @return {ServiceWorker|undefined}
839
+ */
840
+ ;
841
+
842
+ _proto._getControllingSWIfCompatible = function _getControllingSWIfCompatible() {
843
+ var controller = navigator.serviceWorker.controller;
844
+
845
+ if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
846
+ return controller;
847
+ } else {
848
+ return undefined;
849
+ }
850
+ }
851
+ /**
852
+ * Registers a service worker for this instances script URL and register
853
+ * options and tracks the time registration was complete.
854
+ *
855
+ * @private
856
+ */
857
+ ;
858
+
859
+ _proto._registerScript = function _registerScript() {
860
+ try {
861
+ var _this11 = this;
862
+
863
+ return _catch(function () {
864
+ return _await(navigator.serviceWorker.register(_this11._scriptURL, _this11._registerOptions), function (reg) {
865
+ // Keep track of when registration happened, so it can be used in the
866
+ // `this._onUpdateFound` heuristic. Also use the presence of this
867
+ // property as a way to see if `.register()` has been called.
868
+ _this11._registrationTime = performance.now();
869
+ return reg;
870
+ });
871
+ }, function (error) {
872
+ if ("dev" !== 'production') {
873
+ logger.error(error);
874
+ } // Re-throw the error.
875
+
876
+
877
+ throw error;
878
+ });
879
+ } catch (e) {
880
+ return Promise.reject(e);
881
+ }
882
+ };
883
+
884
+ _createClass(Workbox, [{
885
+ key: "active",
886
+ get: function get() {
887
+ return this._activeDeferred.promise;
888
+ }
889
+ /**
890
+ * Resolves to the service worker registered by this instance as soon as it
891
+ * is controlling the page. If a service worker was already controlling at
892
+ * registration time then it will resolve to that if the script URLs (and
893
+ * optionally script versions) match, otherwise it will wait until an update
894
+ * is found and starts controlling the page.
895
+ * Note: the first time a service worker is installed it will active but
896
+ * not start controlling the page unless `clients.claim()` is called in the
897
+ * service worker.
898
+ *
899
+ * @return {Promise<ServiceWorker>}
900
+ */
901
+
902
+ }, {
903
+ key: "controlling",
904
+ get: function get() {
905
+ return this._controllingDeferred.promise;
906
+ }
907
+ }]);
908
+
909
+ return Workbox;
910
+ }(WorkboxEventTarget);
911
+
912
+ function _awaitIgnored(value, direct) {
913
+ if (!direct) {
914
+ return value && value.then ? value.then(_empty) : Promise.resolve();
915
+ }
916
+ } // The jsdoc comments below outline the events this instance may dispatch:
917
+ // -----------------------------------------------------------------------
918
+
919
+ /**
920
+ * The `message` event is dispatched any time a `postMessage` is received.
921
+ *
922
+ * @event module:workbox-window.Workbox#message
923
+ * @type {WorkboxEvent}
924
+ * @property {*} data The `data` property from the original `message` event.
925
+ * @property {Event} originalEvent The original [`message`]{@link https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent}
926
+ * event.
927
+ * @property {string} type `message`.
928
+ * @property {Workbox} target The `Workbox` instance.
929
+ */
930
+
931
+ /**
932
+ * The `installed` event is dispatched if the state of a
933
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
934
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
935
+ * changes to `installed`.
936
+ *
937
+ * Then can happen either the very first time a service worker is installed,
938
+ * or after an update to the current service worker is found. In the case
939
+ * of an update being found, the event's `isUpdate` property will be `true`.
940
+ *
941
+ * @event module:workbox-window.Workbox#installed
942
+ * @type {WorkboxEvent}
943
+ * @property {ServiceWorker} sw The service worker instance.
944
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
945
+ * event.
946
+ * @property {boolean|undefined} isUpdate True if a service worker was already
947
+ * controlling when this `Workbox` instance called `register()`.
948
+ * @property {string} type `installed`.
949
+ * @property {Workbox} target The `Workbox` instance.
950
+ */
951
+
952
+ /**
953
+ * The `waiting` event is dispatched if the state of a
954
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
955
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
956
+ * changes to `installed` and then doesn't immediately change to `activating`.
957
+ * It may also be dispatched if a service worker with the same
958
+ * [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
959
+ * was already waiting when the [`register()`]{@link module:workbox-window.Workbox#register}
960
+ * method was called.
961
+ *
962
+ * @event module:workbox-window.Workbox#waiting
963
+ * @type {WorkboxEvent}
964
+ * @property {ServiceWorker} sw The service worker instance.
965
+ * @property {Event|undefined} originalEvent The original
966
+ * [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
967
+ * event, or `undefined` in the case where the service worker was waiting
968
+ * to before `.register()` was called.
969
+ * @property {boolean|undefined} isUpdate True if a service worker was already
970
+ * controlling when this `Workbox` instance called `register()`.
971
+ * @property {boolean|undefined} wasWaitingBeforeRegister True if a service worker with
972
+ * a matching `scriptURL` was already waiting when this `Workbox`
973
+ * instance called `register()`.
974
+ * @property {string} type `waiting`.
975
+ * @property {Workbox} target The `Workbox` instance.
976
+ */
977
+
978
+ /**
979
+ * The `controlling` event is dispatched if a
980
+ * [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
981
+ * fires on the service worker [container]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer}
982
+ * and the [`scriptURL`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/scriptURL}
983
+ * of the new [controller]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/controller}
984
+ * matches the `scriptURL` of the `Workbox` instance's
985
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}.
986
+ *
987
+ * @event module:workbox-window.Workbox#controlling
988
+ * @type {WorkboxEvent}
989
+ * @property {ServiceWorker} sw The service worker instance.
990
+ * @property {Event} originalEvent The original [`controllerchange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/oncontrollerchange}
991
+ * event.
992
+ * @property {boolean|undefined} isUpdate True if a service worker was already
993
+ * controlling when this service worker was registered.
994
+ * @property {string} type `controlling`.
995
+ * @property {Workbox} target The `Workbox` instance.
996
+ */
997
+
998
+ /**
999
+ * The `activated` event is dispatched if the state of a
1000
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
1001
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
1002
+ * changes to `activated`.
1003
+ *
1004
+ * @event module:workbox-window.Workbox#activated
1005
+ * @type {WorkboxEvent}
1006
+ * @property {ServiceWorker} sw The service worker instance.
1007
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1008
+ * event.
1009
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1010
+ * controlling when this `Workbox` instance called `register()`.
1011
+ * @property {string} type `activated`.
1012
+ * @property {Workbox} target The `Workbox` instance.
1013
+ */
1014
+
1015
+ /**
1016
+ * The `redundant` event is dispatched if the state of a
1017
+ * [`Workbox`]{@link module:workbox-window.Workbox} instance's
1018
+ * [registered service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-precaching#def-registered-sw}
1019
+ * changes to `redundant`.
1020
+ *
1021
+ * @event module:workbox-window.Workbox#redundant
1022
+ * @type {WorkboxEvent}
1023
+ * @property {ServiceWorker} sw The service worker instance.
1024
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1025
+ * event.
1026
+ * @property {boolean|undefined} isUpdate True if a service worker was already
1027
+ * controlling when this `Workbox` instance called `register()`.
1028
+ * @property {string} type `redundant`.
1029
+ * @property {Workbox} target The `Workbox` instance.
1030
+ */
1031
+
1032
+ /**
1033
+ * The `externalinstalled` event is dispatched if the state of an
1034
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1035
+ * changes to `installed`.
1036
+ *
1037
+ * @event module:workbox-window.Workbox#externalinstalled
1038
+ * @type {WorkboxEvent}
1039
+ * @property {ServiceWorker} sw The service worker instance.
1040
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1041
+ * event.
1042
+ * @property {string} type `externalinstalled`.
1043
+ * @property {Workbox} target The `Workbox` instance.
1044
+ */
1045
+
1046
+ /**
1047
+ * The `externalwaiting` event is dispatched if the state of an
1048
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1049
+ * changes to `waiting`.
1050
+ *
1051
+ * @event module:workbox-window.Workbox#externalwaiting
1052
+ * @type {WorkboxEvent}
1053
+ * @property {ServiceWorker} sw The service worker instance.
1054
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1055
+ * event.
1056
+ * @property {string} type `externalwaiting`.
1057
+ * @property {Workbox} target The `Workbox` instance.
1058
+ */
1059
+
1060
+ /**
1061
+ * The `externalactivated` event is dispatched if the state of an
1062
+ * [external service worker]{@link https://developers.google.com/web/tools/workbox/modules/workbox-window#when_an_unexpected_version_of_the_service_worker_is_found}
1063
+ * changes to `activated`.
1064
+ *
1065
+ * @event module:workbox-window.Workbox#externalactivated
1066
+ * @type {WorkboxEvent}
1067
+ * @property {ServiceWorker} sw The service worker instance.
1068
+ * @property {Event} originalEvent The original [`statechange`]{@link https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/onstatechange}
1069
+ * event.
1070
+ * @property {string} type `externalactivated`.
1071
+ * @property {Workbox} target The `Workbox` instance.
1072
+ */
1073
+
1074
+
1075
+ function _invoke(body, then) {
1076
+ var result = body();
1077
+
1078
+ if (result && result.then) {
1079
+ return result.then(then);
1080
+ }
1081
+
1082
+ return then(result);
1083
+ }
1084
+
1085
+ function _catch(body, recover) {
1086
+ try {
1087
+ var result = body();
1088
+ } catch (e) {
1089
+ return recover(e);
1090
+ }
1091
+
1092
+ if (result && result.then) {
1093
+ return result.then(void 0, recover);
1094
+ }
1095
+
1096
+ return result;
1097
+ }
1098
+
1099
+ exports.Workbox = Workbox;
1100
+ exports.messageSW = messageSW;
1101
+
1102
+ Object.defineProperty(exports, '__esModule', { value: true });
1103
+
1104
+ })));
1105
+ //# sourceMappingURL=workbox-window.dev.umd.js.map