@jbrowse/plugin-linear-genome-view 5.0.0-beta.13 → 5.0.0-beta.16

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 (63) hide show
  1. package/esm/FeatureTrack/configSchema.d.ts +2 -1
  2. package/esm/FeatureTrack/configSchema.js +2 -1
  3. package/esm/LinearGenomeView/afterAttach.js +1 -23
  4. package/esm/LinearGenomeView/components/ExportSvgDialog.d.ts +6 -2
  5. package/esm/LinearGenomeView/components/ExportSvgDialog.js +31 -7
  6. package/esm/LinearGenomeView/components/HeaderPanControls.d.ts +3 -3
  7. package/esm/LinearGenomeView/components/HeaderPanControls.js +4 -2
  8. package/esm/LinearGenomeView/components/HighlightBand.d.ts +3 -2
  9. package/esm/LinearGenomeView/components/HighlightBand.js +4 -2
  10. package/esm/LinearGenomeView/components/HighlightChip.d.ts +3 -2
  11. package/esm/LinearGenomeView/components/HighlightChip.js +4 -2
  12. package/esm/LinearGenomeView/components/LinearGenomeView.js +5 -12
  13. package/esm/LinearGenomeView/components/LinearGenomeViewContainer.js +4 -5
  14. package/esm/LinearGenomeView/components/OverviewHighlightBand.d.ts +3 -2
  15. package/esm/LinearGenomeView/components/OverviewHighlightBand.js +4 -2
  16. package/esm/LinearGenomeView/components/RegionWidthEditorDialog.d.ts +3 -2
  17. package/esm/LinearGenomeView/components/RegionWidthEditorDialog.js +4 -4
  18. package/esm/LinearGenomeView/components/ScalebarRefNameLabels.js +4 -4
  19. package/esm/LinearGenomeView/components/SearchPanelForm.d.ts +3 -2
  20. package/esm/LinearGenomeView/components/SearchPanelForm.js +4 -2
  21. package/esm/LinearGenomeView/components/SearchResultsDialog.d.ts +4 -9
  22. package/esm/LinearGenomeView/components/SearchResultsDialog.js +7 -4
  23. package/esm/LinearGenomeView/components/SearchResultsTable.d.ts +3 -8
  24. package/esm/LinearGenomeView/components/SearchResultsTable.js +4 -32
  25. package/esm/LinearGenomeView/components/StrandCheckboxes.d.ts +3 -2
  26. package/esm/LinearGenomeView/components/StrandCheckboxes.js +4 -2
  27. package/esm/LinearGenomeView/components/TrackContainer.js +1 -1
  28. package/esm/LinearGenomeView/components/TrackLabelMenu.js +8 -12
  29. package/esm/LinearGenomeView/components/useRangeSelect.js +3 -2
  30. package/esm/LinearGenomeView/components/useSearchBoxPrefs.d.ts +3 -1
  31. package/esm/LinearGenomeView/components/useSearchBoxPrefs.js +4 -2
  32. package/esm/LinearGenomeView/components/useSideScroll.js +11 -12
  33. package/esm/LinearGenomeView/lazyDialogs.d.ts +17 -2
  34. package/esm/LinearGenomeView/menuItems.js +32 -24
  35. package/esm/LinearGenomeView/model.d.ts +197 -151
  36. package/esm/LinearGenomeView/model.js +203 -201
  37. package/esm/LinearGenomeView/rExport/exportLinearView.d.ts +13 -0
  38. package/esm/LinearGenomeView/rExport/exportLinearView.js +98 -0
  39. package/esm/LinearGenomeView/rExport/rScript.d.ts +75 -0
  40. package/esm/LinearGenomeView/rExport/rScript.js +465 -0
  41. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +3 -6
  42. package/esm/LinearGenomeView/svgcomponents/SVGStackedRow.d.ts +1 -2
  43. package/esm/LinearGenomeView/svgcomponents/SVGStackedRow.js +2 -2
  44. package/esm/LinearGenomeView/svgcomponents/SVGTracks.d.ts +1 -2
  45. package/esm/LinearGenomeView/svgcomponents/SVGTracks.js +4 -4
  46. package/esm/LinearGenomeView/svgcomponents/SVGView.d.ts +1 -2
  47. package/esm/LinearGenomeView/svgcomponents/SVGView.js +3 -3
  48. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.d.ts +22 -20
  49. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.js +42 -29
  50. package/esm/LinearGenomeView/svgcomponents/useViewSvgFigure.js +6 -11
  51. package/esm/LinearGenomeView/svgcomponents/util.d.ts +2 -1
  52. package/esm/LinearGenomeView/util.d.ts +42 -0
  53. package/esm/LinearGenomeView/util.js +81 -0
  54. package/esm/MultiLevelRubberband/MultiLevelRubberband.js +2 -2
  55. package/esm/displayKitTests/perRegionTestEnv.d.ts +45 -12
  56. package/esm/index.d.ts +4 -2
  57. package/esm/index.js +3 -1
  58. package/esm/searchUtils.js +1 -0
  59. package/esm/shared/RubberbandSpan.d.ts +3 -2
  60. package/esm/shared/RubberbandSpan.js +4 -2
  61. package/esm/shared/coordLabels.d.ts +6 -6
  62. package/esm/shared/coordLabels.js +7 -6
  63. package/package.json +9 -9
@@ -7,7 +7,7 @@ import type { TrackLabelMode } from '@jbrowse/display-kit/types';
7
7
  * reserves `getRowHeaderLayout().bandHeight` above it for the header to draw
8
8
  * into, and the row is `rulerHeight + rendered.tracksHeight` tall below it.
9
9
  */
10
- export default function SVGStackedRow({ view, rendered, top, margin, fontSize, textHeight, rulerHeight, trackLabels, trackLabelOffset, showGridlines, legendWidth, showAssemblyName, showScalebar, }: {
10
+ export default function SVGStackedRow({ view, rendered, top, margin, fontSize, textHeight, rulerHeight, trackLabels, trackLabelOffset, showGridlines, showAssemblyName, showScalebar, }: {
11
11
  view: LinearGenomeViewModel;
12
12
  rendered: {
13
13
  displayResults: SvgDisplayResult[];
@@ -21,7 +21,6 @@ export default function SVGStackedRow({ view, rendered, top, margin, fontSize, t
21
21
  trackLabels: TrackLabelMode;
22
22
  trackLabelOffset: number;
23
23
  showGridlines: boolean;
24
- legendWidth?: number;
25
24
  showAssemblyName?: boolean;
26
25
  showScalebar?: boolean;
27
26
  }): import("react").JSX.Element;
@@ -7,6 +7,6 @@ import SVGView from './SVGView.js';
7
7
  * reserves `getRowHeaderLayout().bandHeight` above it for the header to draw
8
8
  * into, and the row is `rulerHeight + rendered.tracksHeight` tall below it.
9
9
  */
10
- export default function SVGStackedRow({ view, rendered, top, margin, fontSize, textHeight, rulerHeight, trackLabels, trackLabelOffset, showGridlines, legendWidth, showAssemblyName, showScalebar, }) {
11
- return (_jsx("g", { transform: `translate(${margin} ${top})`, children: _jsx(SVGView, { view: view, displayResults: rendered.displayResults, header: _jsx(SVGRowHeader, { view: view, fontSize: fontSize, rulerHeight: rulerHeight, showAssemblyName: showAssemblyName, showScalebar: showScalebar }), fontSize: fontSize, textHeight: textHeight, trackLabels: trackLabels, trackLabelOffset: trackLabelOffset, contentTop: rulerHeight, tracksHeight: rendered.tracksHeight, showGridlines: showGridlines, leftBuffer: margin, legendWidth: legendWidth }) }));
10
+ export default function SVGStackedRow({ view, rendered, top, margin, fontSize, textHeight, rulerHeight, trackLabels, trackLabelOffset, showGridlines, showAssemblyName, showScalebar, }) {
11
+ return (_jsx("g", { transform: `translate(${margin} ${top})`, children: _jsx(SVGView, { view: view, displayResults: rendered.displayResults, header: _jsx(SVGRowHeader, { view: view, fontSize: fontSize, rulerHeight: rulerHeight, showAssemblyName: showAssemblyName, showScalebar: showScalebar }), fontSize: fontSize, textHeight: textHeight, trackLabels: trackLabels, trackLabelOffset: trackLabelOffset, contentTop: rulerHeight, tracksHeight: rendered.tracksHeight, showGridlines: showGridlines, leftBuffer: margin }) }));
12
12
  }
@@ -2,7 +2,7 @@ import type { LinearGenomeViewModel } from '../index.ts';
2
2
  import type { TrackLabelMode } from '../types.ts';
3
3
  import type { SvgDisplayResult } from './util.ts';
4
4
  type LGV = LinearGenomeViewModel;
5
- export default function SVGTracks({ displayResults, model, textHeight, fontSize, trackLabels, trackLabelOffset, leftBuffer, legendWidth, }: {
5
+ export default function SVGTracks({ displayResults, model, textHeight, fontSize, trackLabels, trackLabelOffset, leftBuffer, }: {
6
6
  displayResults: SvgDisplayResult[];
7
7
  model: LGV;
8
8
  textHeight: number;
@@ -10,6 +10,5 @@ export default function SVGTracks({ displayResults, model, textHeight, fontSize,
10
10
  trackLabels: TrackLabelMode;
11
11
  trackLabelOffset: number;
12
12
  leftBuffer: number;
13
- legendWidth: number;
14
13
  }): import("react").JSX.Element;
15
14
  export {};
@@ -3,20 +3,20 @@ import { SvgClipRect } from '@jbrowse/core/svg/SvgExport';
3
3
  import { svgNodeId } from '@jbrowse/core/svg/svgId';
4
4
  import { svgTrackName } from '@jbrowse/core/svg/trackNames';
5
5
  import { getSession } from '@jbrowse/core/util';
6
- import { exportsTooLargeNote } from '@jbrowse/display-kit/renderDisplaySvg';
6
+ import { SvgLegend } from '@jbrowse/display-kit/renderDisplaySvg';
7
7
  import SVGRegionSeparators from './SVGRegionSeparators.js';
8
8
  import SVGTrackLabel from './SVGTrackLabel.js';
9
9
  import { labelOffset, trackBoxOffsets, trackLabelMode } from './util.js';
10
- export default function SVGTracks({ displayResults, model, textHeight, fontSize, trackLabels, trackLabelOffset, leftBuffer, legendWidth, }) {
10
+ export default function SVGTracks({ displayResults, model, textHeight, fontSize, trackLabels, trackLabelOffset, leftBuffer, }) {
11
11
  const session = getSession(model);
12
12
  const x = Math.max(-model.offsetPx, 0);
13
13
  const offsets = trackBoxOffsets(displayResults.map(r => r.track), trackLabels, textHeight);
14
- return (_jsx(_Fragment, { children: displayResults.map(({ track, result }, i) => {
14
+ return (_jsx(_Fragment, { children: displayResults.map(({ track, result, legendHeight }, i) => {
15
15
  const conf = track.configuration;
16
16
  const trackName = svgTrackName(track, session);
17
17
  const display = track.displays[0];
18
18
  const currentOffset = offsets[i];
19
19
  const textOffset = labelOffset(track, trackLabels, textHeight);
20
- return (_jsxs("g", { transform: `translate(0 ${currentOffset})`, children: [_jsx(SvgClipRect, { id: `track-clip-${svgNodeId(model)}-${conf.trackId}`, x: -leftBuffer, y: textOffset, width: model.width + trackLabelOffset + leftBuffer + legendWidth, height: display.height, children: _jsxs("g", { transform: `translate(${trackLabelOffset} ${textOffset})`, children: [result, exportsTooLargeNote(display) ? null : (_jsx(SVGRegionSeparators, { model: model, height: display.height }))] }) }), _jsx(SVGTrackLabel, { trackName: trackName, fontSize: fontSize, textHeight: textHeight, trackLabels: trackLabelMode(track, trackLabels), trackLabelOffset: trackLabelOffset, x: x + trackLabelOffset })] }, conf.trackId));
20
+ return (_jsxs("g", { transform: `translate(0 ${currentOffset})`, children: [_jsx(SvgClipRect, { id: `track-clip-${svgNodeId(model)}-${conf.trackId}`, x: -leftBuffer, y: textOffset, width: model.width + trackLabelOffset + leftBuffer, height: display.height, children: _jsxs("g", { transform: `translate(${trackLabelOffset} ${textOffset})`, children: [result, display.regionTooLarge ? null : (_jsx(SVGRegionSeparators, { model: model, height: display.height }))] }) }), legendHeight === undefined ? null : (_jsx("g", { transform: `translate(${trackLabelOffset} ${textOffset})`, children: _jsx(SvgLegend, { model: display, width: model.width, height: legendHeight }) })), _jsx(SVGTrackLabel, { trackName: trackName, fontSize: fontSize, textHeight: textHeight, trackLabels: trackLabelMode(track, trackLabels), trackLabelOffset: trackLabelOffset, x: x + trackLabelOffset })] }, conf.trackId));
21
21
  }) }));
22
22
  }
@@ -2,7 +2,7 @@ import type { LinearGenomeViewModel } from '../index.ts';
2
2
  import type { TrackLabelMode } from '../types.ts';
3
3
  import type { SvgDisplayResult } from './util.ts';
4
4
  import type { ReactNode } from 'react';
5
- export default function SVGView({ view, displayResults, header, fontSize, textHeight, trackLabels, trackLabelOffset, contentTop, tracksHeight, showGridlines, leftBuffer, legendWidth, }: {
5
+ export default function SVGView({ view, displayResults, header, fontSize, textHeight, trackLabels, trackLabelOffset, contentTop, tracksHeight, showGridlines, leftBuffer, }: {
6
6
  view: LinearGenomeViewModel;
7
7
  displayResults: SvgDisplayResult[];
8
8
  header: ReactNode;
@@ -14,5 +14,4 @@ export default function SVGView({ view, displayResults, header, fontSize, textHe
14
14
  tracksHeight: number;
15
15
  showGridlines: boolean;
16
16
  leftBuffer: number;
17
- legendWidth?: number;
18
17
  }): import("react").JSX.Element;
@@ -7,7 +7,7 @@ import SVGTracks from './SVGTracks.js';
7
7
  // Shared by all three exports that stack an LGV — the standalone one, and the
8
8
  // linear-synteny and breakpoint-split rows — so their per-view layout can't
9
9
  // drift. It did drift while the standalone export kept its own copy of these
10
- // four groups: only that copy widened the per-track clip by `legendWidth`.
11
- export default function SVGView({ view, displayResults, header, fontSize, textHeight, trackLabels, trackLabelOffset, contentTop, tracksHeight, showGridlines, leftBuffer, legendWidth = 0, }) {
12
- return (_jsxs(_Fragment, { children: [_jsx("g", { transform: `translate(${trackLabelOffset})`, children: header }), showGridlines ? (_jsx("g", { transform: `translate(${trackLabelOffset} ${contentTop})`, children: _jsx(SVGGridlines, { model: view, height: tracksHeight }) })) : null, _jsx("g", { transform: `translate(0 ${contentTop})`, children: _jsx(SVGTracks, { textHeight: textHeight, trackLabels: trackLabels, fontSize: fontSize, model: view, displayResults: displayResults, trackLabelOffset: trackLabelOffset, leftBuffer: leftBuffer, legendWidth: legendWidth }) }), _jsx("g", { transform: `translate(${trackLabelOffset} ${contentTop})`, children: _jsx(SVGHighlightsOverlay, { model: view, tracksHeight: tracksHeight }) })] }));
10
+ // four groups.
11
+ export default function SVGView({ view, displayResults, header, fontSize, textHeight, trackLabels, trackLabelOffset, contentTop, tracksHeight, showGridlines, leftBuffer, }) {
12
+ return (_jsxs(_Fragment, { children: [_jsx("g", { transform: `translate(${trackLabelOffset})`, children: header }), showGridlines ? (_jsx("g", { transform: `translate(${trackLabelOffset} ${contentTop})`, children: _jsx(SVGGridlines, { model: view, height: tracksHeight }) })) : null, _jsx("g", { transform: `translate(0 ${contentTop})`, children: _jsx(SVGTracks, { textHeight: textHeight, trackLabels: trackLabels, fontSize: fontSize, model: view, displayResults: displayResults, trackLabelOffset: trackLabelOffset, leftBuffer: leftBuffer }) }), _jsx("g", { transform: `translate(${trackLabelOffset} ${contentTop})`, children: _jsx(SVGHighlightsOverlay, { model: view, tracksHeight: tracksHeight }) })] }));
13
13
  }
@@ -7,7 +7,7 @@ export interface SvgExportTrack {
7
7
  minimized: boolean;
8
8
  displays: {
9
9
  height: number;
10
- svgLegendWidth?: () => number;
10
+ regionTooLarge?: boolean;
11
11
  svgSidebarWidth?: LgvSvgExportable['svgSidebarWidth'];
12
12
  /**
13
13
  * Optional, and the option is the point: SVG export is a substantial extra
@@ -23,13 +23,18 @@ export interface SvgExportTrack {
23
23
  export interface ViewTracksSvg<T> {
24
24
  /** the tracks that were rendered, in the order they were laid out */
25
25
  tracks: T[];
26
+ /**
27
+ * `legendHeight` is the room a track's key has in the gutter, absent for a
28
+ * track with no key to draw
29
+ */
26
30
  displayResults: {
27
31
  track: T;
28
32
  result: ReactNode;
33
+ legendHeight?: number;
29
34
  }[];
30
35
  /** total height of the stack, valid only because the renders above resolved */
31
36
  tracksHeight: number;
32
- /** 0 unless `reserveLegendWidth` was asked for */
37
+ /** px the caller widens its canvas by for the keys right of the plot */
33
38
  legendWidth: number;
34
39
  /**
35
40
  * Visible tracks left out because their display implements no `renderSvg`.
@@ -42,30 +47,28 @@ export interface ViewTracksSvg<T> {
42
47
  * One view's worth of exported track bodies: which tracks are in, their
43
48
  * rendered SVG, and how tall the stack ends up.
44
49
  *
45
- * It exists to own the two orderings that each of the three view exports got
46
- * wrong at least once, because neither is visible at a call site that merely
47
- * lists the same statements in some order:
50
+ * It exists to own an ordering that each of the three view exports got wrong at
51
+ * least once, because it is not visible at a call site that merely lists the
52
+ * same statements in some order: the geometry is measured **after** the
53
+ * awaits.
48
54
  *
49
- * - `legendWidth` is measured **before** the awaits, because it is an input to
50
- * them: a display draws its legend beside its body or floating over it
51
- * depending on whether the container reserved room. That is why
52
- * `svgLegendWidth` is specified as a function of the *settings* and not of
53
- * the loaded data — see LinearHicDisplay's implementation.
54
- * - `tracksHeight` is measured **after** them. A display whose height follows
55
- * its data (grow mode; `LinearMultiRowFeatureDisplay` is `nrow *
56
- * effectiveRowHeight`) only reaches its final height once `renderSvg`'s
57
- * readiness wait resolves, and `SVGTracks` re-reads `displays[0].height`
58
- * later still. Measuring up front sized the canvas for the pre-fetch height
59
- * and the taller bodies ran off the bottom of the export — and in the
60
- * breakpoint-split export it also desynced the overlay anchors, resolved
61
- * after, from the view tops, which weren't.
55
+ * - `tracksHeight`: a display whose height follows its data (grow mode;
56
+ * `LinearMultiRowFeatureDisplay` is `nrow * effectiveRowHeight`) only reaches
57
+ * its final height once `renderSvg`'s readiness wait resolves, and
58
+ * `SVGTracks` re-reads `displays[0].height` later still. Measuring up front
59
+ * sized the canvas for the pre-fetch height and the taller bodies ran off the
60
+ * bottom of the export — and in the breakpoint-split export it also desynced
61
+ * the overlay anchors, resolved after, from the view tops, which weren't.
62
+ * - `legendWidth`: most keys list what was loaded, and on a headless export
63
+ * (jbrowse-img) nothing has loaded before the waits. Measured after, a track
64
+ * with no key reserves nothing and the figure has no empty strip.
62
65
  *
63
66
  * The minimized filter and the track order are here for the same reason: the
64
67
  * reserved height, the rendered bodies, the label gutter and (breakpoint-split)
65
68
  * the ribbon anchors must all be derived from one list, and pinned tracks are
66
69
  * drawn at the top of a view on screen.
67
70
  */
68
- export declare function renderViewTracks<T extends SvgExportTrack>({ view, opts, theme, textHeight, trackLabels, reserveLegendWidth, }: {
71
+ export declare function renderViewTracks<T extends SvgExportTrack>({ view, opts, theme, textHeight, trackLabels, }: {
69
72
  view: {
70
73
  pinnedTracks: T[];
71
74
  unpinnedTracks: T[];
@@ -74,5 +77,4 @@ export declare function renderViewTracks<T extends SvgExportTrack>({ view, opts,
74
77
  theme: ThemeOptions | undefined;
75
78
  textHeight: number;
76
79
  trackLabels: TrackLabelMode;
77
- reserveLegendWidth?: boolean;
78
80
  }): Promise<ViewTracksSvg<T>>;
@@ -1,34 +1,33 @@
1
1
  import { awaitSvgRenders } from '@jbrowse/core/svg/svgReady';
2
2
  import { max } from '@jbrowse/core/util';
3
- import { totalHeight } from './util.js';
3
+ import { svgLegendGutterWidth } from '@jbrowse/display-kit/renderDisplaySvg';
4
+ import { labelOffset, totalHeight, trackBoxOffsets } from './util.js';
4
5
  /**
5
6
  * One view's worth of exported track bodies: which tracks are in, their
6
7
  * rendered SVG, and how tall the stack ends up.
7
8
  *
8
- * It exists to own the two orderings that each of the three view exports got
9
- * wrong at least once, because neither is visible at a call site that merely
10
- * lists the same statements in some order:
9
+ * It exists to own an ordering that each of the three view exports got wrong at
10
+ * least once, because it is not visible at a call site that merely lists the
11
+ * same statements in some order: the geometry is measured **after** the
12
+ * awaits.
11
13
  *
12
- * - `legendWidth` is measured **before** the awaits, because it is an input to
13
- * them: a display draws its legend beside its body or floating over it
14
- * depending on whether the container reserved room. That is why
15
- * `svgLegendWidth` is specified as a function of the *settings* and not of
16
- * the loaded data — see LinearHicDisplay's implementation.
17
- * - `tracksHeight` is measured **after** them. A display whose height follows
18
- * its data (grow mode; `LinearMultiRowFeatureDisplay` is `nrow *
19
- * effectiveRowHeight`) only reaches its final height once `renderSvg`'s
20
- * readiness wait resolves, and `SVGTracks` re-reads `displays[0].height`
21
- * later still. Measuring up front sized the canvas for the pre-fetch height
22
- * and the taller bodies ran off the bottom of the export — and in the
23
- * breakpoint-split export it also desynced the overlay anchors, resolved
24
- * after, from the view tops, which weren't.
14
+ * - `tracksHeight`: a display whose height follows its data (grow mode;
15
+ * `LinearMultiRowFeatureDisplay` is `nrow * effectiveRowHeight`) only reaches
16
+ * its final height once `renderSvg`'s readiness wait resolves, and
17
+ * `SVGTracks` re-reads `displays[0].height` later still. Measuring up front
18
+ * sized the canvas for the pre-fetch height and the taller bodies ran off the
19
+ * bottom of the export — and in the breakpoint-split export it also desynced
20
+ * the overlay anchors, resolved after, from the view tops, which weren't.
21
+ * - `legendWidth`: most keys list what was loaded, and on a headless export
22
+ * (jbrowse-img) nothing has loaded before the waits. Measured after, a track
23
+ * with no key reserves nothing and the figure has no empty strip.
25
24
  *
26
25
  * The minimized filter and the track order are here for the same reason: the
27
26
  * reserved height, the rendered bodies, the label gutter and (breakpoint-split)
28
27
  * the ribbon anchors must all be derived from one list, and pinned tracks are
29
28
  * drawn at the top of a view on screen.
30
29
  */
31
- export async function renderViewTracks({ view, opts, theme, textHeight, trackLabels, reserveLegendWidth = false, }) {
30
+ export async function renderViewTracks({ view, opts, theme, textHeight, trackLabels, }) {
32
31
  // Partitioned before anything is measured, so a skipped track reserves no
33
32
  // height and takes no place in the label gutter — the alternative is a figure
34
33
  // with a labelled empty band where the track would have been. One pass, so
@@ -42,25 +41,39 @@ export async function renderViewTracks({ view, opts, theme, textHeight, trackLab
42
41
  (track.displays[0]?.renderSvg ? tracks : skippedTracks).push(track);
43
42
  }
44
43
  }
45
- const legendWidth = reserveLegendWidth
46
- ? max(tracks.map(track => track.displays[0].svgLegendWidth?.() ?? 0), 0)
47
- : 0;
48
44
  // `awaitSvgRenders` over `Promise.all`: a track whose data won't load fails
49
45
  // the export, and a view with three broken tracks should say so once rather
50
46
  // than name whichever rejected first
51
47
  const displayResults = await awaitSvgRenders(tracks.map(async (track) => ({
52
48
  track,
53
- result: await track.displays[0].renderSvg({
54
- ...opts,
55
- theme,
56
- legendWidth,
57
- }),
49
+ result: await track.displays[0].renderSvg({ ...opts, theme }),
58
50
  })));
51
+ const tracksHeight = totalHeight(tracks, trackLabels, textHeight);
52
+ const keyed = tracks.map(track => !track.displays[0].regionTooLarge &&
53
+ svgLegendGutterWidth(track.displays[0], theme, Infinity) > 0);
54
+ const bodyTops = trackBoxOffsets(tracks, trackLabels, textHeight).map((top, i) => top + labelOffset(tracks[i], trackLabels, textHeight));
55
+ // A key runs from its body's top to the next keyed body's, or to the foot of
56
+ // the stack, so a long key beside a short track carries on past the unkeyed
57
+ // tracks below it before it cuts to "+N more".
58
+ const legendHeights = keyed.map((isKeyed, i) => {
59
+ const next = keyed.findIndex((k, j) => k && j > i);
60
+ return isKeyed
61
+ ? (next === -1 ? tracksHeight : bodyTops[next]) - bodyTops[i]
62
+ : undefined;
63
+ });
59
64
  return {
60
65
  tracks,
61
- displayResults,
62
- tracksHeight: totalHeight(tracks, trackLabels, textHeight),
63
- legendWidth,
66
+ displayResults: displayResults.map((r, i) => ({
67
+ ...r,
68
+ legendHeight: legendHeights[i],
69
+ })),
70
+ tracksHeight,
71
+ legendWidth: max(tracks.map((track, i) => {
72
+ const height = legendHeights[i];
73
+ return height === undefined
74
+ ? 0
75
+ : svgLegendGutterWidth(track.displays[0], theme, height);
76
+ }), 0),
64
77
  skippedTracks,
65
78
  };
66
79
  }
@@ -16,12 +16,11 @@ import { defaultTextHeight, getRowHeaderLayout, trackLabelLeftOffset, } from './
16
16
  * One figure: every visible track rendered to SVG elements, and the geometry
17
17
  * that lays them out.
18
18
  *
19
- * `renderViewTracks` owns the two orderings this cannot state for itself — the
20
- * legend gutter measured before the renders (a display draws its key beside the
21
- * plot or floating over it depending on whether the container reserved room),
22
- * the stack height after them (a display whose height follows its data only
23
- * reaches its final height once its readiness wait resolves). Everything read
24
- * below is read after the awaits for the same reason.
19
+ * `renderViewTracks` owns the ordering this cannot state for itself: the stack
20
+ * height and the legend gutter are measured after the renders, since a
21
+ * display's height and its key follow data that lands only once its readiness
22
+ * wait resolves. Everything read below is read after the awaits for the same
23
+ * reason.
25
24
  */
26
25
  async function renderFigure(view, opts) {
27
26
  const { fontSize, rulerHeight, trackLabels, rasterizeLayers, showScalebar } = opts;
@@ -39,9 +38,6 @@ async function renderFigure(view, opts) {
39
38
  theme,
40
39
  textHeight,
41
40
  trackLabels,
42
- // an inline figure has room to give: a legend sits beside the plot rather
43
- // than over it
44
- reserveLegendWidth: true,
45
41
  });
46
42
  // the room the row header needs *above* its own origin — it draws the assembly
47
43
  // name and the scalebar at negative y, so the caller reserves the band and
@@ -61,7 +57,6 @@ async function renderFigure(view, opts) {
61
57
  height: bandHeight + rulerHeight + tracksHeight + opts.margin,
62
58
  bandHeight,
63
59
  tracksHeight,
64
- legendWidth,
65
60
  trackLabelOffset,
66
61
  textHeight,
67
62
  locstring: view.visibleLocStrings,
@@ -108,7 +103,7 @@ const FrozenSvgFigure = memo(function FrozenSvgFigure({ view, snapshot, }) {
108
103
  // anything passed per-render would have to reach past the memo above,
109
104
  // which is the one thing holding the figure's two halves together. A
110
105
  // host that wants other sizing wraps this in a box of its own.
111
- style: { display: 'block', maxWidth: '100%' }, children: _jsx(SVGStackedRow, { view: view, rendered: snapshot, top: snapshot.bandHeight, margin: margin, fontSize: snapshot.fontSize, textHeight: snapshot.textHeight, rulerHeight: snapshot.rulerHeight, trackLabels: snapshot.trackLabels, trackLabelOffset: snapshot.trackLabelOffset, showGridlines: snapshot.showGridlines, legendWidth: snapshot.legendWidth, showScalebar: snapshot.showScalebar }) }) }));
106
+ style: { display: 'block', maxWidth: '100%' }, children: _jsx(SVGStackedRow, { view: view, rendered: snapshot, top: snapshot.bandHeight, margin: margin, fontSize: snapshot.fontSize, textHeight: snapshot.textHeight, rulerHeight: snapshot.rulerHeight, trackLabels: snapshot.trackLabels, trackLabelOffset: snapshot.trackLabelOffset, showGridlines: snapshot.showGridlines, showScalebar: snapshot.showScalebar }) }) }));
112
107
  });
113
108
  /**
114
109
  * What "the figure is out of date" means, as a string.
@@ -17,10 +17,11 @@ export interface SvgDisplayResult {
17
17
  displays: ({
18
18
  height: number;
19
19
  regionTooLarge?: boolean;
20
- drawsWhenTooLarge?: boolean;
21
20
  } & SidebarDisplay)[];
22
21
  };
23
22
  result: ReactNode;
23
+ /** the room its key has in the export's legend gutter, absent for no key */
24
+ legendHeight?: number;
24
25
  }
25
26
  export declare const trackSpacing = 2;
26
27
  export declare function gridlineTickXs(model: {
@@ -361,5 +361,47 @@ export declare function generateLocations({ regions, assemblyManager, assemblyNa
361
361
  * Used by navToLocString
362
362
  */
363
363
  export declare function parseLocStrings(input: string, assemblyName: string, isValidRefName: (str: string, assemblyName: string) => boolean): ParsedLocString[];
364
+ /** One span of the row that is not track data — see `paddingSpans`. */
365
+ export interface PaddingSpan {
366
+ key: string;
367
+ x: number;
368
+ width: number;
369
+ kind: 'seam' | 'elided' | 'boundary';
370
+ }
371
+ /**
372
+ * Tick positions in the staticBlocks frame, one pass per merged run so a tick
373
+ * on an internal ~800px chunk boundary is emitted once.
374
+ */
375
+ export declare function getGridlineTicks({ blocks, firstBlockOffset, bpPerPx, }: {
376
+ blocks: BaseBlock[];
377
+ firstBlockOffset: number;
378
+ bpPerPx: number;
379
+ }): {
380
+ x: number;
381
+ major: boolean;
382
+ }[];
383
+ /**
384
+ * Coordinate labels in the staticBlocks frame, off the same ticks as
385
+ * `getGridlineTicks`. A run that can hold too few labels to make a ruler goes
386
+ * unnumbered, and the bold refName label pinned at a run's left edge takes
387
+ * precedence over a number.
388
+ */
389
+ export declare function getScalebarLabels({ blocks, firstBlockOffset, bpPerPx, orientation, }: {
390
+ blocks: BaseBlock[];
391
+ firstBlockOffset: number;
392
+ bpPerPx: number;
393
+ orientation: RegionsOrientation;
394
+ }): {
395
+ x: number;
396
+ label: string;
397
+ key: string;
398
+ }[];
399
+ /**
400
+ * Every span along the row that is not track data, in the staticBlocks frame.
401
+ * Nothing to draw returns one shared array, so the computed's value repeats and
402
+ * MobX's `===` stops the chain: a view inside one contig has no seam, elision
403
+ * or boundary, and a fresh `[]` each frame re-rendered every track's padding.
404
+ */
405
+ export declare function getPaddingSpans(blocks: BaseBlock[], firstBlockOffset: number): readonly PaddingSpan[];
364
406
  export declare function calculateVisibleLocStrings(contentBlocks: ContentBlock[]): string;
365
407
  export {};
@@ -636,6 +636,87 @@ export function parseLocStrings(input, assemblyName, isValidRefName) {
636
636
  throw e;
637
637
  }
638
638
  }
639
+ // Frozen because every consumer maps over it and a caller that sorted in place
640
+ // would do so for the whole session.
641
+ const NO_PADDING_SPANS = Object.freeze([]);
642
+ /**
643
+ * Tick positions in the staticBlocks frame, one pass per merged run so a tick
644
+ * on an internal ~800px chunk boundary is emitted once.
645
+ */
646
+ export function getGridlineTicks({ blocks, firstBlockOffset, bpPerPx, }) {
647
+ const ticks = [];
648
+ for (const run of groupContiguousBlocks(blocks)) {
649
+ const runLeft = run.offsetPx - firstBlockOffset;
650
+ for (const { type, x } of makeBlockTicks(run, bpPerPx)) {
651
+ if (x >= 0 && x <= run.widthPx) {
652
+ ticks.push({ x: runLeft + x, major: type === 'major' });
653
+ }
654
+ }
655
+ }
656
+ return ticks;
657
+ }
658
+ /**
659
+ * Coordinate labels in the staticBlocks frame, off the same ticks as
660
+ * `getGridlineTicks`. A run that can hold too few labels to make a ruler goes
661
+ * unnumbered, and the bold refName label pinned at a run's left edge takes
662
+ * precedence over a number.
663
+ */
664
+ export function getScalebarLabels({ blocks, firstBlockOffset, bpPerPx, orientation, }) {
665
+ const labels = [];
666
+ const runs = groupContiguousBlocks(blocks);
667
+ const refNameLabelPx = runRefNameLabelPx(runs, orientation);
668
+ for (const [i, run] of runs.entries()) {
669
+ const runLeft = run.offsetPx - firstBlockOffset;
670
+ const runLabels = [];
671
+ for (const { base, x } of makeBlockTicks(run, bpPerPx, false)) {
672
+ const label = getTickDisplayStr(base + 1, bpPerPx);
673
+ const w = tickLabelWidth(label);
674
+ if (x - w / 2 >= refNameLabelPx[i] &&
675
+ labelFitsInBlock(x - w / 2, w, run.widthPx)) {
676
+ runLabels.push({
677
+ x: runLeft + x,
678
+ label,
679
+ key: `${run.offsetPx}-${base}`,
680
+ });
681
+ }
682
+ }
683
+ if (tickLabelsWorthDrawing(runLabels.length)) {
684
+ labels.push(...runLabels);
685
+ }
686
+ }
687
+ return labels;
688
+ }
689
+ /**
690
+ * Every span along the row that is not track data, in the staticBlocks frame.
691
+ * Nothing to draw returns one shared array, so the computed's value repeats and
692
+ * MobX's `===` stops the chain: a view inside one contig has no seam, elision
693
+ * or boundary, and a fresh `[]` each frame re-rendered every track's padding.
694
+ */
695
+ export function getPaddingSpans(blocks, firstBlockOffset) {
696
+ const spans = [];
697
+ for (const block of blocks) {
698
+ const x = block.offsetPx - firstBlockOffset;
699
+ if (block.type === 'ContentBlock') {
700
+ if (block.isRightEndOfDisplayedRegion) {
701
+ spans.push({
702
+ key: `${block.key}-sep`,
703
+ x: x + block.widthPx - 1,
704
+ width: 3,
705
+ kind: 'seam',
706
+ });
707
+ }
708
+ }
709
+ else {
710
+ spans.push({
711
+ key: block.key,
712
+ x,
713
+ width: block.widthPx,
714
+ kind: block.type === 'ElidedBlock' ? 'elided' : 'boundary',
715
+ });
716
+ }
717
+ }
718
+ return spans.length > 0 ? spans : NO_PADDING_SPANS;
719
+ }
639
720
  export function calculateVisibleLocStrings(contentBlocks) {
640
721
  return assembleLocStrings(contentBlocks.map(block => ({
641
722
  refName: block.refName,
@@ -34,7 +34,7 @@ const MultiLevelRubberband = observer(function MultiLevelRubberband({ model, Con
34
34
  });
35
35
  // one row per rubberband level, in level order. values repeat across levels
36
36
  // whenever the assemblies line up, so the index is the only stable key
37
- function PerLevelRows({ rows }) {
37
+ const PerLevelRows = observer(function PerLevelRows({ rows, }) {
38
38
  return rows.map((row, idx) => (_jsx("div", { children: row }, idx)));
39
- }
39
+ });
40
40
  export default MultiLevelRubberband;
@@ -245,6 +245,8 @@ declare function makeStateModel(control: PerRegionTestControl, gate: GateOptIns,
245
245
  }, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>>;
246
246
  };
247
247
  trackMenuItems(): import("@jbrowse/core/ui").MenuItem[];
248
+ configProblemsOf(conf: import("@jbrowse/core/configuration").AnyConfigurationModel): string[];
249
+ readonly liveNotices: string[];
248
250
  } & {
249
251
  setStatusMessage(status?: import("@jbrowse/core/util").RpcStatus): void;
250
252
  setError(error?: unknown): void;
@@ -263,15 +265,23 @@ declare function makeStateModel(control: PerRegionTestControl, gate: GateOptIns,
263
265
  } & {
264
266
  readonly plotKeys: string[];
265
267
  readonly plot: import("@jbrowse/core/configuration").Plot;
268
+ readonly configNotices: string[];
269
+ readonly notices: string[];
270
+ readonly cornerNotices: string[];
266
271
  readonly plotExamples: readonly import("@jbrowse/core/configuration").PlotExample[];
267
272
  readonly configDocsUrl: string;
268
- liftPlot(draft: import("@jbrowse/core/configuration").Plot): import("@jbrowse/core/configuration").AnyConfigurationModel;
269
- plotProblems(draft: import("@jbrowse/core/configuration").Plot): string[];
270
- plotWrites(draft: import("@jbrowse/core/configuration").Plot): Record<string, unknown>;
273
+ liftPlot(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): import("@jbrowse/core/configuration").AnyConfigurationModel;
274
+ plotProblems(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): string[];
275
+ plotWrites(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): Record<string, unknown>;
271
276
  } & {
272
- applyPlot(draft: import("@jbrowse/core/configuration").Plot): void;
277
+ applyPlot(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): void;
273
278
  } & {
274
279
  scrollTop: number;
280
+ hostHeight: number | undefined;
281
+ } & {
282
+ readonly configuredHeight: number;
283
+ } & {
284
+ readonly allottedHeight: number;
275
285
  } & {
276
286
  readonly height: number;
277
287
  readonly resizing: boolean;
@@ -281,6 +291,7 @@ declare function makeStateModel(control: PerRegionTestControl, gate: GateOptIns,
281
291
  readonly scrollableHeight: number;
282
292
  } & {
283
293
  setScrollTop(scrollTop: number): void;
294
+ setHostHeight(height: number | undefined): void;
284
295
  setHeight(displayHeight: number): number;
285
296
  resizeHeight(distance: number): number;
286
297
  } & {
@@ -772,6 +783,8 @@ export declare function createPerRegionTestEnvironment({ measuresBytes, gate, es
772
783
  }, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>>;
773
784
  };
774
785
  trackMenuItems(): import("@jbrowse/core/ui").MenuItem[];
786
+ configProblemsOf(conf: import("@jbrowse/core/configuration").AnyConfigurationModel): string[];
787
+ readonly liveNotices: string[];
775
788
  } & {
776
789
  setStatusMessage(status?: import("@jbrowse/core/util").RpcStatus): void;
777
790
  setError(error?: unknown): void;
@@ -790,15 +803,23 @@ export declare function createPerRegionTestEnvironment({ measuresBytes, gate, es
790
803
  } & {
791
804
  readonly plotKeys: string[];
792
805
  readonly plot: import("@jbrowse/core/configuration").Plot;
806
+ readonly configNotices: string[];
807
+ readonly notices: string[];
808
+ readonly cornerNotices: string[];
793
809
  readonly plotExamples: readonly import("@jbrowse/core/configuration").PlotExample[];
794
810
  readonly configDocsUrl: string;
795
- liftPlot(draft: import("@jbrowse/core/configuration").Plot): import("@jbrowse/core/configuration").AnyConfigurationModel;
796
- plotProblems(draft: import("@jbrowse/core/configuration").Plot): string[];
797
- plotWrites(draft: import("@jbrowse/core/configuration").Plot): Record<string, unknown>;
811
+ liftPlot(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): import("@jbrowse/core/configuration").AnyConfigurationModel;
812
+ plotProblems(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): string[];
813
+ plotWrites(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): Record<string, unknown>;
798
814
  } & {
799
- applyPlot(draft: import("@jbrowse/core/configuration").Plot): void;
815
+ applyPlot(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): void;
800
816
  } & {
801
817
  scrollTop: number;
818
+ hostHeight: number | undefined;
819
+ } & {
820
+ readonly configuredHeight: number;
821
+ } & {
822
+ readonly allottedHeight: number;
802
823
  } & {
803
824
  readonly height: number;
804
825
  readonly resizing: boolean;
@@ -808,6 +829,7 @@ export declare function createPerRegionTestEnvironment({ measuresBytes, gate, es
808
829
  readonly scrollableHeight: number;
809
830
  } & {
810
831
  setScrollTop(scrollTop: number): void;
832
+ setHostHeight(height: number | undefined): void;
811
833
  setHeight(displayHeight: number): number;
812
834
  resizeHeight(distance: number): number;
813
835
  } & {
@@ -1188,6 +1210,8 @@ export declare function createPerRegionTestEnvironment({ measuresBytes, gate, es
1188
1210
  }, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>>;
1189
1211
  };
1190
1212
  trackMenuItems(): import("@jbrowse/core/ui").MenuItem[];
1213
+ configProblemsOf(conf: import("@jbrowse/core/configuration").AnyConfigurationModel): string[];
1214
+ readonly liveNotices: string[];
1191
1215
  } & {
1192
1216
  setStatusMessage(status?: import("@jbrowse/core/util").RpcStatus): void;
1193
1217
  setError(error?: unknown): void;
@@ -1206,15 +1230,23 @@ export declare function createPerRegionTestEnvironment({ measuresBytes, gate, es
1206
1230
  } & {
1207
1231
  readonly plotKeys: string[];
1208
1232
  readonly plot: import("@jbrowse/core/configuration").Plot;
1233
+ readonly configNotices: string[];
1234
+ readonly notices: string[];
1235
+ readonly cornerNotices: string[];
1209
1236
  readonly plotExamples: readonly import("@jbrowse/core/configuration").PlotExample[];
1210
1237
  readonly configDocsUrl: string;
1211
- liftPlot(draft: import("@jbrowse/core/configuration").Plot): import("@jbrowse/core/configuration").AnyConfigurationModel;
1212
- plotProblems(draft: import("@jbrowse/core/configuration").Plot): string[];
1213
- plotWrites(draft: import("@jbrowse/core/configuration").Plot): Record<string, unknown>;
1238
+ liftPlot(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): import("@jbrowse/core/configuration").AnyConfigurationModel;
1239
+ plotProblems(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): string[];
1240
+ plotWrites(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): Record<string, unknown>;
1214
1241
  } & {
1215
- applyPlot(draft: import("@jbrowse/core/configuration").Plot): void;
1242
+ applyPlot(draft: import("@jbrowse/core/configuration").Plot, options?: import("@jbrowse/core/configuration").PlotWriteOptions): void;
1216
1243
  } & {
1217
1244
  scrollTop: number;
1245
+ hostHeight: number | undefined;
1246
+ } & {
1247
+ readonly configuredHeight: number;
1248
+ } & {
1249
+ readonly allottedHeight: number;
1218
1250
  } & {
1219
1251
  readonly height: number;
1220
1252
  readonly resizing: boolean;
@@ -1224,6 +1256,7 @@ export declare function createPerRegionTestEnvironment({ measuresBytes, gate, es
1224
1256
  readonly scrollableHeight: number;
1225
1257
  } & {
1226
1258
  setScrollTop(scrollTop: number): void;
1259
+ setHostHeight(height: number | undefined): void;
1227
1260
  setHeight(displayHeight: number): number;
1228
1261
  resizeHeight(distance: number): number;
1229
1262
  } & {