@jbrowse/plugin-grid-bookmark 2.17.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/GridBookmarkWidget/components/AssemblySelector.d.ts +2 -3
  2. package/dist/GridBookmarkWidget/components/AssemblySelector.js +10 -25
  3. package/dist/GridBookmarkWidget/components/BookmarkGrid.d.ts +2 -3
  4. package/dist/GridBookmarkWidget/components/BookmarkGrid.js +52 -82
  5. package/dist/GridBookmarkWidget/components/GridBookmarkWidget.d.ts +2 -3
  6. package/dist/GridBookmarkWidget/components/GridBookmarkWidget.js +90 -93
  7. package/dist/GridBookmarkWidget/components/Highlight/Highlight.d.ts +2 -3
  8. package/dist/GridBookmarkWidget/components/Highlight/Highlight.js +34 -58
  9. package/dist/GridBookmarkWidget/components/Highlight/OverviewHighlight.d.ts +3 -4
  10. package/dist/GridBookmarkWidget/components/Highlight/OverviewHighlight.js +8 -31
  11. package/dist/GridBookmarkWidget/components/Highlight/index.d.ts +1 -1
  12. package/dist/GridBookmarkWidget/components/Highlight/index.js +5 -10
  13. package/dist/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.d.ts +2 -3
  14. package/dist/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.js +12 -23
  15. package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +2 -3
  16. package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +12 -41
  17. package/dist/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.d.ts +3 -4
  18. package/dist/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.js +14 -47
  19. package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +2 -3
  20. package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +10 -23
  21. package/dist/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.d.ts +2 -3
  22. package/dist/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.js +39 -81
  23. package/dist/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.d.ts +2 -3
  24. package/dist/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.js +19 -53
  25. package/dist/GridBookmarkWidget/index.d.ts +1 -1
  26. package/dist/GridBookmarkWidget/index.js +18 -9
  27. package/dist/GridBookmarkWidget/model.d.ts +10 -86
  28. package/dist/GridBookmarkWidget/model.js +18 -94
  29. package/dist/GridBookmarkWidget/sessionSharing.d.ts +1 -1
  30. package/dist/GridBookmarkWidget/sessionSharing.js +20 -16
  31. package/dist/GridBookmarkWidget/types.d.ts +1 -1
  32. package/dist/GridBookmarkWidget/utils.d.ts +2 -16
  33. package/dist/GridBookmarkWidget/utils.js +19 -30
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +10 -29
  36. package/esm/GridBookmarkWidget/components/AssemblySelector.d.ts +2 -3
  37. package/esm/GridBookmarkWidget/components/AssemblySelector.js +10 -22
  38. package/esm/GridBookmarkWidget/components/BookmarkGrid.d.ts +2 -3
  39. package/esm/GridBookmarkWidget/components/BookmarkGrid.js +52 -59
  40. package/esm/GridBookmarkWidget/components/GridBookmarkWidget.d.ts +2 -3
  41. package/esm/GridBookmarkWidget/components/GridBookmarkWidget.js +73 -86
  42. package/esm/GridBookmarkWidget/components/Highlight/Highlight.d.ts +2 -3
  43. package/esm/GridBookmarkWidget/components/Highlight/Highlight.js +34 -35
  44. package/esm/GridBookmarkWidget/components/Highlight/OverviewHighlight.d.ts +3 -4
  45. package/esm/GridBookmarkWidget/components/Highlight/OverviewHighlight.js +8 -8
  46. package/esm/GridBookmarkWidget/components/Highlight/index.d.ts +1 -1
  47. package/esm/GridBookmarkWidget/components/Highlight/index.js +5 -10
  48. package/esm/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.d.ts +2 -3
  49. package/esm/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.js +12 -20
  50. package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +2 -3
  51. package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +12 -18
  52. package/esm/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.d.ts +3 -4
  53. package/esm/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.js +14 -24
  54. package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +2 -3
  55. package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +10 -20
  56. package/esm/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.d.ts +2 -3
  57. package/esm/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.js +40 -59
  58. package/esm/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.d.ts +2 -3
  59. package/esm/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.js +19 -30
  60. package/esm/GridBookmarkWidget/index.d.ts +1 -1
  61. package/esm/GridBookmarkWidget/index.js +1 -2
  62. package/esm/GridBookmarkWidget/model.d.ts +10 -86
  63. package/esm/GridBookmarkWidget/model.js +18 -94
  64. package/esm/GridBookmarkWidget/sessionSharing.d.ts +1 -1
  65. package/esm/GridBookmarkWidget/sessionSharing.js +3 -9
  66. package/esm/GridBookmarkWidget/types.d.ts +1 -1
  67. package/esm/GridBookmarkWidget/utils.d.ts +2 -16
  68. package/esm/GridBookmarkWidget/utils.js +2 -23
  69. package/esm/index.d.ts +1 -1
  70. package/esm/index.js +10 -29
  71. package/package.json +2 -2
  72. package/dist/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.d.ts +0 -8
  73. package/dist/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.js +0 -54
  74. package/esm/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.d.ts +0 -8
  75. package/esm/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.js +0 -29
@@ -1,13 +1,13 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { Dialog, ErrorMessage } from '@jbrowse/core/ui';
4
+ import { ContentCopy as ContentCopyIcon } from '@jbrowse/core/ui/Icons';
5
+ import { getSession, isSessionWithShareURL } from '@jbrowse/core/util';
6
+ import { Alert, Button, DialogActions, DialogContent, DialogContentText, TextField, Typography, } from '@mui/material';
7
+ import copy from 'copy-to-clipboard';
2
8
  import { observer } from 'mobx-react';
3
9
  import { getSnapshot } from 'mobx-state-tree';
4
- import { Alert, Button, DialogActions, DialogContent, DialogContentText, TextField, Typography, } from '@mui/material';
5
10
  import { makeStyles } from 'tss-react/mui';
6
- import copy from 'copy-to-clipboard';
7
- import { getSession, isSessionWithShareURL } from '@jbrowse/core/util';
8
- import { Dialog, ErrorMessage } from '@jbrowse/core/ui';
9
- import { ContentCopy as ContentCopyIcon } from '@jbrowse/core/ui/Icons';
10
- // locals
11
11
  import { shareSessionToDynamo } from '../../sessionSharing';
12
12
  const useStyles = makeStyles()(() => ({
13
13
  flexItem: {
@@ -31,7 +31,6 @@ const ShareBookmarksDialog = observer(function ({ onClose, model, }) {
31
31
  ? model.allBookmarksModel
32
32
  : model.sharedBookmarksModel;
33
33
  useEffect(() => {
34
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
35
34
  ;
36
35
  (async () => {
37
36
  try {
@@ -57,27 +56,17 @@ const ShareBookmarksDialog = observer(function ({ onClose, model, }) {
57
56
  }
58
57
  })();
59
58
  }, [bookmarksToShare, session]);
60
- return (React.createElement(Dialog, { open: true, onClose: onClose, title: "Share bookmarks" },
61
- React.createElement(DialogContent, { className: classes.content },
62
- React.createElement(Alert, { severity: "info" }, shareAll ? (React.createElement(React.Fragment, null,
63
- React.createElement("span", null, "All bookmarks will be shared."),
64
- React.createElement("br", null),
65
- React.createElement("span", null, "Use the checkboxes to select individual bookmarks to share."))) : ('Only selected bookmarks will be shared.')),
66
- React.createElement(DialogContentText, null, "Copy the URL below to share your bookmarks."),
67
- error ? (React.createElement(ErrorMessage, { error: error })) : loading ? (React.createElement(Typography, null, "Generating short URL...")) : (React.createElement(TextField, { label: "URL", value: url, slotProps: {
68
- input: {
69
- readOnly: true,
70
- },
71
- }, variant: "filled", fullWidth: true, onClick: event => {
72
- const target = event.target;
73
- target.select();
74
- } })),
75
- React.createElement(DialogContentText, null, "The URL should be pasted into the \"Import from share link\" field in the \"Import\" form found in the \"Bookmarked regions\" drawer.")),
76
- React.createElement(DialogActions, null,
77
- React.createElement(Button, { className: classes.flexItem, "data-testid": "dialogShare", variant: "contained", color: "primary", disabled: loading, startIcon: React.createElement(ContentCopyIcon, null), onClick: async () => {
78
- copy(url);
79
- session.notify('Copied to clipboard', 'success');
80
- onClose();
81
- } }, "Copy share link"))));
59
+ return (_jsxs(Dialog, { open: true, onClose: onClose, title: "Share bookmarks", children: [_jsxs(DialogContent, { className: classes.content, children: [_jsx(Alert, { severity: "info", children: shareAll ? (_jsxs(_Fragment, { children: [_jsx("span", { children: "All bookmarks will be shared." }), _jsx("br", {}), _jsx("span", { children: "Use the checkboxes to select individual bookmarks to share." })] })) : ('Only selected bookmarks will be shared.') }), _jsx(DialogContentText, { children: "Copy the URL below to share your bookmarks." }), error ? (_jsx(ErrorMessage, { error: error })) : loading ? (_jsx(Typography, { children: "Generating short URL..." })) : (_jsx(TextField, { label: "URL", value: url, slotProps: {
60
+ input: {
61
+ readOnly: true,
62
+ },
63
+ }, variant: "filled", fullWidth: true, onClick: event => {
64
+ const target = event.target;
65
+ target.select();
66
+ } })), _jsx(DialogContentText, { children: "The URL should be pasted into the \"Import from share link\" field in the \"Import\" form found in the \"Bookmarked regions\" drawer." })] }), _jsx(DialogActions, { children: _jsx(Button, { className: classes.flexItem, "data-testid": "dialogShare", variant: "contained", color: "primary", disabled: loading, startIcon: _jsx(ContentCopyIcon, {}), onClick: async () => {
67
+ copy(url);
68
+ session.notify('Copied to clipboard', 'success');
69
+ onClose();
70
+ }, children: "Copy share link" }) })] }));
82
71
  });
83
72
  export default ShareBookmarksDialog;
@@ -1,2 +1,2 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
2
  export default function GridBookmarkWidgetF(pluginManager: PluginManager): void;
@@ -1,9 +1,8 @@
1
1
  import { lazy } from 'react';
2
2
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
3
3
  import { WidgetType } from '@jbrowse/core/pluggableElementTypes';
4
- // locals
5
- import stateModelFactory from './model';
6
4
  import AddHighlightModelF from './components/Highlight';
5
+ import stateModelFactory from './model';
7
6
  const configSchema = ConfigurationSchema('GridBookmarkWidget', {});
8
7
  export default function GridBookmarkWidgetF(pluginManager) {
9
8
  pluginManager.addWidgetType(() => {
@@ -1,7 +1,7 @@
1
- import { Instance, SnapshotIn, IMSTArray } from 'mobx-state-tree';
2
- import PluginManager from '@jbrowse/core/PluginManager';
3
- import { Region } from '@jbrowse/core/util/types';
4
- import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ import type { Region } from '@jbrowse/core/util/types';
3
+ import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
4
+ import type { IMSTArray, Instance, SnapshotIn } from 'mobx-state-tree';
5
5
  declare const LabeledRegionModel: import("mobx-state-tree").IModelType<{
6
6
  refName: import("mobx-state-tree").ISimpleType<string>;
7
7
  start: import("mobx-state-tree").ISimpleType<number>;
@@ -19,10 +19,10 @@ declare const LabeledRegionModel: import("mobx-state-tree").IModelType<{
19
19
  setHighlight(color: string): void;
20
20
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
21
21
  export interface IExtendedLGV extends LinearGenomeViewModel {
22
- showBookmarkHighlights: boolean;
23
- showBookmarkLabels: boolean;
24
- toggleShowBookmarkHighlights: (arg: boolean) => void;
25
- toggleShowBookmarkLabels: (arg: boolean) => void;
22
+ bookmarkHighlightsVisible: boolean;
23
+ bookmarkLabelsVisible: boolean;
24
+ setBookmarkHighlightsVisible: (arg: boolean) => void;
25
+ setBookmarkLabelsVisible: (arg: boolean) => void;
26
26
  }
27
27
  export interface ILabeledRegionModel extends SnapshotIn<typeof LabeledRegionModel> {
28
28
  refName: string;
@@ -40,22 +40,9 @@ export interface IExtendedLabeledRegionModel extends ILabeledRegionModel {
40
40
  id: number;
41
41
  correspondingObj: ILabeledRegionModel;
42
42
  }
43
- /**
44
- * #stateModel GridBookmarkWidgetModel
45
- */
46
43
  export default function f(_pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
47
- /**
48
- * #property
49
- */
50
44
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
51
- /**
52
- * #property
53
- */
54
45
  type: import("mobx-state-tree").ISimpleType<"GridBookmarkWidget">;
55
- /**
56
- * #property
57
- * removed by postProcessSnapshot, only loaded from localStorage
58
- */
59
46
  bookmarks: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
60
47
  refName: import("mobx-state-tree").ISimpleType<string>;
61
48
  start: import("mobx-state-tree").ISimpleType<number>;
@@ -76,26 +63,11 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
76
63
  selectedBookmarks: IExtendedLabeledRegionModel[];
77
64
  selectedAssembliesPre: string[] | undefined;
78
65
  } & {
79
- /**
80
- * #getter
81
- */
82
66
  readonly bookmarkAssemblies: string[];
83
- /**
84
- * #getter
85
- */
86
67
  readonly validAssemblies: Set<string>;
87
- /**
88
- * #getter
89
- */
90
68
  readonly areBookmarksHighlightedOnAllOpenViews: boolean;
91
- /**
92
- * #getter
93
- */
94
69
  readonly areBookmarksHighlightLabelsOnAllOpenViews: boolean;
95
70
  } & {
96
- /**
97
- * #getter
98
- */
99
71
  readonly bookmarksWithValidAssemblies: ({
100
72
  refName: string;
101
73
  start: number;
@@ -126,9 +98,6 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
126
98
  setHighlight(color: string): void;
127
99
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
128
100
  } & {
129
- /**
130
- * #getter
131
- */
132
101
  readonly sharedBookmarksModel: {
133
102
  sharedBookmarks: (IMSTArray<import("mobx-state-tree").IModelType<{
134
103
  refName: import("mobx-state-tree").ISimpleType<string>;
@@ -179,9 +148,6 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
179
148
  setHighlight(color: string): void;
180
149
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
181
150
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
182
- /**
183
- * #getter
184
- */
185
151
  readonly allBookmarksModel: {
186
152
  sharedBookmarks: (IMSTArray<import("mobx-state-tree").IModelType<{
187
153
  refName: import("mobx-state-tree").ISimpleType<string>;
@@ -233,64 +199,22 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
233
199
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
234
200
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
235
201
  } & {
236
- /**
237
- * #action
238
- */
239
202
  setSelectedAssemblies(assemblies?: string[]): void;
240
203
  } & {
241
- /**
242
- * #getter
243
- */
244
204
  readonly selectedAssemblies: string[];
245
205
  } & {
246
- /**
247
- * #action
248
- */
249
206
  importBookmarks(regions: Region[]): void;
250
- /**
251
- * #action
252
- */
253
207
  addBookmark(region: Region): void;
254
- /**
255
- * #action
256
- */
257
208
  removeBookmark(index: number): void;
258
- /**
259
- * #action
260
- */
261
209
  updateBookmarkLabel(bookmark: IExtendedLabeledRegionModel, label: string): void;
262
- /**
263
- * #action
264
- */
265
210
  updateBookmarkHighlight(bookmark: IExtendedLabeledRegionModel, color: string): void;
266
- /**
267
- * #action
268
- */
269
211
  updateBulkBookmarkHighlights(color: string): void;
270
- /**
271
- * #action
272
- */
273
212
  setSelectedBookmarks(bookmarks: IExtendedLabeledRegionModel[]): void;
274
- /**
275
- * #action
276
- */
277
213
  setBookmarkedRegions(regions: IMSTArray<typeof LabeledRegionModel>): void;
278
- /**
279
- * #action
280
- */
281
- setHighlightToggle(toggle: boolean): void;
282
- /**
283
- * #action
284
- */
285
- setLabelToggle(toggle: boolean): void;
214
+ setBookmarkHighlightsVisible(arg: boolean): void;
215
+ setBookmarkLabelsVisible(arg: boolean): void;
286
216
  } & {
287
- /**
288
- * #action
289
- */
290
217
  clearAllBookmarks(): void;
291
- /**
292
- * #action
293
- */
294
218
  clearSelectedBookmarks(): void;
295
219
  removeBookmarkObject(arg: Instance<typeof LabeledRegionModel>): void;
296
220
  } & {
@@ -1,7 +1,7 @@
1
- import { types, cast, addDisposer, } from 'mobx-state-tree';
2
- import { Region as RegionModel, ElementId } from '@jbrowse/core/util/types/mst';
3
1
  import { getSession, localStorageGetItem, localStorageSetItem, } from '@jbrowse/core/util';
2
+ import { ElementId, Region as RegionModel } from '@jbrowse/core/util/types/mst';
4
3
  import { autorun } from 'mobx';
4
+ import { addDisposer, cast, types } from 'mobx-state-tree';
5
5
  const LabeledRegionModel = types
6
6
  .compose(RegionModel, types.model('Label', {
7
7
  label: types.optional(types.string, ''),
@@ -21,24 +21,11 @@ const SharedBookmarksModel = types.model('SharedBookmarksModel', {
21
21
  const localStorageKeyF = () => typeof window !== 'undefined'
22
22
  ? `bookmarks-${[window.location.host + window.location.pathname].join('-')}`
23
23
  : 'empty';
24
- /**
25
- * #stateModel GridBookmarkWidgetModel
26
- */
27
24
  export default function f(_pluginManager) {
28
25
  return types
29
26
  .model('GridBookmarkModel', {
30
- /**
31
- * #property
32
- */
33
27
  id: ElementId,
34
- /**
35
- * #property
36
- */
37
28
  type: types.literal('GridBookmarkWidget'),
38
- /**
39
- * #property
40
- * removed by postProcessSnapshot, only loaded from localStorage
41
- */
42
29
  bookmarks: types.optional(types.array(LabeledRegionModel), () => JSON.parse(localStorageGetItem(localStorageKeyF()) || '[]')),
43
30
  })
44
31
  .volatile(() => ({
@@ -46,167 +33,104 @@ export default function f(_pluginManager) {
46
33
  selectedAssembliesPre: undefined,
47
34
  }))
48
35
  .views(self => ({
49
- /**
50
- * #getter
51
- */
52
36
  get bookmarkAssemblies() {
53
37
  return [...new Set(self.bookmarks.map(r => r.assemblyName))];
54
38
  },
55
- /**
56
- * #getter
57
- */
58
39
  get validAssemblies() {
59
40
  const { assemblyManager } = getSession(self);
60
41
  return new Set(this.bookmarkAssemblies.filter(a => assemblyManager.get(a)));
61
42
  },
62
- /**
63
- * #getter
64
- */
65
43
  get areBookmarksHighlightedOnAllOpenViews() {
66
44
  const { views } = getSession(self);
67
- return views.every(v => 'showBookmarkHighlights' in v ? v.showBookmarkHighlights : true);
45
+ return views.every(v => 'bookmarkHighlightsVisible' in v ? v.bookmarkHighlightsVisible : true);
68
46
  },
69
- /**
70
- * #getter
71
- */
72
47
  get areBookmarksHighlightLabelsOnAllOpenViews() {
73
48
  const { views } = getSession(self);
74
- return views.every(v => 'showBookmarkLabels' in v ? v.showBookmarkLabels : true);
49
+ return views.every(v => 'bookmarkLabelsVisible' in v ? v.bookmarkLabelsVisible : true);
75
50
  },
76
51
  }))
77
52
  .views(self => ({
78
- /**
79
- * #getter
80
- */
81
53
  get bookmarksWithValidAssemblies() {
82
54
  return self.bookmarks.filter(e => self.validAssemblies.has(e.assemblyName));
83
55
  },
84
56
  }))
85
57
  .views(self => ({
86
- /**
87
- * #getter
88
- */
89
58
  get sharedBookmarksModel() {
90
- // requires cloning bookmarks with JSON.stringify/parse to avoid duplicate
91
- // reference to same object in the same state tree, will otherwise error
92
- // when performing share
93
59
  return SharedBookmarksModel.create({
94
60
  sharedBookmarks: JSON.parse(JSON.stringify(self.selectedBookmarks)),
95
61
  });
96
62
  },
97
- /**
98
- * #getter
99
- */
100
63
  get allBookmarksModel() {
101
- // requires cloning bookmarks with JSON.stringify/parse to avoid duplicate
102
- // reference to same object in the same state tree, will otherwise error
103
- // when performing share
104
64
  return SharedBookmarksModel.create({
105
65
  sharedBookmarks: JSON.parse(JSON.stringify(self.bookmarksWithValidAssemblies)),
106
66
  });
107
67
  },
108
68
  }))
109
69
  .actions(self => ({
110
- /**
111
- * #action
112
- */
113
70
  setSelectedAssemblies(assemblies) {
114
71
  self.selectedAssembliesPre = assemblies;
115
72
  },
116
73
  }))
117
74
  .views(self => ({
118
- /**
119
- * #getter
120
- */
121
75
  get selectedAssemblies() {
122
76
  var _a, _b;
123
77
  return ((_b = (_a = self.selectedAssembliesPre) === null || _a === void 0 ? void 0 : _a.filter(f => self.validAssemblies.has(f))) !== null && _b !== void 0 ? _b : [...self.validAssemblies]);
124
78
  },
125
79
  }))
126
80
  .actions(self => ({
127
- /**
128
- * #action
129
- */
130
81
  importBookmarks(regions) {
131
82
  self.bookmarks = cast([...self.bookmarks, ...regions]);
132
83
  },
133
- /**
134
- * #action
135
- */
136
84
  addBookmark(region) {
137
85
  self.bookmarks.push(region);
138
86
  },
139
- /**
140
- * #action
141
- */
142
87
  removeBookmark(index) {
143
88
  self.bookmarks.splice(index, 1);
144
89
  },
145
- /**
146
- * #action
147
- */
148
90
  updateBookmarkLabel(bookmark, label) {
149
91
  bookmark.correspondingObj.setLabel(label);
150
92
  },
151
- /**
152
- * #action
153
- */
154
93
  updateBookmarkHighlight(bookmark, color) {
155
94
  bookmark.correspondingObj.setHighlight(color);
156
95
  },
157
- /**
158
- * #action
159
- */
160
96
  updateBulkBookmarkHighlights(color) {
161
97
  self.selectedBookmarks.forEach(bookmark => {
162
98
  this.updateBookmarkHighlight(bookmark, color);
163
99
  });
164
100
  },
165
- /**
166
- * #action
167
- */
168
101
  setSelectedBookmarks(bookmarks) {
169
102
  self.selectedBookmarks = bookmarks;
170
103
  },
171
- /**
172
- * #action
173
- */
174
104
  setBookmarkedRegions(regions) {
175
105
  self.bookmarks = cast(regions);
176
106
  },
177
- /**
178
- * #action
179
- */
180
- setHighlightToggle(toggle) {
107
+ setBookmarkHighlightsVisible(arg) {
181
108
  const { views } = getSession(self);
182
109
  views.forEach(view => {
183
- var _a;
184
- // @ts-expect-error
185
- (_a = view.toggleShowBookmarkHighlights) === null || _a === void 0 ? void 0 : _a.call(view, toggle);
110
+ var _a, _b;
111
+ (_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
112
+ (_b = view.views) === null || _b === void 0 ? void 0 : _b.map(view => {
113
+ var _a;
114
+ (_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
115
+ });
186
116
  });
187
117
  },
188
- /**
189
- * #action
190
- */
191
- setLabelToggle(toggle) {
118
+ setBookmarkLabelsVisible(arg) {
192
119
  const { views } = getSession(self);
193
120
  views.forEach(view => {
194
- var _a;
195
- // @ts-expect-error
196
- (_a = view.toggleShowBookmarkLabels) === null || _a === void 0 ? void 0 : _a.call(view, toggle);
121
+ var _a, _b;
122
+ (_a = view.setBookmarkLabelsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
123
+ (_b = view.views) === null || _b === void 0 ? void 0 : _b.map(view => {
124
+ var _a;
125
+ (_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
126
+ });
197
127
  });
198
128
  },
199
129
  }))
200
130
  .actions(self => ({
201
- /**
202
- * #action
203
- */
204
131
  clearAllBookmarks() {
205
132
  self.setBookmarkedRegions(self.bookmarks.filter(bookmark => !self.validAssemblies.has(bookmark.assemblyName)));
206
133
  },
207
- /**
208
- * #action
209
- */
210
134
  clearSelectedBookmarks() {
211
135
  for (const bookmark of self.selectedBookmarks) {
212
136
  self.bookmarks.remove(bookmark.correspondingObj);
@@ -3,4 +3,4 @@ export declare function shareSessionToDynamo(session: unknown, url: string, refe
3
3
  encryptedSession: string;
4
4
  password: string;
5
5
  }>;
6
- export declare function readSessionFromDynamo(baseUrl: string, sessionQueryParam: string, password: string, signal?: AbortSignal): Promise<string>;
6
+ export declare function readSessionFromDynamo(baseUrl: string, sessionQueryParam: string, password: string): Promise<string>;
@@ -1,6 +1,4 @@
1
- // duplicated from products/jbrowse-web/src/sessionSharing.ts ; could possibly be moved into a higher directory and shared between the two
2
1
  import { toUrlSafeB64 } from './utils';
3
- // from https://stackoverflow.com/questions/1349404/
4
2
  function generateUID(length) {
5
3
  return window
6
4
  .btoa([...window.crypto.getRandomValues(new Uint8Array(length * 2))]
@@ -28,7 +26,6 @@ function getErrorMsg(err) {
28
26
  return err;
29
27
  }
30
28
  }
31
- // writes the encrypted session, current datetime, and referer to DynamoDB
32
29
  export async function shareSessionToDynamo(session, url, referer) {
33
30
  const sess = await toUrlSafeB64(JSON.stringify(session));
34
31
  const password = generateUID(5);
@@ -53,15 +50,12 @@ export async function shareSessionToDynamo(session, url, referer) {
53
50
  password,
54
51
  };
55
52
  }
56
- export async function readSessionFromDynamo(baseUrl, sessionQueryParam, password, signal) {
53
+ export async function readSessionFromDynamo(baseUrl, sessionQueryParam, password) {
57
54
  const sessionId = sessionQueryParam.split('share-')[1];
58
55
  const url = `${baseUrl}?sessionId=${encodeURIComponent(sessionId)}`;
59
- const response = await fetch(url, {
60
- signal,
61
- });
56
+ const response = await fetch(url);
62
57
  if (!response.ok) {
63
- const err = await response.text();
64
- throw new Error(getErrorMsg(err));
58
+ throw new Error(getErrorMsg(await response.text()));
65
59
  }
66
60
  const json = await response.json();
67
61
  return decrypt(json.session, password);
@@ -1,4 +1,4 @@
1
- import { Region } from '@jbrowse/core/util/types';
1
+ import type { Region } from '@jbrowse/core/util/types';
2
2
  export interface LabeledRegion extends Region {
3
3
  label: string;
4
4
  }
@@ -1,21 +1,7 @@
1
- import { AbstractViewModel } from '@jbrowse/core/util/types';
2
- import { GridBookmarkModel } from './model';
1
+ import type { GridBookmarkModel } from './model';
2
+ import type { AbstractViewModel } from '@jbrowse/core/util/types';
3
3
  export declare function navToBookmark(locString: string, assembly: string, views: AbstractViewModel[], model: GridBookmarkModel): Promise<void>;
4
4
  export declare function downloadBookmarkFile(fileFormat: string, model: GridBookmarkModel): void;
5
- /**
6
- * Pad the end of a base64 string with "=" to make it valid
7
- * @param b64 - unpadded b64 string
8
- */
9
5
  export declare function b64PadSuffix(b64: string): string;
10
- /**
11
- * Decode and inflate a url-safe base64 to a string
12
- * See {@link https://en.wikipedia.org/wiki/Base64#URL_applications}
13
- * @param b64 - a base64 string to decode and inflate
14
- */
15
6
  export declare function fromUrlSafeB64(b64: string): Promise<string>;
16
- /**
17
- * Compress and encode a string as url-safe base64
18
- * See {@link https://en.wikipedia.org/wiki/Base64#URL_applications}
19
- * @param str- a string to compress and encode
20
- */
21
7
  export declare function toUrlSafeB64(str: string): Promise<string>;
@@ -1,18 +1,12 @@
1
+ import { assembleLocString, getSession } from '@jbrowse/core/util';
1
2
  import { saveAs } from 'file-saver';
2
- import { getSession, assembleLocString } from '@jbrowse/core/util';
3
3
  export async function navToBookmark(locString, assembly, views, model) {
4
4
  const session = getSession(model);
5
5
  try {
6
- // get the focused view
7
6
  let view = views.find(view => view.id === session.focusedViewId);
8
- // check if the focused view is the appropriate assembly, if not proceed
9
7
  if ((view === null || view === void 0 ? void 0 : view.assemblyNames[0]) !== assembly) {
10
- view = views.find(elt =>
11
- // @ts-expect-error
12
- elt.type === 'LinearGenomeView' && elt.assemblyNames[0] === assembly);
8
+ view = views.find(elt => elt.type === 'LinearGenomeView' && elt.assemblyNames[0] === assembly);
13
9
  }
14
- // if no view is opened of the selectedAssembly, open a new
15
- // view with that assembly
16
10
  if (!view) {
17
11
  const newViewId = `${model.id}_${assembly}`;
18
12
  view = session.addView('LinearGenomeView', {
@@ -55,7 +49,6 @@ export function downloadBookmarkFile(fileFormat, model) {
55
49
  }
56
50
  }
57
51
  else {
58
- // TSV
59
52
  const fileHeader = 'chrom\tstart\tend\tlabel\tassembly_name\tcoord_range\n';
60
53
  const fileContents = bookmarksToDownload
61
54
  .map(bookmark => {
@@ -72,10 +65,6 @@ export function downloadBookmarkFile(fileFormat, model) {
72
65
  saveAs(blob, fileName);
73
66
  }
74
67
  }
75
- /**
76
- * Pad the end of a base64 string with "=" to make it valid
77
- * @param b64 - unpadded b64 string
78
- */
79
68
  export function b64PadSuffix(b64) {
80
69
  let num = 0;
81
70
  const mo = b64.length % 4;
@@ -94,11 +83,6 @@ export function b64PadSuffix(b64) {
94
83
  }
95
84
  return b64 + '='.repeat(num);
96
85
  }
97
- /**
98
- * Decode and inflate a url-safe base64 to a string
99
- * See {@link https://en.wikipedia.org/wiki/Base64#URL_applications}
100
- * @param b64 - a base64 string to decode and inflate
101
- */
102
86
  export async function fromUrlSafeB64(b64) {
103
87
  const originalB64 = b64PadSuffix(b64.replaceAll('-', '+').replaceAll('_', '/'));
104
88
  const { toByteArray } = await import('base64-js');
@@ -107,11 +91,6 @@ export async function fromUrlSafeB64(b64) {
107
91
  const inflated = inflate(bytes);
108
92
  return new TextDecoder().decode(inflated);
109
93
  }
110
- /**
111
- * Compress and encode a string as url-safe base64
112
- * See {@link https://en.wikipedia.org/wiki/Base64#URL_applications}
113
- * @param str- a string to compress and encode
114
- */
115
94
  export async function toUrlSafeB64(str) {
116
95
  const bytes = new TextEncoder().encode(str);
117
96
  const { deflate } = await import('pako');
package/esm/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import PluginManager from '@jbrowse/core/PluginManager';
2
+ import type PluginManager from '@jbrowse/core/PluginManager';
3
3
  export default class GridBookmarkPlugin extends Plugin {
4
4
  name: string;
5
5
  install(pluginManager: PluginManager): void;