jekyll-pwa-workbox 0.0.6 → 0.0.7.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll-pwa-workbox.rb +1 -1
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js +819 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js +486 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js +192 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js +1643 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js +652 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js +103 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js +236 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js +994 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js +263 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js +1026 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js +1127 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js +333 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map +1 -0
- data/lib/vendor/{workbox-v4.3.1 → workbox-v5.0.0.alpha1}/workbox-window.dev.es5.mjs +248 -262
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map +1 -0
- data/lib/vendor/{workbox-v4.3.1 → workbox-v5.0.0.alpha1}/workbox-window.dev.mjs +234 -242
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js +882 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map +1 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js +2 -0
- data/lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map +1 -0
- metadata +75 -80
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.dev.js +0 -822
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-background-sync.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.dev.js +0 -496
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-broadcast-update.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.dev.js +0 -200
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-cacheable-response.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-core.dev.js +0 -1712
- data/lib/vendor/workbox-v4.3.1/workbox-core.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-core.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-core.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.dev.js +0 -652
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-expiration.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.dev.js +0 -110
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-navigation-preload.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js +0 -243
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-offline-ga.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js +0 -989
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-precaching.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js +0 -268
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-range-requests.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js +0 -1020
- data/lib/vendor/workbox-v4.3.1/workbox-routing.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-routing.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js +0 -1138
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-strategies.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js +0 -337
- data/lib/vendor/workbox-v4.3.1/workbox-streams.dev.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-streams.prod.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-sw.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-sw.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js +0 -896
- data/lib/vendor/workbox-v4.3.1/workbox-window.dev.umd.js.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.es5.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.mjs.map +0 -1
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js +0 -2
- data/lib/vendor/workbox-v4.3.1/workbox-window.prod.umd.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-window.dev.es5.mjs","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../../workbox-core/_private/logger.js","../utils/WorkboxEventTarget.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js"],"sourcesContent":["// @ts-ignore\ntry {\n self['workbox:window:5.0.0-alpha.0'] && _();\n}\ncatch (e) { }\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport './_version.js';\n/**\n * Sends a data object to a service worker via `postMessage` and resolves with\n * a response (if any).\n *\n * A response can be set in a message handler in the service worker by\n * calling `event.ports[0].postMessage(...)`, which will resolve the promise\n * returned by `messageSW()`. If no response is set, the promise will not\n * resolve.\n *\n * @param {ServiceWorker} sw The service worker to send the message to.\n * @param {Object} data An object to send to the service worker.\n * @return {Promise<Object|undefined>}\n *\n * @memberof module:workbox-window\n */\nexport function messageSW(sw, data) {\n return new Promise((resolve) => {\n let messageChannel = new MessageChannel();\n messageChannel.port1.onmessage = (event) => {\n resolve(event.data);\n };\n sw.postMessage(data, [messageChannel.port2]);\n });\n}\n;\n","// @ts-ignore\ntry {\n self['workbox:core:5.0.0-alpha.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';\nconst logger = (process.env.NODE_ENV === 'production' ? null : (() => {\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 (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*/\nimport '../_version.js';\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 = {};\n }\n /**\n * @param {string} type\n * @param {Function} listener\n * @private\n */\n addEventListener(type, listener) {\n this._getEventListenersByType(type).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 return this._eventListenerRegistry[type] =\n (this._eventListenerRegistry[type] || new Set());\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * Returns true if two URLs have the same `.href` property. The URLS can be\n * relative, and if they are the current location href is used to resolve URLs.\n *\n * @private\n * @param {string} url1\n * @param {string} url2\n * @return {boolean}\n */\nexport function urlsMatch(url1, url2) {\n const { href } = location;\n return new URL(url1, href).href === new URL(url2, href).href;\n}\n;\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport '../_version.js';\n/**\n * A minimal `Event` subclass shim.\n * This doesn't *actually* subclass `Event` because not all browsers support\n * constructable `EventTarget`, and using a real `Event` will error.\n * @private\n */\nexport class WorkboxEvent {\n constructor(type, props) {\n this.type = type;\n Object.assign(this, props);\n }\n}\n","/*\n Copyright 2019 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\nimport { Deferred } from 'workbox-core/_private/Deferred.js';\nimport { 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 *\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 /**\n * @private\n */\n this._onUpdateFound = () => {\n // `this._registration` will never be `undefined` after an update is found.\n const registration = this._registration;\n const installingSW = registration.installing;\n // If the script URL passed to `navigator.serviceWorker.register()` is\n // different from the current controlling SW's script URL, we know any\n // successful registration calls will trigger an `updatefound` event.\n // But if the registered script URL is the same as the current controlling\n // SW's script URL, we'll only get an `updatefound` event if the file\n // changed since it was last registered. This can be a problem if the user\n // opens up the same page in a different tab, and that page registers\n // a SW that triggers an update. It's a problem because this page has no\n // good way of knowing whether the `updatefound` event came from the SW\n // script it registered or from a registration attempt made by a newer\n // version of the page running in another tab.\n // To minimize the possibility of a false positive, we use the logic here:\n let updateLikelyTriggeredExternally = \n // Since we enforce only calling `register()` once, and since we don't\n // add the `updatefound` event listener until the `register()` call, if\n // `_updateFoundCount` is > 0 then it means this method has already\n // been called, thus this SW must be external\n this._updateFoundCount > 0 ||\n // If the script URL of the installing SW is different from this\n // instance's script URL, we know it's definitely not from our\n // registration.\n !urlsMatch(installingSW.scriptURL, this._scriptURL) ||\n // If all of the above are false, then we use a time-based heuristic:\n // Any `updatefound` event that occurs long after our registration is\n // assumed to be external.\n (performance.now() >\n this._registrationTime + REGISTRATION_TIMEOUT_DURATION) ?\n // If any of the above are not true, we assume the update was\n // triggered by this instance.\n true : false;\n if (updateLikelyTriggeredExternally) {\n this._externalSW = installingSW;\n registration.removeEventListener('updatefound', this._onUpdateFound);\n }\n else {\n // If the update was not triggered externally we know the installing\n // SW is the one we registered, so we set it.\n this._sw = installingSW;\n this._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 = { sw, originalEvent };\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 = (originalEvent) => {\n const { data } = originalEvent;\n this.dispatchEvent(new WorkboxEvent('message', { data, originalEvent }));\n };\n this._scriptURL = scriptURL;\n this._registerOptions = registerOptions;\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) => 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._reportWindowReady(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 prevoius\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 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 }\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 // Add message listeners.\n if ('BroadcastChannel' in self) {\n this._broadcastChannel = new BroadcastChannel('workbox');\n this._broadcastChannel.addEventListener('message', this._onMessage);\n }\n navigator.serviceWorker.addEventListener('message', this._onMessage);\n return this._registration;\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 matchs.\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 /**\n * Sends a message to the passed service worker that the window is ready.\n *\n * @param {ServiceWorker} sw\n * @private\n */\n _reportWindowReady(sw) {\n messageSW(sw, {\n type: 'WINDOW_READY',\n meta: 'workbox-window',\n });\n }\n}\n// The jsdoc comments below outline the events this instance may dispatch:\n// -----------------------------------------------------------------------\n/**\n * The `message` event is dispatched any time a `postMessage` (or a\n * `BroadcastChannel` message with the `workbox` channel name) 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} originalEvent The native `controllerchange` event\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-precaching#def-external-sw}\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-precaching#def-external-sw}\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|undefined} 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-precaching#def-external-sw}\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 */\nexport { Workbox };\n"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","postMessage","port2","Deferred","promise","reject","logger","process","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","addEventListener","type","listener","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","target","listeners","Set","urlsMatch","url1","url2","location","href","URL","WorkboxEvent","props","assign","body","recover","result","then","f","i","arguments","length","apply","value","direct","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_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","register","immediate","document","readyState","res","Boolean","_getControllingSWIfCompatible","_registerScript","_reportWindowReady","once","waitingSW","wasWaitingBeforeRegister","currentPageIsOutOfScope","scopeURL","scope","baseURI","scopeURLBasePath","pathname","startsWith","_broadcastChannel","BroadcastChannel","getSW","undefined","reg","meta"],"mappings":"AAAA;AACA,IAAI;EACAA,IAAI,CAAC,8BAAD,CAAJ,IAAwCC,CAAC,EAAzC;CADJ,CAGA,OAAOC,CAAP,EAAU;;ACJV;;;;;;;AAOA,AACA;;;;;;;;;;;;;;;;AAeA,AAAO,SAASC,SAAT,CAAmBC,EAAnB,EAAuBC,IAAvB,EAA6B;SACzB,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;QACxBC,cAAc,GAAG,IAAIC,cAAJ,EAArB;;IACAD,cAAc,CAACE,KAAf,CAAqBC,SAArB,GAAiC,UAACC,KAAD,EAAW;MACxCL,OAAO,CAACK,KAAK,CAACP,IAAP,CAAP;KADJ;;IAGAD,EAAE,CAACS,WAAH,CAAeR,IAAf,EAAqB,CAACG,cAAc,CAACM,KAAhB,CAArB;GALG,CAAP;;;;;;;;;;;;;;;;;;;;;;;;;ACxBJ;AACA,IAAI;EACAd,IAAI,CAAC,4BAAD,CAAJ,IAAsCC,CAAC,EAAvC;CADJ,CAGA,OAAOC,CAAP,EAAU;;ACJV;;;;;;;AAOA,AACA;;;;;;;;;IAQMa;;;;AAIF,oBAAc;;;OACLC,OAAL,GAAe,IAAIV,OAAJ,CAAY,UAACC,OAAD,EAAUU,MAAV,EAAqB;IAC5C,KAAI,CAACV,OAAL,GAAeA,OAAf;IACA,KAAI,CAACU,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IACnBD,SAAS,CAACC,EAAD,EAAK;MACV0C,IAAI,EAAE,cADI;MAEV6F,IAAI,EAAE;KAFD,CAAT;;;;;wBArGS;aACF,KAAKvD,eAAL,CAAqBpE,OAA5B;;;;;;;;;;;;;;;;;wBAcc;aACP,KAAKqE,oBAAL,CAA0BrE,OAAjC;;;;;EAhUc2B;;;;"}
|
@@ -1,6 +1,7 @@
|
|
1
|
+
// @ts-ignore
|
1
2
|
try {
|
2
|
-
self['workbox:window:
|
3
|
-
} catch (e) {}
|
3
|
+
self['workbox:window:5.0.0-alpha.0'] && _();
|
4
|
+
} catch (e) {}
|
4
5
|
|
5
6
|
/*
|
6
7
|
Copyright 2019 Google LLC
|
@@ -25,19 +26,22 @@ try {
|
|
25
26
|
* @memberof module:workbox-window
|
26
27
|
*/
|
27
28
|
|
28
|
-
|
29
|
+
function messageSW(sw, data) {
|
29
30
|
return new Promise(resolve => {
|
30
31
|
let messageChannel = new MessageChannel();
|
31
32
|
|
32
|
-
messageChannel.port1.onmessage =
|
33
|
+
messageChannel.port1.onmessage = event => {
|
34
|
+
resolve(event.data);
|
35
|
+
};
|
33
36
|
|
34
37
|
sw.postMessage(data, [messageChannel.port2]);
|
35
38
|
});
|
36
|
-
}
|
39
|
+
}
|
37
40
|
|
41
|
+
// @ts-ignore
|
38
42
|
try {
|
39
|
-
self['workbox:core:
|
40
|
-
} catch (e) {}
|
43
|
+
self['workbox:core:5.0.0-alpha.1'] && _();
|
44
|
+
} catch (e) {}
|
41
45
|
|
42
46
|
/*
|
43
47
|
Copyright 2018 Google LLC
|
@@ -74,21 +78,15 @@ class Deferred {
|
|
74
78
|
license that can be found in the LICENSE file or at
|
75
79
|
https://opensource.org/licenses/MIT.
|
76
80
|
*/
|
77
|
-
const logger =
|
81
|
+
const logger = (() => {
|
78
82
|
let inGroup = false;
|
79
83
|
const methodToColorMap = {
|
80
84
|
debug: `#7f8c8d`,
|
81
|
-
// Gray
|
82
85
|
log: `#2ecc71`,
|
83
|
-
// Green
|
84
86
|
warn: `#f39c12`,
|
85
|
-
// Yellow
|
86
87
|
error: `#c0392b`,
|
87
|
-
// Red
|
88
88
|
groupCollapsed: `#3498db`,
|
89
|
-
|
90
|
-
groupEnd: null // No colored prefix on groupEnd
|
91
|
-
|
89
|
+
groupEnd: null
|
92
90
|
};
|
93
91
|
|
94
92
|
const print = function (method, args) {
|
@@ -116,8 +114,11 @@ const logger = (() => {
|
|
116
114
|
};
|
117
115
|
|
118
116
|
const api = {};
|
117
|
+
const loggerMethods = Object.keys(methodToColorMap);
|
118
|
+
|
119
|
+
for (const key of loggerMethods) {
|
120
|
+
const method = key;
|
119
121
|
|
120
|
-
for (const method of Object.keys(methodToColorMap)) {
|
121
122
|
api[method] = (...args) => {
|
122
123
|
print(method, args);
|
123
124
|
};
|
@@ -140,14 +141,8 @@ const logger = (() => {
|
|
140
141
|
* @private
|
141
142
|
*/
|
142
143
|
|
143
|
-
class
|
144
|
-
/**
|
145
|
-
* Creates an event listener registry
|
146
|
-
*
|
147
|
-
* @private
|
148
|
-
*/
|
144
|
+
class WorkboxEventTarget {
|
149
145
|
constructor() {
|
150
|
-
// A registry of event types to listeners.
|
151
146
|
this._eventListenerRegistry = {};
|
152
147
|
}
|
153
148
|
/**
|
@@ -171,7 +166,7 @@ class EventTargetShim {
|
|
171
166
|
this._getEventListenersByType(type).delete(listener);
|
172
167
|
}
|
173
168
|
/**
|
174
|
-
* @param {
|
169
|
+
* @param {Object} event
|
175
170
|
* @private
|
176
171
|
*/
|
177
172
|
|
@@ -179,14 +174,18 @@ class EventTargetShim {
|
|
179
174
|
dispatchEvent(event) {
|
180
175
|
event.target = this;
|
181
176
|
|
182
|
-
this._getEventListenersByType(event.type)
|
177
|
+
const listeners = this._getEventListenersByType(event.type);
|
178
|
+
|
179
|
+
for (const listener of listeners) {
|
180
|
+
listener(event);
|
181
|
+
}
|
183
182
|
}
|
184
183
|
/**
|
185
184
|
* Returns a Set of listeners associated with the passed event type.
|
186
185
|
* If no handlers have been registered, an empty Set is returned.
|
187
186
|
*
|
188
187
|
* @param {string} type The event type.
|
189
|
-
* @return {Set} An array of handler functions.
|
188
|
+
* @return {Set<ListenerCallback>} An array of handler functions.
|
190
189
|
* @private
|
191
190
|
*/
|
192
191
|
|
@@ -214,9 +213,12 @@ class EventTargetShim {
|
|
214
213
|
* @return {boolean}
|
215
214
|
*/
|
216
215
|
|
217
|
-
|
218
|
-
|
219
|
-
|
216
|
+
function urlsMatch(url1, url2) {
|
217
|
+
const {
|
218
|
+
href
|
219
|
+
} = location;
|
220
|
+
return new URL(url1, href).href === new URL(url2, href).href;
|
221
|
+
}
|
220
222
|
|
221
223
|
/*
|
222
224
|
Copyright 2019 Google LLC
|
@@ -233,14 +235,9 @@ const urlsMatch = (url1, url2) => {
|
|
233
235
|
*/
|
234
236
|
|
235
237
|
class WorkboxEvent {
|
236
|
-
/**
|
237
|
-
* @param {string} type
|
238
|
-
* @param {Object} props
|
239
|
-
*/
|
240
238
|
constructor(type, props) {
|
241
|
-
|
242
|
-
|
243
|
-
});
|
239
|
+
this.type = type;
|
240
|
+
Object.assign(this, props);
|
244
241
|
}
|
245
242
|
|
246
243
|
}
|
@@ -276,7 +273,7 @@ const REGISTRATION_TIMEOUT_DURATION = 60000;
|
|
276
273
|
* @memberof module:workbox-window
|
277
274
|
*/
|
278
275
|
|
279
|
-
class Workbox extends
|
276
|
+
class Workbox extends WorkboxEventTarget {
|
280
277
|
/**
|
281
278
|
* Creates a new Workbox instance with a script URL and service worker
|
282
279
|
* options. The script URL and options are the same as those used when
|
@@ -290,18 +287,208 @@ class Workbox extends EventTargetShim {
|
|
290
287
|
*/
|
291
288
|
constructor(scriptURL, registerOptions = {}) {
|
292
289
|
super();
|
293
|
-
this.
|
294
|
-
this._registerOptions = registerOptions;
|
290
|
+
this._registerOptions = {};
|
295
291
|
this._updateFoundCount = 0; // Deferreds we can resolve later.
|
296
292
|
|
297
293
|
this._swDeferred = new Deferred();
|
298
294
|
this._activeDeferred = new Deferred();
|
299
|
-
this._controllingDeferred = new Deferred();
|
295
|
+
this._controllingDeferred = new Deferred();
|
296
|
+
this._registrationTime = 0;
|
297
|
+
/**
|
298
|
+
* @private
|
299
|
+
*/
|
300
|
+
|
301
|
+
this._onUpdateFound = () => {
|
302
|
+
// `this._registration` will never be `undefined` after an update is found.
|
303
|
+
const registration = this._registration;
|
304
|
+
const installingSW = registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
|
305
|
+
// different from the current controlling SW's script URL, we know any
|
306
|
+
// successful registration calls will trigger an `updatefound` event.
|
307
|
+
// But if the registered script URL is the same as the current controlling
|
308
|
+
// SW's script URL, we'll only get an `updatefound` event if the file
|
309
|
+
// changed since it was last registered. This can be a problem if the user
|
310
|
+
// opens up the same page in a different tab, and that page registers
|
311
|
+
// a SW that triggers an update. It's a problem because this page has no
|
312
|
+
// good way of knowing whether the `updatefound` event came from the SW
|
313
|
+
// script it registered or from a registration attempt made by a newer
|
314
|
+
// version of the page running in another tab.
|
315
|
+
// To minimize the possibility of a false positive, we use the logic here:
|
316
|
+
|
317
|
+
let updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
|
318
|
+
// add the `updatefound` event listener until the `register()` call, if
|
319
|
+
// `_updateFoundCount` is > 0 then it means this method has already
|
320
|
+
// been called, thus this SW must be external
|
321
|
+
this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
|
322
|
+
// instance's script URL, we know it's definitely not from our
|
323
|
+
// registration.
|
324
|
+
!urlsMatch(installingSW.scriptURL, this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
|
325
|
+
// Any `updatefound` event that occurs long after our registration is
|
326
|
+
// assumed to be external.
|
327
|
+
performance.now() > this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
|
328
|
+
// triggered by this instance.
|
329
|
+
true : false;
|
330
|
+
|
331
|
+
if (updateLikelyTriggeredExternally) {
|
332
|
+
this._externalSW = installingSW;
|
333
|
+
registration.removeEventListener('updatefound', this._onUpdateFound);
|
334
|
+
} else {
|
335
|
+
// If the update was not triggered externally we know the installing
|
336
|
+
// SW is the one we registered, so we set it.
|
337
|
+
this._sw = installingSW;
|
338
|
+
|
339
|
+
this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
|
340
|
+
// callback for, but we do log messages for it in development.
|
341
|
+
|
342
|
+
|
343
|
+
{
|
344
|
+
if (navigator.serviceWorker.controller) {
|
345
|
+
logger.log('Updated service worker found. Installing now...');
|
346
|
+
} else {
|
347
|
+
logger.log('Service worker is installing...');
|
348
|
+
}
|
349
|
+
}
|
350
|
+
} // Increment the `updatefound` count, so future invocations of this
|
351
|
+
// method can be sure they were triggered externally.
|
352
|
+
|
353
|
+
|
354
|
+
++this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
|
355
|
+
// triggered externally, since we have callbacks for both.
|
356
|
+
|
357
|
+
installingSW.addEventListener('statechange', this._onStateChange);
|
358
|
+
};
|
359
|
+
/**
|
360
|
+
* @private
|
361
|
+
* @param {Event} originalEvent
|
362
|
+
*/
|
363
|
+
|
364
|
+
|
365
|
+
this._onStateChange = originalEvent => {
|
366
|
+
// `this._registration` will never be `undefined` after an update is found.
|
367
|
+
const registration = this._registration;
|
368
|
+
const sw = originalEvent.target;
|
369
|
+
const {
|
370
|
+
state
|
371
|
+
} = sw;
|
372
|
+
const isExternal = sw === this._externalSW;
|
373
|
+
const eventPrefix = isExternal ? 'external' : '';
|
374
|
+
const eventProps = {
|
375
|
+
sw,
|
376
|
+
originalEvent
|
377
|
+
};
|
378
|
+
|
379
|
+
if (!isExternal && this._isUpdate) {
|
380
|
+
eventProps.isUpdate = true;
|
381
|
+
}
|
382
|
+
|
383
|
+
this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
|
384
|
+
|
385
|
+
if (state === 'installed') {
|
386
|
+
// This timeout is used to ignore cases where the service worker calls
|
387
|
+
// `skipWaiting()` in the install event, thus moving it directly in the
|
388
|
+
// activating state. (Since all service workers *must* go through the
|
389
|
+
// waiting phase, the only way to detect `skipWaiting()` called in the
|
390
|
+
// install event is to observe that the time spent in the waiting phase
|
391
|
+
// is very short.)
|
392
|
+
// NOTE: we don't need separate timeouts for the own and external SWs
|
393
|
+
// since they can't go through these phases at the same time.
|
394
|
+
this._waitingTimeout = self.setTimeout(() => {
|
395
|
+
// Ensure the SW is still waiting (it may now be redundant).
|
396
|
+
if (state === 'installed' && registration.waiting === sw) {
|
397
|
+
this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
|
398
|
+
|
399
|
+
{
|
400
|
+
if (isExternal) {
|
401
|
+
logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
|
402
|
+
} else {
|
403
|
+
logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
|
404
|
+
}
|
405
|
+
}
|
406
|
+
}
|
407
|
+
}, WAITING_TIMEOUT_DURATION);
|
408
|
+
} else if (state === 'activating') {
|
409
|
+
clearTimeout(this._waitingTimeout);
|
410
|
+
|
411
|
+
if (!isExternal) {
|
412
|
+
this._activeDeferred.resolve(sw);
|
413
|
+
}
|
414
|
+
}
|
300
415
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
416
|
+
{
|
417
|
+
switch (state) {
|
418
|
+
case 'installed':
|
419
|
+
if (isExternal) {
|
420
|
+
logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
|
421
|
+
} else {
|
422
|
+
logger.log('Registered service worker installed.');
|
423
|
+
}
|
424
|
+
|
425
|
+
break;
|
426
|
+
|
427
|
+
case 'activated':
|
428
|
+
if (isExternal) {
|
429
|
+
logger.warn('An external service worker has activated.');
|
430
|
+
} else {
|
431
|
+
logger.log('Registered service worker activated.');
|
432
|
+
|
433
|
+
if (sw !== navigator.serviceWorker.controller) {
|
434
|
+
logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
break;
|
439
|
+
|
440
|
+
case 'redundant':
|
441
|
+
if (sw === this._compatibleControllingSW) {
|
442
|
+
logger.log('Previously controlling service worker now redundant!');
|
443
|
+
} else if (!isExternal) {
|
444
|
+
logger.log('Registered service worker now redundant!');
|
445
|
+
}
|
446
|
+
|
447
|
+
break;
|
448
|
+
}
|
449
|
+
}
|
450
|
+
};
|
451
|
+
/**
|
452
|
+
* @private
|
453
|
+
* @param {Event} originalEvent
|
454
|
+
*/
|
455
|
+
|
456
|
+
|
457
|
+
this._onControllerChange = originalEvent => {
|
458
|
+
const sw = this._sw;
|
459
|
+
|
460
|
+
if (sw === navigator.serviceWorker.controller) {
|
461
|
+
this.dispatchEvent(new WorkboxEvent('controlling', {
|
462
|
+
sw,
|
463
|
+
originalEvent,
|
464
|
+
isUpdate: this._isUpdate
|
465
|
+
}));
|
466
|
+
|
467
|
+
{
|
468
|
+
logger.log('Registered service worker now controlling this page.');
|
469
|
+
}
|
470
|
+
|
471
|
+
this._controllingDeferred.resolve(sw);
|
472
|
+
}
|
473
|
+
};
|
474
|
+
/**
|
475
|
+
* @private
|
476
|
+
* @param {Event} originalEvent
|
477
|
+
*/
|
478
|
+
|
479
|
+
|
480
|
+
this._onMessage = originalEvent => {
|
481
|
+
const {
|
482
|
+
data
|
483
|
+
} = originalEvent;
|
484
|
+
this.dispatchEvent(new WorkboxEvent('message', {
|
485
|
+
data,
|
486
|
+
originalEvent
|
487
|
+
}));
|
488
|
+
};
|
489
|
+
|
490
|
+
this._scriptURL = scriptURL;
|
491
|
+
this._registerOptions = registerOptions;
|
305
492
|
}
|
306
493
|
/**
|
307
494
|
* Registers a service worker for this instances script URL and service
|
@@ -471,7 +658,7 @@ class Workbox extends EventTargetShim {
|
|
471
658
|
async getSW() {
|
472
659
|
// If `this._sw` is set, resolve with that as we want `getSW()` to
|
473
660
|
// return the correct (new) service worker if an update is found.
|
474
|
-
return this._sw
|
661
|
+
return this._sw !== undefined ? this._sw : this._swDeferred.promise;
|
475
662
|
}
|
476
663
|
/**
|
477
664
|
* Sends the passed data object to the service worker registered by this
|
@@ -506,6 +693,8 @@ class Workbox extends EventTargetShim {
|
|
506
693
|
|
507
694
|
if (controller && urlsMatch(controller.scriptURL, this._scriptURL)) {
|
508
695
|
return controller;
|
696
|
+
} else {
|
697
|
+
return undefined;
|
509
698
|
}
|
510
699
|
}
|
511
700
|
/**
|
@@ -547,205 +736,8 @@ class Workbox extends EventTargetShim {
|
|
547
736
|
meta: 'workbox-window'
|
548
737
|
});
|
549
738
|
}
|
550
|
-
/**
|
551
|
-
* @private
|
552
|
-
*/
|
553
|
-
|
554
|
-
|
555
|
-
_onUpdateFound() {
|
556
|
-
const installingSW = this._registration.installing; // If the script URL passed to `navigator.serviceWorker.register()` is
|
557
|
-
// different from the current controlling SW's script URL, we know any
|
558
|
-
// successful registration calls will trigger an `updatefound` event.
|
559
|
-
// But if the registered script URL is the same as the current controlling
|
560
|
-
// SW's script URL, we'll only get an `updatefound` event if the file
|
561
|
-
// changed since it was last registered. This can be a problem if the user
|
562
|
-
// opens up the same page in a different tab, and that page registers
|
563
|
-
// a SW that triggers an update. It's a problem because this page has no
|
564
|
-
// good way of knowing whether the `updatefound` event came from the SW
|
565
|
-
// script it registered or from a registration attempt made by a newer
|
566
|
-
// version of the page running in another tab.
|
567
|
-
// To minimize the possibility of a false positive, we use the logic here:
|
568
|
-
|
569
|
-
let updateLikelyTriggeredExternally = // Since we enforce only calling `register()` once, and since we don't
|
570
|
-
// add the `updatefound` event listener until the `register()` call, if
|
571
|
-
// `_updateFoundCount` is > 0 then it means this method has already
|
572
|
-
// been called, thus this SW must be external
|
573
|
-
this._updateFoundCount > 0 || // If the script URL of the installing SW is different from this
|
574
|
-
// instance's script URL, we know it's definitely not from our
|
575
|
-
// registration.
|
576
|
-
!urlsMatch(installingSW.scriptURL, this._scriptURL) || // If all of the above are false, then we use a time-based heuristic:
|
577
|
-
// Any `updatefound` event that occurs long after our registration is
|
578
|
-
// assumed to be external.
|
579
|
-
performance.now() > this._registrationTime + REGISTRATION_TIMEOUT_DURATION ? // If any of the above are not true, we assume the update was
|
580
|
-
// triggered by this instance.
|
581
|
-
true : false;
|
582
|
-
|
583
|
-
if (updateLikelyTriggeredExternally) {
|
584
|
-
this._externalSW = installingSW;
|
585
|
-
|
586
|
-
this._registration.removeEventListener('updatefound', this._onUpdateFound);
|
587
|
-
} else {
|
588
|
-
// If the update was not triggered externally we know the installing
|
589
|
-
// SW is the one we registered, so we set it.
|
590
|
-
this._sw = installingSW;
|
591
|
-
|
592
|
-
this._swDeferred.resolve(installingSW); // The `installing` state isn't something we have a dedicated
|
593
|
-
// callback for, but we do log messages for it in development.
|
594
|
-
|
595
|
-
|
596
|
-
{
|
597
|
-
if (navigator.serviceWorker.controller) {
|
598
|
-
logger.log('Updated service worker found. Installing now...');
|
599
|
-
} else {
|
600
|
-
logger.log('Service worker is installing...');
|
601
|
-
}
|
602
|
-
}
|
603
|
-
} // Increment the `updatefound` count, so future invocations of this
|
604
|
-
// method can be sure they were triggered externally.
|
605
|
-
|
606
|
-
|
607
|
-
++this._updateFoundCount; // Add a `statechange` listener regardless of whether this update was
|
608
|
-
// triggered externally, since we have callbacks for both.
|
609
|
-
|
610
|
-
installingSW.addEventListener('statechange', this._onStateChange);
|
611
|
-
}
|
612
|
-
/**
|
613
|
-
* @private
|
614
|
-
* @param {Event} originalEvent
|
615
|
-
*/
|
616
|
-
|
617
|
-
|
618
|
-
_onStateChange(originalEvent) {
|
619
|
-
const sw = originalEvent.target;
|
620
|
-
const {
|
621
|
-
state
|
622
|
-
} = sw;
|
623
|
-
const isExternal = sw === this._externalSW;
|
624
|
-
const eventPrefix = isExternal ? 'external' : '';
|
625
|
-
const eventProps = {
|
626
|
-
sw,
|
627
|
-
originalEvent
|
628
|
-
};
|
629
|
-
|
630
|
-
if (!isExternal && this._isUpdate) {
|
631
|
-
eventProps.isUpdate = true;
|
632
|
-
}
|
633
|
-
|
634
|
-
this.dispatchEvent(new WorkboxEvent(eventPrefix + state, eventProps));
|
635
|
-
|
636
|
-
if (state === 'installed') {
|
637
|
-
// This timeout is used to ignore cases where the service worker calls
|
638
|
-
// `skipWaiting()` in the install event, thus moving it directly in the
|
639
|
-
// activating state. (Since all service workers *must* go through the
|
640
|
-
// waiting phase, the only way to detect `skipWaiting()` called in the
|
641
|
-
// install event is to observe that the time spent in the waiting phase
|
642
|
-
// is very short.)
|
643
|
-
// NOTE: we don't need separate timeouts for the own and external SWs
|
644
|
-
// since they can't go through these phases at the same time.
|
645
|
-
this._waitingTimeout = setTimeout(() => {
|
646
|
-
// Ensure the SW is still waiting (it may now be redundant).
|
647
|
-
if (state === 'installed' && this._registration.waiting === sw) {
|
648
|
-
this.dispatchEvent(new WorkboxEvent(eventPrefix + 'waiting', eventProps));
|
649
|
-
|
650
|
-
{
|
651
|
-
if (isExternal) {
|
652
|
-
logger.warn('An external service worker has installed but is ' + 'waiting for this client to close before activating...');
|
653
|
-
} else {
|
654
|
-
logger.warn('The service worker has installed but is waiting ' + 'for existing clients to close before activating...');
|
655
|
-
}
|
656
|
-
}
|
657
|
-
}
|
658
|
-
}, WAITING_TIMEOUT_DURATION);
|
659
|
-
} else if (state === 'activating') {
|
660
|
-
clearTimeout(this._waitingTimeout);
|
661
|
-
|
662
|
-
if (!isExternal) {
|
663
|
-
this._activeDeferred.resolve(sw);
|
664
|
-
}
|
665
|
-
}
|
666
|
-
|
667
|
-
{
|
668
|
-
switch (state) {
|
669
|
-
case 'installed':
|
670
|
-
if (isExternal) {
|
671
|
-
logger.warn('An external service worker has installed. ' + 'You may want to suggest users reload this page.');
|
672
|
-
} else {
|
673
|
-
logger.log('Registered service worker installed.');
|
674
|
-
}
|
675
|
-
|
676
|
-
break;
|
677
|
-
|
678
|
-
case 'activated':
|
679
|
-
if (isExternal) {
|
680
|
-
logger.warn('An external service worker has activated.');
|
681
|
-
} else {
|
682
|
-
logger.log('Registered service worker activated.');
|
683
|
-
|
684
|
-
if (sw !== navigator.serviceWorker.controller) {
|
685
|
-
logger.warn('The registered service worker is active but ' + 'not yet controlling the page. Reload or run ' + '`clients.claim()` in the service worker.');
|
686
|
-
}
|
687
|
-
}
|
688
|
-
|
689
|
-
break;
|
690
|
-
|
691
|
-
case 'redundant':
|
692
|
-
if (sw === this._compatibleControllingSW) {
|
693
|
-
logger.log('Previously controlling service worker now redundant!');
|
694
|
-
} else if (!isExternal) {
|
695
|
-
logger.log('Registered service worker now redundant!');
|
696
|
-
}
|
697
|
-
|
698
|
-
break;
|
699
|
-
}
|
700
|
-
}
|
701
|
-
}
|
702
|
-
/**
|
703
|
-
* @private
|
704
|
-
* @param {Event} originalEvent
|
705
|
-
*/
|
706
|
-
|
707
|
-
|
708
|
-
_onControllerChange(originalEvent) {
|
709
|
-
const sw = this._sw;
|
710
|
-
|
711
|
-
if (sw === navigator.serviceWorker.controller) {
|
712
|
-
this.dispatchEvent(new WorkboxEvent('controlling', {
|
713
|
-
sw,
|
714
|
-
originalEvent
|
715
|
-
}));
|
716
|
-
|
717
|
-
{
|
718
|
-
logger.log('Registered service worker now controlling this page.');
|
719
|
-
}
|
720
|
-
|
721
|
-
this._controllingDeferred.resolve(sw);
|
722
|
-
}
|
723
|
-
}
|
724
|
-
/**
|
725
|
-
* @private
|
726
|
-
* @param {Event} originalEvent
|
727
|
-
*/
|
728
|
-
|
729
|
-
|
730
|
-
_onMessage(originalEvent) {
|
731
|
-
const {
|
732
|
-
data
|
733
|
-
} = originalEvent;
|
734
|
-
this.dispatchEvent(new WorkboxEvent('message', {
|
735
|
-
data,
|
736
|
-
originalEvent
|
737
|
-
}));
|
738
|
-
}
|
739
739
|
|
740
740
|
} // The jsdoc comments below outline the events this instance may dispatch:
|
741
741
|
|
742
|
-
/*
|
743
|
-
Copyright 2019 Google LLC
|
744
|
-
|
745
|
-
Use of this source code is governed by an MIT-style
|
746
|
-
license that can be found in the LICENSE file or at
|
747
|
-
https://opensource.org/licenses/MIT.
|
748
|
-
*/
|
749
|
-
|
750
742
|
export { Workbox, messageSW };
|
751
743
|
//# sourceMappingURL=workbox-window.dev.mjs.map
|