@jbrowse/plugin-linear-genome-view 2.10.3 → 2.11.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.
Files changed (80) hide show
  1. package/dist/BaseLinearDisplay/components/Tooltip.js +1 -0
  2. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +0 -1
  3. package/dist/BasicTrack/index.d.ts +1 -2
  4. package/dist/BasicTrack/index.js +3 -2
  5. package/dist/FeatureTrack/index.d.ts +1 -2
  6. package/dist/FeatureTrack/index.js +3 -2
  7. package/dist/LaunchLinearGenomeView/index.d.ts +1 -2
  8. package/dist/LaunchLinearGenomeView/index.js +17 -8
  9. package/dist/LinearBareDisplay/index.d.ts +1 -2
  10. package/dist/LinearBareDisplay/index.js +3 -2
  11. package/dist/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  12. package/dist/LinearBasicDisplay/index.d.ts +1 -2
  13. package/dist/LinearBasicDisplay/index.js +3 -2
  14. package/dist/LinearGenomeView/components/Cytobands.d.ts +1 -125
  15. package/dist/LinearGenomeView/components/Cytobands.js +11 -12
  16. package/dist/LinearGenomeView/components/ExportSvgDialog.js +9 -5
  17. package/dist/LinearGenomeView/components/Highlight.d.ts +3 -3
  18. package/dist/LinearGenomeView/components/Highlight.js +21 -17
  19. package/dist/LinearGenomeView/components/MiniControls.js +13 -15
  20. package/dist/LinearGenomeView/components/OverviewHighlight.d.ts +1 -1
  21. package/dist/LinearGenomeView/components/OverviewHighlight.js +20 -11
  22. package/dist/LinearGenomeView/components/OverviewRubberband.d.ts +1 -1
  23. package/dist/LinearGenomeView/components/OverviewScalebar.js +4 -1
  24. package/dist/LinearGenomeView/components/OverviewScalebarPolygon.d.ts +1 -1
  25. package/dist/LinearGenomeView/components/OverviewScalebarPolygon.js +2 -1
  26. package/dist/LinearGenomeView/components/RefNameAutocomplete/index.d.ts +9 -9
  27. package/dist/LinearGenomeView/components/RefNameAutocomplete/index.js +28 -35
  28. package/dist/LinearGenomeView/components/Rubberband.d.ts +1 -1
  29. package/dist/LinearGenomeView/components/SearchBox.d.ts +1 -1
  30. package/dist/LinearGenomeView/components/SearchResultsTable.js +1 -1
  31. package/dist/LinearGenomeView/components/TrackContainer.js +10 -23
  32. package/dist/LinearGenomeView/components/TrackLabel.js +33 -6
  33. package/dist/LinearGenomeView/components/ZoomControls.js +4 -4
  34. package/dist/LinearGenomeView/model.d.ts +67 -7
  35. package/dist/LinearGenomeView/model.js +102 -16
  36. package/dist/LinearGenomeView/svgcomponents/SVGHeader.js +1 -1
  37. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +1 -1
  38. package/dist/LinearGenomeView/svgcomponents/SVGTrackLabel.js +1 -1
  39. package/dist/index.d.ts +159 -21
  40. package/esm/BaseLinearDisplay/components/Tooltip.js +1 -0
  41. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js +0 -1
  42. package/esm/BasicTrack/index.d.ts +1 -2
  43. package/esm/BasicTrack/index.js +2 -2
  44. package/esm/FeatureTrack/index.d.ts +1 -2
  45. package/esm/FeatureTrack/index.js +2 -2
  46. package/esm/LaunchLinearGenomeView/index.d.ts +1 -2
  47. package/esm/LaunchLinearGenomeView/index.js +16 -8
  48. package/esm/LinearBareDisplay/index.d.ts +1 -2
  49. package/esm/LinearBareDisplay/index.js +2 -2
  50. package/esm/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  51. package/esm/LinearBasicDisplay/index.d.ts +1 -2
  52. package/esm/LinearBasicDisplay/index.js +2 -2
  53. package/esm/LinearGenomeView/components/Cytobands.d.ts +1 -125
  54. package/esm/LinearGenomeView/components/Cytobands.js +11 -12
  55. package/esm/LinearGenomeView/components/ExportSvgDialog.js +9 -5
  56. package/esm/LinearGenomeView/components/Highlight.d.ts +3 -3
  57. package/esm/LinearGenomeView/components/Highlight.js +21 -17
  58. package/esm/LinearGenomeView/components/MiniControls.js +14 -16
  59. package/esm/LinearGenomeView/components/OverviewHighlight.d.ts +1 -1
  60. package/esm/LinearGenomeView/components/OverviewHighlight.js +20 -11
  61. package/esm/LinearGenomeView/components/OverviewRubberband.d.ts +1 -1
  62. package/esm/LinearGenomeView/components/OverviewScalebar.js +5 -2
  63. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.d.ts +1 -1
  64. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.js +2 -1
  65. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.d.ts +9 -9
  66. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.js +28 -35
  67. package/esm/LinearGenomeView/components/Rubberband.d.ts +1 -1
  68. package/esm/LinearGenomeView/components/SearchBox.d.ts +1 -1
  69. package/esm/LinearGenomeView/components/SearchResultsTable.js +1 -1
  70. package/esm/LinearGenomeView/components/TrackContainer.js +10 -23
  71. package/esm/LinearGenomeView/components/TrackLabel.js +33 -6
  72. package/esm/LinearGenomeView/components/TracksContainer.js +2 -2
  73. package/esm/LinearGenomeView/components/ZoomControls.js +4 -4
  74. package/esm/LinearGenomeView/model.d.ts +67 -7
  75. package/esm/LinearGenomeView/model.js +103 -17
  76. package/esm/LinearGenomeView/svgcomponents/SVGHeader.js +1 -1
  77. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +1 -1
  78. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js +2 -2
  79. package/esm/index.d.ts +159 -21
  80. package/package.json +2 -2
@@ -50,6 +50,8 @@ const FolderOpen_1 = __importDefault(require("@mui/icons-material/FolderOpen"));
50
50
  const PhotoCamera_1 = __importDefault(require("@mui/icons-material/PhotoCamera"));
51
51
  const ZoomIn_1 = __importDefault(require("@mui/icons-material/ZoomIn"));
52
52
  const MenuOpen_1 = __importDefault(require("@mui/icons-material/MenuOpen"));
53
+ const Palette_1 = __importDefault(require("@mui/icons-material/Palette"));
54
+ const Search_1 = __importDefault(require("@mui/icons-material/Search"));
53
55
  const MiniControls_1 = __importDefault(require("./components/MiniControls"));
54
56
  const Header_1 = __importDefault(require("./components/Header"));
55
57
  const util_2 = require("./util");
@@ -126,7 +128,6 @@ function stateModelFactory(pluginManager) {
126
128
  tracks: mobx_state_tree_1.types.array(pluginManager.pluggableMstType('track', 'stateModel')),
127
129
  /**
128
130
  * #property
129
- * array of currently displayed tracks state model's
130
131
  */
131
132
  hideHeader: false,
132
133
  /**
@@ -169,7 +170,12 @@ function stateModelFactory(pluginManager) {
169
170
  * #property
170
171
  * highlights on the LGV from the URL parameters
171
172
  */
172
- highlight: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.frozen()),
173
+ highlight: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.array(mobx_state_tree_1.types.frozen()), []),
174
+ /**
175
+ * #property
176
+ * color by CDS
177
+ */
178
+ colorByCDS: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.boolean, () => Boolean(JSON.parse((0, util_1.localStorageGetItem)('lgv-colorByCDS') || 'false'))),
173
179
  }))
174
180
  .volatile(() => ({
175
181
  volatileWidth: undefined,
@@ -360,7 +366,7 @@ function stateModelFactory(pluginManager) {
360
366
  return {
361
367
  ...(0, tracks_1.getParentRenderProps)(self),
362
368
  bpPerPx: self.bpPerPx,
363
- highResolutionScaling: (0, configuration_1.getConf)((0, util_1.getSession)(self), 'highResolutionScaling'),
369
+ colorByCDS: self.colorByCDS,
364
370
  };
365
371
  },
366
372
  /**
@@ -431,6 +437,12 @@ function stateModelFactory(pluginManager) {
431
437
  },
432
438
  }))
433
439
  .actions(self => ({
440
+ /**
441
+ * #action
442
+ */
443
+ setColorByCDS(flag) {
444
+ self.colorByCDS = flag;
445
+ },
434
446
  /**
435
447
  * #action
436
448
  */
@@ -473,11 +485,24 @@ function stateModelFactory(pluginManager) {
473
485
  setShowGridlines(b) {
474
486
  self.showGridlines = b;
475
487
  },
488
+ /**
489
+ * #action
490
+ */
491
+ addToHighlights(highlight) {
492
+ var _a;
493
+ (_a = self.highlight) === null || _a === void 0 ? void 0 : _a.push(highlight);
494
+ },
476
495
  /**
477
496
  * #action
478
497
  */
479
498
  setHighlight(highlight) {
480
- self.highlight = highlight;
499
+ self.highlight = (0, mobx_state_tree_1.cast)(highlight);
500
+ },
501
+ /**
502
+ * #action
503
+ */
504
+ removeHighlight(highlight) {
505
+ self.highlight.remove(highlight);
481
506
  },
482
507
  /**
483
508
  * #action
@@ -598,6 +623,47 @@ function stateModelFactory(pluginManager) {
598
623
  },
599
624
  }))
600
625
  .actions(self => ({
626
+ /**
627
+ * #action
628
+ */
629
+ moveTrackDown(id) {
630
+ const idx = self.tracks.findIndex(v => v.id === id);
631
+ if (idx === -1) {
632
+ return;
633
+ }
634
+ if (idx !== -1 && idx < self.tracks.length - 1) {
635
+ self.tracks.splice(idx, 2, self.tracks[idx + 1], self.tracks[idx]);
636
+ }
637
+ },
638
+ /**
639
+ * #action
640
+ */
641
+ moveTrackUp(id) {
642
+ const idx = self.tracks.findIndex(track => track.id === id);
643
+ if (idx > 0) {
644
+ self.tracks.splice(idx - 1, 2, self.tracks[idx], self.tracks[idx - 1]);
645
+ }
646
+ },
647
+ /**
648
+ * #action
649
+ */
650
+ moveTrackToTop(id) {
651
+ const idx = self.tracks.findIndex(track => track.id === id);
652
+ self.tracks = (0, mobx_state_tree_1.cast)([
653
+ self.tracks[idx],
654
+ ...self.tracks.filter(track => track.id !== id),
655
+ ]);
656
+ },
657
+ /**
658
+ * #action
659
+ */
660
+ moveTrackToBottom(id) {
661
+ const idx = self.tracks.findIndex(track => track.id === id);
662
+ self.tracks = (0, mobx_state_tree_1.cast)([
663
+ ...self.tracks.filter(track => track.id !== id),
664
+ self.tracks[idx],
665
+ ]);
666
+ },
601
667
  /**
602
668
  * #action
603
669
  */
@@ -610,9 +676,9 @@ function stateModelFactory(pluginManager) {
610
676
  if (newIndex === -1) {
611
677
  throw new Error(`Track ID ${targetId} not found`);
612
678
  }
613
- const track = (0, mobx_state_tree_1.getSnapshot)(self.tracks[oldIndex]);
614
- self.tracks.splice(oldIndex, 1);
615
- self.tracks.splice(newIndex, 0, track);
679
+ const tracks = self.tracks.filter((_, idx) => idx !== oldIndex);
680
+ tracks.splice(newIndex, 0, self.tracks[oldIndex]);
681
+ self.tracks = (0, mobx_state_tree_1.cast)(tracks);
616
682
  },
617
683
  /**
618
684
  * #action
@@ -803,7 +869,7 @@ function stateModelFactory(pluginManager) {
803
869
  * perform animated slide
804
870
  */
805
871
  function slide(viewWidths) {
806
- const [animate, cancelAnimation] = (0, util_1.springAnimate)(self.offsetPx, self.offsetPx + self.width * viewWidths, self.scrollTo);
872
+ const [animate, cancelAnimation] = (0, util_1.springAnimate)(self.offsetPx, self.offsetPx + self.width * viewWidths, self.scrollTo, undefined, undefined, 200);
807
873
  cancelLastAnimation();
808
874
  cancelLastAnimation = cancelAnimation;
809
875
  animate();
@@ -890,6 +956,7 @@ function stateModelFactory(pluginManager) {
890
956
  ? [
891
957
  {
892
958
  label: 'Sequence search',
959
+ icon: Search_1.default,
893
960
  onClick: () => {
894
961
  (0, util_1.getSession)(self).queueDialog(handleClose => [
895
962
  SequenceSearchDialog,
@@ -919,6 +986,13 @@ function stateModelFactory(pluginManager) {
919
986
  icon: SyncAlt_1.default,
920
987
  onClick: self.horizontallyFlip,
921
988
  },
989
+ {
990
+ label: 'Color by CDS',
991
+ type: 'checkbox',
992
+ checked: self.colorByCDS,
993
+ icon: Palette_1.default,
994
+ onClick: () => self.setColorByCDS(!self.colorByCDS),
995
+ },
922
996
  {
923
997
  label: 'Show...',
924
998
  icon: Visibility_1.default,
@@ -1083,11 +1157,10 @@ function stateModelFactory(pluginManager) {
1083
1157
  }, { delay: 150 }));
1084
1158
  (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
1085
1159
  const s = (s) => JSON.stringify(s);
1086
- const { showCytobandsSetting, showCenterLine } = self;
1087
- if (typeof localStorage !== 'undefined') {
1088
- localStorage.setItem('lgv-showCytobands', s(showCytobandsSetting));
1089
- localStorage.setItem('lgv-showCenterLine', s(showCenterLine));
1090
- }
1160
+ const { showCytobandsSetting, showCenterLine, colorByCDS } = self;
1161
+ (0, util_1.localStorageSetItem)('lgv-showCytobands', s(showCytobandsSetting));
1162
+ (0, util_1.localStorageSetItem)('lgv-showCenterLine', s(showCenterLine));
1163
+ (0, util_1.localStorageSetItem)('lgv-colorByCDS', s(colorByCDS));
1091
1164
  }));
1092
1165
  },
1093
1166
  }))
@@ -1271,8 +1344,9 @@ function stateModelFactory(pluginManager) {
1271
1344
  },
1272
1345
  /**
1273
1346
  * #method
1274
- * scrolls the view to center on the given bp. if that is not in any
1275
- * of the displayed regions, does nothing
1347
+ * scrolls the view to center on the given bp. if that is not in any of
1348
+ * the displayed regions, does nothing
1349
+ *
1276
1350
  * @param coord - basepair at which you want to center the view
1277
1351
  * @param refName - refName of the displayedRegion you are centering at
1278
1352
  * @param regionNumber - index of the displayedRegion
@@ -1330,7 +1404,19 @@ function stateModelFactory(pluginManager) {
1330
1404
  document.removeEventListener('keydown', handler);
1331
1405
  });
1332
1406
  },
1333
- }));
1407
+ }))
1408
+ .preProcessSnapshot(snap => {
1409
+ if (!snap) {
1410
+ return snap;
1411
+ }
1412
+ const { highlight, ...rest } = snap;
1413
+ return {
1414
+ highlight: Array.isArray(highlight) || highlight === undefined
1415
+ ? highlight
1416
+ : [highlight],
1417
+ ...rest,
1418
+ };
1419
+ });
1334
1420
  }
1335
1421
  exports.stateModelFactory = stateModelFactory;
1336
1422
  var LinearGenomeView_1 = require("./components/LinearGenomeView");
@@ -47,7 +47,7 @@ function SVGHeader({ model, fontSize, cytobandHeight, rulerHeight, }) {
47
47
  react_1.default.createElement("text", { x: 0, y: 0, dominantBaseline: "hanging", fontSize: fontSize, fill: c }, assemblyName),
48
48
  showCytobands ? (react_1.default.createElement("g", { transform: `translate(0 ${rulerHeight})` },
49
49
  react_1.default.createElement(Cytobands_1.default, { overview: overview, assembly: assembly, block: block }),
50
- react_1.default.createElement("rect", { stroke: "red", fill: "rgb(255,0,0,0.1)", width: Math.max(lastOverviewPx - firstOverviewPx, 0.5), height: __1.HEADER_OVERVIEW_HEIGHT - 1, x: firstOverviewPx, y: 0.5 }),
50
+ react_1.default.createElement("rect", { stroke: "red", fill: "rgb(255,0,0)", fillOpacity: 0.1, width: Math.max(lastOverviewPx - firstOverviewPx, 0.5), height: __1.HEADER_OVERVIEW_HEIGHT - 1, x: firstOverviewPx, y: 0.5 }),
51
51
  react_1.default.createElement("g", { transform: `translate(0,${__1.HEADER_OVERVIEW_HEIGHT})` },
52
52
  react_1.default.createElement(OverviewScalebarPolygon_1.default, { overview: overview, model: model, useOffset: false })))) : null,
53
53
  react_1.default.createElement("g", { transform: `translate(0 ${fontSize + y})` },
@@ -19,7 +19,7 @@ const util_2 = require("./util");
19
19
  // render LGV to SVG
20
20
  async function renderToSvg(model, opts) {
21
21
  await (0, mobx_1.when)(() => model.initialized);
22
- const { textHeight = 18, headerHeight = 40, rulerHeight = 50, fontSize = 13, cytobandHeight = 100, trackLabels = 'offset', themeName = 'default', Wrapper = ({ children }) => react_1.default.createElement(react_1.default.Fragment, null, children), } = opts;
22
+ const { textHeight = 18, headerHeight = 40, rulerHeight = 50, fontSize = 13, cytobandHeight = 100, trackLabels = 'offset', themeName = 'default', Wrapper = ({ children }) => children, } = opts;
23
23
  const session = (0, util_1.getSession)(model);
24
24
  const { allThemes } = session;
25
25
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -8,7 +8,7 @@ const material_1 = require("@mui/material");
8
8
  const util_1 = require("@jbrowse/core/util");
9
9
  function SVGTrackLabel({ trackLabels, trackName, fontSize, trackLabelOffset, x, }) {
10
10
  const theme = (0, material_1.useTheme)();
11
- const fill = theme.palette.text.primary;
11
+ const fill = (0, util_1.stripAlpha)(theme.palette.text.primary);
12
12
  const xoff = trackLabels === 'overlay' ? 5 : 0;
13
13
  const yoff = trackLabels === 'offset' ? 5 : 0;
14
14
  const name = (0, util_1.coarseStripHTML)(trackName);