igv 2.15.4 → 2.15.5

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,6 +18584,7 @@
18584
18584
  });
18585
18585
  this.RANGE_WARNING_GIVEN = false;
18586
18586
  this.oauth = new Oauth();
18587
+ this.contentLengthMap = new Map();
18587
18588
  }
18588
18589
 
18589
18590
  setApiKey(key) {
@@ -18661,6 +18662,18 @@
18661
18662
  }
18662
18663
  }
18663
18664
 
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
+
18664
18677
  async _loadURL(url, options) {
18665
18678
 
18666
18679
  const self = this;
@@ -18675,6 +18688,11 @@
18675
18688
  oauthToken = await (typeof oauthToken === 'function' ? oauthToken() : oauthToken);
18676
18689
  }
18677
18690
 
18691
+ let contentLength = -1;
18692
+ if (options.range && !isAmazonV4Signed(url) && !isGoogleStorageSigned(url)) {
18693
+ contentLength = await this.getContentLength(url);
18694
+ }
18695
+
18678
18696
  return new Promise(function (resolve, reject) {
18679
18697
 
18680
18698
  // Various Google tansformations
@@ -18700,13 +18718,6 @@
18700
18718
  }
18701
18719
  const range = options.range;
18702
18720
 
18703
- // const isChrome = navigator.userAgent.indexOf('Chrome') > -1
18704
- // const isSafari = navigator.vendor.indexOf("Apple") === 0 && /\sSafari\//.test(navigator.userAgent)
18705
- // if (range && isChrome && !isAmazonV4Signed(url) && !isGoogleStorageSigned(url)) {
18706
- // // Hack to prevent caching for byte-ranges. Attempt to fix net:err-cache errors in Chrome
18707
- // url += url.includes("?") ? "&" : "?"
18708
- // url += "someRandomSeed=" + Math.random().toString(36)
18709
- // }
18710
18721
 
18711
18722
  const xhr = new XMLHttpRequest();
18712
18723
  const sendData = options.sendData || options.body;
@@ -18722,7 +18733,13 @@
18722
18733
  }
18723
18734
 
18724
18735
  if (range) {
18725
- var rangeEnd = range.size ? range.start + range.size - 1 : "";
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
+ }
18726
18743
  xhr.setRequestHeader("Range", "bytes=" + range.start + "-" + rangeEnd);
18727
18744
  // xhr.setRequestHeader("Cache-Control", "no-cache"); <= This can cause CORS issues, disabled for now
18728
18745
  }
@@ -18748,6 +18765,11 @@
18748
18765
  }
18749
18766
 
18750
18767
  xhr.onload = async function (event) {
18768
+
18769
+ if (options.GET_CONTENT_LENGTH) {
18770
+ resolve(xhr.getResponseHeader('content-length'));
18771
+ }
18772
+
18751
18773
  // when the url points to a local file, the status is 0 but that is not an error
18752
18774
  if (xhr.status === 0 || (xhr.status >= 200 && xhr.status <= 300)) {
18753
18775
  if (range && xhr.status !== 206 && range.start !== 0) {
@@ -18780,6 +18802,7 @@
18780
18802
  }
18781
18803
  };
18782
18804
 
18805
+
18783
18806
  xhr.onerror = function (event) {
18784
18807
  if (isGoogleURL(url) && !options.retries) {
18785
18808
  tryGoogleAuth();
@@ -18911,7 +18934,6 @@
18911
18934
  }
18912
18935
 
18913
18936
 
18914
-
18915
18937
  /**
18916
18938
  * Return a Google oAuth token, triggering a sign in if required. This method should not be called until we know
18917
18939
  * a token is required, that is until we've tried the url and received a 401, 403, or 404.
@@ -19070,6 +19092,11 @@
19070
19092
  }
19071
19093
  }
19072
19094
 
19095
+ function isAmazonV4Signed(url) {
19096
+ return url.indexOf("X-Amz-Signature") > -1
19097
+ }
19098
+
19099
+
19073
19100
  const igvxhr = new IGVXhr();
19074
19101
 
19075
19102
  /*
@@ -23950,7 +23977,7 @@
23950
23977
  }
23951
23978
  };
23952
23979
 
23953
- const _version = "2.15.4";
23980
+ const _version = "2.15.5";
23954
23981
  function version() {
23955
23982
  return _version
23956
23983
  }
@@ -30285,7 +30312,8 @@
30285
30312
  this.config = config || {};
30286
30313
  this.genome = genome;
30287
30314
  this.indexURL = config.indexURL;
30288
- this.indexed = config.indexed;
30315
+ this.indexed = config.indexed || this.indexURL !== undefined;
30316
+ this.queryable = this.indexed;
30289
30317
 
30290
30318
  if (isFile(this.config.url)) {
30291
30319
  this.filename = this.config.url.name;
@@ -31945,7 +31973,7 @@
31945
31973
 
31946
31974
  const queryableFormats = new Set(["bigwig", "bw", "bigbed", "bb", "biginteract", "biggenepred", "bignarrowpeak", "tdf"]);
31947
31975
 
31948
- this.queryable = config.queryable === true; // False by default, unless explicitly set
31976
+ this.queryable = config.indexURL || config.queryable === true; // False by default, unless explicitly set
31949
31977
  if (config.reader) {
31950
31978
  // Explicit reader implementation
31951
31979
  this.reader = config.reader;
@@ -32043,6 +32071,7 @@
32043
32071
  // * view is "whole genome" but no features are loaded
32044
32072
  // * cache is disabled
32045
32073
  // * cache does not contain requested range
32074
+ // const containsRange = this.featureCache.containsRange(new GenomicInterval(queryChr, start, end))
32046
32075
  if ((isWholeGenome && !this.wgFeatures && this.supportsWholeGenome()) ||
32047
32076
  this.config.disableCache ||
32048
32077
  !this.featureCache ||
@@ -40883,7 +40912,7 @@
40883
40912
 
40884
40913
  function onDragEnd() {
40885
40914
  if (track.trackView && track.displayMode !== "SQUISHED") {
40886
- track.trackView.repaintViews(); // TODO -- refine this to the viewport that was dragged after DOM refactor
40915
+ track.trackView.updateViews(); // TODO -- refine this to the viewport that was dragged after DOM refactor
40887
40916
  }
40888
40917
  }
40889
40918