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 3.0.0-alpha.1 to 3.0.0-alpha.2

Plugin.mjs

24

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.1'] = 1;
self.workbox.v['workbox:background-sync:3.0.0-alpha.2'] = 1;
} catch (e) {} // eslint-disable-line

@@ -40,2 +40,4 @@

* @return {Promise<StorableRequest>}
*
* @private
*/

@@ -80,2 +82,4 @@ static fromRequest(request) {

* defaulting to the current time if not specified.
*
* @private
*/

@@ -94,2 +98,4 @@ constructor({ url, requestInit, timestamp = Date.now() }) {

* @return {number}
*
* @private
*/

@@ -104,2 +110,4 @@ get timestamp() {

* @return {Object}
*
* @private
*/

@@ -118,2 +126,4 @@ toObject() {

* @return {Request}
*
* @private
*/

@@ -467,8 +477,10 @@ toRequest() {

*/
class QueuePlugin {
class Plugin {
/**
* @param {Queue} queue The Queue instance to add failed requests to.
* @param {...*} queueArgs Args to forward to the composed Queue instance.
* See the [Queue]{@link workbox.backgroundSync.Queue} documentation for
* parameter details.
*/
constructor(queue) {
this._queue = queue;
constructor(...queueArgs) {
this._queue = new Queue(...queueArgs);
this.fetchDidFail = this.fetchDidFail.bind(this);

@@ -510,3 +522,3 @@ }

Queue: Queue,
QueuePlugin: QueuePlugin
Plugin: Plugin
});

@@ -513,0 +525,0 @@

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

this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){"use strict";try{self.workbox.v["workbox:background-sync:3.0.0-alpha.1"]=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=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,QueuePlugin: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.2"]=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);
//# sourceMappingURL=workbox-background-sync.prod.js.map
{
"name": "workbox-background-sync",
"version": "3.0.0-alpha.1",
"version": "3.0.0-alpha.2",
"license": "Apache-2.0",

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

"dependencies": {
"workbox-core": "^3.0.0-alpha.1"
"workbox-core": "^3.0.0-alpha.2"
}
}

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

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