higlass 1.13.6 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/app/scripts/AddTrackDialog.jsx +8 -1
  2. package/app/scripts/AddTrackPositionMenu.jsx +26 -5
  3. package/app/scripts/Annotations1dTrack.js +90 -251
  4. package/app/scripts/Annotations2dTrack.js +9 -2
  5. package/app/scripts/Autocomplete.jsx +1 -9
  6. package/app/scripts/BedLikeTrack.js +549 -441
  7. package/app/scripts/ContextMenuContainer.jsx +3 -0
  8. package/app/scripts/ContextMenuItem.jsx +13 -2
  9. package/app/scripts/FilledLine.js +349 -0
  10. package/app/scripts/GenomePositionSearchBox.jsx +178 -477
  11. package/app/scripts/HiGlassComponent.jsx +443 -349
  12. package/app/scripts/HiGlassComponentContext.js +5 -0
  13. package/app/scripts/SeriesListMenu.jsx +94 -44
  14. package/app/scripts/SeriesListSubmenuMixin.jsx +1 -0
  15. package/app/scripts/Tiled1DPixiTrack.js +0 -1
  16. package/app/scripts/TiledPixiTrack.js +72 -63
  17. package/app/scripts/TiledPlot.jsx +530 -77
  18. package/app/scripts/TrackRenderer.jsx +2 -2
  19. package/app/scripts/ViewContextMenu.jsx +50 -2
  20. package/app/scripts/ViewHeader.jsx +3 -2
  21. package/app/scripts/api.js +87 -6
  22. package/app/scripts/configs/index.js +6 -1
  23. package/app/scripts/configs/primitives.js +2 -0
  24. package/app/scripts/configs/tracks-info.js +1 -0
  25. package/app/scripts/data-fetchers/genbank-fetcher.js +9 -14
  26. package/app/scripts/data-fetchers/local-tile-fetcher.js +8 -2
  27. package/app/scripts/hglib.jsx +61 -70
  28. package/app/scripts/options-info.js +49 -11
  29. package/app/scripts/services/tile-proxy.js +0 -4
  30. package/app/scripts/services/worker.js +1 -0
  31. package/app/scripts/test-helpers/index.js +2 -1
  32. package/app/scripts/test-helpers/test-helpers.jsx +154 -66
  33. package/app/scripts/types.ts +68 -3
  34. package/app/scripts/utils/copy-text-to-clipboard.js +36 -0
  35. package/app/scripts/utils/decompress.js +33 -0
  36. package/app/scripts/utils/default-tracks.js +46 -0
  37. package/app/scripts/utils/get-default-track-for-datatype.js +2 -1
  38. package/app/scripts/utils/get-default-tracks-for-datatype.ts +46 -0
  39. package/app/scripts/utils/index.js +1 -0
  40. package/app/scripts/utils/positioned-tracks-to-all-tracks.js +55 -0
  41. package/app/scripts/utils/show-mouse-position.js +0 -16
  42. package/app/scripts/utils/visit-positioned-tracks.js +4 -1
  43. package/app/styles/AddTrackPositionMenu.module.scss +37 -0
  44. package/app/styles/HiGlass.module.scss +3 -1
  45. package/app/styles/TiledPlot.module.scss +20 -0
  46. package/dist/app/schema.json +525 -0
  47. package/dist/app/scripts/AddTrackDialog.d.ts +64 -0
  48. package/dist/app/scripts/AddTrackPositionMenu.d.ts +5 -0
  49. package/dist/app/scripts/Annotations1dTrack.d.ts +15 -0
  50. package/dist/app/scripts/Annotations2dTrack.d.ts +95 -0
  51. package/dist/app/scripts/ArrowheadDomainsTrack.d.ts +36 -0
  52. package/dist/app/scripts/Autocomplete.d.ts +102 -0
  53. package/dist/app/scripts/AxisPixi.d.ts +25 -0
  54. package/dist/app/scripts/BarTrack.d.ts +28 -0
  55. package/dist/app/scripts/BedLikeTrack.d.ts +84 -0
  56. package/dist/app/scripts/Button.d.ts +3 -0
  57. package/dist/app/scripts/CNVIntervalTrack.d.ts +12 -0
  58. package/dist/app/scripts/CenterTiledPlot.d.ts +3 -0
  59. package/dist/app/scripts/CenterTrack.d.ts +92 -0
  60. package/dist/app/scripts/Chromosome2DAnnotations.d.ts +10 -0
  61. package/dist/app/scripts/Chromosome2DLabels.d.ts +13 -0
  62. package/dist/app/scripts/ChromosomeGrid.d.ts +24 -0
  63. package/dist/app/scripts/ChromosomeInfo.d.ts +14 -0
  64. package/dist/app/scripts/CloseTrackMenu.d.ts +10 -0
  65. package/dist/app/scripts/CombinedTrack.d.ts +32 -0
  66. package/dist/app/scripts/ConfigTrackMenu.d.ts +10 -0
  67. package/dist/app/scripts/ConfigViewMenu.d.ts +34 -0
  68. package/dist/app/scripts/ConfigureSeriesMenu.d.ts +3 -0
  69. package/dist/app/scripts/ContextMenuContainer.d.ts +36 -0
  70. package/dist/app/scripts/ContextMenuItem.d.ts +34 -0
  71. package/dist/app/scripts/Cross.d.ts +3 -0
  72. package/dist/app/scripts/CrossRule.d.ts +24 -0
  73. package/dist/app/scripts/CustomTrackDialog.d.ts +17 -0
  74. package/dist/app/scripts/Dialog.d.ts +5 -0
  75. package/dist/app/scripts/DivergentBarTrack.d.ts +4 -0
  76. package/dist/app/scripts/DragListeningDiv.d.ts +32 -0
  77. package/dist/app/scripts/DraggableDiv.d.ts +63 -0
  78. package/dist/app/scripts/ExportLinkDialog.d.ts +21 -0
  79. package/dist/app/scripts/FilledLine.d.ts +5 -0
  80. package/dist/app/scripts/FixedTrack.d.ts +5 -0
  81. package/dist/app/scripts/GalleryTracks.d.ts +20 -0
  82. package/dist/app/scripts/GenomePositionSearchBox.d.ts +95 -0
  83. package/dist/app/scripts/HeatmapOptions.d.ts +30 -0
  84. package/dist/app/scripts/HeatmapTiledPixiTrack.d.ts +184 -0
  85. package/dist/app/scripts/HiGlassComponent.d.ts +762 -0
  86. package/dist/app/scripts/HiGlassComponentContext.d.ts +3 -0
  87. package/dist/app/scripts/HiGlassTrackComponent.d.ts +37 -0
  88. package/dist/app/scripts/Horizontal1dHeatmapTrack.d.ts +9 -0
  89. package/dist/app/scripts/Horizontal2DDomainsTrack.d.ts +21 -0
  90. package/dist/app/scripts/HorizontalChromosomeLabels.d.ts +47 -0
  91. package/dist/app/scripts/HorizontalGeneAnnotationsTrack.d.ts +25 -0
  92. package/dist/app/scripts/HorizontalHeatmapTrack.d.ts +12 -0
  93. package/dist/app/scripts/HorizontalItem.d.ts +3 -0
  94. package/dist/app/scripts/HorizontalLine1DPixiTrack.d.ts +23 -0
  95. package/dist/app/scripts/HorizontalMultivecTrack.d.ts +50 -0
  96. package/dist/app/scripts/HorizontalPoint1DPixiTrack.d.ts +5 -0
  97. package/dist/app/scripts/HorizontalRule.d.ts +22 -0
  98. package/dist/app/scripts/HorizontalTiled1DPixiTrack.d.ts +26 -0
  99. package/dist/app/scripts/HorizontalTiledPlot.d.ts +49 -0
  100. package/dist/app/scripts/HorizontalTrack.d.ts +6 -0
  101. package/dist/app/scripts/Id2DTiledPixiTrack.d.ts +10 -0
  102. package/dist/app/scripts/IdHorizontal1DTiledPixiTrack.d.ts +6 -0
  103. package/dist/app/scripts/IdVertical1DTiledPixiTrack.d.ts +7 -0
  104. package/dist/app/scripts/LeftAxisTrack.d.ts +9 -0
  105. package/dist/app/scripts/LeftTrackModifier.d.ts +29 -0
  106. package/dist/app/scripts/ListWrapper.d.ts +64 -0
  107. package/dist/app/scripts/MapboxTilesTrack.d.ts +9 -0
  108. package/dist/app/scripts/Modal.d.ts +5 -0
  109. package/dist/app/scripts/MoveableTrack.d.ts +18 -0
  110. package/dist/app/scripts/NestedContextMenu.d.ts +7 -0
  111. package/dist/app/scripts/OSMTileIdsTrack.d.ts +5 -0
  112. package/dist/app/scripts/OSMTilesTrack.d.ts +129 -0
  113. package/dist/app/scripts/OverlayTrack.d.ts +13 -0
  114. package/dist/app/scripts/PixiTrack.d.ts +174 -0
  115. package/dist/app/scripts/PlotTypeChooser.d.ts +25 -0
  116. package/dist/app/scripts/PopupMenu.d.ts +28 -0
  117. package/dist/app/scripts/RasterTilesTrack.d.ts +9 -0
  118. package/dist/app/scripts/RuleMixin.d.ts +2 -0
  119. package/dist/app/scripts/SVGTrack.d.ts +15 -0
  120. package/dist/app/scripts/SearchField.d.ts +13 -0
  121. package/dist/app/scripts/SeriesListItems.d.ts +2 -0
  122. package/dist/app/scripts/SeriesListMenu.d.ts +51 -0
  123. package/dist/app/scripts/SeriesListSubmenuMixin.d.ts +2 -0
  124. package/dist/app/scripts/SketchInlinePicker.d.ts +25 -0
  125. package/dist/app/scripts/SortableList.d.ts +22 -0
  126. package/dist/app/scripts/SquareMarkersTrack.d.ts +22 -0
  127. package/dist/app/scripts/Tiled1DPixiTrack.d.ts +60 -0
  128. package/dist/app/scripts/TiledPixiTrack.d.ts +369 -0
  129. package/dist/app/scripts/TiledPlot.d.ts +313 -0
  130. package/dist/app/scripts/TilesetFinder.d.ts +65 -0
  131. package/dist/app/scripts/TopAxisTrack.d.ts +9 -0
  132. package/dist/app/scripts/Track.d.ts +196 -0
  133. package/dist/app/scripts/TrackArea.d.ts +26 -0
  134. package/dist/app/scripts/TrackControl.d.ts +5 -0
  135. package/dist/app/scripts/TrackRenderer.d.ts +724 -0
  136. package/dist/app/scripts/UnknownPixiTrack.d.ts +7 -0
  137. package/dist/app/scripts/ValueIntervalTrack.d.ts +6 -0
  138. package/dist/app/scripts/VerticalItem.d.ts +3 -0
  139. package/dist/app/scripts/VerticalRule.d.ts +21 -0
  140. package/dist/app/scripts/VerticalTiled1DPixiTrack.d.ts +6 -0
  141. package/dist/app/scripts/VerticalTiledPlot.d.ts +50 -0
  142. package/dist/app/scripts/VerticalTrack.d.ts +6 -0
  143. package/dist/app/scripts/ViewConfigEditor.d.ts +53 -0
  144. package/dist/app/scripts/ViewContextMenu.d.ts +17 -0
  145. package/dist/app/scripts/ViewHeader.d.ts +75 -0
  146. package/dist/app/scripts/ViewportTracker2D.d.ts +17 -0
  147. package/dist/app/scripts/ViewportTracker2DPixi.d.ts +11 -0
  148. package/dist/app/scripts/ViewportTrackerHorizontal.d.ts +17 -0
  149. package/dist/app/scripts/ViewportTrackerVertical.d.ts +17 -0
  150. package/dist/app/scripts/api.d.ts +640 -0
  151. package/dist/app/scripts/configs/available-track-types.d.ts +2 -0
  152. package/dist/app/scripts/configs/colormaps.d.ts +2 -0
  153. package/dist/app/scripts/configs/datatype-to-track-type.d.ts +4 -0
  154. package/dist/app/scripts/configs/default-tracks-for-datatype.d.ts +38 -0
  155. package/dist/app/scripts/configs/dense-data-extrema-config.d.ts +2 -0
  156. package/dist/app/scripts/configs/globals.d.ts +5 -0
  157. package/dist/app/scripts/configs/index.d.ts +16 -0
  158. package/dist/app/scripts/configs/positions-by-datatype.d.ts +2 -0
  159. package/dist/app/scripts/configs/primitives.d.ts +20 -0
  160. package/dist/app/scripts/configs/themes.d.ts +3 -0
  161. package/dist/app/scripts/configs/tracks-info-by-type.d.ts +4 -0
  162. package/dist/app/scripts/configs/tracks-info.d.ts +24 -0
  163. package/dist/app/scripts/d3-context-menu.d.ts +2 -0
  164. package/dist/app/scripts/data-fetchers/DataFetcher.d.ts +151 -0
  165. package/dist/app/scripts/data-fetchers/genbank-fetcher.d.ts +86 -0
  166. package/dist/app/scripts/data-fetchers/index.d.ts +3 -0
  167. package/dist/app/scripts/data-fetchers/local-tile-fetcher.d.ts +47 -0
  168. package/dist/app/scripts/gosling-exports.d.ts +17 -0
  169. package/dist/app/scripts/hglib.d.ts +24 -0
  170. package/dist/app/scripts/hocs/with-modal.d.ts +19 -0
  171. package/dist/app/scripts/hocs/with-pub-sub.d.ts +22 -0
  172. package/dist/app/scripts/hocs/with-theme.d.ts +13 -0
  173. package/dist/app/scripts/icons.d.ts +161 -0
  174. package/dist/app/scripts/mixwith.d.ts +27 -0
  175. package/dist/app/scripts/options-info.d.ts +1355 -0
  176. package/dist/app/scripts/plugins/available-for-plugins.d.ts +2338 -0
  177. package/dist/app/scripts/plugins/get-data-fetcher.d.ts +2 -0
  178. package/dist/app/scripts/plugins/index.d.ts +2 -0
  179. package/dist/app/scripts/services/chrom-info.d.ts +10 -0
  180. package/dist/app/scripts/services/dom-event.d.ts +7 -0
  181. package/dist/app/scripts/services/element-resize-listener.d.ts +5 -0
  182. package/dist/app/scripts/services/index.d.ts +5 -0
  183. package/dist/app/scripts/services/tile-proxy.d.ts +180 -0
  184. package/dist/app/scripts/services/worker.d.ts +157 -0
  185. package/dist/app/scripts/symbol.d.ts +13 -0
  186. package/dist/app/scripts/test-helpers/index.d.ts +1 -0
  187. package/dist/app/scripts/test-helpers/test-helpers.d.ts +33 -0
  188. package/dist/app/scripts/track-utils.d.ts +73 -0
  189. package/dist/app/scripts/types.d.ts +199 -0
  190. package/dist/app/scripts/utils/DenseDataExtrema1D.d.ts +88 -0
  191. package/dist/app/scripts/utils/DenseDataExtrema2D.d.ts +97 -0
  192. package/dist/app/scripts/utils/LruCache.d.ts +44 -0
  193. package/dist/app/scripts/utils/abs-to-chr.d.ts +14 -0
  194. package/dist/app/scripts/utils/accessor-transposition.d.ts +14 -0
  195. package/dist/app/scripts/utils/add-arrays.d.ts +18 -0
  196. package/dist/app/scripts/utils/add-class.d.ts +8 -0
  197. package/dist/app/scripts/utils/add-event-listener-once.d.ts +11 -0
  198. package/dist/app/scripts/utils/assert.d.ts +17 -0
  199. package/dist/app/scripts/utils/background-task-scheduler.d.ts +47 -0
  200. package/dist/app/scripts/utils/base64-to-canvas.d.ts +9 -0
  201. package/dist/app/scripts/utils/chr-to-abs.d.ts +10 -0
  202. package/dist/app/scripts/utils/chrom-info-bisector.d.ts +4 -0
  203. package/dist/app/scripts/utils/clone-event.d.ts +12 -0
  204. package/dist/app/scripts/utils/color-domain-to-rgba-array.d.ts +13 -0
  205. package/dist/app/scripts/utils/color-to-hex.d.ts +9 -0
  206. package/dist/app/scripts/utils/color-to-rgba.d.ts +9 -0
  207. package/dist/app/scripts/utils/copy-text-to-clipboard.d.ts +2 -0
  208. package/dist/app/scripts/utils/data-to-genomic-loci.d.ts +11 -0
  209. package/dist/app/scripts/utils/debounce.d.ts +5 -0
  210. package/dist/app/scripts/utils/dec-to-hex-str.d.ts +8 -0
  211. package/dist/app/scripts/utils/decompress.d.ts +27 -0
  212. package/dist/app/scripts/utils/default-tracks.d.ts +3 -0
  213. package/dist/app/scripts/utils/dict-from-tuples.d.ts +11 -0
  214. package/dist/app/scripts/utils/dict-items.d.ts +18 -0
  215. package/dist/app/scripts/utils/dict-keys.d.ts +10 -0
  216. package/dist/app/scripts/utils/dict-values.d.ts +8 -0
  217. package/dist/app/scripts/utils/download.d.ts +7 -0
  218. package/dist/app/scripts/utils/expand-combined-tracks.d.ts +11 -0
  219. package/dist/app/scripts/utils/fake-pub-sub.d.ts +11 -0
  220. package/dist/app/scripts/utils/fill-in-min-widths.d.ts +44 -0
  221. package/dist/app/scripts/utils/flatten.d.ts +9 -0
  222. package/dist/app/scripts/utils/for-each.d.ts +9 -0
  223. package/dist/app/scripts/utils/forward-event.d.ts +7 -0
  224. package/dist/app/scripts/utils/genome-loci-to-pixels.d.ts +9 -0
  225. package/dist/app/scripts/utils/genomic-range-to-chromosome-chunks.d.ts +21 -0
  226. package/dist/app/scripts/utils/get-aggregation-function.d.ts +10 -0
  227. package/dist/app/scripts/utils/get-default-track-for-datatype.d.ts +21 -0
  228. package/dist/app/scripts/utils/get-default-tracks-for-datatype.d.ts +3 -0
  229. package/dist/app/scripts/utils/get-element-dim.d.ts +7 -0
  230. package/dist/app/scripts/utils/get-higlass-components.d.ts +7 -0
  231. package/dist/app/scripts/utils/get-track-by-uid.d.ts +7 -0
  232. package/dist/app/scripts/utils/get-track-conf-from-hgc.d.ts +10 -0
  233. package/dist/app/scripts/utils/get-track-obj-by-id.d.ts +2 -0
  234. package/dist/app/scripts/utils/get-track-position-by-uid.d.ts +13 -0
  235. package/dist/app/scripts/utils/get-xylofon.d.ts +2 -0
  236. package/dist/app/scripts/utils/gradient.d.ts +14 -0
  237. package/dist/app/scripts/utils/has-class.d.ts +8 -0
  238. package/dist/app/scripts/utils/has-parent.d.ts +9 -0
  239. package/dist/app/scripts/utils/hex-string-to-int.d.ts +14 -0
  240. package/dist/app/scripts/utils/index.d.ts +89 -0
  241. package/dist/app/scripts/utils/interval-tree.d.ts +109 -0
  242. package/dist/app/scripts/utils/into-the-void.d.ts +6 -0
  243. package/dist/app/scripts/utils/is-track-or-child-track.d.ts +7 -0
  244. package/dist/app/scripts/utils/is-track-range-selectable.d.ts +2 -0
  245. package/dist/app/scripts/utils/is-within.d.ts +12 -0
  246. package/dist/app/scripts/utils/lat-to-y.d.ts +9 -0
  247. package/dist/app/scripts/utils/lng-to-x.d.ts +8 -0
  248. package/dist/app/scripts/utils/load-chrom-infos.d.ts +8 -0
  249. package/dist/app/scripts/utils/map.d.ts +13 -0
  250. package/dist/app/scripts/utils/max-non-zero.d.ts +6 -0
  251. package/dist/app/scripts/utils/max.d.ts +10 -0
  252. package/dist/app/scripts/utils/min-non-zero.d.ts +6 -0
  253. package/dist/app/scripts/utils/min.d.ts +10 -0
  254. package/dist/app/scripts/utils/mod.d.ts +9 -0
  255. package/dist/app/scripts/utils/ndarray-assign.d.ts +2 -0
  256. package/dist/app/scripts/utils/ndarray-flatten.d.ts +2 -0
  257. package/dist/app/scripts/utils/ndarray-to-list.d.ts +2 -0
  258. package/dist/app/scripts/utils/numericify-version.d.ts +6 -0
  259. package/dist/app/scripts/utils/obj-vals.d.ts +8 -0
  260. package/dist/app/scripts/utils/or.d.ts +8 -0
  261. package/dist/app/scripts/utils/parse-chromsizes-rows.d.ts +34 -0
  262. package/dist/app/scripts/utils/pixi-text-to-svg.d.ts +2 -0
  263. package/dist/app/scripts/utils/positioned-tracks-to-all-tracks.d.ts +26 -0
  264. package/dist/app/scripts/utils/q.d.ts +18 -0
  265. package/dist/app/scripts/utils/rad-to-deg.d.ts +7 -0
  266. package/dist/app/scripts/utils/range-query-2d.d.ts +17 -0
  267. package/dist/app/scripts/utils/reduce.d.ts +14 -0
  268. package/dist/app/scripts/utils/rel-to-abs-chrom-pos.d.ts +10 -0
  269. package/dist/app/scripts/utils/remove-class.d.ts +7 -0
  270. package/dist/app/scripts/utils/reset-d3-brush-style.d.ts +10 -0
  271. package/dist/app/scripts/utils/rgb-to-hex.d.ts +8 -0
  272. package/dist/app/scripts/utils/scales-center-and-k.d.ts +12 -0
  273. package/dist/app/scripts/utils/scales-to-genome-loci.d.ts +3 -0
  274. package/dist/app/scripts/utils/segments-to-rows.d.ts +15 -0
  275. package/dist/app/scripts/utils/selected-items-to-cum-weights.d.ts +12 -0
  276. package/dist/app/scripts/utils/selected-items-to-size.d.ts +13 -0
  277. package/dist/app/scripts/utils/show-mouse-position.d.ts +54 -0
  278. package/dist/app/scripts/utils/some.d.ts +10 -0
  279. package/dist/app/scripts/utils/sum.d.ts +8 -0
  280. package/dist/app/scripts/utils/svg-line.d.ts +2 -0
  281. package/dist/app/scripts/utils/throttle-and-debounce.d.ts +33 -0
  282. package/dist/app/scripts/utils/tile-to-canvas.d.ts +9 -0
  283. package/dist/app/scripts/utils/timeout.d.ts +3 -0
  284. package/dist/app/scripts/utils/to-void.d.ts +3 -0
  285. package/dist/app/scripts/utils/total-track-pixel-height.d.ts +27 -0
  286. package/dist/app/scripts/utils/trim-trailing-slash.d.ts +7 -0
  287. package/dist/app/scripts/utils/type-guards.d.ts +36 -0
  288. package/dist/app/scripts/utils/value-to-color.d.ts +12 -0
  289. package/dist/app/scripts/utils/visit-positioned-tracks.d.ts +18 -0
  290. package/dist/app/scripts/utils/visit-tracks.d.ts +9 -0
  291. package/dist/esm.html +1 -3
  292. package/dist/hglib.js +65302 -79868
  293. package/dist/hglib.min.js +104 -112
  294. package/dist/higlass.mjs +64214 -78780
  295. package/dist/index.html +1 -3
  296. package/dist/package.json +134 -0
  297. package/package.json +13 -10
@@ -1,8 +1,4 @@
1
1
  // @ts-nocheck
2
- // A better position of this file would be under \configs,
3
- // but this file imports HeatmapOptions that contains React
4
- // components, so having this file near track implementations
5
-
6
2
  import { formatPrefix, precisionPrefix } from 'd3-format';
7
3
 
8
4
  import HeatmapOptions from './HeatmapOptions';
@@ -52,7 +48,7 @@ const SPECIAL_COLORS = {
52
48
  use_stroke: { name: 'Glyph color', value: '[glyph-color]' },
53
49
  };
54
50
 
55
- const AVAILABLE_WIDTHS = sizesInPx([1, 2, 3, 5, 8, 13, 21]);
51
+ const AVAILABLE_WIDTHS = sizesInPx([0, 1, 2, 3, 5, 8, 13, 21]);
56
52
  const AVAILABLE_WIDTHS_AND_NONE = Object.assign(AVAILABLE_WIDTHS, {
57
53
  none: { name: 'none', value: 'none' },
58
54
  });
@@ -64,7 +60,7 @@ const OPACITY_OPTIONS_NO_ZERO = sizesInPx([0.2, 0.4, 0.6, 0.8, 1.0], '%', 100);
64
60
 
65
61
  // these values define the options that are visible in the track config
66
62
  // menu
67
- const OPTIONS_INFO = {
63
+ export const OPTIONS_INFO = {
68
64
  axisLabelFormatting: {
69
65
  name: 'Axis Label Formatting',
70
66
  inlineOptions: {
@@ -136,9 +132,34 @@ const OPTIONS_INFO = {
136
132
  name: 'Stroke Width',
137
133
  inlineOptions: AVAILABLE_WIDTHS,
138
134
  },
139
- strokeWidth: {
135
+ strokeSingleSeries: {
136
+ name: 'Draw single series',
137
+ generateOptions: (track) => {
138
+ const inlineOptions = [];
139
+
140
+ if (track.row_infos) {
141
+ for (let i = 0; i < track.row_infos.length; i++) {
142
+ inlineOptions.push({
143
+ name: i + 1,
144
+ value: i + 1,
145
+ });
146
+ }
147
+ }
148
+
149
+ inlineOptions.push({
150
+ name: 'All',
151
+ value: 'all',
152
+ });
153
+ inlineOptions.push({
154
+ name: 'None',
155
+ value: 'none',
156
+ });
157
+ return inlineOptions;
158
+ },
159
+ },
160
+ strokeWidthAndNone: {
140
161
  name: 'Stroke Width',
141
- inlineOptions: AVAILABLE_WIDTHS,
162
+ inlineOptions: AVAILABLE_WIDTHS_AND_NONE,
142
163
  },
143
164
  trackBorderWidth: {
144
165
  name: 'Track Border Width',
@@ -286,6 +307,10 @@ const OPTIONS_INFO = {
286
307
  name: 'Bar opacity',
287
308
  inlineOptions: OPACITY_OPTIONS,
288
309
  },
310
+ viewNameOpacity: {
311
+ name: 'View name opacity',
312
+ inlineOptions: OPACITY_OPTIONS,
313
+ },
289
314
  zeroLineVisible: {
290
315
  name: 'Zero line visible',
291
316
  inlineOptions: YES_NO,
@@ -418,7 +443,10 @@ const OPTIONS_INFO = {
418
443
  name: 'Show Tooltip',
419
444
  inlineOptions: YES_NO,
420
445
  },
421
-
446
+ nanAsZero: {
447
+ name: 'NaN as Zero',
448
+ inlineOptions: YES_NO,
449
+ },
422
450
  fontSize: {
423
451
  name: 'Font Size',
424
452
  inlineOptions: sizesInPx([8, 9, 10, 11, 12, 14, 16, 18, 24], 'px'),
@@ -542,8 +570,12 @@ const OPTIONS_INFO = {
542
570
  labelPosition: {
543
571
  name: 'Label Position',
544
572
  inlineOptions: {
573
+ l: { name: 'Left', value: 'left' },
574
+ r: { name: 'Right', value: 'right' },
545
575
  ol: { name: 'Outer left', value: 'outerLeft' },
546
576
  or: { name: 'Outer right', value: 'outerRight' },
577
+ t: { name: 'Top', value: 'top' },
578
+ b: { name: 'Bottom', value: 'bottom' },
547
579
  ot: { name: 'Outer top', value: 'outerTop' },
548
580
  ob: { name: 'Outer bottom', value: 'outerBottom' },
549
581
  tl: { name: 'Top left', value: 'topLeft' },
@@ -1305,10 +1337,16 @@ const OPTIONS_INFO = {
1305
1337
 
1306
1338
  if (track.aggregationModes) {
1307
1339
  Object.values(track.aggregationModes).forEach(({ name, value }) => {
1308
- inlineOptions.push({ name, value });
1340
+ inlineOptions.push({
1341
+ name,
1342
+ value,
1343
+ });
1309
1344
  });
1310
1345
  } else {
1311
- inlineOptions.push({ name: 'Default', value: 'default' });
1346
+ inlineOptions.push({
1347
+ name: 'Default',
1348
+ value: 'default',
1349
+ });
1312
1350
  }
1313
1351
 
1314
1352
  return inlineOptions;
@@ -777,10 +777,6 @@ function text(url, callback, pubSub) {
777
777
  * @param {import("pub-sub-es").PubSub} pubSub
778
778
  */
779
779
  async function json(url, callback, pubSub) {
780
- // Fritz: What is going on here? Can someone explain?
781
- if (url.indexOf('hg19') >= 0) {
782
- await sleep(1);
783
- }
784
780
  return fetchEither(url, callback, 'json', pubSub);
785
781
  }
786
782
 
@@ -381,6 +381,7 @@ function uint16ArrayToFloat32Array(uint16array) {
381
381
  /**
382
382
  * @typedef TileResponse
383
383
  * @property {string} [dense] - a base64 encoded string
384
+ * @property {string} [tilePositionId] - The position of the tile
384
385
  */
385
386
 
386
387
  /**
@@ -1,9 +1,10 @@
1
- // @ts-nocheck
2
1
  export {
3
2
  changeOptions,
4
3
  waitForJsonComplete,
5
4
  waitForTilesLoaded,
6
5
  waitForTransitionsFinished,
6
+ waitForScalesStabilized,
7
+ waitForComponentReady,
7
8
  mountHGComponent,
8
9
  mountHGComponentAsync,
9
10
  removeHGComponent,
@@ -1,4 +1,3 @@
1
- // @ts-nocheck
2
1
  import React from 'react';
3
2
  import ReactDOM from 'react-dom';
4
3
 
@@ -14,11 +13,12 @@ const TILE_LOADING_CHECK_INTERVAL = 100;
14
13
 
15
14
  /**
16
15
  * Change the options of a track in higlass
17
- * @param hgc enzyme wrapper for a HiGlassComponent
18
- * @param viewUid The view uid
19
- * @param trackUid The track uid
20
- * @param options An object of new options (e.g. { color: 'black'})
21
- * @return nothing
16
+ *
17
+ * @param {import("enzyme").ReactWrapper<{}, {}, HiGlassComponent>} hgc - Enzyme wrapper for a HiGlassComponent
18
+ * @param {string} viewUid - The view uid
19
+ * @param {string} trackUid - The track uid
20
+ * @param {Record<string, unknown>} options - An object of new options (e.g. { color: 'black'})
21
+ * @returns {void}
22
22
  */
23
23
  export const changeOptions = (hgc, viewUid, trackUid, options) => {
24
24
  for (const { viewId, trackId, track } of hgc.instance().iterateOverTracks()) {
@@ -34,40 +34,77 @@ export const changeOptions = (hgc, viewUid, trackUid, options) => {
34
34
  };
35
35
 
36
36
  /**
37
- * Check if there are any active transitions that we
38
- * need to wait on
37
+ * Check if there are any active transitions that we need to wait on.
39
38
  *
40
- * Parameters
41
- * ----------
42
- * hgc: enzyme wrapper for a HiGlassComponent
39
+ * @param {HiGlassComponent} hgc
43
40
  *
44
- * Returns
45
- * -------
46
- * True if any of the tracks have active transtions. False otherwise.
41
+ * @returns {boolean} Whether any of the tracks have active transtions.
47
42
  */
48
43
  export const areTransitionsActive = (hgc) => {
49
44
  for (const track of hgc.iterateOverTracks()) {
50
- const trackRenderer = getTrackRenderer(hgc, track.viewId, track.trackId);
45
+ const trackRenderer = getTrackRenderer(hgc, track.viewId);
51
46
 
52
- if (trackRenderer.activeTransitions > 0) return true;
47
+ if (trackRenderer?.activeTransitions) return true;
53
48
  }
54
49
  return false;
55
50
  };
56
51
 
57
52
  /**
58
- * Wait until all transitions have finished before
59
- * calling the callback
53
+ * Waits for multiple elements to appear in the DOM.
54
+ *
55
+ * @param {HTMLElement} parent - The parent element to search within.
56
+ * @param {string[]} selectors - An array of CSS selectors for the elements to wait for.
57
+ * @returns {Promise<Array<HTMLElement>>}
58
+ */
59
+ const waitForElements = (parent, selectors) => {
60
+ const foundElements = new Map();
61
+ /** @type {PromiseWithResolvers<Array<HTMLElement>>} */
62
+ const { promise, resolve } = Promise.withResolvers();
63
+
64
+ const observer = new MutationObserver((mutations, obs) => {
65
+ selectors.forEach((selector) => {
66
+ if (!foundElements.has(selector)) {
67
+ const element = parent.querySelector(selector);
68
+ if (element) {
69
+ foundElements.set(selector, element);
70
+ }
71
+ }
72
+ });
73
+
74
+ // If all elements are found, trigger the callback and disconnect
75
+ if (foundElements.size === selectors.length) {
76
+ resolve([...foundElements.values()]); // Pass all elements to the callback
77
+ obs.disconnect();
78
+ }
79
+ });
80
+
81
+ observer.observe(parent, {
82
+ childList: true,
83
+ subtree: true,
84
+ });
85
+
86
+ // Initial check in case elements are already present
87
+ selectors.forEach((selector) => {
88
+ const element = parent.querySelector(selector);
89
+ if (element) {
90
+ foundElements.set(selector, element);
91
+ }
92
+ });
93
+
94
+ if (foundElements.size === selectors.length) {
95
+ resolve([...foundElements.values()]);
96
+ observer.disconnect();
97
+ }
98
+
99
+ return promise;
100
+ };
101
+
102
+ /**
103
+ * Wait until all transitions have finished before calling the callback
60
104
  *
61
- * Arguments
62
- * ---------
63
- * hgc: Enzyme wrapper for a HiGlassComponent
64
- * The componentthat we're waiting on
65
- * tilesLoadedCallback: function
66
- * The callback to call whenever all of the tiles
67
- * have been loaded.
68
- * Returns
69
- * -------
70
- * Nothing
105
+ * @param {HiGlassComponent} hgc
106
+ * @param {() => void} callback A callback to invoke when all tiles have been loaded.
107
+ * @returns {void}
71
108
  */
72
109
  export const waitForTransitionsFinished = (hgc, callback) => {
73
110
  if (areTransitionsActive(hgc)) {
@@ -82,12 +119,8 @@ export const waitForTransitionsFinished = (hgc, callback) => {
82
119
  /**
83
120
  * Wait until all open JSON requests are finished
84
121
  *
85
- * Parameters
86
- * ----------
87
- * finished: function
88
- * A callback to call when there's no more JSON requests
89
- * open
90
- *
122
+ * @param {() => void} finished - A callback to invoke when there's no more JSON requests open.
123
+ * @returns {void}
91
124
  */
92
125
  export const waitForJsonComplete = (finished) => {
93
126
  if (requestsInFlight > 0) {
@@ -101,16 +134,11 @@ export const waitForJsonComplete = (finished) => {
101
134
  };
102
135
 
103
136
  /**
104
- * Check if a HiGlassComponent is still waiting on tiles from a remote
105
- * server.
137
+ * Check if a HiGlassComponent is still waiting on tiles from a remote server.
106
138
  *
107
- * Arguments
108
- * ---------
109
- * hgc: enzyme wrapper for a HiGlassComponent
139
+ * @param {HiGlassComponent} hgc
140
+ * @returns {boolean} Whether any of the tracks are wating for tiles.
110
141
  *
111
- * Returns
112
- * -------
113
- * True if any of the tracks are waiting for tiles, false otherwise.
114
142
  */
115
143
  export const isWaitingOnTiles = (hgc) => {
116
144
  for (const track of hgc.iterateOverTracks()) {
@@ -119,22 +147,23 @@ export const isWaitingOnTiles = (hgc) => {
119
147
  if (
120
148
  !track.track.server &&
121
149
  !track.track.tilesetUid &&
122
- !(track.track.data && track.track.data.type === 'divided')
150
+ !(track.track.data && track.track.data.type === 'divided') &&
151
+ !(track.track.data && track.track.data.type === 'local-tiles')
123
152
  ) {
124
153
  continue;
125
154
  }
126
155
  if (
127
156
  (track.track.data && track.track.data.type === 'divided') ||
128
- (track.track.server && track.track.tilesetUid)
157
+ (track.track.server && track.track.tilesetUid) ||
158
+ (track.track.data && track.track.data.type === 'local-tiles')
129
159
  ) {
160
+ if (!trackObj) return true;
161
+
130
162
  if (trackObj.originalTrack) {
131
163
  trackObj = trackObj.originalTrack;
132
164
  }
133
165
 
134
166
  if (!(trackObj.tilesetInfo || trackObj.chromInfo)) {
135
- // console.warn(
136
- // `Track uuid:${trackObj.uuid} has no tileset or chromosome info`
137
- // );
138
167
  return true;
139
168
  }
140
169
 
@@ -149,22 +178,14 @@ export const isWaitingOnTiles = (hgc) => {
149
178
  return false;
150
179
  };
151
180
 
181
+ /**
182
+ * Wait until all of the tiles in the HiGlassComponent are loaded until calling the callback
183
+ *
184
+ * @param {HiGlassComponent} hgc
185
+ * @param {(value?: unknown) => void} tilesLoadedCallback A callback to invoke whenever all of the tiles have been loaded.
186
+ * @returns {void}
187
+ */
152
188
  export const waitForTilesLoaded = (hgc, tilesLoadedCallback) => {
153
- /**
154
- * Wait until all of the tiles in the HiGlassComponent are loaded
155
- * until calling the callback
156
- *
157
- * Arguments
158
- * ---------
159
- * hgc: Enzyme wrapper for a HiGlassComponent
160
- * The componentthat we're waiting on
161
- * tilesLoadedCallback: function
162
- * The callback to call whenever all of the tiles
163
- * have been loaded.
164
- * Returns
165
- * -------
166
- * Nothing
167
- */
168
189
  if (isWaitingOnTiles(hgc)) {
169
190
  setTimeout(() => {
170
191
  waitForTilesLoaded(hgc, tilesLoadedCallback);
@@ -178,10 +199,11 @@ export const waitForTilesLoaded = (hgc, tilesLoadedCallback) => {
178
199
  /**
179
200
  * Mount a new HiGlassComponent and unmount the previously visible one.
180
201
  *
181
- * @param {HTMLElement | null} prevDiv A div element to detach and recreate for the component
182
- * @param {import('enzyme').ReactWrapper | null} prevHgc An already mounted
183
- * hgc component
184
- * @param {function} done The callback to call when the component is fully loaded
202
+ * @param {HTMLDivElement | null} prevDiv - A div element to detach and recreate for the component
203
+ * @param {import("enzyme").ReactWrapper<{}, {}, HiGlassComponent> | null} prevHgc
204
+ * @param {Record<string, unknown>} viewConf
205
+ * @param {(value?: unknown) => void} done - The callback to call when the component is fully loaded
206
+ * @param {{ style?: string, bounded?: boolean, extendedDelay?: boolean }} [options]
185
207
  */
186
208
  export const mountHGComponent = (
187
209
  prevDiv,
@@ -214,6 +236,7 @@ export const mountHGComponent = (
214
236
  div.setAttribute('style', style);
215
237
  div.setAttribute('id', 'simple-hg-component');
216
238
 
239
+ /** @type {import("enzyme").ReactWrapper<{}, {}, HiGlassComponent>} */
217
240
  const hgc = mount(
218
241
  <HiGlassComponent options={{ bounded }} viewConfig={viewConf} />,
219
242
  { attachTo: div },
@@ -241,6 +264,62 @@ export const mountHGComponent = (
241
264
  return /** @type {const} */ ([div, hgc]);
242
265
  };
243
266
 
267
+ /** Wait for scales to stop changing.
268
+ *
269
+ * @param {HiGlassComponent} hgc
270
+ * @param {string} viewUid
271
+ * @param {Object} options
272
+ * @param {number} [options.initialWait] - The interval (in milliseconds) that is waited before the first size check.
273
+ * @param {number} [options.timeInterval] - The interval (in milliseconds) between size checks.
274
+ * @param {number} [options.maxTime] - The maximum time (in milliseconds) to wait for stabilization.
275
+ * @returns {Promise<void>}
276
+ */
277
+ export const waitForScalesStabilized = async (hgc, viewUid, options) => {
278
+ const { initialWait = 500, timeInterval = 100, maxTime = 3000 } = options;
279
+ const xScaleDomain = [0, 0];
280
+ const yScaleDomain = [0, 0];
281
+
282
+ await new Promise((r) => setTimeout(r, initialWait));
283
+
284
+ for (let i = 0; i < maxTime; i += timeInterval) {
285
+ const xScale = hgc.xScales[viewUid];
286
+ const yScale = hgc.yScales[viewUid];
287
+
288
+ if (
289
+ xScaleDomain[0] !== xScale.domain()[0] ||
290
+ xScaleDomain[1] !== xScale.domain()[1] ||
291
+ yScaleDomain[0] !== yScale.domain()[0] ||
292
+ yScaleDomain[1] !== yScale.domain()[1]
293
+ ) {
294
+ xScaleDomain[0] = xScale.domain()[0];
295
+ xScaleDomain[1] = xScale.domain()[1];
296
+ yScaleDomain[0] = yScale.domain()[0];
297
+ yScaleDomain[1] = yScale.domain()[1];
298
+ } else {
299
+ return;
300
+ }
301
+
302
+ await new Promise((r) => setTimeout(r, timeInterval));
303
+ }
304
+ };
305
+
306
+ /**
307
+ * Wait for a HiGlassComponet to be ready at the given element.
308
+ *
309
+ * By ready we mean that a track-renderer-div is present and that its
310
+ * size is not changing any more.
311
+ *
312
+ * @param {HTMLElement} div
313
+ * @returns {Promise<void>}
314
+ */
315
+ export const waitForComponentReady = async (div) => {
316
+ await waitForElements(div, ['.track-renderer-div']);
317
+ };
318
+
319
+ /**
320
+ * @param {HTMLDivElement} div
321
+ * @returns {void}
322
+ */
244
323
  export const removeHGComponent = (div) => {
245
324
  if (!div) return;
246
325
 
@@ -250,15 +329,24 @@ export const removeHGComponent = (div) => {
250
329
 
251
330
  // ideally the "await-ers" avoid would be promises (rather than polling)
252
331
  // and that way `mountHGComponent` would be async by default.
332
+ /**
333
+ * @param {HTMLDivElement | null} prevDiv
334
+ * @param {import("enzyme").ReactWrapper<{}, {}, HiGlassComponent> | null} prevHgc
335
+ * @param {Record<string, unknown>} viewConf
336
+ * @param {{ style?: string, bounded?: boolean, extendedDelay?: boolean }} [options]
337
+ * @returns {Promise<[HTMLDivElement, { instance: () => HiGlassComponent }]>}
338
+ */
253
339
  export async function mountHGComponentAsync(
254
340
  prevDiv,
255
341
  prevHgc,
256
342
  viewConf,
257
343
  options,
258
344
  ) {
345
+ /** @type {ReturnType<typeof mountHGComponent>}*/
259
346
  let res;
260
347
  await new Promise((resolve) => {
261
348
  res = mountHGComponent(prevDiv, prevHgc, viewConf, resolve, options);
262
349
  });
350
+ // @ts-expect-error We know it's been resolved
263
351
  return res;
264
352
  }
@@ -1,6 +1,68 @@
1
- import type { THEME_DARK, THEME_LIGHT } from './configs';
1
+ import type * as configs from './configs';
2
2
  import type { ChromsizeRow } from './utils/parse-chromsizes-rows';
3
3
 
4
+ export type Theme = typeof configs.THEME_DARK | typeof configs.THEME_LIGHT;
5
+ export type SizeMode =
6
+ | typeof configs.SIZE_MODE_DEFAULT
7
+ | typeof configs.SIZE_MODE_BOUNDED
8
+ | typeof configs.SIZE_MODE_OVERFLOW
9
+ | typeof configs.SIZE_MODE_BOUNDED_OVERFLOW
10
+ | typeof configs.SIZE_MODE_SCROLL;
11
+
12
+ // TODO: Generate from 'schema.json'
13
+ export type HiGlassViewConfig = Record<string, unknown>;
14
+
15
+ /** Additional options for how the {@link HiGlassComponent} is drawn and behaves */
16
+ export interface HiGlassOptions {
17
+ /** An auth token to be included with every tile request. */
18
+ authToken?: string;
19
+ /**
20
+ * Whether the component should be sized to fit within the enclosing div.
21
+ *
22
+ * If `false`, the component will grow as needed to fit the tracks within it.
23
+ */
24
+ bounded?: boolean;
25
+ /**
26
+ * Whether the layout be changed.
27
+ *
28
+ * If `false`, the view headers will be hidden. Overrides the `editable` value in the viewconf if specified.
29
+ */
30
+ editable?: boolean;
31
+ /** A set of default options that will be used for newly added tracks. */
32
+ defaultTrackOptions?: {
33
+ /** Options for all tracks types. */
34
+ all?: Record<string, unknown>;
35
+ /** Options for specific tracks types. */
36
+ trackSpecific?: Record<string, Record<string, unknown>>;
37
+ };
38
+ viewMarginTop?: number;
39
+ viewMarginBottom?: number;
40
+ viewMarginLeft?: number;
41
+ viewMarginRight?: number;
42
+ viewPaddingTop?: number;
43
+ viewPaddingBottom?: number;
44
+ viewPaddingLeft?: number;
45
+ viewPaddingRight?: number;
46
+ theme?: 'dark' | 'light';
47
+ isDarkTheme?: boolean;
48
+ moustTool?: 'select' | 'track-select';
49
+ pluginTracks?: Record<string, unknown>;
50
+ pluginDataFetchers?: Record<string, unknown>;
51
+ pixelPreciseMarginPadding?: boolean;
52
+ sizeMode?: SizeMode;
53
+ renderer?: 'canvas';
54
+ onViewConfLoaded?: () => void;
55
+ cheatCodesEnabled?: boolean;
56
+ rangeSelectionOnAlt?: boolean;
57
+ tracksEditable?: boolean;
58
+ zoomFixed?: boolean;
59
+ containerPaddingX?: number;
60
+ containerPaddingY?: number;
61
+ broadcastMousePositionGlobally?: boolean;
62
+ showGlobalMousePosition?: boolean;
63
+ globalMousePosition?: boolean;
64
+ }
65
+
4
66
  export type Scale = import('d3-scale').ScaleContinuousNumeric<number, number>;
5
67
 
6
68
  // biome-ignore format: Biome formatting messes up tsc parsing
@@ -77,6 +139,8 @@ export interface TrackObject {
77
139
  draw(): void;
78
140
  rerender(options: unknown): void;
79
141
  delayDrawing: boolean;
142
+ flipText?: boolean;
143
+ originalTrack?: TrackObject;
80
144
  childTracks?: TrackObject[];
81
145
  createdTracks: Record<string, TrackObject>;
82
146
  refScalesChanged(x: Scale, y: Scale): void;
@@ -89,10 +153,11 @@ export interface TrackObject {
89
153
  remove(): void;
90
154
  movedY(extent: number): void;
91
155
  zoomedY(yPosition: number, wheelDelta: number): void;
156
+ fetching?: Set<unknown>;
157
+ tilesetInfo?: TilesetInfo;
158
+ chromInfo?: unknown; // TODO
92
159
  }
93
160
 
94
- export type Theme = typeof THEME_DARK | typeof THEME_LIGHT;
95
-
96
161
  /** Minimum information describing a tileset. */
97
162
  export type TilesetInfoShared = {
98
163
  name: string;
@@ -0,0 +1,36 @@
1
+ /** @param {string} text */
2
+ function fallbackCopyTextToClipboard(text) {
3
+ const textArea = document.createElement('textarea');
4
+ textArea.value = text;
5
+
6
+ // Avoid scrolling to bottom
7
+ textArea.style.top = '0';
8
+ textArea.style.left = '0';
9
+ textArea.style.position = 'fixed';
10
+
11
+ document.body.appendChild(textArea);
12
+ textArea.focus();
13
+ textArea.select();
14
+
15
+ try {
16
+ document.execCommand('copy');
17
+ } catch (err) {
18
+ // console.error('Fallback: Oops, unable to copy', err);
19
+ }
20
+
21
+ document.body.removeChild(textArea);
22
+ }
23
+
24
+ /** @param {string} text */
25
+ export default function copyTextToClipboard(text) {
26
+ if (!navigator.clipboard) {
27
+ fallbackCopyTextToClipboard(text);
28
+ return;
29
+ }
30
+ navigator.clipboard.writeText(text).then(
31
+ () => {},
32
+ (err) => {
33
+ // console.error('Async: Could not copy text: ', err);
34
+ },
35
+ );
36
+ }
@@ -0,0 +1,33 @@
1
+ import assert from './assert.js';
2
+
3
+ /**
4
+ * Decompress a compressed data source.
5
+ *
6
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream DecompressionStream API}
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const compressed = new Uint8Array([
11
+ * 0x1f, 0x8b, 0x08, 0x00, 0x1e, 0xc0, 0x7e, 0x67, 0x00, 0x03, 0xf3, 0x48,
12
+ * 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x28, 0xcf, 0x2f, 0xca, 0x49, 0x51, 0x04,
13
+ * 0x00, 0xe6, 0xc6, 0xe6, 0xeb, 0x0d, 0x00, 0x00, 0x00
14
+ * ]);
15
+ * console.log(await decompress(compressed, { format: "gzip" }).text()); // "Hello, world!"
16
+ * ```
17
+ *
18
+ * @param {BodyInit | Response} data - The compressed data.
19
+ * @param {Object} options
20
+ * @param {CompressionFormat} options.format
21
+ * @param {AbortSignal=} options.signal
22
+ * @returns {Response} A new response for decompressed data.
23
+ *
24
+ * @see {@link https://github.com/manzt/manzt/blob/1380bb/utils/decompress.js source}
25
+ */
26
+ export default function decompress(data, options) {
27
+ const { format, signal } = options;
28
+ const response = data instanceof Response ? data : new Response(data);
29
+ assert(response.body, 'Response does not include a body.');
30
+ return new Response(
31
+ response.body.pipeThrough(new DecompressionStream(format), { signal }),
32
+ );
33
+ }
@@ -0,0 +1,46 @@
1
+ // @ts-nocheck
2
+ import { DEFAULT_TRACKS_FOR_DATATYPE, TRACKS_INFO_BY_TYPE } from '../configs';
3
+
4
+ /** Get the default tracks for a datatype. Uses the known track definitions as
5
+ * well as any extra definitions that may be passed in. */
6
+ export default function getDefaultTracksForDatatype(
7
+ datatype,
8
+ otherDefaultTracks,
9
+ ) {
10
+ if (window.higlassTracksByType) {
11
+ // Extend `TRACKS_INFO_BY_TYPE` with the configs of plugin tracks.
12
+ Object.keys(window.higlassTracksByType).forEach((pluginTrackType) => {
13
+ TRACKS_INFO_BY_TYPE[pluginTrackType] =
14
+ window.higlassTracksByType[pluginTrackType].config;
15
+ });
16
+ }
17
+
18
+ if (!(datatype in DEFAULT_TRACKS_FOR_DATATYPE) && !otherDefaultTracks) {
19
+ console.warn('unknown data type:', datatype);
20
+ return undefined;
21
+ }
22
+
23
+ const orientationToPositions = {
24
+ '1d-horizontal': ['top', 'bottom', 'left', 'right'],
25
+ '2d': ['center'],
26
+ '1d-vertical': ['left', 'right'],
27
+ };
28
+
29
+ const defaultTracks = DEFAULT_TRACKS_FOR_DATATYPE[datatype] || {};
30
+
31
+ if (otherDefaultTracks) {
32
+ for (const trackType of otherDefaultTracks) {
33
+ if (!TRACKS_INFO_BY_TYPE[trackType]) {
34
+ console.warn('unknown track type', trackType);
35
+ } else {
36
+ for (const position of orientationToPositions[
37
+ TRACKS_INFO_BY_TYPE[trackType].orientation
38
+ ]) {
39
+ defaultTracks[position] = trackType;
40
+ }
41
+ }
42
+ }
43
+ }
44
+
45
+ return defaultTracks;
46
+ }