igv 2.15.6 → 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
@@ -23944,7 +23944,7 @@
23944
23944
  }
23945
23945
  };
23946
23946
 
23947
- const _version = "2.15.6";
23947
+ const _version = "2.15.7";
23948
23948
  function version() {
23949
23949
  return _version
23950
23950
  }
@@ -32169,30 +32169,45 @@
32169
32169
  * @param fulfill - function to receive result
32170
32170
  * @param asUint8 - optional flag to return result as an UInt8Array
32171
32171
  */
32172
- async dataViewForRange(requestedRange, asUint8) {
32173
-
32174
- const hasData = (this.data && (this.range.start <= requestedRange.start) &&
32175
- ((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
+ }
32176
32194
 
32177
- if (!hasData) {
32178
- let bufferSize;
32179
- // If requested range size is specified, potentially expand buffer size
32180
- if (requestedRange.size) {
32181
- bufferSize = Math.max(this.bufferSize, requestedRange.size);
32182
- } else {
32183
- 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
32184
32209
  }
32185
- const loadRange = {start: requestedRange.start, size: bufferSize};
32186
- const arrayBuffer = await igvxhr.loadArrayBuffer(this.path, buildOptions(this.config, {range: loadRange}));
32187
- this.data = arrayBuffer;
32188
- this.range = loadRange;
32189
32210
  }
32190
-
32191
- const len = this.data.byteLength;
32192
- const bufferStart = requestedRange.start - this.range.start;
32193
- return asUint8 ?
32194
- new Uint8Array(this.data, bufferStart, len - bufferStart) :
32195
- new DataView(this.data, bufferStart, len - bufferStart)
32196
32211
  }
32197
32212
  }
32198
32213