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.umd.js","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":";;;;;;IAAA;IACA,IAAI;IACAA,EAAAA,IAAI,CAAC,8BAAD,CAAJ,IAAwCC,CAAC,EAAzC;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IACA;;;;;;;;;;;;;;;;AAeA,IAAO,SAASC,SAAT,CAAmBC,EAAnB,EAAuBC,IAAvB,EAA6B;IAChC,SAAO,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;IAC5B,QAAIC,cAAc,GAAG,IAAIC,cAAJ,EAArB;;IACAD,IAAAA,cAAc,CAACE,KAAf,CAAqBC,SAArB,GAAiC,UAACC,KAAD,EAAW;IACxCL,MAAAA,OAAO,CAACK,KAAK,CAACP,IAAP,CAAP;IACH,KAFD;;IAGAD,IAAAA,EAAE,CAACS,WAAH,CAAeR,IAAf,EAAqB,CAACG,cAAc,CAACM,KAAhB,CAArB;IACH,GANM,CAAP;IAOH;;;;;;;;;;;;;;;;;;;;;;;;IC/BD;IACA,IAAI;IACAd,EAAAA,IAAI,CAAC,4BAAD,CAAJ,IAAsCC,CAAC,EAAvC;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICJV;;;;;;;AAOA,IACA;;;;;;;;;QAQMa;IACF;;;IAGA,oBAAc;IAAA;;IACV,OAAKC,OAAL,GAAe,IAAIV,OAAJ,CAA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,MAAAA,IAAI,EAAE,cADI;IAEV6F,MAAAA,IAAI,EAAE;IAFI,KAAL,CAAT;IAIH;;;;4BAzGY;IACT,aAAO,KAAKvD,eAAL,CAAqBpE,OAA5B;IACH;IACD;;;;;;;;;;;;;;;4BAYkB;IACd,aAAO,KAAKqE,oBAAL,CAA0BrE,OAAjC;IACH;;;;MAjUiB2B;;;;;;;;;;;;;"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
try{self["workbox:window:5.0.0-alpha.0"]&&_()}catch(n){}function n(n,t){return new Promise(function(r){var e=new MessageChannel;e.port1.onmessage=function(n){r(n.data)},n.postMessage(t,[e.port2])})}function t(n,t){for(var r=0;r<t.length;r++){var e=t[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}try{self["workbox:core:5.0.0-alpha.1"]&&_()}catch(n){}var r=function(){var n=this;this.promise=new Promise(function(t,r){n.resolve=t,n.reject=r})};function e(n,t){var r=location.href;return new URL(n,r).href===new URL(t,r).href}var i=function(n,t){this.type=n,Object.assign(this,t)};function o(n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function a(n,t,r){return r?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function u(){}var c=200,f=6e4,s=function(s){var v,h;function l(n,t){var o;return void 0===t&&(t={}),(o=s.call(this)||this).t={},o.i=0,o.o=new r,o.u=new r,o.s=new r,o.v=0,o.h=function(){var n=o.l,t=n.installing;o.i>0||!e(t.scriptURL,o.g)||performance.now()>o.v+f?(o.m=t,n.removeEventListener("updatefound",o.h)):(o.p=t,o.o.resolve(t)),++o.i,t.addEventListener("statechange",o.P)},o.P=function(n){var t=o.l,r=n.target,e=r.state,a=r===o.m,u=a?"external":"",f={sw:r,originalEvent:n};!a&&o.k&&(f.isUpdate=!0),o.dispatchEvent(new i(u+e,f)),"installed"===e?o.B=self.setTimeout(function(){"installed"===e&&t.waiting===r&&o.dispatchEvent(new i(u+"waiting",f))},c):"activating"===e&&(clearTimeout(o.B),a||o.u.resolve(r))},o.O=function(n){var t=o.p;t===navigator.serviceWorker.controller&&(o.dispatchEvent(new i("controlling",{sw:t,originalEvent:n,isUpdate:o.k})),o.s.resolve(t))},o.R=function(n){var t=n.data;o.dispatchEvent(new i("message",{data:t,originalEvent:n}))},o.g=n,o.t=t,o}h=s,(v=l).prototype=Object.create(h.prototype),v.prototype.constructor=v,v.__proto__=h;var w,g,d,m=l.prototype;return m.register=o(function(n){var t,r,o=this,c=(void 0===n?{}:n).immediate,f=void 0!==c&&c;return t=function(){return o.k=Boolean(navigator.serviceWorker.controller),o.j=o.C(),a(o.L(),function(n){o.l=n,o.j&&(o.p=o.j,o.u.resolve(o.j),o.s.resolve(o.j),o.U(o.j),o.j.addEventListener("statechange",o.P,{once:!0}));var t=o.l.waiting;return t&&e(t.scriptURL,o.g)&&(o.p=t,Promise.resolve().then(function(){o.dispatchEvent(new i("waiting",{sw:t,wasWaitingBeforeRegister:!0}))})),o.p&&o.o.resolve(o.p),o.l.addEventListener("updatefound",o.h),navigator.serviceWorker.addEventListener("controllerchange",o.O,{once:!0}),"BroadcastChannel"in self&&(o.W=new BroadcastChannel("workbox"),o.W.addEventListener("message",o.R)),navigator.serviceWorker.addEventListener("message",o.R),o.l})},(r=function(){if(!f&&"complete"!==document.readyState)return function(n,t){if(!t)return n&&n.then?n.then(u):Promise.resolve()}(new Promise(function(n){return addEventListener("load",n)}))}())&&r.then?r.then(t):t(r)}),m.getSW=o(function(){return void 0!==this.p?this.p:this.o.promise}),m.messageSW=o(function(t){return a(this.getSW(),function(r){return n(r,t)})}),m.C=function(){var n=navigator.serviceWorker.controller;return n&&e(n.scriptURL,this.g)?n:void 0},m.L=o(function(){var n=this;return function(n,t){try{var r=n()}catch(n){return t(n)}return r&&r.then?r.then(void 0,t):r}(function(){return a(navigator.serviceWorker.register(n.g,n.t),function(t){return n.v=performance.now(),t})},function(n){throw n})}),m.U=function(t){n(t,{type:"WINDOW_READY",meta:"workbox-window"})},w=l,(g=[{key:"active",get:function(){return this.u.promise}},{key:"controlling",get:function(){return this.s.promise}}])&&t(w.prototype,g),d&&t(w,d),l}(function(){function n(){this._={}}var t=n.prototype;return t.addEventListener=function(n,t){this.A(n).add(t)},t.removeEventListener=function(n,t){this.A(n).delete(t)},t.dispatchEvent=function(n){n.target=this;var t=this.A(n.type),r=Array.isArray(t),e=0;for(t=r?t:t[Symbol.iterator]();;){var i;if(r){if(e>=t.length)break;i=t[e++]}else{if((e=t.next()).done)break;i=e.value}i(n)}},t.A=function(n){return this._[n]=this._[n]||new Set},n}());export{s as Workbox,n as messageSW};
|
2
|
+
//# sourceMappingURL=workbox-window.prod.es5.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-window.prod.es5.mjs","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js","../utils/WorkboxEventTarget.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\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","/*\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"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","postMessage","port2","Deferred","promise","reject","_this","urlsMatch","url1","url2","href","location","URL","WorkboxEvent","type","props","Object","assign","this","f","args","i","arguments","length","apply","value","then","direct","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_onUpdateFound","registration","_registration","installingSW","installing","_scriptURL","performance","now","_externalSW","removeEventListener","_sw","addEventListener","_onStateChange","originalEvent","target","state","isExternal","eventPrefix","eventProps","_isUpdate","isUpdate","dispatchEvent","_waitingTimeout","setTimeout","waiting","clearTimeout","_onControllerChange","navigator","serviceWorker","controller","_onMessage","register","result","immediate","Boolean","_compatibleControllingSW","_this2","_getControllingSWIfCompatible","_registerScript","_reportWindowReady","once","waitingSW","wasWaitingBeforeRegister","_broadcastChannel","BroadcastChannel","document","readyState","res","body","getSW","undefined","recover","_this5","reg","error","meta","_eventListenerRegistry","listener","_getEventListenersByType","add","delete","Set"],"mappings":"AACA,IACIA,KAAK,iCAAmCC,IAE5C,MAAOC,ICmBA,SAASC,EAAUC,EAAIC,UACnB,IAAIC,QAAQ,SAACC,OACZC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAY,SAACC,GAC9BL,EAAQK,EAAMP,OAElBD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,gLC5B7C,IACId,KAAK,+BAAiCC,IAE1C,MAAOC,QCYDa,EAIF,2BACSC,QAAU,IAAIV,QAAQ,SAACC,EAASU,GACjCC,EAAKX,QAAUA,EACfW,EAAKD,OAASA,KCNnB,SAASE,EAAUC,EAAMC,OACpBC,EAASC,SAATD,YACD,IAAIE,IAAIJ,EAAME,GAAMA,OAAS,IAAIE,IAAIH,EAAMC,GAAMA,KCL5D,IAAaG,EACT,SAAYC,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EAAMc,8DACpB,uFACrBd,OAWjBiG,WAAyBnF,UACdI,KAAK6E,EAAuBjF,GAC9BI,KAAK6E,EAAuBjF,IAAS,IAAIsF,OAzCtD"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
try{self["workbox:window:5.0.0-alpha.0"]&&_()}catch(t){}function t(t,s){return new Promise(i=>{let e=new MessageChannel;e.port1.onmessage=(t=>{i(t.data)}),t.postMessage(s,[e.port2])})}try{self["workbox:core:5.0.0-alpha.1"]&&_()}catch(t){}class s{constructor(){this.promise=new Promise((t,s)=>{this.resolve=t,this.reject=s})}}class i{constructor(){this.t={}}addEventListener(t,s){this.s(t).add(s)}removeEventListener(t,s){this.s(t).delete(s)}dispatchEvent(t){t.target=this;const s=this.s(t.type);for(const i of s)i(t)}s(t){return this.t[t]=this.t[t]||new Set}}function e(t,s){const{href:i}=location;return new URL(t,i).href===new URL(s,i).href}class n{constructor(t,s){this.type=t,Object.assign(this,s)}}const h=200,a=6e4;class r extends i{constructor(t,i={}){super(),this.i={},this.h=0,this.o=new s,this.l=new s,this.g=new s,this.u=0,this.v=(()=>{const t=this.m,s=t.installing;this.h>0||!e(s.scriptURL,this.p)||performance.now()>this.u+a?(this.W=s,t.removeEventListener("updatefound",this.v)):(this._=s,this.o.resolve(s)),++this.h,s.addEventListener("statechange",this.L)}),this.L=(t=>{const s=this.m,i=t.target,{state:e}=i,a=i===this.W,r=a?"external":"",o={sw:i,originalEvent:t};!a&&this.B&&(o.isUpdate=!0),this.dispatchEvent(new n(r+e,o)),"installed"===e?this.C=self.setTimeout(()=>{"installed"===e&&s.waiting===i&&this.dispatchEvent(new n(r+"waiting",o))},h):"activating"===e&&(clearTimeout(this.C),a||this.l.resolve(i))}),this.R=(t=>{const s=this._;s===navigator.serviceWorker.controller&&(this.dispatchEvent(new n("controlling",{sw:s,originalEvent:t,isUpdate:this.B})),this.g.resolve(s))}),this.S=(t=>{const{data:s}=t;this.dispatchEvent(new n("message",{data:s,originalEvent:t}))}),this.p=t,this.i=i}async register({immediate:t=!1}={}){t||"complete"===document.readyState||await new Promise(t=>addEventListener("load",t)),this.B=Boolean(navigator.serviceWorker.controller),this.P=this.U(),this.m=await this.k(),this.P&&(this._=this.P,this.l.resolve(this.P),this.g.resolve(this.P),this.D(this.P),this.P.addEventListener("statechange",this.L,{once:!0}));const s=this.m.waiting;return s&&e(s.scriptURL,this.p)&&(this._=s,Promise.resolve().then(()=>{this.dispatchEvent(new n("waiting",{sw:s,wasWaitingBeforeRegister:!0}))})),this._&&this.o.resolve(this._),this.m.addEventListener("updatefound",this.v),navigator.serviceWorker.addEventListener("controllerchange",this.R,{once:!0}),"BroadcastChannel"in self&&(this.I=new BroadcastChannel("workbox"),this.I.addEventListener("message",this.S)),navigator.serviceWorker.addEventListener("message",this.S),this.m}get active(){return this.l.promise}get controlling(){return this.g.promise}async getSW(){return void 0!==this._?this._:this.o.promise}async messageSW(s){return t(await this.getSW(),s)}U(){const t=navigator.serviceWorker.controller;return t&&e(t.scriptURL,this.p)?t:void 0}async k(){try{const t=await navigator.serviceWorker.register(this.p,this.i);return this.u=performance.now(),t}catch(t){throw t}}D(s){t(s,{type:"WINDOW_READY",meta:"workbox-window"})}}export{r as Workbox,t as messageSW};
|
2
|
+
//# sourceMappingURL=workbox-window.prod.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-window.prod.mjs","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../utils/WorkboxEventTarget.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js"],"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\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","constructor","promise","reject","WorkboxEventTarget","_eventListenerRegistry","addEventListener","type","listener","_getEventListenersByType","add","removeEventListener","delete","dispatchEvent","target","this","listeners","Set","urlsMatch","url1","url2","href","location","URL","WorkboxEvent","props","Object","assign","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_onUpdateFound","registration","_registration","installingSW","installing","_scriptURL","performance","now","_externalSW","_sw","_onStateChange","originalEvent","state","isExternal","eventPrefix","eventProps","_isUpdate","isUpdate","_waitingTimeout","setTimeout","waiting","clearTimeout","_onControllerChange","navigator","serviceWorker","controller","_onMessage","immediate","document","readyState","res","Boolean","_compatibleControllingSW","_getControllingSWIfCompatible","_registerScript","_reportWindowReady","once","waitingSW","then","wasWaitingBeforeRegister","_broadcastChannel","BroadcastChannel","undefined","getSW","reg","register","error","meta"],"mappings":"AACA,IACIA,KAAK,iCAAmCC,IAE5C,MAAOC,ICmBA,SAASC,EAAUC,EAAIC,UACnB,IAAIC,QAASC,QACZC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAaC,CAAAA,IAC9BL,EAAQK,EAAMP,QAElBD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,UC5B7C,IAC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U0D,EAAU7C,UAAWhB,KAAK6B,UAG5CI,EAAM4B,EAGXrF,QAAQC,UAAUqF,KAAK,UACdhE,cAAc,IAAIW,EAAa,UAAW,CAC3CnC,GAAIuF,EACJE,0BAA0B,QASlC/D,KAAKiC,QACAb,EAAY3C,QAAQuB,KAAKiC,QAyB7BP,EAAcnC,iBAAiB,cAAeS,KAAKwB,GACxDuB,UAAUC,cAAczD,iBAAiB,mBAAoBS,KAAK8C,EAAqB,CAAEc,MAAM,IAE3F,qBAAsB1F,YACjB8F,EAAoB,IAAIC,iBAAiB,gBACzCD,EAAkBzE,iBAAiB,UAAWS,KAAKkD,IAE5DH,UAAUC,cAAczD,iBAAiB,UAAWS,KAAKkD,GAClDlD,KAAK0B,sBAYL1B,KAAKqB,EAAgBlC,iCAerBa,KAAKsB,EAAqBnC,kCAoBb+E,IAAblE,KAAKiC,EAAoBjC,KAAKiC,EAAMjC,KAAKoB,EAAYjC,wBAehDZ,UAELF,QADU2B,KAAKmE,QACD5F,GASzBkF,UACUR,EAAaF,UAAUC,cAAcC,kBACvCA,GAAc9C,EAAU8C,EAAWjC,UAAWhB,KAAK6B,GAC5CoB,6BAcDmB,QAAYrB,UAAUC,cAAcqB,SAASrE,KAAK6B,EAAY7B,KAAKkB,eAIpEK,EAAoBO,YAAYC,MAC9BqC,EAEX,MAAOE,SAKGA,GASdX,EAAmBrF,GACfD,EAAUC,EAAI,CACVkB,KAAM,eACN+E,KAAM"}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n=n||self).workbox={})}(this,function(n){"use strict";try{self["workbox:window:5.0.0-alpha.0"]&&_()}catch(n){}function t(n,t){return new Promise(function(e){var i=new MessageChannel;i.port1.onmessage=function(n){e(n.data)},n.postMessage(t,[i.port2])})}function e(n,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}try{self["workbox:core:5.0.0-alpha.1"]&&_()}catch(n){}var i=function(){var n=this;this.promise=new Promise(function(t,e){n.resolve=t,n.reject=e})};function r(n,t){var e=location.href;return new URL(n,e).href===new URL(t,e).href}var o=function(n,t){this.type=n,Object.assign(this,t)};function a(n){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{return Promise.resolve(n.apply(this,t))}catch(n){return Promise.reject(n)}}}function u(n,t,e){return e?t?t(n):n:(n&&n.then||(n=Promise.resolve(n)),t?n.then(t):n)}function c(){}var f=200,s=6e4,v=function(n){var v,h;function l(t,e){var a;return void 0===e&&(e={}),(a=n.call(this)||this).t={},a.i=0,a.o=new i,a.u=new i,a.s=new i,a.v=0,a.h=function(){var n=a.l,t=n.installing;a.i>0||!r(t.scriptURL,a.g)||performance.now()>a.v+s?(a.m=t,n.removeEventListener("updatefound",a.h)):(a.p=t,a.o.resolve(t)),++a.i,t.addEventListener("statechange",a.P)},a.P=function(n){var t=a.l,e=n.target,i=e.state,r=e===a.m,u=r?"external":"",c={sw:e,originalEvent:n};!r&&a.k&&(c.isUpdate=!0),a.dispatchEvent(new o(u+i,c)),"installed"===i?a.j=self.setTimeout(function(){"installed"===i&&t.waiting===e&&a.dispatchEvent(new o(u+"waiting",c))},f):"activating"===i&&(clearTimeout(a.j),r||a.u.resolve(e))},a.O=function(n){var t=a.p;t===navigator.serviceWorker.controller&&(a.dispatchEvent(new o("controlling",{sw:t,originalEvent:n,isUpdate:a.k})),a.s.resolve(t))},a._=function(n){var t=n.data;a.dispatchEvent(new o("message",{data:t,originalEvent:n}))},a.g=t,a.t=e,a}h=n,(v=l).prototype=Object.create(h.prototype),v.prototype.constructor=v,v.__proto__=h;var d,w,g,m=l.prototype;return m.register=a(function(n){var t,e,i=this,a=(void 0===n?{}:n).immediate,f=void 0!==a&&a;return t=function(){return i.k=Boolean(navigator.serviceWorker.controller),i.B=i.R(),u(i.C(),function(n){i.l=n,i.B&&(i.p=i.B,i.u.resolve(i.B),i.s.resolve(i.B),i.L(i.B),i.B.addEventListener("statechange",i.P,{once:!0}));var t=i.l.waiting;return t&&r(t.scriptURL,i.g)&&(i.p=t,Promise.resolve().then(function(){i.dispatchEvent(new o("waiting",{sw:t,wasWaitingBeforeRegister:!0}))})),i.p&&i.o.resolve(i.p),i.l.addEventListener("updatefound",i.h),navigator.serviceWorker.addEventListener("controllerchange",i.O,{once:!0}),"BroadcastChannel"in self&&(i.U=new BroadcastChannel("workbox"),i.U.addEventListener("message",i._)),navigator.serviceWorker.addEventListener("message",i._),i.l})},(e=function(){if(!f&&"complete"!==document.readyState)return function(n,t){if(!t)return n&&n.then?n.then(c):Promise.resolve()}(new Promise(function(n){return addEventListener("load",n)}))}())&&e.then?e.then(t):t(e)}),m.getSW=a(function(){return void 0!==this.p?this.p:this.o.promise}),m.messageSW=a(function(n){return u(this.getSW(),function(e){return t(e,n)})}),m.R=function(){var n=navigator.serviceWorker.controller;return n&&r(n.scriptURL,this.g)?n:void 0},m.C=a(function(){var n=this;return function(n,t){try{var e=n()}catch(n){return t(n)}return e&&e.then?e.then(void 0,t):e}(function(){return u(navigator.serviceWorker.register(n.g,n.t),function(t){return n.v=performance.now(),t})},function(n){throw n})}),m.L=function(n){t(n,{type:"WINDOW_READY",meta:"workbox-window"})},d=l,(w=[{key:"active",get:function(){return this.u.promise}},{key:"controlling",get:function(){return this.s.promise}}])&&e(d.prototype,w),g&&e(d,g),l}(function(){function n(){this.W={}}var t=n.prototype;return t.addEventListener=function(n,t){this.A(n).add(t)},t.removeEventListener=function(n,t){this.A(n).delete(t)},t.dispatchEvent=function(n){n.target=this;var t=this.A(n.type),e=Array.isArray(t),i=0;for(t=e?t:t[Symbol.iterator]();;){var r;if(e){if(i>=t.length)break;r=t[i++]}else{if((i=t.next()).done)break;r=i.value}r(n)}},t.A=function(n){return this.W[n]=this.W[n]||new Set},n}());n.Workbox=v,n.messageSW=t,Object.defineProperty(n,"__esModule",{value:!0})});
|
2
|
+
//# sourceMappingURL=workbox-window.prod.umd.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workbox-window.prod.umd.js","sources":["../_version.js","../messageSW.js","../../workbox-core/_version.js","../../workbox-core/_private/Deferred.js","../utils/urlsMatch.js","../utils/WorkboxEvent.js","../Workbox.js","../utils/WorkboxEventTarget.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\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","/*\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"],"names":["self","_","e","messageSW","sw","data","Promise","resolve","messageChannel","MessageChannel","port1","onmessage","event","postMessage","port2","Deferred","promise","reject","_this","urlsMatch","url1","url2","href","location","URL","WorkboxEvent","type","props","Object","assign","this","f","args","i","arguments","length","apply","value","then","direct","WAITING_TIMEOUT_DURATION","REGISTRATION_TIMEOUT_DURATION","Workbox","scriptURL","registerOptions","_registerOptions","_updateFoundCount","_swDeferred","_activeDeferred","_controllingDeferred","_registrationTime","_onUpdateFound","registration","_registration","installingSW","installing","_scriptURL","performance","now","_externalSW","removeEventListener","_sw","addEventListener","_onStateChange","originalEvent","target","state","isExternal","eventPrefix","eventProps","_isUpdate","isUpdate","dispatchEvent","_waitingTimeout","setTimeout","waiting","clearTimeout","_onControllerChange","navigator","serviceWorker","controller","_onMessage","register","result","immediate","Boolean","_compatibleControllingSW","_this2","_getControllingSWIfCompatible","_registerScript","_reportWindowReady","once","waitingSW","wasWaitingBeforeRegister","_broadcastChannel","BroadcastChannel","document","readyState","res","body","getSW","undefined","recover","_this5","reg","error","meta","_eventListenerRegistry","listener","_getEventListenersByType","add","delete","Set"],"mappings":"oMACA,IACIA,KAAK,iCAAmCC,IAE5C,MAAOC,ICmBA,SAASC,EAAUC,EAAIC,UACnB,IAAIC,QAAQ,SAACC,OACZC,EAAiB,IAAIC,eACzBD,EAAeE,MAAMC,UAAY,SAACC,GAC9BL,EAAQK,EAAMP,OAElBD,EAAGS,YAAYR,EAAM,CAACG,EAAeM,gLC5B7C,IACId,KAAK,+BAAiCC,IAE1C,MAAOC,QCYDa,EAIF,2BACSC,QAAU,IAAIV,QAAQ,SAACC,EAASU,GACjCC,EAAKX,QAAUA,EACfW,EAAKD,OAASA,KCNnB,SAASE,EAAUC,EAAMC,OACpBC,EAASC,SAATD,YACD,IAAIE,IAAIJ,EAAME,GAAMA,OAAS,IAAIE,IAAIH,EAAMC,GAAMA,SCL/CG,EACT,SAAYC,EAAMC,QACTD,KAAOA,EACZE,OAAOC,OAAOC,KAAMH,ICqDrB,WAAgBI,UACf,eACD,IAAIC,EAAO,GAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAChDD,EAAKC,GAAKC,UAAUD,cAGb3B,QAAQC,QAAQwB,EAAEK,MAAMN,KAAME,IACpC,MAAM9B,UACAI,QAAQW,OAAOf,KAMlB,WAAgBmC,EAAOC,EAAMC,UAC/BA,EACID,EAAOA,EAAKD,GAASA,GAExBA,GAAUA,EAAMC,OACpBD,EAAQ/B,QAAQC,QAAQ8B,IAElBC,EAAOD,EAAMC,KAAKA,GAAQD,GAugB3B,cAjlBP,IAAMG,EAA2B,IAG3BC,EAAgC,IAiBhCC,iCA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KAAyCiB,EAAY/B,YAe1Db,qBAAUE,YACKyB,KAAKsE,iBAAhBhG,UACCD,EAAUC,EAAIC,SASzBmF,iBACUR,EAAaF,UAAUC,cAAcC,kBACvCA,GAAc7D,EAAU6D,EAAWrC,UAAWb,KAAK0B,GAC5CwB,YAYTS,qBAEqD3D,YAgJxD,SAAgBqE,EAAMG,WAEvBnB,EAASgB,IACZ,MAAMjG,UACAoG,EAAQpG,UAEZiF,GAAUA,EAAO7C,KACb6C,EAAO7C,UAAK,EAAQgE,GAErBnB,uBAzJsBL,UAAUC,cAAcG,SAASqB,EAAK/C,EAAY+C,EAAK1D,YAAnE2D,YAIDtD,EAAoBO,YAAYC,MAC9B8C,cAEJC,SAKGA,QASdf,WAAmBtF,GACfD,EAAUC,EAAI,CACVsB,KAAM,eACNgF,KAAM,gEAtGH5E,KAAKkB,EAAgBhC,mDAerBc,KAAKmB,EAAqBjC,2CCvVzC,6BAEa2F,EAAyB,8BAOlC7C,0BAAiBpC,EAAMkF,QACdC,EAAyBnF,GAAMoF,IAAIF,MAO5ChD,6BAAoBlC,EAAMkF,QACjBC,EAAyBnF,GAAMqF,OAAOH,MAM/CpC,uBAAc5D,GACVA,EAAMqD,OAASnC,WACGA,KAAK+E,EAAyBjG,EAAMc,8DACpB,uFACrBd,OAWjBiG,WAAyBnF,UACdI,KAAK6E,EAAuBjF,GAC9BI,KAAK6E,EAAuBjF,IAAS,IAAIsF,OAzCtD"}
|
metadata
CHANGED
@@ -1,101 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-pwa-workbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7.alpha
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- souldanger
|
8
|
-
- Pan Yuqi
|
9
|
-
- sekiyika
|
10
8
|
autorequire:
|
11
9
|
bindir: bin
|
12
10
|
cert_chain: []
|
13
|
-
date: 2019-
|
11
|
+
date: 2019-07-20 00:00:00.000000000 Z
|
14
12
|
dependencies: []
|
15
|
-
description: "
|
16
|
-
you
|
17
|
-
|
18
|
-
|
13
|
+
description: "A Jekyll plugin that makes your PWA / Website available offline and
|
14
|
+
lets you install on desktop and mobile. \n\t\t\t\t\tIt generates and injects a precache
|
15
|
+
list into a Workbox v5.0.0-alpha.1 service worker and handles the registration process
|
16
|
+
in a secure way."
|
19
17
|
email:
|
20
|
-
-
|
21
|
-
- pyqiverson@gmail.com
|
22
|
-
- pengxing5501854@gmail.com
|
18
|
+
- souldanger.industries@gmail.com
|
23
19
|
executables: []
|
24
20
|
extensions: []
|
25
21
|
extra_rdoc_files: []
|
26
22
|
files:
|
27
23
|
- lib/jekyll-pwa-workbox.rb
|
28
|
-
- lib/vendor/workbox-
|
29
|
-
- lib/vendor/workbox-
|
30
|
-
- lib/vendor/workbox-
|
31
|
-
- lib/vendor/workbox-
|
32
|
-
- lib/vendor/workbox-
|
33
|
-
- lib/vendor/workbox-
|
34
|
-
- lib/vendor/workbox-
|
35
|
-
- lib/vendor/workbox-
|
36
|
-
- lib/vendor/workbox-
|
37
|
-
- lib/vendor/workbox-
|
38
|
-
- lib/vendor/workbox-
|
39
|
-
- lib/vendor/workbox-
|
40
|
-
- lib/vendor/workbox-
|
41
|
-
- lib/vendor/workbox-
|
42
|
-
- lib/vendor/workbox-
|
43
|
-
- lib/vendor/workbox-
|
44
|
-
- lib/vendor/workbox-
|
45
|
-
- lib/vendor/workbox-
|
46
|
-
- lib/vendor/workbox-
|
47
|
-
- lib/vendor/workbox-
|
48
|
-
- lib/vendor/workbox-
|
49
|
-
- lib/vendor/workbox-
|
50
|
-
- lib/vendor/workbox-
|
51
|
-
- lib/vendor/workbox-
|
52
|
-
- lib/vendor/workbox-
|
53
|
-
- lib/vendor/workbox-
|
54
|
-
- lib/vendor/workbox-
|
55
|
-
- lib/vendor/workbox-
|
56
|
-
- lib/vendor/workbox-
|
57
|
-
- lib/vendor/workbox-
|
58
|
-
- lib/vendor/workbox-
|
59
|
-
- lib/vendor/workbox-
|
60
|
-
- lib/vendor/workbox-
|
61
|
-
- lib/vendor/workbox-
|
62
|
-
- lib/vendor/workbox-
|
63
|
-
- lib/vendor/workbox-
|
64
|
-
- lib/vendor/workbox-
|
65
|
-
- lib/vendor/workbox-
|
66
|
-
- lib/vendor/workbox-
|
67
|
-
- lib/vendor/workbox-
|
68
|
-
- lib/vendor/workbox-
|
69
|
-
- lib/vendor/workbox-
|
70
|
-
- lib/vendor/workbox-
|
71
|
-
- lib/vendor/workbox-
|
72
|
-
- lib/vendor/workbox-
|
73
|
-
- lib/vendor/workbox-
|
74
|
-
- lib/vendor/workbox-
|
75
|
-
- lib/vendor/workbox-
|
76
|
-
- lib/vendor/workbox-
|
77
|
-
- lib/vendor/workbox-
|
78
|
-
- lib/vendor/workbox-
|
79
|
-
- lib/vendor/workbox-
|
80
|
-
- lib/vendor/workbox-
|
81
|
-
- lib/vendor/workbox-
|
82
|
-
- lib/vendor/workbox-
|
83
|
-
- lib/vendor/workbox-
|
84
|
-
- lib/vendor/workbox-
|
85
|
-
- lib/vendor/workbox-
|
86
|
-
- lib/vendor/workbox-
|
87
|
-
- lib/vendor/workbox-
|
88
|
-
- lib/vendor/workbox-
|
89
|
-
- lib/vendor/workbox-
|
24
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js
|
25
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.dev.js.map
|
26
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js
|
27
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-background-sync.prod.js.map
|
28
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js
|
29
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.dev.js.map
|
30
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js
|
31
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-broadcast-update.prod.js.map
|
32
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js
|
33
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.dev.js.map
|
34
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js
|
35
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-cacheable-response.prod.js.map
|
36
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js
|
37
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-core.dev.js.map
|
38
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js
|
39
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-core.prod.js.map
|
40
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js
|
41
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.dev.js.map
|
42
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js
|
43
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-expiration.prod.js.map
|
44
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js
|
45
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.dev.js.map
|
46
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js
|
47
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-navigation-preload.prod.js.map
|
48
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js
|
49
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.dev.js.map
|
50
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js
|
51
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-offline-ga.prod.js.map
|
52
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js
|
53
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.dev.js.map
|
54
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js
|
55
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-precaching.prod.js.map
|
56
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js
|
57
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.dev.js.map
|
58
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js
|
59
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-range-requests.prod.js.map
|
60
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js
|
61
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.dev.js.map
|
62
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js
|
63
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-routing.prod.js.map
|
64
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js
|
65
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.dev.js.map
|
66
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js
|
67
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-strategies.prod.js.map
|
68
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js
|
69
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.dev.js.map
|
70
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js
|
71
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-streams.prod.js.map
|
72
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js
|
73
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-sw.js.map
|
74
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs
|
75
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.es5.mjs.map
|
76
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs
|
77
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.mjs.map
|
78
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js
|
79
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.dev.umd.js.map
|
80
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs
|
81
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.es5.mjs.map
|
82
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs
|
83
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.mjs.map
|
84
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js
|
85
|
+
- lib/vendor/workbox-v5.0.0.alpha1/workbox-window.prod.umd.js.map
|
90
86
|
homepage: https://github.com/souldanger/jekyll-pwa-workbox
|
91
87
|
licenses:
|
92
88
|
- MIT
|
93
89
|
metadata:
|
94
90
|
bug_tracker_uri: https://github.com/souldanger/jekyll-pwa-workbox/issues
|
95
|
-
changelog_uri: https://github.com/souldanger/jekyll-pwa-workbox/blob/master/
|
96
|
-
documentation_uri: https://github.com/souldanger/jekyll-pwa-workbox
|
91
|
+
changelog_uri: https://github.com/souldanger/jekyll-pwa-workbox/blob/master/CHANGELOG.md
|
92
|
+
documentation_uri: https://github.com/souldanger/jekyll-pwa-workbox/blob/master/README.md
|
97
93
|
homepage_uri: https://github.com/souldanger/jekyll-pwa-workbox
|
98
|
-
source_code_uri: https://github.com/souldanger/jekyll-pwa-workbox
|
94
|
+
source_code_uri: https://github.com/souldanger/jekyll-pwa-workbox/releases
|
99
95
|
post_install_message:
|
100
96
|
rdoc_options: []
|
101
97
|
require_paths:
|
@@ -107,12 +103,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
103
|
version: '0'
|
108
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
105
|
requirements:
|
110
|
-
- - "
|
106
|
+
- - ">"
|
111
107
|
- !ruby/object:Gem::Version
|
112
|
-
version:
|
108
|
+
version: 1.3.1
|
113
109
|
requirements: []
|
114
|
-
|
115
|
-
rubygems_version: 2.7.6
|
110
|
+
rubygems_version: 3.0.3
|
116
111
|
signing_key:
|
117
112
|
specification_version: 4
|
118
113
|
summary: PWA Workbox Service Worker for Jekyll.
|
@@ -1,822 +0,0 @@
|
|
1
|
-
this.workbox = this.workbox || {};
|
2
|
-
this.workbox.backgroundSync = (function (exports, WorkboxError_mjs, logger_mjs, assert_mjs, getFriendlyURL_mjs, DBWrapper_mjs) {
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
try {
|
6
|
-
self['workbox:background-sync:4.3.1'] && _();
|
7
|
-
} catch (e) {} // eslint-disable-line
|
8
|
-
|
9
|
-
/*
|
10
|
-
Copyright 2018 Google LLC
|
11
|
-
|
12
|
-
Use of this source code is governed by an MIT-style
|
13
|
-
license that can be found in the LICENSE file or at
|
14
|
-
https://opensource.org/licenses/MIT.
|
15
|
-
*/
|
16
|
-
const DB_VERSION = 3;
|
17
|
-
const DB_NAME = 'workbox-background-sync';
|
18
|
-
const OBJECT_STORE_NAME = 'requests';
|
19
|
-
const INDEXED_PROP = 'queueName';
|
20
|
-
/**
|
21
|
-
* A class to manage storing requests from a Queue in IndexedbDB,
|
22
|
-
* indexed by their queue name for easier access.
|
23
|
-
*
|
24
|
-
* @private
|
25
|
-
*/
|
26
|
-
|
27
|
-
class QueueStore {
|
28
|
-
/**
|
29
|
-
* Associates this instance with a Queue instance, so entries added can be
|
30
|
-
* identified by their queue name.
|
31
|
-
*
|
32
|
-
* @param {string} queueName
|
33
|
-
* @private
|
34
|
-
*/
|
35
|
-
constructor(queueName) {
|
36
|
-
this._queueName = queueName;
|
37
|
-
this._db = new DBWrapper_mjs.DBWrapper(DB_NAME, DB_VERSION, {
|
38
|
-
onupgradeneeded: this._upgradeDb
|
39
|
-
});
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* Append an entry last in the queue.
|
43
|
-
*
|
44
|
-
* @param {Object} entry
|
45
|
-
* @param {Object} entry.requestData
|
46
|
-
* @param {number} [entry.timestamp]
|
47
|
-
* @param {Object} [entry.metadata]
|
48
|
-
* @private
|
49
|
-
*/
|
50
|
-
|
51
|
-
|
52
|
-
async pushEntry(entry) {
|
53
|
-
{
|
54
|
-
assert_mjs.assert.isType(entry, 'object', {
|
55
|
-
moduleName: 'workbox-background-sync',
|
56
|
-
className: 'QueueStore',
|
57
|
-
funcName: 'pushEntry',
|
58
|
-
paramName: 'entry'
|
59
|
-
});
|
60
|
-
assert_mjs.assert.isType(entry.requestData, 'object', {
|
61
|
-
moduleName: 'workbox-background-sync',
|
62
|
-
className: 'QueueStore',
|
63
|
-
funcName: 'pushEntry',
|
64
|
-
paramName: 'entry.requestData'
|
65
|
-
});
|
66
|
-
} // Don't specify an ID since one is automatically generated.
|
67
|
-
|
68
|
-
|
69
|
-
delete entry.id;
|
70
|
-
entry.queueName = this._queueName;
|
71
|
-
await this._db.add(OBJECT_STORE_NAME, entry);
|
72
|
-
}
|
73
|
-
/**
|
74
|
-
* Preppend an entry first in the queue.
|
75
|
-
*
|
76
|
-
* @param {Object} entry
|
77
|
-
* @param {Object} entry.requestData
|
78
|
-
* @param {number} [entry.timestamp]
|
79
|
-
* @param {Object} [entry.metadata]
|
80
|
-
* @private
|
81
|
-
*/
|
82
|
-
|
83
|
-
|
84
|
-
async unshiftEntry(entry) {
|
85
|
-
{
|
86
|
-
assert_mjs.assert.isType(entry, 'object', {
|
87
|
-
moduleName: 'workbox-background-sync',
|
88
|
-
className: 'QueueStore',
|
89
|
-
funcName: 'unshiftEntry',
|
90
|
-
paramName: 'entry'
|
91
|
-
});
|
92
|
-
assert_mjs.assert.isType(entry.requestData, 'object', {
|
93
|
-
moduleName: 'workbox-background-sync',
|
94
|
-
className: 'QueueStore',
|
95
|
-
funcName: 'unshiftEntry',
|
96
|
-
paramName: 'entry.requestData'
|
97
|
-
});
|
98
|
-
}
|
99
|
-
|
100
|
-
const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {
|
101
|
-
count: 1
|
102
|
-
});
|
103
|
-
|
104
|
-
if (firstEntry) {
|
105
|
-
// Pick an ID one less than the lowest ID in the object store.
|
106
|
-
entry.id = firstEntry.id - 1;
|
107
|
-
} else {
|
108
|
-
// Otherwise let the auto-incrementor assign the ID.
|
109
|
-
delete entry.id;
|
110
|
-
}
|
111
|
-
|
112
|
-
entry.queueName = this._queueName;
|
113
|
-
await this._db.add(OBJECT_STORE_NAME, entry);
|
114
|
-
}
|
115
|
-
/**
|
116
|
-
* Removes and returns the last entry in the queue matching the `queueName`.
|
117
|
-
*
|
118
|
-
* @return {Promise<Object>}
|
119
|
-
* @private
|
120
|
-
*/
|
121
|
-
|
122
|
-
|
123
|
-
async popEntry() {
|
124
|
-
return this._removeEntry({
|
125
|
-
direction: 'prev'
|
126
|
-
});
|
127
|
-
}
|
128
|
-
/**
|
129
|
-
* Removes and returns the first entry in the queue matching the `queueName`.
|
130
|
-
*
|
131
|
-
* @return {Promise<Object>}
|
132
|
-
* @private
|
133
|
-
*/
|
134
|
-
|
135
|
-
|
136
|
-
async shiftEntry() {
|
137
|
-
return this._removeEntry({
|
138
|
-
direction: 'next'
|
139
|
-
});
|
140
|
-
}
|
141
|
-
/**
|
142
|
-
* Returns all entries in the store matching the `queueName`.
|
143
|
-
*
|
144
|
-
* @param {Object} options See workbox.backgroundSync.Queue~getAll}
|
145
|
-
* @return {Promise<Array<Object>>}
|
146
|
-
* @private
|
147
|
-
*/
|
148
|
-
|
149
|
-
|
150
|
-
async getAll() {
|
151
|
-
return await this._db.getAllMatching(OBJECT_STORE_NAME, {
|
152
|
-
index: INDEXED_PROP,
|
153
|
-
query: IDBKeyRange.only(this._queueName)
|
154
|
-
});
|
155
|
-
}
|
156
|
-
/**
|
157
|
-
* Deletes the entry for the given ID.
|
158
|
-
*
|
159
|
-
* WARNING: this method does not ensure the deleted enry belongs to this
|
160
|
-
* queue (i.e. matches the `queueName`). But this limitation is acceptable
|
161
|
-
* as this class is not publicly exposed. An additional check would make
|
162
|
-
* this method slower than it needs to be.
|
163
|
-
*
|
164
|
-
* @private
|
165
|
-
* @param {number} id
|
166
|
-
*/
|
167
|
-
|
168
|
-
|
169
|
-
async deleteEntry(id) {
|
170
|
-
await this._db.delete(OBJECT_STORE_NAME, id);
|
171
|
-
}
|
172
|
-
/**
|
173
|
-
* Removes and returns the first or last entry in the queue (based on the
|
174
|
-
* `direction` argument) matching the `queueName`.
|
175
|
-
*
|
176
|
-
* @return {Promise<Object>}
|
177
|
-
* @private
|
178
|
-
*/
|
179
|
-
|
180
|
-
|
181
|
-
async _removeEntry({
|
182
|
-
direction
|
183
|
-
}) {
|
184
|
-
const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {
|
185
|
-
direction,
|
186
|
-
index: INDEXED_PROP,
|
187
|
-
query: IDBKeyRange.only(this._queueName),
|
188
|
-
count: 1
|
189
|
-
});
|
190
|
-
|
191
|
-
if (entry) {
|
192
|
-
await this.deleteEntry(entry.id);
|
193
|
-
return entry;
|
194
|
-
}
|
195
|
-
}
|
196
|
-
/**
|
197
|
-
* Upgrades the database given an `upgradeneeded` event.
|
198
|
-
*
|
199
|
-
* @param {Event} event
|
200
|
-
* @private
|
201
|
-
*/
|
202
|
-
|
203
|
-
|
204
|
-
_upgradeDb(event) {
|
205
|
-
const db = event.target.result;
|
206
|
-
|
207
|
-
if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {
|
208
|
-
if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {
|
209
|
-
db.deleteObjectStore(OBJECT_STORE_NAME);
|
210
|
-
}
|
211
|
-
}
|
212
|
-
|
213
|
-
const objStore = db.createObjectStore(OBJECT_STORE_NAME, {
|
214
|
-
autoIncrement: true,
|
215
|
-
keyPath: 'id'
|
216
|
-
});
|
217
|
-
objStore.createIndex(INDEXED_PROP, INDEXED_PROP, {
|
218
|
-
unique: false
|
219
|
-
});
|
220
|
-
}
|
221
|
-
|
222
|
-
}
|
223
|
-
|
224
|
-
/*
|
225
|
-
Copyright 2018 Google LLC
|
226
|
-
|
227
|
-
Use of this source code is governed by an MIT-style
|
228
|
-
license that can be found in the LICENSE file or at
|
229
|
-
https://opensource.org/licenses/MIT.
|
230
|
-
*/
|
231
|
-
const serializableProperties = ['method', 'referrer', 'referrerPolicy', 'mode', 'credentials', 'cache', 'redirect', 'integrity', 'keepalive'];
|
232
|
-
/**
|
233
|
-
* A class to make it easier to serialize and de-serialize requests so they
|
234
|
-
* can be stored in IndexedDB.
|
235
|
-
*
|
236
|
-
* @private
|
237
|
-
*/
|
238
|
-
|
239
|
-
class StorableRequest {
|
240
|
-
/**
|
241
|
-
* Converts a Request object to a plain object that can be structured
|
242
|
-
* cloned or JSON-stringified.
|
243
|
-
*
|
244
|
-
* @param {Request} request
|
245
|
-
* @return {Promise<StorableRequest>}
|
246
|
-
*
|
247
|
-
* @private
|
248
|
-
*/
|
249
|
-
static async fromRequest(request) {
|
250
|
-
const requestData = {
|
251
|
-
url: request.url,
|
252
|
-
headers: {}
|
253
|
-
}; // Set the body if present.
|
254
|
-
|
255
|
-
if (request.method !== 'GET') {
|
256
|
-
// Use ArrayBuffer to support non-text request bodies.
|
257
|
-
// NOTE: we can't use Blobs becuse Safari doesn't support storing
|
258
|
-
// Blobs in IndexedDB in some cases:
|
259
|
-
// https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457
|
260
|
-
requestData.body = await request.clone().arrayBuffer();
|
261
|
-
} // Convert the headers from an iterable to an object.
|
262
|
-
|
263
|
-
|
264
|
-
for (const [key, value] of request.headers.entries()) {
|
265
|
-
requestData.headers[key] = value;
|
266
|
-
} // Add all other serializable request properties
|
267
|
-
|
268
|
-
|
269
|
-
for (const prop of serializableProperties) {
|
270
|
-
if (request[prop] !== undefined) {
|
271
|
-
requestData[prop] = request[prop];
|
272
|
-
}
|
273
|
-
}
|
274
|
-
|
275
|
-
return new StorableRequest(requestData);
|
276
|
-
}
|
277
|
-
/**
|
278
|
-
* Accepts an object of request data that can be used to construct a
|
279
|
-
* `Request` but can also be stored in IndexedDB.
|
280
|
-
*
|
281
|
-
* @param {Object} requestData An object of request data that includes the
|
282
|
-
* `url` plus any relevant properties of
|
283
|
-
* [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.
|
284
|
-
* @private
|
285
|
-
*/
|
286
|
-
|
287
|
-
|
288
|
-
constructor(requestData) {
|
289
|
-
{
|
290
|
-
assert_mjs.assert.isType(requestData, 'object', {
|
291
|
-
moduleName: 'workbox-background-sync',
|
292
|
-
className: 'StorableRequest',
|
293
|
-
funcName: 'constructor',
|
294
|
-
paramName: 'requestData'
|
295
|
-
});
|
296
|
-
assert_mjs.assert.isType(requestData.url, 'string', {
|
297
|
-
moduleName: 'workbox-background-sync',
|
298
|
-
className: 'StorableRequest',
|
299
|
-
funcName: 'constructor',
|
300
|
-
paramName: 'requestData.url'
|
301
|
-
});
|
302
|
-
} // If the request's mode is `navigate`, convert it to `same-origin` since
|
303
|
-
// navigation requests can't be constructed via script.
|
304
|
-
|
305
|
-
|
306
|
-
if (requestData.mode === 'navigate') {
|
307
|
-
requestData.mode = 'same-origin';
|
308
|
-
}
|
309
|
-
|
310
|
-
this._requestData = requestData;
|
311
|
-
}
|
312
|
-
/**
|
313
|
-
* Returns a deep clone of the instances `_requestData` object.
|
314
|
-
*
|
315
|
-
* @return {Object}
|
316
|
-
*
|
317
|
-
* @private
|
318
|
-
*/
|
319
|
-
|
320
|
-
|
321
|
-
toObject() {
|
322
|
-
const requestData = Object.assign({}, this._requestData);
|
323
|
-
requestData.headers = Object.assign({}, this._requestData.headers);
|
324
|
-
|
325
|
-
if (requestData.body) {
|
326
|
-
requestData.body = requestData.body.slice(0);
|
327
|
-
}
|
328
|
-
|
329
|
-
return requestData;
|
330
|
-
}
|
331
|
-
/**
|
332
|
-
* Converts this instance to a Request.
|
333
|
-
*
|
334
|
-
* @return {Request}
|
335
|
-
*
|
336
|
-
* @private
|
337
|
-
*/
|
338
|
-
|
339
|
-
|
340
|
-
toRequest() {
|
341
|
-
return new Request(this._requestData.url, this._requestData);
|
342
|
-
}
|
343
|
-
/**
|
344
|
-
* Creates and returns a deep clone of the instance.
|
345
|
-
*
|
346
|
-
* @return {StorableRequest}
|
347
|
-
*
|
348
|
-
* @private
|
349
|
-
*/
|
350
|
-
|
351
|
-
|
352
|
-
clone() {
|
353
|
-
return new StorableRequest(this.toObject());
|
354
|
-
}
|
355
|
-
|
356
|
-
}
|
357
|
-
|
358
|
-
/*
|
359
|
-
Copyright 2018 Google LLC
|
360
|
-
|
361
|
-
Use of this source code is governed by an MIT-style
|
362
|
-
license that can be found in the LICENSE file or at
|
363
|
-
https://opensource.org/licenses/MIT.
|
364
|
-
*/
|
365
|
-
const TAG_PREFIX = 'workbox-background-sync';
|
366
|
-
const MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes
|
367
|
-
|
368
|
-
const queueNames = new Set();
|
369
|
-
/**
|
370
|
-
* A class to manage storing failed requests in IndexedDB and retrying them
|
371
|
-
* later. All parts of the storing and replaying process are observable via
|
372
|
-
* callbacks.
|
373
|
-
*
|
374
|
-
* @memberof workbox.backgroundSync
|
375
|
-
*/
|
376
|
-
|
377
|
-
class Queue {
|
378
|
-
/**
|
379
|
-
* Creates an instance of Queue with the given options
|
380
|
-
*
|
381
|
-
* @param {string} name The unique name for this queue. This name must be
|
382
|
-
* unique as it's used to register sync events and store requests
|
383
|
-
* in IndexedDB specific to this instance. An error will be thrown if
|
384
|
-
* a duplicate name is detected.
|
385
|
-
* @param {Object} [options]
|
386
|
-
* @param {Function} [options.onSync] A function that gets invoked whenever
|
387
|
-
* the 'sync' event fires. The function is invoked with an object
|
388
|
-
* containing the `queue` property (referencing this instance), and you
|
389
|
-
* can use the callback to customize the replay behavior of the queue.
|
390
|
-
* When not set the `replayRequests()` method is called.
|
391
|
-
* Note: if the replay fails after a sync event, make sure you throw an
|
392
|
-
* error, so the browser knows to retry the sync event later.
|
393
|
-
* @param {number} [options.maxRetentionTime=7 days] The amount of time (in
|
394
|
-
* minutes) a request may be retried. After this amount of time has
|
395
|
-
* passed, the request will be deleted from the queue.
|
396
|
-
*/
|
397
|
-
constructor(name, {
|
398
|
-
onSync,
|
399
|
-
maxRetentionTime
|
400
|
-
} = {}) {
|
401
|
-
// Ensure the store name is not already being used
|
402
|
-
if (queueNames.has(name)) {
|
403
|
-
throw new WorkboxError_mjs.WorkboxError('duplicate-queue-name', {
|
404
|
-
name
|
405
|
-
});
|
406
|
-
} else {
|
407
|
-
queueNames.add(name);
|
408
|
-
}
|
409
|
-
|
410
|
-
this._name = name;
|
411
|
-
this._onSync = onSync || this.replayRequests;
|
412
|
-
this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;
|
413
|
-
this._queueStore = new QueueStore(this._name);
|
414
|
-
|
415
|
-
this._addSyncListener();
|
416
|
-
}
|
417
|
-
/**
|
418
|
-
* @return {string}
|
419
|
-
*/
|
420
|
-
|
421
|
-
|
422
|
-
get name() {
|
423
|
-
return this._name;
|
424
|
-
}
|
425
|
-
/**
|
426
|
-
* Stores the passed request in IndexedDB (with its timestamp and any
|
427
|
-
* metadata) at the end of the queue.
|
428
|
-
*
|
429
|
-
* @param {Object} entry
|
430
|
-
* @param {Request} entry.request The request to store in the queue.
|
431
|
-
* @param {Object} [entry.metadata] Any metadata you want associated with the
|
432
|
-
* stored request. When requests are replayed you'll have access to this
|
433
|
-
* metadata object in case you need to modify the request beforehand.
|
434
|
-
* @param {number} [entry.timestamp] The timestamp (Epoch time in
|
435
|
-
* milliseconds) when the request was first added to the queue. This is
|
436
|
-
* used along with `maxRetentionTime` to remove outdated requests. In
|
437
|
-
* general you don't need to set this value, as it's automatically set
|
438
|
-
* for you (defaulting to `Date.now()`), but you can update it if you
|
439
|
-
* don't want particular requests to expire.
|
440
|
-
*/
|
441
|
-
|
442
|
-
|
443
|
-
async pushRequest(entry) {
|
444
|
-
{
|
445
|
-
assert_mjs.assert.isType(entry, 'object', {
|
446
|
-
moduleName: 'workbox-background-sync',
|
447
|
-
className: 'Queue',
|
448
|
-
funcName: 'pushRequest',
|
449
|
-
paramName: 'entry'
|
450
|
-
});
|
451
|
-
assert_mjs.assert.isInstance(entry.request, Request, {
|
452
|
-
moduleName: 'workbox-background-sync',
|
453
|
-
className: 'Queue',
|
454
|
-
funcName: 'pushRequest',
|
455
|
-
paramName: 'entry.request'
|
456
|
-
});
|
457
|
-
}
|
458
|
-
|
459
|
-
await this._addRequest(entry, 'push');
|
460
|
-
}
|
461
|
-
/**
|
462
|
-
* Stores the passed request in IndexedDB (with its timestamp and any
|
463
|
-
* metadata) at the beginning of the queue.
|
464
|
-
*
|
465
|
-
* @param {Object} entry
|
466
|
-
* @param {Request} entry.request The request to store in the queue.
|
467
|
-
* @param {Object} [entry.metadata] Any metadata you want associated with the
|
468
|
-
* stored request. When requests are replayed you'll have access to this
|
469
|
-
* metadata object in case you need to modify the request beforehand.
|
470
|
-
* @param {number} [entry.timestamp] The timestamp (Epoch time in
|
471
|
-
* milliseconds) when the request was first added to the queue. This is
|
472
|
-
* used along with `maxRetentionTime` to remove outdated requests. In
|
473
|
-
* general you don't need to set this value, as it's automatically set
|
474
|
-
* for you (defaulting to `Date.now()`), but you can update it if you
|
475
|
-
* don't want particular requests to expire.
|
476
|
-
*/
|
477
|
-
|
478
|
-
|
479
|
-
async unshiftRequest(entry) {
|
480
|
-
{
|
481
|
-
assert_mjs.assert.isType(entry, 'object', {
|
482
|
-
moduleName: 'workbox-background-sync',
|
483
|
-
className: 'Queue',
|
484
|
-
funcName: 'unshiftRequest',
|
485
|
-
paramName: 'entry'
|
486
|
-
});
|
487
|
-
assert_mjs.assert.isInstance(entry.request, Request, {
|
488
|
-
moduleName: 'workbox-background-sync',
|
489
|
-
className: 'Queue',
|
490
|
-
funcName: 'unshiftRequest',
|
491
|
-
paramName: 'entry.request'
|
492
|
-
});
|
493
|
-
}
|
494
|
-
|
495
|
-
await this._addRequest(entry, 'unshift');
|
496
|
-
}
|
497
|
-
/**
|
498
|
-
* Removes and returns the last request in the queue (along with its
|
499
|
-
* timestamp and any metadata). The returned object takes the form:
|
500
|
-
* `{request, timestamp, metadata}`.
|
501
|
-
*
|
502
|
-
* @return {Promise<Object>}
|
503
|
-
*/
|
504
|
-
|
505
|
-
|
506
|
-
async popRequest() {
|
507
|
-
return this._removeRequest('pop');
|
508
|
-
}
|
509
|
-
/**
|
510
|
-
* Removes and returns the first request in the queue (along with its
|
511
|
-
* timestamp and any metadata). The returned object takes the form:
|
512
|
-
* `{request, timestamp, metadata}`.
|
513
|
-
*
|
514
|
-
* @return {Promise<Object>}
|
515
|
-
*/
|
516
|
-
|
517
|
-
|
518
|
-
async shiftRequest() {
|
519
|
-
return this._removeRequest('shift');
|
520
|
-
}
|
521
|
-
/**
|
522
|
-
* Returns all the entries that have not expired (per `maxRetentionTime`).
|
523
|
-
* Any expired entries are removed from the queue.
|
524
|
-
*
|
525
|
-
* @return {Promise<Array<Object>>}
|
526
|
-
*/
|
527
|
-
|
528
|
-
|
529
|
-
async getAll() {
|
530
|
-
const allEntries = await this._queueStore.getAll();
|
531
|
-
const now = Date.now();
|
532
|
-
const unexpiredEntries = [];
|
533
|
-
|
534
|
-
for (const entry of allEntries) {
|
535
|
-
// Ignore requests older than maxRetentionTime. Call this function
|
536
|
-
// recursively until an unexpired request is found.
|
537
|
-
const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;
|
538
|
-
|
539
|
-
if (now - entry.timestamp > maxRetentionTimeInMs) {
|
540
|
-
await this._queueStore.deleteEntry(entry.id);
|
541
|
-
} else {
|
542
|
-
unexpiredEntries.push(convertEntry(entry));
|
543
|
-
}
|
544
|
-
}
|
545
|
-
|
546
|
-
return unexpiredEntries;
|
547
|
-
}
|
548
|
-
/**
|
549
|
-
* Adds the entry to the QueueStore and registers for a sync event.
|
550
|
-
*
|
551
|
-
* @param {Object} entry
|
552
|
-
* @param {Request} entry.request
|
553
|
-
* @param {Object} [entry.metadata]
|
554
|
-
* @param {number} [entry.timestamp=Date.now()]
|
555
|
-
* @param {string} operation ('push' or 'unshift')
|
556
|
-
* @private
|
557
|
-
*/
|
558
|
-
|
559
|
-
|
560
|
-
async _addRequest({
|
561
|
-
request,
|
562
|
-
metadata,
|
563
|
-
timestamp = Date.now()
|
564
|
-
}, operation) {
|
565
|
-
const storableRequest = await StorableRequest.fromRequest(request.clone());
|
566
|
-
const entry = {
|
567
|
-
requestData: storableRequest.toObject(),
|
568
|
-
timestamp
|
569
|
-
}; // Only include metadata if it's present.
|
570
|
-
|
571
|
-
if (metadata) {
|
572
|
-
entry.metadata = metadata;
|
573
|
-
}
|
574
|
-
|
575
|
-
await this._queueStore[`${operation}Entry`](entry);
|
576
|
-
|
577
|
-
{
|
578
|
-
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}' has ` + `been added to background sync queue '${this._name}'.`);
|
579
|
-
} // Don't register for a sync if we're in the middle of a sync. Instead,
|
580
|
-
// we wait until the sync is complete and call register if
|
581
|
-
// `this._requestsAddedDuringSync` is true.
|
582
|
-
|
583
|
-
|
584
|
-
if (this._syncInProgress) {
|
585
|
-
this._requestsAddedDuringSync = true;
|
586
|
-
} else {
|
587
|
-
await this.registerSync();
|
588
|
-
}
|
589
|
-
}
|
590
|
-
/**
|
591
|
-
* Removes and returns the first or last (depending on `operation`) entry
|
592
|
-
* from the QueueStore that's not older than the `maxRetentionTime`.
|
593
|
-
*
|
594
|
-
* @param {string} operation ('pop' or 'shift')
|
595
|
-
* @return {Object|undefined}
|
596
|
-
* @private
|
597
|
-
*/
|
598
|
-
|
599
|
-
|
600
|
-
async _removeRequest(operation) {
|
601
|
-
const now = Date.now();
|
602
|
-
const entry = await this._queueStore[`${operation}Entry`]();
|
603
|
-
|
604
|
-
if (entry) {
|
605
|
-
// Ignore requests older than maxRetentionTime. Call this function
|
606
|
-
// recursively until an unexpired request is found.
|
607
|
-
const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;
|
608
|
-
|
609
|
-
if (now - entry.timestamp > maxRetentionTimeInMs) {
|
610
|
-
return this._removeRequest(operation);
|
611
|
-
}
|
612
|
-
|
613
|
-
return convertEntry(entry);
|
614
|
-
}
|
615
|
-
}
|
616
|
-
/**
|
617
|
-
* Loops through each request in the queue and attempts to re-fetch it.
|
618
|
-
* If any request fails to re-fetch, it's put back in the same position in
|
619
|
-
* the queue (which registers a retry for the next sync event).
|
620
|
-
*/
|
621
|
-
|
622
|
-
|
623
|
-
async replayRequests() {
|
624
|
-
let entry;
|
625
|
-
|
626
|
-
while (entry = await this.shiftRequest()) {
|
627
|
-
try {
|
628
|
-
await fetch(entry.request.clone());
|
629
|
-
|
630
|
-
{
|
631
|
-
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(entry.request.url)}'` + `has been replayed in queue '${this._name}'`);
|
632
|
-
}
|
633
|
-
} catch (error) {
|
634
|
-
await this.unshiftRequest(entry);
|
635
|
-
|
636
|
-
{
|
637
|
-
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(entry.request.url)}'` + `failed to replay, putting it back in queue '${this._name}'`);
|
638
|
-
}
|
639
|
-
|
640
|
-
throw new WorkboxError_mjs.WorkboxError('queue-replay-failed', {
|
641
|
-
name: this._name
|
642
|
-
});
|
643
|
-
}
|
644
|
-
}
|
645
|
-
|
646
|
-
{
|
647
|
-
logger_mjs.logger.log(`All requests in queue '${this.name}' have successfully ` + `replayed; the queue is now empty!`);
|
648
|
-
}
|
649
|
-
}
|
650
|
-
/**
|
651
|
-
* Registers a sync event with a tag unique to this instance.
|
652
|
-
*/
|
653
|
-
|
654
|
-
|
655
|
-
async registerSync() {
|
656
|
-
if ('sync' in registration) {
|
657
|
-
try {
|
658
|
-
await registration.sync.register(`${TAG_PREFIX}:${this._name}`);
|
659
|
-
} catch (err) {
|
660
|
-
// This means the registration failed for some reason, possibly due to
|
661
|
-
// the user disabling it.
|
662
|
-
{
|
663
|
-
logger_mjs.logger.warn(`Unable to register sync event for '${this._name}'.`, err);
|
664
|
-
}
|
665
|
-
}
|
666
|
-
}
|
667
|
-
}
|
668
|
-
/**
|
669
|
-
* In sync-supporting browsers, this adds a listener for the sync event.
|
670
|
-
* In non-sync-supporting browsers, this will retry the queue on service
|
671
|
-
* worker startup.
|
672
|
-
*
|
673
|
-
* @private
|
674
|
-
*/
|
675
|
-
|
676
|
-
|
677
|
-
_addSyncListener() {
|
678
|
-
if ('sync' in registration) {
|
679
|
-
self.addEventListener('sync', event => {
|
680
|
-
if (event.tag === `${TAG_PREFIX}:${this._name}`) {
|
681
|
-
{
|
682
|
-
logger_mjs.logger.log(`Background sync for tag '${event.tag}'` + `has been received`);
|
683
|
-
}
|
684
|
-
|
685
|
-
const syncComplete = async () => {
|
686
|
-
this._syncInProgress = true;
|
687
|
-
let syncError;
|
688
|
-
|
689
|
-
try {
|
690
|
-
await this._onSync({
|
691
|
-
queue: this
|
692
|
-
});
|
693
|
-
} catch (error) {
|
694
|
-
syncError = error; // Rethrow the error. Note: the logic in the finally clause
|
695
|
-
// will run before this gets rethrown.
|
696
|
-
|
697
|
-
throw syncError;
|
698
|
-
} finally {
|
699
|
-
// New items may have been added to the queue during the sync,
|
700
|
-
// so we need to register for a new sync if that's happened...
|
701
|
-
// Unless there was an error during the sync, in which
|
702
|
-
// case the browser will automatically retry later, as long
|
703
|
-
// as `event.lastChance` is not true.
|
704
|
-
if (this._requestsAddedDuringSync && !(syncError && !event.lastChance)) {
|
705
|
-
await this.registerSync();
|
706
|
-
}
|
707
|
-
|
708
|
-
this._syncInProgress = false;
|
709
|
-
this._requestsAddedDuringSync = false;
|
710
|
-
}
|
711
|
-
};
|
712
|
-
|
713
|
-
event.waitUntil(syncComplete());
|
714
|
-
}
|
715
|
-
});
|
716
|
-
} else {
|
717
|
-
{
|
718
|
-
logger_mjs.logger.log(`Background sync replaying without background sync event`);
|
719
|
-
} // If the browser doesn't support background sync, retry
|
720
|
-
// every time the service worker starts up as a fallback.
|
721
|
-
|
722
|
-
|
723
|
-
this._onSync({
|
724
|
-
queue: this
|
725
|
-
});
|
726
|
-
}
|
727
|
-
}
|
728
|
-
/**
|
729
|
-
* Returns the set of queue names. This is primarily used to reset the list
|
730
|
-
* of queue names in tests.
|
731
|
-
*
|
732
|
-
* @return {Set}
|
733
|
-
*
|
734
|
-
* @private
|
735
|
-
*/
|
736
|
-
|
737
|
-
|
738
|
-
static get _queueNames() {
|
739
|
-
return queueNames;
|
740
|
-
}
|
741
|
-
|
742
|
-
}
|
743
|
-
/**
|
744
|
-
* Converts a QueueStore entry into the format exposed by Queue. This entails
|
745
|
-
* converting the request data into a real request and omitting the `id` and
|
746
|
-
* `queueName` properties.
|
747
|
-
*
|
748
|
-
* @param {Object} queueStoreEntry
|
749
|
-
* @return {Object}
|
750
|
-
* @private
|
751
|
-
*/
|
752
|
-
|
753
|
-
|
754
|
-
const convertEntry = queueStoreEntry => {
|
755
|
-
const queueEntry = {
|
756
|
-
request: new StorableRequest(queueStoreEntry.requestData).toRequest(),
|
757
|
-
timestamp: queueStoreEntry.timestamp
|
758
|
-
};
|
759
|
-
|
760
|
-
if (queueStoreEntry.metadata) {
|
761
|
-
queueEntry.metadata = queueStoreEntry.metadata;
|
762
|
-
}
|
763
|
-
|
764
|
-
return queueEntry;
|
765
|
-
};
|
766
|
-
|
767
|
-
/*
|
768
|
-
Copyright 2018 Google LLC
|
769
|
-
|
770
|
-
Use of this source code is governed by an MIT-style
|
771
|
-
license that can be found in the LICENSE file or at
|
772
|
-
https://opensource.org/licenses/MIT.
|
773
|
-
*/
|
774
|
-
/**
|
775
|
-
* A class implementing the `fetchDidFail` lifecycle callback. This makes it
|
776
|
-
* easier to add failed requests to a background sync Queue.
|
777
|
-
*
|
778
|
-
* @memberof workbox.backgroundSync
|
779
|
-
*/
|
780
|
-
|
781
|
-
class Plugin {
|
782
|
-
/**
|
783
|
-
* @param {...*} queueArgs Args to forward to the composed Queue instance.
|
784
|
-
* See the [Queue]{@link workbox.backgroundSync.Queue} documentation for
|
785
|
-
* parameter details.
|
786
|
-
*/
|
787
|
-
constructor(...queueArgs) {
|
788
|
-
this._queue = new Queue(...queueArgs);
|
789
|
-
this.fetchDidFail = this.fetchDidFail.bind(this);
|
790
|
-
}
|
791
|
-
/**
|
792
|
-
* @param {Object} options
|
793
|
-
* @param {Request} options.request
|
794
|
-
* @private
|
795
|
-
*/
|
796
|
-
|
797
|
-
|
798
|
-
async fetchDidFail({
|
799
|
-
request
|
800
|
-
}) {
|
801
|
-
await this._queue.pushRequest({
|
802
|
-
request
|
803
|
-
});
|
804
|
-
}
|
805
|
-
|
806
|
-
}
|
807
|
-
|
808
|
-
/*
|
809
|
-
Copyright 2018 Google LLC
|
810
|
-
|
811
|
-
Use of this source code is governed by an MIT-style
|
812
|
-
license that can be found in the LICENSE file or at
|
813
|
-
https://opensource.org/licenses/MIT.
|
814
|
-
*/
|
815
|
-
|
816
|
-
exports.Queue = Queue;
|
817
|
-
exports.Plugin = Plugin;
|
818
|
-
|
819
|
-
return exports;
|
820
|
-
|
821
|
-
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
|
822
|
-
//# sourceMappingURL=workbox-background-sync.dev.js.map
|