New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sw-background-sync-queue

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sw-background-sync-queue - npm Package Compare versions

Comparing version 0.0.18 to 0.0.19

12

build/background-sync-queue.js

@@ -804,2 +804,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -1578,2 +1579,13 @@ }());

}
/**
* Replays all the requests in the queue, this can be used for custom timing
* of replaying requests may be in an environment where sync event is not
* supported
*
* @memberOf BackgroundSyncQueue
*/
replayRequests() {
return this._requestManager.replayRequests();
}
}

@@ -1580,0 +1592,0 @@

2

build/background-sync-queue.min.js

@@ -22,3 +22,3 @@ /*

one or more '${H}' elements.`;Array.isArray(G[I])||throwError(J);for(let K of G[I])typeof K!==H&&throwError(J)},isArrayOfClass:function isArrayOfClass(G,H){const I=Object.keys(G).pop(),J=`The '${I}' parameter should be an array containing
one or more '${H.name}' instances.`;Array.isArray(G[I])||throwError(J);for(let K of G[I])K instanceof H||throwError(J)}};let u='bgQueueSyncDB';var w=createCommonjsModule(function(G){'use strict';(function(){function toArray(I){return Array.prototype.slice.call(I)}function promisifyRequest(I){return new Promise(function(J,K){I.onsuccess=function(){J(I.result)},I.onerror=function(){K(I.error)}})}function promisifyRequestCall(I,J,K){var L,M=new Promise(function(N,O){L=I[J].apply(I,K),promisifyRequest(L).then(N,O)});return M.request=L,M}function promisifyCursorRequestCall(I,J,K){var L=promisifyRequestCall(I,J,K);return L.then(function(M){return M?new Cursor(M,L.request):void 0})}function proxyProperties(I,J,K){K.forEach(function(L){Object.defineProperty(I.prototype,L,{get:function(){return this[J][L]},set:function(M){this[J][L]=M}})})}function proxyRequestMethods(I,J,K,L){L.forEach(function(M){M in K.prototype&&(I.prototype[M]=function(){return promisifyRequestCall(this[J],M,arguments)})})}function proxyMethods(I,J,K,L){L.forEach(function(M){M in K.prototype&&(I.prototype[M]=function(){return this[J][M].apply(this[J],arguments)})})}function proxyCursorRequestMethods(I,J,K,L){L.forEach(function(M){M in K.prototype&&(I.prototype[M]=function(){return promisifyCursorRequestCall(this[J],M,arguments)})})}function Index(I){this._index=I}function Cursor(I,J){this._cursor=I,this._request=J}function ObjectStore(I){this._store=I}function Transaction(I){this._tx=I,this.complete=new Promise(function(J,K){I.oncomplete=function(){J()},I.onerror=function(){K(I.error)},I.onabort=function(){K(I.error)}})}function UpgradeDB(I,J,K){this._db=I,this.oldVersion=J,this.transaction=new Transaction(K)}function DB(I){this._db=I}proxyProperties(Index,'_index',['name','keyPath','multiEntry','unique']),proxyRequestMethods(Index,'_index',IDBIndex,['get','getKey','getAll','getAllKeys','count']),proxyCursorRequestMethods(Index,'_index',IDBIndex,['openCursor','openKeyCursor']),proxyProperties(Cursor,'_cursor',['direction','key','primaryKey','value']),proxyRequestMethods(Cursor,'_cursor',IDBCursor,['update','delete']),['advance','continue','continuePrimaryKey'].forEach(function(I){I in IDBCursor.prototype&&(Cursor.prototype[I]=function(){var J=this,K=arguments;return Promise.resolve().then(function(){return J._cursor[I].apply(J._cursor,K),promisifyRequest(J._request).then(function(L){return L?new Cursor(L,J._request):void 0})})})}),ObjectStore.prototype.createIndex=function(){return new Index(this._store.createIndex.apply(this._store,arguments))},ObjectStore.prototype.index=function(){return new Index(this._store.index.apply(this._store,arguments))},proxyProperties(ObjectStore,'_store',['name','keyPath','indexNames','autoIncrement']),proxyRequestMethods(ObjectStore,'_store',IDBObjectStore,['put','add','delete','clear','get','getAll','getKey','getAllKeys','count']),proxyCursorRequestMethods(ObjectStore,'_store',IDBObjectStore,['openCursor','openKeyCursor']),proxyMethods(ObjectStore,'_store',IDBObjectStore,['deleteIndex']),Transaction.prototype.objectStore=function(){return new ObjectStore(this._tx.objectStore.apply(this._tx,arguments))},proxyProperties(Transaction,'_tx',['objectStoreNames','mode']),proxyMethods(Transaction,'_tx',IDBTransaction,['abort']),UpgradeDB.prototype.createObjectStore=function(){return new ObjectStore(this._db.createObjectStore.apply(this._db,arguments))},proxyProperties(UpgradeDB,'_db',['name','version','objectStoreNames']),proxyMethods(UpgradeDB,'_db',IDBDatabase,['deleteObjectStore','close']),DB.prototype.transaction=function(){return new Transaction(this._db.transaction.apply(this._db,arguments))},proxyProperties(DB,'_db',['name','version','objectStoreNames']),proxyMethods(DB,'_db',IDBDatabase,['close']),['openCursor','openKeyCursor'].forEach(function(I){[ObjectStore,Index].forEach(function(J){J.prototype[I.replace('open','iterate')]=function(){var K=toArray(arguments),L=K[K.length-1],M=this._store||this._index,N=M[I].apply(M,K.slice(0,-1));N.onsuccess=function(){L(N.result)}}})}),[Index,ObjectStore].forEach(function(I){I.prototype.getAll||(I.prototype.getAll=function(J,K){var L=this,M=[];return new Promise(function(N){L.iterateCursor(J,function(O){return O?(M.push(O.value),void 0!==K&&M.length==K?void N(M):void O.continue()):void N(M)})})})});G.exports={open:function(I,J,K){var L=promisifyRequestCall(indexedDB,'open',[I,J]),M=L.request;return M.onupgradeneeded=function(N){K&&K(new UpgradeDB(M.result,N.oldVersion,M.transaction))},L.then(function(N){return new DB(N)})},delete:function(I){return promisifyRequestCall(indexedDB,'deleteDatabase',[I])}}})()});class IDBHelper{constructor(G,H,I){if(G==void 0||H==void 0||I==void 0)throw Error('name, version, storeName must be passed to the constructor.');this._name=G,this._version=H,this._storeName=I}_getDb(){return this._dbPromise?this._dbPromise:(this._dbPromise=w.open(this._name,this._version,(G)=>{G.createObjectStore(this._storeName)}).then((G)=>{return G}),this._dbPromise)}close(){return this._dbPromise?this._dbPromise.then((G)=>{G.close(),this._dbPromise=null}):void 0}put(G,H){return this._getDb().then((I)=>{const J=I.transaction(this._storeName,'readwrite'),K=J.objectStore(this._storeName);return K.put(H,G),J.complete})}delete(G){return this._getDb().then((H)=>{const I=H.transaction(this._storeName,'readwrite'),J=I.objectStore(this._storeName);return J.delete(G),I.complete})}get(G){return this._getDb().then((H)=>{return H.transaction(this._storeName).objectStore(this._storeName).get(G)})}getAllValues(){return this._getDb().then((G)=>{return G.transaction(this._storeName).objectStore(this._storeName).getAll()})}getAllKeys(){return this._getDb().then((G)=>{return G.transaction(this._storeName).objectStore(this._storeName).getAllKeys()})}}var x=function(G){return function(){var H=G.apply(this,arguments);return new Promise(function(I,J){function step(K,L){try{var M=H[K](L),N=M.value}catch(O){return void J(O)}return M.done?void I(N):Promise.resolve(N).then(function(O){step('next',O)},function(O){step('throw',O)})}return step('next')})}};let y=(()=>{var G=x(function*({hash:H,idbObject:I,response:J,idbQDb:K}){I.response={headers:JSON.stringify([...J.headers]),status:J.status,body:yield J.blob()},K.put(H,I)});return function putResponse(){return G.apply(this,arguments)}})(),z=(()=>{var G=x(function*({id:H}){const I=new IDBHelper(getDbName(),1,'QueueStore'),J=yield I.get(H);return J&&J.response?J.response:null});return function getResponse(){return G.apply(this,arguments)}})(),A=(()=>{var G=x(function*({request:H,config:I}){let J={config:I,metadata:{creationTimestamp:Date.now()},request:{url:H.url,headers:JSON.stringify([...H.headers]),mode:H.mode,method:H.method,redirect:H.redirect,credentials:H.credentials}};const K=yield H.text();return 0<K.length&&(J.request.body=K),J});return function getQueueableRequest(){return G.apply(this,arguments)}})(),B=(()=>{var G=x(function*({idbRequestObject:H}){let I={mode:H.mode,method:H.method,redirect:H.redirect,headers:new Headers(JSON.parse(H.headers)),credentials:H.credentials};return H.body&&(I.body=H.body),new Request(H.url,I)});return function getFetchableRequest(){return G.apply(this,arguments)}})(),C=(()=>{var G=x(function*(){let H=new IDBHelper(getDbName(),1,'QueueStore'),I=yield H.get(m);return I?void(yield Promise.all(I.map((()=>{var J=x(function*(K){const L=yield H.get(K);let M=[],N=[];yield Promise.all(L.map((()=>{var O=x(function*(P){const Q=yield H.get(P);Q&&Q.metadata&&Q.metadata.creationTimestamp+Q.config.maxAge<=Date.now()?N.push(H.delete(P)):M.push(P)});return function(){return O.apply(this,arguments)}})())),yield Promise.all(N),H.put(K,M)});return function(){return J.apply(this,arguments)}})()))):null});return function cleanupQueue(){return G.apply(this,arguments)}})();class RequestManager{constructor({callbacks:G,queue:H}){this._globalCallbacks=G||{},this._queue=H,this.attachSyncHandler()}attachSyncHandler(){self.addEventListener('sync',(G)=>{(G.tag===h+this._queue.queueName||G.tag==='SW_BACKGROUND_QUEUE_TAG_REPLAY')&&G.waitUntil(this.replayRequests())})}replayRequests(){var G=this;return this._queue.queue.reduce((H,I)=>{return H.then((()=>{var J=x(function*(){const L=yield G._queue.getRequestFromQueue({hash:I});if(!L.response){const M=yield B({idbRequestObject:L.request});return fetch(M).then(function(N){return N.ok?void(y({hash:I,idbObject:L,response:N.clone(),idbQDb:G._queue.idbQDb}),G._globalCallbacks.onResponse&&G._globalCallbacks.onResponse(I,N)):Promise.resolve()}).catch(function(N){G._globalCallbacks.onRetryFailure&&G._globalCallbacks.onRetryFailure(I,N)})}});return function(){return J.apply(this,arguments)}})())},Promise.resolve())}}let D=0,E=0;class RequestQueue{constructor({config:G,queueName:J='DEFAULT_QUEUE'+'_'+E++,idbQDb:H,broadcastChannel:I}){this._isQueueNameAddedToAllQueue=!1,this._queueName=J,this._config=G,this._idbQDb=H,this._broadcastChannel=I,this._queue=[],this.initQueue()}initQueue(){var G=this;return x(function*(){const H=yield G._idbQDb.get(G._queueName);G._queue.concat(H)})()}addQueueNameToAllQueues(){var G=this;return x(function*(){if(!G._isQueueNameAddedToAllQueue){let H=yield G._idbQDb.get(m);H=H||[],H.includes(G._queueName)||H.push(G._queueName),G._idbQDb.put(m,H),G._isQueueNameAddedToAllQueue=!0}})()}saveQueue(){var G=this;return x(function*(){yield G._idbQDb.put(G._queueName,G._queue)})()}push({request:G}){var H=this;return x(function*(){t.isInstance({request:G},Request);const I=`${G.url}!${Date.now()}!${D++}`,J=yield A({request:G,config:H._config});try{H._queue.push(I),H.saveQueue(),H._idbQDb.put(I,J),yield H.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(h+H._queueName),broadcastMessage({broadcastChannel:H._broadcastChannel,type:'BACKGROUND_REQUESTED_ADDED',id:I,url:G.url})}catch(K){broadcastMessage({broadcastChannel:H._broadcastChannel,type:'BACKGROUND_REQUESTED_FAILED',id:I,url:G.url})}})()}getRequestFromQueue({hash:G}){var H=this;return x(function*(){if(t.isType({hash:G},'string'),H._queue.includes(G))return yield H._idbQDb.get(G)})()}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}}let F=(()=>{var G=x(function*({dbName:H}={}){H&&(t.isType({dbName:H},'string'),setDbName(H)),yield C()});return function initialize(){return G.apply(this,arguments)}})();a.initialize=F,a.getResponse=z,a.BackgroundSyncQueue=class BackgroundSyncQueue{constructor({maxRetentionTime:J=432000000,callbacks:G,queueName:H,broadcastChannel:I}={}){H&&t.isType({queueName:H},'string'),J&&t.isType({maxRetentionTime:J},'number'),I&&t.isInstance({broadcastChannel:I},BroadcastChannel),this._queue=new RequestQueue({config:{maxAge:J},queueName:H,idbQDb:new IDBHelper(getDbName(),1,'QueueStore'),broadcastChannel:I}),this._requestManager=new RequestManager({callbacks:G,queue:this._queue})}pushIntoQueue({request:G}){return t.isInstance({request:G},Request),this._queue.push({request:G})}fetchDidFail({request:G}){return this.pushIntoQueue({request:G})}},Object.defineProperty(a,'__esModule',{value:!0})});
one or more '${H.name}' instances.`;Array.isArray(G[I])||throwError(J);for(let K of G[I])K instanceof H||throwError(J)}};let u='bgQueueSyncDB';var w=createCommonjsModule(function(G){'use strict';(function(){function toArray(I){return Array.prototype.slice.call(I)}function promisifyRequest(I){return new Promise(function(J,K){I.onsuccess=function(){J(I.result)},I.onerror=function(){K(I.error)}})}function promisifyRequestCall(I,J,K){var L,M=new Promise(function(N,O){L=I[J].apply(I,K),promisifyRequest(L).then(N,O)});return M.request=L,M}function promisifyCursorRequestCall(I,J,K){var L=promisifyRequestCall(I,J,K);return L.then(function(M){return M?new Cursor(M,L.request):void 0})}function proxyProperties(I,J,K){K.forEach(function(L){Object.defineProperty(I.prototype,L,{get:function(){return this[J][L]},set:function(M){this[J][L]=M}})})}function proxyRequestMethods(I,J,K,L){L.forEach(function(M){M in K.prototype&&(I.prototype[M]=function(){return promisifyRequestCall(this[J],M,arguments)})})}function proxyMethods(I,J,K,L){L.forEach(function(M){M in K.prototype&&(I.prototype[M]=function(){return this[J][M].apply(this[J],arguments)})})}function proxyCursorRequestMethods(I,J,K,L){L.forEach(function(M){M in K.prototype&&(I.prototype[M]=function(){return promisifyCursorRequestCall(this[J],M,arguments)})})}function Index(I){this._index=I}function Cursor(I,J){this._cursor=I,this._request=J}function ObjectStore(I){this._store=I}function Transaction(I){this._tx=I,this.complete=new Promise(function(J,K){I.oncomplete=function(){J()},I.onerror=function(){K(I.error)},I.onabort=function(){K(I.error)}})}function UpgradeDB(I,J,K){this._db=I,this.oldVersion=J,this.transaction=new Transaction(K)}function DB(I){this._db=I}proxyProperties(Index,'_index',['name','keyPath','multiEntry','unique']),proxyRequestMethods(Index,'_index',IDBIndex,['get','getKey','getAll','getAllKeys','count']),proxyCursorRequestMethods(Index,'_index',IDBIndex,['openCursor','openKeyCursor']),proxyProperties(Cursor,'_cursor',['direction','key','primaryKey','value']),proxyRequestMethods(Cursor,'_cursor',IDBCursor,['update','delete']),['advance','continue','continuePrimaryKey'].forEach(function(I){I in IDBCursor.prototype&&(Cursor.prototype[I]=function(){var J=this,K=arguments;return Promise.resolve().then(function(){return J._cursor[I].apply(J._cursor,K),promisifyRequest(J._request).then(function(L){return L?new Cursor(L,J._request):void 0})})})}),ObjectStore.prototype.createIndex=function(){return new Index(this._store.createIndex.apply(this._store,arguments))},ObjectStore.prototype.index=function(){return new Index(this._store.index.apply(this._store,arguments))},proxyProperties(ObjectStore,'_store',['name','keyPath','indexNames','autoIncrement']),proxyRequestMethods(ObjectStore,'_store',IDBObjectStore,['put','add','delete','clear','get','getAll','getKey','getAllKeys','count']),proxyCursorRequestMethods(ObjectStore,'_store',IDBObjectStore,['openCursor','openKeyCursor']),proxyMethods(ObjectStore,'_store',IDBObjectStore,['deleteIndex']),Transaction.prototype.objectStore=function(){return new ObjectStore(this._tx.objectStore.apply(this._tx,arguments))},proxyProperties(Transaction,'_tx',['objectStoreNames','mode']),proxyMethods(Transaction,'_tx',IDBTransaction,['abort']),UpgradeDB.prototype.createObjectStore=function(){return new ObjectStore(this._db.createObjectStore.apply(this._db,arguments))},proxyProperties(UpgradeDB,'_db',['name','version','objectStoreNames']),proxyMethods(UpgradeDB,'_db',IDBDatabase,['deleteObjectStore','close']),DB.prototype.transaction=function(){return new Transaction(this._db.transaction.apply(this._db,arguments))},proxyProperties(DB,'_db',['name','version','objectStoreNames']),proxyMethods(DB,'_db',IDBDatabase,['close']),['openCursor','openKeyCursor'].forEach(function(I){[ObjectStore,Index].forEach(function(J){J.prototype[I.replace('open','iterate')]=function(){var K=toArray(arguments),L=K[K.length-1],M=this._store||this._index,N=M[I].apply(M,K.slice(0,-1));N.onsuccess=function(){L(N.result)}}})}),[Index,ObjectStore].forEach(function(I){I.prototype.getAll||(I.prototype.getAll=function(J,K){var L=this,M=[];return new Promise(function(N){L.iterateCursor(J,function(O){return O?(M.push(O.value),void 0!==K&&M.length==K?void N(M):void O.continue()):void N(M)})})})});G.exports={open:function(I,J,K){var L=promisifyRequestCall(indexedDB,'open',[I,J]),M=L.request;return M.onupgradeneeded=function(N){K&&K(new UpgradeDB(M.result,N.oldVersion,M.transaction))},L.then(function(N){return new DB(N)})},delete:function(I){return promisifyRequestCall(indexedDB,'deleteDatabase',[I])}},G.exports.default=G.exports})()});class IDBHelper{constructor(G,H,I){if(G==void 0||H==void 0||I==void 0)throw Error('name, version, storeName must be passed to the constructor.');this._name=G,this._version=H,this._storeName=I}_getDb(){return this._dbPromise?this._dbPromise:(this._dbPromise=w.open(this._name,this._version,(G)=>{G.createObjectStore(this._storeName)}).then((G)=>{return G}),this._dbPromise)}close(){return this._dbPromise?this._dbPromise.then((G)=>{G.close(),this._dbPromise=null}):void 0}put(G,H){return this._getDb().then((I)=>{const J=I.transaction(this._storeName,'readwrite'),K=J.objectStore(this._storeName);return K.put(H,G),J.complete})}delete(G){return this._getDb().then((H)=>{const I=H.transaction(this._storeName,'readwrite'),J=I.objectStore(this._storeName);return J.delete(G),I.complete})}get(G){return this._getDb().then((H)=>{return H.transaction(this._storeName).objectStore(this._storeName).get(G)})}getAllValues(){return this._getDb().then((G)=>{return G.transaction(this._storeName).objectStore(this._storeName).getAll()})}getAllKeys(){return this._getDb().then((G)=>{return G.transaction(this._storeName).objectStore(this._storeName).getAllKeys()})}}var x=function(G){return function(){var H=G.apply(this,arguments);return new Promise(function(I,J){function step(K,L){try{var M=H[K](L),N=M.value}catch(O){return void J(O)}return M.done?void I(N):Promise.resolve(N).then(function(O){step('next',O)},function(O){step('throw',O)})}return step('next')})}};let y=(()=>{var G=x(function*({hash:H,idbObject:I,response:J,idbQDb:K}){I.response={headers:JSON.stringify([...J.headers]),status:J.status,body:yield J.blob()},K.put(H,I)});return function putResponse(){return G.apply(this,arguments)}})(),z=(()=>{var G=x(function*({id:H}){const I=new IDBHelper(getDbName(),1,'QueueStore'),J=yield I.get(H);return J&&J.response?J.response:null});return function getResponse(){return G.apply(this,arguments)}})(),A=(()=>{var G=x(function*({request:H,config:I}){let J={config:I,metadata:{creationTimestamp:Date.now()},request:{url:H.url,headers:JSON.stringify([...H.headers]),mode:H.mode,method:H.method,redirect:H.redirect,credentials:H.credentials}};const K=yield H.text();return 0<K.length&&(J.request.body=K),J});return function getQueueableRequest(){return G.apply(this,arguments)}})(),B=(()=>{var G=x(function*({idbRequestObject:H}){let I={mode:H.mode,method:H.method,redirect:H.redirect,headers:new Headers(JSON.parse(H.headers)),credentials:H.credentials};return H.body&&(I.body=H.body),new Request(H.url,I)});return function getFetchableRequest(){return G.apply(this,arguments)}})(),C=(()=>{var G=x(function*(){let H=new IDBHelper(getDbName(),1,'QueueStore'),I=yield H.get(m);return I?void(yield Promise.all(I.map((()=>{var J=x(function*(K){const L=yield H.get(K);let M=[],N=[];yield Promise.all(L.map((()=>{var O=x(function*(P){const Q=yield H.get(P);Q&&Q.metadata&&Q.metadata.creationTimestamp+Q.config.maxAge<=Date.now()?N.push(H.delete(P)):M.push(P)});return function(){return O.apply(this,arguments)}})())),yield Promise.all(N),H.put(K,M)});return function(){return J.apply(this,arguments)}})()))):null});return function cleanupQueue(){return G.apply(this,arguments)}})();class RequestManager{constructor({callbacks:G,queue:H}){this._globalCallbacks=G||{},this._queue=H,this.attachSyncHandler()}attachSyncHandler(){self.addEventListener('sync',(G)=>{(G.tag===h+this._queue.queueName||G.tag==='SW_BACKGROUND_QUEUE_TAG_REPLAY')&&G.waitUntil(this.replayRequests())})}replayRequests(){var G=this;return this._queue.queue.reduce((H,I)=>{return H.then((()=>{var J=x(function*(){const L=yield G._queue.getRequestFromQueue({hash:I});if(!L.response){const M=yield B({idbRequestObject:L.request});return fetch(M).then(function(N){return N.ok?void(y({hash:I,idbObject:L,response:N.clone(),idbQDb:G._queue.idbQDb}),G._globalCallbacks.onResponse&&G._globalCallbacks.onResponse(I,N)):Promise.resolve()}).catch(function(N){G._globalCallbacks.onRetryFailure&&G._globalCallbacks.onRetryFailure(I,N)})}});return function(){return J.apply(this,arguments)}})())},Promise.resolve())}}let D=0,E=0;class RequestQueue{constructor({config:G,queueName:J='DEFAULT_QUEUE'+'_'+E++,idbQDb:H,broadcastChannel:I}){this._isQueueNameAddedToAllQueue=!1,this._queueName=J,this._config=G,this._idbQDb=H,this._broadcastChannel=I,this._queue=[],this.initQueue()}initQueue(){var G=this;return x(function*(){const H=yield G._idbQDb.get(G._queueName);G._queue.concat(H)})()}addQueueNameToAllQueues(){var G=this;return x(function*(){if(!G._isQueueNameAddedToAllQueue){let H=yield G._idbQDb.get(m);H=H||[],H.includes(G._queueName)||H.push(G._queueName),G._idbQDb.put(m,H),G._isQueueNameAddedToAllQueue=!0}})()}saveQueue(){var G=this;return x(function*(){yield G._idbQDb.put(G._queueName,G._queue)})()}push({request:G}){var H=this;return x(function*(){t.isInstance({request:G},Request);const I=`${G.url}!${Date.now()}!${D++}`,J=yield A({request:G,config:H._config});try{H._queue.push(I),H.saveQueue(),H._idbQDb.put(I,J),yield H.addQueueNameToAllQueues(),self.registration&&self.registration.sync.register(h+H._queueName),broadcastMessage({broadcastChannel:H._broadcastChannel,type:'BACKGROUND_REQUESTED_ADDED',id:I,url:G.url})}catch(K){broadcastMessage({broadcastChannel:H._broadcastChannel,type:'BACKGROUND_REQUESTED_FAILED',id:I,url:G.url})}})()}getRequestFromQueue({hash:G}){var H=this;return x(function*(){if(t.isType({hash:G},'string'),H._queue.includes(G))return yield H._idbQDb.get(G)})()}get queue(){return Object.assign([],this._queue)}get queueName(){return this._queueName}get idbQDb(){return this._idbQDb}}let F=(()=>{var G=x(function*({dbName:H}={}){H&&(t.isType({dbName:H},'string'),setDbName(H)),yield C()});return function initialize(){return G.apply(this,arguments)}})();a.initialize=F,a.getResponse=z,a.BackgroundSyncQueue=class BackgroundSyncQueue{constructor({maxRetentionTime:J=432000000,callbacks:G,queueName:H,broadcastChannel:I}={}){H&&t.isType({queueName:H},'string'),J&&t.isType({maxRetentionTime:J},'number'),I&&t.isInstance({broadcastChannel:I},BroadcastChannel),this._queue=new RequestQueue({config:{maxAge:J},queueName:H,idbQDb:new IDBHelper(getDbName(),1,'QueueStore'),broadcastChannel:I}),this._requestManager=new RequestManager({callbacks:G,queue:this._queue})}pushIntoQueue({request:G}){return t.isInstance({request:G},Request),this._queue.push({request:G})}fetchDidFail({request:G}){return this.pushIntoQueue({request:G})}replayRequests(){return this._requestManager.replayRequests()}},Object.defineProperty(a,'__esModule',{value:!0})});
//# sourceMappingURL=background-sync-queue.min.js.map

@@ -793,2 +793,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -1485,2 +1486,13 @@ }());

}
/**
* Replays all the requests in the queue, this can be used for custom timing
* of replaying requests may be in an environment where sync event is not
* supported
*
* @memberOf BackgroundSyncQueue
*/
replayRequests() {
return this._requestManager.replayRequests();
}
}

@@ -1487,0 +1499,0 @@

@@ -331,2 +331,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -333,0 +334,0 @@ }());

@@ -337,2 +337,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -339,0 +340,0 @@ }());

@@ -660,2 +660,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -662,0 +663,0 @@ }());

@@ -337,2 +337,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -339,0 +340,0 @@ }());

@@ -670,2 +670,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -672,0 +673,0 @@ }());

@@ -804,2 +804,3 @@ /*

module.exports = exp;
module.exports.default = module.exports;
}

@@ -1578,2 +1579,13 @@ }());

}
/**
* Replays all the requests in the queue, this can be used for custom timing
* of replaying requests may be in an environment where sync event is not
* supported
*
* @memberOf BackgroundSyncQueue
*/
replayRequests() {
return this._requestManager.replayRequests();
}
}

@@ -1580,0 +1592,0 @@

{
"name": "sw-background-sync-queue",
"version": "0.0.18",
"version": "0.0.19",
"description": "Queues failed requests and uses the Background Sync API to replay those requests at a later time when the network state has changed.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,2 +0,4 @@

<!-- DO NOT EDIT. This page is autogenerated. --># sw-background-sync-queue
<!-- DO NOT EDIT. This page is autogenerated. -->
<!-- To make changes, edit templates/Project-README.hbs, not this file. -->
# sw-background-sync-queue

@@ -3,0 +5,0 @@ Queues failed requests and uses the Background Sync API to replay those requests at a later time when the network state has changed.

@@ -124,4 +124,15 @@ import RequestManager from './request-manager';

}
/**
* Replays all the requests in the queue, this can be used for custom timing
* of replaying requests may be in an environment where sync event is not
* supported
*
* @memberOf BackgroundSyncQueue
*/
replayRequests() {
return this._requestManager.replayRequests();
}
}
export default BackgroundSyncQueue;

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

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