@jbrowse/plugin-linear-genome-view 5.0.0-beta.2 → 5.0.0-beta.20

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 (177) hide show
  1. package/esm/LinearGenomeView/afterAttach.d.ts +22 -5
  2. package/esm/LinearGenomeView/afterAttach.js +129 -106
  3. package/esm/LinearGenomeView/axisConfigSchema.d.ts +18 -0
  4. package/esm/LinearGenomeView/axisConfigSchema.js +22 -0
  5. package/esm/LinearGenomeView/components/CenterLine.js +10 -5
  6. package/esm/LinearGenomeView/components/ConnectedHoverHighlight.js +2 -3
  7. package/esm/LinearGenomeView/components/CrisprGuidePanel.js +3 -5
  8. package/esm/LinearGenomeView/components/ExportSvgDialog.d.ts +9 -4
  9. package/esm/LinearGenomeView/components/ExportSvgDialog.js +45 -8
  10. package/esm/LinearGenomeView/components/GetSequenceDialog.js +2 -2
  11. package/esm/LinearGenomeView/components/Header.js +11 -1
  12. package/esm/LinearGenomeView/components/HeaderClearHighlightButton.js +2 -2
  13. package/esm/LinearGenomeView/components/HeaderPanControls.d.ts +3 -3
  14. package/esm/LinearGenomeView/components/HeaderPanControls.js +6 -3
  15. package/esm/LinearGenomeView/components/HeaderSearchBoxes.js +4 -1
  16. package/esm/LinearGenomeView/components/HeaderZoomControls.js +6 -35
  17. package/esm/LinearGenomeView/components/Highlight.js +27 -11
  18. package/esm/LinearGenomeView/components/HighlightBand.d.ts +11 -2
  19. package/esm/LinearGenomeView/components/HighlightBand.js +32 -13
  20. package/esm/LinearGenomeView/components/HighlightChip.d.ts +3 -3
  21. package/esm/LinearGenomeView/components/HighlightChip.js +13 -8
  22. package/esm/LinearGenomeView/components/HighlightLabelDialog.d.ts +6 -0
  23. package/esm/LinearGenomeView/components/HighlightLabelDialog.js +18 -0
  24. package/esm/LinearGenomeView/components/HoverPositionHighlight.js +3 -3
  25. package/esm/LinearGenomeView/components/ImportForm.js +7 -9
  26. package/esm/LinearGenomeView/components/LinearGenomeView.js +5 -12
  27. package/esm/LinearGenomeView/components/LinearGenomeViewContainer.js +13 -14
  28. package/esm/LinearGenomeView/components/MiniControls.js +11 -5
  29. package/esm/LinearGenomeView/components/OverviewHighlight.js +3 -3
  30. package/esm/LinearGenomeView/components/OverviewHighlightBand.d.ts +3 -2
  31. package/esm/LinearGenomeView/components/OverviewHighlightBand.js +6 -5
  32. package/esm/LinearGenomeView/components/OverviewRubberband.js +25 -48
  33. package/esm/LinearGenomeView/components/OverviewScalebar.js +4 -5
  34. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.js +5 -3
  35. package/esm/LinearGenomeView/components/PaddingBlocks.js +3 -8
  36. package/esm/LinearGenomeView/components/RangeSelectOverlay.js +5 -6
  37. package/esm/LinearGenomeView/components/RegionWidthEditorDialog.d.ts +3 -2
  38. package/esm/LinearGenomeView/components/RegionWidthEditorDialog.js +4 -4
  39. package/esm/LinearGenomeView/components/ResizeAllTracksHandle.d.ts +5 -0
  40. package/esm/LinearGenomeView/components/ResizeAllTracksHandle.js +74 -0
  41. package/esm/LinearGenomeView/components/Rubberband.d.ts +1 -2
  42. package/esm/LinearGenomeView/components/Rubberband.js +3 -2
  43. package/esm/LinearGenomeView/components/SVGHighlightBand.d.ts +10 -1
  44. package/esm/LinearGenomeView/components/SVGHighlightBand.js +16 -5
  45. package/esm/LinearGenomeView/components/Scalebar.d.ts +2 -6
  46. package/esm/LinearGenomeView/components/Scalebar.js +8 -5
  47. package/esm/LinearGenomeView/components/ScalebarRefNameLabels.js +51 -36
  48. package/esm/LinearGenomeView/components/SearchBox.js +10 -16
  49. package/esm/LinearGenomeView/components/SearchPanelForm.d.ts +3 -2
  50. package/esm/LinearGenomeView/components/SearchPanelForm.js +4 -2
  51. package/esm/LinearGenomeView/components/SearchResultsDialog.d.ts +4 -8
  52. package/esm/LinearGenomeView/components/SearchResultsDialog.js +7 -4
  53. package/esm/LinearGenomeView/components/SearchResultsTable.d.ts +4 -7
  54. package/esm/LinearGenomeView/components/SearchResultsTable.js +25 -53
  55. package/esm/LinearGenomeView/components/SequenceFeatureHoverHighlight.js +2 -3
  56. package/esm/LinearGenomeView/components/SequenceSearchDialog.d.ts +2 -4
  57. package/esm/LinearGenomeView/components/StrandCheckboxes.d.ts +3 -2
  58. package/esm/LinearGenomeView/components/StrandCheckboxes.js +4 -2
  59. package/esm/LinearGenomeView/components/TrackContainer.d.ts +2 -3
  60. package/esm/LinearGenomeView/components/TrackContainer.js +63 -10
  61. package/esm/LinearGenomeView/components/TrackLabel.js +14 -4
  62. package/esm/LinearGenomeView/components/TrackLabelButtons.js +2 -2
  63. package/esm/LinearGenomeView/components/TrackLabelDragHandle.js +4 -5
  64. package/esm/LinearGenomeView/components/TrackLabelMenu.js +11 -14
  65. package/esm/LinearGenomeView/components/TrackLabelRefNameWarning.d.ts +3 -4
  66. package/esm/LinearGenomeView/components/TrackLabelRefNameWarning.js +23 -10
  67. package/esm/LinearGenomeView/components/TrackRenderingContainer.d.ts +6 -4
  68. package/esm/LinearGenomeView/components/TrackRenderingContainer.js +12 -24
  69. package/esm/LinearGenomeView/components/TracksContainer.js +11 -23
  70. package/esm/LinearGenomeView/components/VerticalGuide.d.ts +1 -2
  71. package/esm/LinearGenomeView/components/VerticalGuide.js +3 -16
  72. package/esm/LinearGenomeView/components/fetchSequence.d.ts +1 -2
  73. package/esm/LinearGenomeView/components/fetchSequence.js +15 -7
  74. package/esm/LinearGenomeView/components/recentLocationsMenu.js +10 -0
  75. package/esm/LinearGenomeView/components/useRangeSelect.d.ts +0 -3
  76. package/esm/LinearGenomeView/components/useRangeSelect.js +26 -61
  77. package/esm/LinearGenomeView/components/useSearchBoxPrefs.d.ts +3 -1
  78. package/esm/LinearGenomeView/components/useSearchBoxPrefs.js +4 -2
  79. package/esm/LinearGenomeView/components/useSideScroll.d.ts +17 -2
  80. package/esm/LinearGenomeView/components/useSideScroll.js +156 -102
  81. package/esm/LinearGenomeView/components/util.d.ts +4 -0
  82. package/esm/LinearGenomeView/components/util.js +4 -2
  83. package/esm/LinearGenomeView/consts.d.ts +2 -0
  84. package/esm/LinearGenomeView/consts.js +3 -1
  85. package/esm/LinearGenomeView/containingLgv.d.ts +21 -0
  86. package/esm/LinearGenomeView/containingLgv.js +23 -0
  87. package/esm/LinearGenomeView/headerFit.d.ts +4 -2
  88. package/esm/LinearGenomeView/headerFit.js +20 -7
  89. package/esm/LinearGenomeView/index.d.ts +2 -7
  90. package/esm/LinearGenomeView/index.js +5 -7
  91. package/esm/LinearGenomeView/keyboardHandler.d.ts +8 -7
  92. package/esm/LinearGenomeView/keyboardHandler.js +61 -23
  93. package/esm/LinearGenomeView/launchKeys.d.ts +1 -1
  94. package/esm/LinearGenomeView/launchKeys.js +11 -6
  95. package/esm/LinearGenomeView/lazyDialogs.d.ts +16 -3
  96. package/esm/LinearGenomeView/lazyDialogs.js +1 -0
  97. package/esm/LinearGenomeView/linkedViewSync.d.ts +3 -11
  98. package/esm/LinearGenomeView/linkedViewSync.js +27 -49
  99. package/esm/LinearGenomeView/menuItems.d.ts +16 -18
  100. package/esm/LinearGenomeView/menuItems.js +264 -164
  101. package/esm/LinearGenomeView/model.d.ts +1192 -560
  102. package/esm/LinearGenomeView/model.js +805 -590
  103. package/esm/LinearGenomeView/rExport/exportLinearView.d.ts +17 -0
  104. package/esm/LinearGenomeView/rExport/exportLinearView.js +117 -0
  105. package/esm/LinearGenomeView/rExport/rScript.d.ts +110 -0
  106. package/esm/LinearGenomeView/rExport/rScript.js +524 -0
  107. package/esm/LinearGenomeView/sharedScaleContainer.d.ts +1 -1
  108. package/esm/LinearGenomeView/sharedScaleContainer.js +2 -12
  109. package/esm/LinearGenomeView/showFiles.d.ts +2 -0
  110. package/esm/LinearGenomeView/showFiles.js +19 -0
  111. package/esm/LinearGenomeView/showRegionsWithUndo.d.ts +1 -1
  112. package/esm/LinearGenomeView/showRegionsWithUndo.js +13 -5
  113. package/esm/LinearGenomeView/stickyChrome.d.ts +5 -9
  114. package/esm/LinearGenomeView/stickyChrome.js +5 -9
  115. package/esm/LinearGenomeView/svgcomponents/SVGGridlines.js +4 -4
  116. package/esm/LinearGenomeView/svgcomponents/SVGHeader.d.ts +4 -1
  117. package/esm/LinearGenomeView/svgcomponents/SVGHeader.js +8 -21
  118. package/esm/LinearGenomeView/svgcomponents/SVGHighlights.d.ts +3 -1
  119. package/esm/LinearGenomeView/svgcomponents/SVGHighlights.js +9 -9
  120. package/esm/LinearGenomeView/svgcomponents/SVGHighlightsOverlay.d.ts +3 -1
  121. package/esm/LinearGenomeView/svgcomponents/SVGHighlightsOverlay.js +5 -5
  122. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +13 -18
  123. package/esm/LinearGenomeView/svgcomponents/SVGRegionSeparators.js +2 -5
  124. package/esm/LinearGenomeView/svgcomponents/SVGRowHeader.js +5 -6
  125. package/esm/LinearGenomeView/svgcomponents/SVGRuler.js +9 -10
  126. package/esm/LinearGenomeView/svgcomponents/SVGScalebar.js +3 -3
  127. package/esm/LinearGenomeView/svgcomponents/SVGStackedRow.d.ts +26 -0
  128. package/esm/LinearGenomeView/svgcomponents/SVGStackedRow.js +12 -0
  129. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js +21 -13
  130. package/esm/LinearGenomeView/svgcomponents/SVGTracks.d.ts +4 -5
  131. package/esm/LinearGenomeView/svgcomponents/SVGTracks.js +7 -6
  132. package/esm/LinearGenomeView/svgcomponents/SVGView.d.ts +2 -3
  133. package/esm/LinearGenomeView/svgcomponents/SVGView.js +17 -3
  134. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.d.ts +24 -20
  135. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.js +42 -29
  136. package/esm/LinearGenomeView/svgcomponents/useViewSvgFigure.js +74 -77
  137. package/esm/LinearGenomeView/svgcomponents/util.d.ts +28 -12
  138. package/esm/LinearGenomeView/svgcomponents/util.js +41 -29
  139. package/esm/LinearGenomeView/types.d.ts +13 -10
  140. package/esm/LinearGenomeView/types.js +0 -1
  141. package/esm/LinearGenomeView/util.d.ts +103 -46
  142. package/esm/LinearGenomeView/util.js +222 -170
  143. package/esm/MultiLevelRubberband/MultiLevelRubberband.js +9 -6
  144. package/esm/MultiLevelRubberband/index.d.ts +2 -0
  145. package/esm/MultiLevelRubberband/index.js +2 -0
  146. package/esm/MultiLevelRubberband/menuItems.d.ts +34 -0
  147. package/esm/MultiLevelRubberband/menuItems.js +52 -0
  148. package/esm/MultiLevelRubberband/rowLabel.d.ts +22 -0
  149. package/esm/MultiLevelRubberband/rowLabel.js +27 -0
  150. package/esm/MultiLevelRubberband/types.d.ts +1 -0
  151. package/esm/MultiLevelRubberband/useRangeSelect.d.ts +2 -1
  152. package/esm/MultiLevelRubberband/useRangeSelect.js +45 -59
  153. package/esm/TrackModifiers/index.d.ts +83 -0
  154. package/esm/TrackModifiers/index.js +231 -0
  155. package/esm/displayKitTests/perRegionTestEnv.d.ts +244 -68
  156. package/esm/displayKitTests/perRegionTestEnv.js +30 -26
  157. package/esm/index.d.ts +21 -99
  158. package/esm/index.js +17 -38
  159. package/esm/searchUtils.d.ts +26 -10
  160. package/esm/searchUtils.js +137 -137
  161. package/esm/shared/RubberbandSpan.d.ts +3 -2
  162. package/esm/shared/RubberbandSpan.js +6 -3
  163. package/esm/shared/coordLabels.d.ts +11 -4
  164. package/esm/shared/coordLabels.js +20 -5
  165. package/esm/shared/useWindowDrag.d.ts +18 -0
  166. package/esm/shared/useWindowDrag.js +47 -0
  167. package/package.json +12 -11
  168. package/esm/FeatureTrack/configSchema.d.ts +0 -124
  169. package/esm/FeatureTrack/configSchema.js +0 -54
  170. package/esm/FeatureTrack/index.d.ts +0 -2
  171. package/esm/FeatureTrack/index.js +0 -13
  172. package/esm/LinearGenomeView/initKeys.d.ts +0 -12
  173. package/esm/LinearGenomeView/initKeys.js +0 -68
  174. package/esm/MultiLevelRubberband/VerticalGuide.d.ts +0 -6
  175. package/esm/MultiLevelRubberband/VerticalGuide.js +0 -21
  176. package/esm/lazyPluginExports.d.ts +0 -23
  177. package/esm/lazyPluginExports.js +0 -36
@@ -80,7 +80,7 @@ export function defaultTextHeight(fontSize) {
80
80
  export function offsetLabelBaselineY(textHeight, fontSize) {
81
81
  return textHeight - LABEL_PAD_BOTTOM - labelDescent(fontSize);
82
82
  }
83
- // Baseline for a label inset into the top of the box it draws over ('overlay'
83
+ // Baseline for a label inset into the top of the box it draws over ('overlapping'
84
84
  // mode), measured down from that top edge so the ascenders stay inside it.
85
85
  export function insetLabelBaselineY(fontSize) {
86
86
  return labelBaselineFromTop(LABEL_PAD_TOP, fontSize);
@@ -99,6 +99,9 @@ export function insetLabelBaselineY(fontSize) {
99
99
  // scale in each row the only thing saying whether two rows are at the same zoom
100
100
  // is their ruler coordinates, which are unreadable at the size a figure is
101
101
  // published at. The standalone LGV export has drawn this bar all along.
102
+ //
103
+ // The name's band is reserved whether or not the row draws one: a breakpoint
104
+ // split view names its first row only, and the rest stay the same height as it.
102
105
  export function getRowHeaderLayout({ fontSize, showScalebar, }) {
103
106
  const label = labelInkHeight(fontSize);
104
107
  // the bp label hangs a cap below the bar's line and its own ink box ends a gap
@@ -111,8 +114,10 @@ export function getRowHeaderLayout({ fontSize, showScalebar, }) {
111
114
  // ink box rather than by baseline, because the gaps are fixed while a font's
112
115
  // descent is not: laying the label out from its baseline instead put its
113
116
  // descenders through that cap at the larger export fonts.
117
+ // without a scalebar the name sits on its baseline at the origin, its
118
+ // descenders into the ruler's top, so only the ink above the baseline counts
114
119
  const assemblyInkTop = scalebarLineY === undefined
115
- ? -label
120
+ ? -labelBaselineFromTop(0, fontSize)
116
121
  : scalebarLineY - SVG_SCALEBAR_CAP - ROW_GAP - label;
117
122
  return {
118
123
  // undefined rather than an unused number: a row without a scalebar has no
@@ -123,17 +128,9 @@ export function getRowHeaderLayout({ fontSize, showScalebar, }) {
123
128
  assemblyLabelBaselineY: showScalebar
124
129
  ? labelBaselineFromTop(assemblyInkTop, fontSize)
125
130
  : 0,
126
- // up from the ruler to the top of the topmost ink box — the assembly
127
- // label's, in both cases
128
131
  bandHeight: -assemblyInkTop,
129
132
  };
130
133
  }
131
- // Compact vertical layout for the exported header: rows (assembly name,
132
- // cytoband overview, "you are here" polygon, total-bp scalebar, ruler) are
133
- // stacked with a small fixed gap rather than reserving loose fixed-height
134
- // bands, so nothing is separated by dead space. `tracksTop` is where the track
135
- // bodies begin (renderToSvg's `offset`). Shared by SVGHeader and renderToSvg so
136
- // the header height and the track origin can't drift.
137
134
  export function getHeaderLayout({ fontSize, showCytobands, rulerHeight, }) {
138
135
  // the assembly name is drawn on its ink box, not on `fontSize`: at y=0 with a
139
136
  // hanging baseline its ascenders rose above the export's top edge and got
@@ -161,7 +158,6 @@ export function getHeaderLayout({ fontSize, showCytobands, rulerHeight, }) {
161
158
  // Ruler tick geometry, shared by the tick marks and their number labels.
162
159
  export const RULER_MAJOR_TICK = 5;
163
160
  export const RULER_MINOR_TICK = 3;
164
- export const RULER_TICK_FONT_SIZE = 11;
165
161
  // clearance between the tick-number baseline and the marks below it
166
162
  const RULER_TICK_LABEL_GAP = 2;
167
163
  // Vertical positions within a ruler of the given budget: tick marks hang just
@@ -180,18 +176,30 @@ export function getRulerLayout(rulerHeight) {
180
176
  // 13, and both ends of the glyphs at any smaller export font.
181
177
  export const refNameLabelBoxHeight = labelInkHeight(REF_NAME_LABEL_FONT_SIZE);
182
178
  export const refNameLabelBaselineY = labelBaselineFromTop(0, REF_NAME_LABEL_FONT_SIZE);
183
- // space the label pushes a track down by; only 'offset' mode does
184
- export function labelOffset(trackLabels, textHeight) {
185
- return trackLabels === 'offset' ? textHeight : 0;
179
+ // The mode one track's label is drawn in. 'overlapping' yields to 'offset' for a
180
+ // display that `prefersOffset`, as TrackContainer does on screen: its left edge
181
+ // carries content — an axis, a sample's genotypes — the label would print over.
182
+ // 'left' yields to 'offset' for a track whose sidebar holds the gutter beside
183
+ // its rows.
184
+ export function trackLabelMode(track, trackLabels) {
185
+ return (trackLabels === 'overlapping' && track.displays[0]?.prefersOffset) ||
186
+ (trackLabels === 'left' && trackSidebarWidth(track) > 0)
187
+ ? 'offset'
188
+ : trackLabels;
189
+ }
190
+ // space an 'offset' label pushes a track's body down by
191
+ export function labelOffset(track, trackLabels, textHeight) {
192
+ return trackLabelMode(track, trackLabels) === 'offset' ? textHeight : 0;
186
193
  }
187
194
  // Gap between a 'left' track label's right edge and the track body.
188
195
  // SVGTrackLabel right-aligns its text at `trackLabelOffset - TRACK_LABEL_GAP`,
189
196
  // so it and trackLabelLeftOffset must agree or the widest name overflows the
190
197
  // gutter it was measured for.
191
198
  export const TRACK_LABEL_GAP = 40;
192
- // Horizontal gutter reserved for 'left' track labels (0 in every other mode).
193
- // Takes an already-minimized-filtered track list, so the reserved width matches
194
- // the labels that actually get drawn.
199
+ // Horizontal gutter left of the track bodies: the widest of each track's
200
+ // sidebar and of each name drawn 'left', plus TRACK_LABEL_GAP. Takes an
201
+ // already-minimized-filtered track list, so the reserved width matches the
202
+ // labels that actually get drawn.
195
203
  //
196
204
  // `fontFamily` is the export's own font option, and it has to reach the ruler
197
205
  // here: the labels are drawn in it (wrapSvgExport puts it on the root <svg>,
@@ -208,31 +216,35 @@ export const TRACK_LABEL_GAP = 40;
208
216
  // `getScalebarRefNameLabels`, an on-screen model getter, so making them
209
217
  // family-aware means threading an export option through screen state.
210
218
  export function trackLabelLeftOffset({ tracks, trackLabels, fontSize, fontFamily, session, }) {
211
- // no labels means no gutter, and that includes having no tracks to label: the
212
- // gap alone would push the whole figure right of a margin nothing is drawn in
213
- return trackLabels === 'left' && tracks.length > 0
214
- ? max(tracks.map(t => measureText(svgTrackName(t, session), fontSize, fontFamily)), 0) + TRACK_LABEL_GAP
215
- : 0;
219
+ return max(tracks.map(t => Math.max(trackSidebarWidth(t, { fontSize, fontFamily }), trackLabelMode(t, trackLabels) === 'left'
220
+ ? measureText(svgTrackName(t, session), fontSize, fontFamily) +
221
+ TRACK_LABEL_GAP
222
+ : 0)), 0);
223
+ }
224
+ // Px of tree and row labels a track's display draws left of its body.
225
+ export function trackSidebarWidth(track, text) {
226
+ return track.displays[0]?.svgSidebarWidth?.(text) ?? 0;
216
227
  }
217
228
  // vertical box a single track occupies. Shared by totalHeight (sum) and
218
229
  // trackBoxOffsets (prefix-sum) so the two can't drift.
219
- export function trackBoxHeight(track, textOffset) {
220
- return track.displays[0].height + textOffset + trackSpacing;
230
+ export function trackBoxHeight(track, trackLabels, textHeight) {
231
+ return (track.displays[0].height +
232
+ labelOffset(track, trackLabels, textHeight) +
233
+ trackSpacing);
221
234
  }
222
235
  // Top y of each track's box within a stack of them. SVGTracks lays the bodies
223
236
  // out with it and the breakpoint-split export anchors its overlay ribbons with
224
237
  // it, so one implementation rather than two prefix-sums that must agree —
225
238
  // they drifted by trackSpacing per track when they didn't.
226
- export function trackBoxOffsets(tracks, textOffset) {
239
+ export function trackBoxOffsets(tracks, trackLabels, textHeight) {
227
240
  const offsets = [];
228
241
  let total = 0;
229
242
  for (const track of tracks) {
230
243
  offsets.push(total);
231
- total += trackBoxHeight(track, textOffset);
244
+ total += trackBoxHeight(track, trackLabels, textHeight);
232
245
  }
233
246
  return offsets;
234
247
  }
235
- export function totalHeight(tracks, textHeight, trackLabels) {
236
- const textOffset = labelOffset(trackLabels, textHeight);
237
- return sum(tracks.map(t => trackBoxHeight(t, textOffset)));
248
+ export function totalHeight(tracks, trackLabels, textHeight) {
249
+ return sum(tracks.map(t => trackBoxHeight(t, trackLabels, textHeight)));
238
250
  }
@@ -1,20 +1,16 @@
1
1
  import type { LinearGenomeViewStateModel } from './model.ts';
2
- import type { HighlightType } from '@jbrowse/core/util/highlights';
2
+ import type { BpOffset as CoreBpOffset } from '@jbrowse/core/util/Base1DUtils';
3
+ import type { HighlightInput, HighlightType } from '@jbrowse/core/util/highlights';
3
4
  import type { TrackInit } from '@jbrowse/core/util/tracks';
4
5
  import type { SnapshotIn } from '@jbrowse/mobx-state-tree';
5
- export interface BpOffset {
6
- refName?: string;
7
- index: number;
8
- offset: number;
9
- start?: number;
10
- end?: number;
6
+ export interface BpOffset extends CoreBpOffset {
11
7
  coord?: number;
12
8
  reversed?: boolean;
13
9
  assemblyName?: string;
14
10
  oob?: boolean;
15
11
  }
16
- export type { ExportSvgOptions, TrackLabelMode, } from '@jbrowse/display-kit/types';
17
- export type { HighlightType };
12
+ export type { ExportSvgOptions, TrackLabelMode, ViewTrackLabelMode, } from '@jbrowse/display-kit/types';
13
+ export type { HighlightInput, HighlightType };
18
14
  export interface NavLocation {
19
15
  refName: string;
20
16
  start?: number;
@@ -34,11 +30,18 @@ export interface InitState {
34
30
  */
35
31
  loc?: string;
36
32
  grow?: number;
33
+ showHitTrack?: boolean;
37
34
  assembly: string;
38
35
  displayedRegionNames?: string[];
39
36
  tracks?: TrackInit[];
40
37
  tracklist?: boolean;
41
38
  nav?: boolean;
42
- highlight?: (string | HighlightType)[];
39
+ highlight?: (string | HighlightInput)[];
43
40
  }
44
41
  export type LinearGenomeViewLaunchProps = Partial<Omit<SnapshotIn<LinearGenomeViewStateModel>, keyof InitState | 'id' | 'type' | 'launch'>>;
42
+ /**
43
+ * One LinearGenomeView panel inside another view (a breakpoint split view's
44
+ * stack, a synteny view's rows): the LGV's launch keys and props, less `nav`
45
+ * and `tracklist`, the header and the track selector a panel does not show.
46
+ */
47
+ export type LinearGenomeViewPanelInit = Omit<InitState, 'nav' | 'tracklist'> & LinearGenomeViewLaunchProps;
@@ -1,2 +1 @@
1
1
  export {};
2
- // #endregion
@@ -1,6 +1,14 @@
1
1
  import type { AssemblyManager, ParsedLocString } from '@jbrowse/core/util';
2
+ import type { PxToBpResult } from '@jbrowse/core/util/Base1DUtils';
2
3
  import type { BaseBlock, ContentBlock } from '@jbrowse/core/util/blockTypes';
3
4
  import type { Region } from '@jbrowse/core/util/types';
5
+ interface CenterKeepingView {
6
+ width: number;
7
+ displayedRegions: Region[];
8
+ pxToBp: (px: number) => PxToBpResult;
9
+ setDisplayedRegions: (regions: Region[]) => void;
10
+ centerAt: (coord: number, refName: string, index?: number) => void;
11
+ }
4
12
  /**
5
13
  * The stored viewport of a view showing `totalBp` of displayed regions fitted to
6
14
  * `width` — the regions filling it edge to edge, and centered in it only where
@@ -17,7 +25,7 @@ import type { Region } from '@jbrowse/core/util/types';
17
25
  * A caller building a view SNAPSHOT does: it has no model to call
18
26
  * `fitAllRegions()` on, and naming `bpPerPx`/`offsetPx` instead is dropped
19
27
  * whenever the snapshot also carries a `windowWidthBp` — which one copied off an
20
- * existing view always does. plugin-canvas's collapsed-intron launch is that
28
+ * existing view always does. plugin-features's collapsed-intron launch is that
21
29
  * caller. A live view calls `fitAllRegions()`.
22
30
  *
23
31
  * `width` enters only through the zoom-in floor, which bites for a region set
@@ -64,7 +72,7 @@ export interface Tick {
64
72
  * `makeBlockTicks`. What the two do share is already shared: `chooseGridPitch`,
65
73
  * and `base` as the 0-based coordinate that `getTickDisplayStr` labels `base+1`.
66
74
  */
67
- export declare function makeTicks(start: number, end: number, bpPerPx: number, emitMajor?: boolean, emitMinor?: boolean): Tick[];
75
+ export declare function makeTicks(start: number, end: number, bpPerPx: number, includeMinor?: boolean): Tick[];
68
76
  /** A block's refName, or undefined for non-content (elided/padding) blocks. */
69
77
  export declare function getBlockRefName(block: BaseBlock): string | undefined;
70
78
  /**
@@ -104,48 +112,31 @@ export interface ScalebarRefNameLabel {
104
112
  }
105
113
  /**
106
114
  * Builds the refName labels drawn along the scalebar as plain data (no JSX): one
107
- * label per run of same-refName regions (deduped so collapsed introns don't
108
- * repeat the name) plus a "sticky" label pinned to the left edge naming the
109
- * refName under the viewport's left border.
110
- *
111
- * `caption` is the row-level chip at the viewport's left edge, and it says two
112
- * things: which assembly this row is (`prefix`, an assembly name, synteny only)
113
- * and whether the row is flipped. Without it a row of stacked genomes would
114
- * label some rows with the assembly name and some without, depending only on
115
- * how wide their leftmost chromosome happens to be.
115
+ * label per run of same-refName regions, the leftmost of them "sticky" — pinned
116
+ * so the run under the left edge stays named once its own left edge scrolls off.
116
117
  *
117
- * The assembly name alone folds into the sticky label instead — "prefix:refName"
118
- * — whenever the two would collide at the left edge, and stands alone when the
119
- * sticky label sits far enough right not to (a view scrolled left of its first
120
- * region, so the row's data starts mid-viewport) or when there is no sticky
121
- * label at all.
118
+ * `caption` is the row-level chip at the viewport's left edge: which assembly
119
+ * the row is (`prefix`, synteny only) and whether the whole row is flipped. The
120
+ * chip takes `captionSpanPx` of the strip and the labels get the rest, so the
121
+ * sticky label pins to the chip's right edge ("hg38" then "chr1") and rides the
122
+ * run under THAT edge. A run the chip covers entirely goes unnamed, and the
123
+ * chip is not shortened to uncover it: a width fitted to the run under it
124
+ * changes with every run that pans past, and a fixed cap short enough to
125
+ * uncover a 55px chromosome cuts ordinary names. The assembly's `displayName`
126
+ * is where a long name gets shortened.
122
127
  *
123
- * `orientation` decides the ` [rev]` marker, and it is the row's
124
- * (`displayedRegionsOrientation`) rather than anything read off the blocks —
125
- * blocks cover the window, and a row is flipped or not whatever part of it you
126
- * are looking at. The rule is `assembleLocStrings`': say it where it
127
- * distinguishes, once where it does not.
128
+ * `orientation` decides the ` [rev]` marker, following `assembleLocStrings`: say
129
+ * it where it distinguishes, once where it does not.
128
130
  *
129
- * - `reversed`: the whole row is flipped, which is a fact about the row, so the
130
- * caption carries it and NO name does. The caption cannot fold in this state
131
- * — the sticky label is pushed clear of it instead — because a marker sitting
132
- * on a chromosome name is how the mixed case spells a fact about that one
133
- * region. `chr1 [rev] | chr2` would otherwise mean both "the row is flipped,
134
- * said once" and "chr1 is flipped and chr2 is not", in identical pixels.
135
- * - `mixed`: only some regions are flipped — reachable through the label menu's
136
- * per-region "Reverse region" — so every reversed run is marked and the
137
- * forward ones are left alone. Here the marker on a name is the only thing
138
- * telling two labels apart.
131
+ * - `reversed`: the caption carries the marker and no name does. A marker on a
132
+ * chromosome name is how the mixed case flags that one region.
133
+ * - `mixed`: every reversed run is marked. A marked label that fails the fit
134
+ * test falls back to the bare name rather than dropping.
139
135
  * - `forward`: no marker.
140
136
  *
141
- * Saying it once is the point: a flipped whole-genome row would otherwise
142
- * repeat `[rev]` after all 24 chromosomes to say a single thing about the row.
143
- *
144
- * Under `mixed` the marker never costs a name: a suffixed label that fails the
145
- * fit test falls back to the bare name rather than being dropped. Widening the
146
- * text moves the region width a name needs from ~30px to ~56px at 11px bold,
147
- * and a feature meant to surface information should not be deleting chromosome
148
- * names in the narrow half of that gap.
137
+ * `maxWidth` is the whole label box, `paddingLeft` included — both consumers
138
+ * clip from the box's left edge. A name is drawn whole or not at all: clipped
139
+ * mid-glyph, "chr16" reads as "chr1".
149
140
  */
150
141
  export declare function getScalebarRefNameLabels({ blocks, offsetPx, prefix, orientation, }: {
151
142
  blocks: BaseBlock[];
@@ -192,13 +183,35 @@ export declare function regionMoveActions(idx: number, numRegions: number): {
192
183
  to: number;
193
184
  }[];
194
185
  /**
195
- * The region reorderings offered by the refName-label menu, as pure list
196
- * transforms feeding setDisplayedRegions (which re-clamps bpPerPx/offsetPx for
197
- * the new region set).
186
+ * A new region list, and where each old index went in it (-1 for a region it
187
+ * dropped). The index map is what lets a region displayed twice be followed.
188
+ */
189
+ export interface RegionEdit {
190
+ regions: Region[];
191
+ newIndexOf: (oldIndex: number) => number;
192
+ }
193
+ export declare function withRegionMoved(regions: Region[], from: number, to: number): RegionEdit;
194
+ export declare function withRegionRemoved(regions: Region[], index: number): RegionEdit;
195
+ export declare function withRegionsKept(regions: Region[], first: number, last: number): RegionEdit;
196
+ export declare function withRegionReversed(regions: Region[], index: number): RegionEdit;
197
+ /**
198
+ * Apply a region edit and keep the base under the middle of the viewport
199
+ * there, where the edit kept its region. `setDisplayedRegions` alone carries
200
+ * `offsetPx` into a coordinate space the edit redefined, which lands on
201
+ * whatever region now sits at that offset.
198
202
  */
199
- export declare function withRegionMoved(regions: Region[], from: number, to: number): Region[];
200
- export declare function withRegionRemoved(regions: Region[], index: number): Region[];
201
- export declare function withRegionReversed(regions: Region[], index: number): Region[];
203
+ export declare function setDisplayedRegionsKeepingCenter(model: CenterKeepingView, { regions, newIndexOf }: RegionEdit): void;
204
+ /**
205
+ * The full run of same-orientation regions on one refName that a scalebar
206
+ * label's `firstRegionIndex`..`lastRegionIndex` sits inside. Those come off the
207
+ * static blocks, which are clipped to the viewport and broken by an elided
208
+ * block, so a zoomed-in collapsed-introns view brackets only the exons on
209
+ * screen — which is the wrong answer for anything acting on the whole run.
210
+ */
211
+ export declare function regionRunBounds(regions: Region[], firstIndex: number, lastIndex: number): {
212
+ first: number;
213
+ last: number;
214
+ };
202
215
  /**
203
216
  * Whether a label occupying [leftPx, leftPx + labelWidth] fits within a block
204
217
  * of the given pixel width, used to skip tick labels that would be clipped at a
@@ -264,6 +277,7 @@ export interface BlockRun {
264
277
  reversed: boolean;
265
278
  refName: string;
266
279
  isLeftEndOfDisplayedRegion: boolean;
280
+ labeled: boolean;
267
281
  }
268
282
  export declare function groupContiguousBlocks(blocks: BaseBlock[]): BlockRun[];
269
283
  /**
@@ -300,7 +314,7 @@ export declare function makeBlockTicks({ start, end, reversed, }: {
300
314
  start: number;
301
315
  end: number;
302
316
  reversed?: boolean;
303
- }, bpPerPx: number, emitMajor?: boolean, emitMinor?: boolean): {
317
+ }, bpPerPx: number, includeMinor?: boolean): {
304
318
  type: 'major' | 'minor';
305
319
  base: number;
306
320
  x: number;
@@ -347,4 +361,47 @@ export declare function generateLocations({ regions, assemblyManager, assemblyNa
347
361
  * Used by navToLocString
348
362
  */
349
363
  export declare function parseLocStrings(input: string, assemblyName: string, isValidRefName: (str: string, assemblyName: string) => boolean): ParsedLocString[];
364
+ /** One span of the row that is not track data — see `paddingSpans`. */
365
+ export interface PaddingSpan {
366
+ key: string;
367
+ x: number;
368
+ width: number;
369
+ kind: 'seam' | 'elided' | 'boundary';
370
+ }
371
+ /**
372
+ * Tick positions in the staticBlocks frame, one pass per merged run so a tick
373
+ * on an internal ~800px chunk boundary is emitted once.
374
+ */
375
+ export declare function getGridlineTicks({ blocks, firstBlockOffset, bpPerPx, }: {
376
+ blocks: BaseBlock[];
377
+ firstBlockOffset: number;
378
+ bpPerPx: number;
379
+ }): {
380
+ x: number;
381
+ major: boolean;
382
+ }[];
383
+ /**
384
+ * Coordinate labels in the staticBlocks frame, off the same ticks as
385
+ * `getGridlineTicks`. A run that can hold too few labels to make a ruler goes
386
+ * unnumbered, and the bold refName label pinned at a run's left edge takes
387
+ * precedence over a number.
388
+ */
389
+ export declare function getScalebarLabels({ blocks, firstBlockOffset, bpPerPx, orientation, }: {
390
+ blocks: BaseBlock[];
391
+ firstBlockOffset: number;
392
+ bpPerPx: number;
393
+ orientation: RegionsOrientation;
394
+ }): {
395
+ x: number;
396
+ label: string;
397
+ key: string;
398
+ }[];
399
+ /**
400
+ * Every span along the row that is not track data, in the staticBlocks frame.
401
+ * Nothing to draw returns one shared array, so the computed's value repeats and
402
+ * MobX's `===` stops the chain: a view inside one contig has no seam, elision
403
+ * or boundary, and a fresh `[]` each frame re-rendered every track's padding.
404
+ */
405
+ export declare function getPaddingSpans(blocks: BaseBlock[], firstBlockOffset: number): readonly PaddingSpan[];
350
406
  export declare function calculateVisibleLocStrings(contentBlocks: ContentBlock[]): string;
407
+ export {};