misc fixes:

- fix file download in chrome
- fix full-text index loading in older wacz files
dependencies: updaate to wabac 2.7.1
bump to 1.4.1
This commit is contained in:
Ilya Kreymer
2021-04-29 13:44:24 -07:00
parent 03d8e8ffdc
commit 0f08190aca
7 changed files with 21 additions and 17 deletions
+3 -3
View File
@@ -387,7 +387,7 @@ const oe=new WeakMap,ne=v(e=>t=>{if(!(t instanceof D))throw new Error("unsafeSVG
<div style="display: flex">
<div class="has-text-centered" style="width: 220px">
<wr-anim-logo class="logo" size="48px"></wr-anim-logo>
<div style="font-size: smaller; margin-bottom: 1em">${pe?"App":""} v${"1.4.0"}</div>
<div style="font-size: smaller; margin-bottom: 1em">${pe?"App":""} v${"1.4.1"}</div>
</div>
${pe?q`
@@ -1178,7 +1178,7 @@ const oe=new WeakMap,ne=v(e=>t=>{if(!(t instanceof D))throw new Error("unsafeSVG
<a href="#" role="button" class="dropdown-item" @click="${this.onAbout}">
<fa-icon class="menu-logo" size="1.0rem" aria-hidden="true" .svg=${this.appLogo}></fa-icon>
<span>&nbsp;About ${this.appName}</span>
<span class="menu-version">(${"1.4.0"})</span>
<span class="menu-version">(${"1.4.1"})</span>
</a>
</div>
</div>
@@ -1497,7 +1497,7 @@ const Et=new WeakMap,Rt=v(e=>t=>{if(!(t instanceof D))throw new Error("unsafeHTM
<div class="">Permission is needed to reload the archive file. (Click <i>Cancel</i> to cancel loading this archive.)</div>
<button @click="${this.onAskPermission}" class="button is-primary">Show Permission</button>
<a href="/" class="button is-danger">Cancel</a>
</div>`;case"waiting":default:return q`<progress class="progress is-primary is-large" style="max-width: 400px"/>`}}async onAskPermission(){"granted"===await this.fileHandle.requestPermission({mode:"read"})&&this.doLoad()}}customElements.define("wr-loader",Ht);var Bt=i(98),Ft=i.n(Bt),Gt=i(99),Wt=i.n(Gt),Vt=i(100),Kt=i.n(Vt),Zt=i(101),Jt=i.n(Zt);class Yt extends re{constructor(){super(),this.filteredPages=[],this.sortedPages=[],this.query="",this.flex=null,this.newQuery=null,this.loading=!1,this.updatingSearch=!1,this.currList=0,this.active=!1,this.editable=!1,this.changeNeeded=!1,this.selectedPages=new Set,this.menuActive=!1,this.sortKey="date",this.sortDesc=!0,this.isSidebar=!1,this.url="",this.ts="",this.editing=!1,this.toDeletePages=null,this.toDeletePage=null}static get sortKeys(){return[{key:"",name:"Best Match"},{key:"title",name:"Title"},{key:"date",name:"Date"}]}static get properties(){return{active:{type:Boolean},collInfo:{type:Object},currList:{type:Number},filteredPages:{type:Array},sortedPages:{type:Array},query:{type:String},defaultKey:{type:String},loading:{type:Boolean},updatingSearch:{type:Boolean},editable:{type:Boolean},selectedPages:{type:Set},allSelected:{type:Boolean},menuActive:{type:Boolean},sortKey:{type:String},sortDesc:{type:Boolean},isSidebar:{type:Boolean},url:{type:String},ts:{type:String},editing:{type:Boolean},toDeletePages:{type:Object},toDeletePage:{type:Object}}}_timedUpdate(){null!==this.newQuery&&(this.query=this.newQuery,this.newQuery=null,this.filter())}async updated(e){if(e.has("collInfo")?this.updateTextSearch():(e.has("query")||e.has("currList"))&&this.filter(),e.has("active")&&this.active&&this.changeNeeded&&this.filter(),e.has("query")){this.query?(this.sortKey="",this.sortDesc=!1):(this.sortKey="date",this.sortDesc=!0);const e=this.renderRoot.querySelector("wr-sorter");e&&(e.sortKey=this.sortKey,e.sortDesc=this.sortDesc)}if(e.has("sortedPages")&&this.isSidebar){const e=this.renderRoot.querySelector(".current");if(e){const t={behavior:"smooth",block:"nearest",inline:"nearest"};setTimeout(()=>e.scrollIntoView(t),100)}}}onChangeQuery(e){this.newQuery=e.currentTarget.value,this._ival&&window.clearTimeout(this._ival),this._ival=window.setTimeout(()=>this._timedUpdate(),250)}async filter(){if(this.loading)return;if(this.active||(this.changeNeeded=!0),this.loading=!0,this.flex&&this.query){const e=await this.flex.search(this.query,{limit:25});this.filteredPages=e}else this.filteredPages=[...this.collInfo.pages];0!==this.currList&&await this.filterCurated();for(const e of this.filteredPages){const{timestamp:t,date:i}=ze(e);e.timestamp=t,e.date=i}this.loading=!1,this.changeNeeded=!1;const e={query:this.query,currList:this.currList};this.sendChangeEvent(e)}async filterCurated(){const e=await fetch(`${this.collInfo.apiPrefix}/curated/${this.currList}`),t=(await e.json()).curated;this.filteredPages=t}sendChangeEvent(e){this.dispatchEvent(new CustomEvent("coll-tab-nav",{detail:{data:e}}))}async updateTextSearch(){if(this.updatingSearch)return;this.updatingSearch=!0;let e=0;try{const t=new Wt.a({doc:{id:"id",field:["url","title","text"]},async:!0});this.flex=t;const i=await caches.open("cache:"+this.collInfo.coll),a=this.collInfo.apiPrefix+"/textIndex";let r=await i.match(a);r&&Number(r.headers.get("Content-Length"))||(r=await fetch(this.collInfo.apiPrefix+"/textIndex"),200===r.status&&Number(r.headers.get("Content-Length"))&&i.put(a,r.clone()));let o=[];const n=async()=>{let i=o;o=[],await t.add(i),console.log("added "+e+" "+i.length),console.log(t.info())};for await(const t of Ft()(r.body.getReader()))t.text&&(t.id=++e,o.push(t),e%100==0&&await n());await n()}finally{0===e&&this.flex.add(this.collInfo.pages),this.updatingSearch=!1}await this.filter()}static get styles(){return be(ie`
</div>`;case"waiting":default:return q`<progress class="progress is-primary is-large" style="max-width: 400px"/>`}}async onAskPermission(){"granted"===await this.fileHandle.requestPermission({mode:"read"})&&this.doLoad()}}customElements.define("wr-loader",Ht);var Bt=i(98),Ft=i.n(Bt),Gt=i(99),Wt=i.n(Gt),Vt=i(100),Kt=i.n(Vt),Zt=i(101),Jt=i.n(Zt);class Yt extends re{constructor(){super(),this.filteredPages=[],this.sortedPages=[],this.query="",this.flex=null,this.newQuery=null,this.loading=!1,this.updatingSearch=!1,this.currList=0,this.active=!1,this.editable=!1,this.changeNeeded=!1,this.selectedPages=new Set,this.menuActive=!1,this.sortKey="date",this.sortDesc=!0,this.isSidebar=!1,this.url="",this.ts="",this.editing=!1,this.toDeletePages=null,this.toDeletePage=null}static get sortKeys(){return[{key:"",name:"Best Match"},{key:"title",name:"Title"},{key:"date",name:"Date"}]}static get properties(){return{active:{type:Boolean},collInfo:{type:Object},currList:{type:Number},filteredPages:{type:Array},sortedPages:{type:Array},query:{type:String},defaultKey:{type:String},loading:{type:Boolean},updatingSearch:{type:Boolean},editable:{type:Boolean},selectedPages:{type:Set},allSelected:{type:Boolean},menuActive:{type:Boolean},sortKey:{type:String},sortDesc:{type:Boolean},isSidebar:{type:Boolean},url:{type:String},ts:{type:String},editing:{type:Boolean},toDeletePages:{type:Object},toDeletePage:{type:Object}}}_timedUpdate(){null!==this.newQuery&&(this.query=this.newQuery,this.newQuery=null,this.filter())}async updated(e){if(e.has("collInfo")?this.updateTextSearch():(e.has("query")||e.has("currList"))&&this.filter(),e.has("active")&&this.active&&this.changeNeeded&&this.filter(),e.has("query")){this.query?(this.sortKey="",this.sortDesc=!1):(this.sortKey="date",this.sortDesc=!0);const e=this.renderRoot.querySelector("wr-sorter");e&&(e.sortKey=this.sortKey,e.sortDesc=this.sortDesc)}if(e.has("sortedPages")&&this.isSidebar){const e=this.renderRoot.querySelector(".current");if(e){const t={behavior:"smooth",block:"nearest",inline:"nearest"};setTimeout(()=>e.scrollIntoView(t),100)}}}onChangeQuery(e){this.newQuery=e.currentTarget.value,this._ival&&window.clearTimeout(this._ival),this._ival=window.setTimeout(()=>this._timedUpdate(),250)}async filter(){if(this.loading)return;if(this.active||(this.changeNeeded=!0),this.loading=!0,this.flex&&this.query){const e=await this.flex.search(this.query,{limit:25});this.filteredPages=e}else this.filteredPages=[...this.collInfo.pages];0!==this.currList&&await this.filterCurated();for(const e of this.filteredPages){const{timestamp:t,date:i}=ze(e);e.timestamp=t,e.date=i}this.loading=!1,this.changeNeeded=!1;const e={query:this.query,currList:this.currList};this.sendChangeEvent(e)}async filterCurated(){const e=await fetch(`${this.collInfo.apiPrefix}/curated/${this.currList}`),t=(await e.json()).curated;this.filteredPages=t}sendChangeEvent(e){this.dispatchEvent(new CustomEvent("coll-tab-nav",{detail:{data:e}}))}async updateTextSearch(){if(this.updatingSearch)return;this.updatingSearch=!0;let e=0;try{const t=new Wt.a({doc:{id:"id",field:["url","title","text"]},async:!0});this.flex=t;const i=await caches.open("cache:"+this.collInfo.coll),a=this.collInfo.apiPrefix+"/textIndex";let r=await i.match(a);r&&Number(r.headers.get("Content-Length"))||(r=await fetch(this.collInfo.apiPrefix+"/textIndex"),200===r.status&&Number(r.headers.get("Content-Length"))&&i.put(a,r.clone()));let o=[];const n=async()=>{let e=o;o=[],await t.add(e)};for await(const t of Ft()(r.body.getReader()))t.text&&(t.id=++e,o.push(t),e%100==0&&await n());await n()}finally{0===e&&this.flex.add(this.collInfo.pages),this.updatingSearch=!1}await this.filter()}static get styles(){return be(ie`
:host {
width: 100%;
height: 100%;