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

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 (357) hide show
  1. package/esm/FeatureTrack/configSchema.d.ts +104 -65
  2. package/esm/FeatureTrack/configSchema.js +47 -1
  3. package/esm/FeatureTrack/index.js +1 -1
  4. package/esm/LaunchLinearGenomeView/index.d.ts +14 -0
  5. package/esm/LaunchLinearGenomeView/index.js +6 -12
  6. package/esm/LinearGenomeView/afterAttach.d.ts +20 -2
  7. package/esm/LinearGenomeView/afterAttach.js +250 -121
  8. package/esm/LinearGenomeView/components/CenterLine.d.ts +1 -1
  9. package/esm/LinearGenomeView/components/CenterLine.js +16 -7
  10. package/esm/LinearGenomeView/components/ConnectedHoverHighlight.d.ts +7 -0
  11. package/esm/LinearGenomeView/components/ConnectedHoverHighlight.js +22 -0
  12. package/esm/LinearGenomeView/components/CrisprGuidePanel.d.ts +3 -0
  13. package/esm/LinearGenomeView/components/CrisprGuidePanel.js +144 -0
  14. package/esm/LinearGenomeView/components/Cytobands.d.ts +6 -6
  15. package/esm/LinearGenomeView/components/Cytobands.js +76 -53
  16. package/esm/LinearGenomeView/components/ExportSvgDialog.d.ts +7 -3
  17. package/esm/LinearGenomeView/components/ExportSvgDialog.js +11 -67
  18. package/esm/LinearGenomeView/components/GetSequenceDialog.d.ts +5 -9
  19. package/esm/LinearGenomeView/components/GetSequenceDialog.js +84 -88
  20. package/esm/LinearGenomeView/components/Gridlines.d.ts +1 -1
  21. package/esm/LinearGenomeView/components/Gridlines.js +29 -58
  22. package/esm/LinearGenomeView/components/Header.d.ts +1 -1
  23. package/esm/LinearGenomeView/components/Header.js +32 -16
  24. package/esm/LinearGenomeView/components/HeaderClearHighlightButton.d.ts +21 -0
  25. package/esm/LinearGenomeView/components/HeaderClearHighlightButton.js +35 -0
  26. package/esm/LinearGenomeView/components/HeaderPanControls.d.ts +3 -2
  27. package/esm/LinearGenomeView/components/HeaderPanControls.js +16 -7
  28. package/esm/LinearGenomeView/components/HeaderRegionWidth.d.ts +1 -1
  29. package/esm/LinearGenomeView/components/HeaderRegionWidth.js +9 -6
  30. package/esm/LinearGenomeView/components/HeaderSearchBoxRow.d.ts +6 -0
  31. package/esm/LinearGenomeView/components/HeaderSearchBoxRow.js +27 -0
  32. package/esm/LinearGenomeView/components/HeaderSearchBoxes.d.ts +5 -0
  33. package/esm/LinearGenomeView/components/HeaderSearchBoxes.js +28 -0
  34. package/esm/LinearGenomeView/components/HeaderTrackSelectorButton.d.ts +3 -2
  35. package/esm/LinearGenomeView/components/HeaderTrackSelectorButton.js +11 -4
  36. package/esm/LinearGenomeView/components/HeaderZoomControls.d.ts +3 -2
  37. package/esm/LinearGenomeView/components/HeaderZoomControls.js +67 -51
  38. package/esm/LinearGenomeView/components/Highlight.d.ts +1 -1
  39. package/esm/LinearGenomeView/components/Highlight.js +19 -23
  40. package/esm/LinearGenomeView/components/HighlightBand.d.ts +3 -2
  41. package/esm/LinearGenomeView/components/HighlightBand.js +25 -8
  42. package/esm/LinearGenomeView/components/HighlightChip.d.ts +9 -0
  43. package/esm/LinearGenomeView/components/HighlightChip.js +15 -0
  44. package/esm/LinearGenomeView/components/HoverPositionHighlight.d.ts +12 -0
  45. package/esm/LinearGenomeView/components/HoverPositionHighlight.js +25 -0
  46. package/esm/LinearGenomeView/components/ImportForm.d.ts +3 -4
  47. package/esm/LinearGenomeView/components/ImportForm.js +95 -61
  48. package/esm/LinearGenomeView/components/LinearGenomeView.d.ts +1 -1
  49. package/esm/LinearGenomeView/components/LinearGenomeView.js +6 -5
  50. package/esm/LinearGenomeView/components/LinearGenomeViewContainer.d.ts +1 -1
  51. package/esm/LinearGenomeView/components/LinearGenomeViewContainer.js +89 -30
  52. package/esm/LinearGenomeView/components/MiniControls.d.ts +1 -1
  53. package/esm/LinearGenomeView/components/MiniControls.js +13 -10
  54. package/esm/LinearGenomeView/components/MotifListPanel.d.ts +3 -0
  55. package/esm/LinearGenomeView/components/MotifListPanel.js +59 -0
  56. package/esm/LinearGenomeView/components/NavigationAnnouncer.d.ts +32 -0
  57. package/esm/LinearGenomeView/components/NavigationAnnouncer.js +51 -0
  58. package/esm/LinearGenomeView/components/NoTracksActiveButton.d.ts +1 -1
  59. package/esm/LinearGenomeView/components/NoTracksActiveButton.js +1 -1
  60. package/esm/LinearGenomeView/components/OverviewHighlight.d.ts +2 -4
  61. package/esm/LinearGenomeView/components/OverviewHighlight.js +23 -44
  62. package/esm/LinearGenomeView/components/OverviewHighlightBand.d.ts +9 -0
  63. package/esm/LinearGenomeView/components/OverviewHighlightBand.js +26 -0
  64. package/esm/LinearGenomeView/components/OverviewRubberband.d.ts +3 -3
  65. package/esm/LinearGenomeView/components/OverviewRubberband.js +44 -57
  66. package/esm/LinearGenomeView/components/OverviewRubberbandHoverTooltip.d.ts +4 -5
  67. package/esm/LinearGenomeView/components/OverviewRubberbandHoverTooltip.js +13 -20
  68. package/esm/LinearGenomeView/components/OverviewScalebar.d.ts +3 -2
  69. package/esm/LinearGenomeView/components/OverviewScalebar.js +84 -79
  70. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.d.ts +19 -5
  71. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.js +55 -32
  72. package/esm/LinearGenomeView/components/OverviewScalebarTickLabels.d.ts +4 -5
  73. package/esm/LinearGenomeView/components/OverviewScalebarTickLabels.js +16 -18
  74. package/esm/LinearGenomeView/components/PaddingBlocks.d.ts +7 -0
  75. package/esm/LinearGenomeView/components/PaddingBlocks.js +61 -0
  76. package/esm/LinearGenomeView/components/RangeSelectOverlay.d.ts +9 -0
  77. package/esm/LinearGenomeView/components/RangeSelectOverlay.js +20 -0
  78. package/esm/LinearGenomeView/components/RegionWidthEditorDialog.d.ts +2 -3
  79. package/esm/LinearGenomeView/components/RegionWidthEditorDialog.js +19 -26
  80. package/esm/LinearGenomeView/components/Rubberband.d.ts +1 -1
  81. package/esm/LinearGenomeView/components/Rubberband.js +13 -16
  82. package/esm/LinearGenomeView/components/SVGHighlightBand.d.ts +10 -0
  83. package/esm/LinearGenomeView/components/SVGHighlightBand.js +9 -0
  84. package/esm/LinearGenomeView/components/Scalebar.d.ts +2 -2
  85. package/esm/LinearGenomeView/components/Scalebar.js +16 -21
  86. package/esm/LinearGenomeView/components/ScalebarCoordinateLabels.d.ts +1 -1
  87. package/esm/LinearGenomeView/components/ScalebarCoordinateLabels.js +54 -35
  88. package/esm/LinearGenomeView/components/ScalebarRefNameLabels.d.ts +1 -1
  89. package/esm/LinearGenomeView/components/ScalebarRefNameLabels.js +142 -126
  90. package/esm/LinearGenomeView/components/SearchBox.d.ts +22 -2
  91. package/esm/LinearGenomeView/components/SearchBox.js +58 -66
  92. package/esm/LinearGenomeView/components/SearchPanelForm.d.ts +9 -0
  93. package/esm/LinearGenomeView/components/SearchPanelForm.js +18 -0
  94. package/esm/LinearGenomeView/components/SearchResultsDialog.d.ts +3 -3
  95. package/esm/LinearGenomeView/components/SearchResultsDialog.js +5 -7
  96. package/esm/LinearGenomeView/components/SearchResultsTable.d.ts +4 -3
  97. package/esm/LinearGenomeView/components/SearchResultsTable.js +45 -53
  98. package/esm/LinearGenomeView/components/SequenceFeatureHoverHighlight.d.ts +5 -0
  99. package/esm/LinearGenomeView/components/SequenceFeatureHoverHighlight.js +37 -0
  100. package/esm/LinearGenomeView/components/SequenceFeatureHoverHighlightExtension.d.ts +2 -0
  101. package/esm/LinearGenomeView/components/SequenceFeatureHoverHighlightExtension.js +5 -0
  102. package/esm/LinearGenomeView/components/SequencePatternPanel.d.ts +3 -0
  103. package/esm/LinearGenomeView/components/SequencePatternPanel.js +42 -0
  104. package/esm/LinearGenomeView/components/SequenceSearchDialog.d.ts +2 -2
  105. package/esm/LinearGenomeView/components/SequenceSearchDialog.js +31 -53
  106. package/esm/LinearGenomeView/components/StrandCheckboxes.d.ts +8 -0
  107. package/esm/LinearGenomeView/components/StrandCheckboxes.js +13 -0
  108. package/esm/LinearGenomeView/components/TrackContainer.d.ts +1 -1
  109. package/esm/LinearGenomeView/components/TrackContainer.js +83 -39
  110. package/esm/LinearGenomeView/components/TrackLabel.d.ts +2 -3
  111. package/esm/LinearGenomeView/components/TrackLabel.js +11 -24
  112. package/esm/LinearGenomeView/components/TrackLabelButtons.d.ts +7 -0
  113. package/esm/LinearGenomeView/components/TrackLabelButtons.js +33 -0
  114. package/esm/LinearGenomeView/components/TrackLabelDragHandle.d.ts +2 -5
  115. package/esm/LinearGenomeView/components/TrackLabelDragHandle.js +6 -2
  116. package/esm/LinearGenomeView/components/TrackLabelMenu.d.ts +1 -1
  117. package/esm/LinearGenomeView/components/TrackLabelMenu.js +32 -85
  118. package/esm/LinearGenomeView/components/TrackLabelRefNameWarning.d.ts +22 -0
  119. package/esm/LinearGenomeView/components/TrackLabelRefNameWarning.js +46 -0
  120. package/esm/LinearGenomeView/components/TrackRenderingContainer.d.ts +1 -1
  121. package/esm/LinearGenomeView/components/TrackRenderingContainer.js +72 -18
  122. package/esm/LinearGenomeView/components/TracksContainer.d.ts +1 -1
  123. package/esm/LinearGenomeView/components/TracksContainer.js +65 -32
  124. package/esm/LinearGenomeView/components/VerticalGuide.d.ts +1 -1
  125. package/esm/LinearGenomeView/components/VerticalGuide.js +6 -13
  126. package/esm/LinearGenomeView/components/ZoomButton.d.ts +7 -0
  127. package/esm/LinearGenomeView/components/ZoomButton.js +27 -0
  128. package/esm/LinearGenomeView/components/ZoomTransform.d.ts +9 -0
  129. package/esm/LinearGenomeView/components/ZoomTransform.js +37 -0
  130. package/esm/LinearGenomeView/components/defaultMotifs.d.ts +1 -0
  131. package/esm/LinearGenomeView/components/defaultMotifs.js +22 -0
  132. package/esm/LinearGenomeView/components/fetchSequence.d.ts +7 -8
  133. package/esm/LinearGenomeView/components/fetchSequence.js +17 -9
  134. package/esm/LinearGenomeView/components/recentLocationsMenu.d.ts +15 -0
  135. package/esm/LinearGenomeView/components/recentLocationsMenu.js +36 -0
  136. package/esm/LinearGenomeView/components/searchModes.d.ts +13 -0
  137. package/esm/LinearGenomeView/components/searchModes.js +22 -0
  138. package/esm/LinearGenomeView/components/trackLabelMenuItems.d.ts +7 -0
  139. package/esm/LinearGenomeView/components/trackLabelMenuItems.js +67 -0
  140. package/esm/LinearGenomeView/components/useRangeSelect.d.ts +11 -66
  141. package/esm/LinearGenomeView/components/useRangeSelect.js +82 -91
  142. package/esm/LinearGenomeView/components/useSearchBoxPrefs.d.ts +26 -0
  143. package/esm/LinearGenomeView/components/useSearchBoxPrefs.js +58 -0
  144. package/esm/LinearGenomeView/components/useSideScroll.d.ts +1 -1
  145. package/esm/LinearGenomeView/components/useSideScroll.js +87 -19
  146. package/esm/LinearGenomeView/components/util.d.ts +20 -6
  147. package/esm/LinearGenomeView/components/util.js +27 -6
  148. package/esm/LinearGenomeView/consts.d.ts +7 -2
  149. package/esm/LinearGenomeView/consts.js +18 -2
  150. package/esm/LinearGenomeView/flyTo.d.ts +38 -0
  151. package/esm/LinearGenomeView/flyTo.js +135 -0
  152. package/esm/LinearGenomeView/headerFit.d.ts +27 -0
  153. package/esm/LinearGenomeView/headerFit.js +59 -0
  154. package/esm/LinearGenomeView/index.d.ts +32 -2
  155. package/esm/LinearGenomeView/index.js +16 -6
  156. package/esm/LinearGenomeView/initKeys.d.ts +12 -0
  157. package/esm/LinearGenomeView/initKeys.js +68 -0
  158. package/esm/LinearGenomeView/keyboardHandler.d.ts +7 -0
  159. package/esm/LinearGenomeView/keyboardHandler.js +10 -0
  160. package/esm/LinearGenomeView/launchKeys.d.ts +2 -0
  161. package/esm/LinearGenomeView/launchKeys.js +23 -0
  162. package/esm/LinearGenomeView/lazyDialogs.d.ts +7 -11
  163. package/esm/LinearGenomeView/lazyDialogs.js +3 -3
  164. package/esm/LinearGenomeView/linkedViewSync.d.ts +20 -0
  165. package/esm/LinearGenomeView/linkedViewSync.js +58 -0
  166. package/esm/LinearGenomeView/menuItems.d.ts +27 -2
  167. package/esm/LinearGenomeView/menuItems.js +137 -101
  168. package/esm/LinearGenomeView/model.d.ts +3238 -136
  169. package/esm/LinearGenomeView/model.js +2425 -528
  170. package/esm/LinearGenomeView/sharedScaleContainer.d.ts +18 -0
  171. package/esm/LinearGenomeView/sharedScaleContainer.js +17 -0
  172. package/esm/LinearGenomeView/showRegionsWithUndo.d.ts +35 -0
  173. package/esm/LinearGenomeView/showRegionsWithUndo.js +44 -0
  174. package/esm/LinearGenomeView/stickyChrome.d.ts +19 -0
  175. package/esm/LinearGenomeView/stickyChrome.js +30 -0
  176. package/esm/LinearGenomeView/svgcomponents/SVGGridlines.d.ts +1 -1
  177. package/esm/LinearGenomeView/svgcomponents/SVGGridlines.js +15 -16
  178. package/esm/LinearGenomeView/svgcomponents/SVGHeader.d.ts +2 -3
  179. package/esm/LinearGenomeView/svgcomponents/SVGHeader.js +45 -33
  180. package/esm/LinearGenomeView/svgcomponents/SVGHighlights.d.ts +5 -0
  181. package/esm/LinearGenomeView/svgcomponents/SVGHighlights.js +26 -0
  182. package/esm/LinearGenomeView/svgcomponents/SVGHighlightsOverlay.d.ts +5 -0
  183. package/esm/LinearGenomeView/svgcomponents/SVGHighlightsOverlay.js +13 -0
  184. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.d.ts +1 -3
  185. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +77 -41
  186. package/esm/LinearGenomeView/svgcomponents/SVGRegionSeparators.d.ts +1 -1
  187. package/esm/LinearGenomeView/svgcomponents/SVGRegionSeparators.js +23 -3
  188. package/esm/LinearGenomeView/svgcomponents/SVGRowHeader.d.ts +8 -0
  189. package/esm/LinearGenomeView/svgcomponents/SVGRowHeader.js +37 -0
  190. package/esm/LinearGenomeView/svgcomponents/SVGRuler.d.ts +3 -3
  191. package/esm/LinearGenomeView/svgcomponents/SVGRuler.js +64 -36
  192. package/esm/LinearGenomeView/svgcomponents/SVGScalebar.d.ts +1 -1
  193. package/esm/LinearGenomeView/svgcomponents/SVGScalebar.js +7 -5
  194. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.d.ts +5 -3
  195. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js +43 -7
  196. package/esm/LinearGenomeView/svgcomponents/SVGTracks.d.ts +8 -14
  197. package/esm/LinearGenomeView/svgcomponents/SVGTracks.js +16 -21
  198. package/esm/LinearGenomeView/svgcomponents/SVGView.d.ts +18 -0
  199. package/esm/LinearGenomeView/svgcomponents/SVGView.js +13 -0
  200. package/esm/LinearGenomeView/svgcomponents/figureContract.d.ts +45 -0
  201. package/esm/LinearGenomeView/svgcomponents/figureContract.js +130 -0
  202. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.d.ts +76 -0
  203. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.js +66 -0
  204. package/esm/LinearGenomeView/svgcomponents/useViewSvgFigure.d.ts +70 -0
  205. package/esm/LinearGenomeView/svgcomponents/useViewSvgFigure.js +263 -0
  206. package/esm/LinearGenomeView/svgcomponents/util.d.ts +92 -5
  207. package/esm/LinearGenomeView/svgcomponents/util.js +236 -3
  208. package/esm/LinearGenomeView/types.d.ts +17 -31
  209. package/esm/LinearGenomeView/types.js +1 -0
  210. package/esm/LinearGenomeView/util.d.ts +332 -12
  211. package/esm/LinearGenomeView/util.js +606 -62
  212. package/esm/MultiLevelRubberband/MultiLevelRubberband.d.ts +6 -0
  213. package/esm/MultiLevelRubberband/MultiLevelRubberband.js +37 -0
  214. package/esm/MultiLevelRubberband/VerticalGuide.d.ts +6 -0
  215. package/esm/MultiLevelRubberband/VerticalGuide.js +21 -0
  216. package/esm/MultiLevelRubberband/index.d.ts +2 -0
  217. package/esm/MultiLevelRubberband/index.js +1 -0
  218. package/esm/MultiLevelRubberband/types.d.ts +6 -0
  219. package/esm/MultiLevelRubberband/useRangeSelect.d.ts +24 -0
  220. package/esm/MultiLevelRubberband/useRangeSelect.js +136 -0
  221. package/esm/displayKitTests/perRegionTestEnv.d.ts +1286 -0
  222. package/esm/displayKitTests/perRegionTestEnv.js +138 -0
  223. package/esm/index.d.ts +122 -1235
  224. package/esm/index.js +101 -24
  225. package/esm/lazyPluginExports.d.ts +23 -0
  226. package/esm/lazyPluginExports.js +36 -0
  227. package/esm/searchUtils.d.ts +55 -11
  228. package/esm/searchUtils.js +342 -45
  229. package/esm/shared/RubberbandSpan.d.ts +15 -0
  230. package/esm/shared/RubberbandSpan.js +33 -0
  231. package/esm/shared/coordLabels.d.ts +40 -0
  232. package/esm/shared/coordLabels.js +119 -0
  233. package/package.json +18 -19
  234. package/esm/BaseLinearDisplay/SVGLegend.d.ts +0 -6
  235. package/esm/BaseLinearDisplay/SVGLegend.js +0 -17
  236. package/esm/BaseLinearDisplay/calculateSvgLegendWidth.d.ts +0 -2
  237. package/esm/BaseLinearDisplay/calculateSvgLegendWidth.js +0 -11
  238. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.d.ts +0 -8
  239. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.js +0 -53
  240. package/esm/BaseLinearDisplay/components/Block.d.ts +0 -14
  241. package/esm/BaseLinearDisplay/components/Block.js +0 -45
  242. package/esm/BaseLinearDisplay/components/BlockErrorMessage.d.ts +0 -7
  243. package/esm/BaseLinearDisplay/components/BlockErrorMessage.js +0 -22
  244. package/esm/BaseLinearDisplay/components/BlockMsg.d.ts +0 -6
  245. package/esm/BaseLinearDisplay/components/BlockMsg.js +0 -26
  246. package/esm/BaseLinearDisplay/components/CollapseIntronsDialog/CollapseIntronsDialog.d.ts +0 -9
  247. package/esm/BaseLinearDisplay/components/CollapseIntronsDialog/CollapseIntronsDialog.js +0 -42
  248. package/esm/BaseLinearDisplay/components/CollapseIntronsDialog/TranscriptTable.d.ts +0 -11
  249. package/esm/BaseLinearDisplay/components/CollapseIntronsDialog/TranscriptTable.js +0 -40
  250. package/esm/BaseLinearDisplay/components/CollapseIntronsDialog/util.d.ts +0 -19
  251. package/esm/BaseLinearDisplay/components/CollapseIntronsDialog/util.js +0 -45
  252. package/esm/BaseLinearDisplay/components/FloatingLabels.d.ts +0 -5
  253. package/esm/BaseLinearDisplay/components/FloatingLabels.js +0 -75
  254. package/esm/BaseLinearDisplay/components/FloatingLegend.d.ts +0 -8
  255. package/esm/BaseLinearDisplay/components/FloatingLegend.js +0 -43
  256. package/esm/BaseLinearDisplay/components/LinearBlocks.d.ts +0 -5
  257. package/esm/BaseLinearDisplay/components/LinearBlocks.js +0 -23
  258. package/esm/BaseLinearDisplay/components/LoadingOverlay.d.ts +0 -5
  259. package/esm/BaseLinearDisplay/components/LoadingOverlay.js +0 -49
  260. package/esm/BaseLinearDisplay/components/MaxHeightReachedIndicator.d.ts +0 -4
  261. package/esm/BaseLinearDisplay/components/MaxHeightReachedIndicator.js +0 -26
  262. package/esm/BaseLinearDisplay/components/MenuPage.d.ts +0 -8
  263. package/esm/BaseLinearDisplay/components/MenuPage.js +0 -24
  264. package/esm/BaseLinearDisplay/components/NonBlockCanvasDisplayComponent.d.ts +0 -21
  265. package/esm/BaseLinearDisplay/components/NonBlockCanvasDisplayComponent.js +0 -52
  266. package/esm/BaseLinearDisplay/components/RenderedBlocks.d.ts +0 -12
  267. package/esm/BaseLinearDisplay/components/RenderedBlocks.js +0 -22
  268. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.d.ts +0 -12
  269. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +0 -18
  270. package/esm/BaseLinearDisplay/components/TooLargeMessage.d.ts +0 -10
  271. package/esm/BaseLinearDisplay/components/TooLargeMessage.js +0 -20
  272. package/esm/BaseLinearDisplay/components/Tooltip.d.ts +0 -13
  273. package/esm/BaseLinearDisplay/components/Tooltip.js +0 -22
  274. package/esm/BaseLinearDisplay/components/types.d.ts +0 -1
  275. package/esm/BaseLinearDisplay/components/util.d.ts +0 -21
  276. package/esm/BaseLinearDisplay/components/util.js +0 -107
  277. package/esm/BaseLinearDisplay/index.d.ts +0 -17
  278. package/esm/BaseLinearDisplay/index.js +0 -13
  279. package/esm/BaseLinearDisplay/model.d.ts +0 -1197
  280. package/esm/BaseLinearDisplay/model.js +0 -432
  281. package/esm/BaseLinearDisplay/models/FeatureDensityMixin.d.ts +0 -32
  282. package/esm/BaseLinearDisplay/models/FeatureDensityMixin.js +0 -113
  283. package/esm/BaseLinearDisplay/models/NonBlockCanvasDisplayMixin.d.ts +0 -26
  284. package/esm/BaseLinearDisplay/models/NonBlockCanvasDisplayMixin.js +0 -57
  285. package/esm/BaseLinearDisplay/models/SvgFloatingLabels.d.ts +0 -8
  286. package/esm/BaseLinearDisplay/models/SvgFloatingLabels.js +0 -19
  287. package/esm/BaseLinearDisplay/models/TrackHeightMixin.d.ts +0 -11
  288. package/esm/BaseLinearDisplay/models/TrackHeightMixin.js +0 -31
  289. package/esm/BaseLinearDisplay/models/autorunFeatureDensityStats.d.ts +0 -2
  290. package/esm/BaseLinearDisplay/models/autorunFeatureDensityStats.js +0 -29
  291. package/esm/BaseLinearDisplay/models/configSchema.d.ts +0 -29
  292. package/esm/BaseLinearDisplay/models/configSchema.js +0 -33
  293. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +0 -98
  294. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js +0 -242
  295. package/esm/BaseLinearDisplay/models/util.d.ts +0 -9
  296. package/esm/BaseLinearDisplay/models/util.js +0 -43
  297. package/esm/BaseLinearDisplay/renderSvg.d.ts +0 -3
  298. package/esm/BaseLinearDisplay/renderSvg.js +0 -63
  299. package/esm/BaseLinearDisplay/types.d.ts +0 -43
  300. package/esm/BaseLinearDisplay/types.js +0 -3
  301. package/esm/BaseLinearDisplay/util.d.ts +0 -16
  302. package/esm/BaseLinearDisplay/util.js +0 -71
  303. package/esm/BasicTrack/configSchema.d.ts +0 -85
  304. package/esm/BasicTrack/configSchema.js +0 -8
  305. package/esm/BasicTrack/index.d.ts +0 -2
  306. package/esm/BasicTrack/index.js +0 -12
  307. package/esm/LinearBareDisplay/configSchema.d.ts +0 -32
  308. package/esm/LinearBareDisplay/configSchema.js +0 -11
  309. package/esm/LinearBareDisplay/index.d.ts +0 -4
  310. package/esm/LinearBareDisplay/index.js +0 -20
  311. package/esm/LinearBareDisplay/model.d.ts +0 -1196
  312. package/esm/LinearBareDisplay/model.js +0 -32
  313. package/esm/LinearBasicDisplay/components/LinearBasicDisplayComponent.d.ts +0 -5
  314. package/esm/LinearBasicDisplay/components/LinearBasicDisplayComponent.js +0 -9
  315. package/esm/LinearBasicDisplay/configSchema.d.ts +0 -32
  316. package/esm/LinearBasicDisplay/configSchema.js +0 -11
  317. package/esm/LinearBasicDisplay/index.d.ts +0 -4
  318. package/esm/LinearBasicDisplay/index.js +0 -20
  319. package/esm/LinearBasicDisplay/model.d.ts +0 -1391
  320. package/esm/LinearBasicDisplay/model.js +0 -158
  321. package/esm/LinearFeatureDisplay/components/AddFiltersDialog.d.ts +0 -9
  322. package/esm/LinearFeatureDisplay/components/AddFiltersDialog.js +0 -58
  323. package/esm/LinearFeatureDisplay/components/SetMaxHeightDialog.d.ts +0 -8
  324. package/esm/LinearFeatureDisplay/components/SetMaxHeightDialog.js +0 -26
  325. package/esm/LinearFeatureDisplay/configSchema.d.ts +0 -32
  326. package/esm/LinearFeatureDisplay/configSchema.js +0 -11
  327. package/esm/LinearFeatureDisplay/index.d.ts +0 -3
  328. package/esm/LinearFeatureDisplay/index.js +0 -2
  329. package/esm/LinearFeatureDisplay/model.d.ts +0 -1443
  330. package/esm/LinearFeatureDisplay/model.js +0 -305
  331. package/esm/LinearGenomeView/SVGErrorBox.d.ts +0 -5
  332. package/esm/LinearGenomeView/SVGErrorBox.js +0 -4
  333. package/esm/LinearGenomeView/components/ImportFormRefNameAutocomplete.d.ts +0 -11
  334. package/esm/LinearGenomeView/components/ImportFormRefNameAutocomplete.js +0 -27
  335. package/esm/LinearGenomeView/components/RefNameAutocomplete/AutocompleteTextField.d.ts +0 -5
  336. package/esm/LinearGenomeView/components/RefNameAutocomplete/AutocompleteTextField.js +0 -13
  337. package/esm/LinearGenomeView/components/RefNameAutocomplete/EndAdornment.d.ts +0 -3
  338. package/esm/LinearGenomeView/components/RefNameAutocomplete/EndAdornment.js +0 -17
  339. package/esm/LinearGenomeView/components/RefNameAutocomplete/HelpDialog.d.ts +0 -3
  340. package/esm/LinearGenomeView/components/RefNameAutocomplete/HelpDialog.js +0 -8
  341. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.d.ts +0 -16
  342. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.js +0 -101
  343. package/esm/LinearGenomeView/components/RefNameAutocomplete/util.d.ts +0 -10
  344. package/esm/LinearGenomeView/components/RefNameAutocomplete/util.js +0 -45
  345. package/esm/LinearGenomeView/components/RubberbandSpan.d.ts +0 -15
  346. package/esm/LinearGenomeView/components/RubberbandSpan.js +0 -32
  347. package/esm/LinearGenomeView/components/RubberbandTooltip.d.ts +0 -5
  348. package/esm/LinearGenomeView/components/RubberbandTooltip.js +0 -17
  349. package/esm/LinearGenomeView/components/TrackLabelContainer.d.ts +0 -8
  350. package/esm/LinearGenomeView/components/TrackLabelContainer.js +0 -25
  351. package/esm/LinearGenomeView/components/useWheelScroll.d.ts +0 -7
  352. package/esm/LinearGenomeView/components/useWheelScroll.js +0 -69
  353. package/esm/LinearGenomeView/svgExportUtil.d.ts +0 -9
  354. package/esm/LinearGenomeView/svgExportUtil.js +0 -6
  355. package/esm/LinearGenomeView/svgcomponents/SVGBackground.d.ts +0 -5
  356. package/esm/LinearGenomeView/svgcomponents/SVGBackground.js +0 -7
  357. /package/esm/{BaseLinearDisplay/components → MultiLevelRubberband}/types.js +0 -0
@@ -1,4 +1,47 @@
1
- import { assembleLocString, parseLocString } from '@jbrowse/core/util';
1
+ import { UnknownRefNameError, assembleLocStrings, getTickDisplayStr, measureText, parseBpString, parseLocString, } from '@jbrowse/core/util';
2
+ import { bpOffsetInRegion } from '@jbrowse/core/util/Base1DUtils';
3
+ import { chooseGridPitch } from '@jbrowse/core/util/chooseGridPitch';
4
+ import { tickLabelsWorthDrawing } from '@jbrowse/core/util/tickLabels';
5
+ /**
6
+ * The stored viewport of a view showing `totalBp` of displayed regions fitted to
7
+ * `width` — the regions filling it edge to edge, and centered in it only where
8
+ * they are too narrow to fill it.
9
+ *
10
+ * **This is where the fit-to-width rule is written.** `fitAllRegions` takes its
11
+ * scale from here rather than restating it, so the two cannot drift; a second
12
+ * spelling of `max(minBpPerPx * width, totalBp)` reading `MIN_BP_PER_PX` where
13
+ * the action reads the `minBpPerPx` GETTER would agree only for as long as
14
+ * nothing overrides it.
15
+ *
16
+ * The reason it is a function at all is `windowStartBp`, which `fitAllRegions`
17
+ * does not need (it centers in pixels, through `scrollTo`, which also clamps).
18
+ * A caller building a view SNAPSHOT does: it has no model to call
19
+ * `fitAllRegions()` on, and naming `bpPerPx`/`offsetPx` instead is dropped
20
+ * whenever the snapshot also carries a `windowWidthBp` — which one copied off an
21
+ * existing view always does. plugin-canvas's collapsed-intron launch is that
22
+ * caller. A live view calls `fitAllRegions()`.
23
+ *
24
+ * `width` enters only through the zoom-in floor, which bites for a region set
25
+ * narrower than `width * minBpPerPx`; the window itself is in bp and needs no
26
+ * width, which is why a snapshot can carry it at all.
27
+ */
28
+ export function fitAllRegionsWindow(totalBp, width, minBpPerPx) {
29
+ const windowWidthBp = Math.max(minBpPerPx * width, totalBp);
30
+ // the same centering as getCenteredOffsetPx: half the width the content leaves
31
+ // unfilled, which is zero whenever the fit above is exact
32
+ return { windowWidthBp, windowStartBp: (totalBp - windowWidthBp) / 2 };
33
+ }
34
+ /**
35
+ * Expand a region by a grow factor, adding padding on each side.
36
+ *
37
+ * @param start - region start coordinate
38
+ * @param end - region end coordinate
39
+ * @param grow - multiplier for expansion (e.g., 0.2 adds 20% padding on each
40
+ * side)
41
+ * @param minBound - minimum bound to clamp start to (default 0)
42
+ * @param maxBound - maximum bound to clamp end to (default Infinity)
43
+ * @returns object with expanded start and end coordinates
44
+ */
2
45
  export function expandRegion(start, end, grow, minBound = 0, maxBound = Infinity) {
3
46
  const len = end - start;
4
47
  const margin = len * grow;
@@ -7,57 +50,543 @@ export function expandRegion(start, end, grow, minBound = 0, maxBound = Infinity
7
50
  end: Math.min(maxBound, end + margin),
8
51
  };
9
52
  }
10
- export function chooseGridPitch(scale, minMajorPitchPx, minMinorPitchPx) {
11
- scale = Math.abs(scale);
12
- const minMajorPitchBp = minMajorPitchPx * scale;
13
- const majorMagnitude = +minMajorPitchBp.toExponential().split(/e/i)[1];
14
- let majorPitch = 10 ** majorMagnitude;
15
- while (majorPitch < minMajorPitchBp) {
16
- majorPitch *= 2;
17
- if (majorPitch >= minMajorPitchBp) {
18
- break;
19
- }
20
- majorPitch *= 2.5;
21
- }
22
- majorPitch = Math.max(majorPitch, 5);
23
- const majorPitchPx = majorPitch / scale;
24
- let minorPitch = 0;
25
- if (!(majorPitch % 10) && majorPitchPx / 10 >= minMinorPitchPx) {
26
- minorPitch = majorPitch / 10;
53
+ /**
54
+ * Generate tick positions for the overview scalebar. Anchors at the first neat
55
+ * majorPitch multiple strictly inside the block so ticks land on round numbers
56
+ * regardless of where the block starts/ends.
57
+ */
58
+ export function makeOverviewTicks(start, end, bpPerPx, reversed = false) {
59
+ // A zero (or negative) scale has no tick pitch to speak of, and this loop is
60
+ // sized in bp: chooseGridPitch bottoms out at 5bp, so a chromosome-length
61
+ // region would ask for tens of millions of ticks and hang. createOverviewLayout
62
+ // reports bpPerPx 0 whenever the overview's width collapses to 0 or less —
63
+ // a view narrower than its own chromosome-name gutter, or a caller that sets
64
+ // width directly (jbrowse-img) rather than through useWidthSetter, which
65
+ // filters 0 out.
66
+ if (!(bpPerPx > 0)) {
67
+ return [];
27
68
  }
28
- else if (!(majorPitch % 5) && majorPitchPx / 5 >= minMinorPitchPx) {
29
- minorPitch = majorPitch / 5;
30
- }
31
- else if (!(majorPitch % 2) && majorPitchPx / 2 >= minMinorPitchPx) {
32
- minorPitch = majorPitch / 2;
33
- }
34
- return { majorPitch, minorPitch };
69
+ const { majorPitch } = chooseGridPitch(bpPerPx, 120, 15);
70
+ const firstTick = reversed
71
+ ? Math.floor((end - 1) / majorPitch) * majorPitch
72
+ : Math.ceil((start + 1) / majorPitch) * majorPitch;
73
+ const numTicks = reversed
74
+ ? Math.floor((firstTick - start - 1) / majorPitch) + 1
75
+ : Math.floor((end - firstTick) / majorPitch) + 1;
76
+ return Array.from({ length: Math.max(0, numTicks) }, (_, i) => {
77
+ const genomicCoord = reversed
78
+ ? firstTick - i * majorPitch
79
+ : firstTick + i * majorPitch;
80
+ const offsetPx = bpOffsetInRegion({ start, end, reversed }, genomicCoord) / bpPerPx;
81
+ return { genomicCoord, offsetPx };
82
+ });
35
83
  }
84
+ /**
85
+ * Ticks for one span of the ruler. Not the dotplot's same-named function, which
86
+ * walks static blocks into a single continuous axis and therefore has to dedupe
87
+ * the shared block seam and carry each tick's px. Here every block draws its own
88
+ * clipped ruler, so this overscans its span instead of deduping and leaves px to
89
+ * `makeBlockTicks`. What the two do share is already shared: `chooseGridPitch`,
90
+ * and `base` as the 0-based coordinate that `getTickDisplayStr` labels `base+1`.
91
+ */
36
92
  export function makeTicks(start, end, bpPerPx, emitMajor = true, emitMinor = true) {
37
- const gridPitch = chooseGridPitch(bpPerPx, 60, 15);
38
- let minBase = start;
39
- let maxBase = end;
40
- if (bpPerPx < 0) {
41
- ;
42
- [minBase, maxBase] = [maxBase, minBase];
43
- }
44
- minBase -= Math.abs(20 * bpPerPx) - 1;
45
- maxBase += Math.abs(20 * bpPerPx) + 1;
46
- const iterPitch = gridPitch.minorPitch || gridPitch.majorPitch;
47
- let index = 0;
93
+ // Ask for the ~200px spacing this ruler actually wants, and mark majors at
94
+ // that pitch. This used to ask for 60px and then mark majors every *two*
95
+ // pitches, which spaced them the same but off chooseGridPitch's 1/2/5 ladder:
96
+ // doubling a ladder value yields 4×10ⁿ half the time, so the scalebar numbered
97
+ // 4000/8000/12000 rather than 5000/10000/15000. The overview scalebar
98
+ // (makeOverviewTicks) and the dotplot's ruler both already read majorPitch
99
+ // straight, which is the contract chooseGridPitch documents.
100
+ const { majorPitch, minorPitch } = chooseGridPitch(bpPerPx, 120, 15);
101
+ // pad 20px on each side so label ends that spill slightly outside the region
102
+ // still draw
103
+ const margin = 20 * bpPerPx;
104
+ const minBase = start - margin + 1;
105
+ const maxBase = end + margin + 1;
106
+ const iterPitch = minorPitch || majorPitch;
48
107
  const ticks = [];
49
108
  for (let base = Math.floor(minBase / iterPitch) * iterPitch; base < Math.ceil(maxBase / iterPitch) * iterPitch + 1; base += iterPitch) {
50
- if (emitMinor && base % (gridPitch.majorPitch * 2)) {
51
- ticks.push({ type: 'minor', base: base - 1, index });
52
- index += 1;
109
+ if (emitMinor && base % majorPitch) {
110
+ ticks.push({ type: 'minor', base: base - 1 });
53
111
  }
54
- else if (emitMajor && !(base % (gridPitch.majorPitch * 2))) {
55
- ticks.push({ type: 'major', base: base - 1, index });
56
- index += 1;
112
+ else if (emitMajor && !(base % majorPitch)) {
113
+ ticks.push({ type: 'major', base: base - 1 });
57
114
  }
58
115
  }
59
116
  return ticks;
60
117
  }
118
+ /** A block's refName, or undefined for non-content (elided/padding) blocks. */
119
+ export function getBlockRefName(block) {
120
+ return block.type === 'ContentBlock' ? block.refName : undefined;
121
+ }
122
+ /**
123
+ * For blocks in display order, returns whether each block's refName should be
124
+ * labeled: true only for the first block of each run of same-refName regions,
125
+ * so a refName is shown once instead of repeated at every region boundary (e.g.
126
+ * collapsed introns produce many adjacent same-refName regions).
127
+ *
128
+ * A block with no refName ends the run. What an elided block hides is *other
129
+ * chromosomes*, so the same name reappearing on its far side starts a region the
130
+ * reader needs named again, not a continuation of the one before it. Regions lay
131
+ * out contiguously, so an elided run is the only nameless block that can fall
132
+ * between two content blocks — the boundary pads only bracket the whole set,
133
+ * where ending a run changes nothing.
134
+ */
135
+ export function showRefNameLabels(blocks, getRefName) {
136
+ let prev;
137
+ return blocks.map(block => {
138
+ const refName = getRefName(block);
139
+ const show = refName !== undefined && refName !== prev;
140
+ prev = refName;
141
+ return show;
142
+ });
143
+ }
144
+ function refNameRuns(blocks) {
145
+ const runs = [];
146
+ let current;
147
+ for (const block of blocks) {
148
+ if (block.type !== 'ContentBlock' ||
149
+ block.displayedRegionIndex === undefined) {
150
+ current = undefined;
151
+ }
152
+ else if (
153
+ // orientation is part of a run's identity, not just its refName: one
154
+ // label carries one direction (a `[rev]` marker under mixed orientation
155
+ // has to mean the whole of what it sits on), and two regions of one
156
+ // chromosome laid out in opposite directions are two things to name
157
+ // anyway, however they are marked
158
+ current?.refName === block.refName &&
159
+ current.reversed === !!block.reversed) {
160
+ current.endPx = block.offsetPx + block.widthPx;
161
+ current.lastRegionIndex = block.displayedRegionIndex;
162
+ }
163
+ else {
164
+ current = {
165
+ key: block.key,
166
+ refName: block.refName,
167
+ reversed: !!block.reversed,
168
+ offsetPx: block.offsetPx,
169
+ endPx: block.offsetPx + block.widthPx,
170
+ firstRegionIndex: block.displayedRegionIndex,
171
+ lastRegionIndex: block.displayedRegionIndex,
172
+ isLeftEndOfDisplayedRegion: !!block.isLeftEndOfDisplayedRegion,
173
+ };
174
+ runs.push(current);
175
+ }
176
+ }
177
+ return runs;
178
+ }
179
+ /**
180
+ * Index of the run carrying the "sticky" refName label pinned to the left edge:
181
+ * the rightmost run whose left edge has scrolled off the left of the viewport,
182
+ * or the first run when none have.
183
+ */
184
+ function stickyRunIndex(runs, offsetPx) {
185
+ const scrolledOff = runs.findLastIndex(run => run.offsetPx < offsetPx);
186
+ return scrolledOff === -1 ? 0 : scrolledOff;
187
+ }
188
+ export function regionsOrientation(regions) {
189
+ const first = !!regions[0]?.reversed;
190
+ return regions.every(r => !!r.reversed === first)
191
+ ? first
192
+ ? 'reversed'
193
+ : 'forward'
194
+ : 'mixed';
195
+ }
196
+ /**
197
+ * What a reversed region's label says after its name. `[rev]` rather than a
198
+ * glyph, and not only because it is the spelling `assembleLocString` already
199
+ * writes into every locstring the search box shows: `measureText`'s width table
200
+ * is indexed by char code and covers ASCII only, so an arrow falls through to
201
+ * the average advance and measures ~6px against a real ~11px. The fit test
202
+ * upstream is whole-or-nothing, and it would go on believing a glyph fits.
203
+ */
204
+ const REV_MARKER = ' [rev]';
205
+ /** Clearance between the standalone assembly-name chip and a sticky label. */
206
+ const PREFIX_GAP = 4;
207
+ /** Left inset of a non-sticky refName label from its region's left edge. */
208
+ const REF_NAME_LABEL_PADDING_PX = 7;
209
+ /**
210
+ * translateX, maxWidth and paddingLeft for one refName label. Sticky labels
211
+ * start at the viewport's left edge; others start at their run's left edge.
212
+ *
213
+ * maxWidth is the width of the whole label box, paddingLeft included, so the
214
+ * text has `maxWidth - paddingLeft` to draw in — that is what both consumers
215
+ * clip to (a border-box max-width on the span, an SVG clip rect from the box's
216
+ * own left edge). The caller decides whether the name it wants to draw fits in
217
+ * that (see refNameLabelWidth); a name is drawn whole or not at all.
218
+ */
219
+ function refLabelLayout({ run, offsetPx, sticky,
220
+ // left-edge x a sticky label may not start before, so a caption chip drawn
221
+ // there keeps the strip to itself. Zero wherever the caption folds into the
222
+ // label instead (the assembly prefix does)
223
+ minTransform = 0, }) {
224
+ const transform = sticky
225
+ ? Math.max(minTransform, -offsetPx)
226
+ : run.offsetPx - offsetPx - 1;
227
+ // block-frame x where the label actually starts. Derived from `transform` (=
228
+ // transform + offsetPx) so the width-to-run-end clip stays in lockstep with
229
+ // where the label is drawn: a sticky label pins to the run's left edge, not
230
+ // the viewport's, whenever the view is left-overscrolled (offsetPx < 0) —
231
+ // reading offsetPx directly there over-counted the available width by
232
+ // |offsetPx|, letting the name bleed past its run's right edge.
233
+ const labelStartPx = transform + offsetPx;
234
+ // A non-sticky label's transform anchors at the same x as the region
235
+ // divider drawn just to its left (SVGRegionSeparators, a 3px bar spanning
236
+ // local [0,3] from this same run.offsetPx edge), so paddingLeft must clear
237
+ // that bar plus a few px of breathing room, else the text visually touches
238
+ // the divider. Sticky labels sit at the viewport's own left edge, no divider.
239
+ const paddingLeft = sticky ? 0 : REF_NAME_LABEL_PADDING_PX;
240
+ return { transform, maxWidth: run.endPx - labelStartPx - 1, paddingLeft };
241
+ }
242
+ /**
243
+ * Builds the refName labels drawn along the scalebar as plain data (no JSX): one
244
+ * label per run of same-refName regions (deduped so collapsed introns don't
245
+ * repeat the name) plus a "sticky" label pinned to the left edge naming the
246
+ * refName under the viewport's left border.
247
+ *
248
+ * `caption` is the row-level chip at the viewport's left edge, and it says two
249
+ * things: which assembly this row is (`prefix`, an assembly name, synteny only)
250
+ * and whether the row is flipped. Without it a row of stacked genomes would
251
+ * label some rows with the assembly name and some without, depending only on
252
+ * how wide their leftmost chromosome happens to be.
253
+ *
254
+ * The assembly name alone folds into the sticky label instead — "prefix:refName"
255
+ * — whenever the two would collide at the left edge, and stands alone when the
256
+ * sticky label sits far enough right not to (a view scrolled left of its first
257
+ * region, so the row's data starts mid-viewport) or when there is no sticky
258
+ * label at all.
259
+ *
260
+ * `orientation` decides the ` [rev]` marker, and it is the row's
261
+ * (`displayedRegionsOrientation`) rather than anything read off the blocks —
262
+ * blocks cover the window, and a row is flipped or not whatever part of it you
263
+ * are looking at. The rule is `assembleLocStrings`': say it where it
264
+ * distinguishes, once where it does not.
265
+ *
266
+ * - `reversed`: the whole row is flipped, which is a fact about the row, so the
267
+ * caption carries it and NO name does. The caption cannot fold in this state
268
+ * — the sticky label is pushed clear of it instead — because a marker sitting
269
+ * on a chromosome name is how the mixed case spells a fact about that one
270
+ * region. `chr1 [rev] | chr2` would otherwise mean both "the row is flipped,
271
+ * said once" and "chr1 is flipped and chr2 is not", in identical pixels.
272
+ * - `mixed`: only some regions are flipped — reachable through the label menu's
273
+ * per-region "Reverse region" — so every reversed run is marked and the
274
+ * forward ones are left alone. Here the marker on a name is the only thing
275
+ * telling two labels apart.
276
+ * - `forward`: no marker.
277
+ *
278
+ * Saying it once is the point: a flipped whole-genome row would otherwise
279
+ * repeat `[rev]` after all 24 chromosomes to say a single thing about the row.
280
+ *
281
+ * Under `mixed` the marker never costs a name: a suffixed label that fails the
282
+ * fit test falls back to the bare name rather than being dropped. Widening the
283
+ * text moves the region width a name needs from ~30px to ~56px at 11px bold,
284
+ * and a feature meant to surface information should not be deleting chromosome
285
+ * names in the narrow half of that gap.
286
+ */
287
+ export function getScalebarRefNameLabels({ blocks, offsetPx, prefix, orientation = 'forward', }) {
288
+ const hasPrefix = prefix !== undefined && prefix !== '';
289
+ const rowIsReversed = orientation === 'reversed';
290
+ const captionText = rowIsReversed
291
+ ? `${hasPrefix ? prefix : ''}${REV_MARKER}`.trimStart()
292
+ : prefix;
293
+ // the caption chip occupies the viewport's left edge, so a sticky label
294
+ // starting inside that span has to yield: absorb the assembly name, or, where
295
+ // the caption carries the row's orientation and so cannot fold, start after
296
+ // it. The gap is part of the span: a sticky label carries no padding of its
297
+ // own, so one starting at exactly the chip's right edge abuts it and the two
298
+ // read as a single word ("volvoxctgA") for the few px of scroll around the
299
+ // threshold
300
+ const captionSpanPx = captionText
301
+ ? refNameLabelWidth(captionText) + PREFIX_GAP
302
+ : 0;
303
+ const runs = refNameRuns(blocks);
304
+ const stickyIdx = stickyRunIndex(runs, offsetPx);
305
+ const labels = [];
306
+ let stickyHasPrefix = false;
307
+ for (const [i, run] of runs.entries()) {
308
+ const sticky = i === stickyIdx;
309
+ // A non-sticky run starting left of the viewport is entirely off-screen:
310
+ // the sticky run is by definition the rightmost one starting there, so
311
+ // every earlier run also *ends* left of the viewport. Its label would just
312
+ // repeat the name the sticky label already shows, drawn off-canvas —
313
+ // invisible on screen (overflow:clip) but bleeding into the margin of an
314
+ // SVG export, which has no such clip.
315
+ const runStart = run.offsetPx >= offsetPx && run.isLeftEndOfDisplayedRegion;
316
+ if (!(sticky || runStart)) {
317
+ continue;
318
+ }
319
+ const layout = refLabelLayout({
320
+ run,
321
+ offsetPx,
322
+ sticky,
323
+ minTransform: rowIsReversed ? captionSpanPx : 0,
324
+ });
325
+ const withPrefix = !rowIsReversed && sticky && hasPrefix && layout.transform < captionSpanPx;
326
+ const name = withPrefix ? `${prefix}:${run.refName}` : run.refName;
327
+ // draw the name whole or not at all: a name clipped mid-glyph reads as a
328
+ // different chromosome ("LG2" cut to "LG"), and measuring it means a short
329
+ // name gets its label in a region a fixed minimum width would have skipped.
330
+ // The marker is the one part that degrades instead of dropping the label
331
+ const text = (orientation === 'mixed' && run.reversed
332
+ ? [`${name}${REV_MARKER}`, name]
333
+ : [name]).find(candidate => layout.maxWidth >= layout.paddingLeft + refNameLabelWidth(candidate));
334
+ if (text === undefined) {
335
+ continue;
336
+ }
337
+ stickyHasPrefix ||= withPrefix;
338
+ labels.push({
339
+ key: run.key,
340
+ refName: run.refName,
341
+ displayedRegionIndex: run.firstRegionIndex,
342
+ lastDisplayedRegionIndex: run.lastRegionIndex,
343
+ sticky,
344
+ transform: layout.transform,
345
+ maxWidth: layout.maxWidth,
346
+ paddingLeft: layout.paddingLeft,
347
+ text,
348
+ });
349
+ }
350
+ return {
351
+ labels,
352
+ // the chip to draw at the left edge, or undefined for none. A caption
353
+ // carrying the orientation always draws; one carrying only the assembly
354
+ // name draws when no sticky label folded it in
355
+ caption: rowIsReversed || (hasPrefix && !stickyHasPrefix)
356
+ ? captionText
357
+ : undefined,
358
+ captionSpanPx,
359
+ };
360
+ }
361
+ /**
362
+ * Screen-x span a refName label paints over: its padding and its glyphs, which
363
+ * is the whole of it, since the box shrinks to its text rather than filling the
364
+ * `maxWidth` it was fitted against. Anything drawn under this span is hidden by
365
+ * the label's opaque backing, so the coordinate numbers use it to stay out from
366
+ * under the sticky label the way `runRefNameLabelPx` keeps them out from under
367
+ * the others.
368
+ */
369
+ export function refNameLabelSpanPx(label) {
370
+ return {
371
+ left: label.transform,
372
+ right: label.transform + label.paddingLeft + refNameLabelWidth(label.text),
373
+ };
374
+ }
375
+ /**
376
+ * Whether a label from getScalebarRefNameLabels is drawn whole within a
377
+ * viewport `widthPx` wide. The labels themselves are only fitted to their own
378
+ * *run of regions*, which routinely runs past the right edge of the view, so
379
+ * one starting a few px before that edge passes the run fit and is then cut by
380
+ * the viewport clip. On screen that reads as a name scrolled partly out of
381
+ * frame, but a static SVG export has no frame to scroll — there a cut "LG2"
382
+ * just names a chromosome that doesn't exist, so the export drops it instead,
383
+ * as it already does for tick numbers at the same edge.
384
+ */
385
+ export function refNameLabelFitsInView(label, widthPx) {
386
+ return refNameLabelSpanPx(label).right <= widthPx;
387
+ }
388
+ /**
389
+ * The reorder entries the refName-label menu offers for the region at `idx` of
390
+ * `numRegions`, each already carrying the index it moves to. The "far" moves
391
+ * need a gap of more than one between `idx` and the end — otherwise "Move to
392
+ * far left/right" targets the same index as "Move left/right" and duplicates
393
+ * the entry.
394
+ */
395
+ export function regionMoveActions(idx, numRegions) {
396
+ return [
397
+ { when: idx > 0, label: 'Move left', to: idx - 1 },
398
+ { when: idx < numRegions - 1, label: 'Move right', to: idx + 1 },
399
+ { when: idx > 1, label: 'Move to far left', to: 0 },
400
+ {
401
+ when: idx < numRegions - 2,
402
+ label: 'Move to far right',
403
+ to: numRegions - 1,
404
+ },
405
+ ].flatMap(({ when, label, to }) => (when ? [{ label, to }] : []));
406
+ }
407
+ /**
408
+ * The region reorderings offered by the refName-label menu, as pure list
409
+ * transforms feeding setDisplayedRegions (which re-clamps bpPerPx/offsetPx for
410
+ * the new region set).
411
+ */
412
+ export function withRegionMoved(regions, from, to) {
413
+ const out = [...regions];
414
+ const [moved] = out.splice(from, 1);
415
+ out.splice(to, 0, moved);
416
+ return out;
417
+ }
418
+ export function withRegionRemoved(regions, index) {
419
+ return regions.filter((_, i) => i !== index);
420
+ }
421
+ export function withRegionReversed(regions, index) {
422
+ return regions.map((region, i) => i === index ? { ...region, reversed: !region.reversed } : region);
423
+ }
424
+ /**
425
+ * Whether a label occupying [leftPx, leftPx + labelWidth] fits within a block
426
+ * of the given pixel width, used to skip tick labels that would be clipped at a
427
+ * region edge (common with small collapsed-intron regions).
428
+ */
429
+ export function labelFitsInBlock(leftPx, labelWidth, widthPx) {
430
+ return leftPx >= 0 && leftPx + labelWidth <= widthPx;
431
+ }
432
+ /** Font size of coordinate tick labels on the scalebar and overview scalebar. */
433
+ export const TICK_LABEL_FONT_SIZE = 11;
434
+ /**
435
+ * On-screen width of a coordinate tick label: the text plus 2px of horizontal
436
+ * padding on each side. Single-sourced so the HTML scalebar and the SVG export
437
+ * agree on when a label is too wide to fit inside its block.
438
+ */
439
+ export function tickLabelWidth(label) {
440
+ return measureText(label, TICK_LABEL_FONT_SIZE) + 4;
441
+ }
442
+ /** Font size of the bold refName label drawn at the left edge of its block, on
443
+ * the scalebar and the overview scalebar alike. */
444
+ export const REF_NAME_LABEL_FONT_SIZE = 11;
445
+ /**
446
+ * measureText's width table is for the regular weight; refName labels are bold,
447
+ * which runs a few percent wider. Under-measuring here would clip the last glyph
448
+ * off a name that was judged to fit, so round up rather than down.
449
+ */
450
+ const BOLD_WIDTH_FACTOR = 1.05;
451
+ /** On-screen width of a bold refName label. */
452
+ function refNameLabelWidth(refName) {
453
+ return measureText(refName, REF_NAME_LABEL_FONT_SIZE) * BOLD_WIDTH_FACTOR;
454
+ }
455
+ /** Left inset of the overview refName label within its block. */
456
+ const REF_NAME_LABEL_INSET_PX = 3;
457
+ /**
458
+ * Horizontal space the overview refName label occupies at a block's left edge.
459
+ * Overview tick labels use this to avoid drawing underneath the refName, which
460
+ * otherwise collide when zoomed far out (ticks bunch up near the block start).
461
+ */
462
+ export function overviewRefNameLabelWidth(refName) {
463
+ return (REF_NAME_LABEL_INSET_PX +
464
+ refNameLabelWidth(refName) +
465
+ REF_NAME_LABEL_INSET_PX);
466
+ }
467
+ /**
468
+ * Breathing room between the chromosome name and the ideogram to its right, on
469
+ * top of the space the name itself needs.
470
+ */
471
+ const CYTOBAND_LABEL_GAP_PX = 9;
472
+ /**
473
+ * How far right the ideogram starts, i.e. the gutter the chromosome name drawn
474
+ * to its left gets to itself. Shares overviewRefNameLabelWidth with the tick
475
+ * labels that dodge the same name, rather than measuring it again at a font size
476
+ * (12) the label is not actually drawn at (REF_NAME_LABEL_FONT_SIZE).
477
+ */
478
+ export function cytobandLabelGutterWidth(refName) {
479
+ return overviewRefNameLabelWidth(refName) + CYTOBAND_LABEL_GAP_PX;
480
+ }
481
+ /**
482
+ * Coordinate labels drawn inside one overview-scalebar block: tick text plus its
483
+ * x within the block. Labels that can't be drawn whole between the block's bold
484
+ * refName label and its right edge are dropped by the same
485
+ * tickLabelWidth/labelFitsInBlock test the main scalebar and SVG export use; if
486
+ * too few survive to make a ruler, the block goes unnumbered.
487
+ */
488
+ export function makeOverviewTickLabels({ block, bpPerPx, refNameLabelPx, }) {
489
+ const { start, end, reversed, widthPx } = block;
490
+ const labels = makeOverviewTicks(start, end, bpPerPx, reversed).flatMap(({ genomicCoord, offsetPx }) => {
491
+ const label = getTickDisplayStr(genomicCoord, bpPerPx);
492
+ const fits = offsetPx >= refNameLabelPx &&
493
+ labelFitsInBlock(offsetPx, tickLabelWidth(label), widthPx);
494
+ return fits ? [{ genomicCoord, offsetPx, label }] : [];
495
+ });
496
+ return tickLabelsWorthDrawing(labels.length) ? labels : [];
497
+ }
498
+ export function groupContiguousBlocks(blocks) {
499
+ const runs = [];
500
+ let current;
501
+ let currentRegionIndex;
502
+ for (const block of blocks) {
503
+ if (block.type === 'ContentBlock') {
504
+ if (current !== undefined &&
505
+ currentRegionIndex === block.displayedRegionIndex) {
506
+ current.widthPx += block.widthPx;
507
+ current.start = Math.min(current.start, block.start);
508
+ current.end = Math.max(current.end, block.end);
509
+ }
510
+ else {
511
+ current = {
512
+ offsetPx: block.offsetPx,
513
+ widthPx: block.widthPx,
514
+ start: block.start,
515
+ end: block.end,
516
+ reversed: !!block.reversed,
517
+ refName: block.refName,
518
+ isLeftEndOfDisplayedRegion: !!block.isLeftEndOfDisplayedRegion,
519
+ };
520
+ currentRegionIndex = block.displayedRegionIndex;
521
+ runs.push(current);
522
+ }
523
+ }
524
+ else {
525
+ current = undefined;
526
+ currentRegionIndex = undefined;
527
+ }
528
+ }
529
+ return runs;
530
+ }
531
+ /**
532
+ * Horizontal space reserved at each run's left edge for the bold refName label
533
+ * drawn there, or 0 for runs that get none. Coordinate labels use this to stay
534
+ * out from under the name, the way the overview scalebar's already do via
535
+ * overviewRefNameLabelWidth: the refName label is opaque and painted after the
536
+ * numbers, so one underneath it isn't merely crowded but invisible — and since
537
+ * both sit in the block frame and scroll together, invisible at every scroll
538
+ * position rather than only while passing behind.
539
+ *
540
+ * Which runs get a label follows getScalebarRefNameLabels: only where a region
541
+ * genuinely begins, and only the first of a run of one refName (collapsed
542
+ * introns make many adjacent regions of the same name). It deliberately drops
543
+ * that function's offsetPx term so the reservation — and with it scalebarLabels
544
+ * — stays stable while scrolling; a run scrolled off the left reserves space
545
+ * that is off-screen anyway. Where the two disagree the reservation is the
546
+ * conservative side: at worst a coordinate is dropped from a region too narrow
547
+ * to have kept MIN_TICK_LABELS_PER_BLOCK of them.
548
+ *
549
+ * `orientation` enters because under `mixed` a reversed run's label carries the
550
+ * ` [rev]` marker and so is wider than its name. Under a uniformly `reversed`
551
+ * row only the sticky label is marked, and that one is dodged on screen instead
552
+ * (`refNameLabelSpanPx`), its x being a function of the scroll rather than of
553
+ * this frame.
554
+ */
555
+ export function runRefNameLabelPx(runs, orientation = 'forward') {
556
+ const isRunStart = showRefNameLabels(runs, run => run.refName);
557
+ return runs.map((run, i) => isRunStart[i] && run.isLeftEndOfDisplayedRegion
558
+ ? REF_NAME_LABEL_PADDING_PX +
559
+ refNameLabelWidth(orientation === 'mixed' && run.reversed
560
+ ? `${run.refName}${REV_MARKER}`
561
+ : run.refName)
562
+ : 0);
563
+ }
564
+ /**
565
+ * makeTicks plus each tick's pixel x within its block, accounting for reversed
566
+ * regions. Single source of the tick→px formula shared by gridlines, the
567
+ * scalebar coordinate labels, and SVG export so their positions can't drift.
568
+ */
569
+ export function makeBlockTicks({ start, end, reversed = false, }, bpPerPx, emitMajor = true, emitMinor = true) {
570
+ return makeTicks(start, end, bpPerPx, emitMajor, emitMinor).map(tick => ({
571
+ ...tick,
572
+ x: (reversed ? end - tick.base : tick.base - start) / bpPerPx,
573
+ }));
574
+ }
575
+ /**
576
+ * Generate location objects for a set of parsed locstrings, which includes
577
+ * translating the refNames to assembly-canonical refNames and adding the
578
+ * 'parentRegion'
579
+ *
580
+ * Used by navToLocations and navToLocString
581
+ *
582
+ * @param regions - array of parsed location strings to generate locations for
583
+ * @param assemblyManager - the assembly manager instance
584
+ * @param assemblyName - optional assembly name to use for regions that don't
585
+ * specify one
586
+ * @param grow - optional multiplier to expand regions by (e.g., 0.2 adds 20%
587
+ * padding on each side of the region). Useful for adding visual padding when
588
+ * navigating to a feature
589
+ */
61
590
  export async function generateLocations({ regions, assemblyManager, assemblyName, grow, }) {
62
591
  return Promise.all(regions.map(async (region) => {
63
592
  const asmName = region.assemblyName || assemblyName;
@@ -73,10 +602,13 @@ export async function generateLocations({ regions, assemblyManager, assemblyName
73
602
  if (!regions) {
74
603
  throw new Error(`regions not loaded yet for ${asmName}`);
75
604
  }
76
- const canonicalRefName = asm.getCanonicalRefName(region.refName);
605
+ const canonicalRefName = asm.getCanonicalRefName(refName);
77
606
  if (!canonicalRefName) {
78
607
  throw new Error(`Could not find refName ${refName} in ${asm.name}`);
79
608
  }
609
+ // scans rather than calling getRegionForRefName: this runs once per typed
610
+ // locstring, not per frame, and the assembly here is duck-typed by several
611
+ // navigation tests that would each have to grow the method
80
612
  const parentRegion = regions.find(r => r.refName === canonicalRefName);
81
613
  if (!parentRegion) {
82
614
  throw new Error(`Could not find refName ${refName} in ${asmName}`);
@@ -93,19 +625,39 @@ export async function generateLocations({ regions, assemblyManager, assemblyName
93
625
  };
94
626
  }));
95
627
  }
628
+ /**
629
+ * Parses locString or space separated set of locStrings into location objects
630
+ * Example inputs:
631
+ * "chr1"
632
+ * "chr1:1-100"
633
+ * "chr1:1..100"
634
+ * "chr1 chr2"
635
+ * "chr1:1-100 chr2:1-100"
636
+ * "chr1 100 200" equivalent to "chr1:100-200"
637
+ * "chr1:34M-35M" equivalent to "chr1:34000000-35000000"
638
+ *
639
+ * Used by navToLocString
640
+ */
96
641
  export function parseLocStrings(input, assemblyName, isValidRefName) {
97
642
  const inputs = input
98
643
  .split(/(\s+)/)
99
644
  .map(f => f.trim())
100
645
  .filter(f => !!f);
646
+ // first try interpreting as a whitespace-separated sequence of
647
+ // multiple locstrings
101
648
  try {
102
649
  return inputs.map(loc => parseLocString(loc, ref => isValidRefName(ref, assemblyName)));
103
650
  }
104
651
  catch (e) {
105
- const [refName, start, end] = inputs;
106
- if (/Unknown feature or sequence/.exec(`${e}`) &&
107
- Number.isInteger(+start) &&
108
- Number.isInteger(+end)) {
652
+ // if this fails, try interpreting as a whitespace-separated refname,
653
+ // start, end if start and end are base-pair quantities. The tokens are
654
+ // handed on verbatim rather than as the numbers they parsed to, so the
655
+ // shorthands parseLocString accepts ("34M", "1,000") mean the same thing
656
+ // in this form as in the colon form.
657
+ const [refName, start = '', end = ''] = inputs;
658
+ if (e instanceof UnknownRefNameError &&
659
+ parseBpString(start) !== undefined &&
660
+ parseBpString(end) !== undefined) {
109
661
  return [
110
662
  parseLocString(`${refName}:${start}..${end}`, ref => isValidRefName(ref, assemblyName)),
111
663
  ];
@@ -114,19 +666,11 @@ export function parseLocStrings(input, assemblyName, isValidRefName) {
114
666
  }
115
667
  }
116
668
  export function calculateVisibleLocStrings(contentBlocks) {
117
- if (!contentBlocks.length) {
118
- return '';
119
- }
120
- else {
121
- const isSingleAssemblyName = contentBlocks.every(b => b.assemblyName === contentBlocks[0].assemblyName);
122
- return contentBlocks
123
- .map(block => assembleLocString({
124
- refName: block.refName,
125
- start: Math.round(block.start),
126
- end: Math.round(block.end),
127
- assemblyName: isSingleAssemblyName ? undefined : block.assemblyName,
128
- reversed: block.reversed,
129
- }))
130
- .join(' ');
131
- }
669
+ return assembleLocStrings(contentBlocks.map(block => ({
670
+ refName: block.refName,
671
+ start: Math.round(block.start),
672
+ end: Math.round(block.end),
673
+ assemblyName: block.assemblyName,
674
+ reversed: block.reversed,
675
+ })));
132
676
  }