diff options
Diffstat (limited to 'node_modules/workbox-background-sync')
| -rw-r--r-- | node_modules/workbox-background-sync/LICENSE | 201 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/Plugin.mjs | 46 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/Queue.mjs | 249 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/README.md | 1 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/_public.mjs | 23 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/_version.mjs | 1 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/browser.mjs | 19 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/index.mjs | 22 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/models/QueueStore.mjs | 82 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/models/StorableRequest.mjs | 151 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/package.json | 32 | ||||
| -rw-r--r-- | node_modules/workbox-background-sync/utils/constants.mjs | 22 |
12 files changed, 0 insertions, 849 deletions
diff --git a/node_modules/workbox-background-sync/LICENSE b/node_modules/workbox-background-sync/LICENSE deleted file mode 100644 index 136b9039..00000000 --- a/node_modules/workbox-background-sync/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2017 Google, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/node_modules/workbox-background-sync/Plugin.mjs b/node_modules/workbox-background-sync/Plugin.mjs deleted file mode 100644 index f61f0d71..00000000 --- a/node_modules/workbox-background-sync/Plugin.mjs +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import {Queue} from './Queue.mjs'; -import './_version.mjs'; - -/** - * A class implementing the `fetchDidFail` lifecycle callback. This makes it - * easier to add failed requests to a background sync Queue. - * - * @memberof workbox.backgroundSync - */ -class Plugin { - /** - * @param {...*} queueArgs Args to forward to the composed Queue instance. - * See the [Queue]{@link workbox.backgroundSync.Queue} documentation for - * parameter details. - */ - constructor(...queueArgs) { - this._queue = new Queue(...queueArgs); - this.fetchDidFail = this.fetchDidFail.bind(this); - } - - /** - * @param {Object} options - * @param {Request} options.request - * @private - */ - async fetchDidFail({request}) { - await this._queue.addRequest(request); - } -} - -export {Plugin}; diff --git a/node_modules/workbox-background-sync/Queue.mjs b/node_modules/workbox-background-sync/Queue.mjs deleted file mode 100644 index 21df3867..00000000 --- a/node_modules/workbox-background-sync/Queue.mjs +++ /dev/null @@ -1,249 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import {WorkboxError} from 'workbox-core/_private/WorkboxError.mjs'; -import {logger} from 'workbox-core/_private/logger.mjs'; -import {assert} from 'workbox-core/_private/assert.mjs'; -import {getFriendlyURL} from 'workbox-core/_private/getFriendlyURL.mjs'; -import {QueueStore} from './models/QueueStore.mjs'; -import StorableRequest from './models/StorableRequest.mjs'; -import {TAG_PREFIX, MAX_RETENTION_TIME} from './utils/constants.mjs'; -import './_version.mjs'; - -const queueNames = new Set(); - -/** - * A class to manage storing failed requests in IndexedDB and retrying them - * later. All parts of the storing and replaying process are observable via - * callbacks. - * - * @memberof workbox.backgroundSync - */ -class Queue { - /** - * Creates an instance of Queue with the given options - * - * @param {string} name The unique name for this queue. This name must be - * unique as it's used to register sync events and store requests - * in IndexedDB specific to this instance. An error will be thrown if - * a duplicate name is detected. - * @param {Object} [options] - * @param {Object} [options.callbacks] Callbacks to observe the lifecycle of - * queued requests. Use these to respond to or modify the requests - * during the replay process. - * @param {function(StorableRequest):undefined} - * [options.callbacks.requestWillEnqueue] - * Invoked immediately before the request is stored to IndexedDB. Use - * this callback to modify request data at store time. - * @param {function(StorableRequest):undefined} - * [options.callbacks.requestWillReplay] - * Invoked immediately before the request is re-fetched. Use this - * callback to modify request data at fetch time. - * @param {function(Array<StorableRequest>):undefined} - * [options.callbacks.queueDidReplay] - * Invoked after all requests in the queue have successfully replayed. - * @param {number} [options.maxRetentionTime = 7 days] The amount of time (in - * minutes) a request may be retried. After this amount of time has - * passed, the request will be deleted from the queue. - */ - constructor(name, { - callbacks = {}, - maxRetentionTime = MAX_RETENTION_TIME, - } = {}) { - // Ensure the store name is not already being used - if (queueNames.has(name)) { - throw new WorkboxError('duplicate-queue-name', {name}); - } else { - queueNames.add(name); - } - - this._name = name; - this._callbacks = callbacks; - this._maxRetentionTime = maxRetentionTime; - this._queueStore = new QueueStore(this); - - this._addSyncListener(); - } - - /** - * @return {string} - */ - get name() { - return this._name; - } - - /** - * Stores the passed request into IndexedDB. The database used is - * `workbox-background-sync` and the object store name is the same as - * the name this instance was created with (to guarantee it's unique). - * - * @param {Request} request The request object to store. - */ - async addRequest(request) { - if (process.env.NODE_ENV !== 'production') { - assert.isInstance(request, Request, { - moduleName: 'workbox-background-sync', - className: 'Queue', - funcName: 'addRequest', - paramName: 'request', - }); - } - - const storableRequest = await StorableRequest.fromRequest(request.clone()); - await this._runCallback('requestWillEnqueue', storableRequest); - await this._queueStore.addEntry(storableRequest); - await this._registerSync(); - if (process.env.NODE_ENV !== 'production') { - logger.log(`Request for '${getFriendlyURL(storableRequest.url)}' has been - added to background sync queue '${this._name}'.`); - } - } - - /** - * Retrieves all stored requests in IndexedDB and retries them. If the - * queue contained requests that were successfully replayed, the - * `queueDidReplay` callback is invoked (which implies the queue is - * now empty). If any of the requests fail, a new sync registration is - * created to retry again later. - */ - async replayRequests() { - const now = Date.now(); - const replayedRequests = []; - const failedRequests = []; - - let storableRequest; - while (storableRequest = await this._queueStore.getAndRemoveOldestEntry()) { - // Make a copy so the unmodified request can be stored - // in the event of a replay failure. - const storableRequestClone = storableRequest.clone(); - - // Ignore requests older than maxRetentionTime. - const maxRetentionTimeInMs = this._maxRetentionTime * 60 * 1000; - if (now - storableRequest.timestamp > maxRetentionTimeInMs) { - continue; - } - - await this._runCallback('requestWillReplay', storableRequest); - - const replay = {request: storableRequest.toRequest()}; - - try { - // Clone the request before fetching so callbacks get an unused one. - replay.response = await fetch(replay.request.clone()); - if (process.env.NODE_ENV !== 'production') { - logger.log(`Request for '${getFriendlyURL(storableRequest.url)}' - has been replayed`); - } - } catch (err) { - if (process.env.NODE_ENV !== 'production') { - logger.log(`Request for '${getFriendlyURL(storableRequest.url)}' - failed to replay`); - } - replay.error = err; - failedRequests.push(storableRequestClone); - } - - replayedRequests.push(replay); - } - - await this._runCallback('queueDidReplay', replayedRequests); - - // If any requests failed, put the failed requests back in the queue - // and rethrow the failed requests count. - if (failedRequests.length) { - await Promise.all(failedRequests.map((storableRequest) => { - return this._queueStore.addEntry(storableRequest); - })); - - throw new WorkboxError('queue-replay-failed', - {name: this._name, count: failedRequests.length}); - } - } - - /** - * Runs the passed callback if it exists. - * - * @private - * @param {string} name The name of the callback on this._callbacks. - * @param {...*} args The arguments to invoke the callback with. - */ - async _runCallback(name, ...args) { - if (typeof this._callbacks[name] === 'function') { - await this._callbacks[name].apply(null, args); - } - } - - /** - * In sync-supporting browsers, this adds a listener for the sync event. - * In non-sync-supporting browsers, this will retry the queue on service - * worker startup. - * - * @private - */ - _addSyncListener() { - if ('sync' in registration) { - self.addEventListener('sync', (event) => { - if (event.tag === `${TAG_PREFIX}:${this._name}`) { - if (process.env.NODE_ENV !== 'production') { - logger.log(`Background sync for tag '${event.tag}' - has been received, starting replay now`); - } - event.waitUntil(this.replayRequests()); - } - }); - } else { - if (process.env.NODE_ENV !== 'production') { - logger.log(`Background sync replaying without background sync event`); - } - // If the browser doesn't support background sync, retry - // every time the service worker starts up as a fallback. - this.replayRequests(); - } - } - - /** - * Registers a sync event with a tag unique to this instance. - * - * @private - */ - async _registerSync() { - if ('sync' in registration) { - try { - await registration.sync.register(`${TAG_PREFIX}:${this._name}`); - } catch (err) { - // This means the registration failed for some reason, possibly due to - // the user disabling it. - if (process.env.NODE_ENV !== 'production') { - logger.warn( - `Unable to register sync event for '${this._name}'.`, err); - } - } - } - } - - /** - * Returns the set of queue names. This is primarily used to reset the list - * of queue names in tests. - * - * @return {Set} - * - * @private - */ - static get _queueNames() { - return queueNames; - } -} - -export {Queue}; diff --git a/node_modules/workbox-background-sync/README.md b/node_modules/workbox-background-sync/README.md deleted file mode 100644 index af63198d..00000000 --- a/node_modules/workbox-background-sync/README.md +++ /dev/null @@ -1 +0,0 @@ -This module's documentation can be found at https://developers.google.com/web/tools/workbox/modules/workbox-background-sync diff --git a/node_modules/workbox-background-sync/_public.mjs b/node_modules/workbox-background-sync/_public.mjs deleted file mode 100644 index 9cecc946..00000000 --- a/node_modules/workbox-background-sync/_public.mjs +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import {Queue} from './Queue.mjs'; -import {Plugin} from './Plugin.mjs'; -import './_version.mjs'; - -export { - Queue, - Plugin, -}; diff --git a/node_modules/workbox-background-sync/_version.mjs b/node_modules/workbox-background-sync/_version.mjs deleted file mode 100644 index 6a85bad3..00000000 --- a/node_modules/workbox-background-sync/_version.mjs +++ /dev/null @@ -1 +0,0 @@ -try{self.workbox.v['workbox:background-sync:3.6.3']=1;}catch(e){} // eslint-disable-line
\ No newline at end of file diff --git a/node_modules/workbox-background-sync/browser.mjs b/node_modules/workbox-background-sync/browser.mjs deleted file mode 100644 index 996a6921..00000000 --- a/node_modules/workbox-background-sync/browser.mjs +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import * as publicAPI from './_public.mjs'; -import './_version.mjs'; - -export default publicAPI; diff --git a/node_modules/workbox-background-sync/index.mjs b/node_modules/workbox-background-sync/index.mjs deleted file mode 100644 index 5559c821..00000000 --- a/node_modules/workbox-background-sync/index.mjs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import './_version.mjs'; - -/** - * @namespace workbox.backgroundSync - */ - -export * from './_public.mjs'; diff --git a/node_modules/workbox-background-sync/models/QueueStore.mjs b/node_modules/workbox-background-sync/models/QueueStore.mjs deleted file mode 100644 index 6f880d88..00000000 --- a/node_modules/workbox-background-sync/models/QueueStore.mjs +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import {DBWrapper} from 'workbox-core/_private/DBWrapper.mjs'; -import StorableRequest from './StorableRequest.mjs'; -import {DB_NAME, OBJECT_STORE_NAME, INDEXED_PROP} from '../utils/constants.mjs'; -import '../_version.mjs'; - -/** - * A class to manage storing requests from a Queue in IndexedbDB, - * indexed by their queue name for easier access. - * - * @private - */ -export class QueueStore { - /** - * Associates this instance with a Queue instance, so entries added can be - * identified by their queue name. - * - * @param {Queue} queue - * - * @private - */ - constructor(queue) { - this._queue = queue; - this._db = new DBWrapper(DB_NAME, 1, { - onupgradeneeded: (evt) => evt.target.result - .createObjectStore(OBJECT_STORE_NAME, {autoIncrement: true}) - .createIndex(INDEXED_PROP, INDEXED_PROP, {unique: false}), - }); - } - - /** - * Takes a StorableRequest instance, converts it to an object and adds it - * as an entry in the object store. - * - * @param {StorableRequest} storableRequest - * - * @private - */ - async addEntry(storableRequest) { - await this._db.add(OBJECT_STORE_NAME, { - queueName: this._queue.name, - storableRequest: storableRequest.toObject(), - }); - } - - /** - * Gets the oldest entry in the object store, removes it, and returns the - * value as a StorableRequest instance. If no entry exists, it returns - * undefined. - * - * @return {StorableRequest|undefined} - * - * @private - */ - async getAndRemoveOldestEntry() { - const [entry] = await this._db.getAllMatching(OBJECT_STORE_NAME, { - index: INDEXED_PROP, - query: IDBKeyRange.only(this._queue.name), - count: 1, - includeKeys: true, - }); - - if (entry) { - await this._db.delete(OBJECT_STORE_NAME, entry.primaryKey); - return new StorableRequest(entry.value.storableRequest); - } - } -} diff --git a/node_modules/workbox-background-sync/models/StorableRequest.mjs b/node_modules/workbox-background-sync/models/StorableRequest.mjs deleted file mode 100644 index dc03b47b..00000000 --- a/node_modules/workbox-background-sync/models/StorableRequest.mjs +++ /dev/null @@ -1,151 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import '../_version.mjs'; - -const serializableProperties = [ - 'method', - 'referrer', - 'referrerPolicy', - 'mode', - 'credentials', - 'cache', - 'redirect', - 'integrity', - 'keepalive', -]; - - -/** - * A class to make it easier to serialize and de-serialize requests so they - * can be stored in IndexedDB. - * - * @private - */ -export default class StorableRequest { - /** - * Converts a Request object to a plain object that can be structured - * cloned or JSON-stringified. - * - * @param {Request} request - * @return {Promise<StorableRequest>} - * - * @private - */ - static async fromRequest(request) { - const requestInit = {headers: {}}; - - // Set the body if present. - if (request.method !== 'GET') { - // Use blob to support non-text request bodies, - // and clone first in case the caller still needs the request. - requestInit.body = await request.clone().blob(); - } - - // Convert the headers from an iterable to an object. - for (const [key, value] of request.headers.entries()) { - requestInit.headers[key] = value; - } - - // Add all other serializable request properties - for (const prop of serializableProperties) { - if (request[prop] !== undefined) { - requestInit[prop] = request[prop]; - } - } - - return new StorableRequest({url: request.url, requestInit}); - } - - /** - * Accepts a URL and RequestInit dictionary that can be used to create a - * new Request object. A timestamp is also generated so consumers can - * reference when the object was created. - * - * @param {Object} param1 - * @param {string} param1.url - * @param {Object} param1.requestInit - * See: https://fetch.spec.whatwg.org/#requestinit - * @param {number} param1.timestamp The time the request was created, - * defaulting to the current time if not specified. - * - * @private - */ - constructor({url, requestInit, timestamp = Date.now()}) { - this.url = url; - this.requestInit = requestInit; - - // "Private" - this._timestamp = timestamp; - } - - /** - * Gets the private _timestamp property. - * - * @return {number} - * - * @private - */ - get timestamp() { - return this._timestamp; - } - - /** - * Coverts this instance to a plain Object. - * - * @return {Object} - * - * @private - */ - toObject() { - return { - url: this.url, - timestamp: this.timestamp, - requestInit: this.requestInit, - }; - } - - /** - * Converts this instance to a Request. - * - * @return {Request} - * - * @private - */ - toRequest() { - return new Request(this.url, this.requestInit); - } - - /** - * Creates and returns a deep clone of the instance. - * - * @return {StorableRequest} - * - * @private - */ - clone() { - const requestInit = Object.assign({}, this.requestInit); - requestInit.headers = Object.assign({}, this.requestInit.headers); - if (this.requestInit.body) { - requestInit.body = this.requestInit.body.slice(); - } - - return new StorableRequest({ - url: this.url, - timestamp: this.timestamp, - requestInit, - }); - } -} diff --git a/node_modules/workbox-background-sync/package.json b/node_modules/workbox-background-sync/package.json deleted file mode 100644 index c093fe1c..00000000 --- a/node_modules/workbox-background-sync/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "workbox-background-sync", - "version": "3.6.3", - "license": "Apache-2.0", - "author": "Google's Web DevRel Team", - "description": "Queues failed requests and uses the Background Sync API to replay them when the network is available", - "repository": "googlechrome/workbox", - "bugs": "https://github.com/googlechrome/workbox/issues", - "homepage": "https://github.com/GoogleChrome/workbox", - "keywords": [ - "workbox", - "workboxjs", - "service worker", - "sw", - "background", - "sync" - ], - "scripts": { - "build": "gulp build-packages --package workbox-background-sync", - "version": "npm run build", - "prepare": "npm run build" - }, - "workbox": { - "browserNamespace": "workbox.backgroundSync", - "packageType": "browser" - }, - "main": "build/workbox-background-sync.prod.js", - "module": "index.mjs", - "dependencies": { - "workbox-core": "^3.6.3" - } -} diff --git a/node_modules/workbox-background-sync/utils/constants.mjs b/node_modules/workbox-background-sync/utils/constants.mjs deleted file mode 100644 index c915b8ab..00000000 --- a/node_modules/workbox-background-sync/utils/constants.mjs +++ /dev/null @@ -1,22 +0,0 @@ -/* - Copyright 2017 Google Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -import '../_version.mjs'; - -export const DB_NAME = 'workbox-background-sync'; -export const OBJECT_STORE_NAME = 'requests'; -export const INDEXED_PROP = 'queueName'; -export const TAG_PREFIX = 'workbox-background-sync'; -export const MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes |
