jbrowse-plugin-graphgenomeviewer 10.0.2 → 10.0.3

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 (40) hide show
  1. package/dist/chunks/{GraphGenomeView-2WSTZQNY.js → GraphGenomeView-7KODXFCZ.js} +2 -2
  2. package/dist/chunks/{LinearGraphDisplay-VYCJVUW4.js → LinearGraphDisplay-ZAIMEATG.js} +2 -2
  3. package/dist/chunks/chunk-4MTS65XF.js +3 -0
  4. package/dist/chunks/{chunk-ZKQLPKNN.js.map → chunk-4MTS65XF.js.map} +3 -3
  5. package/dist/chunks/{chunk-NDWP2KNR.js → chunk-JJ2TPWSH.js} +2 -2
  6. package/dist/chunks/{chunk-EVYIBH4N.js → chunk-TMF6JHCE.js} +2 -2
  7. package/dist/chunks/{chunk-AVUNIRM5.js → chunk-TP6OXTXD.js} +5 -5
  8. package/dist/chunks/chunk-TP6OXTXD.js.map +7 -0
  9. package/dist/chunks/chunk-VV5LVNCP.js +9 -0
  10. package/dist/chunks/chunk-VV5LVNCP.js.map +7 -0
  11. package/dist/chunks/renderSvg-SEYWHXD7.js +2 -0
  12. package/dist/chunks/renderSvg-SEYWHXD7.js.map +7 -0
  13. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js +1 -1
  14. package/dist/jbrowse-plugin-graphgenomeviewer.esm.js.map +1 -1
  15. package/package.json +1 -1
  16. package/src/GraphGenomeView/components/PaneSvg.tsx +2 -1
  17. package/src/GraphGenomeView/model.facetRebuild.test.ts +10 -7
  18. package/src/GraphGenomeView/model.fold.test.ts +2 -5
  19. package/src/GraphGenomeView/model.geneNames.test.ts +4 -4
  20. package/src/GraphGenomeView/model.layout.test.ts +6 -13
  21. package/src/GraphGenomeView/model.passes.test.tsx +2 -5
  22. package/src/GraphGenomeView/model.ts +2 -8
  23. package/src/GraphGenomeView/pane/fitViews.ts +63 -20
  24. package/src/GraphGenomeView/pane/graphViews.ts +1 -18
  25. package/src/GraphGenomeView/pane/paneBase.ts +28 -13
  26. package/src/GraphGenomeView/pane/renderingActions.ts +34 -66
  27. package/src/GraphGenomeView/pane/settingActions.ts +47 -28
  28. package/src/GraphGenomeView/renderPipeline.test.ts +28 -9
  29. package/src/LinearGraphDisplay/LinearGraphDisplay.test.ts +6 -6
  30. package/src/version.ts +1 -1
  31. package/dist/chunks/chunk-AVUNIRM5.js.map +0 -7
  32. package/dist/chunks/chunk-EUXYBAW2.js +0 -9
  33. package/dist/chunks/chunk-EUXYBAW2.js.map +0 -7
  34. package/dist/chunks/chunk-ZKQLPKNN.js +0 -3
  35. package/dist/chunks/renderSvg-X3BRMJX3.js +0 -2
  36. package/dist/chunks/renderSvg-X3BRMJX3.js.map +0 -7
  37. /package/dist/chunks/{GraphGenomeView-2WSTZQNY.js.map → GraphGenomeView-7KODXFCZ.js.map} +0 -0
  38. /package/dist/chunks/{LinearGraphDisplay-VYCJVUW4.js.map → LinearGraphDisplay-ZAIMEATG.js.map} +0 -0
  39. /package/dist/chunks/{chunk-NDWP2KNR.js.map → chunk-JJ2TPWSH.js.map} +0 -0
  40. /package/dist/chunks/{chunk-EVYIBH4N.js.map → chunk-TMF6JHCE.js.map} +0 -0
@@ -53,7 +53,8 @@ function Body({
53
53
  height: number
54
54
  rasterize: boolean
55
55
  }) {
56
- const built = model.buildDrawing(lift, drawPaths)
56
+ // the view as it is, though a gesture's window may not have settled yet
57
+ const built = model.buildDrawing(lift, drawPaths, model.liveBuildView)
57
58
  if (!built) {
58
59
  return null
59
60
  }
@@ -2,7 +2,7 @@ import { layoutEngine } from '@jbrowse/bandage-core/layoutEngines'
2
2
  import { reaction } from 'mobx'
3
3
 
4
4
  import { mockRpcCall } from './modelTestMocks'
5
- import { createModel, fakeRenderer } from './modelTestSupport'
5
+ import { attachedModel, fakeRenderer } from './modelTestSupport'
6
6
  import { VIEWPORT_DEBOUNCE_MS } from './pane/paneBase'
7
7
 
8
8
  import type { EngineRequest } from '@jbrowse/bandage-core/pipeline'
@@ -40,7 +40,7 @@ beforeEach(() => {
40
40
  )
41
41
  })
42
42
 
43
- async function splitByWalk(model: ReturnType<typeof createModel>) {
43
+ async function splitByWalk(model: ReturnType<typeof attachedModel>) {
44
44
  await model.loadGFA(BUBBLE, 'bubble')
45
45
  model.liftWalks(['GRCh38#0#chr1', 'A#1#ctg'])
46
46
  model.setFacet('walk')
@@ -54,24 +54,27 @@ async function splitByWalk(model: ReturnType<typeof createModel>) {
54
54
  return { early, stop }
55
55
  }
56
56
 
57
- function fit(model: ReturnType<typeof createModel>) {
57
+ function fit(model: ReturnType<typeof attachedModel>) {
58
58
  model.setWidth(1200)
59
59
  model.setLegendSize({ width: 150, height: 60 })
60
60
  }
61
61
 
62
62
  function expectBuiltFor(
63
- model: ReturnType<typeof createModel>,
63
+ model: ReturnType<typeof attachedModel>,
64
64
  drawings: typeof model.facetDrawings,
65
65
  ) {
66
66
  const panels = (drawings ?? []).flatMap(panel => panel ?? [])
67
- expect(panels.map(p => p.scale)).toEqual([model.scale, model.scale])
67
+ expect(panels.map(p => p.view.axis)).toEqual([
68
+ model.axisScale,
69
+ model.axisScale,
70
+ ])
68
71
  expect(panels.map(p => p.batch.nodeStrokes.length > 0)).toEqual([true, true])
69
72
  }
70
73
 
71
74
  // The key reads the panels' drawings as soon as the layout lands, before the
72
75
  // pane is sized and fitted, as a restored session's does
73
76
  test('a panel drawing built before the fit is built again for the fitted view', async () => {
74
- const model = createModel()
77
+ const model = attachedModel()
75
78
  model.startRenderingBackend(fakeRenderer())
76
79
  const { early, stop } = await splitByWalk(model)
77
80
  fit(model)
@@ -85,7 +88,7 @@ test('a panel drawing built before the fit is built again for the fitted view',
85
88
  // A track's pane takes its view before its canvas mounts, so the renderer
86
89
  // starts on a view the panels were never built for
87
90
  test('a panel drawing built before a view the renderer never saw is built again', async () => {
88
- const model = createModel()
91
+ const model = attachedModel()
89
92
  const { early, stop } = await splitByWalk(model)
90
93
  fit(model)
91
94
  model.zoomToFit()
@@ -52,11 +52,8 @@ async function drawnGap571(layers: GraphLayers = { lengths: true }) {
52
52
 
53
53
  // the batch the canvas holds
54
54
  function draw(model: GraphPaneModel) {
55
- const { batch, viewportBounds } = model.buildDrawing(undefined, false)!
56
- model.setGeometryMetrics(0, batch, {
57
- scale: model.scale,
58
- bounds: viewportBounds,
59
- })
55
+ const { batch, view } = model.buildDrawing(undefined, false)!
56
+ model.setGeometryMetrics(0, batch, view)
60
57
  }
61
58
 
62
59
  // A reference of two 5 kb nodes, and between them two stretches the cut did
@@ -198,11 +198,11 @@ test('an exon on a node the drawing folds is not outlined, and its gene stays ov
198
198
  const outlinedOn = (id: string) =>
199
199
  model.exonOutlines.filter(s => s.key.endsWith(`-${id}`))
200
200
  expect(outlinedOn('h0+').length).toBeGreaterThan(0)
201
- const { batch, viewportBounds } = model.buildDrawing(undefined, false)!
201
+ const { batch, view } = model.buildDrawing(undefined, false)!
202
202
  model.setGeometryMetrics(
203
203
  0,
204
204
  { ...batch, collapsed: { ...NO_FOLD, nodes: new Set(['h0+']) } },
205
- { scale: model.scale, bounds: viewportBounds },
205
+ view,
206
206
  )
207
207
  expect(outlinedOn('h0+')).toEqual([])
208
208
  expect(outlinedOn('h1+').length).toBeGreaterThan(0)
@@ -214,11 +214,11 @@ test('an exon on a reference node that only the lanes across a folded site draw
214
214
  const outlinedOn = (id: string) =>
215
215
  model.exonOutlines.filter(s => s.key.endsWith(`-${id}`))
216
216
  expect(outlinedOn('h0+').length).toBeGreaterThan(0)
217
- const { batch, viewportBounds } = model.buildDrawing(undefined, false)!
217
+ const { batch, view } = model.buildDrawing(undefined, false)!
218
218
  model.setGeometryMetrics(
219
219
  0,
220
220
  { ...batch, laneOnly: { nodes: new Set(['h0+']), edges: new Set() } },
221
- { scale: model.scale, bounds: viewportBounds },
221
+ view,
222
222
  )
223
223
  expect(outlinedOn('h0+')).toEqual([])
224
224
  expect(outlinedOn('h1+').length).toBeGreaterThan(0)
@@ -74,23 +74,19 @@ describe('performance instrumentation', () => {
74
74
  expect(model.showLoading).toBe(false)
75
75
  await model.loadGFA(SIMPLE_GFA, 'imported')
76
76
  expect(model.showLoading).toBe(true)
77
- model.setGeometryMetrics(1, EMPTY_BATCH, {
78
- scale: 1,
79
- bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 },
80
- })
77
+ model.settleBuildView()
78
+ model.setGeometryMetrics(1, EMPTY_BATCH, model.buildView)
81
79
  expect(model.showLoading).toBe(true)
82
80
  model.markPainted()
83
81
  expect(model.showLoading).toBe(false)
84
82
 
85
- model.setGeometryMetrics(1, EMPTY_BATCH, {
86
- scale: 1,
87
- bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 },
88
- })
83
+ model.setGeometryMetrics(1, EMPTY_BATCH, model.buildView)
89
84
  expect(model.showLoading).toBe(true)
90
85
  model.markPainted()
91
86
  expect(model.showLoading).toBe(false)
92
87
 
93
- model.setViewportDirty()
88
+ // a zoom off the settled window holds it until a build for the new one
89
+ model.zoom(2, 0, 0)
94
90
  expect(model.showLoading).toBe(true)
95
91
  })
96
92
 
@@ -111,10 +107,7 @@ describe('performance instrumentation', () => {
111
107
  const model = createModel()
112
108
  await model.loadGFA(SIMPLE_GFA, 'imported')
113
109
  const batch = { ...model.drawnBatch, nodeStrokes: [] }
114
- model.setGeometryMetrics(1, batch, {
115
- scale: 1,
116
- bounds: { minX: 0, minY: 0, maxX: 1, maxY: 1 },
117
- })
110
+ model.setGeometryMetrics(1, batch, model.buildView)
118
111
  model.setMorphFrame({
119
112
  layout: model.layoutResult!,
120
113
  ids: new Set(['1']),
@@ -58,11 +58,8 @@ async function liftedByPass(walkStrip = false) {
58
58
  { walk: 'hap#1#ctg', color: { field: 'pass' } },
59
59
  ])
60
60
  model.zoomToFit()
61
- const { batch, viewportBounds } = model.buildDrawing(model.walkLift, false)!
62
- model.setGeometryMetrics(0, batch, {
63
- scale: model.scale,
64
- bounds: viewportBounds,
65
- })
61
+ const { batch, view } = model.buildDrawing(model.walkLift, false)!
62
+ model.setGeometryMetrics(0, batch, view)
66
63
  return model
67
64
  }
68
65
 
@@ -15,7 +15,7 @@ import {
15
15
  } from '../graphTrackConfig'
16
16
  import { canonicalAssemblyName } from '../launchFromGraph/launchFromGraph'
17
17
  import { withLaunchActions } from './pane/launchActions'
18
- import { VIEWPORT_DEBOUNCE_MS } from './pane/paneBase'
18
+ import { VIEWPORT_DEBOUNCE_MS, sameBounds } from './pane/paneBase'
19
19
 
20
20
  import type { SubgraphCutOptions, SubgraphRegion } from '../GetSubgraph'
21
21
  import type { PaneLayout } from './tubeMapPanels'
@@ -34,12 +34,6 @@ const NO_LABELS: LabelLayout = {
34
34
  sizes: [],
35
35
  }
36
36
 
37
- const sameBounds = (a: Bounds, b: Bounds) =>
38
- a.minX === b.minX &&
39
- a.maxX === b.maxX &&
40
- a.minY === b.minY &&
41
- a.maxY === b.maxY
42
-
43
37
  const sameEntry = (a: GraphKeyEntry, b: GraphKeyEntry | undefined) =>
44
38
  !!b &&
45
39
  a.key === b.key &&
@@ -328,7 +322,7 @@ export const GraphPane = withLaunchActions
328
322
  () => ({
329
323
  shape: self.keyShape,
330
324
  view: self.keyView,
331
- rebuilt: self.builtViewport?.viewportDirty,
325
+ rebuilt: self.builtViewport?.view,
332
326
  layout: self.layoutResult,
333
327
  width: self.paneWidth,
334
328
  owner: self.viewportOwner,
@@ -45,9 +45,8 @@ import {
45
45
  GENE_ROW_PX,
46
46
  tubeMapGeneRows,
47
47
  } from '@jbrowse/bandage-core/tubeMap/genes'
48
- import { padded } from '@jbrowse/bandage-core/viewport'
48
+ import { contains, padded } from '@jbrowse/bandage-core/viewport'
49
49
  import { walkPosition } from '@jbrowse/bandage-core/walkKey'
50
- import { untracked } from 'mobx'
51
50
 
52
51
  import { cutRuleOf, hostWindow, paneWindow } from '../host'
53
52
  import { measureReadout } from '../readoutMeasure'
@@ -62,10 +61,13 @@ import {
62
61
  SELECT_BRIGHTEN,
63
62
  VIEWPORT_PANES_BUILT,
64
63
  dependOn,
64
+ geometryPainted,
65
65
  paneViewportOf,
66
+ sameAxis,
66
67
  } from './paneBase'
67
68
  import { trackedDpr } from '../trackedDpr'
68
69
 
70
+ import type { BuildView } from './paneBase'
69
71
  import type { SubgraphRegion } from '../../GetSubgraph'
70
72
  import type { FacetGrid, FacetSetting } from '@jbrowse/bandage-core/facetGrid'
71
73
  import type {
@@ -675,11 +677,54 @@ export const withFitViews = withHostViews
675
677
  },
676
678
  }))
677
679
  .views(self => ({
678
- // The window the transform shows plus a pane of overscan all round,
679
- // which a pan inside needs no rebuild for
680
- viewportToBuild() {
681
- return padded(paneViewportOf(self), VIEWPORT_PANES_BUILT)
680
+ // The zoom and the window the transform shows plus a pane of overscan
681
+ // all round, which a pan inside needs no rebuild for
682
+ get liveBuildView(): BuildView {
683
+ return {
684
+ axis: self.axisScale,
685
+ bounds: padded(paneViewportOf(self), VIEWPORT_PANES_BUILT),
686
+ }
687
+ },
688
+ // Whether the window settled on this layout still holds the zoom and
689
+ // the window the pane shows
690
+ get buildViewSettled() {
691
+ const settled = self.settledBuildView
692
+ return (
693
+ settled !== undefined &&
694
+ settled.layout === self.layoutResult &&
695
+ sameAxis(settled.view.axis, self.axisScale) &&
696
+ contains(settled.view.bounds, paneViewportOf(self))
697
+ )
682
698
  },
699
+ }))
700
+ .views(self => ({
701
+ // What the drawing is built for: the window last settled (afterAttach),
702
+ // so a gesture rebuilds nothing until it ends, and the pane's view as it
703
+ // is until one is
704
+ get buildView() {
705
+ return self.settledBuildView?.view ?? self.liveBuildView
706
+ },
707
+ }))
708
+ .views(self => ({
709
+ get geometryPainted() {
710
+ return geometryPainted(self)
711
+ },
712
+ get paintSuperseded() {
713
+ return !this.geometryPainted
714
+ },
715
+ // The app-wide readiness contract (AppReadyMarker, @jbrowse/capture)
716
+ // reads this: a declared source still fetching, or a graph whose
717
+ // settled geometry is not on the canvas yet.
718
+ get showLoading() {
719
+ return (
720
+ self.error === undefined &&
721
+ (self.isLoading ||
722
+ self.hasPendingSource ||
723
+ (self.graph !== undefined && !this.geometryPainted))
724
+ )
725
+ },
726
+ }))
727
+ .views(self => ({
683
728
  // The selection as a draw-time colour override, keyed by node so it
684
729
  // survives a rebuild renumbering the batch, and none while the drawing
685
730
  // folds it. The hover is paintHover's, on a layer of its own.
@@ -724,21 +769,19 @@ export const withFitViews = withHostViews
724
769
  },
725
770
  }))
726
771
  .views(self => ({
727
- // The drawing's batch with `highlight`'s walks lifted, for the window
728
- // the transform shows. A caller's autorun rebuilds it when the window
729
- // settles after a pan or zoom, when a drag moves the positions, and when
730
- // any display option read here changes.
731
- buildDrawing(highlight: WalkLift | undefined, drawPaths: boolean) {
772
+ // The drawing's batch with `highlight`'s walks lifted, for `view`. A
773
+ // caller's autorun rebuilds it when that window moves, when a drag moves
774
+ // the positions, and when any display option read here changes.
775
+ buildDrawing(
776
+ highlight: WalkLift | undefined,
777
+ drawPaths: boolean,
778
+ view = self.buildView,
779
+ ) {
732
780
  const { graph, nodeById, layoutResult, deletionDrawing } = self
733
781
  if (!graph || !nodeById || !layoutResult || !deletionDrawing) {
734
782
  return undefined
735
783
  }
736
- dependOn(self.viewportDirty, self.positionsVersion)
737
- const viewportBounds = untracked(() => self.viewportToBuild())
738
- // Untracked, so a zoom does not eagerly rebuild geometry — the
739
- // debounced viewportDirty bump drives the scale-dependent rebuild
740
- // (flatness, arrow visibility, viewport culling), same as pan.
741
- const axis = untracked(() => self.axisScale)
784
+ dependOn(self.positionsVersion)
742
785
  const batch = buildGeometry({
743
786
  // walk rows' overlay draws every bar, the reference's among them;
744
787
  // its nodes stay in the hit index, so hovering the bar finds them
@@ -754,9 +797,9 @@ export const withFitViews = withHostViews
754
797
  nodeWidth: self.nodeWidth,
755
798
  edgeWidth: self.linkWidth,
756
799
  highlight,
757
- axis,
800
+ axis: view.axis,
758
801
  linearLayout: self.linearLayout,
759
- viewportBounds,
802
+ viewportBounds: view.bounds,
760
803
  // Held against the graph rather than derived here, the same way the
761
804
  // deletion drawing is and for the same reason — see `drawnReferenceRamp`.
762
805
  referenceRamp: self.referenceRamp,
@@ -768,7 +811,7 @@ export const withFitViews = withHostViews
768
811
  if (entering?.layout === layoutResult) {
769
812
  fadeEntering(batch, graph.edges, entering)
770
813
  }
771
- return { batch, viewportBounds, scale: untracked(() => self.scale) }
814
+ return { batch, view }
772
815
  },
773
816
  // Each facet panel's drawing, which the panel paints and the key reads
774
817
  get facetDrawings() {
@@ -70,7 +70,7 @@ import {
70
70
  import { getTrackName } from '@jbrowse/core/util/tracks'
71
71
  import { computed } from 'mobx'
72
72
 
73
- import { TUBE_MAP_MODES, dependOn, geometryPainted, paneBase } from './paneBase'
73
+ import { TUBE_MAP_MODES, dependOn, paneBase } from './paneBase'
74
74
  import { trackAdapterSnapshot } from '../../graphTrackConfig'
75
75
  import {
76
76
  canonicalAssemblyName,
@@ -416,23 +416,6 @@ export const withGraphViews = paneBase
416
416
  get hasGraph() {
417
417
  return self.graph !== undefined
418
418
  },
419
- get geometryPainted() {
420
- return geometryPainted(self)
421
- },
422
- get paintSuperseded() {
423
- return !this.geometryPainted
424
- },
425
- // The app-wide readiness contract (AppReadyMarker, @jbrowse/capture)
426
- // reads this: a declared source still fetching, or a graph whose
427
- // settled geometry is not on the canvas yet.
428
- get showLoading() {
429
- return (
430
- self.error === undefined &&
431
- (self.isLoading ||
432
- self.hasPendingSource ||
433
- (self.graph !== undefined && !this.geometryPainted))
434
- )
435
- },
436
419
  // Only before anything is drawn: past that point a reload is superseded
437
420
  // by the next setting change, and stopping one midway would leave a new
438
421
  // graph under the previous graph's layout.
@@ -184,23 +184,37 @@ export function fileName(location: FileLocation) {
184
184
 
185
185
  type ViewportOwner = 'fit' | 'user' | 'host'
186
186
 
187
- interface BuiltViewport {
188
- scale: number
187
+ // The zoom and the window a drawing is built for
188
+ export interface BuildView {
189
+ axis: AxisScale
189
190
  bounds: Bounds
190
- viewportDirty: number
191
+ }
192
+
193
+ export const sameBounds = (a: Bounds, b: Bounds) =>
194
+ a.minX === b.minX &&
195
+ a.maxX === b.maxX &&
196
+ a.minY === b.minY &&
197
+ a.maxY === b.maxY
198
+
199
+ export const sameAxis = (a: AxisScale, b: AxisScale) =>
200
+ a.scaleX === b.scaleX && a.scaleY === b.scaleY && a.pixelRows === b.pixelRows
201
+
202
+ // One upload's record of the view its batch was built for
203
+ interface BuiltViewport {
204
+ view: BuildView
191
205
  }
192
206
 
193
207
  export function geometryPainted(model: {
194
- viewportRebuildPending: boolean
195
- viewportDirty: number
208
+ buildView: BuildView
209
+ buildViewSettled: boolean
196
210
  builtViewport?: BuiltViewport
197
211
  paintedViewport?: BuiltViewport
198
212
  }) {
199
213
  return (
200
214
  model.builtViewport !== undefined &&
201
215
  model.paintedViewport === model.builtViewport &&
202
- model.builtViewport.viewportDirty === model.viewportDirty &&
203
- !model.viewportRebuildPending
216
+ model.builtViewport.view === model.buildView &&
217
+ model.buildViewSettled
204
218
  )
205
219
  }
206
220
 
@@ -424,10 +438,13 @@ export const paneBase = types
424
438
  hoveredWalkRow: null as string | null,
425
439
  hoveredEdge: null as number | null,
426
440
  selectedNode: null as string | null,
427
- viewportDirty: 0,
441
+ // The build window last settled, and the layout it was settled on (see
442
+ // buildView)
443
+ settledBuildView: undefined as
444
+ { view: BuildView; layout: PaneLayout | undefined } | undefined,
428
445
  // Bumped when the layout's positions are mutated IN PLACE, which only a
429
- // node drag does. Separate from `viewportDirty` because that one also
430
- // fires on pan and zoom, and the things keyed off this — the two hit
446
+ // node drag does. Separate from the build window because that one also
447
+ // moves on pan and zoom, and the things keyed off this — the two hit
431
448
  // indexes and the label placement's per-layout caches — do not depend on
432
449
  // the transform at all. Rebuilding a 12k-edge hit index because the user
433
450
  // panned cost ~14 ms of the first mousemove after every gesture.
@@ -441,8 +458,7 @@ export const paneBase = types
441
458
  // the batch of the last frame no morph was under way in, which the key
442
459
  // reads so it never shows a morph's in-between folds
443
460
  settledBatch: EMPTY_BATCH,
444
- // The zoom and the window the current batch was built for; a pan that
445
- // stays inside it needs no rebuild.
461
+ // The view the current batch was built for
446
462
  builtViewport: undefined as BuiltViewport | undefined,
447
463
  // The builtViewport whose batch is on the canvas
448
464
  paintedViewport: undefined as BuiltViewport | undefined,
@@ -470,5 +486,4 @@ export const paneBase = types
470
486
  lastLayoutMs: undefined as number | undefined,
471
487
  lastGeometryMs: undefined as number | undefined,
472
488
  lastGeometryStrokeCount: undefined as number | undefined,
473
- viewportRebuildPending: false,
474
489
  }))
@@ -1,16 +1,10 @@
1
1
  import { sameBubble } from '@jbrowse/bandage-core/bubbles/bubbleLine'
2
- import { contains } from '@jbrowse/bandage-core/viewport'
3
2
  import { getSession } from '@jbrowse/core/util'
4
3
  import { addDisposer, isAlive } from '@jbrowse/mobx-state-tree'
5
- import { autorun, reaction, untracked } from 'mobx'
4
+ import { autorun, reaction } from 'mobx'
6
5
 
7
6
  import { withLoadActions } from './loadActions'
8
- import {
9
- EMPTY_BATCH,
10
- TUBE_MAP_MODES,
11
- dependOn,
12
- paneViewportOf,
13
- } from './paneBase'
7
+ import { EMPTY_BATCH, TUBE_MAP_MODES, dependOn } from './paneBase'
14
8
  import {
15
9
  bubbleForLgvHover,
16
10
  hoverFromPair,
@@ -102,22 +96,23 @@ export const withRenderingActions = withLoadActions
102
96
  { fireImmediately: true },
103
97
  ),
104
98
  )
105
- // Autorun: keep the view fitted to the graph until the user moves it.
106
- // Reading fittedTransform tracks everything the fit depends on, so
99
+ // Keep the view fitted to the graph until the user moves it.
100
+ // fittedTransform tracks everything the fit depends on, so
107
101
  // it re-fits as the layout arrives, the canvas is measured and the
108
102
  // genes over a tube map claim their rows. A manual pan/zoom (or a
109
103
  // restored-session transform) makes the viewport the user's, and a
110
104
  // host makes it the linear view's.
111
105
  addDisposer(
112
106
  self,
113
- autorun(() => {
114
- if (
115
- self.fittedTransform &&
116
- untracked(() => self.viewportOwner === 'fit')
117
- ) {
118
- self.zoomToFit()
119
- }
120
- }),
107
+ reaction(
108
+ () => self.fittedTransform,
109
+ fit => {
110
+ if (fit && self.viewportOwner === 'fit') {
111
+ self.zoomToFit()
112
+ }
113
+ },
114
+ { fireImmediately: true, name: 'GraphKeepFitted' },
115
+ ),
121
116
  )
122
117
 
123
118
  // A narrower or shorter pane can leave a placed drawing off screen
@@ -219,7 +214,7 @@ export const withRenderingActions = withLoadActions
219
214
  ),
220
215
  )
221
216
 
222
- // Autorun: mirror a connected linear view's hover onto the graph. An
217
+ // Mirror a connected linear view's hover onto the graph. An
223
218
  // LGV writes `{hoverPosition, hoverFeature}` to session.hovered on
224
219
  // every mousemove; neither field names the source view, so the guard
225
220
  // is that the position lies in the region this graph was cut from.
@@ -229,16 +224,18 @@ export const withRenderingActions = withLoadActions
229
224
  // a bp lights only on `hover: 'everything'`, since every track's
230
225
  // pointer passes over some node's bp.
231
226
  //
232
- // Only `hovered` and the setting are tracked — the graph reads are
233
- // untracked, so a geometry rebuild can't re-fire this and clobber a
234
- // hover the canvas itself set. Assigning an unchanged id doesn't notify, so a hover
235
- // that travels within one segment costs nothing downstream.
227
+ // Only `hovered` and the setting are watched, so a geometry rebuild
228
+ // can't re-fire this and clobber a hover the canvas itself set.
229
+ // Assigning an unchanged id doesn't notify, so a hover that travels
230
+ // within one segment costs nothing downstream.
236
231
  addDisposer(
237
232
  self,
238
- autorun(() => {
239
- const hover = readLgvHover(getSession(self).hovered)
240
- const lightsNode = self.hoverLightsEverything
241
- untracked(() => {
233
+ reaction(
234
+ () => ({
235
+ hover: readLgvHover(getSession(self).hovered),
236
+ lightsNode: self.hoverLightsEverything,
237
+ }),
238
+ ({ hover, lightsNode }) => {
242
239
  const region = self.graphRegion
243
240
  const graph = self.graph
244
241
  const inRegion =
@@ -271,8 +268,9 @@ export const withRenderingActions = withLoadActions
271
268
  )
272
269
  }
273
270
  self.setHoveredRowWalks(rowWalks)
274
- })
275
- }),
271
+ },
272
+ { fireImmediately: true, name: 'GraphMirrorLgvHover' },
273
+ ),
276
274
  )
277
275
 
278
276
  // A click on a bubble feature or graph-derived variant in a linear
@@ -332,24 +330,6 @@ export const withRenderingActions = withLoadActions
332
330
  ),
333
331
  )
334
332
 
335
- // Autorun: a build that misses the view shown schedules a debounced
336
- // rebuild, whether a zoom or a pan left it or it was made for a view
337
- // the pane had already left, as facet panels built before a track's
338
- // fit are. A pan inside it costs a repaint and nothing else.
339
- addDisposer(
340
- self,
341
- autorun(() => {
342
- const { scale, builtViewport } = self
343
- if (
344
- builtViewport &&
345
- (builtViewport.scale !== scale ||
346
- !contains(builtViewport.bounds, paneViewportOf(self)))
347
- ) {
348
- self.scheduleViewportDirty()
349
- }
350
- }),
351
- )
352
-
353
333
  // Autorun: the selection. The hover paints on a layer of its own.
354
334
  addDisposer(
355
335
  self,
@@ -368,31 +348,22 @@ export const withRenderingActions = withLoadActions
368
348
  // read it, which is what lets a per-backend memo work.
369
349
  // eslint-disable-next-line no-restricted-syntax -- the pane uploads one batch, not keyed cells, which installUpload has no form for; its callbacks keep no memo, reading only the model
370
350
  self.attachRenderingBackend<Renderer>(backend, () => ({
371
- // Autorun: rebuild geometry when graph data or display options
372
- // change. scale/translate are untracked so they don't trigger a full
373
- // rebuild — only the debounced viewportDirty flag does.
351
+ // Autorun: rebuild geometry when graph data, display options or the
352
+ // build window change. The transform itself repaints, in `render`.
374
353
  upload: (b: Renderer) => {
375
354
  dependOn(trackedDpr())
376
355
  b.resize(self.paneWidth, self.canvasHeight)
377
356
  if (self.layoutResult?.tubeMap) {
378
- dependOn(self.viewportDirty)
379
357
  b.uploadGeometry(EMPTY_BATCH)
380
- self.setGeometryMetrics(0, EMPTY_BATCH, {
381
- scale: untracked(() => self.scale),
382
- bounds: untracked(() => self.viewportToBuild()),
383
- })
358
+ self.setGeometryMetrics(0, EMPTY_BATCH, self.buildView)
384
359
  return true
385
360
  }
386
- // The panels paint the drawings, built whenever the key first read
387
- // them, so the view recorded as built is theirs: a fit that lands
388
- // before or after it schedules their rebuild as it would the pane's
361
+ // The panels paint the drawings, so the view recorded as built is
362
+ // theirs
389
363
  const panel = self.facetDrawings?.[0]
390
364
  if (panel) {
391
365
  b.uploadGeometry(EMPTY_BATCH)
392
- self.setGeometryMetrics(0, EMPTY_BATCH, {
393
- scale: panel.scale,
394
- bounds: panel.viewportBounds,
395
- })
366
+ self.setGeometryMetrics(0, EMPTY_BATCH, panel.view)
396
367
  return true
397
368
  }
398
369
  const geometryStart = performance.now()
@@ -405,10 +376,7 @@ export const withRenderingActions = withLoadActions
405
376
  self.setGeometryMetrics(
406
377
  performance.now() - geometryStart,
407
378
  built.batch,
408
- {
409
- scale: untracked(() => self.scale),
410
- bounds: built.viewportBounds,
411
- },
379
+ built.view,
412
380
  )
413
381
  return true
414
382
  }