@nypl/web-reader 0.2.0-alpha.1 → 0.2.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ServiceWorker/sw.js +1 -1
- package/dist/cjs/ServiceWorker/sw.js.map +3 -3
- package/dist/cjs/index.js +125 -125
- package/dist/cjs/index.js.map +3 -3
- package/dist/esm/ServiceWorker/sw.js +511 -22
- package/dist/esm/ServiceWorker/sw.js.map +3 -3
- package/dist/esm/index.js +142 -130
- package/dist/esm/index.js.map +3 -3
- package/dist/{css/HtmlReader/styles.css → html-styles.css} +1 -1
- package/dist/{css/HtmlReader/styles.css.map → html-styles.css.map} +1 -1
- package/dist/{css/PdfReader/styles.css → pdf-styles.css} +1 -1
- package/dist/{css/PdfReader/styles.css.map → pdf-styles.css.map} +1 -1
- package/dist/types/ServiceWorker/client.d.ts +3 -6
- package/dist/types/ServiceWorker/constants.d.ts +1 -0
- package/dist/types/ServiceWorker/sw.d.ts +12 -0
- package/dist/types/ServiceWorker/types.d.ts +10 -0
- package/dist/types/WebpubManifestTypes/ConformsTo.d.ts +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/types.d.ts +12 -4
- package/dist/types/ui/Header.d.ts +2 -5
- package/dist/types/ui/manager.d.ts +2 -2
- package/package.json +14 -17
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var S=Object.defineProperty,pe=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var H=(t,e,r)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K=(t,e)=>{for(var r in e||(e={}))ue.call(e,r)&&H(t,r,e[r]);if(G)for(var r of G(e))me.call(e,r)&&H(t,r,e[r]);return t},Q=(t,e)=>pe(t,le(e)),he=t=>S(t,"__esModule",{value:!0});var $e=typeof require!="undefined"?require:t=>{throw new Error('Dynamic require of "'+t+'" is not supported')};var de=(t,e)=>{he(t);for(var r in e)S(t,r,{get:e[r],enumerable:!0})};var i=(t,e,r)=>new Promise((o,s)=>{var a=c=>{try{p(r.next(c))}catch(u){s(u)}},n=c=>{try{p(r.throw(c))}catch(u){s(u)}},p=c=>c.done?o(c.value):Promise.resolve(c.value).then(a,n);p((r=r.apply(t,e)).next())});de(exports,{default:()=>ce});"use strict";try{self["workbox:core:6.2.4"]&&_()}catch(t){}var fe=(t,...e)=>{let r=t;return e.length>0&&(r+=` :: ${JSON.stringify(e)}`),r};var J=fe;var l=class extends Error{constructor(e,r){let o=J(e,r);super(o);this.name=e,this.details=r}};var E=new Set;function T(t){E.add(t)}var h={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration!="undefined"?registration.scope:""},$=t=>[h.prefix,t,h.suffix].filter(e=>e&&e.length>0).join("-"),ge=t=>{for(let e of Object.keys(h))t(e)},f={updateDetails:t=>{ge(e=>{typeof t[e]=="string"&&(h[e]=t[e])})},getGoogleAnalyticsName:t=>t||$(h.googleAnalytics),getPrecacheName:t=>t||$(h.precache),getPrefix:()=>h.prefix,getRuntimeName:t=>t||$(h.runtime),getSuffix:()=>h.suffix};function Y(t,e){let r=new URL(t);for(let o of e)r.searchParams.delete(o);return r.href}function O(t,e,r,o){return i(this,null,function*(){let s=Y(e.url,r);if(e.url===s)return t.match(e,o);let a=Object.assign(Object.assign({},o),{ignoreSearch:!0}),n=yield t.keys(e,a);for(let p of n){let c=Y(p.url,r);if(s===c)return t.match(p,o)}})}function w(t){t.then(()=>{})}var y=class{constructor(){this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r})}};function q(){return i(this,null,function*(){for(let t of E)yield t()})}var v=t=>new URL(String(t),location.href).href.replace(new RegExp(`^${location.origin}`),"");function x(t){return new Promise(e=>setTimeout(e,t))}function W(){self.addEventListener("activate",()=>self.clients.claim())}var Ee=(t,e)=>e.some(r=>t instanceof r),X,Z;function _e(){return X||(X=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ye(){return Z||(Z=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var z=new WeakMap,U=new WeakMap,ee=new WeakMap,A=new WeakMap,P=new WeakMap;function ve(t){let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("success",a),t.removeEventListener("error",n)},a=()=>{r(m(t.result)),s()},n=()=>{o(t.error),s()};t.addEventListener("success",a),t.addEventListener("error",n)});return e.then(r=>{r instanceof IDBCursor&&z.set(r,t)}).catch(()=>{}),P.set(e,t),e}function Ne(t){if(U.has(t))return;let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("complete",a),t.removeEventListener("error",n),t.removeEventListener("abort",n)},a=()=>{r(),s()},n=()=>{o(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",a),t.addEventListener("error",n),t.addEventListener("abort",n)});U.set(t,e)}var L={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return U.get(t);if(e==="objectStoreNames")return t.objectStoreNames||ee.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return m(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function re(t){L=t(L)}function ke(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let o=t.call(N(this),e,...r);return ee.set(o,e.sort?e.sort():[e]),m(o)}:ye().includes(t)?function(...e){return t.apply(N(this),e),m(z.get(this))}:function(...e){return m(t.apply(N(this),e))}}function je(t){return typeof t=="function"?ke(t):(t instanceof IDBTransaction&&Ne(t),Ee(t,_e())?new Proxy(t,L):t)}function m(t){if(t instanceof IDBRequest)return ve(t);if(A.has(t))return A.get(t);let e=je(t);return e!==t&&(A.set(t,e),P.set(e,t)),e}var N=t=>P.get(t);function te(t,e,{blocked:r,upgrade:o,blocking:s,terminated:a}={}){let n=indexedDB.open(t,e),p=m(n);return o&&n.addEventListener("upgradeneeded",c=>{o(m(n.result),c.oldVersion,c.newVersion,m(n.transaction))}),r&&n.addEventListener("blocked",()=>r()),p.then(c=>{a&&c.addEventListener("close",()=>a()),s&&c.addEventListener("versionchange",()=>s())}).catch(()=>{}),p}function oe(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",()=>e()),m(r).then(()=>{})}var Re=["get","getKey","getAll","getAllKeys","count"],Ce=["put","add","delete","clear"],I=new Map;function se(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(I.get(e))return I.get(e);let r=e.replace(/FromIndex$/,""),o=e!==r,s=Ce.includes(r);if(!(r in(o?IDBIndex:IDBObjectStore).prototype)||!(s||Re.includes(r)))return;let a=function(n,...p){return i(this,null,function*(){let c=this.transaction(n,s?"readwrite":"readonly"),u=c.store;return o&&(u=u.index(p.shift())),(yield Promise.all([u[r](...p),s&&c.done]))[0]})};return I.set(e,a),a}re(t=>Q(K({},t),{get:(e,r,o)=>se(e,r)||t.get(e,r,o),has:(e,r)=>!!se(e,r)||t.has(e,r)}));"use strict";try{self["workbox:expiration:6.2.4"]&&_()}catch(t){}var De="workbox-expiration",b="cache-entries",ne=t=>{let e=new URL(t,location.href);return e.hash="",e.href},F=class{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){let r=e.createObjectStore(b,{keyPath:"id"});r.createIndex("cacheName","cacheName",{unique:!1}),r.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&oe(this._cacheName)}setTimestamp(e,r){return i(this,null,function*(){e=ne(e);let o={url:e,timestamp:r,cacheName:this._cacheName,id:this._getId(e)},a=(yield this.getDb()).transaction(b,"readwrite",{durability:"relaxed"});yield a.store.put(o),yield a.done})}getTimestamp(e){return i(this,null,function*(){let o=yield(yield this.getDb()).get(b,this._getId(e));return o==null?void 0:o.timestamp})}expireEntries(e,r){return i(this,null,function*(){let o=yield this.getDb(),s=yield o.transaction(b).store.index("timestamp").openCursor(null,"prev"),a=[],n=0;for(;s;){let c=s.value;c.cacheName===this._cacheName&&(e&&c.timestamp<e||r&&n>=r?a.push(s.value):n++),s=yield s.continue()}let p=[];for(let c of a)yield o.delete(b,c.id),p.push(c.url);return p})}_getId(e){return this._cacheName+"|"+ne(e)}getDb(){return i(this,null,function*(){return this._db||(this._db=yield te(De,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db})}};var k=class{constructor(e,r={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=r.maxEntries,this._maxAgeSeconds=r.maxAgeSeconds,this._matchOptions=r.matchOptions,this._cacheName=e,this._timestampModel=new F(e)}expireEntries(){return i(this,null,function*(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;let e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,r=yield this._timestampModel.expireEntries(e,this._maxEntries),o=yield self.caches.open(this._cacheName);for(let s of r)yield o.delete(s,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,w(this.expireEntries()))})}updateTimestamp(e){return i(this,null,function*(){yield this._timestampModel.setTimestamp(e,Date.now())})}isURLExpired(e){return i(this,null,function*(){if(this._maxAgeSeconds){let r=yield this._timestampModel.getTimestamp(e),o=Date.now()-this._maxAgeSeconds*1e3;return r!==void 0?r<o:!0}else return!1})}delete(){return i(this,null,function*(){this._rerunRequested=!1,yield this._timestampModel.expireEntries(1/0)})}};var j=class{constructor(e={}){this.cachedResponseWillBeUsed=n=>i(this,[n],function*({event:r,request:o,cacheName:s,cachedResponse:a}){if(!a)return null;let p=this._isResponseDateFresh(a),c=this._getCacheExpiration(s);w(c.expireEntries());let u=c.updateTimestamp(o.url);if(r)try{r.waitUntil(u)}catch(B){}return p?a:null}),this.cacheDidUpdate=s=>i(this,[s],function*({cacheName:r,request:o}){let a=this._getCacheExpiration(r);yield a.updateTimestamp(o.url),yield a.expireEntries()}),this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&T(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===f.getRuntimeName())throw new l("expire-custom-caches-only");let r=this._cacheExpirations.get(e);return r||(r=new k(e,this._config),this._cacheExpirations.set(e,r)),r}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;let r=this._getDateHeaderTimestamp(e);if(r===null)return!0;let o=Date.now();return r>=o-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;let r=e.headers.get("date"),s=new Date(r).getTime();return isNaN(s)?null:s}deleteCacheAndMetadata(){return i(this,null,function*(){for(let[e,r]of this._cacheExpirations)yield self.caches.delete(e),yield r.delete();this._cacheExpirations=new Map})}};"use strict";try{self["workbox:strategies:6.2.4"]&&_()}catch(t){}function R(t){return typeof t=="string"?new Request(t):t}var C=class{constructor(e,r){this._cacheKeys={},Object.assign(this,r),this.event=r.event,this._strategy=e,this._handlerDeferred=new y,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(let o of this._plugins)this._pluginStateMap.set(o,{});this.event.waitUntil(this._handlerDeferred.promise)}fetch(e){return i(this,null,function*(){let{event:r}=this,o=R(e);if(o.mode==="navigate"&&r instanceof FetchEvent&&r.preloadResponse){let n=yield r.preloadResponse;if(n)return n}let s=this.hasCallback("fetchDidFail")?o.clone():null;try{for(let n of this.iterateCallbacks("requestWillFetch"))o=yield n({request:o.clone(),event:r})}catch(n){if(n instanceof Error)throw new l("plugin-error-request-will-fetch",{thrownErrorMessage:n.message})}let a=o.clone();try{let n;n=yield fetch(o,o.mode==="navigate"?void 0:this._strategy.fetchOptions);for(let p of this.iterateCallbacks("fetchDidSucceed"))n=yield p({event:r,request:a,response:n});return n}catch(n){throw s&&(yield this.runCallbacks("fetchDidFail",{error:n,event:r,originalRequest:s.clone(),request:a.clone()})),n}})}fetchAndCachePut(e){return i(this,null,function*(){let r=yield this.fetch(e),o=r.clone();return this.waitUntil(this.cachePut(e,o)),r})}cacheMatch(e){return i(this,null,function*(){let r=R(e),o,{cacheName:s,matchOptions:a}=this._strategy,n=yield this.getCacheKey(r,"read"),p=Object.assign(Object.assign({},a),{cacheName:s});o=yield caches.match(n,p);for(let c of this.iterateCallbacks("cachedResponseWillBeUsed"))o=(yield c({cacheName:s,matchOptions:a,cachedResponse:o,request:n,event:this.event}))||void 0;return o})}cachePut(e,r){return i(this,null,function*(){let o=R(e);yield x(0);let s=yield this.getCacheKey(o,"write");if(!r)throw new l("cache-put-with-no-response",{url:v(s.url)});let a=yield this._ensureResponseSafeToCache(r);if(!a)return!1;let{cacheName:n,matchOptions:p}=this._strategy,c=yield self.caches.open(n),u=this.hasCallback("cacheDidUpdate"),B=u?yield O(c,s.clone(),["__WB_REVISION__"],p):null;try{yield c.put(s,u?a.clone():a)}catch(g){if(g instanceof Error)throw g.name==="QuotaExceededError"&&(yield q()),g}for(let g of this.iterateCallbacks("cacheDidUpdate"))yield g({cacheName:n,oldResponse:B,newResponse:a.clone(),request:s,event:this.event});return!0})}getCacheKey(e,r){return i(this,null,function*(){if(!this._cacheKeys[r]){let o=e;for(let s of this.iterateCallbacks("cacheKeyWillBeUsed"))o=R(yield s({mode:r,request:o,event:this.event,params:this.params}));this._cacheKeys[r]=o}return this._cacheKeys[r]})}hasCallback(e){for(let r of this._strategy.plugins)if(e in r)return!0;return!1}runCallbacks(e,r){return i(this,null,function*(){for(let o of this.iterateCallbacks(e))yield o(r)})}*iterateCallbacks(e){for(let r of this._strategy.plugins)if(typeof r[e]=="function"){let o=this._pluginStateMap.get(r);yield a=>{let n=Object.assign(Object.assign({},a),{state:o});return r[e](n)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}doneWaiting(){return i(this,null,function*(){let e;for(;e=this._extendLifetimePromises.shift();)yield e})}destroy(){this._handlerDeferred.resolve(null)}_ensureResponseSafeToCache(e){return i(this,null,function*(){let r=e,o=!1;for(let s of this.iterateCallbacks("cacheWillUpdate"))if(r=(yield s({request:this.request,response:r,event:this.event}))||void 0,o=!0,!r)break;return o||r&&r.status!==200&&(r=void 0),r})}};var d=class{constructor(e={}){this.cacheName=f.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){let[r]=this.handleAll(e);return r}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});let r=e.event,o=typeof e.request=="string"?new Request(e.request):e.request,s="params"in e?e.params:void 0,a=new C(this,{event:r,request:o,params:s}),n=this._getResponse(a,o,r),p=this._awaitComplete(n,a,o,r);return[n,p]}_getResponse(e,r,o){return i(this,null,function*(){yield e.runCallbacks("handlerWillStart",{event:o,request:r});let s;try{if(s=yield this._handle(r,e),!s||s.type==="error")throw new l("no-response",{url:r.url})}catch(a){if(a instanceof Error){for(let n of e.iterateCallbacks("handlerDidError"))if(s=yield n({error:a,event:o,request:r}),s)break}if(!s)throw a}for(let a of e.iterateCallbacks("handlerWillRespond"))s=yield a({event:o,request:r,response:s});return s})}_awaitComplete(e,r,o,s){return i(this,null,function*(){let a,n;try{a=yield e}catch(p){}try{yield r.runCallbacks("handlerDidRespond",{event:s,request:o,response:a}),yield r.doneWaiting()}catch(p){p instanceof Error&&(n=p)}if(yield r.runCallbacks("handlerDidComplete",{event:s,request:o,response:a,error:n}),r.destroy(),n)throw n})}};var D=class extends d{_handle(e,r){return i(this,null,function*(){let o=[],s=yield r.cacheMatch(e),a;if(!s)try{s=yield r.fetchAndCachePut(e)}catch(n){n instanceof Error&&(a=n)}if(!s)throw new l("no-response",{url:e.url,error:a});return s})}};var ae=!1;var V="webpub-cache";var ie=7*24*60*60;var Te="v1";W();function ce({cacheExpirationSeconds:t=ie}={}){M("INITIALIZING"),self.addEventListener("install",e=>{M("INSTALLING ");function r(){return i(this,null,function*(){self.skipWaiting(),M("INSTALLED")})}e.waitUntil(r)}),self.addEventListener("fetch",e=>{if(e.request.method!=="GET")return;function r(){return i(this,null,function*(){return(yield(yield caches.open(V)).match(e.request))?new D({cacheName:V,plugins:[new j({maxAgeSeconds:t})]}).handle(e):fetch(e.request)})}e.respondWith(r())})}function M(t){ae&&console.log(`SW (${Te}) -`,t)}
|
|
1
|
+
var K=Object.defineProperty,Ce=Object.defineProperties;var De=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var Oe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var ue=(t,e,r)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e)=>{for(var r in e||(e={}))Oe.call(e,r)&&ue(t,r,e[r]);if(ce)for(var r of ce(e))Se.call(e,r)&&ue(t,r,e[r]);return t},k=(t,e)=>Ce(t,De(e)),Te=t=>K(t,"__esModule",{value:!0});var Ze=typeof require!="undefined"?require:t=>{throw new Error('Dynamic require of "'+t+'" is not supported')};var $e=(t,e)=>{Te(t);for(var r in e)K(t,r,{get:e[r],enumerable:!0})};var i=(t,e,r)=>new Promise((o,s)=>{var a=u=>{try{c(r.next(u))}catch(l){s(l)}},n=u=>{try{c(r.throw(u))}catch(l){s(l)}},c=u=>u.done?o(u.value):Promise.resolve(u.value).then(a,n);c((r=r.apply(t,e)).next())});$e(exports,{default:()=>ve});"use strict";try{self["workbox:core:6.2.4"]&&_()}catch(t){}var Ue=(t,...e)=>{let r=t;return e.length>0&&(r+=` :: ${JSON.stringify(e)}`),r};var le=Ue;var p=class extends Error{constructor(e,r){let o=le(e,r);super(o);this.name=e,this.details=r}};var T=new Set;function Q(t){T.add(t)}var g={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration!="undefined"?registration.scope:""},J=t=>[g.prefix,t,g.suffix].filter(e=>e&&e.length>0).join("-"),We=t=>{for(let e of Object.keys(g))t(e)},E={updateDetails:t=>{We(e=>{typeof t[e]=="string"&&(g[e]=t[e])})},getGoogleAnalyticsName:t=>t||J(g.googleAnalytics),getPrecacheName:t=>t||J(g.precache),getPrefix:()=>g.prefix,getRuntimeName:t=>t||J(g.runtime),getSuffix:()=>g.suffix};function pe(t,e){let r=new URL(t);for(let o of e)r.searchParams.delete(o);return r.href}function Y(t,e,r,o){return i(this,null,function*(){let s=pe(e.url,r);if(e.url===s)return t.match(e,o);let a=Object.assign(Object.assign({},o),{ignoreSearch:!0}),n=yield t.keys(e,a);for(let c of n){let u=pe(c.url,r);if(s===u)return t.match(c,o)}})}function R(t){t.then(()=>{})}var $=class{constructor(){this.promise=new Promise((e,r)=>{this.resolve=e,this.reject=r})}};function z(){return i(this,null,function*(){for(let t of T)yield t()})}var U=t=>new URL(String(t),location.href).href.replace(new RegExp(`^${location.origin}`),"");function j(t){return new Promise(e=>setTimeout(e,t))}function X(){self.addEventListener("activate",()=>self.clients.claim())}var qe=(t,e)=>e.some(r=>t instanceof r),me,he;function Me(){return me||(me=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ve(){return he||(he=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var de=new WeakMap,Z=new WeakMap,fe=new WeakMap,ee=new WeakMap,re=new WeakMap;function Fe(t){let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("success",a),t.removeEventListener("error",n)},a=()=>{r(f(t.result)),s()},n=()=>{o(t.error),s()};t.addEventListener("success",a),t.addEventListener("error",n)});return e.then(r=>{r instanceof IDBCursor&&de.set(r,t)}).catch(()=>{}),re.set(e,t),e}function Ie(t){if(Z.has(t))return;let e=new Promise((r,o)=>{let s=()=>{t.removeEventListener("complete",a),t.removeEventListener("error",n),t.removeEventListener("abort",n)},a=()=>{r(),s()},n=()=>{o(t.error||new DOMException("AbortError","AbortError")),s()};t.addEventListener("complete",a),t.addEventListener("error",n),t.addEventListener("abort",n)});Z.set(t,e)}var te={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return Z.get(t);if(e==="objectStoreNames")return t.objectStoreNames||fe.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return f(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function ge(t){te=t(te)}function He(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let o=t.call(W(this),e,...r);return fe.set(o,e.sort?e.sort():[e]),f(o)}:Ve().includes(t)?function(...e){return t.apply(W(this),e),f(de.get(this))}:function(...e){return f(t.apply(W(this),e))}}function Be(t){return typeof t=="function"?He(t):(t instanceof IDBTransaction&&Ie(t),qe(t,Me())?new Proxy(t,te):t)}function f(t){if(t instanceof IDBRequest)return Fe(t);if(ee.has(t))return ee.get(t);let e=Be(t);return e!==t&&(ee.set(t,e),re.set(e,t)),e}var W=t=>re.get(t);function we(t,e,{blocked:r,upgrade:o,blocking:s,terminated:a}={}){let n=indexedDB.open(t,e),c=f(n);return o&&n.addEventListener("upgradeneeded",u=>{o(f(n.result),u.oldVersion,u.newVersion,f(n.transaction))}),r&&n.addEventListener("blocked",()=>r()),c.then(u=>{a&&u.addEventListener("close",()=>a()),s&&u.addEventListener("versionchange",()=>s())}).catch(()=>{}),c}function be(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",()=>e()),f(r).then(()=>{})}var Ge=["get","getKey","getAll","getAllKeys","count"],Ke=["put","add","delete","clear"],oe=new Map;function xe(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(oe.get(e))return oe.get(e);let r=e.replace(/FromIndex$/,""),o=e!==r,s=Ke.includes(r);if(!(r in(o?IDBIndex:IDBObjectStore).prototype)||!(s||Ge.includes(r)))return;let a=function(n,...c){return i(this,null,function*(){let u=this.transaction(n,s?"readwrite":"readonly"),l=u.store;return o&&(l=l.index(c.shift())),(yield Promise.all([l[r](...c),s&&u.done]))[0]})};return oe.set(e,a),a}ge(t=>k(v({},t),{get:(e,r,o)=>xe(e,r)||t.get(e,r,o),has:(e,r)=>!!xe(e,r)||t.has(e,r)}));"use strict";try{self["workbox:expiration:6.2.4"]&&_()}catch(t){}var Qe="workbox-expiration",C="cache-entries",Ee=t=>{let e=new URL(t,location.href);return e.hash="",e.href},se=class{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){let r=e.createObjectStore(C,{keyPath:"id"});r.createIndex("cacheName","cacheName",{unique:!1}),r.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&be(this._cacheName)}setTimestamp(e,r){return i(this,null,function*(){e=Ee(e);let o={url:e,timestamp:r,cacheName:this._cacheName,id:this._getId(e)},a=(yield this.getDb()).transaction(C,"readwrite",{durability:"relaxed"});yield a.store.put(o),yield a.done})}getTimestamp(e){return i(this,null,function*(){let o=yield(yield this.getDb()).get(C,this._getId(e));return o==null?void 0:o.timestamp})}expireEntries(e,r){return i(this,null,function*(){let o=yield this.getDb(),s=yield o.transaction(C).store.index("timestamp").openCursor(null,"prev"),a=[],n=0;for(;s;){let u=s.value;u.cacheName===this._cacheName&&(e&&u.timestamp<e||r&&n>=r?a.push(s.value):n++),s=yield s.continue()}let c=[];for(let u of a)yield o.delete(C,u.id),c.push(u.url);return c})}_getId(e){return this._cacheName+"|"+Ee(e)}getDb(){return i(this,null,function*(){return this._db||(this._db=yield we(Qe,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db})}};var A=class{constructor(e,r={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=r.maxEntries,this._maxAgeSeconds=r.maxAgeSeconds,this._matchOptions=r.matchOptions,this._cacheName=e,this._timestampModel=new se(e)}expireEntries(){return i(this,null,function*(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;let e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,r=yield this._timestampModel.expireEntries(e,this._maxEntries),o=yield self.caches.open(this._cacheName);for(let s of r)yield o.delete(s,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,R(this.expireEntries()))})}updateTimestamp(e){return i(this,null,function*(){yield this._timestampModel.setTimestamp(e,Date.now())})}isURLExpired(e){return i(this,null,function*(){if(this._maxAgeSeconds){let r=yield this._timestampModel.getTimestamp(e),o=Date.now()-this._maxAgeSeconds*1e3;return r!==void 0?r<o:!0}else return!1})}delete(){return i(this,null,function*(){this._rerunRequested=!1,yield this._timestampModel.expireEntries(1/0)})}};var P=class{constructor(e={}){this.cachedResponseWillBeUsed=n=>i(this,[n],function*({event:r,request:o,cacheName:s,cachedResponse:a}){if(!a)return null;let c=this._isResponseDateFresh(a),u=this._getCacheExpiration(s);R(u.expireEntries());let l=u.updateTimestamp(o.url);if(r)try{r.waitUntil(l)}catch(m){}return c?a:null}),this.cacheDidUpdate=s=>i(this,[s],function*({cacheName:r,request:o}){let a=this._getCacheExpiration(r);yield a.updateTimestamp(o.url),yield a.expireEntries()}),this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&Q(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===E.getRuntimeName())throw new p("expire-custom-caches-only");let r=this._cacheExpirations.get(e);return r||(r=new A(e,this._config),this._cacheExpirations.set(e,r)),r}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;let r=this._getDateHeaderTimestamp(e);if(r===null)return!0;let o=Date.now();return r>=o-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;let r=e.headers.get("date"),s=new Date(r).getTime();return isNaN(s)?null:s}deleteCacheAndMetadata(){return i(this,null,function*(){for(let[e,r]of this._cacheExpirations)yield self.caches.delete(e),yield r.delete();this._cacheExpirations=new Map})}};"use strict";try{self["workbox:strategies:6.2.4"]&&_()}catch(t){}function L(t){return typeof t=="string"?new Request(t):t}var q=class{constructor(e,r){this._cacheKeys={},Object.assign(this,r),this.event=r.event,this._strategy=e,this._handlerDeferred=new $,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(let o of this._plugins)this._pluginStateMap.set(o,{});this.event.waitUntil(this._handlerDeferred.promise)}fetch(e){return i(this,null,function*(){let{event:r}=this,o=L(e);if(o.mode==="navigate"&&r instanceof FetchEvent&&r.preloadResponse){let n=yield r.preloadResponse;if(n)return n}let s=this.hasCallback("fetchDidFail")?o.clone():null;try{for(let n of this.iterateCallbacks("requestWillFetch"))o=yield n({request:o.clone(),event:r})}catch(n){if(n instanceof Error)throw new p("plugin-error-request-will-fetch",{thrownErrorMessage:n.message})}let a=o.clone();try{let n;n=yield fetch(o,o.mode==="navigate"?void 0:this._strategy.fetchOptions);for(let c of this.iterateCallbacks("fetchDidSucceed"))n=yield c({event:r,request:a,response:n});return n}catch(n){throw s&&(yield this.runCallbacks("fetchDidFail",{error:n,event:r,originalRequest:s.clone(),request:a.clone()})),n}})}fetchAndCachePut(e){return i(this,null,function*(){let r=yield this.fetch(e),o=r.clone();return this.waitUntil(this.cachePut(e,o)),r})}cacheMatch(e){return i(this,null,function*(){let r=L(e),o,{cacheName:s,matchOptions:a}=this._strategy,n=yield this.getCacheKey(r,"read"),c=Object.assign(Object.assign({},a),{cacheName:s});o=yield caches.match(n,c);for(let u of this.iterateCallbacks("cachedResponseWillBeUsed"))o=(yield u({cacheName:s,matchOptions:a,cachedResponse:o,request:n,event:this.event}))||void 0;return o})}cachePut(e,r){return i(this,null,function*(){let o=L(e);yield j(0);let s=yield this.getCacheKey(o,"write");if(!r)throw new p("cache-put-with-no-response",{url:U(s.url)});let a=yield this._ensureResponseSafeToCache(r);if(!a)return!1;let{cacheName:n,matchOptions:c}=this._strategy,u=yield self.caches.open(n),l=this.hasCallback("cacheDidUpdate"),m=l?yield Y(u,s.clone(),["__WB_REVISION__"],c):null;try{yield u.put(s,l?a.clone():a)}catch(h){if(h instanceof Error)throw h.name==="QuotaExceededError"&&(yield z()),h}for(let h of this.iterateCallbacks("cacheDidUpdate"))yield h({cacheName:n,oldResponse:m,newResponse:a.clone(),request:s,event:this.event});return!0})}getCacheKey(e,r){return i(this,null,function*(){if(!this._cacheKeys[r]){let o=e;for(let s of this.iterateCallbacks("cacheKeyWillBeUsed"))o=L(yield s({mode:r,request:o,event:this.event,params:this.params}));this._cacheKeys[r]=o}return this._cacheKeys[r]})}hasCallback(e){for(let r of this._strategy.plugins)if(e in r)return!0;return!1}runCallbacks(e,r){return i(this,null,function*(){for(let o of this.iterateCallbacks(e))yield o(r)})}*iterateCallbacks(e){for(let r of this._strategy.plugins)if(typeof r[e]=="function"){let o=this._pluginStateMap.get(r);yield a=>{let n=Object.assign(Object.assign({},a),{state:o});return r[e](n)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}doneWaiting(){return i(this,null,function*(){let e;for(;e=this._extendLifetimePromises.shift();)yield e})}destroy(){this._handlerDeferred.resolve(null)}_ensureResponseSafeToCache(e){return i(this,null,function*(){let r=e,o=!1;for(let s of this.iterateCallbacks("cacheWillUpdate"))if(r=(yield s({request:this.request,response:r,event:this.event}))||void 0,o=!0,!r)break;return o||r&&r.status!==200&&(r=void 0),r})}};var w=class{constructor(e={}){this.cacheName=E.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){let[r]=this.handleAll(e);return r}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});let r=e.event,o=typeof e.request=="string"?new Request(e.request):e.request,s="params"in e?e.params:void 0,a=new q(this,{event:r,request:o,params:s}),n=this._getResponse(a,o,r),c=this._awaitComplete(n,a,o,r);return[n,c]}_getResponse(e,r,o){return i(this,null,function*(){yield e.runCallbacks("handlerWillStart",{event:o,request:r});let s;try{if(s=yield this._handle(r,e),!s||s.type==="error")throw new p("no-response",{url:r.url})}catch(a){if(a instanceof Error){for(let n of e.iterateCallbacks("handlerDidError"))if(s=yield n({error:a,event:o,request:r}),s)break}if(!s)throw a}for(let a of e.iterateCallbacks("handlerWillRespond"))s=yield a({event:o,request:r,response:s});return s})}_awaitComplete(e,r,o,s){return i(this,null,function*(){let a,n;try{a=yield e}catch(c){}try{yield r.runCallbacks("handlerDidRespond",{event:s,request:o,response:a}),yield r.doneWaiting()}catch(c){c instanceof Error&&(n=c)}if(yield r.runCallbacks("handlerDidComplete",{event:s,request:o,response:a,error:n}),r.destroy(),n)throw n})}};var M=class extends w{_handle(e,r){return i(this,null,function*(){let o=[],s=yield r.cacheMatch(e),a;if(!s)try{s=yield r.fetchAndCachePut(e)}catch(n){n instanceof Error&&(a=n)}if(!s)throw new p("no-response",{url:e.url,error:a});return s})}};var ne={cacheWillUpdate:e=>i(void 0,[e],function*({response:t}){return t.status===200||t.status===0?t:null})};var V=class extends w{constructor(e={}){super(e);this.plugins.some(r=>"cacheWillUpdate"in r)||this.plugins.unshift(ne)}_handle(e,r){return i(this,null,function*(){let o=[],s=r.fetchAndCachePut(e).catch(()=>{}),a=yield r.cacheMatch(e),n;if(!a)try{a=yield s}catch(c){c instanceof Error&&(n=c)}if(!a)throw new p("no-response",{url:e.url,error:n});return a})}};var _e=!1;var F="webpub-cache";var Ne="PRECACHE_PUBLICATIONS",ye=7*24*60*60;"use strict";try{self["workbox:routing:6.2.4"]&&_()}catch(t){}var I="GET";var N=t=>t&&typeof t=="object"?t:{handle:t};var b=class{constructor(e,r,o=I){this.handler=N(r),this.match=e,this.method=o}setCatchHandler(e){this.catchHandler=N(e)}};var H=class extends b{constructor(e,r,o){let s=({url:a})=>{let n=e.exec(a.href);if(!!n&&!(a.origin!==location.origin&&n.index!==0))return n.slice(1)};super(s,r,o)}};var B=class{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",e=>{let{request:r}=e,o=this.handleRequest({request:r,event:e});o&&e.respondWith(o)})}addCacheListener(){self.addEventListener("message",e=>{if(e.data&&e.data.type==="CACHE_URLS"){let{payload:r}=e.data,o=Promise.all(r.urlsToCache.map(s=>{typeof s=="string"&&(s=[s]);let a=new Request(...s);return this.handleRequest({request:a,event:e})}));e.waitUntil(o),e.ports&&e.ports[0]&&o.then(()=>e.ports[0].postMessage(!0))}})}handleRequest({request:e,event:r}){let o=new URL(e.url,location.href);if(!o.protocol.startsWith("http"))return;let s=o.origin===location.origin,{params:a,route:n}=this.findMatchingRoute({event:r,request:e,sameOrigin:s,url:o}),c=n&&n.handler,u=[],l=e.method;if(!c&&this._defaultHandlerMap.has(l)&&(c=this._defaultHandlerMap.get(l)),!c)return;let m;try{m=c.handle({url:o,request:e,event:r,params:a})}catch(d){m=Promise.reject(d)}let h=n&&n.catchHandler;return m instanceof Promise&&(this._catchHandler||h)&&(m=m.catch(d=>i(this,null,function*(){if(h)try{return yield h.handle({url:o,request:e,event:r,params:a})}catch(x){x instanceof Error&&(d=x)}if(this._catchHandler)return this._catchHandler.handle({url:o,request:e,event:r});throw d}))),m}findMatchingRoute({url:e,sameOrigin:r,request:o,event:s}){let a=this._routes.get(o.method)||[];for(let n of a){let c,u=n.match({url:e,sameOrigin:r,request:o,event:s});if(u)return c=u,(Array.isArray(c)&&c.length===0||u.constructor===Object&&Object.keys(u).length===0||typeof u=="boolean")&&(c=void 0),{route:n,params:c}}return{}}setDefaultHandler(e,r=I){this._defaultHandlerMap.set(r,N(e))}setCatchHandler(e){this._catchHandler=N(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new p("unregister-route-but-not-found-with-method",{method:e.method});let r=this._routes.get(e.method).indexOf(e);if(r>-1)this._routes.get(e.method).splice(r,1);else throw new p("unregister-route-route-not-registered")}};var D,G=()=>(D||(D=new B,D.addFetchListener(),D.addCacheListener()),D);function O(t,e,r){let o;if(typeof t=="string"){let a=new URL(t,location.href),n=({url:c})=>c.href===a.href;o=new b(n,e,r)}else if(t instanceof RegExp)o=new H(t,e,r);else if(typeof t=="function")o=new b(t,e,r);else if(t instanceof b)o=t;else throw new p("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return G().registerRoute(o),o}var Je="v2";X();function ve({cacheExpirationSeconds:t=ye}={}){S("INITIALIZING"),self.addEventListener("install",o=>{S("INSTALLING ");function s(){return i(this,null,function*(){yield self.skipWaiting(),S("INSTALLED")})}o.waitUntil(s)}),self.addEventListener("message",o=>i(this,null,function*(){if(o.data.type===Ne){if(S("Precaching publications"),typeof o.data.publications!="object"){console.error("Precache event missing publications");return}yield r(o.data.publications)}}));let e=new M({cacheName:F,plugins:[new P({maxAgeSeconds:t})]});function r(o){return i(this,null,function*(){var u;let s=yield caches.open(F);for(let l of o)for(let m of(u=l.swrUrls)!=null?u:[])S(`Routing ${m}`),O(m,new V({cacheName:F}));let c=(yield Promise.allSettled(o.map(l=>i(this,null,function*(){let m=Re(l.manifestUrl,l.proxyUrl);O(m,e);let h=yield s.match(m);if(h)return k(v({},l),{manifest:yield h.json()});let d=yield fetch(m);ke(m,d),yield s.put(m,d.clone());let x=yield d.json();return k(v({},l),{manifest:x})})))).map(l=>l.status==="fulfilled"?l.value:void 0).filter(Ye).map(l=>i(this,null,function*(){var x,ae;let m=je((x=l.manifest.resources)!=null?x:[],l.manifestUrl,l.proxyUrl),h=je((ae=l.manifest.readingOrder)!=null?ae:[],l.manifestUrl,l.proxyUrl),d=Array.from(new Set([...m,...h]));yield Promise.all(d.map(y=>i(this,null,function*(){if(O(y,e),yield s.match(y))return;let ie=yield fetch(y);return ke(y,ie),yield s.put(y,ie)})))}));return yield Promise.allSettled(c)})}}function Ye(t){return!!t}function ke(t,e){if(!e.ok){let r=`Bad response status for: ${t}. Status: ${e.status}`;throw console.warn(r),new Error(r)}}function Re(t,e){return e?`${e}${encodeURIComponent(t)}`:t}function ze(t,e,r){return Re(new URL(t,e).toString(),r)}function je(t,e,r){return t.map(o=>ze(o.href,e,r))}function S(t){_e&&console.log(`SW (${Je}) -`,t)}
|
|
2
2
|
//# sourceMappingURL=sw.js.map
|