@jbrowse/web-core 2.16.1 → 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.
@@ -28,169 +28,74 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.BaseWebSession = BaseWebSession;
30
30
  const react_1 = require("react");
31
- const clone_1 = __importDefault(require("clone"));
31
+ const app_core_1 = require("@jbrowse/app-core");
32
32
  const configuration_1 = require("@jbrowse/core/configuration");
33
+ const SnackbarModel_1 = __importDefault(require("@jbrowse/core/ui/SnackbarModel"));
33
34
  const util_1 = require("@jbrowse/core/util");
34
- const mobx_1 = require("mobx");
35
- const mobx_state_tree_1 = require("mobx-state-tree");
36
35
  const product_core_1 = require("@jbrowse/product-core");
37
- const app_core_1 = require("@jbrowse/app-core");
38
- const SnackbarModel_1 = __importDefault(require("@jbrowse/core/ui/SnackbarModel"));
39
- // icons
40
- const Settings_1 = __importDefault(require("@mui/icons-material/Settings"));
41
- const FileCopy_1 = __importDefault(require("@mui/icons-material/FileCopy"));
42
36
  const Delete_1 = __importDefault(require("@mui/icons-material/Delete"));
37
+ const FileCopy_1 = __importDefault(require("@mui/icons-material/FileCopy"));
43
38
  const Info_1 = __importDefault(require("@mui/icons-material/Info"));
44
- // locals
39
+ const Settings_1 = __importDefault(require("@mui/icons-material/Settings"));
40
+ const mobx_1 = require("mobx");
41
+ const mobx_state_tree_1 = require("mobx-state-tree");
45
42
  const SessionConnections_1 = require("../SessionConnections");
46
- // lazies
47
43
  const AboutDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./AboutDialog'))));
48
- /**
49
- * #stateModel BaseWebSession
50
- * used for "web based" products, including jbrowse-web and react-app
51
- * composed of
52
- * - [ReferenceManagementSessionMixin](../referencemanagementsessionmixin)
53
- * - [DrawerWidgetSessionMixin](../drawerwidgetsessionmixin)
54
- * - [DialogQueueSessionMixin](../dialogqueuesessionmixin)
55
- * - [ThemeManagerSessionMixin](../thememanagersessionmixin)
56
- * - [MultipleViewsSessionMixin](../multipleviewssessionmixin)
57
- * - [SessionTracksManagerSessionMixin](../sessiontracksmanagersessionmixin)
58
- * - [SessionAssembliesMixin](../sessionassembliesmixin)
59
- * - [TemporaryAssembliesMixin](../temporaryassembliesmixin)
60
- * - [WebSessionConnectionsMixin](../websessionconnectionsmixin)
61
- * - [AppFocusMixin](../appfocusmixin)
62
- */
63
44
  function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
64
45
  const sessionModel = mobx_state_tree_1.types
65
46
  .compose('WebCoreSessionModel', mobx_state_tree_1.types.compose('WebCoreSessionModelGroupA', (0, product_core_1.ReferenceManagementSessionMixin)(pluginManager), (0, product_core_1.DrawerWidgetSessionMixin)(pluginManager), (0, product_core_1.DialogQueueSessionMixin)(pluginManager), (0, product_core_1.ThemeManagerSessionMixin)(pluginManager), (0, product_core_1.MultipleViewsSessionMixin)(pluginManager)), mobx_state_tree_1.types.compose('WebCoreSessionModelGroupB', (0, product_core_1.SessionTracksManagerSessionMixin)(pluginManager), (0, app_core_1.SessionAssembliesMixin)(pluginManager, assemblyConfigSchema), (0, app_core_1.TemporaryAssembliesMixin)(pluginManager, assemblyConfigSchema), (0, SessionConnections_1.WebSessionConnectionsMixin)(pluginManager), (0, app_core_1.AppFocusMixin)(), (0, SnackbarModel_1.default)()))
66
47
  .props({
67
- /**
68
- * #property
69
- */
70
48
  margin: 0,
71
- /**
72
- * #property
73
- */
74
49
  sessionPlugins: mobx_state_tree_1.types.array(mobx_state_tree_1.types.frozen()),
75
50
  })
76
- .volatile(( /* self */) => ({
77
- /**
78
- * #volatile
79
- */
51
+ .volatile(() => ({
80
52
  sessionThemeName: (0, util_1.localStorageGetItem)('themeName') || 'default',
81
- /**
82
- * #volatile
83
- * this is the current "task" that is being performed in the UI.
84
- * this is usually an object of the form
85
- * `{ taskName: "configure", target: thing_being_configured }`
86
- */
87
53
  task: undefined,
88
54
  }))
89
55
  .views(self => ({
90
- /**
91
- * #getter
92
- */
93
56
  get tracks() {
94
57
  return [...self.sessionTracks, ...self.jbrowse.tracks];
95
58
  },
96
- /**
97
- * #getter
98
- */
99
59
  get root() {
100
60
  return (0, mobx_state_tree_1.getParent)(self);
101
61
  },
102
- /**
103
- * #getter
104
- * list of sessionAssemblies and jbrowse config assemblies, does not
105
- * include temporaryAssemblies. basically the list to be displayed in a
106
- * AssemblySelector dropdown
107
- */
108
62
  get assemblies() {
109
63
  return [...self.jbrowse.assemblies, ...self.sessionAssemblies];
110
64
  },
111
- /**
112
- * #getter
113
- * list of config connections and session connections
114
- */
115
65
  get connections() {
116
66
  return [...self.jbrowse.connections, ...self.sessionConnections];
117
67
  },
118
68
  }))
119
69
  .actions(self => ({
120
- /**
121
- * #action
122
- */
123
70
  setName(str) {
124
71
  self.name = str;
125
72
  },
126
73
  }))
127
74
  .views(self => ({
128
- /**
129
- * #getter
130
- * list of sessionAssemblies and jbrowse config assemblies, does not
131
- * include temporaryAssemblies. basically the list to be displayed in a
132
- * AssemblySelector dropdown
133
- */
134
75
  get assemblyNames() {
135
76
  return self.assemblies.map(f => (0, configuration_1.readConfObject)(f, 'name'));
136
77
  },
137
- /**
138
- * #getter
139
- */
140
78
  get version() {
141
79
  return self.root.version;
142
80
  },
143
- /**
144
- * #getter
145
- */
146
81
  get shareURL() {
147
82
  return (0, configuration_1.getConf)(self.jbrowse, 'shareURL');
148
83
  },
149
- /**
150
- * #getter
151
- */
152
84
  get textSearchManager() {
153
85
  return self.root.textSearchManager;
154
86
  },
155
- /**
156
- * #getter
157
- */
158
87
  get assemblyManager() {
159
88
  return self.root.assemblyManager;
160
89
  },
161
- /**
162
- * #getter
163
- */
164
- get savedSessions() {
165
- return self.root.savedSessions;
90
+ get savedSessionMetadata() {
91
+ return self.root.savedSessionMetadata;
166
92
  },
167
- /**
168
- * #getter
169
- */
170
93
  get previousAutosaveId() {
171
94
  return self.root.previousAutosaveId;
172
95
  },
173
- /**
174
- * #getter
175
- */
176
- get savedSessionNames() {
177
- return self.root.savedSessionNames;
178
- },
179
- /**
180
- * #getter
181
- */
182
96
  get history() {
183
97
  return self.root.history;
184
98
  },
185
- /**
186
- * #getter
187
- */
188
- get menus() {
189
- return self.root.menus;
190
- },
191
- /**
192
- * #method
193
- */
194
99
  renderProps() {
195
100
  return {
196
101
  theme: self.theme,
@@ -199,15 +104,9 @@ function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
199
104
  },
200
105
  }))
201
106
  .actions(self => ({
202
- /**
203
- * #action
204
- */
205
107
  addAssemblyConf(conf) {
206
108
  self.jbrowse.addAssemblyConf(conf);
207
109
  },
208
- /**
209
- * #action
210
- */
211
110
  addSessionPlugin(plugin) {
212
111
  if (self.sessionPlugins.some(p => p.name === plugin.name)) {
213
112
  throw new Error('session plugin cannot be installed twice');
@@ -215,80 +114,48 @@ function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
215
114
  self.sessionPlugins.push(plugin);
216
115
  self.root.setPluginsUpdated(true);
217
116
  },
218
- /**
219
- * #action
220
- */
221
117
  removeSessionPlugin(pluginDefinition) {
222
- self.sessionPlugins = (0, mobx_state_tree_1.cast)(self.sessionPlugins.filter(plugin =>
223
- // @ts-expect-error
224
- plugin.url !== pluginDefinition.url ||
225
- // @ts-expect-error
118
+ self.sessionPlugins = (0, mobx_state_tree_1.cast)(self.sessionPlugins.filter(plugin => plugin.url !== pluginDefinition.url ||
226
119
  plugin.umdUrl !== pluginDefinition.umdUrl ||
227
- // @ts-expect-error
228
120
  plugin.cjsUrl !== pluginDefinition.cjsUrl ||
229
- // @ts-expect-error
230
121
  plugin.esmUrl !== pluginDefinition.esmUrl));
231
122
  (0, mobx_state_tree_1.getParent)(self).setPluginsUpdated(true);
232
123
  },
233
- /**
234
- * #action
235
- */
236
124
  addSavedSession(sessionSnapshot) {
237
125
  return self.root.addSavedSession(sessionSnapshot);
238
126
  },
239
- /**
240
- * #action
241
- */
242
- removeSavedSession(sessionSnapshot) {
243
- return self.root.removeSavedSession(sessionSnapshot);
127
+ deleteSavedSession(id) {
128
+ return self.root.deleteSavedSession(id);
129
+ },
130
+ favoriteSavedSession(id) {
131
+ return self.root.favoriteSavedSession(id);
132
+ },
133
+ unfavoriteSavedSession(id) {
134
+ return self.root.unfavoriteSavedSession(id);
244
135
  },
245
- /**
246
- * #action
247
- */
248
136
  renameCurrentSession(sessionName) {
249
137
  return self.root.renameCurrentSession(sessionName);
250
138
  },
251
- /**
252
- * #action
253
- */
254
139
  duplicateCurrentSession() {
255
140
  return self.root.duplicateCurrentSession();
256
141
  },
257
- /**
258
- * #action
259
- */
260
142
  activateSession(sessionName) {
261
143
  return self.root.activateSession(sessionName);
262
144
  },
263
- /**
264
- * #action
265
- */
266
145
  setDefaultSession() {
267
146
  return self.root.setDefaultSession();
268
147
  },
269
- /**
270
- * #action
271
- */
272
148
  saveSessionToLocalStorage() {
273
149
  return self.root.saveSessionToLocalStorage();
274
150
  },
275
- /**
276
- * #action
277
- */
278
151
  loadAutosaveSession() {
279
152
  return self.root.loadAutosaveSession();
280
153
  },
281
- /**
282
- * #action
283
- */
284
154
  setSession(sessionSnapshot) {
285
155
  return self.root.setSession(sessionSnapshot);
286
156
  },
287
157
  }))
288
158
  .actions(self => ({
289
- /**
290
- * #action
291
- */
292
159
  editTrackConfiguration(configuration) {
293
160
  const { adminMode, sessionTracks } = self;
294
161
  if (!adminMode && !sessionTracks.includes(configuration)) {
@@ -298,13 +165,9 @@ function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
298
165
  },
299
166
  }))
300
167
  .views(self => ({
301
- /**
302
- * #method
303
- */
304
168
  getTrackActionMenuItems(config) {
305
169
  const { adminMode, sessionTracks } = self;
306
170
  const canEdit = adminMode || sessionTracks.find(t => t.trackId === config.trackId);
307
- // disable if it is a reference sequence track
308
171
  const isRefSeq = config.type === 'ReferenceSequenceTrack';
309
172
  return [
310
173
  {
@@ -313,7 +176,10 @@ function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
313
176
  onClick: () => {
314
177
  self.queueDialog(handleClose => [
315
178
  AboutDialog,
316
- { config, handleClose },
179
+ {
180
+ config,
181
+ handleClose,
182
+ },
317
183
  ]);
318
184
  },
319
185
  icon: Info_1.default,
@@ -322,32 +188,31 @@ function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
322
188
  label: 'Settings',
323
189
  priority: 1001,
324
190
  disabled: !canEdit,
191
+ icon: Settings_1.default,
325
192
  onClick: () => {
326
193
  self.editTrackConfiguration(config);
327
194
  },
328
- icon: Settings_1.default,
329
195
  },
330
196
  {
331
197
  label: 'Delete track',
332
198
  priority: 1000,
333
199
  disabled: !canEdit || isRefSeq,
334
- onClick: () => self.deleteTrackConf(config),
335
200
  icon: Delete_1.default,
201
+ onClick: () => {
202
+ self.deleteTrackConf(config);
203
+ },
336
204
  },
337
205
  {
338
206
  label: 'Copy track',
339
207
  priority: 999,
340
208
  disabled: isRefSeq,
341
209
  onClick: () => {
342
- const snap = (0, clone_1.default)((0, mobx_state_tree_1.getSnapshot)(config));
210
+ const snap = structuredClone((0, mobx_state_tree_1.getSnapshot)(config));
343
211
  const now = Date.now();
344
212
  snap.trackId += `-${now}`;
345
213
  snap.displays.forEach(display => {
346
214
  display.displayId += `-${now}`;
347
215
  });
348
- // the -sessionTrack suffix to trackId is used as metadata for
349
- // the track selector to store the track in a special category,
350
- // and default category is also cleared
351
216
  if (!self.adminMode) {
352
217
  snap.trackId += '-sessionTrack';
353
218
  snap.category = undefined;
@@ -359,6 +224,9 @@ function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
359
224
  },
360
225
  ];
361
226
  },
227
+ menus() {
228
+ return self.root.menus();
229
+ },
362
230
  }))
363
231
  .actions(self => ({
364
232
  afterAttach() {
@@ -370,14 +238,8 @@ function BaseWebSession({ pluginManager, assemblyConfigSchema, }) {
370
238
  }));
371
239
  const extendedSessionModel = pluginManager.evaluateExtensionPoint('Core-extendSession', sessionModel);
372
240
  return mobx_state_tree_1.types.snapshotProcessor(extendedSessionModel, {
373
- // @ts-expect-error
374
241
  preProcessor(snapshot) {
375
- // @ts-expect-error
376
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
377
242
  const { connectionInstances, ...rest } = snapshot || {};
378
- // connectionInstances schema changed from object to an array, so any
379
- // old connectionInstances as object is in snapshot, filter it out
380
- // https://github.com/GMOD/jbrowse-components/issues/1903
381
243
  return !Array.isArray(connectionInstances) ? rest : snapshot;
382
244
  },
383
245
  });
@@ -1,10 +1,6 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
2
- import { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
- import { BaseConnectionConfigModel } from '@jbrowse/core/pluggableElementTypes/models/baseConnectionConfig';
4
- /**
5
- * #stateModel WebSessionConnectionsMixin
6
- * #category session
7
- */
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
3
+ import type { BaseConnectionConfigModel } from '@jbrowse/core/pluggableElementTypes/models/baseConnectionConfig';
8
4
  export declare function WebSessionConnectionsMixin(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
9
5
  connectionInstances: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
10
6
  name: import("mobx-state-tree").ISimpleType<string>;
@@ -51,9 +47,6 @@ export declare function WebSessionConnectionsMixin(pluginManager: PluginManager)
51
47
  clear(): void;
52
48
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
53
49
  } & {
54
- /**
55
- * #property
56
- */
57
50
  sessionConnections: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyModelType>;
58
51
  }, {
59
52
  readonly connections: ({
@@ -1,18 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebSessionConnectionsMixin = WebSessionConnectionsMixin;
4
- const mobx_state_tree_1 = require("mobx-state-tree");
5
4
  const product_core_1 = require("@jbrowse/product-core");
6
- /**
7
- * #stateModel WebSessionConnectionsMixin
8
- * #category session
9
- */
5
+ const mobx_state_tree_1 = require("mobx-state-tree");
10
6
  function WebSessionConnectionsMixin(pluginManager) {
11
7
  return mobx_state_tree_1.types
12
8
  .compose('SessionConnectionsManagement', (0, product_core_1.ConnectionManagementSessionMixin)(pluginManager), mobx_state_tree_1.types.model({
13
- /**
14
- * #property
15
- */
16
9
  sessionConnections: mobx_state_tree_1.types.array(pluginManager.pluggableConfigSchemaType('connection')),
17
10
  }))
18
11
  .actions(s => {