jekyll-pwa-workbox 0.0.6 → 0.0.7.alpha
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"workbox-background-sync.dev.js","sources":["../_version.mjs","../lib/QueueStore.mjs","../lib/StorableRequest.mjs","../Queue.mjs","../Plugin.mjs","../index.mjs"],"sourcesContent":["try{self['workbox:background-sync:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\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*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport '../_version.mjs';\n\n\nconst DB_VERSION = 3;\nconst DB_NAME = 'workbox-background-sync';\nconst OBJECT_STORE_NAME = 'requests';\nconst INDEXED_PROP = 'queueName';\n\n/**\n * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\nexport class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {string} queueName\n * @private\n */\n constructor(queueName) {\n this._queueName = queueName;\n this._db = new DBWrapper(DB_NAME, DB_VERSION, {\n onupgradeneeded: this._upgradeDb,\n });\n }\n\n /**\n * Append an entry last in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async pushEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry.requestData',\n });\n }\n\n // Don't specify an ID since one is automatically generated.\n delete entry.id;\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Preppend an entry first in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async unshiftEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry.requestData',\n });\n }\n\n const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n count: 1,\n });\n\n if (firstEntry) {\n // Pick an ID one less than the lowest ID in the object store.\n entry.id = firstEntry.id - 1;\n } else {\n // Otherwise let the auto-incrementor assign the ID.\n delete entry.id;\n }\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Removes and returns the last entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async popEntry() {\n return this._removeEntry({direction: 'prev'});\n }\n\n /**\n * Removes and returns the first entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async shiftEntry() {\n return this._removeEntry({direction: 'next'});\n }\n\n /**\n * Returns all entries in the store matching the `queueName`.\n *\n * @param {Object} options See workbox.backgroundSync.Queue~getAll}\n * @return {Promise<Array<Object>>}\n * @private\n */\n async getAll() {\n return await this._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n });\n }\n\n /**\n * Deletes the entry for the given ID.\n *\n * WARNING: this method does not ensure the deleted enry belongs to this\n * queue (i.e. matches the `queueName`). But this limitation is acceptable\n * as this class is not publicly exposed. An additional check would make\n * this method slower than it needs to be.\n *\n * @private\n * @param {number} id\n */\n async deleteEntry(id) {\n await this._db.delete(OBJECT_STORE_NAME, id);\n }\n\n /**\n * Removes and returns the first or last entry in the queue (based on the\n * `direction` argument) matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async _removeEntry({direction}) {\n const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n direction,\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n count: 1,\n });\n\n if (entry) {\n await this.deleteEntry(entry.id);\n return entry;\n }\n }\n\n /**\n * Upgrades the database given an `upgradeneeded` event.\n *\n * @param {Event} event\n * @private\n */\n _upgradeDb(event) {\n const db = event.target.result;\n\n if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {\n if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {\n db.deleteObjectStore(OBJECT_STORE_NAME);\n }\n }\n\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {\n autoIncrement: true,\n keyPath: 'id',\n });\n objStore.createIndex(INDEXED_PROP, INDEXED_PROP, {unique: false});\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n\nconst serializableProperties = [\n 'method',\n 'referrer',\n 'referrerPolicy',\n 'mode',\n 'credentials',\n 'cache',\n 'redirect',\n 'integrity',\n 'keepalive',\n];\n\n\n/**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\nclass StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static async fromRequest(request) {\n const requestData = {\n url: request.url,\n headers: {},\n };\n\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use ArrayBuffer to support non-text request bodies.\n // NOTE: we can't use Blobs becuse Safari doesn't support storing\n // Blobs in IndexedDB in some cases:\n // https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457\n requestData.body = await request.clone().arrayBuffer();\n }\n\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestData.headers[key] = value;\n }\n\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestData[prop] = request[prop];\n }\n }\n\n return new StorableRequest(requestData);\n }\n\n /**\n * Accepts an object of request data that can be used to construct a\n * `Request` but can also be stored in IndexedDB.\n *\n * @param {Object} requestData An object of request data that includes the\n * `url` plus any relevant properties of\n * [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.\n * @private\n */\n constructor(requestData) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData',\n });\n assert.isType(requestData.url, 'string', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData.url',\n });\n }\n\n // If the request's mode is `navigate`, convert it to `same-origin` since\n // navigation requests can't be constructed via script.\n if (requestData.mode === 'navigate') {\n requestData.mode = 'same-origin';\n }\n\n this._requestData = requestData;\n }\n\n /**\n * Returns a deep clone of the instances `_requestData` object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n const requestData = Object.assign({}, this._requestData);\n requestData.headers = Object.assign({}, this._requestData.headers);\n if (requestData.body) {\n requestData.body = requestData.body.slice(0);\n }\n\n return requestData;\n }\n\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this._requestData.url, this._requestData);\n }\n\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n return new StorableRequest(this.toObject());\n }\n}\n\nexport {StorableRequest};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {QueueStore} from './lib/QueueStore.mjs';\nimport {StorableRequest} from './lib/StorableRequest.mjs';\nimport './_version.mjs';\n\n\nconst TAG_PREFIX = 'workbox-background-sync';\nconst MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\n\nconst queueNames = new Set();\n\n/**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\nclass Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Function} [options.onSync] A function that gets invoked whenever\n * the 'sync' event fires. The function is invoked with an object\n * containing the `queue` property (referencing this instance), and you\n * can use the callback to customize the replay behavior of the queue.\n * When not set the `replayRequests()` method is called.\n * Note: if the replay fails after a sync event, make sure you throw an\n * error, so the browser knows to retry the sync event later.\n * @param {number} [options.maxRetentionTime=7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, {onSync, maxRetentionTime} = {}) {\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError('duplicate-queue-name', {name});\n } else {\n queueNames.add(name);\n }\n\n this._name = name;\n this._onSync = onSync || this.replayRequests;\n this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;\n this._queueStore = new QueueStore(this._name);\n\n this._addSyncListener();\n }\n\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the end of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async pushRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'push');\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the beginning of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async unshiftRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'unshift');\n }\n\n /**\n * Removes and returns the last request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async popRequest() {\n return this._removeRequest('pop');\n }\n\n /**\n * Removes and returns the first request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async shiftRequest() {\n return this._removeRequest('shift');\n }\n\n /**\n * Returns all the entries that have not expired (per `maxRetentionTime`).\n * Any expired entries are removed from the queue.\n *\n * @return {Promise<Array<Object>>}\n */\n async getAll() {\n const allEntries = await this._queueStore.getAll();\n const now = Date.now();\n\n const unexpiredEntries = [];\n for (const entry of allEntries) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n await this._queueStore.deleteEntry(entry.id);\n } else {\n unexpiredEntries.push(convertEntry(entry));\n }\n }\n\n return unexpiredEntries;\n }\n\n\n /**\n * Adds the entry to the QueueStore and registers for a sync event.\n *\n * @param {Object} entry\n * @param {Request} entry.request\n * @param {Object} [entry.metadata]\n * @param {number} [entry.timestamp=Date.now()]\n * @param {string} operation ('push' or 'unshift')\n * @private\n */\n async _addRequest(\n {request, metadata, timestamp = Date.now()}, operation) {\n const storableRequest = await StorableRequest.fromRequest(request.clone());\n const entry = {\n requestData: storableRequest.toObject(),\n timestamp,\n };\n\n // Only include metadata if it's present.\n if (metadata) {\n entry.metadata = metadata;\n }\n\n await this._queueStore[`${operation}Entry`](entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(request.url)}' has ` +\n `been added to background sync queue '${this._name}'.`);\n }\n\n // Don't register for a sync if we're in the middle of a sync. Instead,\n // we wait until the sync is complete and call register if\n // `this._requestsAddedDuringSync` is true.\n if (this._syncInProgress) {\n this._requestsAddedDuringSync = true;\n } else {\n await this.registerSync();\n }\n }\n\n /**\n * Removes and returns the first or last (depending on `operation`) entry\n * from the QueueStore that's not older than the `maxRetentionTime`.\n *\n * @param {string} operation ('pop' or 'shift')\n * @return {Object|undefined}\n * @private\n */\n async _removeRequest(operation) {\n const now = Date.now();\n const entry = await this._queueStore[`${operation}Entry`]();\n\n if (entry) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n return this._removeRequest(operation);\n }\n\n return convertEntry(entry);\n }\n }\n\n /**\n * Loops through each request in the queue and attempts to re-fetch it.\n * If any request fails to re-fetch, it's put back in the same position in\n * the queue (which registers a retry for the next sync event).\n */\n async replayRequests() {\n let entry;\n while (entry = await this.shiftRequest()) {\n try {\n await fetch(entry.request.clone());\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `has been replayed in queue '${this._name}'`);\n }\n } catch (error) {\n await this.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `failed to replay, putting it back in queue '${this._name}'`);\n }\n throw new WorkboxError('queue-replay-failed', {name: this._name});\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All requests in queue '${this.name}' have successfully ` +\n `replayed; the queue is now empty!`);\n }\n }\n\n /**\n * Registers a sync event with a tag unique to this instance.\n */\n async registerSync() {\n if ('sync' in registration) {\n try {\n await registration.sync.register(`${TAG_PREFIX}:${this._name}`);\n } catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n `Unable to register sync event for '${this._name}'.`, err);\n }\n }\n }\n }\n\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in registration) {\n self.addEventListener('sync', (event) => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync for tag '${event.tag}'` +\n `has been received`);\n }\n\n const syncComplete = async () => {\n this._syncInProgress = true;\n\n let syncError;\n try {\n await this._onSync({queue: this});\n } catch (error) {\n syncError = error;\n\n // Rethrow the error. Note: the logic in the finally clause\n // will run before this gets rethrown.\n throw syncError;\n } finally {\n // New items may have been added to the queue during the sync,\n // so we need to register for a new sync if that's happened...\n // Unless there was an error during the sync, in which\n // case the browser will automatically retry later, as long\n // as `event.lastChance` is not true.\n if (this._requestsAddedDuringSync &&\n !(syncError && !event.lastChance)) {\n await this.registerSync();\n }\n\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n }\n };\n event.waitUntil(syncComplete());\n }\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this._onSync({queue: this});\n }\n }\n\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n}\n\n\n/**\n * Converts a QueueStore entry into the format exposed by Queue. This entails\n * converting the request data into a real request and omitting the `id` and\n * `queueName` properties.\n *\n * @param {Object} queueStoreEntry\n * @return {Object}\n * @private\n */\nconst convertEntry = (queueStoreEntry) => {\n const queueEntry = {\n request: new StorableRequest(queueStoreEntry.requestData).toRequest(),\n timestamp: queueStoreEntry.timestamp,\n };\n if (queueStoreEntry.metadata) {\n queueEntry.metadata = queueStoreEntry.metadata;\n }\n return queueEntry;\n};\n\nexport {Queue};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Queue} from './Queue.mjs';\nimport './_version.mjs';\n\n/**\n * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\nclass Plugin {\n /**\n * @param {...*} queueArgs Args to forward to the composed Queue instance.\n * See the [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(...queueArgs) {\n this._queue = new Queue(...queueArgs);\n this.fetchDidFail = this.fetchDidFail.bind(this);\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n async fetchDidFail({request}) {\n await this._queue.pushRequest({request});\n }\n}\n\nexport {Plugin};\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*/\n\nimport {Queue} from './Queue.mjs';\nimport {Plugin} from './Plugin.mjs';\nimport './_version.mjs';\n\n\n/**\n * @namespace workbox.backgroundSync\n */\n\nexport {\n Queue,\n Plugin,\n};\n"],"names":["self","_","e","DB_VERSION","DB_NAME","OBJECT_STORE_NAME","INDEXED_PROP","QueueStore","constructor","queueName","_queueName","_db","DBWrapper","onupgradeneeded","_upgradeDb","pushEntry","entry","assert","isType","moduleName","className","funcName","paramName","requestData","id","add","unshiftEntry","firstEntry","getAllMatching","count","popEntry","_removeEntry","direction","shiftEntry","getAll","index","query","IDBKeyRange","only","deleteEntry","delete","event","db","target","result","oldVersion","objectStoreNames","contains","deleteObjectStore","objStore","createObjectStore","autoIncrement","keyPath","createIndex","unique","serializableProperties","StorableRequest","fromRequest","request","url","headers","method","body","clone","arrayBuffer","key","value","entries","prop","undefined","mode","_requestData","toObject","Object","assign","slice","toRequest","Request","TAG_PREFIX","MAX_RETENTION_TIME","queueNames","Set","Queue","name","onSync","maxRetentionTime","has","WorkboxError","_name","_onSync","replayRequests","_maxRetentionTime","_queueStore","_addSyncListener","pushRequest","isInstance","_addRequest","unshiftRequest","popRequest","_removeRequest","shiftRequest","allEntries","now","Date","unexpiredEntries","maxRetentionTimeInMs","timestamp","push","convertEntry","metadata","operation","storableRequest","logger","log","getFriendlyURL","_syncInProgress","_requestsAddedDuringSync","registerSync","fetch","error","registration","sync","register","err","warn","addEventListener","tag","syncComplete","syncError","queue","lastChance","waitUntil","_queueNames","queueStoreEntry","queueEntry","Plugin","queueArgs","_queue","fetchDidFail","bind"],"mappings":";;;;EAAA,IAAG;EAACA,EAAAA,IAAI,CAAC,+BAAD,CAAJ,IAAuCC,CAAC,EAAxC;EAA2C,CAA/C,CAA+C,OAAMC,CAAN,EAAQ;;ECAvD;;;;;;;AAQA,EAKA,MAAMC,UAAU,GAAG,CAAnB;EACA,MAAMC,OAAO,GAAG,yBAAhB;EACA,MAAMC,iBAAiB,GAAG,UAA1B;EACA,MAAMC,YAAY,GAAG,WAArB;EAEA;;;;;;;AAMA,EAAO,MAAMC,UAAN,CAAiB;EACtB;;;;;;;EAOAC,EAAAA,WAAW,CAACC,SAAD,EAAY;EACrB,SAAKC,UAAL,GAAkBD,SAAlB;EACA,SAAKE,GAAL,GAAW,IAAIC,uBAAJ,CAAcR,OAAd,EAAuBD,UAAvB,EAAmC;EAC5CU,MAAAA,eAAe,EAAE,KAAKC;EADsB,KAAnC,CAAX;EAGD;EAED;;;;;;;;;;;EASA,QAAMC,SAAN,CAAgBC,KAAhB,EAAuB;EACrB,IAA2C;EACzCC,MAAAA,iBAAM,CAACC,MAAP,CAAcF,KAAd,EAAqB,QAArB,EAA+B;EAC7BG,QAAAA,UAAU,EAAE,yBADiB;EAE7BC,QAAAA,SAAS,EAAE,YAFkB;EAG7BC,QAAAA,QAAQ,EAAE,WAHmB;EAI7BC,QAAAA,SAAS,EAAE;EAJkB,OAA/B;EAMAL,MAAAA,iBAAM,CAACC,MAAP,CAAcF,KAAK,CAACO,WAApB,EAAiC,QAAjC,EAA2C;EACzC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AtC;EACD;;EACD,SAAOyB,UAAP;EACD,CATD;;EC9XA;;;;;;;AAQA,EAGA;;;;;;;EAMA,MAAMC,MAAN,CAAa;EACX;;;;;EAKA/H,EAAAA,WAAW,CAAC,GAAGgI,SAAJ,EAAe;EACxB,SAAKC,MAAL,GAAc,IAAIvD,KAAJ,CAAU,GAAGsD,SAAb,CAAd;EACA,SAAKE,YAAL,GAAoB,KAAKA,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB,CAApB;EACD;EAED;;;;;;;EAKA,QAAMD,YAAN,CAAmB;EAAChF,IAAAA;EAAD,GAAnB,EAA8B;EAC5B,UAAM,KAAK+E,MAAL,CAAY3C,WAAZ,CAAwB;EAACpC,MAAAA;EAAD,KAAxB,CAAN;EACD;;EAlBU;;ECjBb;;;;;;;;;;;;;;;;;"}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
this.workbox=this.workbox||{},this.workbox.backgroundSync=function(t,e,s){"use strict";try{self["workbox:background-sync:4.3.1"]&&_()}catch(t){}const i=3,n="workbox-background-sync",a="requests",r="queueName";class c{constructor(t){this.t=t,this.s=new s.DBWrapper(n,i,{onupgradeneeded:this.i})}async pushEntry(t){delete t.id,t.queueName=this.t,await this.s.add(a,t)}async unshiftEntry(t){const[e]=await this.s.getAllMatching(a,{count:1});e?t.id=e.id-1:delete t.id,t.queueName=this.t,await this.s.add(a,t)}async popEntry(){return this.h({direction:"prev"})}async shiftEntry(){return this.h({direction:"next"})}async getAll(){return await this.s.getAllMatching(a,{index:r,query:IDBKeyRange.only(this.t)})}async deleteEntry(t){await this.s.delete(a,t)}async h({direction:t}){const[e]=await this.s.getAllMatching(a,{direction:t,index:r,query:IDBKeyRange.only(this.t),count:1});if(e)return await this.deleteEntry(e.id),e}i(t){const e=t.target.result;t.oldVersion>0&&t.oldVersion<i&&e.objectStoreNames.contains(a)&&e.deleteObjectStore(a),e.createObjectStore(a,{autoIncrement:!0,keyPath:"id"}).createIndex(r,r,{unique:!1})}}const h=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class o{static async fromRequest(t){const e={url:t.url,headers:{}};"GET"!==t.method&&(e.body=await t.clone().arrayBuffer());for(const[s,i]of t.headers.entries())e.headers[s]=i;for(const s of h)void 0!==t[s]&&(e[s]=t[s]);return new o(e)}constructor(t){"navigate"===t.mode&&(t.mode="same-origin"),this.o=t}toObject(){const t=Object.assign({},this.o);return t.headers=Object.assign({},this.o.headers),t.body&&(t.body=t.body.slice(0)),t}toRequest(){return new Request(this.o.url,this.o)}clone(){return new o(this.toObject())}}const u="workbox-background-sync",y=10080,w=new Set;class d{constructor(t,{onSync:s,maxRetentionTime:i}={}){if(w.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});w.add(t),this.u=t,this.l=s||this.replayRequests,this.q=i||y,this.m=new c(this.u),this.p()}get name(){return this.u}async pushRequest(t){await this.g(t,"push")}async unshiftRequest(t){await this.g(t,"unshift")}async popRequest(){return this.R("pop")}async shiftRequest(){return this.R("shift")}async getAll(){const t=await this.m.getAll(),e=Date.now(),s=[];for(const i of t){const t=60*this.q*1e3;e-i.timestamp>t?await this.m.deleteEntry(i.id):s.push(f(i))}return s}async g({request:t,metadata:e,timestamp:s=Date.now()},i){const n={requestData:(await o.fromRequest(t.clone())).toObject(),timestamp:s};e&&(n.metadata=e),await this.m[`${i}Entry`](n),this.k?this.D=!0:await this.registerSync()}async R(t){const e=Date.now(),s=await this.m[`${t}Entry`]();if(s){const i=60*this.q*1e3;return e-s.timestamp>i?this.R(t):f(s)}}async replayRequests(){let t;for(;t=await this.shiftRequest();)try{await fetch(t.request.clone())}catch(s){throw await this.unshiftRequest(t),new e.WorkboxError("queue-replay-failed",{name:this.u})}}async registerSync(){if("sync"in registration)try{await registration.sync.register(`${u}:${this.u}`)}catch(t){}}p(){"sync"in registration?self.addEventListener("sync",t=>{if(t.tag===`${u}:${this.u}`){const e=async()=>{let e;this.k=!0;try{await this.l({queue:this})}catch(t){throw e=t}finally{!this.D||e&&!t.lastChance||await this.registerSync(),this.k=!1,this.D=!1}};t.waitUntil(e())}}):this.l({queue:this})}static get _(){return w}}const f=t=>{const e={request:new o(t.requestData).toRequest(),timestamp:t.timestamp};return t.metadata&&(e.metadata=t.metadata),e};return t.Queue=d,t.Plugin=class{constructor(...t){this.v=new d(...t),this.fetchDidFail=this.fetchDidFail.bind(this)}async fetchDidFail({request:t}){await this.v.pushRequest({request:t})}},t}({},workbox.core._private,workbox.core._private);
|
2
|
-
//# sourceMappingURL=workbox-background-sync.prod.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"workbox-background-sync.prod.js","sources":["../_version.mjs","../lib/QueueStore.mjs","../lib/StorableRequest.mjs","../Queue.mjs","../Plugin.mjs"],"sourcesContent":["try{self['workbox:background-sync:4.3.1']&&_()}catch(e){}// eslint-disable-line","/*\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*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs';\nimport '../_version.mjs';\n\n\nconst DB_VERSION = 3;\nconst DB_NAME = 'workbox-background-sync';\nconst OBJECT_STORE_NAME = 'requests';\nconst INDEXED_PROP = 'queueName';\n\n/**\n * A class to manage storing requests from a Queue in IndexedbDB,\n * indexed by their queue name for easier access.\n *\n * @private\n */\nexport class QueueStore {\n /**\n * Associates this instance with a Queue instance, so entries added can be\n * identified by their queue name.\n *\n * @param {string} queueName\n * @private\n */\n constructor(queueName) {\n this._queueName = queueName;\n this._db = new DBWrapper(DB_NAME, DB_VERSION, {\n onupgradeneeded: this._upgradeDb,\n });\n }\n\n /**\n * Append an entry last in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async pushEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'pushEntry',\n paramName: 'entry.requestData',\n });\n }\n\n // Don't specify an ID since one is automatically generated.\n delete entry.id;\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Preppend an entry first in the queue.\n *\n * @param {Object} entry\n * @param {Object} entry.requestData\n * @param {number} [entry.timestamp]\n * @param {Object} [entry.metadata]\n * @private\n */\n async unshiftEntry(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry',\n });\n assert.isType(entry.requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'QueueStore',\n funcName: 'unshiftEntry',\n paramName: 'entry.requestData',\n });\n }\n\n const [firstEntry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n count: 1,\n });\n\n if (firstEntry) {\n // Pick an ID one less than the lowest ID in the object store.\n entry.id = firstEntry.id - 1;\n } else {\n // Otherwise let the auto-incrementor assign the ID.\n delete entry.id;\n }\n entry.queueName = this._queueName;\n\n await this._db.add(OBJECT_STORE_NAME, entry);\n }\n\n /**\n * Removes and returns the last entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async popEntry() {\n return this._removeEntry({direction: 'prev'});\n }\n\n /**\n * Removes and returns the first entry in the queue matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async shiftEntry() {\n return this._removeEntry({direction: 'next'});\n }\n\n /**\n * Returns all entries in the store matching the `queueName`.\n *\n * @param {Object} options See workbox.backgroundSync.Queue~getAll}\n * @return {Promise<Array<Object>>}\n * @private\n */\n async getAll() {\n return await this._db.getAllMatching(OBJECT_STORE_NAME, {\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n });\n }\n\n /**\n * Deletes the entry for the given ID.\n *\n * WARNING: this method does not ensure the deleted enry belongs to this\n * queue (i.e. matches the `queueName`). But this limitation is acceptable\n * as this class is not publicly exposed. An additional check would make\n * this method slower than it needs to be.\n *\n * @private\n * @param {number} id\n */\n async deleteEntry(id) {\n await this._db.delete(OBJECT_STORE_NAME, id);\n }\n\n /**\n * Removes and returns the first or last entry in the queue (based on the\n * `direction` argument) matching the `queueName`.\n *\n * @return {Promise<Object>}\n * @private\n */\n async _removeEntry({direction}) {\n const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, {\n direction,\n index: INDEXED_PROP,\n query: IDBKeyRange.only(this._queueName),\n count: 1,\n });\n\n if (entry) {\n await this.deleteEntry(entry.id);\n return entry;\n }\n }\n\n /**\n * Upgrades the database given an `upgradeneeded` event.\n *\n * @param {Event} event\n * @private\n */\n _upgradeDb(event) {\n const db = event.target.result;\n\n if (event.oldVersion > 0 && event.oldVersion < DB_VERSION) {\n if (db.objectStoreNames.contains(OBJECT_STORE_NAME)) {\n db.deleteObjectStore(OBJECT_STORE_NAME);\n }\n }\n\n const objStore = db.createObjectStore(OBJECT_STORE_NAME, {\n autoIncrement: true,\n keyPath: 'id',\n });\n objStore.createIndex(INDEXED_PROP, INDEXED_PROP, {unique: false});\n }\n}\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport '../_version.mjs';\n\n\nconst serializableProperties = [\n 'method',\n 'referrer',\n 'referrerPolicy',\n 'mode',\n 'credentials',\n 'cache',\n 'redirect',\n 'integrity',\n 'keepalive',\n];\n\n\n/**\n * A class to make it easier to serialize and de-serialize requests so they\n * can be stored in IndexedDB.\n *\n * @private\n */\nclass StorableRequest {\n /**\n * Converts a Request object to a plain object that can be structured\n * cloned or JSON-stringified.\n *\n * @param {Request} request\n * @return {Promise<StorableRequest>}\n *\n * @private\n */\n static async fromRequest(request) {\n const requestData = {\n url: request.url,\n headers: {},\n };\n\n // Set the body if present.\n if (request.method !== 'GET') {\n // Use ArrayBuffer to support non-text request bodies.\n // NOTE: we can't use Blobs becuse Safari doesn't support storing\n // Blobs in IndexedDB in some cases:\n // https://github.com/dfahlander/Dexie.js/issues/618#issuecomment-398348457\n requestData.body = await request.clone().arrayBuffer();\n }\n\n // Convert the headers from an iterable to an object.\n for (const [key, value] of request.headers.entries()) {\n requestData.headers[key] = value;\n }\n\n // Add all other serializable request properties\n for (const prop of serializableProperties) {\n if (request[prop] !== undefined) {\n requestData[prop] = request[prop];\n }\n }\n\n return new StorableRequest(requestData);\n }\n\n /**\n * Accepts an object of request data that can be used to construct a\n * `Request` but can also be stored in IndexedDB.\n *\n * @param {Object} requestData An object of request data that includes the\n * `url` plus any relevant properties of\n * [requestInit]{@link https://fetch.spec.whatwg.org/#requestinit}.\n * @private\n */\n constructor(requestData) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(requestData, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData',\n });\n assert.isType(requestData.url, 'string', {\n moduleName: 'workbox-background-sync',\n className: 'StorableRequest',\n funcName: 'constructor',\n paramName: 'requestData.url',\n });\n }\n\n // If the request's mode is `navigate`, convert it to `same-origin` since\n // navigation requests can't be constructed via script.\n if (requestData.mode === 'navigate') {\n requestData.mode = 'same-origin';\n }\n\n this._requestData = requestData;\n }\n\n /**\n * Returns a deep clone of the instances `_requestData` object.\n *\n * @return {Object}\n *\n * @private\n */\n toObject() {\n const requestData = Object.assign({}, this._requestData);\n requestData.headers = Object.assign({}, this._requestData.headers);\n if (requestData.body) {\n requestData.body = requestData.body.slice(0);\n }\n\n return requestData;\n }\n\n /**\n * Converts this instance to a Request.\n *\n * @return {Request}\n *\n * @private\n */\n toRequest() {\n return new Request(this._requestData.url, this._requestData);\n }\n\n /**\n * Creates and returns a deep clone of the instance.\n *\n * @return {StorableRequest}\n *\n * @private\n */\n clone() {\n return new StorableRequest(this.toObject());\n }\n}\n\nexport {StorableRequest};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs';\nimport {logger} from 'workbox-core/_private/logger.mjs';\nimport {assert} from 'workbox-core/_private/assert.mjs';\nimport {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs';\nimport {QueueStore} from './lib/QueueStore.mjs';\nimport {StorableRequest} from './lib/StorableRequest.mjs';\nimport './_version.mjs';\n\n\nconst TAG_PREFIX = 'workbox-background-sync';\nconst MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes\n\nconst queueNames = new Set();\n\n/**\n * A class to manage storing failed requests in IndexedDB and retrying them\n * later. All parts of the storing and replaying process are observable via\n * callbacks.\n *\n * @memberof workbox.backgroundSync\n */\nclass Queue {\n /**\n * Creates an instance of Queue with the given options\n *\n * @param {string} name The unique name for this queue. This name must be\n * unique as it's used to register sync events and store requests\n * in IndexedDB specific to this instance. An error will be thrown if\n * a duplicate name is detected.\n * @param {Object} [options]\n * @param {Function} [options.onSync] A function that gets invoked whenever\n * the 'sync' event fires. The function is invoked with an object\n * containing the `queue` property (referencing this instance), and you\n * can use the callback to customize the replay behavior of the queue.\n * When not set the `replayRequests()` method is called.\n * Note: if the replay fails after a sync event, make sure you throw an\n * error, so the browser knows to retry the sync event later.\n * @param {number} [options.maxRetentionTime=7 days] The amount of time (in\n * minutes) a request may be retried. After this amount of time has\n * passed, the request will be deleted from the queue.\n */\n constructor(name, {onSync, maxRetentionTime} = {}) {\n // Ensure the store name is not already being used\n if (queueNames.has(name)) {\n throw new WorkboxError('duplicate-queue-name', {name});\n } else {\n queueNames.add(name);\n }\n\n this._name = name;\n this._onSync = onSync || this.replayRequests;\n this._maxRetentionTime = maxRetentionTime || MAX_RETENTION_TIME;\n this._queueStore = new QueueStore(this._name);\n\n this._addSyncListener();\n }\n\n /**\n * @return {string}\n */\n get name() {\n return this._name;\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the end of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async pushRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'pushRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'push');\n }\n\n /**\n * Stores the passed request in IndexedDB (with its timestamp and any\n * metadata) at the beginning of the queue.\n *\n * @param {Object} entry\n * @param {Request} entry.request The request to store in the queue.\n * @param {Object} [entry.metadata] Any metadata you want associated with the\n * stored request. When requests are replayed you'll have access to this\n * metadata object in case you need to modify the request beforehand.\n * @param {number} [entry.timestamp] The timestamp (Epoch time in\n * milliseconds) when the request was first added to the queue. This is\n * used along with `maxRetentionTime` to remove outdated requests. In\n * general you don't need to set this value, as it's automatically set\n * for you (defaulting to `Date.now()`), but you can update it if you\n * don't want particular requests to expire.\n */\n async unshiftRequest(entry) {\n if (process.env.NODE_ENV !== 'production') {\n assert.isType(entry, 'object', {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry',\n });\n assert.isInstance(entry.request, Request, {\n moduleName: 'workbox-background-sync',\n className: 'Queue',\n funcName: 'unshiftRequest',\n paramName: 'entry.request',\n });\n }\n\n await this._addRequest(entry, 'unshift');\n }\n\n /**\n * Removes and returns the last request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async popRequest() {\n return this._removeRequest('pop');\n }\n\n /**\n * Removes and returns the first request in the queue (along with its\n * timestamp and any metadata). The returned object takes the form:\n * `{request, timestamp, metadata}`.\n *\n * @return {Promise<Object>}\n */\n async shiftRequest() {\n return this._removeRequest('shift');\n }\n\n /**\n * Returns all the entries that have not expired (per `maxRetentionTime`).\n * Any expired entries are removed from the queue.\n *\n * @return {Promise<Array<Object>>}\n */\n async getAll() {\n const allEntries = await this._queueStore.getAll();\n const now = Date.now();\n\n const unexpiredEntries = [];\n for (const entry of allEntries) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n await this._queueStore.deleteEntry(entry.id);\n } else {\n unexpiredEntries.push(convertEntry(entry));\n }\n }\n\n return unexpiredEntries;\n }\n\n\n /**\n * Adds the entry to the QueueStore and registers for a sync event.\n *\n * @param {Object} entry\n * @param {Request} entry.request\n * @param {Object} [entry.metadata]\n * @param {number} [entry.timestamp=Date.now()]\n * @param {string} operation ('push' or 'unshift')\n * @private\n */\n async _addRequest(\n {request, metadata, timestamp = Date.now()}, operation) {\n const storableRequest = await StorableRequest.fromRequest(request.clone());\n const entry = {\n requestData: storableRequest.toObject(),\n timestamp,\n };\n\n // Only include metadata if it's present.\n if (metadata) {\n entry.metadata = metadata;\n }\n\n await this._queueStore[`${operation}Entry`](entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(request.url)}' has ` +\n `been added to background sync queue '${this._name}'.`);\n }\n\n // Don't register for a sync if we're in the middle of a sync. Instead,\n // we wait until the sync is complete and call register if\n // `this._requestsAddedDuringSync` is true.\n if (this._syncInProgress) {\n this._requestsAddedDuringSync = true;\n } else {\n await this.registerSync();\n }\n }\n\n /**\n * Removes and returns the first or last (depending on `operation`) entry\n * from the QueueStore that's not older than the `maxRetentionTime`.\n *\n * @param {string} operation ('pop' or 'shift')\n * @return {Object|undefined}\n * @private\n */\n async _removeRequest(operation) {\n const now = Date.now();\n const entry = await this._queueStore[`${operation}Entry`]();\n\n if (entry) {\n // Ignore requests older than maxRetentionTime. Call this function\n // recursively until an unexpired request is found.\n const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000;\n if (now - entry.timestamp > maxRetentionTimeInMs) {\n return this._removeRequest(operation);\n }\n\n return convertEntry(entry);\n }\n }\n\n /**\n * Loops through each request in the queue and attempts to re-fetch it.\n * If any request fails to re-fetch, it's put back in the same position in\n * the queue (which registers a retry for the next sync event).\n */\n async replayRequests() {\n let entry;\n while (entry = await this.shiftRequest()) {\n try {\n await fetch(entry.request.clone());\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `has been replayed in queue '${this._name}'`);\n }\n } catch (error) {\n await this.unshiftRequest(entry);\n\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Request for '${getFriendlyURL(entry.request.url)}'` +\n `failed to replay, putting it back in queue '${this._name}'`);\n }\n throw new WorkboxError('queue-replay-failed', {name: this._name});\n }\n }\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`All requests in queue '${this.name}' have successfully ` +\n `replayed; the queue is now empty!`);\n }\n }\n\n /**\n * Registers a sync event with a tag unique to this instance.\n */\n async registerSync() {\n if ('sync' in registration) {\n try {\n await registration.sync.register(`${TAG_PREFIX}:${this._name}`);\n } catch (err) {\n // This means the registration failed for some reason, possibly due to\n // the user disabling it.\n if (process.env.NODE_ENV !== 'production') {\n logger.warn(\n `Unable to register sync event for '${this._name}'.`, err);\n }\n }\n }\n }\n\n /**\n * In sync-supporting browsers, this adds a listener for the sync event.\n * In non-sync-supporting browsers, this will retry the queue on service\n * worker startup.\n *\n * @private\n */\n _addSyncListener() {\n if ('sync' in registration) {\n self.addEventListener('sync', (event) => {\n if (event.tag === `${TAG_PREFIX}:${this._name}`) {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync for tag '${event.tag}'` +\n `has been received`);\n }\n\n const syncComplete = async () => {\n this._syncInProgress = true;\n\n let syncError;\n try {\n await this._onSync({queue: this});\n } catch (error) {\n syncError = error;\n\n // Rethrow the error. Note: the logic in the finally clause\n // will run before this gets rethrown.\n throw syncError;\n } finally {\n // New items may have been added to the queue during the sync,\n // so we need to register for a new sync if that's happened...\n // Unless there was an error during the sync, in which\n // case the browser will automatically retry later, as long\n // as `event.lastChance` is not true.\n if (this._requestsAddedDuringSync &&\n !(syncError && !event.lastChance)) {\n await this.registerSync();\n }\n\n this._syncInProgress = false;\n this._requestsAddedDuringSync = false;\n }\n };\n event.waitUntil(syncComplete());\n }\n });\n } else {\n if (process.env.NODE_ENV !== 'production') {\n logger.log(`Background sync replaying without background sync event`);\n }\n // If the browser doesn't support background sync, retry\n // every time the service worker starts up as a fallback.\n this._onSync({queue: this});\n }\n }\n\n /**\n * Returns the set of queue names. This is primarily used to reset the list\n * of queue names in tests.\n *\n * @return {Set}\n *\n * @private\n */\n static get _queueNames() {\n return queueNames;\n }\n}\n\n\n/**\n * Converts a QueueStore entry into the format exposed by Queue. This entails\n * converting the request data into a real request and omitting the `id` and\n * `queueName` properties.\n *\n * @param {Object} queueStoreEntry\n * @return {Object}\n * @private\n */\nconst convertEntry = (queueStoreEntry) => {\n const queueEntry = {\n request: new StorableRequest(queueStoreEntry.requestData).toRequest(),\n timestamp: queueStoreEntry.timestamp,\n };\n if (queueStoreEntry.metadata) {\n queueEntry.metadata = queueStoreEntry.metadata;\n }\n return queueEntry;\n};\n\nexport {Queue};\n","/*\n Copyright 2018 Google LLC\n\n Use of this source code is governed by an MIT-style\n license that can be found in the LICENSE file or at\n https://opensource.org/licenses/MIT.\n*/\n\nimport {Queue} from './Queue.mjs';\nimport './_version.mjs';\n\n/**\n * A class implementing the `fetchDidFail` lifecycle callback. This makes it\n * easier to add failed requests to a background sync Queue.\n *\n * @memberof workbox.backgroundSync\n */\nclass Plugin {\n /**\n * @param {...*} queueArgs Args to forward to the composed Queue instance.\n * See the [Queue]{@link workbox.backgroundSync.Queue} documentation for\n * parameter details.\n */\n constructor(...queueArgs) {\n this._queue = new Queue(...queueArgs);\n this.fetchDidFail = this.fetchDidFail.bind(this);\n }\n\n /**\n * @param {Object} options\n * @param {Request} options.request\n * @private\n */\n async fetchDidFail({request}) {\n await this._queue.pushRequest({request});\n }\n}\n\nexport {Plugin};\n"],"names":["self","_","e","DB_VERSION","DB_NAME","OBJECT_STORE_NAME","INDEXED_PROP","QueueStore","constructor","queueName","_queueName","_db","DBWrapper","onupgradeneeded","this","_upgradeDb","entry","id","add","firstEntry","getAllMatching","count","_removeEntry","direction","index","query","IDBKeyRange","only","delete","deleteEntry","event","db","target","result","oldVersion","objectStoreNames","contains","deleteObjectStore","createObjectStore","autoIncrement","keyPath","createIndex","unique","serializableProperties","StorableRequest","request","requestData","url","headers","method","body","clone","arrayBuffer","key","value","entries","prop","undefined","mode","_requestData","toObject","Object","assign","slice","toRequest","Request","TAG_PREFIX","MAX_RETENTION_TIME","queueNames","Set","Queue","name","onSync","maxRetentionTime","has","WorkboxError","_name","_onSync","replayRequests","_maxRetentionTime","_queueStore","_addSyncListener","_addRequest","_removeRequest","allEntries","getAll","now","Date","unexpiredEntries","maxRetentionTimeInMs","timestamp","push","convertEntry","metadata","operation","fromRequest","_syncInProgress","_requestsAddedDuringSync","registerSync","shiftRequest","fetch","error","unshiftRequest","registration","sync","register","err","addEventListener","tag","syncComplete","async","syncError","queue","lastChance","waitUntil","queueStoreEntry","queueEntry","queueArgs","_queue","fetchDidFail","bind","pushRequest"],"mappings":"uFAAA,IAAIA,KAAK,kCAAkCC,IAAI,MAAMC,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AgBzB,kBAEzByB,EAAgBtB,WAClBuB,EAAWvB,SAAWsB,EAAgBtB,UAEjCuB,6BCrXT,MAME5G,eAAe6G,QACRC,EAAS,IAAIhD,KAAS+C,QACtBE,aAAezG,KAAKyG,aAAaC,KAAK1G,0BAQ1B+B,QAACA,UACZ/B,KAAKwG,EAAOG,YAAY,CAAC5E,QAAAA"}
|
@@ -1,496 +0,0 @@
|
|
1
|
-
this.workbox = this.workbox || {};
|
2
|
-
this.workbox.broadcastUpdate = (function (exports, assert_mjs, getFriendlyURL_mjs, logger_mjs, Deferred_mjs, WorkboxError_mjs) {
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
try {
|
6
|
-
self['workbox:broadcast-update: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
|
-
/**
|
17
|
-
* Given two `Response's`, compares several header values to see if they are
|
18
|
-
* the same or not.
|
19
|
-
*
|
20
|
-
* @param {Response} firstResponse
|
21
|
-
* @param {Response} secondResponse
|
22
|
-
* @param {Array<string>} headersToCheck
|
23
|
-
* @return {boolean}
|
24
|
-
*
|
25
|
-
* @memberof workbox.broadcastUpdate
|
26
|
-
* @private
|
27
|
-
*/
|
28
|
-
|
29
|
-
const responsesAreSame = (firstResponse, secondResponse, headersToCheck) => {
|
30
|
-
{
|
31
|
-
if (!(firstResponse instanceof Response && secondResponse instanceof Response)) {
|
32
|
-
throw new WorkboxError_mjs.WorkboxError('invalid-responses-are-same-args');
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
const atLeastOneHeaderAvailable = headersToCheck.some(header => {
|
37
|
-
return firstResponse.headers.has(header) && secondResponse.headers.has(header);
|
38
|
-
});
|
39
|
-
|
40
|
-
if (!atLeastOneHeaderAvailable) {
|
41
|
-
{
|
42
|
-
logger_mjs.logger.warn(`Unable to determine where the response has been updated ` + `because none of the headers that would be checked are present.`);
|
43
|
-
logger_mjs.logger.debug(`Attempting to compare the following: `, firstResponse, secondResponse, headersToCheck);
|
44
|
-
} // Just return true, indicating the that responses are the same, since we
|
45
|
-
// can't determine otherwise.
|
46
|
-
|
47
|
-
|
48
|
-
return true;
|
49
|
-
}
|
50
|
-
|
51
|
-
return headersToCheck.every(header => {
|
52
|
-
const headerStateComparison = firstResponse.headers.has(header) === secondResponse.headers.has(header);
|
53
|
-
const headerValueComparison = firstResponse.headers.get(header) === secondResponse.headers.get(header);
|
54
|
-
return headerStateComparison && headerValueComparison;
|
55
|
-
});
|
56
|
-
};
|
57
|
-
|
58
|
-
/*
|
59
|
-
Copyright 2018 Google LLC
|
60
|
-
|
61
|
-
Use of this source code is governed by an MIT-style
|
62
|
-
license that can be found in the LICENSE file or at
|
63
|
-
https://opensource.org/licenses/MIT.
|
64
|
-
*/
|
65
|
-
const CACHE_UPDATED_MESSAGE_TYPE = 'CACHE_UPDATED';
|
66
|
-
const CACHE_UPDATED_MESSAGE_META = 'workbox-broadcast-update';
|
67
|
-
const DEFAULT_BROADCAST_CHANNEL_NAME = 'workbox';
|
68
|
-
const DEFAULT_DEFER_NOTIFICATION_TIMEOUT = 10000;
|
69
|
-
const DEFAULT_HEADERS_TO_CHECK = ['content-length', 'etag', 'last-modified'];
|
70
|
-
|
71
|
-
/*
|
72
|
-
Copyright 2018 Google LLC
|
73
|
-
|
74
|
-
Use of this source code is governed by an MIT-style
|
75
|
-
license that can be found in the LICENSE file or at
|
76
|
-
https://opensource.org/licenses/MIT.
|
77
|
-
*/
|
78
|
-
/**
|
79
|
-
* You would not normally call this method directly; it's called automatically
|
80
|
-
* by an instance of the {@link BroadcastCacheUpdate} class. It's exposed here
|
81
|
-
* for the benefit of developers who would rather not use the full
|
82
|
-
* `BroadcastCacheUpdate` implementation.
|
83
|
-
*
|
84
|
-
* Calling this will dispatch a message on the provided
|
85
|
-
* {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel}
|
86
|
-
* to notify interested subscribers about a change to a cached resource.
|
87
|
-
*
|
88
|
-
* The message that's posted has a formation inspired by the
|
89
|
-
* [Flux standard action](https://github.com/acdlite/flux-standard-action#introduction)
|
90
|
-
* format like so:
|
91
|
-
*
|
92
|
-
* ```
|
93
|
-
* {
|
94
|
-
* type: 'CACHE_UPDATED',
|
95
|
-
* meta: 'workbox-broadcast-update',
|
96
|
-
* payload: {
|
97
|
-
* cacheName: 'the-cache-name',
|
98
|
-
* updatedURL: 'https://example.com/'
|
99
|
-
* }
|
100
|
-
* }
|
101
|
-
* ```
|
102
|
-
*
|
103
|
-
* (Usage of [Flux](https://facebook.github.io/flux/) itself is not at
|
104
|
-
* all required.)
|
105
|
-
*
|
106
|
-
* @param {Object} options
|
107
|
-
* @param {string} options.cacheName The name of the cache in which the updated
|
108
|
-
* `Response` was stored.
|
109
|
-
* @param {string} options.url The URL associated with the updated `Response`.
|
110
|
-
* @param {BroadcastChannel} [options.channel] The `BroadcastChannel` to use.
|
111
|
-
* If no channel is set or the browser doesn't support the BroadcastChannel
|
112
|
-
* api, then an attempt will be made to `postMessage` each window client.
|
113
|
-
*
|
114
|
-
* @memberof workbox.broadcastUpdate
|
115
|
-
*/
|
116
|
-
|
117
|
-
const broadcastUpdate = async ({
|
118
|
-
channel,
|
119
|
-
cacheName,
|
120
|
-
url
|
121
|
-
}) => {
|
122
|
-
{
|
123
|
-
assert_mjs.assert.isType(cacheName, 'string', {
|
124
|
-
moduleName: 'workbox-broadcast-update',
|
125
|
-
className: '~',
|
126
|
-
funcName: 'broadcastUpdate',
|
127
|
-
paramName: 'cacheName'
|
128
|
-
});
|
129
|
-
assert_mjs.assert.isType(url, 'string', {
|
130
|
-
moduleName: 'workbox-broadcast-update',
|
131
|
-
className: '~',
|
132
|
-
funcName: 'broadcastUpdate',
|
133
|
-
paramName: 'url'
|
134
|
-
});
|
135
|
-
}
|
136
|
-
|
137
|
-
const data = {
|
138
|
-
type: CACHE_UPDATED_MESSAGE_TYPE,
|
139
|
-
meta: CACHE_UPDATED_MESSAGE_META,
|
140
|
-
payload: {
|
141
|
-
cacheName: cacheName,
|
142
|
-
updatedURL: url
|
143
|
-
}
|
144
|
-
};
|
145
|
-
|
146
|
-
if (channel) {
|
147
|
-
channel.postMessage(data);
|
148
|
-
} else {
|
149
|
-
const windows = await clients.matchAll({
|
150
|
-
type: 'window'
|
151
|
-
});
|
152
|
-
|
153
|
-
for (const win of windows) {
|
154
|
-
win.postMessage(data);
|
155
|
-
}
|
156
|
-
}
|
157
|
-
};
|
158
|
-
|
159
|
-
/*
|
160
|
-
Copyright 2018 Google LLC
|
161
|
-
|
162
|
-
Use of this source code is governed by an MIT-style
|
163
|
-
license that can be found in the LICENSE file or at
|
164
|
-
https://opensource.org/licenses/MIT.
|
165
|
-
*/
|
166
|
-
/**
|
167
|
-
* Uses the [Broadcast Channel API]{@link https://developers.google.com/web/updates/2016/09/broadcastchannel}
|
168
|
-
* to notify interested parties when a cached response has been updated.
|
169
|
-
* In browsers that do not support the Broadcast Channel API, the instance
|
170
|
-
* falls back to sending the update via `postMessage()` to all window clients.
|
171
|
-
*
|
172
|
-
* For efficiency's sake, the underlying response bodies are not compared;
|
173
|
-
* only specific response headers are checked.
|
174
|
-
*
|
175
|
-
* @memberof workbox.broadcastUpdate
|
176
|
-
*/
|
177
|
-
|
178
|
-
class BroadcastCacheUpdate {
|
179
|
-
/**
|
180
|
-
* Construct a BroadcastCacheUpdate instance with a specific `channelName` to
|
181
|
-
* broadcast messages on
|
182
|
-
*
|
183
|
-
* @param {Object} options
|
184
|
-
* @param {Array<string>}
|
185
|
-
* [options.headersToCheck=['content-length', 'etag', 'last-modified']]
|
186
|
-
* A list of headers that will be used to determine whether the responses
|
187
|
-
* differ.
|
188
|
-
* @param {string} [options.channelName='workbox'] The name that will be used
|
189
|
-
*. when creating the `BroadcastChannel`, which defaults to 'workbox' (the
|
190
|
-
* channel name used by the `workbox-window` package).
|
191
|
-
* @param {string} [options.deferNoticationTimeout=10000] The amount of time
|
192
|
-
* to wait for a ready message from the window on navigation requests
|
193
|
-
* before sending the update.
|
194
|
-
*/
|
195
|
-
constructor({
|
196
|
-
headersToCheck,
|
197
|
-
channelName,
|
198
|
-
deferNoticationTimeout
|
199
|
-
} = {}) {
|
200
|
-
this._headersToCheck = headersToCheck || DEFAULT_HEADERS_TO_CHECK;
|
201
|
-
this._channelName = channelName || DEFAULT_BROADCAST_CHANNEL_NAME;
|
202
|
-
this._deferNoticationTimeout = deferNoticationTimeout || DEFAULT_DEFER_NOTIFICATION_TIMEOUT;
|
203
|
-
|
204
|
-
{
|
205
|
-
assert_mjs.assert.isType(this._channelName, 'string', {
|
206
|
-
moduleName: 'workbox-broadcast-update',
|
207
|
-
className: 'BroadcastCacheUpdate',
|
208
|
-
funcName: 'constructor',
|
209
|
-
paramName: 'channelName'
|
210
|
-
});
|
211
|
-
assert_mjs.assert.isArray(this._headersToCheck, {
|
212
|
-
moduleName: 'workbox-broadcast-update',
|
213
|
-
className: 'BroadcastCacheUpdate',
|
214
|
-
funcName: 'constructor',
|
215
|
-
paramName: 'headersToCheck'
|
216
|
-
});
|
217
|
-
}
|
218
|
-
|
219
|
-
this._initWindowReadyDeferreds();
|
220
|
-
}
|
221
|
-
/**
|
222
|
-
* Compare two [Responses](https://developer.mozilla.org/en-US/docs/Web/API/Response)
|
223
|
-
* and send a message via the
|
224
|
-
* {@link https://developers.google.com/web/updates/2016/09/broadcastchannel|Broadcast Channel API}
|
225
|
-
* if they differ.
|
226
|
-
*
|
227
|
-
* Neither of the Responses can be {@link http://stackoverflow.com/questions/39109789|opaque}.
|
228
|
-
*
|
229
|
-
* @param {Object} options
|
230
|
-
* @param {Response} options.oldResponse Cached response to compare.
|
231
|
-
* @param {Response} options.newResponse Possibly updated response to compare.
|
232
|
-
* @param {string} options.url The URL of the request.
|
233
|
-
* @param {string} options.cacheName Name of the cache the responses belong
|
234
|
-
* to. This is included in the broadcast message.
|
235
|
-
* @param {Event} [options.event] event An optional event that triggered
|
236
|
-
* this possible cache update.
|
237
|
-
* @return {Promise} Resolves once the update is sent.
|
238
|
-
*/
|
239
|
-
|
240
|
-
|
241
|
-
notifyIfUpdated({
|
242
|
-
oldResponse,
|
243
|
-
newResponse,
|
244
|
-
url,
|
245
|
-
cacheName,
|
246
|
-
event
|
247
|
-
}) {
|
248
|
-
if (!responsesAreSame(oldResponse, newResponse, this._headersToCheck)) {
|
249
|
-
{
|
250
|
-
logger_mjs.logger.log(`Newer response found (and cached) for:`, url);
|
251
|
-
}
|
252
|
-
|
253
|
-
const sendUpdate = async () => {
|
254
|
-
// In the case of a navigation request, the requesting page will likely
|
255
|
-
// not have loaded its JavaScript in time to recevied the update
|
256
|
-
// notification, so we defer it until ready (or we timeout waiting).
|
257
|
-
if (event && event.request && event.request.mode === 'navigate') {
|
258
|
-
{
|
259
|
-
logger_mjs.logger.debug(`Original request was a navigation request, ` + `waiting for a ready message from the window`, event.request);
|
260
|
-
}
|
261
|
-
|
262
|
-
await this._windowReadyOrTimeout(event);
|
263
|
-
}
|
264
|
-
|
265
|
-
await this._broadcastUpdate({
|
266
|
-
channel: this._getChannel(),
|
267
|
-
cacheName,
|
268
|
-
url
|
269
|
-
});
|
270
|
-
}; // Send the update and ensure the SW stays alive until it's sent.
|
271
|
-
|
272
|
-
|
273
|
-
const done = sendUpdate();
|
274
|
-
|
275
|
-
if (event) {
|
276
|
-
try {
|
277
|
-
event.waitUntil(done);
|
278
|
-
} catch (error) {
|
279
|
-
{
|
280
|
-
logger_mjs.logger.warn(`Unable to ensure service worker stays alive ` + `when broadcasting cache update for ` + `${getFriendlyURL_mjs.getFriendlyURL(event.request.url)}'.`);
|
281
|
-
}
|
282
|
-
}
|
283
|
-
}
|
284
|
-
|
285
|
-
return done;
|
286
|
-
}
|
287
|
-
}
|
288
|
-
/**
|
289
|
-
* NOTE: this is exposed on the instance primarily so it can be spied on
|
290
|
-
* in tests.
|
291
|
-
*
|
292
|
-
* @param {Object} opts
|
293
|
-
* @private
|
294
|
-
*/
|
295
|
-
|
296
|
-
|
297
|
-
async _broadcastUpdate(opts) {
|
298
|
-
await broadcastUpdate(opts);
|
299
|
-
}
|
300
|
-
/**
|
301
|
-
* @return {BroadcastChannel|undefined} The BroadcastChannel instance used for
|
302
|
-
* broadcasting updates, or undefined if the browser doesn't support the
|
303
|
-
* Broadcast Channel API.
|
304
|
-
*
|
305
|
-
* @private
|
306
|
-
*/
|
307
|
-
|
308
|
-
|
309
|
-
_getChannel() {
|
310
|
-
if ('BroadcastChannel' in self && !this._channel) {
|
311
|
-
this._channel = new BroadcastChannel(this._channelName);
|
312
|
-
}
|
313
|
-
|
314
|
-
return this._channel;
|
315
|
-
}
|
316
|
-
/**
|
317
|
-
* Waits for a message from the window indicating that it's capable of
|
318
|
-
* receiving broadcasts. By default, this will only wait for the amount of
|
319
|
-
* time specified via the `deferNoticationTimeout` option.
|
320
|
-
*
|
321
|
-
* @param {Event} event The navigation fetch event.
|
322
|
-
* @return {Promise}
|
323
|
-
* @private
|
324
|
-
*/
|
325
|
-
|
326
|
-
|
327
|
-
_windowReadyOrTimeout(event) {
|
328
|
-
if (!this._navigationEventsDeferreds.has(event)) {
|
329
|
-
const deferred = new Deferred_mjs.Deferred(); // Set the deferred on the `_navigationEventsDeferreds` map so it will
|
330
|
-
// be resolved when the next ready message event comes.
|
331
|
-
|
332
|
-
this._navigationEventsDeferreds.set(event, deferred); // But don't wait too long for the message since it may never come.
|
333
|
-
|
334
|
-
|
335
|
-
const timeout = setTimeout(() => {
|
336
|
-
{
|
337
|
-
logger_mjs.logger.debug(`Timed out after ${this._deferNoticationTimeout}` + `ms waiting for message from window`);
|
338
|
-
}
|
339
|
-
|
340
|
-
deferred.resolve();
|
341
|
-
}, this._deferNoticationTimeout); // Ensure the timeout is cleared if the deferred promise is resolved.
|
342
|
-
|
343
|
-
deferred.promise.then(() => clearTimeout(timeout));
|
344
|
-
}
|
345
|
-
|
346
|
-
return this._navigationEventsDeferreds.get(event).promise;
|
347
|
-
}
|
348
|
-
/**
|
349
|
-
* Creates a mapping between navigation fetch events and deferreds, and adds
|
350
|
-
* a listener for message events from the window. When message events arrive,
|
351
|
-
* all deferreds in the mapping are resolved.
|
352
|
-
*
|
353
|
-
* Note: it would be easier if we could only resolve the deferred of
|
354
|
-
* navigation fetch event whose client ID matched the source ID of the
|
355
|
-
* message event, but currently client IDs are not exposed on navigation
|
356
|
-
* fetch events: https://www.chromestatus.com/feature/4846038800138240
|
357
|
-
*
|
358
|
-
* @private
|
359
|
-
*/
|
360
|
-
|
361
|
-
|
362
|
-
_initWindowReadyDeferreds() {
|
363
|
-
// A mapping between navigation events and their deferreds.
|
364
|
-
this._navigationEventsDeferreds = new Map(); // The message listener needs to be added in the initial run of the
|
365
|
-
// service worker, but since we don't actually need to be listening for
|
366
|
-
// messages until the cache updates, we only invoke the callback if set.
|
367
|
-
|
368
|
-
self.addEventListener('message', event => {
|
369
|
-
if (event.data.type === 'WINDOW_READY' && event.data.meta === 'workbox-window' && this._navigationEventsDeferreds.size > 0) {
|
370
|
-
{
|
371
|
-
logger_mjs.logger.debug(`Received WINDOW_READY event: `, event);
|
372
|
-
} // Resolve any pending deferreds.
|
373
|
-
|
374
|
-
|
375
|
-
for (const deferred of this._navigationEventsDeferreds.values()) {
|
376
|
-
deferred.resolve();
|
377
|
-
}
|
378
|
-
|
379
|
-
this._navigationEventsDeferreds.clear();
|
380
|
-
}
|
381
|
-
});
|
382
|
-
}
|
383
|
-
|
384
|
-
}
|
385
|
-
|
386
|
-
/*
|
387
|
-
Copyright 2018 Google LLC
|
388
|
-
|
389
|
-
Use of this source code is governed by an MIT-style
|
390
|
-
license that can be found in the LICENSE file or at
|
391
|
-
https://opensource.org/licenses/MIT.
|
392
|
-
*/
|
393
|
-
/**
|
394
|
-
* This plugin will automatically broadcast a message whenever a cached response
|
395
|
-
* is updated.
|
396
|
-
*
|
397
|
-
* @memberof workbox.broadcastUpdate
|
398
|
-
*/
|
399
|
-
|
400
|
-
class Plugin {
|
401
|
-
/**
|
402
|
-
* Construct a BroadcastCacheUpdate instance with the passed options and
|
403
|
-
* calls its `notifyIfUpdated()` method whenever the plugin's
|
404
|
-
* `cacheDidUpdate` callback is invoked.
|
405
|
-
*
|
406
|
-
* @param {Object} options
|
407
|
-
* @param {Array<string>}
|
408
|
-
* [options.headersToCheck=['content-length', 'etag', 'last-modified']]
|
409
|
-
* A list of headers that will be used to determine whether the responses
|
410
|
-
* differ.
|
411
|
-
* @param {string} [options.channelName='workbox'] The name that will be used
|
412
|
-
*. when creating the `BroadcastChannel`, which defaults to 'workbox' (the
|
413
|
-
* channel name used by the `workbox-window` package).
|
414
|
-
* @param {string} [options.deferNoticationTimeout=10000] The amount of time
|
415
|
-
* to wait for a ready message from the window on navigation requests
|
416
|
-
* before sending the update.
|
417
|
-
*/
|
418
|
-
constructor(options) {
|
419
|
-
this._broadcastUpdate = new BroadcastCacheUpdate(options);
|
420
|
-
}
|
421
|
-
/**
|
422
|
-
* A "lifecycle" callback that will be triggered automatically by the
|
423
|
-
* `workbox-sw` and `workbox-runtime-caching` handlers when an entry is
|
424
|
-
* added to a cache.
|
425
|
-
*
|
426
|
-
* @private
|
427
|
-
* @param {Object} options The input object to this function.
|
428
|
-
* @param {string} options.cacheName Name of the cache being updated.
|
429
|
-
* @param {Response} [options.oldResponse] The previous cached value, if any.
|
430
|
-
* @param {Response} options.newResponse The new value in the cache.
|
431
|
-
* @param {Request} options.request The request that triggered the udpate.
|
432
|
-
* @param {Request} [options.event] The event that triggered the update.
|
433
|
-
*/
|
434
|
-
|
435
|
-
|
436
|
-
cacheDidUpdate({
|
437
|
-
cacheName,
|
438
|
-
oldResponse,
|
439
|
-
newResponse,
|
440
|
-
request,
|
441
|
-
event
|
442
|
-
}) {
|
443
|
-
{
|
444
|
-
assert_mjs.assert.isType(cacheName, 'string', {
|
445
|
-
moduleName: 'workbox-broadcast-update',
|
446
|
-
className: 'Plugin',
|
447
|
-
funcName: 'cacheDidUpdate',
|
448
|
-
paramName: 'cacheName'
|
449
|
-
});
|
450
|
-
assert_mjs.assert.isInstance(newResponse, Response, {
|
451
|
-
moduleName: 'workbox-broadcast-update',
|
452
|
-
className: 'Plugin',
|
453
|
-
funcName: 'cacheDidUpdate',
|
454
|
-
paramName: 'newResponse'
|
455
|
-
});
|
456
|
-
assert_mjs.assert.isInstance(request, Request, {
|
457
|
-
moduleName: 'workbox-broadcast-update',
|
458
|
-
className: 'Plugin',
|
459
|
-
funcName: 'cacheDidUpdate',
|
460
|
-
paramName: 'request'
|
461
|
-
});
|
462
|
-
}
|
463
|
-
|
464
|
-
if (!oldResponse) {
|
465
|
-
// Without a two responses there is nothing to compare.
|
466
|
-
return;
|
467
|
-
}
|
468
|
-
|
469
|
-
this._broadcastUpdate.notifyIfUpdated({
|
470
|
-
cacheName,
|
471
|
-
oldResponse,
|
472
|
-
newResponse,
|
473
|
-
event,
|
474
|
-
url: request.url
|
475
|
-
});
|
476
|
-
}
|
477
|
-
|
478
|
-
}
|
479
|
-
|
480
|
-
/*
|
481
|
-
Copyright 2018 Google LLC
|
482
|
-
|
483
|
-
Use of this source code is governed by an MIT-style
|
484
|
-
license that can be found in the LICENSE file or at
|
485
|
-
https://opensource.org/licenses/MIT.
|
486
|
-
*/
|
487
|
-
|
488
|
-
exports.BroadcastCacheUpdate = BroadcastCacheUpdate;
|
489
|
-
exports.Plugin = Plugin;
|
490
|
-
exports.broadcastUpdate = broadcastUpdate;
|
491
|
-
exports.responsesAreSame = responsesAreSame;
|
492
|
-
|
493
|
-
return exports;
|
494
|
-
|
495
|
-
}({}, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private, workbox.core._private));
|
496
|
-
//# sourceMappingURL=workbox-broadcast-update.dev.js.map
|