higlass 1.13.5 → 2.0.0

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 (392) hide show
  1. package/README.md +48 -54
  2. package/app/globals.d.ts +1 -1
  3. package/app/missing-types.d.ts +4 -1
  4. package/app/scripts/AddTrackDialog.jsx +11 -4
  5. package/app/scripts/AddTrackPositionMenu.jsx +28 -7
  6. package/app/scripts/Annotations1dTrack.js +90 -251
  7. package/app/scripts/Annotations2dTrack.js +12 -7
  8. package/app/scripts/Autocomplete.jsx +13 -28
  9. package/app/scripts/AxisPixi.js +6 -10
  10. package/app/scripts/BarTrack.js +3 -3
  11. package/app/scripts/BedLikeTrack.js +556 -449
  12. package/app/scripts/Button.jsx +1 -1
  13. package/app/scripts/CNVIntervalTrack.js +1 -1
  14. package/app/scripts/CenterTrack.jsx +8 -7
  15. package/app/scripts/Chromosome2DAnnotations.js +1 -1
  16. package/app/scripts/Chromosome2DLabels.js +1 -1
  17. package/app/scripts/ChromosomeGrid.js +49 -38
  18. package/app/scripts/ChromosomeInfo.js +1 -1
  19. package/app/scripts/CombinedTrack.js +3 -1
  20. package/app/scripts/ConfigTrackMenu.jsx +1 -1
  21. package/app/scripts/ConfigViewMenu.jsx +2 -2
  22. package/app/scripts/ContextMenuContainer.jsx +4 -2
  23. package/app/scripts/ContextMenuItem.jsx +14 -2
  24. package/app/scripts/CrossRule.js +1 -1
  25. package/app/scripts/CustomTrackDialog.jsx +2 -2
  26. package/app/scripts/Dialog.jsx +2 -2
  27. package/app/scripts/DragListeningDiv.jsx +1 -1
  28. package/app/scripts/DraggableDiv.jsx +2 -3
  29. package/app/scripts/ExportLinkDialog.jsx +1 -1
  30. package/app/scripts/FilledLine.js +349 -0
  31. package/app/scripts/GalleryTracks.jsx +77 -78
  32. package/app/scripts/GenomePositionSearchBox.jsx +184 -482
  33. package/app/scripts/HeatmapOptions.jsx +4 -2
  34. package/app/scripts/HeatmapTiledPixiTrack.js +23 -32
  35. package/app/scripts/HiGlassComponent.jsx +515 -444
  36. package/app/scripts/HiGlassComponentContext.js +5 -0
  37. package/app/scripts/Horizontal1dHeatmapTrack.js +1 -1
  38. package/app/scripts/Horizontal2DDomainsTrack.js +1 -1
  39. package/app/scripts/HorizontalChromosomeLabels.js +28 -22
  40. package/app/scripts/HorizontalGeneAnnotationsTrack.js +1 -1
  41. package/app/scripts/HorizontalHeatmapTrack.js +2 -2
  42. package/app/scripts/HorizontalMultivecTrack.js +6 -7
  43. package/app/scripts/HorizontalRule.js +1 -2
  44. package/app/scripts/HorizontalTiled1DPixiTrack.js +4 -4
  45. package/app/scripts/HorizontalTiledPlot.jsx +9 -9
  46. package/app/scripts/LeftTrackModifier.js +4 -0
  47. package/app/scripts/ListWrapper.jsx +1 -2
  48. package/app/scripts/MapboxTilesTrack.js +1 -2
  49. package/app/scripts/Modal.jsx +2 -2
  50. package/app/scripts/MoveableTrack.jsx +10 -12
  51. package/app/scripts/NestedContextMenu.jsx +2 -1
  52. package/app/scripts/OSMTileIdsTrack.js +1 -1
  53. package/app/scripts/OverlayTrack.js +4 -4
  54. package/app/scripts/PixiTrack.js +27 -13
  55. package/app/scripts/PlotTypeChooser.jsx +3 -4
  56. package/app/scripts/SearchField.js +5 -5
  57. package/app/scripts/SeriesListItems.jsx +3 -4
  58. package/app/scripts/SeriesListMenu.jsx +95 -53
  59. package/app/scripts/SeriesListSubmenuMixin.jsx +2 -1
  60. package/app/scripts/SketchInlinePicker.jsx +2 -2
  61. package/app/scripts/SortableList.jsx +1 -1
  62. package/app/scripts/Tiled1DPixiTrack.js +4 -1
  63. package/app/scripts/TiledPixiTrack.js +244 -102
  64. package/app/scripts/TiledPlot.jsx +565 -118
  65. package/app/scripts/TilesetFinder.jsx +12 -4
  66. package/app/scripts/Track.js +1 -1
  67. package/app/scripts/TrackArea.jsx +4 -0
  68. package/app/scripts/TrackControl.jsx +2 -2
  69. package/app/scripts/TrackRenderer.jsx +32 -33
  70. package/app/scripts/ValueIntervalTrack.js +1 -1
  71. package/app/scripts/VerticalRule.js +2 -2
  72. package/app/scripts/VerticalTiledPlot.jsx +7 -7
  73. package/app/scripts/ViewConfigEditor.jsx +1 -1
  74. package/app/scripts/ViewContextMenu.jsx +53 -5
  75. package/app/scripts/ViewHeader.jsx +9 -9
  76. package/app/scripts/ViewportTracker2D.js +1 -1
  77. package/app/scripts/api.js +92 -12
  78. package/app/scripts/configs/available-track-types.js +1 -1
  79. package/app/scripts/configs/index.js +6 -1
  80. package/app/scripts/configs/positions-by-datatype.js +2 -2
  81. package/app/scripts/configs/primitives.js +2 -0
  82. package/app/scripts/configs/themes.js +0 -1
  83. package/app/scripts/configs/tracks-info-by-type.js +11 -8
  84. package/app/scripts/configs/tracks-info.js +3 -2
  85. package/app/scripts/d3-context-menu.js +3 -4
  86. package/app/scripts/data-fetchers/DataFetcher.js +35 -36
  87. package/app/scripts/data-fetchers/genbank-fetcher.js +13 -22
  88. package/app/scripts/data-fetchers/local-tile-fetcher.js +10 -8
  89. package/app/scripts/hglib.jsx +62 -71
  90. package/app/scripts/hocs/with-modal.jsx +32 -10
  91. package/app/scripts/hocs/with-pub-sub.js +12 -3
  92. package/app/scripts/hocs/with-theme.jsx +21 -14
  93. package/app/scripts/icons.jsx +3 -2
  94. package/app/scripts/mixwith.js +2 -2
  95. package/app/scripts/options-info.js +49 -11
  96. package/app/scripts/plugins/get-data-fetcher.js +2 -3
  97. package/app/scripts/services/chrom-info.js +32 -4
  98. package/app/scripts/services/element-resize-listener.js +2 -2
  99. package/app/scripts/services/index.js +0 -1
  100. package/app/scripts/services/tile-proxy.js +368 -285
  101. package/app/scripts/services/worker.js +31 -28
  102. package/app/scripts/test-helpers/index.js +2 -1
  103. package/app/scripts/test-helpers/test-helpers.jsx +157 -69
  104. package/app/scripts/types.ts +118 -47
  105. package/app/scripts/utils/LruCache.js +3 -2
  106. package/app/scripts/utils/assert.js +19 -0
  107. package/app/scripts/utils/background-task-scheduler.js +2 -0
  108. package/app/scripts/utils/color-domain-to-rgba-array.js +13 -3
  109. package/app/scripts/utils/copy-text-to-clipboard.js +36 -0
  110. package/app/scripts/utils/decompress.js +33 -0
  111. package/app/scripts/utils/default-tracks.js +46 -0
  112. package/app/scripts/utils/dict-items.js +1 -0
  113. package/app/scripts/utils/dict-keys.js +1 -0
  114. package/app/scripts/utils/dict-values.js +1 -0
  115. package/app/scripts/utils/expand-combined-tracks.js +11 -7
  116. package/app/scripts/utils/fill-in-min-widths.js +47 -21
  117. package/app/scripts/utils/flatten.js +0 -1
  118. package/app/scripts/utils/get-aggregation-function.js +1 -1
  119. package/app/scripts/utils/get-default-track-for-datatype.js +37 -10
  120. package/app/scripts/utils/get-default-tracks-for-datatype.ts +46 -0
  121. package/app/scripts/utils/get-higlass-components.js +27 -3
  122. package/app/scripts/utils/get-track-position-by-uid.js +8 -1
  123. package/app/scripts/utils/get-xylofon.js +12 -9
  124. package/app/scripts/utils/has-parent.js +5 -5
  125. package/app/scripts/utils/hex-string-to-int.js +1 -1
  126. package/app/scripts/utils/index.js +1 -0
  127. package/app/scripts/utils/interval-tree.js +222 -177
  128. package/app/scripts/utils/load-chrom-infos.js +4 -1
  129. package/app/scripts/utils/pixi-text-to-svg.js +5 -9
  130. package/app/scripts/utils/positioned-tracks-to-all-tracks.js +55 -0
  131. package/app/scripts/utils/range-query-2d.js +3 -3
  132. package/app/scripts/utils/reduce.js +12 -5
  133. package/app/scripts/utils/segments-to-rows.js +14 -11
  134. package/app/scripts/utils/svg-line.js +7 -8
  135. package/app/scripts/utils/type-guards.js +16 -7
  136. package/app/scripts/utils/visit-positioned-tracks.js +9 -4
  137. package/app/styles/AddTrackPositionMenu.module.scss +37 -0
  138. package/app/styles/HiGlass.module.scss +3 -1
  139. package/app/styles/d3-context-menu.css +0 -1
  140. package/app/styles/prism.css +1 -0
  141. package/dist/app/schema.json +525 -0
  142. package/dist/app/scripts/AddTrackDialog.d.ts +64 -0
  143. package/dist/app/scripts/AddTrackPositionMenu.d.ts +5 -0
  144. package/dist/app/scripts/Annotations1dTrack.d.ts +15 -0
  145. package/dist/app/scripts/Annotations2dTrack.d.ts +95 -0
  146. package/dist/app/scripts/ArrowheadDomainsTrack.d.ts +36 -0
  147. package/dist/app/scripts/Autocomplete.d.ts +102 -0
  148. package/dist/app/scripts/AxisPixi.d.ts +25 -0
  149. package/dist/app/scripts/BarTrack.d.ts +28 -0
  150. package/dist/app/scripts/BedLikeTrack.d.ts +84 -0
  151. package/dist/app/scripts/Button.d.ts +3 -0
  152. package/dist/app/scripts/CNVIntervalTrack.d.ts +12 -0
  153. package/dist/app/scripts/CenterTiledPlot.d.ts +3 -0
  154. package/dist/app/scripts/CenterTrack.d.ts +92 -0
  155. package/dist/app/scripts/Chromosome2DAnnotations.d.ts +10 -0
  156. package/dist/app/scripts/Chromosome2DLabels.d.ts +13 -0
  157. package/dist/app/scripts/ChromosomeGrid.d.ts +24 -0
  158. package/dist/app/scripts/ChromosomeInfo.d.ts +14 -0
  159. package/dist/app/scripts/CloseTrackMenu.d.ts +10 -0
  160. package/dist/app/scripts/CombinedTrack.d.ts +32 -0
  161. package/dist/app/scripts/ConfigTrackMenu.d.ts +10 -0
  162. package/dist/app/scripts/ConfigViewMenu.d.ts +34 -0
  163. package/dist/app/scripts/ConfigureSeriesMenu.d.ts +3 -0
  164. package/dist/app/scripts/ContextMenuContainer.d.ts +36 -0
  165. package/dist/app/scripts/ContextMenuItem.d.ts +34 -0
  166. package/dist/app/scripts/Cross.d.ts +3 -0
  167. package/dist/app/scripts/CrossRule.d.ts +24 -0
  168. package/dist/app/scripts/CustomTrackDialog.d.ts +17 -0
  169. package/dist/app/scripts/Dialog.d.ts +5 -0
  170. package/dist/app/scripts/DivergentBarTrack.d.ts +4 -0
  171. package/dist/app/scripts/DragListeningDiv.d.ts +32 -0
  172. package/dist/app/scripts/DraggableDiv.d.ts +63 -0
  173. package/dist/app/scripts/ExportLinkDialog.d.ts +21 -0
  174. package/dist/app/scripts/FilledLine.d.ts +5 -0
  175. package/dist/app/scripts/FixedTrack.d.ts +5 -0
  176. package/dist/app/scripts/GalleryTracks.d.ts +20 -0
  177. package/dist/app/scripts/GenomePositionSearchBox.d.ts +95 -0
  178. package/dist/app/scripts/HeatmapOptions.d.ts +30 -0
  179. package/dist/app/scripts/HeatmapTiledPixiTrack.d.ts +184 -0
  180. package/dist/app/scripts/HiGlassComponent.d.ts +762 -0
  181. package/dist/app/scripts/HiGlassComponentContext.d.ts +3 -0
  182. package/dist/app/scripts/HiGlassTrackComponent.d.ts +37 -0
  183. package/dist/app/scripts/Horizontal1dHeatmapTrack.d.ts +9 -0
  184. package/dist/app/scripts/Horizontal2DDomainsTrack.d.ts +21 -0
  185. package/dist/app/scripts/HorizontalChromosomeLabels.d.ts +47 -0
  186. package/dist/app/scripts/HorizontalGeneAnnotationsTrack.d.ts +25 -0
  187. package/dist/app/scripts/HorizontalHeatmapTrack.d.ts +12 -0
  188. package/dist/app/scripts/HorizontalItem.d.ts +3 -0
  189. package/dist/app/scripts/HorizontalLine1DPixiTrack.d.ts +23 -0
  190. package/dist/app/scripts/HorizontalMultivecTrack.d.ts +50 -0
  191. package/dist/app/scripts/HorizontalPoint1DPixiTrack.d.ts +5 -0
  192. package/dist/app/scripts/HorizontalRule.d.ts +22 -0
  193. package/dist/app/scripts/HorizontalTiled1DPixiTrack.d.ts +26 -0
  194. package/dist/app/scripts/HorizontalTiledPlot.d.ts +49 -0
  195. package/dist/app/scripts/HorizontalTrack.d.ts +6 -0
  196. package/dist/app/scripts/Id2DTiledPixiTrack.d.ts +10 -0
  197. package/dist/app/scripts/IdHorizontal1DTiledPixiTrack.d.ts +6 -0
  198. package/dist/app/scripts/IdVertical1DTiledPixiTrack.d.ts +7 -0
  199. package/dist/app/scripts/LeftAxisTrack.d.ts +9 -0
  200. package/dist/app/scripts/LeftTrackModifier.d.ts +29 -0
  201. package/dist/app/scripts/ListWrapper.d.ts +64 -0
  202. package/dist/app/scripts/MapboxTilesTrack.d.ts +9 -0
  203. package/dist/app/scripts/Modal.d.ts +5 -0
  204. package/dist/app/scripts/MoveableTrack.d.ts +18 -0
  205. package/dist/app/scripts/NestedContextMenu.d.ts +7 -0
  206. package/dist/app/scripts/OSMTileIdsTrack.d.ts +5 -0
  207. package/dist/app/scripts/OSMTilesTrack.d.ts +129 -0
  208. package/dist/app/scripts/OverlayTrack.d.ts +13 -0
  209. package/dist/app/scripts/PixiTrack.d.ts +174 -0
  210. package/dist/app/scripts/PlotTypeChooser.d.ts +25 -0
  211. package/dist/app/scripts/PopupMenu.d.ts +28 -0
  212. package/dist/app/scripts/RasterTilesTrack.d.ts +9 -0
  213. package/dist/app/scripts/RuleMixin.d.ts +2 -0
  214. package/dist/app/scripts/SVGTrack.d.ts +15 -0
  215. package/dist/app/scripts/SearchField.d.ts +13 -0
  216. package/dist/app/scripts/SeriesListItems.d.ts +2 -0
  217. package/dist/app/scripts/SeriesListMenu.d.ts +51 -0
  218. package/dist/app/scripts/SeriesListSubmenuMixin.d.ts +2 -0
  219. package/dist/app/scripts/SketchInlinePicker.d.ts +25 -0
  220. package/dist/app/scripts/SortableList.d.ts +22 -0
  221. package/dist/app/scripts/SquareMarkersTrack.d.ts +22 -0
  222. package/dist/app/scripts/Tiled1DPixiTrack.d.ts +60 -0
  223. package/dist/app/scripts/TiledPixiTrack.d.ts +369 -0
  224. package/dist/app/scripts/TiledPlot.d.ts +313 -0
  225. package/dist/app/scripts/TilesetFinder.d.ts +65 -0
  226. package/dist/app/scripts/TopAxisTrack.d.ts +9 -0
  227. package/dist/app/scripts/Track.d.ts +196 -0
  228. package/dist/app/scripts/TrackArea.d.ts +26 -0
  229. package/dist/app/scripts/TrackControl.d.ts +5 -0
  230. package/dist/app/scripts/TrackRenderer.d.ts +724 -0
  231. package/dist/app/scripts/UnknownPixiTrack.d.ts +7 -0
  232. package/dist/app/scripts/ValueIntervalTrack.d.ts +6 -0
  233. package/dist/app/scripts/VerticalItem.d.ts +3 -0
  234. package/dist/app/scripts/VerticalRule.d.ts +21 -0
  235. package/dist/app/scripts/VerticalTiled1DPixiTrack.d.ts +6 -0
  236. package/dist/app/scripts/VerticalTiledPlot.d.ts +50 -0
  237. package/dist/app/scripts/VerticalTrack.d.ts +6 -0
  238. package/dist/app/scripts/ViewConfigEditor.d.ts +53 -0
  239. package/dist/app/scripts/ViewContextMenu.d.ts +17 -0
  240. package/dist/app/scripts/ViewHeader.d.ts +75 -0
  241. package/dist/app/scripts/ViewportTracker2D.d.ts +17 -0
  242. package/dist/app/scripts/ViewportTracker2DPixi.d.ts +11 -0
  243. package/dist/app/scripts/ViewportTrackerHorizontal.d.ts +17 -0
  244. package/dist/app/scripts/ViewportTrackerVertical.d.ts +17 -0
  245. package/dist/app/scripts/api.d.ts +640 -0
  246. package/dist/app/scripts/configs/available-track-types.d.ts +2 -0
  247. package/dist/app/scripts/configs/colormaps.d.ts +2 -0
  248. package/dist/app/scripts/configs/datatype-to-track-type.d.ts +4 -0
  249. package/dist/app/scripts/configs/default-tracks-for-datatype.d.ts +38 -0
  250. package/dist/app/scripts/configs/dense-data-extrema-config.d.ts +2 -0
  251. package/dist/app/scripts/configs/globals.d.ts +5 -0
  252. package/dist/app/scripts/configs/index.d.ts +16 -0
  253. package/dist/app/scripts/configs/positions-by-datatype.d.ts +2 -0
  254. package/dist/app/scripts/configs/primitives.d.ts +20 -0
  255. package/dist/app/scripts/configs/themes.d.ts +3 -0
  256. package/dist/app/scripts/configs/tracks-info-by-type.d.ts +4 -0
  257. package/dist/app/scripts/configs/tracks-info.d.ts +24 -0
  258. package/dist/app/scripts/d3-context-menu.d.ts +2 -0
  259. package/dist/app/scripts/data-fetchers/DataFetcher.d.ts +151 -0
  260. package/dist/app/scripts/data-fetchers/genbank-fetcher.d.ts +86 -0
  261. package/dist/app/scripts/data-fetchers/index.d.ts +3 -0
  262. package/dist/app/scripts/data-fetchers/local-tile-fetcher.d.ts +47 -0
  263. package/dist/app/scripts/gosling-exports.d.ts +17 -0
  264. package/dist/app/scripts/hglib.d.ts +24 -0
  265. package/dist/app/scripts/hocs/with-modal.d.ts +19 -0
  266. package/dist/app/scripts/hocs/with-pub-sub.d.ts +22 -0
  267. package/dist/app/scripts/hocs/with-theme.d.ts +13 -0
  268. package/dist/app/scripts/icons.d.ts +161 -0
  269. package/dist/app/scripts/mixwith.d.ts +27 -0
  270. package/dist/app/scripts/options-info.d.ts +1355 -0
  271. package/dist/app/scripts/plugins/available-for-plugins.d.ts +2338 -0
  272. package/dist/app/scripts/plugins/get-data-fetcher.d.ts +2 -0
  273. package/dist/app/scripts/plugins/index.d.ts +2 -0
  274. package/dist/app/scripts/services/chrom-info.d.ts +10 -0
  275. package/dist/app/scripts/services/dom-event.d.ts +7 -0
  276. package/dist/app/scripts/services/element-resize-listener.d.ts +5 -0
  277. package/dist/app/scripts/services/index.d.ts +5 -0
  278. package/dist/app/scripts/services/tile-proxy.d.ts +180 -0
  279. package/dist/app/scripts/services/worker.d.ts +157 -0
  280. package/dist/app/scripts/symbol.d.ts +13 -0
  281. package/dist/app/scripts/test-helpers/index.d.ts +1 -0
  282. package/dist/app/scripts/test-helpers/test-helpers.d.ts +33 -0
  283. package/dist/app/scripts/track-utils.d.ts +73 -0
  284. package/dist/app/scripts/types.d.ts +199 -0
  285. package/dist/app/scripts/utils/DenseDataExtrema1D.d.ts +88 -0
  286. package/dist/app/scripts/utils/DenseDataExtrema2D.d.ts +97 -0
  287. package/dist/app/scripts/utils/LruCache.d.ts +44 -0
  288. package/dist/app/scripts/utils/abs-to-chr.d.ts +14 -0
  289. package/dist/app/scripts/utils/accessor-transposition.d.ts +14 -0
  290. package/dist/app/scripts/utils/add-arrays.d.ts +18 -0
  291. package/dist/app/scripts/utils/add-class.d.ts +8 -0
  292. package/dist/app/scripts/utils/add-event-listener-once.d.ts +11 -0
  293. package/dist/app/scripts/utils/assert.d.ts +17 -0
  294. package/dist/app/scripts/utils/background-task-scheduler.d.ts +47 -0
  295. package/dist/app/scripts/utils/base64-to-canvas.d.ts +9 -0
  296. package/dist/app/scripts/utils/chr-to-abs.d.ts +10 -0
  297. package/dist/app/scripts/utils/chrom-info-bisector.d.ts +4 -0
  298. package/dist/app/scripts/utils/clone-event.d.ts +12 -0
  299. package/dist/app/scripts/utils/color-domain-to-rgba-array.d.ts +13 -0
  300. package/dist/app/scripts/utils/color-to-hex.d.ts +9 -0
  301. package/dist/app/scripts/utils/color-to-rgba.d.ts +9 -0
  302. package/dist/app/scripts/utils/copy-text-to-clipboard.d.ts +2 -0
  303. package/dist/app/scripts/utils/data-to-genomic-loci.d.ts +11 -0
  304. package/dist/app/scripts/utils/debounce.d.ts +5 -0
  305. package/dist/app/scripts/utils/dec-to-hex-str.d.ts +8 -0
  306. package/dist/app/scripts/utils/decompress.d.ts +27 -0
  307. package/dist/app/scripts/utils/default-tracks.d.ts +3 -0
  308. package/dist/app/scripts/utils/dict-from-tuples.d.ts +11 -0
  309. package/dist/app/scripts/utils/dict-items.d.ts +18 -0
  310. package/dist/app/scripts/utils/dict-keys.d.ts +10 -0
  311. package/dist/app/scripts/utils/dict-values.d.ts +8 -0
  312. package/dist/app/scripts/utils/download.d.ts +7 -0
  313. package/dist/app/scripts/utils/expand-combined-tracks.d.ts +11 -0
  314. package/dist/app/scripts/utils/fake-pub-sub.d.ts +11 -0
  315. package/dist/app/scripts/utils/fill-in-min-widths.d.ts +44 -0
  316. package/dist/app/scripts/utils/flatten.d.ts +9 -0
  317. package/dist/app/scripts/utils/for-each.d.ts +9 -0
  318. package/dist/app/scripts/utils/forward-event.d.ts +7 -0
  319. package/dist/app/scripts/utils/genome-loci-to-pixels.d.ts +9 -0
  320. package/dist/app/scripts/utils/genomic-range-to-chromosome-chunks.d.ts +21 -0
  321. package/dist/app/scripts/utils/get-aggregation-function.d.ts +10 -0
  322. package/dist/app/scripts/utils/get-default-track-for-datatype.d.ts +21 -0
  323. package/dist/app/scripts/utils/get-default-tracks-for-datatype.d.ts +3 -0
  324. package/dist/app/scripts/utils/get-element-dim.d.ts +7 -0
  325. package/dist/app/scripts/utils/get-higlass-components.d.ts +7 -0
  326. package/dist/app/scripts/utils/get-track-by-uid.d.ts +7 -0
  327. package/dist/app/scripts/utils/get-track-conf-from-hgc.d.ts +10 -0
  328. package/dist/app/scripts/utils/get-track-obj-by-id.d.ts +2 -0
  329. package/dist/app/scripts/utils/get-track-position-by-uid.d.ts +13 -0
  330. package/dist/app/scripts/utils/get-xylofon.d.ts +2 -0
  331. package/dist/app/scripts/utils/gradient.d.ts +14 -0
  332. package/dist/app/scripts/utils/has-class.d.ts +8 -0
  333. package/dist/app/scripts/utils/has-parent.d.ts +9 -0
  334. package/dist/app/scripts/utils/hex-string-to-int.d.ts +14 -0
  335. package/dist/app/scripts/utils/index.d.ts +89 -0
  336. package/dist/app/scripts/utils/interval-tree.d.ts +109 -0
  337. package/dist/app/scripts/utils/into-the-void.d.ts +6 -0
  338. package/dist/app/scripts/utils/is-track-or-child-track.d.ts +7 -0
  339. package/dist/app/scripts/utils/is-track-range-selectable.d.ts +2 -0
  340. package/dist/app/scripts/utils/is-within.d.ts +12 -0
  341. package/dist/app/scripts/utils/lat-to-y.d.ts +9 -0
  342. package/dist/app/scripts/utils/lng-to-x.d.ts +8 -0
  343. package/dist/app/scripts/utils/load-chrom-infos.d.ts +8 -0
  344. package/dist/app/scripts/utils/map.d.ts +13 -0
  345. package/dist/app/scripts/utils/max-non-zero.d.ts +6 -0
  346. package/dist/app/scripts/utils/max.d.ts +10 -0
  347. package/dist/app/scripts/utils/min-non-zero.d.ts +6 -0
  348. package/dist/app/scripts/utils/min.d.ts +10 -0
  349. package/dist/app/scripts/utils/mod.d.ts +9 -0
  350. package/dist/app/scripts/utils/ndarray-assign.d.ts +2 -0
  351. package/dist/app/scripts/utils/ndarray-flatten.d.ts +2 -0
  352. package/dist/app/scripts/utils/ndarray-to-list.d.ts +2 -0
  353. package/dist/app/scripts/utils/numericify-version.d.ts +6 -0
  354. package/dist/app/scripts/utils/obj-vals.d.ts +8 -0
  355. package/dist/app/scripts/utils/or.d.ts +8 -0
  356. package/dist/app/scripts/utils/parse-chromsizes-rows.d.ts +34 -0
  357. package/dist/app/scripts/utils/pixi-text-to-svg.d.ts +2 -0
  358. package/dist/app/scripts/utils/positioned-tracks-to-all-tracks.d.ts +26 -0
  359. package/dist/app/scripts/utils/q.d.ts +18 -0
  360. package/dist/app/scripts/utils/rad-to-deg.d.ts +7 -0
  361. package/dist/app/scripts/utils/range-query-2d.d.ts +17 -0
  362. package/dist/app/scripts/utils/reduce.d.ts +14 -0
  363. package/dist/app/scripts/utils/rel-to-abs-chrom-pos.d.ts +10 -0
  364. package/dist/app/scripts/utils/remove-class.d.ts +7 -0
  365. package/dist/app/scripts/utils/reset-d3-brush-style.d.ts +10 -0
  366. package/dist/app/scripts/utils/rgb-to-hex.d.ts +8 -0
  367. package/dist/app/scripts/utils/scales-center-and-k.d.ts +12 -0
  368. package/dist/app/scripts/utils/scales-to-genome-loci.d.ts +3 -0
  369. package/dist/app/scripts/utils/segments-to-rows.d.ts +15 -0
  370. package/dist/app/scripts/utils/selected-items-to-cum-weights.d.ts +12 -0
  371. package/dist/app/scripts/utils/selected-items-to-size.d.ts +13 -0
  372. package/dist/app/scripts/utils/show-mouse-position.d.ts +54 -0
  373. package/dist/app/scripts/utils/some.d.ts +10 -0
  374. package/dist/app/scripts/utils/sum.d.ts +8 -0
  375. package/dist/app/scripts/utils/svg-line.d.ts +2 -0
  376. package/dist/app/scripts/utils/throttle-and-debounce.d.ts +33 -0
  377. package/dist/app/scripts/utils/tile-to-canvas.d.ts +9 -0
  378. package/dist/app/scripts/utils/timeout.d.ts +3 -0
  379. package/dist/app/scripts/utils/to-void.d.ts +3 -0
  380. package/dist/app/scripts/utils/total-track-pixel-height.d.ts +27 -0
  381. package/dist/app/scripts/utils/trim-trailing-slash.d.ts +7 -0
  382. package/dist/app/scripts/utils/type-guards.d.ts +36 -0
  383. package/dist/app/scripts/utils/value-to-color.d.ts +12 -0
  384. package/dist/app/scripts/utils/visit-positioned-tracks.d.ts +18 -0
  385. package/dist/app/scripts/utils/visit-tracks.d.ts +9 -0
  386. package/dist/esm.html +1 -3
  387. package/dist/hglib.js +86315 -100592
  388. package/dist/hglib.min.js +123 -131
  389. package/dist/higlass.mjs +88861 -103138
  390. package/dist/index.html +1 -3
  391. package/dist/package.json +134 -0
  392. package/package.json +25 -27
@@ -1,20 +1,22 @@
1
- // @ts-nocheck
2
- import { scaleLinear, scaleLog, scaleQuantile } from 'd3-scale';
3
1
  import { median, range, ticks } from 'd3-array';
2
+ import { scaleLinear, scaleLog, scaleQuantile } from 'd3-scale';
4
3
  import slugid from 'slugid';
5
4
 
6
- import DataFetcher from './data-fetchers/DataFetcher';
7
5
  import PixiTrack from './PixiTrack';
6
+ import { DataFetcher } from './data-fetchers';
8
7
 
9
- // Utils
10
- import throttleAndDebounce from './utils/throttle-and-debounce';
11
- import parseChromsizesRows from './utils/parse-chromsizes-rows';
12
8
  import backgroundTaskScheduler from './utils/background-task-scheduler';
9
+ // Utils
10
+ import parseChromsizesRows from './utils/parse-chromsizes-rows.js';
11
+ import throttleAndDebounce from './utils/throttle-and-debounce.js';
12
+ import { isResolutionsTilesetInfo, isTilesetInfo } from './utils/type-guards';
13
13
 
14
14
  // Configs
15
15
  import GLOBALS from './configs/globals';
16
16
  import { ZOOM_DEBOUNCE } from './configs/primitives';
17
17
 
18
+ /** @import * as t from './types' */
19
+
18
20
  /**
19
21
  * Get a valueScale for a heatmap.
20
22
  *
@@ -22,13 +24,13 @@ import { ZOOM_DEBOUNCE } from './configs/primitives';
22
24
  *
23
25
  * @param {string} scalingType: The type of the (e.g. 'linear', or 'log')
24
26
  * @param {number} minValue: The minimum data value to which this scale will apply
25
- * @param {number} pseudocount: A value to add to all numbers to prevent taking the log of 0
27
+ * @param {number} pseudocountIn: A value to add to all numbers to prevent taking the log of 0
26
28
  * @param {number} maxValue: The maximum data value to which this scale will apply
27
29
  * @param {string} defaultScaling: The default scaling type to use in case
28
30
  * 'scalingType' is null (e.g. 'linear' or 'log')
29
31
  *
30
- * @returns {array} An array of [string, scale] containin the scale type
31
- * and a scale with an appropriately set domain and range
32
+ * @returns {[string, import('d3-scale').ScaleLogarithmic<number, number> | import('d3-scale').ScaleLinear<number, number>]}
33
+ * An array of [string, scale] containing the scale type and a scale with an appropriately set domain and range
32
34
  */
33
35
  export function getValueScale(
34
36
  scalingType,
@@ -60,22 +62,82 @@ export function getValueScale(
60
62
  return ['linear', scaleLinear().range([254, 0]).domain([minValue, maxValue])];
61
63
  }
62
64
 
65
+ /**
66
+ * @typedef Scale
67
+ * @property {number | null} [minValue]
68
+ * @property {number | null} [maxValue]
69
+ * @property {number | null} [maxRawValue]
70
+ * @property {number | null} [minRawValue]
71
+ */
72
+
73
+ /**
74
+ * An alternative to Tile. Perhaps the worst data type. An array of numbers with some extra properties.
75
+ * @typedef {Array<number> & Pick<Tile, 'mirrored' | 'tilePositionId'>} TilePositionArrayObject
76
+ */
77
+
78
+ /**
79
+ * @typedef Tile
80
+ * @property {string} tileId
81
+ * @property {TileData} tileData
82
+ * @property {string} remoteId
83
+ * @property {unknown} mirrored
84
+ * @property {string} tilePositionId
85
+ * @property {import("pixi.js").Graphics} graphics
86
+ */
87
+
88
+ /**
89
+ * @typedef TileData
90
+ * @property {string} tilesetUid
91
+ * @property {number} zoomLevel
92
+ * @property {Array<number>} tilePos
93
+ * @property {string} error
94
+ * @property {Float32Array} dense
95
+ * @property {number} minNonZero
96
+ * @property {number} maxNonZero
97
+ * @property {Array<number>} [shape] - Optional 1D or 2D array dimensions
98
+ */
99
+
100
+ /**
101
+ * @typedef TiledPixiTrackContextBase
102
+ * @property {DataFetcher} dataFetcher
103
+ * @property {t.DataConfig} dataConfig
104
+ * @property {function} animate A function to redraw this track. Typically called when an
105
+ * asynchronous event occurs (i.e. tiles loaded)
106
+ * @property {() => void} onValueScaleChanged The range of values has changed so we need to inform
107
+ * the higher ups that the value scale has changed. Only occurs on tracks with ``dense`` data.
108
+ * @property {(t: t.TilesetInfo) => void} [handleTilesetInfoReceived] A callback to do something once once the tileset
109
+ * info is received. Usually it registers some information about the tileset with its definition
110
+ */
111
+ /**
112
+ * @typedef {import('./PixiTrack').ExtendedPixiContext<TiledPixiTrackContextBase>} TiledPixiTrackContext
113
+ */
114
+
115
+ /**
116
+ * @typedef TiledPixiTrackOptions
117
+ * @property {string} labelPosition - If the label is to be drawn, where should it be drawn?
118
+ * @property {string} labelText - What should be drawn in the label.
119
+ * @property {number} maxZoom
120
+ * @property {string} name
121
+ */
122
+
123
+ /**
124
+ * @template T
125
+ * @typedef {T & TiledPixiTrackOptions} ExtendedTiledPixiTrackOptions
126
+ */
127
+
128
+ /**
129
+ * The TiledPixiTrack requires an options parameter, which should be an object containing properties specified in
130
+ * TiledPixiTrackOptions. It is capable of accepting any property defined in any of its superclasses.
131
+ * @template {ExtendedTiledPixiTrackOptions<{[key: string]: any}>} Options
132
+ * @extends {PixiTrack<Options>}
133
+ * */
63
134
  class TiledPixiTrack extends PixiTrack {
64
135
  /**
65
- * A track that must pull remote tiles
66
136
  *
67
- * @param (PIXI.scene) scene A PIXI.js scene to draw everything to.
68
- * @param (Object) dataConfig: A data source. Usually a
69
- * ``{{server: 'x/api/v1/', tilesetUuid: 'y'}}`` Object.
70
- * @param {Object} handleTilesetInfoReceived: A callback to do something once once the tileset
71
- * info is received. Usually it registers some information about the tileset with its
72
- * definition
73
- * @param {Object} options The track's options
74
- * @param {function} animate A function to redraw this track. Typically called when an
75
- * asynchronous event occurs (i.e. tiles loaded)
76
- * @param {function} onValueScaleChanged The range of values has changed so we need to inform
77
- * the higher ups that the value scale has changed. Only occurs on tracks with ``dense`` data.
137
+ * @param {TiledPixiTrackContext} context
138
+ * @param {Options} options
78
139
  */
140
+
79
141
  constructor(context, options) {
80
142
  super(context, options);
81
143
  const {
@@ -90,10 +152,13 @@ class TiledPixiTrack extends PixiTrack {
90
152
  // rerendering all rendering in the same version will have the same
91
153
  // scaling so tiles rendered in the same version will have the same
92
154
  // output. Mostly useful for heatmap tiles.
155
+ /** @type {number} */
93
156
  this.renderVersion = 1;
94
157
 
95
158
  // the tiles which should be visible (although they're not necessarily fetched)
96
- this.visibleTiles = new Set();
159
+ /** @type {Array<Pick<Tile, 'tileId' |'remoteId' | 'mirrored'>>} */
160
+ this.visibleTiles = [];
161
+ /** @type {Set<string>} */
97
162
  this.visibleTileIds = new Set();
98
163
 
99
164
  // keep track of tiles that are currently being rendered
@@ -101,14 +166,18 @@ class TiledPixiTrack extends PixiTrack {
101
166
 
102
167
  // the tiles we already have requests out for
103
168
  this.fetching = new Set();
169
+ /** @type {Scale} */
104
170
  this.scale = {};
105
171
 
106
172
  // tiles we have fetched and ready to be rendered
173
+ /** @type {{[id: string]: Tile}} */
107
174
  this.fetchedTiles = {};
108
175
 
109
176
  // the graphics that have already been drawn for this track
177
+ /** @type {Object.<string, import('pixi.js').DisplayObject>} */
110
178
  this.tileGraphics = {};
111
179
 
180
+ /** @type {number} */
112
181
  this.maxZoom = 0;
113
182
  this.medianVisibleValue = null;
114
183
 
@@ -123,8 +192,11 @@ class TiledPixiTrack extends PixiTrack {
123
192
  this.valueScaleMax = null;
124
193
  this.fixedValueScaleMax = null;
125
194
 
195
+ /** @type {Record<string, Array<Function>>} */
126
196
  this.listeners = {};
127
197
 
198
+ /** @type {import('pub-sub-es').PubSub & { __fake__?: boolean }} */
199
+ // @ts-expect-error This is always defined in Track.js
128
200
  this.pubSub = pubSub;
129
201
  this.animate = animate;
130
202
  this.onValueScaleChanged = onValueScaleChanged;
@@ -140,7 +212,11 @@ class TiledPixiTrack extends PixiTrack {
140
212
  }
141
213
 
142
214
  // To indicate that this track is requiring a tileset info
215
+ /** @type {t.TilesetInfo} */
216
+ // @ts-expect-error This has to be initialized to null
143
217
  this.tilesetInfo = null;
218
+ /** @type {null | string} */
219
+ this.tilesetInfoError = null;
144
220
  this.uuid = slugid.nice();
145
221
 
146
222
  // this needs to be above the tilesetInfo() call because if that
@@ -163,7 +239,31 @@ class TiledPixiTrack extends PixiTrack {
163
239
  this.dataFetcher.tilesetInfo((tilesetInfo, tilesetUid) => {
164
240
  if (!tilesetInfo) return;
165
241
 
166
- this.tilesetInfo = tilesetInfo;
242
+ if (isTilesetInfo(tilesetInfo)) {
243
+ this.tilesetInfo = tilesetInfo;
244
+
245
+ if (this.tilesetInfo.chromsizes) {
246
+ // We got chromosome info from the tileset info so let's parse it
247
+ // into an object we can use
248
+ this.chromInfo = parseChromsizesRows(this.tilesetInfo.chromsizes);
249
+ }
250
+ } else {
251
+ // no tileset info for this track
252
+ console.warn(
253
+ 'Error retrieving tilesetInfo:',
254
+ dataConfig,
255
+ tilesetInfo.error,
256
+ );
257
+
258
+ if (tilesetInfo.error) {
259
+ this.setError(tilesetInfo.error, 'dataFetcher.tilesetInfo');
260
+ }
261
+ // Fritz: Not sure why it's reset
262
+ // this.trackNotFoundText = '';
263
+ this.tilesetInfo = undefined;
264
+ return;
265
+ }
266
+
167
267
  // If the dataConfig contained a fileUrl, then
168
268
  // we need to update the tilesetUid based
169
269
  // on the registration of the fileUrl.
@@ -174,33 +274,17 @@ class TiledPixiTrack extends PixiTrack {
174
274
  this.tilesetUid = this.dataFetcher.dataConfig.tilesetUid;
175
275
  this.server = this.dataFetcher.dataConfig.server || 'unknown';
176
276
 
177
- if (this.tilesetInfo && this.tilesetInfo.chromsizes) {
277
+ if (this.tilesetInfo?.chromsizes) {
178
278
  this.chromInfo = parseChromsizesRows(this.tilesetInfo.chromsizes);
179
279
  }
180
280
 
181
- if ('error' in this.tilesetInfo) {
182
- // no tileset info for this track
183
- console.warn(
184
- 'Error retrieving tilesetInfo:',
185
- dataConfig,
186
- this.tilesetInfo.error,
187
- );
188
-
189
- // Fritz: Not sure why it's reset
190
- // this.trackNotFoundText = '';
191
- this.tilesetInfo = null;
192
-
193
- this.setError(this.tilesetInfo.error);
194
- return;
195
- }
196
-
197
- if (this.tilesetInfo.resolutions) {
281
+ if (isResolutionsTilesetInfo(this.tilesetInfo)) {
198
282
  this.maxZoom = this.tilesetInfo.resolutions.length;
199
283
  } else {
200
284
  this.maxZoom = +this.tilesetInfo.max_zoom;
201
285
  }
202
286
 
203
- if (this.options && this.options.maxZoom) {
287
+ if (this.options?.maxZoom) {
204
288
  if (this.options.maxZoom >= 0) {
205
289
  this.maxZoom = Math.min(this.options.maxZoom, this.maxZoom);
206
290
  } else {
@@ -210,11 +294,15 @@ class TiledPixiTrack extends PixiTrack {
210
294
 
211
295
  this.refreshTiles();
212
296
 
213
- if (handleTilesetInfoReceived) handleTilesetInfoReceived(tilesetInfo);
297
+ // Let this track know that tileset info was received
298
+ this.tilesetInfoReceived();
214
299
 
215
- if (!this.options) this.options = {};
300
+ // Let external listeners know that tileset info was received
301
+ handleTilesetInfoReceived?.(this.tilesetInfo);
216
302
 
217
- this.options.name = this.options.name || tilesetInfo.name;
303
+ // @ts-expect-error This should never happen since options is set in Track
304
+ this.options ??= {};
305
+ this.options.name = this.options.name || this.tilesetInfo.name;
218
306
 
219
307
  this.checkValueScaleLimits();
220
308
 
@@ -224,11 +312,23 @@ class TiledPixiTrack extends PixiTrack {
224
312
  });
225
313
  }
226
314
 
315
+ /**
316
+ * @param {string} error
317
+ * @param {string} source
318
+ */
319
+ setError(error, source) {
320
+ this.errorTexts[source] = error;
321
+
322
+ this.drawError();
323
+ }
324
+
325
+ /** @param {number | string} value */
227
326
  setFixedValueScaleMin(value) {
228
327
  if (!Number.isNaN(+value)) this.fixedValueScaleMin = +value;
229
328
  else this.fixedValueScaleMin = null;
230
329
  }
231
330
 
331
+ /** @param {number | string} value */
232
332
  setFixedValueScaleMax(value) {
233
333
  if (!Number.isNaN(+value)) this.fixedValueScaleMax = +value;
234
334
  else this.fixedValueScaleMax = null;
@@ -276,6 +376,11 @@ class TiledPixiTrack extends PixiTrack {
276
376
  this.listeners[event].push(callback);
277
377
  }
278
378
 
379
+ /**
380
+ * @param {string} event The event to listen for
381
+ * @param {function} callback The callback to call when the event occurs. The
382
+ * parameters for the event depend on the event called.
383
+ */
279
384
  off(event, callback) {
280
385
  const id = this.listeners[event].indexOf(callback);
281
386
  if (id === -1 || id >= this.listeners[event].length) return;
@@ -283,6 +388,7 @@ class TiledPixiTrack extends PixiTrack {
283
388
  this.listeners[event].splice(id, 1);
284
389
  }
285
390
 
391
+ /** @param {Options} options */
286
392
  rerender(options) {
287
393
  super.rerender(options);
288
394
 
@@ -294,13 +400,13 @@ class TiledPixiTrack extends PixiTrack {
294
400
 
295
401
  this.checkValueScaleLimits();
296
402
 
297
- if (this.tilesetInfo.resolutions) {
403
+ if (isResolutionsTilesetInfo(this.tilesetInfo)) {
298
404
  this.maxZoom = this.tilesetInfo.resolutions.length;
299
405
  } else {
300
406
  this.maxZoom = +this.tilesetInfo.max_zoom;
301
407
  }
302
408
 
303
- if (this.options && this.options.maxZoom) {
409
+ if (this.options?.maxZoom) {
304
410
  if (this.options.maxZoom >= 0) {
305
411
  this.maxZoom = Math.min(this.options.maxZoom, this.maxZoom);
306
412
  } else {
@@ -309,6 +415,13 @@ class TiledPixiTrack extends PixiTrack {
309
415
  }
310
416
  }
311
417
 
418
+ /** Called when tileset info is received. The actual tileset info
419
+ * can be found in this.tilesetInfo.
420
+ *
421
+ * Child tracks can implement this method.
422
+ */
423
+ tilesetInfoReceived() {}
424
+
312
425
  /**
313
426
  * Return the set of ids of all tiles which are both visible and fetched.
314
427
  */
@@ -325,12 +438,13 @@ class TiledPixiTrack extends PixiTrack {
325
438
  /**
326
439
  * Set which tiles are visible right now.
327
440
  *
328
- * @param tiles: A set of tiles which will be considered the currently visible
329
- * tile positions.
441
+ * @param {Array<TilePositionArrayObject>} tilePositions - A set of tiles which will be considered the currently visible tile positions.
330
442
  */
331
443
  setVisibleTiles(tilePositions) {
332
444
  this.visibleTiles = tilePositions.map((x) => ({
445
+ // @ts-expect-error Classes which extend TiledPixiTrack have this
333
446
  tileId: this.tileToLocalId(x),
447
+ // @ts-expect-error Classes which extend TiledPixiTrack have this
334
448
  remoteId: this.tileToRemoteId(x),
335
449
  mirrored: x.mirrored,
336
450
  }));
@@ -339,6 +453,7 @@ class TiledPixiTrack extends PixiTrack {
339
453
  }
340
454
 
341
455
  removeOldTiles() {
456
+ // @ts-expect-error Classes which extend TiledPixiTrack have this
342
457
  this.calculateVisibleTiles();
343
458
 
344
459
  // tiles that are fetched
@@ -358,6 +473,7 @@ class TiledPixiTrack extends PixiTrack {
358
473
  return;
359
474
  }
360
475
 
476
+ // @ts-expect-error Classes which extend TiledPixiTrack have this
361
477
  this.calculateVisibleTiles();
362
478
 
363
479
  // tiles that are fetched
@@ -377,6 +493,7 @@ class TiledPixiTrack extends PixiTrack {
377
493
  this.fetchNewTiles(toFetch);
378
494
  }
379
495
 
496
+ /** @param {Tile} tile */
380
497
  parentInFetched(tile) {
381
498
  const uid = tile.tileData.tilesetUid;
382
499
  let zl = tile.tileData.zoomLevel;
@@ -395,6 +512,7 @@ class TiledPixiTrack extends PixiTrack {
395
512
  return false;
396
513
  }
397
514
 
515
+ /** @param {Tile} tile */
398
516
  parentTileId(tile) {
399
517
  const parentZoomLevel = tile.tileData.zoomLevel - 1;
400
518
  const parentPos = tile.tileData.tilePos.map((x) => Math.floor(x / 2));
@@ -406,7 +524,7 @@ class TiledPixiTrack extends PixiTrack {
406
524
  /**
407
525
  * Remove obsolete tiles
408
526
  *
409
- * @param toRemoveIds: An array of tile ids to remove from the list of fetched tiles.
527
+ * @param {Array<string>} toRemoveIds: An array of tile ids to remove from the list of fetched tiles.
410
528
  */
411
529
  removeTiles(toRemoveIds) {
412
530
  // if there's nothing to remove, don't bother doing anything
@@ -434,10 +552,15 @@ class TiledPixiTrack extends PixiTrack {
434
552
  this.draw();
435
553
  }
436
554
 
555
+ /**
556
+ * @param {t.Scale} newXScale
557
+ * @param {t.Scale} newYScale
558
+ */
437
559
  zoomed(newXScale, newYScale, k = 1, tx = 0, ty = 0) {
438
560
  this.xScale(newXScale);
439
561
  this.yScale(newYScale);
440
562
 
563
+ // @ts-expect-error Not sure why this is called without an argument
441
564
  this.refreshTilesDebounced();
442
565
 
443
566
  this.pMobile.position.x = tx;
@@ -447,12 +570,14 @@ class TiledPixiTrack extends PixiTrack {
447
570
  this.pMobile.scale.y = 1;
448
571
  }
449
572
 
573
+ /** @param {[number, number]} newPosition */
450
574
  setPosition(newPosition) {
451
575
  super.setPosition(newPosition);
452
576
 
453
577
  // this.draw();
454
578
  }
455
579
 
580
+ /** @param {[number, number]} newDimensions */
456
581
  setDimensions(newDimensions) {
457
582
  super.setDimensions(newDimensions);
458
583
 
@@ -485,6 +610,7 @@ class TiledPixiTrack extends PixiTrack {
485
610
  */
486
611
  allTilesLoaded() {}
487
612
 
613
+ /** @param {number} [_] - Optional value to set */
488
614
  minValue(_) {
489
615
  if (_) {
490
616
  this.scale.minValue = _;
@@ -495,6 +621,7 @@ class TiledPixiTrack extends PixiTrack {
495
621
  : this.scale.minValue;
496
622
  }
497
623
 
624
+ /** @param {number} [_] - Optional value to set */
498
625
  maxValue(_) {
499
626
  if (_) {
500
627
  this.scale.maxValue = _;
@@ -517,7 +644,11 @@ class TiledPixiTrack extends PixiTrack {
517
644
  return this.scale.maxRawValue;
518
645
  }
519
646
 
520
- initTile(/* tile */) {
647
+ /** @param {Tile} tile */
648
+ initTile(tile) {
649
+ if (!tile.tileData?.dense) {
650
+ return;
651
+ }
521
652
  // create the tile
522
653
  // should be overwritten by child classes
523
654
  this.scale.minRawValue = this.continuousScaling
@@ -531,9 +662,11 @@ class TiledPixiTrack extends PixiTrack {
531
662
  this.scale.maxValue = this.scale.maxRawValue;
532
663
  }
533
664
 
534
- updateTile(/* tile */) {}
665
+ /** @param {Tile} tile */
666
+ updateTile(tile) {}
535
667
 
536
- destroyTile(/* tile */) {
668
+ /** @param {Tile} tile */
669
+ destroyTile(tile) {
537
670
  // remove all data structures needed to draw this tile
538
671
  }
539
672
 
@@ -596,6 +729,20 @@ class TiledPixiTrack extends PixiTrack {
596
729
  }
597
730
  }
598
731
 
732
+ /**
733
+ * @typedef TiledAreaTile
734
+ * @property {string} tileId
735
+ * @property {string} type
736
+ * @property {unknown} data
737
+ */
738
+
739
+ /**
740
+ *
741
+ * @param {TiledAreaTile} tile A tile returned by a TiledArea.
742
+ * @param {function} dataLoader A function for extracting drawable data from a tile. This
743
+ * usually means differentiating the between dense and sparse tiles and putting the data into an array.
744
+ * @returns
745
+ */
599
746
  loadTileData(tile, dataLoader) {
600
747
  /**
601
748
  * Extract drawable data from a tile loaded by a generic tile loader
@@ -607,17 +754,20 @@ class TiledPixiTrack extends PixiTrack {
607
754
  */
608
755
 
609
756
  // see if the data is already cached
757
+ // @ts-expect-error this.lruCache exists in classes that extend this one
610
758
  let loadedTileData = this.lruCache.get(tile.tileId);
611
759
 
612
760
  // if not, load it and put it in the cache
613
761
  if (!loadedTileData) {
614
762
  loadedTileData = dataLoader(tile.data, tile.type);
763
+ // @ts-expect-error this.lruCache exists in classes that extend this one
615
764
  this.lruCache.put(tile.tileId, loadedTileData);
616
765
  }
617
766
 
618
767
  return loadedTileData;
619
768
  }
620
769
 
770
+ /** @param {Pick<Tile,'remoteId'>[]} toFetch */
621
771
  fetchNewTiles(toFetch) {
622
772
  this._checkForErrors();
623
773
  this.draw();
@@ -635,6 +785,7 @@ class TiledPixiTrack extends PixiTrack {
635
785
  /**
636
786
  * We've gotten a bunch of tiles from the server in
637
787
  * response to a request from fetchTiles.
788
+ * @param {Object<string, import('./data-fetchers/DataFetcher').DividedTile | Tile | TilePositionArrayObject>} loadedTiles
638
789
  */
639
790
  receivedTiles(loadedTiles) {
640
791
  for (let i = 0; i < this.visibleTiles.length; i++) {
@@ -645,6 +796,7 @@ class TiledPixiTrack extends PixiTrack {
645
796
  if (this.visibleTiles[i].remoteId in loadedTiles) {
646
797
  if (!(tileId in this.fetchedTiles)) {
647
798
  // this tile may have graphics associated with it
799
+ // @ts-expect-error more properties will be added to this.fetchedTiles[tileId] later (such as by synchronizeTilesAndGraphics())
648
800
  this.fetchedTiles[tileId] = this.visibleTiles[i];
649
801
  }
650
802
 
@@ -654,14 +806,17 @@ class TiledPixiTrack extends PixiTrack {
654
806
  // object but an object array...
655
807
  if (Array.isArray(loadedTiles[this.visibleTiles[i].remoteId])) {
656
808
  const tileData = loadedTiles[this.visibleTiles[i].remoteId];
809
+ // @ts-expect-error this.fetchedTiles[tileId].tileData will get more defined in the next lines
657
810
  this.fetchedTiles[tileId].tileData = [...tileData];
658
811
  // Fritz: this is sooo hacky... we should really not use object arrays
659
812
  Object.keys(tileData)
660
813
  .filter((key) => Number.isNaN(+key))
661
814
  .forEach((key) => {
815
+ // @ts-expect-error Since tileData is an array, the properties have to be copied over manually
662
816
  this.fetchedTiles[tileId].tileData[key] = tileData[key];
663
817
  });
664
818
  } else {
819
+ // @ts-expect-error The object doesn't at this point have all of the properties that it will have later
665
820
  this.fetchedTiles[tileId].tileData = {
666
821
  ...loadedTiles[this.visibleTiles[i].remoteId],
667
822
  };
@@ -700,12 +855,15 @@ class TiledPixiTrack extends PixiTrack {
700
855
 
701
856
  // Let HiGlass know we need to re-render
702
857
  // check if the value scale has changed
858
+ // @ts-expect-error This is defined by classes which extend this one
703
859
  if (this.valueScale) {
704
860
  if (
705
861
  !this.prevValueScale ||
862
+ // @ts-expect-error This is defined by classes which extend this one
706
863
  JSON.stringify(this.valueScale.domain()) !==
707
864
  JSON.stringify(this.prevValueScale.domain())
708
865
  ) {
866
+ // @ts-expect-error This is defined by classes which extend this one
709
867
  this.prevValueScale = this.valueScale.copy();
710
868
 
711
869
  if (this.onValueScaleChanged) {
@@ -720,18 +878,13 @@ class TiledPixiTrack extends PixiTrack {
720
878
  // 1. Check if all visible tiles are loaded
721
879
  // 2. If `true` then send out event
722
880
  if (this.areAllVisibleTilesLoaded()) {
723
- if (this.pubSub) {
724
- this.pubSub.publish('TiledPixiTrack.tilesLoaded', { uuid: this.uuid });
725
- }
881
+ this.pubSub?.publish('TiledPixiTrack.tilesLoaded', { uuid: this.uuid });
726
882
  }
727
883
  }
728
884
 
729
885
  _checkForErrors() {
730
886
  const errors = Object.values(this.fetchedTiles)
731
- .map(
732
- (x) =>
733
- x.tileData && x.tileData.error && `${x.tileId}: ${x.tileData.error}`,
734
- )
887
+ .map((x) => x.tileData?.error && `${x.tileId}: ${x.tileData.error}`)
735
888
  .filter((x) => x);
736
889
 
737
890
  if (errors.length) {
@@ -756,26 +909,23 @@ class TiledPixiTrack extends PixiTrack {
756
909
  if (this.dataFetcher.tilesetInfoLoading) {
757
910
  this.trackNotFoundText.text = 'Loading...';
758
911
  } else {
759
- this.trackNotFoundText.text = `Tileset info not found. Server: [${this.server}] tilesetUid: [${this.tilesetUid}]`;
912
+ const server = this.dataFetcher.dataConfig.server || 'unknown';
913
+ const tilesetUid = this.dataFetcher.dataConfig.tilesetUid;
914
+ this.trackNotFoundText.text = `Tileset info not found. Server: [${server}] tilesetUid: [${tilesetUid}]`;
760
915
  }
761
916
 
762
917
  [this.trackNotFoundText.x, this.trackNotFoundText.y] = this.position;
763
-
764
- if (this.flipText) {
765
- this.trackNotFoundText.anchor.x = 1;
766
- this.trackNotFoundText.scale.x = -1;
767
- }
918
+ /*
919
+ if (this.flipText)
920
+ this.trackNotFoundText.scale.x = -1;
921
+ */
768
922
 
769
923
  this.trackNotFoundText.visible = true;
770
924
  } else {
771
925
  this.trackNotFoundText.visible = false;
772
926
  }
773
927
 
774
- if (this.pubSub) {
775
- this.pubSub.publish('TiledPixiTrack.tilesDrawnStart', {
776
- uuid: this.uuid,
777
- });
778
- }
928
+ this.pubSub?.publish('TiledPixiTrack.tilesDrawnStart', { uuid: this.uuid });
779
929
 
780
930
  this._checkForErrors();
781
931
 
@@ -784,17 +934,15 @@ class TiledPixiTrack extends PixiTrack {
784
934
  Object.keys(this.fetchedTiles).forEach((tilesetUid) => {
785
935
  this.drawTile(this.fetchedTiles[tilesetUid]);
786
936
  });
787
- // console.log('errors:', errors);
788
937
 
789
- if (this.pubSub) {
790
- this.pubSub.publish('TiledPixiTrack.tilesDrawnEnd', { uuid: this.uuid });
791
- }
938
+ this.pubSub?.publish('TiledPixiTrack.tilesDrawnEnd', { uuid: this.uuid });
792
939
  }
793
940
 
794
941
  /**
795
942
  * Draw a tile on some graphics
943
+ * @param {Tile} tile
796
944
  */
797
- drawTile(/* tileData, graphics */) {}
945
+ drawTile(tile) {}
798
946
 
799
947
  calculateMedianVisibleValue() {
800
948
  if (this.areAllVisibleTilesLoaded()) {
@@ -807,7 +955,7 @@ class TiledPixiTrack extends PixiTrack {
807
955
  visibleAndFetchedIds = Object.keys(this.fetchedTiles);
808
956
  }
809
957
 
810
- const values = []
958
+ const values = /** @type {Array<number>} */ ([])
811
959
  .concat(
812
960
  ...visibleAndFetchedIds
813
961
  .filter((x) => this.fetchedTiles[x].tileData.dense)
@@ -820,7 +968,7 @@ class TiledPixiTrack extends PixiTrack {
820
968
  }
821
969
 
822
970
  allVisibleValues() {
823
- return [].concat(
971
+ return /** @type {Array<number>} */ ([]).concat(
824
972
  ...this.visibleAndFetchedIds().map((x) =>
825
973
  Array.from(this.fetchedTiles[x].tileData.dense),
826
974
  ),
@@ -841,6 +989,7 @@ class TiledPixiTrack extends PixiTrack {
841
989
  visibleAndFetchedIds = Object.keys(this.fetchedTiles);
842
990
  }
843
991
 
992
+ /** @type {number | null} */
844
993
  let min = Math.min(
845
994
  ...visibleAndFetchedIds.map(
846
995
  (x) => this.fetchedTiles[x].tileData.minNonZero,
@@ -871,6 +1020,7 @@ class TiledPixiTrack extends PixiTrack {
871
1020
  visibleAndFetchedIds = Object.keys(this.fetchedTiles);
872
1021
  }
873
1022
 
1023
+ /** @type {number | null} */
874
1024
  let max = Math.max(
875
1025
  ...visibleAndFetchedIds.map(
876
1026
  (x) => this.fetchedTiles[x].tileData.maxNonZero,
@@ -887,30 +1037,20 @@ class TiledPixiTrack extends PixiTrack {
887
1037
  return this.valueScaleMax !== null ? this.valueScaleMax : max;
888
1038
  }
889
1039
 
1040
+ /** @typedef {import('d3-scale').ScaleQuantile<number, never> & { ticks?: (count: number) => number[] }} ScaleQuantile */
1041
+
1042
+ /**
1043
+ * Create a value scale that will be used to position values
1044
+ * along the y axis.
1045
+ * @param {number} minValue The minimum value of the data
1046
+ * @param {number} medianValue The median value of the data. Potentially used for adding a pseudocount
1047
+ * @param {number} maxValue The maximum value of the data
1048
+ * @param {number} [inMargin] A number of pixels to be left free on the top and bottom
1049
+ * of the track. For example if the glyphs have a certain
1050
+ * width and we want all of them to fit into the space
1051
+ * @returns {[t.Scale | ScaleQuantile, number]}
1052
+ */
890
1053
  makeValueScale(minValue, medianValue, maxValue, inMargin) {
891
- /*
892
- * Create a value scale that will be used to position values
893
- * along the y axis.
894
- *
895
- * Parameters
896
- * ----------
897
- * minValue: number
898
- * The minimum value of the data
899
- * medianValue: number
900
- * The median value of the data. Potentially used for adding
901
- * a pseudocount
902
- * maxValue: number
903
- * The maximum value of the data
904
- * margin: number
905
- * A number of pixels to be left free on the top and bottom
906
- * of the track. For example if the glyphs have a certain
907
- * width and we want all of them to fit into the space.
908
- *
909
- * Returns
910
- * -------
911
- * valueScale: d3.scale
912
- * A d3 value scale
913
- */
914
1054
  let valueScale = null;
915
1055
  let offsetValue = 0;
916
1056
 
@@ -941,12 +1081,13 @@ class TiledPixiTrack extends PixiTrack {
941
1081
  // .base(Math.E)
942
1082
  .domain([offsetValue, maxValue + offsetValue])
943
1083
  // .domain([offsetValue, this.maxValue()])
944
- .range([minDimension, maxDimension]);
1084
+ .range([maxDimension, minDimension]);
945
1085
 
946
1086
  // pseudocount = offsetValue;
947
1087
  } else if (this.options.valueScaling === 'quantile') {
948
1088
  const start = this.dimensions[1] - margin;
949
1089
  const end = margin;
1090
+ /** @type {ScaleQuantile} */
950
1091
  const quantScale = scaleQuantile()
951
1092
  .domain(this.allVisibleValues())
952
1093
  .range(range(start, end, (end - start) / 256));
@@ -957,6 +1098,7 @@ class TiledPixiTrack extends PixiTrack {
957
1098
  const start = this.dimensions[1] - margin;
958
1099
  const end = margin;
959
1100
  const s = new Set(this.allVisibleValues());
1101
+ /** @type {ScaleQuantile} */
960
1102
  const quantScale = scaleQuantile()
961
1103
  .domain([...s])
962
1104
  .range(range(start, end, (end - start) / 256));