Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

workbox-background-sync

Package Overview
Dependencies
Maintainers
3
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workbox-background-sync - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

build/importScripts/workbox-background-sync.dev.v1.2.0.js

2

build/test/background-sync-queue-plugin.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc