Socket
Socket
Sign inDemoInstall

workbox-background-sync

Package Overview
Dependencies
Maintainers
4
Versions
97
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.6 to 3.0.0-beta.0

35

build/workbox-background-sync.dev.js
this.workbox = this.workbox || {};
this.workbox.backgroundSync = (function (WorkboxError_mjs,DBWrapper_mjs) {
this.workbox.backgroundSync = (function (WorkboxError_mjs,logger_mjs,DBWrapper_mjs) {
'use strict';
try {
self.workbox.v['workbox:background-sync:3.0.0-alpha.6'] = 1;
self.workbox.v['workbox:background-sync:3.0.0-beta.0'] = 1;
} catch (e) {} // eslint-disable-line

@@ -24,3 +24,3 @@

const serializableProperties = ['method', 'referrer', 'referrerPolicy', 'mode', 'credentials', 'cache', 'redirect', 'integrity', 'keepalive', 'signal'];
const serializableProperties = ['method', 'referrer', 'referrerPolicy', 'mode', 'credentials', 'cache', 'redirect', 'integrity', 'keepalive'];

@@ -149,3 +149,3 @@ /**

const TAG_PREFIX = 'workbox-background-sync';
const MAX_RETENTION_TIME = 1000 * 60 * 60 * 24 * 7; // 7 days
const MAX_RETENTION_TIME = 60 * 24 * 7; // 7 days in minutes

@@ -284,4 +284,4 @@ /*

* @param {number} [options.maxRetentionTime = 7 days] The amount of time (in
* ms) a request may be retried. After this amount of time has passed,
* the request will be deleted from the queue.
* minutes) a request may be retried. After this amount of time has
* passed, the request will be deleted from the queue.
*/

@@ -326,5 +326,3 @@ constructor(name, {

const storableRequest = yield StorableRequest.fromRequest(request.clone());
yield _this._runCallback('requestWillEnqueue', storableRequest);
yield _this._queueStore.addEntry(storableRequest);

@@ -353,3 +351,4 @@ yield _this._registerSync();

// Ignore requests older than maxRetentionTime.
if (now - storableRequest.timestamp > _this2._maxRetentionTime) {
const maxRetentionTimeInMs = _this2._maxRetentionTime * 60 * 1000;
if (now - storableRequest.timestamp > maxRetentionTimeInMs) {
continue;

@@ -432,8 +431,12 @@ }

return babelHelpers.asyncToGenerator(function* () {
try {
yield registration.sync.register(`${TAG_PREFIX}:${_this4._name}`);
} catch (err) {
// This means the registration failed for some reason, either because
// the browser doesn't supported it or because the user has disabled it.
// In either case, do nothing.
if ('sync' in registration) {
try {
yield registration.sync.register(`${TAG_PREFIX}:${_this4._name}`);
} catch (err) {
// This means the registration failed for some reason, possibly due to
// the user disabling it.
{
logger_mjs.logger.warn(`Unable to register sync event for '${_this4._name}'.`, err);
}
}
}

@@ -541,4 +544,4 @@ })();

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

@@ -1,3 +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.6"]=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);
this.workbox=this.workbox||{},this.workbox.backgroundSync=function(e,t){"use strict";try{self.workbox.v["workbox:background-sync:3.0.0-beta.0"]=1}catch(e){}const r=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class n{static fromRequest(e){return babelHelpers.asyncToGenerator(function*(){const t={headers:{}};"GET"!==e.method&&(t.body=yield e.clone().blob());for(const[r,n]of e.headers.entries())t.headers[r]=n;for(const n of r)void 0!==e[n]&&(t[n]=e[n]);return new n({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 s="workbox-background-sync",i="requests",u="queueName",c="workbox-background-sync",o=10080;class l{constructor(e){this.t=e,this.r=new t.DBWrapper(s,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 n(t.value.storableRequest)})()}}const a=new Set;class h{constructor(t,{callbacks:r={},maxRetentionTime:n=o}={}){if(a.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});a.add(t),this.n=t,this.s=r,this.i=n,this.u=new l(this),this.c()}get name(){return this.n}addRequest(e){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=yield n.fromRequest(e.clone());yield t.o("requestWillEnqueue",r),yield t.u.addEntry(r),yield t.l()})()}replayRequests(){var t=this;return babelHelpers.asyncToGenerator(function*(){const r=Date.now(),n=[],s=[];let i;for(;i=yield t.u.getAndRemoveOldestEntry();){const e=60*t.i*1e3;if(r-i.timestamp>e)continue;yield t.o("requestWillReplay",i);const u={request:i.toRequest()};try{u.response=yield fetch(u.request.clone())}catch(e){u.error=e,s.push(i)}n.push(u)}if(yield t.o("queueDidReplay",n),s.length)throw yield Promise.all(s.map(function(e){return t.u.addEntry(e)})),new e.WorkboxError("queue-replay-failed",{name:t.n,count:s.length})})()}o(e,...t){var r=this;return babelHelpers.asyncToGenerator(function*(){"function"==typeof r.s[e]&&(yield r.s[e].apply(null,t))})()}c(){"sync"in registration?self.addEventListener("sync",e=>{e.waitUntil(this.replayRequests())}):this.replayRequests()}l(){var e=this;return babelHelpers.asyncToGenerator(function*(){if("sync"in registration)try{yield registration.sync.register(`${c}:${e.n}`)}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.6",
"version": "3.0.0-beta.0",
"license": "Apache-2.0",

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

"dependencies": {
"workbox-core": "^3.0.0-alpha.6"
"workbox-core": "^3.0.0-beta.0"
}
}

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

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