@jbrowse/plugin-grid-bookmark 2.17.0 → 2.18.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.
- package/dist/GridBookmarkWidget/components/AssemblySelector.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/AssemblySelector.js +1 -2
- package/dist/GridBookmarkWidget/components/BookmarkGrid.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/BookmarkGrid.js +53 -82
- package/dist/GridBookmarkWidget/components/GridBookmarkWidget.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/GridBookmarkWidget.js +9 -12
- package/dist/GridBookmarkWidget/components/Highlight/Highlight.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/Highlight/Highlight.js +14 -11
- package/dist/GridBookmarkWidget/components/Highlight/OverviewHighlight.d.ts +2 -2
- package/dist/GridBookmarkWidget/components/Highlight/OverviewHighlight.js +5 -5
- package/dist/GridBookmarkWidget/components/Highlight/index.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/Highlight/index.js +2 -7
- package/dist/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.js +2 -2
- package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +2 -2
- package/dist/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.d.ts +2 -2
- package/dist/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.js +8 -7
- package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +4 -4
- package/dist/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.js +8 -11
- package/dist/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.d.ts +1 -1
- package/dist/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.js +5 -7
- package/dist/GridBookmarkWidget/index.d.ts +1 -1
- package/dist/GridBookmarkWidget/index.js +1 -2
- package/dist/GridBookmarkWidget/model.d.ts +10 -86
- package/dist/GridBookmarkWidget/model.js +18 -94
- package/dist/GridBookmarkWidget/sessionSharing.d.ts +1 -1
- package/dist/GridBookmarkWidget/sessionSharing.js +3 -9
- package/dist/GridBookmarkWidget/types.d.ts +1 -1
- package/dist/GridBookmarkWidget/utils.d.ts +2 -16
- package/dist/GridBookmarkWidget/utils.js +2 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -29
- package/esm/GridBookmarkWidget/components/AssemblySelector.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/AssemblySelector.js +1 -2
- package/esm/GridBookmarkWidget/components/BookmarkGrid.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/BookmarkGrid.js +53 -59
- package/esm/GridBookmarkWidget/components/GridBookmarkWidget.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/GridBookmarkWidget.js +9 -12
- package/esm/GridBookmarkWidget/components/Highlight/Highlight.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/Highlight/Highlight.js +14 -11
- package/esm/GridBookmarkWidget/components/Highlight/OverviewHighlight.d.ts +2 -2
- package/esm/GridBookmarkWidget/components/Highlight/OverviewHighlight.js +5 -5
- package/esm/GridBookmarkWidget/components/Highlight/index.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/Highlight/index.js +2 -7
- package/esm/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/DeleteBookmarksDialog.js +2 -2
- package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +2 -2
- package/esm/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.d.ts +2 -2
- package/esm/GridBookmarkWidget/components/dialogs/ExportBookmarksDialog.js +8 -7
- package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +4 -4
- package/esm/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/ImportBookmarksDialog.js +7 -10
- package/esm/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.d.ts +1 -1
- package/esm/GridBookmarkWidget/components/dialogs/ShareBookmarksDialog.js +5 -7
- package/esm/GridBookmarkWidget/index.d.ts +1 -1
- package/esm/GridBookmarkWidget/index.js +1 -2
- package/esm/GridBookmarkWidget/model.d.ts +10 -86
- package/esm/GridBookmarkWidget/model.js +18 -94
- package/esm/GridBookmarkWidget/sessionSharing.d.ts +1 -1
- package/esm/GridBookmarkWidget/sessionSharing.js +3 -9
- package/esm/GridBookmarkWidget/types.d.ts +1 -1
- package/esm/GridBookmarkWidget/utils.d.ts +2 -16
- package/esm/GridBookmarkWidget/utils.js +2 -23
- package/esm/index.d.ts +1 -1
- package/esm/index.js +10 -29
- package/package.json +2 -2
- package/dist/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.d.ts +0 -8
- package/dist/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.js +0 -54
- package/esm/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.d.ts +0 -8
- package/esm/GridBookmarkWidget/components/dialogs/EditBookmarkLabelDialog.js +0 -29
|
@@ -30,9 +30,8 @@ exports.default = GridBookmarkWidgetF;
|
|
|
30
30
|
const react_1 = require("react");
|
|
31
31
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
32
32
|
const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
|
|
33
|
-
// locals
|
|
34
|
-
const model_1 = __importDefault(require("./model"));
|
|
35
33
|
const Highlight_1 = __importDefault(require("./components/Highlight"));
|
|
34
|
+
const model_1 = __importDefault(require("./model"));
|
|
36
35
|
const configSchema = (0, configuration_1.ConfigurationSchema)('GridBookmarkWidget', {});
|
|
37
36
|
function GridBookmarkWidgetF(pluginManager) {
|
|
38
37
|
pluginManager.addWidgetType(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = f;
|
|
4
|
-
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
5
|
-
const mst_1 = require("@jbrowse/core/util/types/mst");
|
|
6
4
|
const util_1 = require("@jbrowse/core/util");
|
|
5
|
+
const mst_1 = require("@jbrowse/core/util/types/mst");
|
|
7
6
|
const mobx_1 = require("mobx");
|
|
7
|
+
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
8
8
|
const LabeledRegionModel = mobx_state_tree_1.types
|
|
9
9
|
.compose(mst_1.Region, mobx_state_tree_1.types.model('Label', {
|
|
10
10
|
label: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.string, ''),
|
|
@@ -24,24 +24,11 @@ const SharedBookmarksModel = mobx_state_tree_1.types.model('SharedBookmarksModel
|
|
|
24
24
|
const localStorageKeyF = () => typeof window !== 'undefined'
|
|
25
25
|
? `bookmarks-${[window.location.host + window.location.pathname].join('-')}`
|
|
26
26
|
: 'empty';
|
|
27
|
-
/**
|
|
28
|
-
* #stateModel GridBookmarkWidgetModel
|
|
29
|
-
*/
|
|
30
27
|
function f(_pluginManager) {
|
|
31
28
|
return mobx_state_tree_1.types
|
|
32
29
|
.model('GridBookmarkModel', {
|
|
33
|
-
/**
|
|
34
|
-
* #property
|
|
35
|
-
*/
|
|
36
30
|
id: mst_1.ElementId,
|
|
37
|
-
/**
|
|
38
|
-
* #property
|
|
39
|
-
*/
|
|
40
31
|
type: mobx_state_tree_1.types.literal('GridBookmarkWidget'),
|
|
41
|
-
/**
|
|
42
|
-
* #property
|
|
43
|
-
* removed by postProcessSnapshot, only loaded from localStorage
|
|
44
|
-
*/
|
|
45
32
|
bookmarks: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.array(LabeledRegionModel), () => JSON.parse((0, util_1.localStorageGetItem)(localStorageKeyF()) || '[]')),
|
|
46
33
|
})
|
|
47
34
|
.volatile(() => ({
|
|
@@ -49,167 +36,104 @@ function f(_pluginManager) {
|
|
|
49
36
|
selectedAssembliesPre: undefined,
|
|
50
37
|
}))
|
|
51
38
|
.views(self => ({
|
|
52
|
-
/**
|
|
53
|
-
* #getter
|
|
54
|
-
*/
|
|
55
39
|
get bookmarkAssemblies() {
|
|
56
40
|
return [...new Set(self.bookmarks.map(r => r.assemblyName))];
|
|
57
41
|
},
|
|
58
|
-
/**
|
|
59
|
-
* #getter
|
|
60
|
-
*/
|
|
61
42
|
get validAssemblies() {
|
|
62
43
|
const { assemblyManager } = (0, util_1.getSession)(self);
|
|
63
44
|
return new Set(this.bookmarkAssemblies.filter(a => assemblyManager.get(a)));
|
|
64
45
|
},
|
|
65
|
-
/**
|
|
66
|
-
* #getter
|
|
67
|
-
*/
|
|
68
46
|
get areBookmarksHighlightedOnAllOpenViews() {
|
|
69
47
|
const { views } = (0, util_1.getSession)(self);
|
|
70
|
-
return views.every(v => '
|
|
48
|
+
return views.every(v => 'bookmarkHighlightsVisible' in v ? v.bookmarkHighlightsVisible : true);
|
|
71
49
|
},
|
|
72
|
-
/**
|
|
73
|
-
* #getter
|
|
74
|
-
*/
|
|
75
50
|
get areBookmarksHighlightLabelsOnAllOpenViews() {
|
|
76
51
|
const { views } = (0, util_1.getSession)(self);
|
|
77
|
-
return views.every(v => '
|
|
52
|
+
return views.every(v => 'bookmarkLabelsVisible' in v ? v.bookmarkLabelsVisible : true);
|
|
78
53
|
},
|
|
79
54
|
}))
|
|
80
55
|
.views(self => ({
|
|
81
|
-
/**
|
|
82
|
-
* #getter
|
|
83
|
-
*/
|
|
84
56
|
get bookmarksWithValidAssemblies() {
|
|
85
57
|
return self.bookmarks.filter(e => self.validAssemblies.has(e.assemblyName));
|
|
86
58
|
},
|
|
87
59
|
}))
|
|
88
60
|
.views(self => ({
|
|
89
|
-
/**
|
|
90
|
-
* #getter
|
|
91
|
-
*/
|
|
92
61
|
get sharedBookmarksModel() {
|
|
93
|
-
// requires cloning bookmarks with JSON.stringify/parse to avoid duplicate
|
|
94
|
-
// reference to same object in the same state tree, will otherwise error
|
|
95
|
-
// when performing share
|
|
96
62
|
return SharedBookmarksModel.create({
|
|
97
63
|
sharedBookmarks: JSON.parse(JSON.stringify(self.selectedBookmarks)),
|
|
98
64
|
});
|
|
99
65
|
},
|
|
100
|
-
/**
|
|
101
|
-
* #getter
|
|
102
|
-
*/
|
|
103
66
|
get allBookmarksModel() {
|
|
104
|
-
// requires cloning bookmarks with JSON.stringify/parse to avoid duplicate
|
|
105
|
-
// reference to same object in the same state tree, will otherwise error
|
|
106
|
-
// when performing share
|
|
107
67
|
return SharedBookmarksModel.create({
|
|
108
68
|
sharedBookmarks: JSON.parse(JSON.stringify(self.bookmarksWithValidAssemblies)),
|
|
109
69
|
});
|
|
110
70
|
},
|
|
111
71
|
}))
|
|
112
72
|
.actions(self => ({
|
|
113
|
-
/**
|
|
114
|
-
* #action
|
|
115
|
-
*/
|
|
116
73
|
setSelectedAssemblies(assemblies) {
|
|
117
74
|
self.selectedAssembliesPre = assemblies;
|
|
118
75
|
},
|
|
119
76
|
}))
|
|
120
77
|
.views(self => ({
|
|
121
|
-
/**
|
|
122
|
-
* #getter
|
|
123
|
-
*/
|
|
124
78
|
get selectedAssemblies() {
|
|
125
79
|
var _a, _b;
|
|
126
80
|
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]);
|
|
127
81
|
},
|
|
128
82
|
}))
|
|
129
83
|
.actions(self => ({
|
|
130
|
-
/**
|
|
131
|
-
* #action
|
|
132
|
-
*/
|
|
133
84
|
importBookmarks(regions) {
|
|
134
85
|
self.bookmarks = (0, mobx_state_tree_1.cast)([...self.bookmarks, ...regions]);
|
|
135
86
|
},
|
|
136
|
-
/**
|
|
137
|
-
* #action
|
|
138
|
-
*/
|
|
139
87
|
addBookmark(region) {
|
|
140
88
|
self.bookmarks.push(region);
|
|
141
89
|
},
|
|
142
|
-
/**
|
|
143
|
-
* #action
|
|
144
|
-
*/
|
|
145
90
|
removeBookmark(index) {
|
|
146
91
|
self.bookmarks.splice(index, 1);
|
|
147
92
|
},
|
|
148
|
-
/**
|
|
149
|
-
* #action
|
|
150
|
-
*/
|
|
151
93
|
updateBookmarkLabel(bookmark, label) {
|
|
152
94
|
bookmark.correspondingObj.setLabel(label);
|
|
153
95
|
},
|
|
154
|
-
/**
|
|
155
|
-
* #action
|
|
156
|
-
*/
|
|
157
96
|
updateBookmarkHighlight(bookmark, color) {
|
|
158
97
|
bookmark.correspondingObj.setHighlight(color);
|
|
159
98
|
},
|
|
160
|
-
/**
|
|
161
|
-
* #action
|
|
162
|
-
*/
|
|
163
99
|
updateBulkBookmarkHighlights(color) {
|
|
164
100
|
self.selectedBookmarks.forEach(bookmark => {
|
|
165
101
|
this.updateBookmarkHighlight(bookmark, color);
|
|
166
102
|
});
|
|
167
103
|
},
|
|
168
|
-
/**
|
|
169
|
-
* #action
|
|
170
|
-
*/
|
|
171
104
|
setSelectedBookmarks(bookmarks) {
|
|
172
105
|
self.selectedBookmarks = bookmarks;
|
|
173
106
|
},
|
|
174
|
-
/**
|
|
175
|
-
* #action
|
|
176
|
-
*/
|
|
177
107
|
setBookmarkedRegions(regions) {
|
|
178
108
|
self.bookmarks = (0, mobx_state_tree_1.cast)(regions);
|
|
179
109
|
},
|
|
180
|
-
|
|
181
|
-
* #action
|
|
182
|
-
*/
|
|
183
|
-
setHighlightToggle(toggle) {
|
|
110
|
+
setBookmarkHighlightsVisible(arg) {
|
|
184
111
|
const { views } = (0, util_1.getSession)(self);
|
|
185
112
|
views.forEach(view => {
|
|
186
|
-
var _a;
|
|
187
|
-
|
|
188
|
-
(
|
|
113
|
+
var _a, _b;
|
|
114
|
+
(_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
115
|
+
(_b = view.views) === null || _b === void 0 ? void 0 : _b.map(view => {
|
|
116
|
+
var _a;
|
|
117
|
+
(_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
118
|
+
});
|
|
189
119
|
});
|
|
190
120
|
},
|
|
191
|
-
|
|
192
|
-
* #action
|
|
193
|
-
*/
|
|
194
|
-
setLabelToggle(toggle) {
|
|
121
|
+
setBookmarkLabelsVisible(arg) {
|
|
195
122
|
const { views } = (0, util_1.getSession)(self);
|
|
196
123
|
views.forEach(view => {
|
|
197
|
-
var _a;
|
|
198
|
-
|
|
199
|
-
(
|
|
124
|
+
var _a, _b;
|
|
125
|
+
(_a = view.setBookmarkLabelsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
126
|
+
(_b = view.views) === null || _b === void 0 ? void 0 : _b.map(view => {
|
|
127
|
+
var _a;
|
|
128
|
+
(_a = view.setBookmarkHighlightsVisible) === null || _a === void 0 ? void 0 : _a.call(view, arg);
|
|
129
|
+
});
|
|
200
130
|
});
|
|
201
131
|
},
|
|
202
132
|
}))
|
|
203
133
|
.actions(self => ({
|
|
204
|
-
/**
|
|
205
|
-
* #action
|
|
206
|
-
*/
|
|
207
134
|
clearAllBookmarks() {
|
|
208
135
|
self.setBookmarkedRegions(self.bookmarks.filter(bookmark => !self.validAssemblies.has(bookmark.assemblyName)));
|
|
209
136
|
},
|
|
210
|
-
/**
|
|
211
|
-
* #action
|
|
212
|
-
*/
|
|
213
137
|
clearSelectedBookmarks() {
|
|
214
138
|
for (const bookmark of self.selectedBookmarks) {
|
|
215
139
|
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
|
|
6
|
+
export declare function readSessionFromDynamo(baseUrl: string, sessionQueryParam: string, password: string): Promise<string>;
|
|
@@ -25,9 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.shareSessionToDynamo = shareSessionToDynamo;
|
|
27
27
|
exports.readSessionFromDynamo = readSessionFromDynamo;
|
|
28
|
-
// duplicated from products/jbrowse-web/src/sessionSharing.ts ; could possibly be moved into a higher directory and shared between the two
|
|
29
28
|
const utils_1 = require("./utils");
|
|
30
|
-
// from https://stackoverflow.com/questions/1349404/
|
|
31
29
|
function generateUID(length) {
|
|
32
30
|
return window
|
|
33
31
|
.btoa([...window.crypto.getRandomValues(new Uint8Array(length * 2))]
|
|
@@ -55,7 +53,6 @@ function getErrorMsg(err) {
|
|
|
55
53
|
return err;
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
// writes the encrypted session, current datetime, and referer to DynamoDB
|
|
59
56
|
async function shareSessionToDynamo(session, url, referer) {
|
|
60
57
|
const sess = await (0, utils_1.toUrlSafeB64)(JSON.stringify(session));
|
|
61
58
|
const password = generateUID(5);
|
|
@@ -80,15 +77,12 @@ async function shareSessionToDynamo(session, url, referer) {
|
|
|
80
77
|
password,
|
|
81
78
|
};
|
|
82
79
|
}
|
|
83
|
-
async function readSessionFromDynamo(baseUrl, sessionQueryParam, password
|
|
80
|
+
async function readSessionFromDynamo(baseUrl, sessionQueryParam, password) {
|
|
84
81
|
const sessionId = sessionQueryParam.split('share-')[1];
|
|
85
82
|
const url = `${baseUrl}?sessionId=${encodeURIComponent(sessionId)}`;
|
|
86
|
-
const response = await fetch(url
|
|
87
|
-
signal,
|
|
88
|
-
});
|
|
83
|
+
const response = await fetch(url);
|
|
89
84
|
if (!response.ok) {
|
|
90
|
-
|
|
91
|
-
throw new Error(getErrorMsg(err));
|
|
85
|
+
throw new Error(getErrorMsg(await response.text()));
|
|
92
86
|
}
|
|
93
87
|
const json = await response.json();
|
|
94
88
|
return decrypt(json.session, password);
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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>;
|
|
@@ -28,21 +28,15 @@ exports.downloadBookmarkFile = downloadBookmarkFile;
|
|
|
28
28
|
exports.b64PadSuffix = b64PadSuffix;
|
|
29
29
|
exports.fromUrlSafeB64 = fromUrlSafeB64;
|
|
30
30
|
exports.toUrlSafeB64 = toUrlSafeB64;
|
|
31
|
-
const file_saver_1 = require("file-saver");
|
|
32
31
|
const util_1 = require("@jbrowse/core/util");
|
|
32
|
+
const file_saver_1 = require("file-saver");
|
|
33
33
|
async function navToBookmark(locString, assembly, views, model) {
|
|
34
34
|
const session = (0, util_1.getSession)(model);
|
|
35
35
|
try {
|
|
36
|
-
// get the focused view
|
|
37
36
|
let view = views.find(view => view.id === session.focusedViewId);
|
|
38
|
-
// check if the focused view is the appropriate assembly, if not proceed
|
|
39
37
|
if ((view === null || view === void 0 ? void 0 : view.assemblyNames[0]) !== assembly) {
|
|
40
|
-
view = views.find(elt =>
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
elt.type === 'LinearGenomeView' && elt.assemblyNames[0] === assembly);
|
|
38
|
+
view = views.find(elt => elt.type === 'LinearGenomeView' && elt.assemblyNames[0] === assembly);
|
|
43
39
|
}
|
|
44
|
-
// if no view is opened of the selectedAssembly, open a new
|
|
45
|
-
// view with that assembly
|
|
46
40
|
if (!view) {
|
|
47
41
|
const newViewId = `${model.id}_${assembly}`;
|
|
48
42
|
view = session.addView('LinearGenomeView', {
|
|
@@ -85,7 +79,6 @@ function downloadBookmarkFile(fileFormat, model) {
|
|
|
85
79
|
}
|
|
86
80
|
}
|
|
87
81
|
else {
|
|
88
|
-
// TSV
|
|
89
82
|
const fileHeader = 'chrom\tstart\tend\tlabel\tassembly_name\tcoord_range\n';
|
|
90
83
|
const fileContents = bookmarksToDownload
|
|
91
84
|
.map(bookmark => {
|
|
@@ -102,10 +95,6 @@ function downloadBookmarkFile(fileFormat, model) {
|
|
|
102
95
|
(0, file_saver_1.saveAs)(blob, fileName);
|
|
103
96
|
}
|
|
104
97
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Pad the end of a base64 string with "=" to make it valid
|
|
107
|
-
* @param b64 - unpadded b64 string
|
|
108
|
-
*/
|
|
109
98
|
function b64PadSuffix(b64) {
|
|
110
99
|
let num = 0;
|
|
111
100
|
const mo = b64.length % 4;
|
|
@@ -124,11 +113,6 @@ function b64PadSuffix(b64) {
|
|
|
124
113
|
}
|
|
125
114
|
return b64 + '='.repeat(num);
|
|
126
115
|
}
|
|
127
|
-
/**
|
|
128
|
-
* Decode and inflate a url-safe base64 to a string
|
|
129
|
-
* See {@link https://en.wikipedia.org/wiki/Base64#URL_applications}
|
|
130
|
-
* @param b64 - a base64 string to decode and inflate
|
|
131
|
-
*/
|
|
132
116
|
async function fromUrlSafeB64(b64) {
|
|
133
117
|
const originalB64 = b64PadSuffix(b64.replaceAll('-', '+').replaceAll('_', '/'));
|
|
134
118
|
const { toByteArray } = await Promise.resolve().then(() => __importStar(require('base64-js')));
|
|
@@ -137,11 +121,6 @@ async function fromUrlSafeB64(b64) {
|
|
|
137
121
|
const inflated = inflate(bytes);
|
|
138
122
|
return new TextDecoder().decode(inflated);
|
|
139
123
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Compress and encode a string as url-safe base64
|
|
142
|
-
* See {@link https://en.wikipedia.org/wiki/Base64#URL_applications}
|
|
143
|
-
* @param str- a string to compress and encode
|
|
144
|
-
*/
|
|
145
124
|
async function toUrlSafeB64(str) {
|
|
146
125
|
const bytes = new TextEncoder().encode(str);
|
|
147
126
|
const { deflate } = await Promise.resolve().then(() => __importStar(require('pako')));
|
package/dist/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;
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
|
|
7
7
|
const util_1 = require("@jbrowse/core/util");
|
|
8
|
-
// icons
|
|
9
8
|
const Bookmark_1 = __importDefault(require("@mui/icons-material/Bookmark"));
|
|
10
9
|
const Bookmarks_1 = __importDefault(require("@mui/icons-material/Bookmarks"));
|
|
11
10
|
const Highlight_1 = __importDefault(require("@mui/icons-material/Highlight"));
|
|
@@ -24,31 +23,15 @@ class GridBookmarkPlugin extends Plugin_1.default {
|
|
|
24
23
|
const lgv = stateModel;
|
|
25
24
|
const newStateModel = lgv
|
|
26
25
|
.props({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* show the bookmark highlights on this track
|
|
30
|
-
*/
|
|
31
|
-
showBookmarkHighlights: true,
|
|
32
|
-
/**
|
|
33
|
-
* #property
|
|
34
|
-
* show the bookmark labels on this track
|
|
35
|
-
*/
|
|
36
|
-
showBookmarkLabels: true,
|
|
26
|
+
bookmarkHighlightsVisible: true,
|
|
27
|
+
bookmarkLabelsVisible: true,
|
|
37
28
|
})
|
|
38
29
|
.actions(self => ({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*/
|
|
42
|
-
toggleShowBookmarkHighlights(toggle) {
|
|
43
|
-
self.showBookmarkHighlights =
|
|
44
|
-
toggle !== undefined ? toggle : !self.showBookmarkHighlights;
|
|
30
|
+
setBookmarkHighlightsVisible(arg) {
|
|
31
|
+
self.bookmarkHighlightsVisible = arg;
|
|
45
32
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*/
|
|
49
|
-
toggleShowBookmarkLabels(toggle) {
|
|
50
|
-
self.showBookmarkLabels =
|
|
51
|
-
toggle !== undefined ? toggle : !self.showBookmarkLabels;
|
|
33
|
+
setBookmarkLabelsVisible(arg) {
|
|
34
|
+
self.bookmarkLabelsVisible = arg;
|
|
52
35
|
},
|
|
53
36
|
activateBookmarkWidget() {
|
|
54
37
|
const session = (0, util_1.getSession)(self);
|
|
@@ -115,18 +98,18 @@ class GridBookmarkPlugin extends Plugin_1.default {
|
|
|
115
98
|
label: 'Toggle bookmark highlights',
|
|
116
99
|
icon: Highlight_1.default,
|
|
117
100
|
type: 'checkbox',
|
|
118
|
-
checked: self.
|
|
101
|
+
checked: self.bookmarkHighlightsVisible,
|
|
119
102
|
onClick: () => {
|
|
120
|
-
self.
|
|
103
|
+
self.setBookmarkHighlightsVisible(!self.bookmarkHighlightsVisible);
|
|
121
104
|
},
|
|
122
105
|
},
|
|
123
106
|
{
|
|
124
107
|
label: 'Toggle bookmark labels',
|
|
125
108
|
icon: Label_1.default,
|
|
126
109
|
type: 'checkbox',
|
|
127
|
-
checked: self.
|
|
110
|
+
checked: self.bookmarkLabelsVisible,
|
|
128
111
|
onClick: () => {
|
|
129
|
-
self.
|
|
112
|
+
self.setBookmarkLabelsVisible(!self.bookmarkLabelsVisible);
|
|
130
113
|
},
|
|
131
114
|
},
|
|
132
115
|
],
|
|
@@ -159,14 +142,12 @@ class GridBookmarkPlugin extends Plugin_1.default {
|
|
|
159
142
|
afterCreate() {
|
|
160
143
|
document.addEventListener('keydown', e => {
|
|
161
144
|
const activationSequence = (e.ctrlKey || e.metaKey) && e.shiftKey;
|
|
162
|
-
// ctrl+shift+d or cmd+shift+d
|
|
163
145
|
if (activationSequence && e.code === 'KeyD') {
|
|
164
146
|
e.preventDefault();
|
|
165
147
|
self.activateBookmarkWidget();
|
|
166
148
|
self.bookmarkCurrentRegion();
|
|
167
149
|
(0, util_1.getSession)(self).notify('Bookmark created.', 'success');
|
|
168
150
|
}
|
|
169
|
-
// ctrl+shift+m or cmd+shift+m
|
|
170
151
|
if (activationSequence && e.code === 'KeyM') {
|
|
171
152
|
e.preventDefault();
|
|
172
153
|
self.navigateNewestBookmark();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { observer } from 'mobx-react';
|
|
3
2
|
import { Checkbox, FormControl, InputLabel, ListItemText, MenuItem, OutlinedInput, Select, } from '@mui/material';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
4
|
const AssemblySelector = observer(function ({ model, }) {
|
|
5
5
|
const { validAssemblies, selectedAssemblies } = model;
|
|
6
6
|
const noAssemblies = validAssemblies.size === 0;
|
|
@@ -14,7 +14,6 @@ const AssemblySelector = observer(function ({ model, }) {
|
|
|
14
14
|
model.setSelectedAssemblies([...event.target.value]);
|
|
15
15
|
}, input: React.createElement(OutlinedInput, { label: label }), renderValue: selected => selected.join(', ') },
|
|
16
16
|
React.createElement(MenuItem, { onClickCapture: event => {
|
|
17
|
-
// onClickCapture allows us to avoid the parent Select onChange from triggering
|
|
18
17
|
if (isAllSelected) {
|
|
19
18
|
model.setSelectedAssemblies([]);
|
|
20
19
|
}
|