view x/static/js/7706.430ce07e.chunk.js @ 125:49f3d3878413 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/jbrowse2 commit 5ea1f9c1eef1de76232e69aa6d34cda77d90d566
author fubar
date Sat, 05 Oct 2024 23:58:05 +0000
parents
children
line wrap: on
line source

"use strict";(globalThis.webpackChunk_jbrowse_web=globalThis.webpackChunk_jbrowse_web||[]).push([[7706],{7706:(e,t,r)=>{r.d(t,{sG:()=>d,unzip:()=>s,i2:()=>o});var n=r(35451),i=r(45834),a=r(57864);async function s(e){try{let t,r=0,i=0;const s=[];let o,h=0;do{const n=e.subarray(r);if(o=new a.Inflate,({strm:t}=o),o.push(n,a.Z_SYNC_FLUSH),o.err)throw new Error(o.msg);r+=t.next_in,s[i]=o.result,h+=s[i].length,i+=1}while(t.avail_in);const l=new Uint8Array(h);for(let e=0,t=0;e<s.length;e++)l.set(s[e],t),t+=s[e].length;return n.hp.from(l)}catch(e){if(`${e}`.match(/incorrect header check/))throw new Error("problem decompressing block: incorrect gzip header check");throw e}}async function o(e,t){try{let r;const{minv:i,maxv:s}=t;let o=i.blockPosition,h=i.dataPosition;const l=[],c=[],d=[];let f=0,w=0;do{const t=e.subarray(o-i.blockPosition),n=new a.Inflate;if(({strm:r}=n),n.push(t,a.Z_SYNC_FLUSH),n.err)throw new Error(n.msg);const g=n.result;l.push(g);let u=g.length;c.push(o),d.push(h),1===l.length&&i.dataPosition&&(l[0]=l[0].subarray(i.dataPosition),u=l[0].length);const p=o;if(o+=r.next_in,h+=u,p>=s.blockPosition){l[w]=l[w].subarray(0,s.blockPosition===i.blockPosition?s.dataPosition-i.dataPosition+1:s.dataPosition+1),c.push(o),d.push(h),f+=l[w].length;break}f+=l[w].length,w++}while(r.avail_in);const g=new Uint8Array(f);for(let e=0,t=0;e<l.length;e++)g.set(l[e],t),t+=l[e].length;return{buffer:n.hp.from(g),cpositions:c,dpositions:d}}catch(e){if(`${e}`.match(/incorrect header check/))throw new Error("problem decompressing block: incorrect gzip header check");throw e}}var h=r(59086),l=r.n(h);class c{constructor({filehandle:e,path:t}){if(e)this.filehandle=e;else{if(!t)throw new TypeError("either filehandle or path must be defined");this.filehandle=new i.EY(t)}}_readLongWithOverflow(e,t=0,r=!0){const n=l().fromBytesLE(e.slice(t,t+8),r);if(n.greaterThan(Number.MAX_SAFE_INTEGER)||n.lessThan(Number.MIN_SAFE_INTEGER))throw new TypeError("integer overflow");return n.toNumber()}_getIndex(){return this.index||(this.index=this._readIndex()),this.index}async _readIndex(){let e=n.hp.allocUnsafe(8);await this.filehandle.read(e,0,8,0);const t=this._readLongWithOverflow(e,0,!0);if(!t)return[[0,0]];const r=new Array(t+1);r[0]=[0,0];const i=16*t;if(i>Number.MAX_SAFE_INTEGER)throw new TypeError("integer overflow");e=n.hp.allocUnsafe(i),await this.filehandle.read(e,0,i,8);for(let n=0;n<t;n+=1){const t=this._readLongWithOverflow(e,16*n),i=this._readLongWithOverflow(e,16*n+8);r[n+1]=[t,i]}return r}async getLastBlock(){const e=await this._getIndex();if(e.length)return e[e.length-1]}async getRelevantBlocksForRead(e,t){const r=t+e;if(0===e)return[];const n=await this._getIndex(),i=[],a=(e,r)=>{const n=e[1],i=r?r[1]:1/0;return n<=t&&i>t?0:n<t?-1:1};let s=0,o=n.length-1,h=Math.floor(n.length/2),l=a(n[h],n[h+1]);for(;0!==l;)l>0?o=h-1:l<0&&(s=h+1),h=Math.ceil((o-s)/2)+s,l=a(n[h],n[h+1]);i.push(n[h]);let c=h+1;for(;c<n.length&&(i.push(n[c]),!(n[c][1]>=r));c+=1);return i[i.length-1][1]<r&&i.push([]),i}}class d{constructor({filehandle:e,path:t,gziFilehandle:r,gziPath:n}){if(e)this.filehandle=e;else{if(!t)throw new TypeError("either filehandle or path must be defined");this.filehandle=new i.EY(t)}if(!r&&!n&&!t)throw new TypeError("either gziFilehandle or gziPath must be defined");this.gzi=new c({filehandle:r,path:r||n||!t?`${t}.gzi`:n})}async stat(){const e=await this.filehandle.stat();return Object.assign(e,{size:await this.getUncompressedFileSize(),blocks:void 0,blksize:void 0})}async getUncompressedFileSize(){const[,e]=await this.gzi.getLastBlock(),{size:t}=await this.filehandle.stat(),r=n.hp.allocUnsafe(4),{bytesRead:i}=await this.filehandle.read(r,0,4,t-28-4);if(4!==i)throw new Error("read error");return e+r.readUInt32LE(0)}async _readAndUncompressBlock(e,[t],[r]){let n=r;n||(n=(await this.filehandle.stat()).size);const i=n-t;return await this.filehandle.read(e,0,i,t),await s(e.slice(0,i))}async read(e,t,r,i){const a=await this.gzi.getRelevantBlocksForRead(r,i),s=n.hp.allocUnsafe(65536);let o=t,h=0;for(let t=0;t<a.length-1;t+=1){const n=await this._readAndUncompressBlock(s,a[t],a[t+1]),[,l]=a[t],c=l>=i?0:i-l,d=Math.min(i+r,l+n.length)-l;c>=0&&c<n.length&&(n.copy(e,o,c,d),o+=d-c,h+=d-c)}return{bytesRead:h,buffer:e}}}}}]);
//# sourceMappingURL=7706.430ce07e.chunk.js.map