workbox-background-sync
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -70,3 +70,3 @@ /* | ||
let _requestCounter=0; let _queueCounter=0;class RequestQueue{constructor({config:a,queueName:e=defaultQueueName+'_'+_queueCounter++,idbQDb:b,broadcastChannel:c,callbacks:d}){this._isQueueNameAddedToAllQueue=!1,this._queueName=e,this._config=a,this._idbQDb=b,this._broadcastChannel=c,this._globalCallbacks=d||{},this._queue=[],this.initQueue();}async initQueue(){const a=await this._idbQDb.get(this._queueName);this._queue.concat(a);}async addQueueNameToAllQueues(){if(!this._isQueueNameAddedToAllQueue){let a=await this._idbQDb.get(allQueuesPlaceholder);a=a||[],a.includes(this._queueName)||a.push(this._queueName),this._idbQDb.put(allQueuesPlaceholder,a),this._isQueueNameAddedToAllQueue=!0;}}async saveQueue(){await this._idbQDb.put(this._queueName,this._queue);}async push({request:a}){isInstance({request:a},Request);const b=`${a.url}!${Date.now()}!${_requestCounter++}`,c=await getQueueableRequest({request:a,config:this._config});this._globalCallbacks.requestWillEnqueue&&this._globalCallbacks.requestWillEnqueue(c);try{return this._queue.push(b),this.saveQueue(),this._idbQDb.put(b,c),await this.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(tagNamePrefix+this._queueName),broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageAddedType,id:b,url:a.url}),b}catch(d){return broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageFailedType,id:b,url:a.url}),d}}async getRequestFromQueue({hash:a}){if(isType({hash:a},'string'),this._queue.includes(a)){const b=await this._idbQDb.get(a);return this._globalCallbacks.requestWillDequeue&&this._globalCallbacks.requestWillDequeue(b),b}}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}} | ||
let _requestCounter=0; let _queueCounter=0;class RequestQueue{constructor({config:a,queueName:e=defaultQueueName+'_'+_queueCounter++,idbQDb:b,broadcastChannel:c,callbacks:d}){this._isQueueNameAddedToAllQueue=!1,this._queueName=e,this._config=a,this._idbQDb=b,this._broadcastChannel=c,this._globalCallbacks=d||{},this._queue=[],this.initQueue();}async initQueue(){const a=await this._idbQDb.get(this._queueName);a&&this._queue.push(...a);}async addQueueNameToAllQueues(){if(!this._isQueueNameAddedToAllQueue){let a=await this._idbQDb.get(allQueuesPlaceholder);a=a||[],a.includes(this._queueName)||a.push(this._queueName),this._idbQDb.put(allQueuesPlaceholder,a),this._isQueueNameAddedToAllQueue=!0;}}async saveQueue(){await this._idbQDb.put(this._queueName,this._queue);}async push({request:a}){isInstance({request:a},Request);const b=`${a.url}!${Date.now()}!${_requestCounter++}`,c=await getQueueableRequest({request:a,config:this._config});this._globalCallbacks.requestWillEnqueue&&this._globalCallbacks.requestWillEnqueue(c);try{return this._queue.push(b),this.saveQueue(),this._idbQDb.put(b,c),await this.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(tagNamePrefix+this._queueName),broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageAddedType,id:b,url:a.url}),b}catch(d){return broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageFailedType,id:b,url:a.url}),d}}async getRequestFromQueue({hash:a}){if(isType({hash:a},'string'),this._queue.includes(a)){const b=await this._idbQDb.get(a);return this._globalCallbacks.requestWillDequeue&&this._globalCallbacks.requestWillDequeue(b),b}}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}} | ||
@@ -73,0 +73,0 @@ class Queue{constructor({broadcastChannel:a,callbacks:b,queueName:c,dbName:d=defaultDBName,maxRetentionTime:e=maxAge}={}){c&&isType({queueName:c},'string'),e&&isType({maxRetentionTime:e},'number'),a&&isInstance({broadcastChannel:a},BroadcastChannel),isType({dbName:d},'string'),this._dbName=d,this._queue=new RequestQueue({config:{maxAge:e},queueName:c,idbQDb:new IDBHelper(this._dbName,1,'QueueStore'),broadcastChannel:a,callbacks:b}),this._requestManager=new RequestManager({callbacks:b,queue:this._queue}),this.cleanupQueue();}cleanupQueue(){return cleanupQueue(this._dbName)}pushIntoQueue({request:a}){return isInstance({request:a},Request),this._queue.push({request:a})}replayRequests(){return this._requestManager.replayRequests()}getResponse({id:a}){return getResponse({id:a,dbName:this._dbName})}} |
@@ -70,3 +70,3 @@ /* | ||
let _requestCounter=0; let _queueCounter=0;class RequestQueue{constructor({config:a,queueName:e=defaultQueueName+'_'+_queueCounter++,idbQDb:b,broadcastChannel:c,callbacks:d}){this._isQueueNameAddedToAllQueue=!1,this._queueName=e,this._config=a,this._idbQDb=b,this._broadcastChannel=c,this._globalCallbacks=d||{},this._queue=[],this.initQueue();}async initQueue(){const a=await this._idbQDb.get(this._queueName);this._queue.concat(a);}async addQueueNameToAllQueues(){if(!this._isQueueNameAddedToAllQueue){let a=await this._idbQDb.get(allQueuesPlaceholder);a=a||[],a.includes(this._queueName)||a.push(this._queueName),this._idbQDb.put(allQueuesPlaceholder,a),this._isQueueNameAddedToAllQueue=!0;}}async saveQueue(){await this._idbQDb.put(this._queueName,this._queue);}async push({request:a}){isInstance({request:a},Request);const b=`${a.url}!${Date.now()}!${_requestCounter++}`,c=await getQueueableRequest({request:a,config:this._config});this._globalCallbacks.requestWillEnqueue&&this._globalCallbacks.requestWillEnqueue(c);try{return this._queue.push(b),this.saveQueue(),this._idbQDb.put(b,c),await this.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(tagNamePrefix+this._queueName),broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageAddedType,id:b,url:a.url}),b}catch(d){return broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageFailedType,id:b,url:a.url}),d}}async getRequestFromQueue({hash:a}){if(isType({hash:a},'string'),this._queue.includes(a)){const b=await this._idbQDb.get(a);return this._globalCallbacks.requestWillDequeue&&this._globalCallbacks.requestWillDequeue(b),b}}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}} | ||
let _requestCounter=0; let _queueCounter=0;class RequestQueue{constructor({config:a,queueName:e=defaultQueueName+'_'+_queueCounter++,idbQDb:b,broadcastChannel:c,callbacks:d}){this._isQueueNameAddedToAllQueue=!1,this._queueName=e,this._config=a,this._idbQDb=b,this._broadcastChannel=c,this._globalCallbacks=d||{},this._queue=[],this.initQueue();}async initQueue(){const a=await this._idbQDb.get(this._queueName);a&&this._queue.push(...a);}async addQueueNameToAllQueues(){if(!this._isQueueNameAddedToAllQueue){let a=await this._idbQDb.get(allQueuesPlaceholder);a=a||[],a.includes(this._queueName)||a.push(this._queueName),this._idbQDb.put(allQueuesPlaceholder,a),this._isQueueNameAddedToAllQueue=!0;}}async saveQueue(){await this._idbQDb.put(this._queueName,this._queue);}async push({request:a}){isInstance({request:a},Request);const b=`${a.url}!${Date.now()}!${_requestCounter++}`,c=await getQueueableRequest({request:a,config:this._config});this._globalCallbacks.requestWillEnqueue&&this._globalCallbacks.requestWillEnqueue(c);try{return this._queue.push(b),this.saveQueue(),this._idbQDb.put(b,c),await this.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(tagNamePrefix+this._queueName),broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageAddedType,id:b,url:a.url}),b}catch(d){return broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageFailedType,id:b,url:a.url}),d}}async getRequestFromQueue({hash:a}){if(isType({hash:a},'string'),this._queue.includes(a)){const b=await this._idbQDb.get(a);return this._globalCallbacks.requestWillDequeue&&this._globalCallbacks.requestWillDequeue(b),b}}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}} | ||
@@ -73,0 +73,0 @@ class Queue{constructor({broadcastChannel:a,callbacks:b,queueName:c,dbName:d=defaultDBName,maxRetentionTime:e=maxAge}={}){c&&isType({queueName:c},'string'),e&&isType({maxRetentionTime:e},'number'),a&&isInstance({broadcastChannel:a},BroadcastChannel),isType({dbName:d},'string'),this._dbName=d,this._queue=new RequestQueue({config:{maxAge:e},queueName:c,idbQDb:new IDBHelper(this._dbName,1,'QueueStore'),broadcastChannel:a,callbacks:b}),this._requestManager=new RequestManager({callbacks:b,queue:this._queue}),this.cleanupQueue();}cleanupQueue(){return cleanupQueue(this._dbName)}pushIntoQueue({request:a}){return isInstance({request:a},Request),this._queue.push({request:a})}replayRequests(){return this._requestManager.replayRequests()}getResponse({id:a}){return getResponse({id:a,dbName:this._dbName})}} |
@@ -53,3 +53,3 @@ /* | ||
let _requestCounter=0; let _queueCounter=0;class RequestQueue{constructor({config:a,queueName:e=defaultQueueName+'_'+_queueCounter++,idbQDb:b,broadcastChannel:c,callbacks:d}){this._isQueueNameAddedToAllQueue=!1,this._queueName=e,this._config=a,this._idbQDb=b,this._broadcastChannel=c,this._globalCallbacks=d||{},this._queue=[],this.initQueue();}async initQueue(){const a=await this._idbQDb.get(this._queueName);this._queue.concat(a);}async addQueueNameToAllQueues(){if(!this._isQueueNameAddedToAllQueue){let a=await this._idbQDb.get(allQueuesPlaceholder);a=a||[],a.includes(this._queueName)||a.push(this._queueName),this._idbQDb.put(allQueuesPlaceholder,a),this._isQueueNameAddedToAllQueue=!0;}}async saveQueue(){await this._idbQDb.put(this._queueName,this._queue);}async push({request:a}){isInstance({request:a},Request);const b=`${a.url}!${Date.now()}!${_requestCounter++}`,c=await getQueueableRequest({request:a,config:this._config});this._globalCallbacks.requestWillEnqueue&&this._globalCallbacks.requestWillEnqueue(c);try{return this._queue.push(b),this.saveQueue(),this._idbQDb.put(b,c),await this.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(tagNamePrefix+this._queueName),broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageAddedType,id:b,url:a.url}),b}catch(d){return broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageFailedType,id:b,url:a.url}),d}}async getRequestFromQueue({hash:a}){if(isType({hash:a},'string'),this._queue.includes(a)){const b=await this._idbQDb.get(a);return this._globalCallbacks.requestWillDequeue&&this._globalCallbacks.requestWillDequeue(b),b}}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}} | ||
let _requestCounter=0; let _queueCounter=0;class RequestQueue{constructor({config:a,queueName:e=defaultQueueName+'_'+_queueCounter++,idbQDb:b,broadcastChannel:c,callbacks:d}){this._isQueueNameAddedToAllQueue=!1,this._queueName=e,this._config=a,this._idbQDb=b,this._broadcastChannel=c,this._globalCallbacks=d||{},this._queue=[],this.initQueue();}async initQueue(){const a=await this._idbQDb.get(this._queueName);a&&this._queue.push(...a);}async addQueueNameToAllQueues(){if(!this._isQueueNameAddedToAllQueue){let a=await this._idbQDb.get(allQueuesPlaceholder);a=a||[],a.includes(this._queueName)||a.push(this._queueName),this._idbQDb.put(allQueuesPlaceholder,a),this._isQueueNameAddedToAllQueue=!0;}}async saveQueue(){await this._idbQDb.put(this._queueName,this._queue);}async push({request:a}){isInstance({request:a},Request);const b=`${a.url}!${Date.now()}!${_requestCounter++}`,c=await getQueueableRequest({request:a,config:this._config});this._globalCallbacks.requestWillEnqueue&&this._globalCallbacks.requestWillEnqueue(c);try{return this._queue.push(b),this.saveQueue(),this._idbQDb.put(b,c),await this.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(tagNamePrefix+this._queueName),broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageAddedType,id:b,url:a.url}),b}catch(d){return broadcastMessage({broadcastChannel:this._broadcastChannel,type:broadcastMessageFailedType,id:b,url:a.url}),d}}async getRequestFromQueue({hash:a}){if(isType({hash:a},'string'),this._queue.includes(a)){const b=await this._idbQDb.get(a);return this._globalCallbacks.requestWillDequeue&&this._globalCallbacks.requestWillDequeue(b),b}}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}} | ||
@@ -56,0 +56,0 @@ return RequestQueue; |
{ | ||
"name": "workbox-background-sync", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Queues failed requests and uses the Background Sync API to replay them when the network is available", | ||
@@ -24,4 +24,4 @@ "keywords": [ | ||
"homepage": "https://github.com/GoogleChrome/workbox/tree/master/packages/workbox-background-sync", | ||
"main": "build/importScripts/workbox-background-sync.prod.v1.1.0.js", | ||
"module": "build/modules/workbox-background-sync.prod.v1.1.0.mjs" | ||
"main": "build/importScripts/workbox-background-sync.prod.v1.2.0.js", | ||
"module": "build/modules/workbox-background-sync.prod.v1.2.0.mjs" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
888529
7