@jbrowse/core 2.0.0 → 2.0.1

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/util/index.js CHANGED
@@ -54,7 +54,6 @@ var _exportNames = {
54
54
  hashCode: true,
55
55
  objectHash: true,
56
56
  bytesForRegions: true,
57
- viewBpToPx: true,
58
57
  supportedIndexingAdapters: true,
59
58
  getBpDisplayStr: true,
60
59
  toLocale: true,
@@ -123,7 +122,6 @@ exports.toLocale = toLocale;
123
122
  exports.updateStatus = updateStatus;
124
123
  exports.useDebounce = useDebounce;
125
124
  exports.useDebouncedCallback = useDebouncedCallback;
126
- exports.viewBpToPx = viewBpToPx;
127
125
 
128
126
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
129
127
 
@@ -1003,7 +1001,7 @@ function _renameRegionsIfNeeded() {
1003
1001
  _context3.t0 = Object;
1004
1002
  _context3.next = 7;
1005
1003
  return Promise.all(assemblyNames.map( /*#__PURE__*/function () {
1006
- var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(assemblyName) {
1004
+ var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(assemblyName) {
1007
1005
  return _regenerator.default.wrap(function _callee2$(_context2) {
1008
1006
  while (1) {
1009
1007
  switch (_context2.prev = _context2.next) {
@@ -1025,7 +1023,7 @@ function _renameRegionsIfNeeded() {
1025
1023
  }));
1026
1024
 
1027
1025
  return function (_x10) {
1028
- return _ref6.apply(this, arguments);
1026
+ return _ref5.apply(this, arguments);
1029
1027
  };
1030
1028
  }()));
1031
1029
 
@@ -1058,7 +1056,7 @@ function stringify(_ref3) {
1058
1056
  var refName = _ref3.refName,
1059
1057
  coord = _ref3.coord,
1060
1058
  oob = _ref3.oob;
1061
- return "".concat(refName, ":").concat(coord.toLocaleString('en-US')).concat(oob ? ' (out of bounds)' : '');
1059
+ return refName ? "".concat(refName, ":").concat(coord.toLocaleString('en-US')).concat(oob ? ' (out of bounds)' : '') : '';
1062
1060
  } // this is recommended in a later comment in https://github.com/electron/electron/issues/2288
1063
1061
  // for detecting electron in a renderer process, which is the one that has node enabled for us
1064
1062
  // const isElectron = process.versions.electron
@@ -1146,20 +1144,25 @@ window.requestIdleCallback : function (cb) {
1146
1144
  }, 1);
1147
1145
  } : function (cb) {
1148
1146
  return cb();
1149
- }; // xref https://gist.github.com/tophtucker/62f93a4658387bb61e4510c37e2e97cf
1147
+ }; // prettier-ignore
1150
1148
 
1151
1149
  exports.rIC = rIC;
1150
+ var widths = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2796875, 0.2765625, 0.3546875, 0.5546875, 0.5546875, 0.8890625, 0.665625, 0.190625, 0.3328125, 0.3328125, 0.3890625, 0.5828125, 0.2765625, 0.3328125, 0.2765625, 0.3015625, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.2765625, 0.2765625, 0.584375, 0.5828125, 0.584375, 0.5546875, 1.0140625, 0.665625, 0.665625, 0.721875, 0.721875, 0.665625, 0.609375, 0.7765625, 0.721875, 0.2765625, 0.5, 0.665625, 0.5546875, 0.8328125, 0.721875, 0.7765625, 0.665625, 0.7765625, 0.721875, 0.665625, 0.609375, 0.721875, 0.665625, 0.94375, 0.665625, 0.665625, 0.609375, 0.2765625, 0.3546875, 0.2765625, 0.4765625, 0.5546875, 0.3328125, 0.5546875, 0.5546875, 0.5, 0.5546875, 0.5546875, 0.2765625, 0.5546875, 0.5546875, 0.221875, 0.240625, 0.5, 0.221875, 0.8328125, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.3328125, 0.5, 0.2765625, 0.5546875, 0.5, 0.721875, 0.5, 0.5, 0.5, 0.3546875, 0.259375, 0.353125, 0.5890625]; // xref https://gist.github.com/tophtucker/62f93a4658387bb61e4510c37e2e97cf
1152
1151
 
1153
1152
  function measureText(str) {
1154
1153
  var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10;
1155
- // prettier-ignore
1156
- var widths = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2796875, 0.2765625, 0.3546875, 0.5546875, 0.5546875, 0.8890625, 0.665625, 0.190625, 0.3328125, 0.3328125, 0.3890625, 0.5828125, 0.2765625, 0.3328125, 0.2765625, 0.3015625, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.2765625, 0.2765625, 0.584375, 0.5828125, 0.584375, 0.5546875, 1.0140625, 0.665625, 0.665625, 0.721875, 0.721875, 0.665625, 0.609375, 0.7765625, 0.721875, 0.2765625, 0.5, 0.665625, 0.5546875, 0.8328125, 0.721875, 0.7765625, 0.665625, 0.7765625, 0.721875, 0.665625, 0.609375, 0.721875, 0.665625, 0.94375, 0.665625, 0.665625, 0.609375, 0.2765625, 0.3546875, 0.2765625, 0.4765625, 0.5546875, 0.3328125, 0.5546875, 0.5546875, 0.5, 0.5546875, 0.5546875, 0.2765625, 0.5546875, 0.5546875, 0.221875, 0.240625, 0.5, 0.221875, 0.8328125, 0.5546875, 0.5546875, 0.5546875, 0.5546875, 0.3328125, 0.5, 0.2765625, 0.5546875, 0.5, 0.721875, 0.5, 0.5, 0.5, 0.3546875, 0.259375, 0.353125, 0.5890625];
1157
1154
  var avg = 0.5279276315789471;
1158
- return String(str).split('').map(function (c) {
1159
- return c.charCodeAt(0) < widths.length ? widths[c.charCodeAt(0)] : avg;
1160
- }).reduce(function (cur, acc) {
1161
- return acc + cur;
1162
- }, 0) * fontSize;
1155
+ var s = String(str);
1156
+ var total = 0;
1157
+
1158
+ for (var i = 0; i < s.length; i++) {
1159
+ var _widths$code;
1160
+
1161
+ var code = s.charCodeAt(i);
1162
+ total += (_widths$code = widths[code]) !== null && _widths$code !== void 0 ? _widths$code : avg;
1163
+ }
1164
+
1165
+ return total * fontSize;
1163
1166
  }
1164
1167
 
1165
1168
  var defaultStarts = ['ATG'];
@@ -1357,48 +1360,8 @@ function _bytesForRegions() {
1357
1360
  return _bytesForRegions.apply(this, arguments);
1358
1361
  }
1359
1362
 
1360
- function viewBpToPx(_ref4) {
1361
- var refName = _ref4.refName,
1362
- coord = _ref4.coord,
1363
- regionNumber = _ref4.regionNumber,
1364
- self = _ref4.self;
1365
- var offsetBp = 0;
1366
- var interRegionPaddingBp = self.interRegionPaddingWidth * self.bpPerPx;
1367
- var minimumBlockBp = self.minimumBlockWidth * self.bpPerPx;
1368
- var index = self.displayedRegions.findIndex(function (region, idx) {
1369
- var len = region.end - region.start;
1370
-
1371
- if (refName === region.refName && coord >= region.start && coord <= region.end) {
1372
- if (regionNumber ? regionNumber === idx : true) {
1373
- offsetBp += region.reversed ? region.end - coord : coord - region.start;
1374
- return true;
1375
- }
1376
- } // add the interRegionPaddingWidth if the boundary is in the screen
1377
- // e.g. offset>=0 && offset<width
1378
-
1379
-
1380
- if (len > minimumBlockBp && offsetBp / self.bpPerPx >= 0 && offsetBp / self.bpPerPx < self.width) {
1381
- offsetBp += len + interRegionPaddingBp;
1382
- } else {
1383
- offsetBp += len;
1384
- }
1385
-
1386
- return false;
1387
- });
1388
- var found = self.displayedRegions[index];
1389
-
1390
- if (found) {
1391
- return {
1392
- index: index,
1393
- offsetPx: Math.round(offsetBp / self.bpPerPx)
1394
- };
1395
- }
1396
-
1397
- return undefined;
1398
- } // supported adapter types by text indexer
1363
+ // supported adapter types by text indexer
1399
1364
  // ensure that this matches the method found in @jbrowse/text-indexing/util
1400
-
1401
-
1402
1365
  function supportedIndexingAdapters(type) {
1403
1366
  return ['Gff3TabixAdapter', 'VcfTabixAdapter', 'Gff3Adapter', 'VcfAdapter'].includes(type);
1404
1367
  }
@@ -1451,8 +1414,8 @@ function getViewParams(model, exportSVG) {
1451
1414
  };
1452
1415
  }
1453
1416
 
1454
- function getLayoutId(_ref5) {
1455
- var sessionId = _ref5.sessionId,
1456
- layoutId = _ref5.layoutId;
1417
+ function getLayoutId(_ref4) {
1418
+ var sessionId = _ref4.sessionId,
1419
+ layoutId = _ref4.layoutId;
1457
1420
  return sessionId + '-' + layoutId;
1458
1421
  }