hexo/node_modules/workbox-background-sync/build/workbox-background-sync.pro...

3 lines
7.9 KiB
JavaScript
Raw Normal View History

2023-09-25 15:58:56 +08:00
this.workbox=this.workbox||{},this.workbox.backgroundSync=function(t,e,s,n){"use strict";function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])}return t}).apply(this,arguments)}let a,i;const c=new WeakMap,o=new WeakMap,u=new WeakMap,h=new WeakMap,y=new WeakMap;let w={get(t,e,s){if(t instanceof IDBTransaction){if("done"===e)return o.get(t);if("objectStoreNames"===e)return t.objectStoreNames||u.get(t);if("store"===e)return s.objectStoreNames[1]?void 0:s.objectStore(s.objectStoreNames[0])}return d(t[e])},set:(t,e,s)=>(t[e]=s,!0),has:(t,e)=>t instanceof IDBTransaction&&("done"===e||"store"===e)||e in t};function f(t){return t!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(i||(i=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(m(this),e),d(c.get(this))}:function(...e){return d(t.apply(m(this),e))}:function(e,...s){const n=t.call(m(this),e,...s);return u.set(n,e.sort?e.sort():[e]),d(n)}}function l(t){return"function"==typeof t?f(t):(t instanceof IDBTransaction&&function(t){if(o.has(t))return;const e=new Promise(((e,s)=>{const n=()=>{t.removeEventListener("complete",r),t.removeEventListener("error",a),t.removeEventListener("abort",a)},r=()=>{e(),n()},a=()=>{s(t.error||new DOMException("AbortError","AbortError")),n()};t.addEventListener("complete",r),t.addEventListener("error",a),t.addEventListener("abort",a)}));o.set(t,e)}(t),e=t,(a||(a=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some((t=>e instanceof t))?new Proxy(t,w):t);var e}function d(t){if(t instanceof IDBRequest)return function(t){const e=new Promise(((e,s)=>{const n=()=>{t.removeEventListener("success",r),t.removeEventListener("error",a)},r=()=>{e(d(t.result)),n()},a=()=>{s(t.error),n()};t.addEventListener("success",r),t.addEventListener("error",a)}));return e.then((e=>{e instanceof IDBCursor&&c.set(e,t)})).catch((()=>{})),y.set(e,t),e}(t);if(h.has(t))return h.get(t);const e=l(t);return e!==t&&(h.set(t,e),y.set(e,t)),e}const m=t=>y.get(t);const p=["get","getKey","getAll","getAllKeys","count"],g=["put","add","delete","clear"],D=new Map;function b(t,e){if(!(t instanceof IDBDatabase)||e in t||"string"!=typeof e)return;if(D.get(e))return D.get(e);const s=e.replace(/FromIndex$/,""),n=e!==s,r=g.includes(s);if(!(s in(n?IDBIndex:IDBObjectStore).prototype)||!r&&!p.includes(s))return;const a=async function(t,...e){const a=this.transaction(t,r?"readwrite":"readonly");let i=a.store;return n&&(i=i.index(e.shift())),(await Promise.all([i[s](...e),r&&a.done]))[0]};return D.set(e,a),a}w=(t=>r({},t,{get:(e,s,n)=>b(e,s)||t.get(e,s,n),has:(e,s)=>!!b(e,s)||t.has(e,s)}))(w);try{self["workbox:background-sync:6.5.3"]&&_()}catch(t){}const B="requests",I="queueName";class q{constructor(){this.t=null}async addEntry(t){const e=(await this.getDb()).transaction(B,"readwrite",{durability:"relaxed"});await e.store.add(t),await e.done}async getFirstEntryId(){const t=await this.getDb(),e=await t.transaction(B).store.openCursor();return null==e?void 0:e.value.id}async getAllEntriesByQueueName(t){const e=await this.getDb(),s=await e.getAllFromIndex(B,I,IDBKeyRange.only(t));return s||new Array}async getEntryCountByQueueName(t){return(await this.getDb()).countFromIndex(B,I,IDBKeyRange.only(t))}async deleteEntry(t){const e=await this.getDb();await e.delete(B,t)}async getFirstEntryByQueueName(t){return await this.getEndEntryFromIndex(IDBKeyRange.only(t),"next")}async getLastEntryByQueueName(t){return await this.getEndEntryFromIndex(IDBKeyRange.only(t),"prev")}async getEndEntryFromIndex(t,e){const s=await this.getDb(),n=await s.transaction(B).store.index(I).openCursor(t,e);return null==n?void 0:n.value}async getDb(){return this.t||(this.t=await function(t,e,{blocked:s,upgrade:n,blocking:r,terminated:a}={}){const i=indexedDB.open(t,e),c=d(i);return n&&i.addEventListener("upgradeneeded",(t=>{n(d(i.result),t.oldVersion,t.newVersion,d(i.transactio
//# sourceMappingURL=workbox-background-sync.prod.js.map