workbox-background-sync
Advanced tools
Comparing version 4.0.0-beta.0 to 4.0.0-beta.1
this.workbox = this.workbox || {}; | ||
this.workbox.backgroundSync = (function (assert_mjs,DBWrapper_mjs,migrateDb_mjs,WorkboxError_mjs,logger_mjs,getFriendlyURL_mjs) { | ||
this.workbox.backgroundSync = (function (exports,assert_mjs,DBWrapper_mjs,migrateDb_mjs,WorkboxError_mjs,logger_mjs,getFriendlyURL_mjs) { | ||
'use strict'; | ||
try { | ||
self.workbox.v['workbox:background-sync:4.0.0-beta.0'] = 1; | ||
self.workbox.v['workbox:background-sync:4.0.0-beta.1'] = 1; | ||
} catch (e) {} // eslint-disable-line | ||
@@ -399,3 +399,3 @@ | ||
* can use the callback to customize the replay behavior of the queue. | ||
*. When not set the `replayRequests()` method is called. | ||
* When not set the `replayRequests()` method is called. | ||
* @param {number} [options.maxRetentionTime=7 days] The amount of time (in | ||
@@ -559,3 +559,3 @@ * minutes) a request may be retried. After this amount of time has | ||
{ | ||
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(storableRequest.url)}' has ` + `been added to background sync queue '${this._name}'.`); | ||
logger_mjs.logger.log(`Request for '${getFriendlyURL_mjs.getFriendlyURL(request.url)}' has ` + `been added to background sync queue '${this._name}'.`); | ||
} | ||
@@ -741,19 +741,9 @@ } | ||
var publicAPI = /*#__PURE__*/Object.freeze({ | ||
Queue: Queue, | ||
Plugin: Plugin | ||
}); | ||
exports.Queue = Queue; | ||
exports.Plugin = Plugin; | ||
/* | ||
Copyright 2018 Google LLC | ||
return exports; | ||
Use of this source code is governed by an MIT-style | ||
license that can be found in the LICENSE file or at | ||
https://opensource.org/licenses/MIT. | ||
*/ | ||
}({},workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private,workbox.core._private)); | ||
return publicAPI; | ||
}(workbox.core._private,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(t,e,s){"use strict";try{self.workbox.v["workbox:background-sync:4.0.0-beta.0"]=1}catch(t){}const i=2,n="workbox-background-sync",r="requests",a="queueName",c="workbox-background-sync",h=10080;class o{constructor(e){this.t=e,this.e=new t.DBWrapper(n,i,{onupgradeneeded:t=>this.s(t)})}async pushEntry(t){delete t.id,t.queueName=this.t,await this.e.add(r,t)}async unshiftEntry(t){const e=await this.e.get(r);e?t.id=e.id-1:delete t.id,t.queueName=this.t,await this.e.add(r,t)}async popEntry(){return this.i({direction:"prev"})}async shiftEntry(){return this.i({direction:"next"})}async i({direction:t}){const[e]=await this.e.getAllMatching(r,{direction:t,index:a,query:IDBKeyRange.only(this.t),count:1});if(e)return await this.e.delete(r,e.id),delete e.id,delete e.queueName,e}s(t){const s=t.target.result,i=t.target.transaction;let n=[];e.migrateDb(t,{v1:t=>{if(s.objectStoreNames.contains(r)){i.objectStore(r).openCursor().onsuccess=(({target:e})=>{const i=e.result;i?(n.push(i.value),i.continue()):(s.deleteObjectStore(r),t())})}else t()},v2:t=>{const e=s.createObjectStore(r,{autoIncrement:!0,keyPath:"id"});if(e.createIndex(a,a,{unique:!1}),n.length)for(const t of n){const{queueName:s,storableRequest:i}=t,n=i.timestamp,r=Object.assign(i.requestInit,{url:i.url});e.add({queueName:s,timestamp:n,requestData:r})}t()}})}}const u=["method","referrer","referrerPolicy","mode","credentials","cache","redirect","integrity","keepalive"];class y{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 u)void 0!==t[s]&&(e[s]=t[s]);return new y(e)}constructor(t){this.n=t}toObject(){const t=Object.assign({},this.n);return t.headers=Object.assign({},this.n.headers),t.body&&(t.body=t.body.slice()),t}toRequest(){return new Request(this.n.url,this.n)}clone(){return new y(this.toObject())}}const w=new Set;class d{constructor(t,{onSync:e,maxRetentionTime:i}={}){if(w.has(t))throw new s.WorkboxError("duplicate-queue-name",{name:t});w.add(t),this.r=t,this.a=e||this.replayRequests,this.c=i||h,this.h=new o(this.r),this.o()}get name(){return this.r}async pushRequest(t){await this.u(t,"push")}async unshiftRequest(t){await this.u(t,"unshift")}async popRequest(){return this.y("pop")}async shiftRequest(){return this.y("shift")}async u({request:t,metadata:e,timestamp:s=Date.now()},i){const n={requestData:(await y.fromRequest(t.clone())).toObject(),timestamp:s};e&&(n.metadata=e),await this.h[`${i}Entry`](n),await this.registerSync()}async y(t){const e=Date.now(),s=await this.h[`${t}Entry`]();if(s){const i=60*this.c*1e3;return e-s.timestamp>i?this.y(t):(s.request=new y(s.requestData).toRequest(),delete s.requestData,s)}}async replayRequests(){let t;for(;t=await this.shiftRequest();)try{await fetch(t.request)}catch(e){throw await this.unshiftRequest(t),new s.WorkboxError("queue-replay-failed",{name:this.r})}}async registerSync(){if("sync"in registration)try{await registration.sync.register(`${c}:${this.r}`)}catch(t){}}o(){"sync"in registration?self.addEventListener("sync",t=>{t.tag===`${c}:${this.r}`&&t.waitUntil(this.a({queue:this}))}):this.a({queue:this})}static get w(){return w}}return Object.freeze({Queue:d,Plugin:class{constructor(...t){this.d=new d(...t),this.fetchDidFail=this.fetchDidFail.bind(this)}async fetchDidFail({request:t}){await this.d.pushRequest({request: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.v["workbox:background-sync:4.0.0-beta.1"]=1}catch(t){}const n=2,r="workbox-background-sync",a="requests",c="queueName",h="workbox-background-sync",o=10080;class u{constructor(t){this.t=t,this.e=new e.DBWrapper(r,n,{onupgradeneeded:t=>this.s(t)})}async pushEntry(t){delete t.id,t.queueName=this.t,await this.e.add(a,t)}async unshiftEntry(t){const e=await this.e.get(a);e?t.id=e.id-1:delete t.id,t.queueName=this.t,await this.e.add(a,t)}async popEntry(){return this.i({direction:"prev"})}async shiftEntry(){return this.i({direction:"next"})}async i({direction:t}){const[e]=await this.e.getAllMatching(a,{direction:t,index:c,query:IDBKeyRange.only(this.t),count:1});if(e)return await this.e.delete(a,e.id),delete e.id,delete e.queueName,e}s(t){const e=t.target.result,i=t.target.transaction;let n=[];s.migrateDb(t,{v1:t=>{if(e.objectStoreNames.contains(a)){i.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.n=t}toObject(){const t=Object.assign({},this.n);return t.headers=Object.assign({},this.n.headers),t.body&&(t.body=t.body.slice()),t}toRequest(){return new Request(this.n.url,this.n)}clone(){return new w(this.toObject())}}const d=new Set;class f{constructor(t,{onSync:e,maxRetentionTime:s}={}){if(d.has(t))throw new i.WorkboxError("duplicate-queue-name",{name:t});d.add(t),this.r=t,this.a=e||this.replayRequests,this.c=s||o,this.h=new u(this.r),this.o()}get name(){return this.r}async pushRequest(t){await this.u(t,"push")}async unshiftRequest(t){await this.u(t,"unshift")}async popRequest(){return this.y("pop")}async shiftRequest(){return this.y("shift")}async u({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.h[`${i}Entry`](n),await this.registerSync()}async y(t){const e=Date.now(),s=await this.h[`${t}Entry`]();if(s){const i=60*this.c*1e3;return e-s.timestamp>i?this.y(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(e){throw await this.unshiftRequest(t),new i.WorkboxError("queue-replay-failed",{name:this.r})}}async registerSync(){if("sync"in registration)try{await registration.sync.register(`${h}:${this.r}`)}catch(t){}}o(){"sync"in registration?self.addEventListener("sync",t=>{t.tag===`${h}:${this.r}`&&t.waitUntil(this.a({queue:this}))}):this.a({queue:this})}static get w(){return d}}return t.Queue=f,t.Plugin=class{constructor(...t){this.d=new f(...t),this.fetchDidFail=this.fetchDidFail.bind(this)}async fetchDidFail({request:t}){await this.d.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-beta.0", | ||
"version": "4.0.0-beta.1", | ||
"license": "MIT", | ||
@@ -30,5 +30,5 @@ "author": "Google's Web DevRel Team", | ||
"dependencies": { | ||
"workbox-core": "^4.0.0-beta.0" | ||
"workbox-core": "^4.0.0-beta.1" | ||
}, | ||
"gitHead": "bc90cc4bdb1f8ad435564aa84b0c90acfac611e2" | ||
"gitHead": "dda07c48e184f57ce5dfe3b3e93af316989a0877" | ||
} |
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
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
75447
14
1298
Updatedworkbox-core@^4.0.0-beta.1