oncoprintjs 6.1.3 → 6.1.4

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/index.js CHANGED
@@ -2862,18 +2862,36 @@ var OncoprintModel = /** @class */ (function () {
2862
2862
  if (nearest_id_index === -1) {
2863
2863
  return null;
2864
2864
  }
2865
- // Next, see if it's in a track
2865
+ // Next, see if it's in a track.
2866
+ // Try binary search first for performance, but fall back to linear
2867
+ // scan if the result is invalid. cell_tops may not be monotonically
2868
+ // ordered relative to the tracks array during async clustering
2869
+ // transitions, which causes binary search to return wrong results.
2866
2870
  var tracks = this.getTracks();
2867
2871
  var cell_tops = this.getCellTops();
2872
+ var nearest_track;
2868
2873
  var nearest_track_index = binarysearch(tracks, y, function (track) {
2869
2874
  return cell_tops[track];
2870
2875
  }, true);
2871
- if (nearest_track_index === -1) {
2872
- return null;
2876
+ if (nearest_track_index !== -1) {
2877
+ var candidate = tracks[nearest_track_index];
2878
+ if (y >= cell_tops[candidate] &&
2879
+ y < cell_tops[candidate] + this.getCellHeight(candidate)) {
2880
+ nearest_track = candidate;
2881
+ }
2882
+ }
2883
+ if (nearest_track === undefined) {
2884
+ // Binary search failed (tracks out of order) - linear fallback
2885
+ for (var t = 0; t < tracks.length; t++) {
2886
+ var top_1 = cell_tops[tracks[t]];
2887
+ if (y >= top_1 &&
2888
+ y < top_1 + this.getCellHeight(tracks[t])) {
2889
+ nearest_track = tracks[t];
2890
+ break;
2891
+ }
2892
+ }
2873
2893
  }
2874
- var nearest_track = tracks[nearest_track_index];
2875
- if (y >= cell_tops[nearest_track] + this.getCellHeight(nearest_track)) {
2876
- // we know y is past the top of the track (>= cell_tops[nearest_track]), so this checks if y is past the bottom of the track
2894
+ if (nearest_track === undefined) {
2877
2895
  return null;
2878
2896
  }
2879
2897
  // At this point, we know y is inside a track
@@ -4243,42 +4261,6 @@ function getNumWebGLVertexes(shape) {
4243
4261
  return ret;
4244
4262
  }
4245
4263
 
4246
- /******************************************************************************
4247
- Copyright (c) Microsoft Corporation.
4248
-
4249
- Permission to use, copy, modify, and/or distribute this software for any
4250
- purpose with or without fee is hereby granted.
4251
-
4252
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
4253
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
4254
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
4255
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
4256
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
4257
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4258
- PERFORMANCE OF THIS SOFTWARE.
4259
- ***************************************************************************** */
4260
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
4261
-
4262
- var extendStatics = function(d, b) {
4263
- extendStatics = Object.setPrototypeOf ||
4264
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4265
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
4266
- return extendStatics(d, b);
4267
- };
4268
-
4269
- function __extends(d, b) {
4270
- if (typeof b !== "function" && b !== null)
4271
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
4272
- extendStatics(d, b);
4273
- function __() { this.constructor = d; }
4274
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4275
- }
4276
-
4277
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
4278
- var e = new Error(message);
4279
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4280
- };
4281
-
4282
4264
  var default_parameter_values = {
4283
4265
  width: 100,
4284
4266
  height: 100,
@@ -4483,7 +4465,7 @@ var Shape = /** @class */ (function () {
4483
4465
  return Shape;
4484
4466
  }());
4485
4467
  var Rectangle = /** @class */ (function (_super) {
4486
- __extends(Rectangle, _super);
4468
+ tslib.__extends(Rectangle, _super);
4487
4469
  function Rectangle() {
4488
4470
  return _super !== null && _super.apply(this, arguments) || this;
4489
4471
  }
@@ -4507,7 +4489,7 @@ var Rectangle = /** @class */ (function (_super) {
4507
4489
  return Rectangle;
4508
4490
  }(Shape));
4509
4491
  var Triangle = /** @class */ (function (_super) {
4510
- __extends(Triangle, _super);
4492
+ tslib.__extends(Triangle, _super);
4511
4493
  function Triangle() {
4512
4494
  return _super !== null && _super.apply(this, arguments) || this;
4513
4495
  }
@@ -4533,7 +4515,7 @@ var Triangle = /** @class */ (function (_super) {
4533
4515
  return Triangle;
4534
4516
  }(Shape));
4535
4517
  var Ellipse = /** @class */ (function (_super) {
4536
- __extends(Ellipse, _super);
4518
+ tslib.__extends(Ellipse, _super);
4537
4519
  function Ellipse() {
4538
4520
  return _super !== null && _super.apply(this, arguments) || this;
4539
4521
  }
@@ -4557,7 +4539,7 @@ var Ellipse = /** @class */ (function (_super) {
4557
4539
  return Ellipse;
4558
4540
  }(Shape));
4559
4541
  var Line = /** @class */ (function (_super) {
4560
- __extends(Line, _super);
4542
+ tslib.__extends(Line, _super);
4561
4543
  function Line() {
4562
4544
  return _super !== null && _super.apply(this, arguments) || this;
4563
4545
  }