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

workbox-background-sync

Package Overview
Dependencies
Maintainers
4
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 3.0.0-alpha.3 to 3.0.0-alpha.4

11

build/workbox-background-sync.dev.js

@@ -6,3 +6,3 @@ this.workbox = this.workbox || {};

try {
self.workbox.v['workbox:background-sync:3.0.0-alpha.3'] = 1;
self.workbox.v['workbox:background-sync:3.0.0-alpha.4'] = 1;
} catch (e) {} // eslint-disable-line

@@ -369,4 +369,6 @@

yield _this2._runCallback('queueDidReplay', replayedRequests);
// If any requests failed, put the failed requests back in the queue
// and register for another sync.
// and rethrow the failed requests count.
if (failedRequests.length) {

@@ -377,6 +379,4 @@ yield Promise.all(failedRequests.map(function (storableRequest) {

yield _this2._registerSync();
throw new WorkboxError_mjs.WorkboxError('queue-replay-failed', { name: _this2._name, count: failedRequests.length });
}
yield _this2._runCallback('queueDidReplay', replayedRequests);
})();

@@ -539,2 +539,3 @@ }

}(workbox.core._private,workbox.core._private));
//# sourceMappingURL=workbox-background-sync.dev.js.map

@@ -1,2 +0,3 @@

this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){"use strict";try{self.workbox.v["workbox:background-sync:3.0.0-alpha.3"]=1}catch(e){}const r=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive","signal"];class s{static fromRequest(e){return babelHelpers.asyncToGenerator(function*(){const t={headers:{}};"GET"!==e.method&&(t.body=yield e.clone().blob());for(const[r,s]of e.headers.entries())t.headers[r]=s;for(const s of r)void 0!==e[s]&&(t[s]=e[s]);return new s({url:e.url,requestInit:t})})()}constructor({url:e,requestInit:t,timestamp:r=Date.now()}){this.url=e,this.requestInit=t,this.e=r}get timestamp(){return this.e}toObject(){return{url:this.url,timestamp:this.timestamp,requestInit:this.requestInit}}toRequest(){return new Request(this.url,this.requestInit)}}class i{constructor(e){this.t=e,this.r=new t.DBWrapper("workbox-background-sync",1,{onupgradeneeded:e=>e.target.result.createObjectStore("requests",{autoIncrement:!0}).createIndex("queueName","queueName",{unique:!1})})}addEntry(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.add("requests",{queueName:t.t.name,storableRequest:e.toObject()})})()}getAndRemoveOldestEntry(){var e=this;return babelHelpers.asyncToGenerator(function*(){const[t]=yield e.r.getAllMatching("requests",{index:"queueName",query:IDBKeyRange.only(e.t.name),count:1,includeKeys:!0});if(t)return yield e.r.delete("requests",t.primaryKey),new s(t.value.storableRequest)})()}}const n=new Set;class u{constructor(t,{callbacks:r={},maxRetentionTime:s=6048e5}={}){if(n.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});n.add(t),this.s=t,this.i=r,this.n=s,this.u=new i(this),this.c()}get name(){return this.s}addRequest(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield s.fromRequest(e.clone());yield t.l("requestWillEnqueue",r),yield t.u.addEntry(r),yield t.a()})()}replayRequests(){var e=this;return babelHelpers.asyncToGenerator(function*(){const t=Date.now(),r=[],s=[];let i;for(;i=yield e.u.getAndRemoveOldestEntry();){if(t-i.timestamp>e.n)continue;yield e.l("requestWillReplay",i);const n={request:i.toRequest()};try{n.response=yield fetch(n.request.clone())}catch(e){n.error=e,s.push(i)}r.push(n)}s.length&&(yield Promise.all(s.map(function(t){return e.u.addEntry(t)})),yield e.a()),yield e.l("queueDidReplay",r)})()}l(e,...t){var r=this;return babelHelpers.asyncToGenerator(function*(){"function"==typeof r.i[e]&&(yield r.i[e].apply(null,t))})()}c(){"sync"in registration?self.addEventListener("sync",e=>{e.waitUntil(this.replayRequests())}):this.replayRequests()}a(){var e=this;return babelHelpers.asyncToGenerator(function*(){try{yield registration.sync.register(`workbox-background-sync:${e.s}`)}catch(e){}})()}static get o(){return n}}class c{constructor(...e){this.t=new u(...e),this.fetchDidFail=this.fetchDidFail.bind(this)}fetchDidFail({request:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.t.addRequest(e)})()}}return Object.freeze({Queue:u,Plugin:c})}(workbox.core._private,workbox.core._private);
this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){"use strict";try{self.workbox.v["workbox:background-sync:3.0.0-alpha.4"]=1}catch(e){}const r=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive","signal"];class s{static fromRequest(e){return babelHelpers.asyncToGenerator(function*(){const t={headers:{}};"GET"!==e.method&&(t.body=yield e.clone().blob());for(const[r,s]of e.headers.entries())t.headers[r]=s;for(const s of r)void 0!==e[s]&&(t[s]=e[s]);return new s({url:e.url,requestInit:t})})()}constructor({url:e,requestInit:t,timestamp:r=Date.now()}){this.url=e,this.requestInit=t,this.e=r}get timestamp(){return this.e}toObject(){return{url:this.url,timestamp:this.timestamp,requestInit:this.requestInit}}toRequest(){return new Request(this.url,this.requestInit)}}const n="workbox-background-sync",i="requests",u="queueName",c="workbox-background-sync",l=6048e5;class o{constructor(e){this.t=e,this.r=new t.DBWrapper(n,1,{onupgradeneeded:e=>e.target.result.createObjectStore(i,{autoIncrement:!0}).createIndex(u,u,{unique:!1})})}addEntry(e){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.r.add(i,{queueName:t.t.name,storableRequest:e.toObject()})})()}getAndRemoveOldestEntry(){var e=this;return babelHelpers.asyncToGenerator(function*(){const[t]=yield e.r.getAllMatching(i,{index:u,query:IDBKeyRange.only(e.t.name),count:1,includeKeys:!0});if(t)return yield e.r.delete(i,t.primaryKey),new s(t.value.storableRequest)})()}}const a=new Set;class h{constructor(t,{callbacks:r={},maxRetentionTime:s=l}={}){if(a.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});a.add(t),this.s=t,this.n=r,this.i=s,this.u=new o(this),this.c()}get name(){return this.s}addRequest(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield s.fromRequest(e.clone());yield t.l("requestWillEnqueue",r),yield t.u.addEntry(r),yield t.o()})()}replayRequests(){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=Date.now(),s=[],n=[];let i;for(;i=yield t.u.getAndRemoveOldestEntry();){if(r-i.timestamp>t.i)continue;yield t.l("requestWillReplay",i);const e={request:i.toRequest()};try{e.response=yield fetch(e.request.clone())}catch(t){e.error=t,n.push(i)}s.push(e)}if(yield t.l("queueDidReplay",s),n.length)throw yield Promise.all(n.map(function(e){return t.u.addEntry(e)})),new e.WorkboxError("queue-replay-failed",{name:t.s,count:n.length})})()}l(e,...t){var r=this;return babelHelpers.asyncToGenerator(function*(){"function"==typeof r.n[e]&&(yield r.n[e].apply(null,t))})()}c(){"sync"in registration?self.addEventListener("sync",e=>{e.waitUntil(this.replayRequests())}):this.replayRequests()}o(){var e=this;return babelHelpers.asyncToGenerator(function*(){try{yield registration.sync.register(`${c}:${e.s}`)}catch(e){}})()}static get a(){return a}}return Object.freeze({Queue:h,Plugin:class{constructor(...e){this.t=new h(...e),this.fetchDidFail=this.fetchDidFail.bind(this)}fetchDidFail({request:e}){var t=this;return babelHelpers.asyncToGenerator(function*(){yield t.t.addRequest(e)})()}}})}(workbox.core._private,workbox.core._private);
//# sourceMappingURL=workbox-background-sync.prod.js.map
{
"name": "workbox-background-sync",
"version": "3.0.0-alpha.3",
"version": "3.0.0-alpha.4",
"license": "Apache-2.0",

@@ -30,4 +30,4 @@ "author": "Google's Web DevRel Team",

"dependencies": {
"workbox-core": "^3.0.0-alpha.3"
"workbox-core": "^3.0.0-alpha.4"
}
}

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