igv 2.15.5 → 2.15.7

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/igv.js CHANGED
@@ -18584,7 +18584,6 @@
18584
18584
  });
18585
18585
  this.RANGE_WARNING_GIVEN = false;
18586
18586
  this.oauth = new Oauth();
18587
- this.contentLengthMap = new Map();
18588
18587
  }
18589
18588
 
18590
18589
  setApiKey(key) {
@@ -18662,18 +18661,6 @@
18662
18661
  }
18663
18662
  }
18664
18663
 
18665
- async getContentLength(url, options) {
18666
- if (!this.contentLengthMap.has(url)) {
18667
- options = options || {};
18668
- options.method = 'HEAD';
18669
- options.GET_CONTENT_LENGTH = true;
18670
- const contentLengthString = await this._loadURL(url, options);
18671
- const contentLength = contentLengthString ? Number.parseInt(contentLengthString) : -1;
18672
- this.contentLengthMap.set(url, contentLength);
18673
- }
18674
- return this.contentLengthMap.get(url)
18675
- }
18676
-
18677
18664
  async _loadURL(url, options) {
18678
18665
 
18679
18666
  const self = this;
@@ -18688,11 +18675,6 @@
18688
18675
  oauthToken = await (typeof oauthToken === 'function' ? oauthToken() : oauthToken);
18689
18676
  }
18690
18677
 
18691
- let contentLength = -1;
18692
- if (options.range && !isAmazonV4Signed(url) && !isGoogleStorageSigned(url)) {
18693
- contentLength = await this.getContentLength(url);
18694
- }
18695
-
18696
18678
  return new Promise(function (resolve, reject) {
18697
18679
 
18698
18680
  // Various Google tansformations
@@ -18733,13 +18715,7 @@
18733
18715
  }
18734
18716
 
18735
18717
  if (range) {
18736
- let rangeEnd = "";
18737
- if (range.size) {
18738
- rangeEnd = range.start + range.size - 1;
18739
- if (contentLength > 0) {
18740
- rangeEnd = Math.min(rangeEnd, contentLength - 1);
18741
- }
18742
- }
18718
+ var rangeEnd = range.size ? range.start + range.size - 1 : "";
18743
18719
  xhr.setRequestHeader("Range", "bytes=" + range.start + "-" + rangeEnd);
18744
18720
  // xhr.setRequestHeader("Cache-Control", "no-cache"); <= This can cause CORS issues, disabled for now
18745
18721
  }
@@ -18765,11 +18741,6 @@
18765
18741
  }
18766
18742
 
18767
18743
  xhr.onload = async function (event) {
18768
-
18769
- if (options.GET_CONTENT_LENGTH) {
18770
- resolve(xhr.getResponseHeader('content-length'));
18771
- }
18772
-
18773
18744
  // when the url points to a local file, the status is 0 but that is not an error
18774
18745
  if (xhr.status === 0 || (xhr.status >= 200 && xhr.status <= 300)) {
18775
18746
  if (range && xhr.status !== 206 && range.start !== 0) {
@@ -19092,10 +19063,6 @@
19092
19063
  }
19093
19064
  }
19094
19065
 
19095
- function isAmazonV4Signed(url) {
19096
- return url.indexOf("X-Amz-Signature") > -1
19097
- }
19098
-
19099
19066
 
19100
19067
  const igvxhr = new IGVXhr();
19101
19068
 
@@ -23977,7 +23944,7 @@
23977
23944
  }
23978
23945
  };
23979
23946
 
23980
- const _version = "2.15.5";
23947
+ const _version = "2.15.7";
23981
23948
  function version() {
23982
23949
  return _version
23983
23950
  }
@@ -32202,30 +32169,45 @@
32202
32169
  * @param fulfill - function to receive result
32203
32170
  * @param asUint8 - optional flag to return result as an UInt8Array
32204
32171
  */
32205
- async dataViewForRange(requestedRange, asUint8) {
32206
-
32207
- const hasData = (this.data && (this.range.start <= requestedRange.start) &&
32208
- ((this.range.start + this.range.size) >= (requestedRange.start + requestedRange.size)));
32172
+ async dataViewForRange(requestedRange, asUint8, retries = 0) {
32173
+ try {
32174
+ console.log(`buffered reader ${requestedRange}`);
32175
+ const hasData = (this.data && (this.range.start <= requestedRange.start) &&
32176
+ ((this.range.start + this.range.size) >= (requestedRange.start + requestedRange.size)));
32177
+
32178
+ if (!hasData) {
32179
+ let bufferSize;
32180
+ // If requested range size is specified, potentially expand buffer size
32181
+ if (requestedRange.size) {
32182
+ bufferSize = Math.max(this.bufferSize, requestedRange.size);
32183
+ } else {
32184
+ bufferSize = this.bufferSize;
32185
+ }
32186
+ if (this.contentLength) {
32187
+ bufferSize = Math.min(bufferSize, this.contentLength - requestedRange.start);
32188
+ }
32189
+ const loadRange = {start: requestedRange.start, size: bufferSize};
32190
+ const arrayBuffer = await igvxhr.loadArrayBuffer(this.path, buildOptions(this.config, {range: loadRange}));
32191
+ this.data = arrayBuffer;
32192
+ this.range = loadRange;
32193
+ }
32209
32194
 
32210
- if (!hasData) {
32211
- let bufferSize;
32212
- // If requested range size is specified, potentially expand buffer size
32213
- if (requestedRange.size) {
32214
- bufferSize = Math.max(this.bufferSize, requestedRange.size);
32215
- } else {
32216
- bufferSize = this.bufferSize;
32195
+ const len = this.data.byteLength;
32196
+ const bufferStart = requestedRange.start - this.range.start;
32197
+ return asUint8 ?
32198
+ new Uint8Array(this.data, bufferStart, len - bufferStart) :
32199
+ new DataView(this.data, bufferStart, len - bufferStart)
32200
+ } catch (e) {
32201
+ if (retries === 0 && e.message && e.message.startsWith("416")) {
32202
+ try {
32203
+ this.contentLength = await igvxhr.getContentLength(this.path, buildOptions(this.config));
32204
+ return this.dataViewForRange(requestedRange, asUint8, ++retries)
32205
+ } catch (e1) {
32206
+ console.error(e1);
32207
+ }
32208
+ throw e
32217
32209
  }
32218
- const loadRange = {start: requestedRange.start, size: bufferSize};
32219
- const arrayBuffer = await igvxhr.loadArrayBuffer(this.path, buildOptions(this.config, {range: loadRange}));
32220
- this.data = arrayBuffer;
32221
- this.range = loadRange;
32222
32210
  }
32223
-
32224
- const len = this.data.byteLength;
32225
- const bufferStart = requestedRange.start - this.range.start;
32226
- return asUint8 ?
32227
- new Uint8Array(this.data, bufferStart, len - bufferStart) :
32228
- new DataView(this.data, bufferStart, len - bufferStart)
32229
32211
  }
32230
32212
  }
32231
32213