@jbrowse/plugin-linear-genome-view 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/BaseLinearDisplay/components/BaseLinearDisplay.d.ts +2 -3
  2. package/dist/BaseLinearDisplay/components/BaseLinearDisplay.js +4 -4
  3. package/dist/BaseLinearDisplay/components/BaseLinearDisplay.js.map +1 -1
  4. package/dist/BaseLinearDisplay/components/LinearBlocks.d.ts +1 -3
  5. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +8 -43
  6. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js.map +1 -1
  7. package/dist/BaseLinearDisplay/components/TooLargeMessage.d.ts +2 -2
  8. package/dist/BaseLinearDisplay/components/TooLargeMessage.js +4 -8
  9. package/dist/BaseLinearDisplay/components/TooLargeMessage.js.map +1 -1
  10. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +15 -25
  11. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +96 -144
  12. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js.map +1 -1
  13. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +4 -5
  14. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js.map +1 -1
  15. package/dist/BaseLinearDisplay/models/util.d.ts +4 -0
  16. package/dist/BaseLinearDisplay/models/util.js +35 -3
  17. package/dist/BaseLinearDisplay/models/util.js.map +1 -1
  18. package/dist/LaunchLinearGenomeView/index.js +1 -1
  19. package/dist/LaunchLinearGenomeView/index.js.map +1 -1
  20. package/dist/LinearBareDisplay/index.d.ts +2 -3
  21. package/dist/LinearBareDisplay/index.js +5 -2
  22. package/dist/LinearBareDisplay/index.js.map +1 -1
  23. package/dist/LinearBareDisplay/model.d.ts +13 -21
  24. package/dist/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  25. package/dist/LinearBasicDisplay/components/SetMaxHeight.js +2 -5
  26. package/dist/LinearBasicDisplay/components/SetMaxHeight.js.map +1 -1
  27. package/dist/LinearBasicDisplay/index.d.ts +2 -3
  28. package/dist/LinearBasicDisplay/index.js +5 -3
  29. package/dist/LinearBasicDisplay/index.js.map +1 -1
  30. package/dist/LinearBasicDisplay/model.d.ts +14 -25
  31. package/dist/LinearBasicDisplay/model.js.map +1 -1
  32. package/dist/LinearGenomeView/components/ExportSvgDialog.js +1 -1
  33. package/dist/LinearGenomeView/components/ExportSvgDialog.js.map +1 -1
  34. package/dist/LinearGenomeView/components/ImportForm.d.ts +2 -2
  35. package/dist/LinearGenomeView/components/ImportForm.js +15 -19
  36. package/dist/LinearGenomeView/components/ImportForm.js.map +1 -1
  37. package/dist/LinearGenomeView/components/OverviewRubberband.d.ts +3 -4
  38. package/dist/LinearGenomeView/components/OverviewRubberband.js +8 -11
  39. package/dist/LinearGenomeView/components/OverviewRubberband.js.map +1 -1
  40. package/dist/LinearGenomeView/components/OverviewScalebar.d.ts +4 -5
  41. package/dist/LinearGenomeView/components/OverviewScalebar.js +5 -5
  42. package/dist/LinearGenomeView/components/OverviewScalebar.js.map +1 -1
  43. package/dist/LinearGenomeView/components/RefNameAutocomplete.d.ts +2 -1
  44. package/dist/LinearGenomeView/components/RefNameAutocomplete.js +38 -40
  45. package/dist/LinearGenomeView/components/RefNameAutocomplete.js.map +1 -1
  46. package/dist/LinearGenomeView/components/RubberbandSpan.d.ts +2 -2
  47. package/dist/LinearGenomeView/components/RubberbandSpan.js +2 -16
  48. package/dist/LinearGenomeView/components/RubberbandSpan.js.map +1 -1
  49. package/dist/LinearGenomeView/components/SearchBox.js +3 -3
  50. package/dist/LinearGenomeView/components/SearchBox.js.map +1 -1
  51. package/dist/LinearGenomeView/components/TrackLabel.js +3 -3
  52. package/dist/LinearGenomeView/components/TrackLabel.js.map +1 -1
  53. package/dist/LinearGenomeView/components/TracksContainer.d.ts +2 -3
  54. package/dist/LinearGenomeView/components/TracksContainer.js +9 -8
  55. package/dist/LinearGenomeView/components/TracksContainer.js.map +1 -1
  56. package/dist/LinearGenomeView/components/hooks.d.ts +6 -1
  57. package/dist/LinearGenomeView/components/hooks.js +1 -1
  58. package/dist/LinearGenomeView/components/hooks.js.map +1 -1
  59. package/dist/LinearGenomeView/index.js +8 -6
  60. package/dist/LinearGenomeView/index.js.map +1 -1
  61. package/dist/LinearGenomeView/model.d.ts +9 -11
  62. package/dist/LinearGenomeView/model.js +28 -31
  63. package/dist/LinearGenomeView/model.js.map +1 -1
  64. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.d.ts +2 -3
  65. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +6 -5
  66. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js.map +1 -1
  67. package/dist/LinearGenomeView/svgcomponents/SVGTrackLabel.js +2 -1
  68. package/dist/LinearGenomeView/svgcomponents/SVGTrackLabel.js.map +1 -1
  69. package/dist/LinearGenomeView/util.js +1 -1
  70. package/dist/LinearGenomeView/util.js.map +1 -1
  71. package/dist/index.d.ts +69 -95
  72. package/dist/index.js +21 -17
  73. package/dist/index.js.map +1 -1
  74. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.d.ts +2 -3
  75. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.js +2 -3
  76. package/esm/BaseLinearDisplay/components/BaseLinearDisplay.js.map +1 -1
  77. package/esm/BaseLinearDisplay/components/LinearBlocks.d.ts +1 -3
  78. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +8 -20
  79. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js.map +1 -1
  80. package/esm/BaseLinearDisplay/components/TooLargeMessage.d.ts +2 -2
  81. package/esm/BaseLinearDisplay/components/TooLargeMessage.js +4 -8
  82. package/esm/BaseLinearDisplay/components/TooLargeMessage.js.map +1 -1
  83. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +15 -25
  84. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js +95 -143
  85. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js.map +1 -1
  86. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js +4 -5
  87. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js.map +1 -1
  88. package/esm/BaseLinearDisplay/models/util.d.ts +4 -0
  89. package/esm/BaseLinearDisplay/models/util.js +32 -2
  90. package/esm/BaseLinearDisplay/models/util.js.map +1 -1
  91. package/esm/LaunchLinearGenomeView/index.js +1 -1
  92. package/esm/LaunchLinearGenomeView/index.js.map +1 -1
  93. package/esm/LinearBareDisplay/index.d.ts +2 -3
  94. package/esm/LinearBareDisplay/index.js +3 -1
  95. package/esm/LinearBareDisplay/index.js.map +1 -1
  96. package/esm/LinearBareDisplay/model.d.ts +13 -21
  97. package/esm/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  98. package/esm/LinearBasicDisplay/components/SetMaxHeight.js +2 -5
  99. package/esm/LinearBasicDisplay/components/SetMaxHeight.js.map +1 -1
  100. package/esm/LinearBasicDisplay/index.d.ts +2 -3
  101. package/esm/LinearBasicDisplay/index.js +3 -2
  102. package/esm/LinearBasicDisplay/index.js.map +1 -1
  103. package/esm/LinearBasicDisplay/model.d.ts +14 -25
  104. package/esm/LinearBasicDisplay/model.js.map +1 -1
  105. package/esm/LinearGenomeView/components/ExportSvgDialog.js +1 -1
  106. package/esm/LinearGenomeView/components/ExportSvgDialog.js.map +1 -1
  107. package/esm/LinearGenomeView/components/ImportForm.d.ts +2 -2
  108. package/esm/LinearGenomeView/components/ImportForm.js +16 -20
  109. package/esm/LinearGenomeView/components/ImportForm.js.map +1 -1
  110. package/esm/LinearGenomeView/components/OverviewRubberband.d.ts +3 -4
  111. package/esm/LinearGenomeView/components/OverviewRubberband.js +8 -11
  112. package/esm/LinearGenomeView/components/OverviewRubberband.js.map +1 -1
  113. package/esm/LinearGenomeView/components/OverviewScalebar.d.ts +4 -5
  114. package/esm/LinearGenomeView/components/OverviewScalebar.js +4 -4
  115. package/esm/LinearGenomeView/components/OverviewScalebar.js.map +1 -1
  116. package/esm/LinearGenomeView/components/RefNameAutocomplete.d.ts +2 -1
  117. package/esm/LinearGenomeView/components/RefNameAutocomplete.js +39 -41
  118. package/esm/LinearGenomeView/components/RefNameAutocomplete.js.map +1 -1
  119. package/esm/LinearGenomeView/components/RubberbandSpan.d.ts +2 -2
  120. package/esm/LinearGenomeView/components/RubberbandSpan.js +3 -18
  121. package/esm/LinearGenomeView/components/RubberbandSpan.js.map +1 -1
  122. package/esm/LinearGenomeView/components/SearchBox.js +3 -3
  123. package/esm/LinearGenomeView/components/SearchBox.js.map +1 -1
  124. package/esm/LinearGenomeView/components/TrackLabel.js +3 -3
  125. package/esm/LinearGenomeView/components/TrackLabel.js.map +1 -1
  126. package/esm/LinearGenomeView/components/TracksContainer.d.ts +2 -3
  127. package/esm/LinearGenomeView/components/TracksContainer.js +9 -8
  128. package/esm/LinearGenomeView/components/TracksContainer.js.map +1 -1
  129. package/esm/LinearGenomeView/components/hooks.d.ts +6 -1
  130. package/esm/LinearGenomeView/components/hooks.js +1 -1
  131. package/esm/LinearGenomeView/components/hooks.js.map +1 -1
  132. package/esm/LinearGenomeView/index.js +8 -6
  133. package/esm/LinearGenomeView/index.js.map +1 -1
  134. package/esm/LinearGenomeView/model.d.ts +9 -11
  135. package/esm/LinearGenomeView/model.js +22 -26
  136. package/esm/LinearGenomeView/model.js.map +1 -1
  137. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.d.ts +2 -3
  138. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +3 -3
  139. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js.map +1 -1
  140. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js +2 -1
  141. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js.map +1 -1
  142. package/esm/LinearGenomeView/util.js +1 -1
  143. package/esm/LinearGenomeView/util.js.map +1 -1
  144. package/esm/index.d.ts +69 -95
  145. package/esm/index.js +9 -6
  146. package/esm/index.js.map +1 -1
  147. package/package.json +2 -2
  148. package/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +4 -3
  149. package/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx +8 -28
  150. package/src/BaseLinearDisplay/components/TooLargeMessage.tsx +8 -10
  151. package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +134 -196
  152. package/src/BaseLinearDisplay/models/serverSideRenderedBlock.ts +6 -5
  153. package/src/BaseLinearDisplay/models/util.ts +39 -2
  154. package/src/LaunchLinearGenomeView/index.ts +1 -1
  155. package/src/LinearBareDisplay/index.ts +3 -1
  156. package/src/LinearBasicDisplay/components/SetMaxHeight.tsx +3 -7
  157. package/src/LinearBasicDisplay/index.ts +3 -2
  158. package/src/LinearBasicDisplay/model.ts +1 -1
  159. package/src/LinearGenomeView/components/ExportSvgDialog.tsx +1 -1
  160. package/src/LinearGenomeView/components/ImportForm.tsx +17 -26
  161. package/src/LinearGenomeView/components/OverviewRubberband.tsx +40 -49
  162. package/src/LinearGenomeView/components/OverviewScalebar.tsx +4 -4
  163. package/src/LinearGenomeView/components/RefNameAutocomplete.tsx +55 -55
  164. package/src/LinearGenomeView/components/RubberbandSpan.tsx +6 -23
  165. package/src/LinearGenomeView/components/SearchBox.tsx +3 -2
  166. package/src/LinearGenomeView/components/TrackLabel.tsx +74 -71
  167. package/src/LinearGenomeView/components/TracksContainer.tsx +8 -8
  168. package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.tsx.snap +7 -11
  169. package/src/LinearGenomeView/components/hooks.ts +7 -1
  170. package/src/LinearGenomeView/index.test.ts +3 -8
  171. package/src/LinearGenomeView/index.ts +8 -9
  172. package/src/LinearGenomeView/model.ts +31 -33
  173. package/src/LinearGenomeView/svgcomponents/SVGLinearGenomeView.tsx +5 -5
  174. package/src/LinearGenomeView/svgcomponents/SVGTrackLabel.tsx +2 -0
  175. package/src/LinearGenomeView/util.ts +1 -1
  176. package/src/index.ts +21 -31
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import React from 'react'
3
+ import { ThemeOptions } from '@mui/material'
3
4
  import { BaseDisplay } from '@jbrowse/core/pluggableElementTypes/models'
4
5
  import { getConf } from '@jbrowse/core/configuration'
5
6
  import { MenuItem } from '@jbrowse/core/ui'
@@ -19,10 +20,7 @@ import { Stats } from '@jbrowse/core/data_adapters/BaseAdapter'
19
20
  import { BaseBlock } from '@jbrowse/core/util/blockTypes'
20
21
  import { Region } from '@jbrowse/core/util/types'
21
22
  import CompositeMap from '@jbrowse/core/util/compositeMap'
22
- import {
23
- getParentRenderProps,
24
- getRpcSessionId,
25
- } from '@jbrowse/core/util/tracks'
23
+ import { getParentRenderProps } from '@jbrowse/core/util/tracks'
26
24
  import { autorun } from 'mobx'
27
25
  import { addDisposer, isAlive, types, Instance } from 'mobx-state-tree'
28
26
 
@@ -34,7 +32,7 @@ import { LinearGenomeViewModel, ExportSvgOptions } from '../../LinearGenomeView'
34
32
  import { Tooltip } from '../components/BaseLinearDisplay'
35
33
  import TooLargeMessage from '../components/TooLargeMessage'
36
34
  import BlockState, { renderBlockData } from './serverSideRenderedBlock'
37
- import { ThemeOptions } from '@mui/material'
35
+ import { getId, getDisplayStr, estimateRegionsStatsPre } from './util'
38
36
 
39
37
  type LGV = LinearGenomeViewModel
40
38
 
@@ -46,26 +44,8 @@ export interface Layout {
46
44
  name: string
47
45
  }
48
46
 
49
- // stabilize clipid under test for snapshot
50
- function getId(id: string, index: number) {
51
- const isJest = typeof jest === 'undefined'
52
- return `clip-${isJest ? id : 'jest'}-${index}`
53
- }
54
-
55
47
  type LayoutRecord = [number, number, number, number]
56
48
 
57
- function getDisplayStr(totalBytes: number) {
58
- let displayBp
59
- if (Math.floor(totalBytes / 1000000) > 0) {
60
- displayBp = `${parseFloat((totalBytes / 1000000).toPrecision(3))} Mb`
61
- } else if (Math.floor(totalBytes / 1000) > 0) {
62
- displayBp = `${parseFloat((totalBytes / 1000).toPrecision(3))} Kb`
63
- } else {
64
- displayBp = `${Math.floor(totalBytes)} bytes`
65
- }
66
- return displayBp
67
- }
68
-
69
49
  const minDisplayHeight = 20
70
50
 
71
51
  /**
@@ -109,12 +89,12 @@ function stateModelFactory() {
109
89
  message: '',
110
90
  featureIdUnderMouse: undefined as undefined | string,
111
91
  contextMenuFeature: undefined as undefined | Feature,
112
- estimatedRegionStatsP: undefined as undefined | Promise<Stats>,
113
- estimatedRegionStats: undefined as undefined | Stats,
92
+ estimatedRegionsStatsP: undefined as undefined | Promise<Stats>,
93
+ estimatedRegionsStats: undefined as undefined | Stats,
114
94
  }))
115
95
  .views(self => ({
116
96
  get height() {
117
- return self.heightPreConfig ?? getConf(self, 'height')
97
+ return self.heightPreConfig ?? (getConf(self, 'height') as number)
118
98
  },
119
99
  /**
120
100
  * #getter
@@ -184,7 +164,7 @@ function stateModelFactory() {
184
164
  get features() {
185
165
  const featureMaps = []
186
166
  for (const block of self.blockState.values()) {
187
- if (block && block.features) {
167
+ if (block?.features) {
188
168
  featureMaps.push(block.features)
189
169
  }
190
170
  }
@@ -202,7 +182,11 @@ function stateModelFactory() {
202
182
  /**
203
183
  * #getter
204
184
  */
205
- getFeatureOverlapping(blockKey: string, x: number, y: number) {
185
+ getFeatureOverlapping(
186
+ blockKey: string,
187
+ x: number,
188
+ y: number,
189
+ ): string | undefined {
206
190
  return self.blockState.get(blockKey)?.layout?.getByCoord(x, y)
207
191
  },
208
192
 
@@ -231,7 +215,7 @@ function stateModelFactory() {
231
215
  * #getter
232
216
  */
233
217
  get currentBytesRequested() {
234
- return self.estimatedRegionStats?.bytes || 0
218
+ return self.estimatedRegionsStats?.bytes || 0
235
219
  },
236
220
 
237
221
  /**
@@ -239,7 +223,7 @@ function stateModelFactory() {
239
223
  */
240
224
  get currentFeatureScreenDensity() {
241
225
  const view = getContainingView(self) as LGV
242
- return (self.estimatedRegionStats?.featureDensity || 0) * view.bpPerPx
226
+ return (self.estimatedRegionsStats?.featureDensity || 0) * view.bpPerPx
243
227
  },
244
228
 
245
229
  /**
@@ -252,7 +236,7 @@ function stateModelFactory() {
252
236
  * #getter
253
237
  */
254
238
  get estimatedStatsReady() {
255
- return !!self.estimatedRegionStats
239
+ return !!self.estimatedRegionsStats || !!self.userBpPerPxLimit
256
240
  },
257
241
 
258
242
  /**
@@ -261,7 +245,7 @@ function stateModelFactory() {
261
245
  get maxAllowableBytes() {
262
246
  return (
263
247
  self.userByteSizeLimit ||
264
- self.estimatedRegionStats?.fetchSizeLimit ||
248
+ self.estimatedRegionsStats?.fetchSizeLimit ||
265
249
  (getConf(self, 'fetchSizeLimit') as number)
266
250
  )
267
251
  },
@@ -273,105 +257,75 @@ function stateModelFactory() {
273
257
  setMessage(message: string) {
274
258
  self.message = message
275
259
  },
276
-
260
+ }))
261
+ .actions(self => ({
277
262
  afterAttach() {
278
263
  // watch the parent's blocks to update our block state when they change,
279
264
  // then we recreate the blocks on our own model (creating and deleting to
280
265
  // match the parent blocks)
281
- const blockWatchDisposer = autorun(() => {
282
- const blocksPresent: { [key: string]: boolean } = {}
283
- const view = getContainingView(self) as LGV
284
- if (view.initialized) {
285
- self.blockDefinitions.contentBlocks.forEach(block => {
286
- blocksPresent[block.key] = true
287
- if (!self.blockState.has(block.key)) {
288
- this.addBlock(block.key, block)
289
- }
290
- })
291
- self.blockState.forEach((_, key) => {
292
- if (!blocksPresent[key]) {
293
- this.deleteBlock(key)
294
- }
295
- })
296
- }
297
- })
298
-
299
- addDisposer(self, blockWatchDisposer)
266
+ addDisposer(
267
+ self,
268
+ autorun(() => {
269
+ const blocksPresent: { [key: string]: boolean } = {}
270
+ const view = getContainingView(self) as LGV
271
+ if (view.initialized) {
272
+ self.blockDefinitions.contentBlocks.forEach(block => {
273
+ blocksPresent[block.key] = true
274
+ if (!self.blockState.has(block.key)) {
275
+ this.addBlock(block.key, block)
276
+ }
277
+ })
278
+ self.blockState.forEach((_, key) => {
279
+ if (!blocksPresent[key]) {
280
+ this.deleteBlock(key)
281
+ }
282
+ })
283
+ }
284
+ }),
285
+ )
300
286
  },
301
287
 
302
288
  /**
303
289
  * #action
304
290
  */
305
- estimateRegionsStats(
306
- regions: Region[],
307
- opts: {
308
- headers?: Record<string, string>
309
- signal?: AbortSignal
310
- filters?: string[]
311
- },
312
- ) {
313
- if (self.estimatedRegionStatsP) {
314
- return self.estimatedRegionStatsP
315
- }
316
-
317
- const { rpcManager } = getSession(self)
318
- const { adapterConfig } = self
319
- if (!adapterConfig) {
320
- // A track extending the base track might not have an adapter config
321
- // e.g. Apollo tracks don't use adapters
322
- return Promise.resolve({})
323
- }
324
- const sessionId = getRpcSessionId(self)
325
-
326
- const params = {
327
- sessionId,
328
- regions,
329
- adapterConfig,
330
- statusCallback: (message: string) => {
331
- if (isAlive(self)) {
332
- this.setMessage(message)
333
- }
334
- },
335
- ...opts,
291
+ async estimateRegionsStats() {
292
+ if (!self.estimatedRegionsStatsP) {
293
+ self.estimatedRegionsStatsP = estimateRegionsStatsPre(self).catch(
294
+ e => {
295
+ this.setRegionsStatsP(undefined)
296
+ throw e
297
+ },
298
+ )
336
299
  }
337
-
338
- self.estimatedRegionStatsP = rpcManager
339
- .call(sessionId, 'CoreEstimateRegionStats', params)
340
- .catch(e => {
341
- this.setRegionStatsP(undefined)
342
- throw e
343
- }) as Promise<Stats>
344
-
345
- return self.estimatedRegionStatsP
300
+ return self.estimatedRegionsStatsP
346
301
  },
302
+
347
303
  /**
348
304
  * #action
349
305
  */
350
- setRegionStatsP(p?: Promise<Stats>) {
351
- self.estimatedRegionStatsP = p
306
+ setRegionsStatsP(arg: any) {
307
+ self.estimatedRegionsStatsP = arg
352
308
  },
309
+
353
310
  /**
354
311
  * #action
355
312
  */
356
- setRegionStats(estimatedRegionStats?: Stats) {
357
- self.estimatedRegionStats = estimatedRegionStats
313
+ setRegionsStats(estimatedRegionsStats?: Stats) {
314
+ self.estimatedRegionsStats = estimatedRegionsStats
358
315
  },
359
316
  /**
360
317
  * #action
361
318
  */
362
- clearRegionStats() {
363
- self.estimatedRegionStatsP = undefined
364
- self.estimatedRegionStats = undefined
319
+ clearRegionsStats() {
320
+ self.estimatedRegionsStatsP = undefined
321
+ self.estimatedRegionsStats = undefined
365
322
  },
366
323
  /**
367
324
  * #action
368
325
  */
369
326
  setHeight(displayHeight: number) {
370
- if (displayHeight > minDisplayHeight) {
371
- self.heightPreConfig = displayHeight
372
- } else {
373
- self.heightPreConfig = minDisplayHeight
374
- }
327
+ self.heightPreConfig =
328
+ displayHeight > minDisplayHeight ? displayHeight : minDisplayHeight
375
329
  return self.height
376
330
  },
377
331
  /**
@@ -393,9 +347,9 @@ function stateModelFactory() {
393
347
  /**
394
348
  * #action
395
349
  */
396
- updateStatsLimit(stats: Stats) {
350
+ updateStatsLimit(stats?: Stats) {
397
351
  const view = getContainingView(self) as LGV
398
- if (stats.bytes) {
352
+ if (stats?.bytes) {
399
353
  self.userByteSizeLimit = stats.bytes
400
354
  } else {
401
355
  self.userBpPerPxLimit = view.bpPerPx
@@ -487,13 +441,11 @@ function stateModelFactory() {
487
441
  if (!self.estimatedStatsReady || view.dynamicBlocks.totalBp < 20_000) {
488
442
  return false
489
443
  }
490
- const bpLimitOrDensity = self.userBpPerPxLimit
491
- ? view.bpPerPx > self.userBpPerPxLimit
492
- : self.currentFeatureScreenDensity > self.maxFeatureScreenDensity
493
-
494
444
  return (
495
445
  self.currentBytesRequested > self.maxAllowableBytes ||
496
- bpLimitOrDensity
446
+ (self.userBpPerPxLimit
447
+ ? view.bpPerPx > self.userBpPerPxLimit
448
+ : self.currentFeatureScreenDensity > self.maxFeatureScreenDensity)
497
449
  )
498
450
  },
499
451
 
@@ -520,7 +472,6 @@ function stateModelFactory() {
520
472
  */
521
473
  async reload() {
522
474
  self.setError()
523
- const aborter = new AbortController()
524
475
  const view = getContainingView(self) as LGV
525
476
 
526
477
  // extra check for contentBlocks.length
@@ -530,84 +481,70 @@ function stateModelFactory() {
530
481
  }
531
482
 
532
483
  try {
533
- self.estimatedRegionStatsP = self.estimateRegionsStats(
534
- view.staticBlocks.contentBlocks,
535
- { signal: aborter.signal },
536
- )
537
- const estimatedRegionStats = await self.estimatedRegionStatsP
484
+ const estimatedRegionsStats = await self.estimateRegionsStats()
538
485
 
539
486
  if (isAlive(self)) {
540
- self.setRegionStats(estimatedRegionStats)
487
+ self.setRegionsStats(estimatedRegionsStats)
541
488
  superReload()
542
- } else {
543
- return
544
489
  }
545
490
  } catch (e) {
546
491
  console.error(e)
547
492
  self.setError(e)
548
493
  }
549
494
  },
550
- afterAttach() {
551
- // this autorun performs stats estimation
552
- //
553
- // the chain of events calls estimateRegionsStats against the data
554
- // adapter which by default uses featureDensity, but can also respond
555
- // with a byte size estimate and fetch size limit (data adapter can
556
- // define what is too much data)
557
- addDisposer(
558
- self,
559
- autorun(
560
- async () => {
561
- try {
562
- const aborter = new AbortController()
563
- const view = getContainingView(self) as LGV
564
-
565
- // extra check for contentBlocks.length
566
- // https://github.com/GMOD/jbrowse-components/issues/2694
567
- if (
568
- !view.initialized ||
569
- !view.staticBlocks.contentBlocks.length
570
- ) {
571
- return
572
- }
573
-
574
- // don't re-estimate featureDensity even if zoom level changes,
575
- // jbrowse1-style assume it's sort of representative
576
- if (self.estimatedRegionStats?.featureDensity !== undefined) {
577
- self.setCurrBpPerPx(view.bpPerPx)
578
- return
579
- }
580
-
581
- // we estimate stats once at a given zoom level
582
- if (view.bpPerPx === self.currBpPerPx) {
583
- return
584
- }
585
-
586
- self.clearRegionStats()
587
- self.setCurrBpPerPx(view.bpPerPx)
588
- const statsP = self.estimateRegionsStats(
589
- view.staticBlocks.contentBlocks,
590
- { signal: aborter.signal },
591
- )
592
- self.setRegionStatsP(statsP)
593
- const estimatedRegionStats = await statsP
594
-
595
- if (isAlive(self)) {
596
- self.setRegionStats(estimatedRegionStats)
597
- }
598
- } catch (e) {
599
- if (!isAbortException(e) && isAlive(self)) {
600
- console.error(e)
601
- self.setError(e)
602
- }
603
- }
604
- },
605
- { delay: 500 },
606
- ),
607
- )
608
- },
609
495
  }
610
496
  })
497
+ .actions(self => ({
498
+ afterAttach() {
499
+ // this autorun performs stats estimation
500
+ //
501
+ // the chain of events calls estimateRegionsStats against the data
502
+ // adapter which by default uses featureDensity, but can also respond
503
+ // with a byte size estimate and fetch size limit (data adapter can
504
+ // define what is too much data)
505
+ addDisposer(
506
+ self,
507
+ autorun(async () => {
508
+ try {
509
+ const view = getContainingView(self) as LGV
510
+
511
+ // extra check for contentBlocks.length
512
+ // https://github.com/GMOD/jbrowse-components/issues/2694
513
+ if (
514
+ !view.initialized ||
515
+ !view.staticBlocks.contentBlocks.length
516
+ ) {
517
+ return
518
+ }
519
+
520
+ // don't re-estimate featureDensity even if zoom level changes,
521
+ // jbrowse1-style assume it's sort of representative
522
+ if (self.estimatedRegionsStats?.featureDensity !== undefined) {
523
+ self.setCurrBpPerPx(view.bpPerPx)
524
+ return
525
+ }
526
+
527
+ // we estimate stats once at a given zoom level
528
+ if (view.bpPerPx === self.currBpPerPx) {
529
+ return
530
+ }
531
+
532
+ self.clearRegionsStats()
533
+ self.setCurrBpPerPx(view.bpPerPx)
534
+ const estimatedRegionsStats = await self.estimateRegionsStats()
535
+ if (isAlive(self)) {
536
+ self.setRegionsStats(estimatedRegionsStats)
537
+ }
538
+ } catch (e) {
539
+ if (!isAbortException(e) && isAlive(self)) {
540
+ console.error(e)
541
+ self.setError(e)
542
+ }
543
+ }
544
+ }),
545
+ )
546
+ },
547
+ }))
611
548
  .views(self => ({
612
549
  /**
613
550
  * #method
@@ -625,8 +562,7 @@ function stateModelFactory() {
625
562
  * react node allows user to force load at current setting
626
563
  */
627
564
  regionCannotBeRendered(_region: Region) {
628
- const { regionTooLarge } = self
629
- return regionTooLarge ? <TooLargeMessage model={self} /> : null
565
+ return self.regionTooLarge ? <TooLargeMessage model={self} /> : null
630
566
  },
631
567
 
632
568
  /**
@@ -639,20 +575,22 @@ function stateModelFactory() {
639
575
  /**
640
576
  * #method
641
577
  */
642
- contextMenuItems() {
643
- return self.contextMenuFeature
644
- ? [
645
- {
646
- label: 'Open feature details',
647
- icon: MenuOpenIcon,
648
- onClick: () => {
649
- if (self.contextMenuFeature) {
650
- self.selectFeature(self.contextMenuFeature)
651
- }
578
+ contextMenuItems(): MenuItem[] {
579
+ return [
580
+ ...(self.contextMenuFeature
581
+ ? [
582
+ {
583
+ label: 'Open feature details',
584
+ icon: MenuOpenIcon,
585
+ onClick: () => {
586
+ if (self.contextMenuFeature) {
587
+ self.selectFeature(self.contextMenuFeature)
588
+ }
589
+ },
652
590
  },
653
- },
654
- ]
655
- : []
591
+ ]
592
+ : []),
593
+ ]
656
594
  },
657
595
  /**
658
596
  * #method
@@ -662,7 +600,7 @@ function stateModelFactory() {
662
600
  return {
663
601
  ...getParentRenderProps(self),
664
602
  notReady:
665
- self.currBpPerPx !== view.bpPerPx || !self.estimatedRegionStats,
603
+ self.currBpPerPx !== view.bpPerPx || !self.estimatedRegionsStats,
666
604
  rpcDriverName: self.rpcDriverName,
667
605
  displayModel: self,
668
606
  onFeatureClick(_: unknown, featureId?: string) {
@@ -802,7 +740,7 @@ function stateModelFactory() {
802
740
  }
803
741
  // rewrite "height" from older snapshots to "heightPreConfig", this allows
804
742
  // us to maintain a height "getter" going forward
805
- // @ts-ignore
743
+ // @ts-expect-error
806
744
  const { height, ...rest } = snap
807
745
  return { heightPreConfig: height, ...rest }
808
746
  })
@@ -81,10 +81,11 @@ const blockState = types
81
81
  self.status = message
82
82
  },
83
83
  setLoading(abortController: AbortController) {
84
- if (renderInProgress !== undefined) {
85
- if (!renderInProgress.signal.aborted) {
86
- renderInProgress.abort()
87
- }
84
+ if (
85
+ renderInProgress !== undefined &&
86
+ !renderInProgress.signal.aborted
87
+ ) {
88
+ renderInProgress.abort()
88
89
  }
89
90
  self.filled = false
90
91
  self.message = undefined
@@ -215,7 +216,7 @@ export function renderBlockData(
215
216
  const regionAsm = self.region.assemblyName
216
217
  if (
217
218
  !assemblyNames.includes(regionAsm) &&
218
- !assemblyNames.find(name => assemblyManager.get(name)?.hasName(regionAsm))
219
+ !assemblyNames.some(name => assemblyManager.get(name)?.hasName(regionAsm))
219
220
  ) {
220
221
  throw new Error(
221
222
  `region assembly (${regionAsm}) does not match track assemblies (${assemblyNames})`,
@@ -1,3 +1,9 @@
1
+ import { Stats } from '@jbrowse/core/data_adapters/BaseAdapter'
2
+ import { getContainingView, getSession } from '@jbrowse/core/util'
3
+ import { getRpcSessionId } from '@jbrowse/core/util/tracks'
4
+ import { IAnyStateTreeNode, isAlive } from 'mobx-state-tree'
5
+ import { LinearGenomeViewModel } from '../../LinearGenomeView'
6
+
1
7
  export interface RenderProps {
2
8
  rendererType: any // eslint-disable-line @typescript-eslint/no-explicit-any
3
9
  renderArgs: { [key: string]: any } // eslint-disable-line @typescript-eslint/no-explicit-any
@@ -14,11 +20,42 @@ export interface ErrorProps {
14
20
  export function getDisplayStr(totalBytes: number) {
15
21
  let displayBp
16
22
  if (Math.floor(totalBytes / 1000000) > 0) {
17
- displayBp = `${parseFloat((totalBytes / 1000000).toPrecision(3))} Mb`
23
+ displayBp = `${Number.parseFloat((totalBytes / 1000000).toPrecision(3))} Mb`
18
24
  } else if (Math.floor(totalBytes / 1000) > 0) {
19
- displayBp = `${parseFloat((totalBytes / 1000).toPrecision(3))} Kb`
25
+ displayBp = `${Number.parseFloat((totalBytes / 1000).toPrecision(3))} Kb`
20
26
  } else {
21
27
  displayBp = `${Math.floor(totalBytes)} bytes`
22
28
  }
23
29
  return displayBp
24
30
  }
31
+
32
+ // stabilize clipid under test for snapshot
33
+ export function getId(id: string, index: number) {
34
+ const isJest = typeof jest === 'undefined'
35
+ return `clip-${isJest ? id : 'jest'}-${index}`
36
+ }
37
+
38
+ export async function estimateRegionsStatsPre(self: IAnyStateTreeNode) {
39
+ const view = getContainingView(self) as LinearGenomeViewModel
40
+ const regions = view.staticBlocks.contentBlocks
41
+
42
+ const { rpcManager } = getSession(self)
43
+ const { adapterConfig } = self
44
+ if (!adapterConfig) {
45
+ // A track extending the base track might not have an adapter config
46
+ // e.g. Apollo tracks don't use adapters
47
+ return {}
48
+ }
49
+ const sessionId = getRpcSessionId(self)
50
+
51
+ return rpcManager.call(sessionId, 'CoreEstimateRegionStats', {
52
+ sessionId,
53
+ regions,
54
+ adapterConfig,
55
+ statusCallback: (message: string) => {
56
+ if (isAlive(self)) {
57
+ self.setMessage(message)
58
+ }
59
+ },
60
+ }) as Promise<Stats>
61
+ }
@@ -7,7 +7,7 @@ type LGV = LinearGenomeViewModel
7
7
  export default (pluginManager: PluginManager) => {
8
8
  pluginManager.addToExtensionPoint(
9
9
  'LaunchView-LinearGenomeView',
10
- // @ts-ignore
10
+ // @ts-expect-error
11
11
  async ({
12
12
  session,
13
13
  assembly,
@@ -12,6 +12,7 @@ export default (pluginManager: PluginManager) => {
12
12
  return new DisplayType({
13
13
  name: 'LinearBareDisplay',
14
14
  configSchema,
15
+ displayName: 'Bare feature display',
15
16
  stateModel: stateModelFactory(configSchema),
16
17
  trackType: 'BasicTrack',
17
18
  viewType: 'LinearGenomeView',
@@ -20,4 +21,5 @@ export default (pluginManager: PluginManager) => {
20
21
  })
21
22
  }
22
23
 
23
- export { configSchemaFactory, stateModelFactory }
24
+ export { configSchemaFactory } from './configSchema'
25
+ export { stateModelFactory } from './model'
@@ -10,15 +10,11 @@ import {
10
10
  } from '@mui/material'
11
11
  import { makeStyles } from 'tss-react/mui'
12
12
 
13
- const useStyles = makeStyles()(theme => ({
13
+ const useStyles = makeStyles()({
14
14
  root: {
15
15
  width: 500,
16
16
  },
17
-
18
- field: {
19
- margin: theme.spacing(2),
20
- },
21
- }))
17
+ })
22
18
 
23
19
  function SetMaxHeightDlg({
24
20
  model,
@@ -26,7 +22,7 @@ function SetMaxHeightDlg({
26
22
  }: {
27
23
  model: {
28
24
  maxHeight?: number
29
- setMaxHeight: Function
25
+ setMaxHeight: (arg?: number) => void
30
26
  }
31
27
  handleClose: () => void
32
28
  }) {
@@ -11,7 +11,7 @@ export default (pluginManager: PluginManager) => {
11
11
  const config = configSchema(pluginManager)
12
12
  return new DisplayType({
13
13
  name: 'LinearBasicDisplay',
14
- displayName: 'Basic deature display',
14
+ displayName: 'Basic feature display',
15
15
  configSchema: config,
16
16
  stateModel: modelFactory(config),
17
17
  trackType: 'FeatureTrack',
@@ -21,4 +21,5 @@ export default (pluginManager: PluginManager) => {
21
21
  })
22
22
  }
23
23
 
24
- export { modelFactory, configSchema }
24
+ export { default as modelFactory } from './model'
25
+ export { default as configSchema } from './configSchema'
@@ -137,7 +137,7 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
137
137
  /**
138
138
  * #action
139
139
  */
140
- setMaxHeight(val: number) {
140
+ setMaxHeight(val?: number) {
141
141
  self.trackMaxHeight = val
142
142
  },
143
143
  }))
@@ -86,7 +86,7 @@ export default function ExportSvgDlg({
86
86
  {Object.entries(session.allThemes()).map(([key, val]) => (
87
87
  <MenuItem key={key} value={key}>
88
88
  {
89
- // @ts-ignore
89
+ // @ts-expect-error
90
90
  val.name || '(Unknown name)'
91
91
  }
92
92
  </MenuItem>