@jbrowse/plugin-linear-genome-view 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/BaseLinearDisplay/components/LinearBlocks.js +1 -1
  2. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +9 -9
  3. package/dist/LaunchLinearGenomeView/index.js +9 -5
  4. package/dist/LinearBasicDisplay/components/AddFiltersDialog.js +1 -1
  5. package/dist/LinearBasicDisplay/model.js +8 -2
  6. package/dist/LinearGenomeView/components/HeaderZoomControls.js +8 -2
  7. package/dist/LinearGenomeView/components/ImportForm.js +1 -1
  8. package/dist/LinearGenomeView/components/OverviewRubberband.js +2 -14
  9. package/dist/LinearGenomeView/components/OverviewRubberbandHoverTooltip.d.ts +10 -0
  10. package/dist/LinearGenomeView/components/OverviewRubberbandHoverTooltip.js +36 -0
  11. package/dist/LinearGenomeView/components/Rubberband.js +3 -21
  12. package/dist/LinearGenomeView/components/RubberbandSpan.js +7 -21
  13. package/dist/LinearGenomeView/components/RubberbandTooltip.d.ts +5 -0
  14. package/dist/LinearGenomeView/components/RubberbandTooltip.js +28 -0
  15. package/dist/LinearGenomeView/components/TracksContainer.js +2 -2
  16. package/dist/LinearGenomeView/components/VerticalGuide.js +3 -21
  17. package/dist/LinearGenomeView/model.d.ts +28 -3
  18. package/dist/LinearGenomeView/model.js +62 -26
  19. package/dist/LinearGenomeView/types.d.ts +5 -0
  20. package/esm/BaseLinearDisplay/components/LinearBlocks.js +1 -1
  21. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js +9 -9
  22. package/esm/LaunchLinearGenomeView/index.js +9 -5
  23. package/esm/LinearBasicDisplay/components/AddFiltersDialog.js +1 -1
  24. package/esm/LinearBasicDisplay/model.js +8 -2
  25. package/esm/LinearGenomeView/components/HeaderZoomControls.js +9 -3
  26. package/esm/LinearGenomeView/components/ImportForm.js +1 -1
  27. package/esm/LinearGenomeView/components/OverviewRubberband.js +3 -15
  28. package/esm/LinearGenomeView/components/OverviewRubberbandHoverTooltip.d.ts +10 -0
  29. package/esm/LinearGenomeView/components/OverviewRubberbandHoverTooltip.js +34 -0
  30. package/esm/LinearGenomeView/components/Rubberband.js +4 -22
  31. package/esm/LinearGenomeView/components/RubberbandSpan.js +6 -23
  32. package/esm/LinearGenomeView/components/RubberbandTooltip.d.ts +5 -0
  33. package/esm/LinearGenomeView/components/RubberbandTooltip.js +25 -0
  34. package/esm/LinearGenomeView/components/TracksContainer.js +2 -2
  35. package/esm/LinearGenomeView/components/VerticalGuide.js +4 -22
  36. package/esm/LinearGenomeView/model.d.ts +28 -3
  37. package/esm/LinearGenomeView/model.js +62 -26
  38. package/esm/LinearGenomeView/types.d.ts +5 -0
  39. package/package.json +5 -5
@@ -1,11 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { VIEW_HEADER_HEIGHT } from '@jbrowse/core/ui';
3
- import { getSession, stringify } from '@jbrowse/core/util';
4
- import { isSessionWithMultipleViews } from '@jbrowse/product-core';
2
+ import { stringify } from '@jbrowse/core/util';
5
3
  import { Tooltip } from '@mui/material';
6
4
  import { observer } from 'mobx-react';
7
5
  import { makeStyles } from 'tss-react/mui';
8
- import { HEADER_BAR_HEIGHT, HEADER_OVERVIEW_HEIGHT } from '../consts';
9
6
  const useStyles = makeStyles()({
10
7
  guide: {
11
8
  pointerEvents: 'none',
@@ -13,7 +10,7 @@ const useStyles = makeStyles()({
13
10
  width: 1,
14
11
  position: 'absolute',
15
12
  background: 'red',
16
- zIndex: 4,
13
+ zIndex: 1001,
17
14
  },
18
15
  tooltipTarget: {
19
16
  position: 'sticky',
@@ -22,25 +19,10 @@ const useStyles = makeStyles()({
22
19
  });
23
20
  const VerticalGuide = observer(function VerticalGuide({ model, coordX, }) {
24
21
  const { classes } = useStyles();
25
- const session = getSession(model);
26
- let stickyViewHeaders = false;
27
- if (isSessionWithMultipleViews(session)) {
28
- ;
29
- ({ stickyViewHeaders } = session);
30
- }
31
- let tooltipTop = 0;
32
- if (stickyViewHeaders) {
33
- tooltipTop = VIEW_HEADER_HEIGHT;
34
- if (!model.hideHeader) {
35
- tooltipTop += HEADER_BAR_HEIGHT;
36
- if (!model.hideHeaderOverview) {
37
- tooltipTop += HEADER_OVERVIEW_HEIGHT;
38
- }
39
- }
40
- }
22
+ const { stickyViewHeaders, rubberbandTop } = model;
41
23
  return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { open: true, placement: "top", title: stringify(model.pxToBp(coordX)), arrow: true, children: _jsx("div", { className: classes.tooltipTarget, style: {
42
24
  left: coordX + 6,
43
- top: tooltipTop,
25
+ top: rubberbandTop,
44
26
  position: stickyViewHeaders ? 'sticky' : undefined,
45
27
  } }) }), _jsx("div", { className: classes.guide, style: { left: coordX } })] }));
46
28
  });
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- import type { BpOffset, ExportSvgOptions, HighlightType, NavLocation } from './types';
2
+ import type { BpOffset, ExportSvgOptions, HighlightType, InitState, NavLocation } from './types';
3
3
  import type PluginManager from '@jbrowse/core/PluginManager';
4
4
  import type BaseResult from '@jbrowse/core/TextSearch/BaseResults';
5
5
  import type { Assembly } from '@jbrowse/core/assemblyManager/assembly';
@@ -30,6 +30,7 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
30
30
  highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<HighlightType, HighlightType, HighlightType>>, [undefined]>;
31
31
  colorByCDS: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
32
32
  showTrackOutlines: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
33
+ init: import("mobx-state-tree").IType<InitState | undefined, InitState | undefined, InitState | undefined>;
33
34
  }, {
34
35
  width: number;
35
36
  } & {
@@ -58,6 +59,7 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
58
59
  readonly interRegionPaddingWidth: number;
59
60
  readonly assemblyNames: string[];
60
61
  readonly stickyViewHeaders: boolean;
62
+ readonly rubberbandTop: number;
61
63
  readonly pinnedTracksTop: number;
62
64
  } & {
63
65
  scaleBarDisplayPrefix(): string | undefined;
@@ -144,6 +146,7 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
144
146
  setDraggingTrackId(idx?: string): void;
145
147
  setScaleFactor(factor: number): void;
146
148
  clearView(): void;
149
+ setInit(arg?: InitState): void;
147
150
  exportSvg(opts?: ExportSvgOptions): Promise<void>;
148
151
  } & {
149
152
  slide: (viewWidths: number) => void;
@@ -164,7 +167,6 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
164
167
  readonly coarseVisibleLocStrings: string;
165
168
  } & {
166
169
  setCoarseDynamicBlocks(blocks: BlockSet): void;
167
- afterAttach(): void;
168
170
  } & {
169
171
  moveTo(start?: BpOffset, end?: BpOffset): void;
170
172
  navToLocString(input: string, optAssemblyName?: string): Promise<void>;
@@ -172,6 +174,7 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
172
174
  input: string;
173
175
  assembly: Assembly;
174
176
  }): Promise<void>;
177
+ navToLocation(parsedLocString: ParsedLocString, assemblyName?: string): Promise<void>;
175
178
  navToLocations(parsedLocStrings: ParsedLocString[], assemblyName?: string): Promise<void>;
176
179
  navTo(query: NavLocation): void;
177
180
  navToMultiple(locations: NavLocation[]): void;
@@ -210,6 +213,7 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
210
213
  } | undefined;
211
214
  } & {
212
215
  afterCreate(): void;
216
+ afterAttach(): void;
213
217
  }, import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<{
214
218
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
215
219
  displayName: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
@@ -232,7 +236,28 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
232
236
  highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<HighlightType, HighlightType, HighlightType>>, [undefined]>;
233
237
  colorByCDS: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
234
238
  showTrackOutlines: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
235
- }>>, import("mobx-state-tree")._NotCustomized>;
239
+ init: import("mobx-state-tree").IType<InitState | undefined, InitState | undefined, InitState | undefined>;
240
+ }>>, {
241
+ type: string;
242
+ id: string;
243
+ displayName: string | undefined;
244
+ tracks: any[];
245
+ minimized: boolean;
246
+ displayedRegions: Region[];
247
+ offsetPx: number;
248
+ bpPerPx: number;
249
+ hideHeader: boolean;
250
+ hideHeaderOverview: boolean;
251
+ hideNoTracksActive: boolean;
252
+ trackSelectorType: string;
253
+ showCenterLine: boolean;
254
+ showCytobandsSetting: boolean;
255
+ trackLabels: string;
256
+ showGridlines: boolean;
257
+ highlight: HighlightType[];
258
+ colorByCDS: boolean;
259
+ showTrackOutlines: boolean;
260
+ }>;
236
261
  export type LinearGenomeViewStateModel = ReturnType<typeof stateModelFactory>;
237
262
  export type LinearGenomeViewModel = Instance<LinearGenomeViewStateModel>;
238
263
  export { default as LinearGenomeView, default as ReactComponent, } from './components/LinearGenomeView';
@@ -53,6 +53,7 @@ export function stateModelFactory(pluginManager) {
53
53
  highlight: types.optional(types.array(types.frozen()), []),
54
54
  colorByCDS: types.optional(types.boolean, () => localStorageGetBoolean('lgv-colorByCDS', false)),
55
55
  showTrackOutlines: types.optional(types.boolean, () => localStorageGetBoolean('lgv-showTrackOutlines', true)),
56
+ init: types.frozen(),
56
57
  }))
57
58
  .volatile(() => ({
58
59
  volatileWidth: undefined,
@@ -101,10 +102,10 @@ export function stateModelFactory(pluginManager) {
101
102
  ? session.stickyViewHeaders
102
103
  : false;
103
104
  },
104
- get pinnedTracksTop() {
105
+ get rubberbandTop() {
105
106
  let pinnedTracksTop = 0;
106
107
  if (this.stickyViewHeaders) {
107
- pinnedTracksTop = VIEW_HEADER_HEIGHT + SCALE_BAR_HEIGHT;
108
+ pinnedTracksTop = VIEW_HEADER_HEIGHT;
108
109
  if (!self.hideHeader) {
109
110
  pinnedTracksTop += HEADER_BAR_HEIGHT;
110
111
  if (!self.hideHeaderOverview) {
@@ -114,6 +115,9 @@ export function stateModelFactory(pluginManager) {
114
115
  }
115
116
  return pinnedTracksTop;
116
117
  },
118
+ get pinnedTracksTop() {
119
+ return this.rubberbandTop + SCALE_BAR_HEIGHT;
120
+ },
117
121
  }))
118
122
  .views(self => ({
119
123
  scaleBarDisplayPrefix() {
@@ -227,32 +231,32 @@ export function stateModelFactory(pluginManager) {
227
231
  return results;
228
232
  },
229
233
  rewriteOnClicks(trackType, viewMenuActions) {
230
- viewMenuActions.forEach(action => {
234
+ for (const action of viewMenuActions) {
231
235
  if ('subMenu' in action) {
232
236
  this.rewriteOnClicks(trackType, action.subMenu);
233
237
  }
234
238
  if ('onClick' in action) {
235
239
  const holdOnClick = action.onClick;
236
240
  action.onClick = (...args) => {
237
- self.tracks.forEach(track => {
241
+ for (const track of self.tracks) {
238
242
  if (track.type === trackType) {
239
243
  holdOnClick.apply(track, [track, ...args]);
240
244
  }
241
- });
245
+ }
242
246
  };
243
247
  }
244
- });
248
+ }
245
249
  },
246
250
  get trackTypeActions() {
247
251
  const allActions = new Map();
248
- self.tracks.forEach(track => {
252
+ for (const track of self.tracks) {
249
253
  const trackInMap = allActions.get(track.type);
250
254
  if (!trackInMap) {
251
255
  const viewMenuActions = structuredClone(track.viewMenuActions);
252
256
  this.rewriteOnClicks(track.type, viewMenuActions);
253
257
  allActions.set(track.type, viewMenuActions);
254
258
  }
255
- });
259
+ }
256
260
  return allActions;
257
261
  },
258
262
  }))
@@ -377,11 +381,13 @@ export function stateModelFactory(pluginManager) {
377
381
  hideTrack(trackId) {
378
382
  const schema = pluginManager.pluggableConfigSchemaType('track');
379
383
  const conf = resolveIdentifier(schema, getRoot(self), trackId);
380
- const t = self.tracks.filter(t => t.configuration === conf);
384
+ const tracks = self.tracks.filter(t => t.configuration === conf);
381
385
  transaction(() => {
382
- t.forEach(t => self.tracks.remove(t));
386
+ for (const track of tracks) {
387
+ self.tracks.remove(track);
388
+ }
383
389
  });
384
- return t.length;
390
+ return tracks.length;
385
391
  },
386
392
  }))
387
393
  .actions(self => ({
@@ -522,6 +528,9 @@ export function stateModelFactory(pluginManager) {
522
528
  self.scrollTo(0);
523
529
  self.zoomTo(10);
524
530
  },
531
+ setInit(arg) {
532
+ self.init = arg;
533
+ },
525
534
  async exportSvg(opts = {}) {
526
535
  const { renderToSvg } = await import('./svgcomponents/SVGLinearGenomeView');
527
536
  const html = await renderToSvg(self, opts);
@@ -742,7 +751,9 @@ export function stateModelFactory(pluginManager) {
742
751
  for (const [key, value] of self.trackTypeActions.entries()) {
743
752
  if (value.length) {
744
753
  menuItems.push({ type: 'divider' }, { type: 'subHeader', label: key });
745
- value.forEach(action => menuItems.push(action));
754
+ for (const action of value) {
755
+ menuItems.push(action);
756
+ }
746
757
  }
747
758
  }
748
759
  return menuItems;
@@ -784,20 +795,6 @@ export function stateModelFactory(pluginManager) {
784
795
  self.coarseDynamicBlocks = blocks.contentBlocks;
785
796
  self.coarseTotalBp = blocks.totalBp;
786
797
  },
787
- afterAttach() {
788
- addDisposer(self, autorun(() => {
789
- if (self.initialized) {
790
- this.setCoarseDynamicBlocks(self.dynamicBlocks);
791
- }
792
- }, { delay: 150 }));
793
- addDisposer(self, autorun(() => {
794
- const s = (s) => JSON.stringify(s);
795
- const { showCytobandsSetting, showCenterLine, colorByCDS } = self;
796
- localStorageSetItem('lgv-showCytobands', s(showCytobandsSetting));
797
- localStorageSetItem('lgv-showCenterLine', s(showCenterLine));
798
- localStorageSetItem('lgv-colorByCDS', s(colorByCDS));
799
- }));
800
- },
801
798
  }))
802
799
  .actions(self => ({
803
800
  moveTo(start, end) {
@@ -819,6 +816,9 @@ export function stateModelFactory(pluginManager) {
819
816
  model: self,
820
817
  });
821
818
  },
819
+ async navToLocation(parsedLocString, assemblyName) {
820
+ return this.navToLocations([parsedLocString], assemblyName);
821
+ },
822
822
  async navToLocations(parsedLocStrings, assemblyName) {
823
823
  const { assemblyManager } = getSession(self);
824
824
  await when(() => self.volatileWidth !== undefined);
@@ -964,6 +964,33 @@ export function stateModelFactory(pluginManager) {
964
964
  document.removeEventListener('keydown', handler);
965
965
  });
966
966
  },
967
+ afterAttach() {
968
+ addDisposer(self, autorun(() => {
969
+ var _a;
970
+ const { init } = self;
971
+ if (init) {
972
+ self
973
+ .navToLocString(init.loc, init.assembly)
974
+ .catch((e) => {
975
+ getSession(self).notifyError(`${e}`, e);
976
+ });
977
+ (_a = init.tracks) === null || _a === void 0 ? void 0 : _a.map(t => self.showTrack(t));
978
+ self.setInit(undefined);
979
+ }
980
+ }));
981
+ addDisposer(self, autorun(() => {
982
+ if (self.initialized) {
983
+ self.setCoarseDynamicBlocks(self.dynamicBlocks);
984
+ }
985
+ }, { delay: 150 }));
986
+ addDisposer(self, autorun(() => {
987
+ const s = (s) => JSON.stringify(s);
988
+ const { showCytobandsSetting, showCenterLine, colorByCDS } = self;
989
+ localStorageSetItem('lgv-showCytobands', s(showCytobandsSetting));
990
+ localStorageSetItem('lgv-showCenterLine', s(showCenterLine));
991
+ localStorageSetItem('lgv-colorByCDS', s(colorByCDS));
992
+ }));
993
+ },
967
994
  }))
968
995
  .preProcessSnapshot(snap => {
969
996
  if (!snap) {
@@ -976,6 +1003,15 @@ export function stateModelFactory(pluginManager) {
976
1003
  : [highlight],
977
1004
  ...rest,
978
1005
  };
1006
+ })
1007
+ .postProcessSnapshot(snap => {
1008
+ if (!snap) {
1009
+ return snap;
1010
+ }
1011
+ else {
1012
+ const { init, ...rest } = snap;
1013
+ return rest;
1014
+ }
979
1015
  });
980
1016
  }
981
1017
  export { default as LinearGenomeView, default as ReactComponent, } from './components/LinearGenomeView';
@@ -36,3 +36,8 @@ export interface NavLocation {
36
36
  end?: number;
37
37
  assemblyName?: string;
38
38
  }
39
+ export interface InitState {
40
+ loc: string;
41
+ assembly: string;
42
+ tracks?: string[];
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-linear-genome-view",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "JBrowse 2 linear genome view",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -38,9 +38,9 @@
38
38
  "useSrc": "node ../../scripts/useSrc.js"
39
39
  },
40
40
  "dependencies": {
41
- "@jbrowse/core": "^3.1.0",
42
- "@mui/icons-material": "^6.0.0",
43
- "@mui/material": "^6.0.0",
41
+ "@jbrowse/core": "^3.3.0",
42
+ "@mui/icons-material": "^7.0.0",
43
+ "@mui/material": "^7.0.0",
44
44
  "@types/file-saver": "^2.0.1",
45
45
  "copy-to-clipboard": "^3.3.1",
46
46
  "file-saver": "^2.0.0",
@@ -58,5 +58,5 @@
58
58
  "access": "public"
59
59
  },
60
60
  "module": "esm/index.js",
61
- "gitHead": "91492049ddea0aed90eb24d3c066c2d9f5a6b189"
61
+ "gitHead": "0bb64d8cc7ecdd167515308b31eec3d9acbc59e4"
62
62
  }