workbox-background-sync
Advanced tools
Comparing version 4.0.0-rc.4 to 4.0.0
@@ -6,3 +6,3 @@ this.workbox = this.workbox || {}; | ||
try { | ||
self['workbox:background-sync:4.0.0-rc.4'] && _(); | ||
self['workbox:background-sync:4.0.0'] && _(); | ||
} catch (e) {} // eslint-disable-line | ||
@@ -9,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
this.workbox=this.workbox||{},this.workbox.backgroundSync=function(t,e,s,i){"use strict";try{self["workbox:background-sync:4.0.0-rc.4"]&&_()}catch(t){}const n=2,r="workbox-background-sync",a="requests",c="queueName",o="workbox-background-sync",h=10080;class u{constructor(t){this.t=t,this.s=new s.DBWrapper(r,n,{onupgradeneeded:t=>this.i(t)})}async pushEntry(t){delete t.id,t.queueName=this.t,await this.s.add(a,t)}async unshiftEntry(t){const[e]=await this.s.getAllMatching(a,{count:1});e?t.id=e.id-1:delete t.id,t.queueName=this.t,await this.s.add(a,t)}async popEntry(){return this.o({direction:"prev"})}async shiftEntry(){return this.o({direction:"next"})}async o({direction:t}){const[e]=await this.s.getAllMatching(a,{direction:t,index:c,query:IDBKeyRange.only(this.t),count:1});if(e)return await this.s.delete(a,e.id),delete e.id,delete e.queueName,e}i(t){const e=t.target.result,s=t.target.transaction;let n=[];i.migrateDb(t,{v1:t=>{if(e.objectStoreNames.contains(a)){s.objectStore(a).openCursor().onsuccess=(({target:s})=>{const i=s.result;i?(n.push(i.value),i.continue()):(e.deleteObjectStore(a),t())})}else t()},v2:t=>{const s=e.createObjectStore(a,{autoIncrement:!0,keyPath:"id"});if(s.createIndex(c,c,{unique:!1}),n.length)for(const t of n){const{queueName:e,storableRequest:i}=t,n=i.timestamp,r=Object.assign(i.requestInit,{url:i.url});s.add({queueName:e,timestamp:n,requestData:r})}t()}})}}const y=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class w{static async fromRequest(t){const e={url:t.url,headers:{}};"GET"!==t.method&&(e.body=await t.clone().blob());for(const[s,i]of t.headers.entries())e.headers[s]=i;for(const s of y)void 0!==t[s]&&(e[s]=t[s]);return new w(e)}constructor(t){this.h=t}toObject(){const t=Object.assign({},this.h);return t.headers=Object.assign({},this.h.headers),t.body&&(t.body=t.body.slice()),t}toRequest(){return new Request(this.h.url,this.h)}clone(){return new w(this.toObject())}}const d=new Set;class f{constructor(t,{onSync:s,maxRetentionTime:i}={}){if(d.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});d.add(t),this.u=t,this.q=s||this.replayRequests,this.l=i||h,this.m=new u(this.u),this.p()}get name(){return this.u}async pushRequest(t){await this.g(t,"push")}async unshiftRequest(t){await this.g(t,"unshift")}async popRequest(){return this.R("pop")}async shiftRequest(){return this.R("shift")}async g({request:t,metadata:e,timestamp:s=Date.now()},i){const n={requestData:(await w.fromRequest(t.clone())).toObject(),timestamp:s};e&&(n.metadata=e),await this.m[`${i}Entry`](n),await this.registerSync()}async R(t){const e=Date.now(),s=await this.m[`${t}Entry`]();if(s){const i=60*this.l*1e3;return e-s.timestamp>i?this.R(t):(s.request=new w(s.requestData).toRequest(),delete s.requestData,s)}}async replayRequests(){let t;for(;t=await this.shiftRequest();)try{await fetch(t.request)}catch(s){throw await this.unshiftRequest(t),new e.WorkboxError("queue-replay-failed",{name:this.u})}}async registerSync(){if("sync"in registration)try{await registration.sync.register(`${o}:${this.u}`)}catch(t){}}p(){"sync"in registration?self.addEventListener("sync",t=>{t.tag===`${o}:${this.u}`&&t.waitUntil(this.q({queue:this}))}):this.q({queue:this})}static get k(){return d}}return t.Queue=f,t.Plugin=class{constructor(...t){this.v=new f(...t),this.fetchDidFail=this.fetchDidFail.bind(this)}async fetchDidFail({request:t}){await this.v.pushRequest({request:t})}},t}({},workbox.core._private,workbox.core._private,workbox.core._private); | ||
this.workbox=this.workbox||{},this.workbox.backgroundSync=function(t,e,s,i){"use strict";try{self["workbox:background-sync:4.0.0"]&&_()}catch(t){}const n=2,r="workbox-background-sync",a="requests",c="queueName",o="workbox-background-sync",h=10080;class u{constructor(t){this.t=t,this.s=new s.DBWrapper(r,n,{onupgradeneeded:t=>this.i(t)})}async pushEntry(t){delete t.id,t.queueName=this.t,await this.s.add(a,t)}async unshiftEntry(t){const[e]=await this.s.getAllMatching(a,{count:1});e?t.id=e.id-1:delete t.id,t.queueName=this.t,await this.s.add(a,t)}async popEntry(){return this.o({direction:"prev"})}async shiftEntry(){return this.o({direction:"next"})}async o({direction:t}){const[e]=await this.s.getAllMatching(a,{direction:t,index:c,query:IDBKeyRange.only(this.t),count:1});if(e)return await this.s.delete(a,e.id),delete e.id,delete e.queueName,e}i(t){const e=t.target.result,s=t.target.transaction;let n=[];i.migrateDb(t,{v1:t=>{if(e.objectStoreNames.contains(a)){s.objectStore(a).openCursor().onsuccess=(({target:s})=>{const i=s.result;i?(n.push(i.value),i.continue()):(e.deleteObjectStore(a),t())})}else t()},v2:t=>{const s=e.createObjectStore(a,{autoIncrement:!0,keyPath:"id"});if(s.createIndex(c,c,{unique:!1}),n.length)for(const t of n){const{queueName:e,storableRequest:i}=t,n=i.timestamp,r=Object.assign(i.requestInit,{url:i.url});s.add({queueName:e,timestamp:n,requestData:r})}t()}})}}const y=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class w{static async fromRequest(t){const e={url:t.url,headers:{}};"GET"!==t.method&&(e.body=await t.clone().blob());for(const[s,i]of t.headers.entries())e.headers[s]=i;for(const s of y)void 0!==t[s]&&(e[s]=t[s]);return new w(e)}constructor(t){this.h=t}toObject(){const t=Object.assign({},this.h);return t.headers=Object.assign({},this.h.headers),t.body&&(t.body=t.body.slice()),t}toRequest(){return new Request(this.h.url,this.h)}clone(){return new w(this.toObject())}}const d=new Set;class f{constructor(t,{onSync:s,maxRetentionTime:i}={}){if(d.has(t))throw new e.WorkboxError("duplicate-queue-name",{name:t});d.add(t),this.u=t,this.q=s||this.replayRequests,this.l=i||h,this.m=new u(this.u),this.p()}get name(){return this.u}async pushRequest(t){await this.g(t,"push")}async unshiftRequest(t){await this.g(t,"unshift")}async popRequest(){return this.R("pop")}async shiftRequest(){return this.R("shift")}async g({request:t,metadata:e,timestamp:s=Date.now()},i){const n={requestData:(await w.fromRequest(t.clone())).toObject(),timestamp:s};e&&(n.metadata=e),await this.m[`${i}Entry`](n),await this.registerSync()}async R(t){const e=Date.now(),s=await this.m[`${t}Entry`]();if(s){const i=60*this.l*1e3;return e-s.timestamp>i?this.R(t):(s.request=new w(s.requestData).toRequest(),delete s.requestData,s)}}async replayRequests(){let t;for(;t=await this.shiftRequest();)try{await fetch(t.request)}catch(s){throw await this.unshiftRequest(t),new e.WorkboxError("queue-replay-failed",{name:this.u})}}async registerSync(){if("sync"in registration)try{await registration.sync.register(`${o}:${this.u}`)}catch(t){}}p(){"sync"in registration?self.addEventListener("sync",t=>{t.tag===`${o}:${this.u}`&&t.waitUntil(this.q({queue:this}))}):this.q({queue:this})}static get k(){return d}}return t.Queue=f,t.Plugin=class{constructor(...t){this.v=new f(...t),this.fetchDidFail=this.fetchDidFail.bind(this)}async fetchDidFail({request:t}){await this.v.pushRequest({request:t})}},t}({},workbox.core._private,workbox.core._private,workbox.core._private); | ||
//# sourceMappingURL=workbox-background-sync.prod.js.map |
{ | ||
"name": "workbox-background-sync", | ||
"version": "4.0.0-rc.4", | ||
"version": "4.0.0", | ||
"license": "MIT", | ||
@@ -30,5 +30,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^4.0.0-rc.4" | ||
"workbox-core": "^4.0.0" | ||
}, | ||
"gitHead": "cddab54b7b1b7fee18765dcf8350f7e118285efb" | ||
"gitHead": "51ec243c7afc67d5cec835b685bd9ad1e70fb78b" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
110698
Updatedworkbox-core@^4.0.0