@jbrowse/plugin-data-management 2.11.0 → 2.11.1

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 (33) hide show
  1. package/dist/AddConnectionWidget/index.d.ts +1 -2
  2. package/dist/AddConnectionWidget/index.js +3 -2
  3. package/dist/AddTrackWidget/index.d.ts +1 -2
  4. package/dist/AddTrackWidget/index.js +3 -2
  5. package/dist/HierarchicalTrackSelectorWidget/index.d.ts +1 -2
  6. package/dist/HierarchicalTrackSelectorWidget/index.js +3 -2
  7. package/dist/HierarchicalTrackSelectorWidget/model.d.ts +13 -33
  8. package/dist/HierarchicalTrackSelectorWidget/model.js +95 -86
  9. package/dist/HierarchicalTrackSelectorWidget/util.d.ts +1 -1
  10. package/dist/HierarchicalTrackSelectorWidget/util.js +4 -3
  11. package/dist/PluginStoreWidget/index.d.ts +1 -2
  12. package/dist/PluginStoreWidget/index.js +3 -2
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +2 -2
  15. package/dist/ucsc-trackhub/index.d.ts +1 -2
  16. package/dist/ucsc-trackhub/index.js +3 -2
  17. package/esm/AddConnectionWidget/index.d.ts +1 -2
  18. package/esm/AddConnectionWidget/index.js +2 -2
  19. package/esm/AddTrackWidget/index.d.ts +1 -2
  20. package/esm/AddTrackWidget/index.js +2 -2
  21. package/esm/HierarchicalTrackSelectorWidget/index.d.ts +1 -2
  22. package/esm/HierarchicalTrackSelectorWidget/index.js +2 -2
  23. package/esm/HierarchicalTrackSelectorWidget/model.d.ts +13 -33
  24. package/esm/HierarchicalTrackSelectorWidget/model.js +96 -87
  25. package/esm/HierarchicalTrackSelectorWidget/util.d.ts +1 -1
  26. package/esm/HierarchicalTrackSelectorWidget/util.js +4 -3
  27. package/esm/PluginStoreWidget/index.d.ts +1 -2
  28. package/esm/PluginStoreWidget/index.js +2 -2
  29. package/esm/index.d.ts +1 -1
  30. package/esm/index.js +1 -1
  31. package/esm/ucsc-trackhub/index.d.ts +1 -2
  32. package/esm/ucsc-trackhub/index.js +2 -2
  33. package/package.json +2 -2
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function AddConnectionWidgetF(pluginManager: PluginManager): void;
@@ -31,7 +31,7 @@ const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
31
31
  const react_1 = require("react");
32
32
  const model_1 = __importDefault(require("./model"));
33
33
  const configSchema = (0, configuration_1.ConfigurationSchema)('AddConnectionWidget', {});
34
- exports.default = (pluginManager) => {
34
+ function AddConnectionWidgetF(pluginManager) {
35
35
  pluginManager.addWidgetType(() => {
36
36
  return new pluggableElementTypes_1.WidgetType({
37
37
  name: 'AddConnectionWidget',
@@ -41,4 +41,5 @@ exports.default = (pluginManager) => {
41
41
  ReactComponent: (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/AddConnectionWidget')))),
42
42
  });
43
43
  });
44
- };
44
+ }
45
+ exports.default = AddConnectionWidgetF;
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function AddTrackWidgetF(pluginManager: PluginManager): void;
@@ -31,7 +31,7 @@ const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
31
31
  const react_1 = require("react");
32
32
  const model_1 = __importDefault(require("./model"));
33
33
  const configSchema = (0, configuration_1.ConfigurationSchema)('AddTrackWidget', {});
34
- exports.default = (pluginManager) => {
34
+ function AddTrackWidgetF(pluginManager) {
35
35
  pluginManager.addWidgetType(() => {
36
36
  return new pluggableElementTypes_1.WidgetType({
37
37
  name: 'AddTrackWidget',
@@ -41,4 +41,5 @@ exports.default = (pluginManager) => {
41
41
  ReactComponent: (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/AddTrackWidget')))),
42
42
  });
43
43
  });
44
- };
44
+ }
45
+ exports.default = AddTrackWidgetF;
@@ -1,5 +1,4 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function HierarchicalTrackSelectorWidgetF(pluginManager: PluginManager): void;
4
3
  export { type HierarchicalTrackSelectorModel, default as stateModelFactory, } from './model';
5
4
  export { default as configSchema } from './configSchema';
@@ -31,7 +31,7 @@ const model_1 = __importDefault(require("./model"));
31
31
  const configSchema_1 = __importDefault(require("./configSchema"));
32
32
  const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
33
33
  const react_1 = require("react");
34
- exports.default = (pluginManager) => {
34
+ function HierarchicalTrackSelectorWidgetF(pluginManager) {
35
35
  pluginManager.addWidgetType(() => {
36
36
  return new pluggableElementTypes_1.WidgetType({
37
37
  name: 'HierarchicalTrackSelectorWidget',
@@ -41,7 +41,8 @@ exports.default = (pluginManager) => {
41
41
  ReactComponent: (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/HierarchicalTrackSelector')))),
42
42
  });
43
43
  });
44
- };
44
+ }
45
+ exports.default = HierarchicalTrackSelectorWidgetF;
45
46
  var model_2 = require("./model");
46
47
  Object.defineProperty(exports, "stateModelFactory", { enumerable: true, get: function () { return __importDefault(model_2).default; } });
47
48
  var configSchema_2 = require("./configSchema");
@@ -14,22 +14,6 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
14
14
  * #property
15
15
  */
16
16
  type: import("mobx-state-tree").ISimpleType<"HierarchicalTrackSelectorWidget">;
17
- /**
18
- * #property
19
- */
20
- initialized: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<boolean>>;
21
- /**
22
- * #property
23
- */
24
- collapsed: import("mobx-state-tree").IMapType<import("mobx-state-tree").ISimpleType<boolean>>;
25
- /**
26
- * #property
27
- */
28
- sortTrackNames: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<boolean>>;
29
- /**
30
- * #property
31
- */
32
- sortCategories: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<boolean>>;
33
17
  /**
34
18
  * #property
35
19
  */
@@ -107,6 +91,9 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
107
91
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
108
92
  setSubschema(slotName: string, data: unknown): any;
109
93
  } & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>)[];
94
+ sortTrackNames: boolean;
95
+ sortCategories: boolean;
96
+ collapsed: import("mobx").ObservableMap<string, boolean>;
110
97
  filterText: string;
111
98
  recentlyUsedCounter: number;
112
99
  favoritesCounter: number;
@@ -131,6 +118,10 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
131
118
  * #getter
132
119
  */
133
120
  readonly recentlyUsedSet: Set<string>;
121
+ /**
122
+ * #getter
123
+ */
124
+ readonly assemblyNames: string[];
134
125
  } & {
135
126
  /**
136
127
  * #action
@@ -208,6 +199,10 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
208
199
  * #action
209
200
  */
210
201
  expandAllCategories(): void;
202
+ /**
203
+ * #action
204
+ */
205
+ setCollapsedCategories(str: [string, boolean][]): void;
211
206
  /**
212
207
  * #action
213
208
  */
@@ -237,24 +232,11 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
237
232
  /**
238
233
  * #getter
239
234
  */
240
- readonly assemblyNames: string[];
241
- } & {
242
- /**
243
- * #getter
244
- */
245
- readonly recentlyUsedLocalStorageKey: string;
235
+ readonly activeSortTrackNames: boolean;
246
236
  /**
247
237
  * #getter
248
238
  */
249
- readonly favoritesLocalStorageKey: string;
250
- /**
251
- * #getter
252
- */
253
- readonly activeSortTrackNames: any;
254
- /**
255
- * #getter
256
- */
257
- readonly activeSortCategories: any;
239
+ readonly activeSortCategories: boolean;
258
240
  /**
259
241
  * #getter
260
242
  * filter out tracks that don't match the current assembly/display types
@@ -340,8 +322,6 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
340
322
  * #action
341
323
  */
342
324
  collapseTopLevelCategories(): void;
343
- } & {
344
- afterCreate(): void;
345
325
  } & {
346
326
  /**
347
327
  * #getter
@@ -10,21 +10,52 @@ const filterTracks_1 = require("./filterTracks");
10
10
  const generateHierarchy_1 = require("./generateHierarchy");
11
11
  const util_2 = require("./util");
12
12
  const facetedModel_1 = require("./facetedModel");
13
- // for settings that are config dependent
14
- function postNoConfigF() {
13
+ // for settings that are not config dependent
14
+ function keyNoConfigPostFix() {
15
15
  return typeof window !== 'undefined'
16
16
  ? [window.location.host, window.location.pathname].join('-')
17
17
  : 'empty';
18
18
  }
19
- // for settings that are not config dependent
20
- function postF() {
19
+ // for settings that are config dependent
20
+ function keyConfigPostFix() {
21
21
  return typeof window !== 'undefined'
22
22
  ? [
23
- postNoConfigF(),
23
+ keyNoConfigPostFix(),
24
24
  new URLSearchParams(window.location.search).get('config'),
25
25
  ].join('-')
26
26
  : 'empty';
27
27
  }
28
+ function recentlyUsedK(assemblyNames) {
29
+ return ['recentlyUsedTracks', keyConfigPostFix(), assemblyNames.join(',')]
30
+ .filter(f => !!f)
31
+ .join('-');
32
+ }
33
+ // this has a extra } at the end because that's how it was initially
34
+ // released
35
+ function favoritesK() {
36
+ return `favoriteTracks-${keyConfigPostFix()}}`;
37
+ }
38
+ function collapsedK(assemblyNames, viewType) {
39
+ return [
40
+ 'collapsedCategories',
41
+ keyConfigPostFix(),
42
+ assemblyNames.join(','),
43
+ viewType,
44
+ ].join('-');
45
+ }
46
+ function sortTrackNamesK() {
47
+ return 'sortTrackNames';
48
+ }
49
+ function sortCategoriesK() {
50
+ return 'sortCategories';
51
+ }
52
+ function localStorageGetJSON(key, defaultValue) {
53
+ var _a;
54
+ return JSON.parse((_a = (0, util_1.localStorageGetItem)(key)) !== null && _a !== void 0 ? _a : defaultValue);
55
+ }
56
+ function localStorageSetJSON(key, val) {
57
+ (0, util_1.localStorageSetItem)(key, JSON.stringify(val));
58
+ }
28
59
  const MAX_RECENTLY_USED = 10;
29
60
  /**
30
61
  * #stateModel HierarchicalTrackSelectorWidget
@@ -40,22 +71,6 @@ function stateTreeFactory(pluginManager) {
40
71
  * #property
41
72
  */
42
73
  type: mobx_state_tree_1.types.literal('HierarchicalTrackSelectorWidget'),
43
- /**
44
- * #property
45
- */
46
- initialized: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.boolean),
47
- /**
48
- * #property
49
- */
50
- collapsed: mobx_state_tree_1.types.map(mobx_state_tree_1.types.boolean),
51
- /**
52
- * #property
53
- */
54
- sortTrackNames: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.boolean),
55
- /**
56
- * #property
57
- */
58
- sortCategories: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.boolean),
59
74
  /**
60
75
  * #property
61
76
  */
@@ -66,9 +81,12 @@ function stateTreeFactory(pluginManager) {
66
81
  faceted: mobx_state_tree_1.types.optional((0, facetedModel_1.facetedStateTreeF)(), {}),
67
82
  })
68
83
  .volatile(() => ({
69
- favorites: [],
84
+ favorites: localStorageGetJSON(favoritesK(), '[]'),
70
85
  recentlyUsed: [],
71
86
  selection: [],
87
+ sortTrackNames: !!localStorageGetJSON(sortTrackNamesK(), 'false'),
88
+ sortCategories: !!localStorageGetJSON(sortCategoriesK(), 'false'),
89
+ collapsed: mobx_1.observable.map(),
72
90
  filterText: '',
73
91
  recentlyUsedCounter: 0,
74
92
  favoritesCounter: 0,
@@ -99,6 +117,13 @@ function stateTreeFactory(pluginManager) {
99
117
  get recentlyUsedSet() {
100
118
  return new Set(self.recentlyUsed);
101
119
  },
120
+ /**
121
+ * #getter
122
+ */
123
+ get assemblyNames() {
124
+ var _a;
125
+ return ((_a = self.view) === null || _a === void 0 ? void 0 : _a.assemblyNames) || [];
126
+ },
102
127
  }))
103
128
  .actions(self => ({
104
129
  /**
@@ -223,6 +248,12 @@ function stateTreeFactory(pluginManager) {
223
248
  expandAllCategories() {
224
249
  self.collapsed.clear();
225
250
  },
251
+ /**
252
+ * #action
253
+ */
254
+ setCollapsedCategories(str) {
255
+ self.collapsed.replace(str);
256
+ },
226
257
  /**
227
258
  * #action
228
259
  */
@@ -263,43 +294,17 @@ function stateTreeFactory(pluginManager) {
263
294
  const assembly = assemblyManager.get(assemblyName);
264
295
  const trackConf = assembly === null || assembly === void 0 ? void 0 : assembly.configuration.sequence;
265
296
  const viewType = pluginManager.getViewType(self.view.type);
266
- if (!trackConf) {
267
- return undefined;
268
- }
269
- for (const display of trackConf.displays) {
270
- if (viewType.displayTypes.some(d => d.name === display.type)) {
271
- return trackConf;
297
+ if (trackConf) {
298
+ for (const display of trackConf.displays) {
299
+ if (viewType.displayTypes.some(d => d.name === display.type)) {
300
+ return trackConf;
301
+ }
272
302
  }
273
303
  }
274
304
  return undefined;
275
305
  },
276
306
  }))
277
307
  .views(self => ({
278
- /**
279
- * #getter
280
- */
281
- get assemblyNames() {
282
- var _a;
283
- return ((_a = self.view) === null || _a === void 0 ? void 0 : _a.assemblyNames) || [];
284
- },
285
- }))
286
- .views(self => ({
287
- /**
288
- * #getter
289
- */
290
- get recentlyUsedLocalStorageKey() {
291
- return `recentlyUsedTracks-${[postF(), self.assemblyNames.join(',')]
292
- .filter(f => !!f)
293
- .join('-')}`;
294
- },
295
- /**
296
- * #getter
297
- */
298
- get favoritesLocalStorageKey() {
299
- // this has a extra } at the end because that's how it was initially
300
- // released
301
- return `favoriteTracks-${postF()}}`;
302
- },
303
308
  /**
304
309
  * #getter
305
310
  */
@@ -434,35 +439,6 @@ function stateTreeFactory(pluginManager) {
434
439
  self.setCategoryCollapsed(path, true);
435
440
  }
436
441
  },
437
- }))
438
- .actions(self => ({
439
- afterCreate() {
440
- if (!self.initialized) {
441
- const session = (0, util_1.getSession)(self);
442
- if ((0, configuration_1.getConf)(session, [
443
- 'hierarchical',
444
- 'defaultCollapsed',
445
- 'topLevelCategories',
446
- ])) {
447
- self.collapseTopLevelCategories();
448
- }
449
- if ((0, configuration_1.getConf)(session, [
450
- 'hierarchical',
451
- 'defaultCollapsed',
452
- 'subCategories',
453
- ])) {
454
- self.collapseSubCategories();
455
- }
456
- for (const entry of (0, configuration_1.getConf)(session, [
457
- 'hierarchical',
458
- 'defaultCollapsed',
459
- 'categoryNames',
460
- ])) {
461
- self.collapsed.set(entry, true);
462
- }
463
- self.initialized = true;
464
- }
465
- },
466
442
  }))
467
443
  .views(self => ({
468
444
  /**
@@ -476,13 +452,46 @@ function stateTreeFactory(pluginManager) {
476
452
  afterAttach() {
477
453
  // this should be the first autorun to properly initialize
478
454
  (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
479
- self.setRecentlyUsed(JSON.parse((0, util_1.localStorageGetItem)(self.recentlyUsedLocalStorageKey) || '[]'));
480
- self.setFavorites(JSON.parse((0, util_1.localStorageGetItem)(self.favoritesLocalStorageKey) || '[]'));
455
+ const { assemblyNames, view } = self;
456
+ self.setRecentlyUsed(localStorageGetJSON(recentlyUsedK(assemblyNames), '[]'));
457
+ const val = (0, util_1.localStorageGetItem)(collapsedK(assemblyNames, view.type));
458
+ if (!val) {
459
+ self.expandAllCategories();
460
+ const session = (0, util_1.getSession)(self);
461
+ if ((0, configuration_1.getConf)(session, [
462
+ 'hierarchical',
463
+ 'defaultCollapsed',
464
+ 'topLevelCategories',
465
+ ])) {
466
+ self.collapseTopLevelCategories();
467
+ }
468
+ if ((0, configuration_1.getConf)(session, [
469
+ 'hierarchical',
470
+ 'defaultCollapsed',
471
+ 'subCategories',
472
+ ])) {
473
+ self.collapseSubCategories();
474
+ }
475
+ for (const entry of (0, configuration_1.getConf)(session, [
476
+ 'hierarchical',
477
+ 'defaultCollapsed',
478
+ 'categoryNames',
479
+ ])) {
480
+ self.setCategoryCollapsed(`Tracks-${entry}`, true);
481
+ }
482
+ }
483
+ else {
484
+ self.setCollapsedCategories(JSON.parse(val));
485
+ }
481
486
  }));
482
487
  // this should be the second autorun
483
488
  (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
484
- (0, util_1.localStorageSetItem)(self.favoritesLocalStorageKey, JSON.stringify(self.favorites));
485
- (0, util_1.localStorageSetItem)(self.recentlyUsedLocalStorageKey, JSON.stringify(self.recentlyUsed));
489
+ const { assemblyNames, collapsed, view } = self;
490
+ localStorageSetJSON(recentlyUsedK(assemblyNames), self.recentlyUsed);
491
+ localStorageSetJSON(collapsedK(assemblyNames, view.type), collapsed);
492
+ localStorageSetJSON(favoritesK(), self.favorites);
493
+ localStorageSetJSON(sortTrackNamesK(), self.sortTrackNames);
494
+ localStorageSetJSON(sortCategoriesK(), self.sortCategories);
486
495
  }));
487
496
  },
488
497
  }));
@@ -7,6 +7,6 @@ interface Node {
7
7
  children: Node[];
8
8
  id: string;
9
9
  }
10
- export declare function findSubCategories(obj: Node[], paths: string[]): boolean;
10
+ export declare function findSubCategories(obj: Node[], paths: string[], depth?: number): boolean;
11
11
  export declare function findTopLevelCategories(obj: Node[], paths: string[]): void;
12
12
  export {};
@@ -27,12 +27,13 @@ function matches(query, conf, session) {
27
27
  !!categories.filter(c => c.toLowerCase().includes(queryLower)).length);
28
28
  }
29
29
  exports.matches = matches;
30
- function findSubCategories(obj, paths) {
30
+ function findSubCategories(obj, paths, depth = 0) {
31
31
  let hasSubs = false;
32
32
  for (const elt of obj) {
33
33
  if (elt.children.length) {
34
- const hasSubCategories = findSubCategories(elt.children, paths);
35
- if (hasSubCategories) {
34
+ const hasSubCategories = findSubCategories(elt.children, paths, depth + 1);
35
+ // avoid pushing the root "Tracks" node by checking depth>0
36
+ if (hasSubCategories && depth > 0) {
36
37
  paths.push(elt.id);
37
38
  }
38
39
  }
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function PluginStoreWidgetF(pluginManager: PluginManager): void;
@@ -31,7 +31,7 @@ const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
31
31
  const react_1 = require("react");
32
32
  const model_1 = __importDefault(require("./model"));
33
33
  const configSchema = (0, configuration_1.ConfigurationSchema)('PluginStoreWidget', {});
34
- exports.default = (pluginManager) => {
34
+ function PluginStoreWidgetF(pluginManager) {
35
35
  pluginManager.addWidgetType(() => {
36
36
  return new pluggableElementTypes_1.WidgetType({
37
37
  name: 'PluginStoreWidget',
@@ -41,4 +41,5 @@ exports.default = (pluginManager) => {
41
41
  ReactComponent: (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/PluginStoreWidget')))),
42
42
  });
43
43
  });
44
- };
44
+ }
45
+ exports.default = PluginStoreWidgetF;
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ declare const AssemblyManager: import("react").LazyExoticComponent<({ rootModel,
5
5
  rootModel: any;
6
6
  onClose: (arg: boolean) => void;
7
7
  }) => import("react").JSX.Element>;
8
- export default class extends Plugin {
8
+ export default class DataManagementPlugin extends Plugin {
9
9
  name: string;
10
10
  exports: {
11
11
  AssemblyManager: import("react").LazyExoticComponent<({ rootModel, onClose, }: {
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ const PluginStoreWidget_1 = __importDefault(require("./PluginStoreWidget"));
36
36
  const HierarchicalTrackSelectorWidget_1 = __importDefault(require("./HierarchicalTrackSelectorWidget"));
37
37
  const AssemblyManager = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./AssemblyManager'))));
38
38
  exports.AssemblyManager = AssemblyManager;
39
- class default_1 extends Plugin_1.default {
39
+ class DataManagementPlugin extends Plugin_1.default {
40
40
  constructor() {
41
41
  super(...arguments);
42
42
  this.name = 'DataManagementPlugin';
@@ -53,4 +53,4 @@ class default_1 extends Plugin_1.default {
53
53
  }
54
54
  configure(_pluginManager) { }
55
55
  }
56
- exports.default = default_1;
56
+ exports.default = DataManagementPlugin;
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function UCSCTrackHubConnectionF(pluginManager: PluginManager): void;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
7
7
  const model_1 = __importDefault(require("./model"));
8
8
  const configSchema_1 = __importDefault(require("./configSchema"));
9
- exports.default = (pluginManager) => {
9
+ function UCSCTrackHubConnectionF(pluginManager) {
10
10
  pluginManager.addConnectionType(() => new pluggableElementTypes_1.ConnectionType({
11
11
  name: 'UCSCTrackHubConnection',
12
12
  configSchema: configSchema_1.default,
@@ -15,4 +15,5 @@ exports.default = (pluginManager) => {
15
15
  description: 'A track or assembly hub in the Track Hub format',
16
16
  url: '//genome.ucsc.edu/goldenPath/help/hgTrackHubHelp.html#Intro',
17
17
  }));
18
- };
18
+ }
19
+ exports.default = UCSCTrackHubConnectionF;
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function AddConnectionWidgetF(pluginManager: PluginManager): void;
@@ -3,7 +3,7 @@ import { WidgetType } from '@jbrowse/core/pluggableElementTypes';
3
3
  import { lazy } from 'react';
4
4
  import stateModel from './model';
5
5
  const configSchema = ConfigurationSchema('AddConnectionWidget', {});
6
- export default (pluginManager) => {
6
+ export default function AddConnectionWidgetF(pluginManager) {
7
7
  pluginManager.addWidgetType(() => {
8
8
  return new WidgetType({
9
9
  name: 'AddConnectionWidget',
@@ -13,4 +13,4 @@ export default (pluginManager) => {
13
13
  ReactComponent: lazy(() => import('./components/AddConnectionWidget')),
14
14
  });
15
15
  });
16
- };
16
+ }
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function AddTrackWidgetF(pluginManager: PluginManager): void;
@@ -3,7 +3,7 @@ import { WidgetType } from '@jbrowse/core/pluggableElementTypes';
3
3
  import { lazy } from 'react';
4
4
  import stateModelFactory from './model';
5
5
  const configSchema = ConfigurationSchema('AddTrackWidget', {});
6
- export default (pluginManager) => {
6
+ export default function AddTrackWidgetF(pluginManager) {
7
7
  pluginManager.addWidgetType(() => {
8
8
  return new WidgetType({
9
9
  name: 'AddTrackWidget',
@@ -13,4 +13,4 @@ export default (pluginManager) => {
13
13
  ReactComponent: lazy(() => import('./components/AddTrackWidget')),
14
14
  });
15
15
  });
16
- };
16
+ }
@@ -1,5 +1,4 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function HierarchicalTrackSelectorWidgetF(pluginManager: PluginManager): void;
4
3
  export { type HierarchicalTrackSelectorModel, default as stateModelFactory, } from './model';
5
4
  export { default as configSchema } from './configSchema';
@@ -2,7 +2,7 @@ import stateModelFactory from './model';
2
2
  import configSchema from './configSchema';
3
3
  import { WidgetType } from '@jbrowse/core/pluggableElementTypes';
4
4
  import { lazy } from 'react';
5
- export default (pluginManager) => {
5
+ export default function HierarchicalTrackSelectorWidgetF(pluginManager) {
6
6
  pluginManager.addWidgetType(() => {
7
7
  return new WidgetType({
8
8
  name: 'HierarchicalTrackSelectorWidget',
@@ -12,6 +12,6 @@ export default (pluginManager) => {
12
12
  ReactComponent: lazy(() => import('./components/HierarchicalTrackSelector')),
13
13
  });
14
14
  });
15
- };
15
+ }
16
16
  export { default as stateModelFactory, } from './model';
17
17
  export { default as configSchema } from './configSchema';
@@ -14,22 +14,6 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
14
14
  * #property
15
15
  */
16
16
  type: import("mobx-state-tree").ISimpleType<"HierarchicalTrackSelectorWidget">;
17
- /**
18
- * #property
19
- */
20
- initialized: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<boolean>>;
21
- /**
22
- * #property
23
- */
24
- collapsed: import("mobx-state-tree").IMapType<import("mobx-state-tree").ISimpleType<boolean>>;
25
- /**
26
- * #property
27
- */
28
- sortTrackNames: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<boolean>>;
29
- /**
30
- * #property
31
- */
32
- sortCategories: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<boolean>>;
33
17
  /**
34
18
  * #property
35
19
  */
@@ -107,6 +91,9 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
107
91
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
108
92
  setSubschema(slotName: string, data: unknown): any;
109
93
  } & import("mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>)[];
94
+ sortTrackNames: boolean;
95
+ sortCategories: boolean;
96
+ collapsed: import("mobx").ObservableMap<string, boolean>;
110
97
  filterText: string;
111
98
  recentlyUsedCounter: number;
112
99
  favoritesCounter: number;
@@ -131,6 +118,10 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
131
118
  * #getter
132
119
  */
133
120
  readonly recentlyUsedSet: Set<string>;
121
+ /**
122
+ * #getter
123
+ */
124
+ readonly assemblyNames: string[];
134
125
  } & {
135
126
  /**
136
127
  * #action
@@ -208,6 +199,10 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
208
199
  * #action
209
200
  */
210
201
  expandAllCategories(): void;
202
+ /**
203
+ * #action
204
+ */
205
+ setCollapsedCategories(str: [string, boolean][]): void;
211
206
  /**
212
207
  * #action
213
208
  */
@@ -237,24 +232,11 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
237
232
  /**
238
233
  * #getter
239
234
  */
240
- readonly assemblyNames: string[];
241
- } & {
242
- /**
243
- * #getter
244
- */
245
- readonly recentlyUsedLocalStorageKey: string;
235
+ readonly activeSortTrackNames: boolean;
246
236
  /**
247
237
  * #getter
248
238
  */
249
- readonly favoritesLocalStorageKey: string;
250
- /**
251
- * #getter
252
- */
253
- readonly activeSortTrackNames: any;
254
- /**
255
- * #getter
256
- */
257
- readonly activeSortCategories: any;
239
+ readonly activeSortCategories: boolean;
258
240
  /**
259
241
  * #getter
260
242
  * filter out tracks that don't match the current assembly/display types
@@ -340,8 +322,6 @@ export default function stateTreeFactory(pluginManager: PluginManager): import("
340
322
  * #action
341
323
  */
342
324
  collapseTopLevelCategories(): void;
343
- } & {
344
- afterCreate(): void;
345
325
  } & {
346
326
  /**
347
327
  * #getter
@@ -1,5 +1,5 @@
1
1
  import { types, addDisposer } from 'mobx-state-tree';
2
- import { autorun } from 'mobx';
2
+ import { autorun, observable } from 'mobx';
3
3
  import { getConf, readConfObject, } from '@jbrowse/core/configuration';
4
4
  import { dedupe, getSession, localStorageGetItem, localStorageSetItem, notEmpty, } from '@jbrowse/core/util';
5
5
  import { ElementId } from '@jbrowse/core/util/types/mst';
@@ -8,21 +8,52 @@ import { filterTracks } from './filterTracks';
8
8
  import { generateHierarchy } from './generateHierarchy';
9
9
  import { findSubCategories, findTopLevelCategories } from './util';
10
10
  import { facetedStateTreeF } from './facetedModel';
11
- // for settings that are config dependent
12
- function postNoConfigF() {
11
+ // for settings that are not config dependent
12
+ function keyNoConfigPostFix() {
13
13
  return typeof window !== 'undefined'
14
14
  ? [window.location.host, window.location.pathname].join('-')
15
15
  : 'empty';
16
16
  }
17
- // for settings that are not config dependent
18
- function postF() {
17
+ // for settings that are config dependent
18
+ function keyConfigPostFix() {
19
19
  return typeof window !== 'undefined'
20
20
  ? [
21
- postNoConfigF(),
21
+ keyNoConfigPostFix(),
22
22
  new URLSearchParams(window.location.search).get('config'),
23
23
  ].join('-')
24
24
  : 'empty';
25
25
  }
26
+ function recentlyUsedK(assemblyNames) {
27
+ return ['recentlyUsedTracks', keyConfigPostFix(), assemblyNames.join(',')]
28
+ .filter(f => !!f)
29
+ .join('-');
30
+ }
31
+ // this has a extra } at the end because that's how it was initially
32
+ // released
33
+ function favoritesK() {
34
+ return `favoriteTracks-${keyConfigPostFix()}}`;
35
+ }
36
+ function collapsedK(assemblyNames, viewType) {
37
+ return [
38
+ 'collapsedCategories',
39
+ keyConfigPostFix(),
40
+ assemblyNames.join(','),
41
+ viewType,
42
+ ].join('-');
43
+ }
44
+ function sortTrackNamesK() {
45
+ return 'sortTrackNames';
46
+ }
47
+ function sortCategoriesK() {
48
+ return 'sortCategories';
49
+ }
50
+ function localStorageGetJSON(key, defaultValue) {
51
+ var _a;
52
+ return JSON.parse((_a = localStorageGetItem(key)) !== null && _a !== void 0 ? _a : defaultValue);
53
+ }
54
+ function localStorageSetJSON(key, val) {
55
+ localStorageSetItem(key, JSON.stringify(val));
56
+ }
26
57
  const MAX_RECENTLY_USED = 10;
27
58
  /**
28
59
  * #stateModel HierarchicalTrackSelectorWidget
@@ -38,22 +69,6 @@ export default function stateTreeFactory(pluginManager) {
38
69
  * #property
39
70
  */
40
71
  type: types.literal('HierarchicalTrackSelectorWidget'),
41
- /**
42
- * #property
43
- */
44
- initialized: types.maybe(types.boolean),
45
- /**
46
- * #property
47
- */
48
- collapsed: types.map(types.boolean),
49
- /**
50
- * #property
51
- */
52
- sortTrackNames: types.maybe(types.boolean),
53
- /**
54
- * #property
55
- */
56
- sortCategories: types.maybe(types.boolean),
57
72
  /**
58
73
  * #property
59
74
  */
@@ -64,9 +79,12 @@ export default function stateTreeFactory(pluginManager) {
64
79
  faceted: types.optional(facetedStateTreeF(), {}),
65
80
  })
66
81
  .volatile(() => ({
67
- favorites: [],
82
+ favorites: localStorageGetJSON(favoritesK(), '[]'),
68
83
  recentlyUsed: [],
69
84
  selection: [],
85
+ sortTrackNames: !!localStorageGetJSON(sortTrackNamesK(), 'false'),
86
+ sortCategories: !!localStorageGetJSON(sortCategoriesK(), 'false'),
87
+ collapsed: observable.map(),
70
88
  filterText: '',
71
89
  recentlyUsedCounter: 0,
72
90
  favoritesCounter: 0,
@@ -97,6 +115,13 @@ export default function stateTreeFactory(pluginManager) {
97
115
  get recentlyUsedSet() {
98
116
  return new Set(self.recentlyUsed);
99
117
  },
118
+ /**
119
+ * #getter
120
+ */
121
+ get assemblyNames() {
122
+ var _a;
123
+ return ((_a = self.view) === null || _a === void 0 ? void 0 : _a.assemblyNames) || [];
124
+ },
100
125
  }))
101
126
  .actions(self => ({
102
127
  /**
@@ -221,6 +246,12 @@ export default function stateTreeFactory(pluginManager) {
221
246
  expandAllCategories() {
222
247
  self.collapsed.clear();
223
248
  },
249
+ /**
250
+ * #action
251
+ */
252
+ setCollapsedCategories(str) {
253
+ self.collapsed.replace(str);
254
+ },
224
255
  /**
225
256
  * #action
226
257
  */
@@ -261,43 +292,17 @@ export default function stateTreeFactory(pluginManager) {
261
292
  const assembly = assemblyManager.get(assemblyName);
262
293
  const trackConf = assembly === null || assembly === void 0 ? void 0 : assembly.configuration.sequence;
263
294
  const viewType = pluginManager.getViewType(self.view.type);
264
- if (!trackConf) {
265
- return undefined;
266
- }
267
- for (const display of trackConf.displays) {
268
- if (viewType.displayTypes.some(d => d.name === display.type)) {
269
- return trackConf;
295
+ if (trackConf) {
296
+ for (const display of trackConf.displays) {
297
+ if (viewType.displayTypes.some(d => d.name === display.type)) {
298
+ return trackConf;
299
+ }
270
300
  }
271
301
  }
272
302
  return undefined;
273
303
  },
274
304
  }))
275
305
  .views(self => ({
276
- /**
277
- * #getter
278
- */
279
- get assemblyNames() {
280
- var _a;
281
- return ((_a = self.view) === null || _a === void 0 ? void 0 : _a.assemblyNames) || [];
282
- },
283
- }))
284
- .views(self => ({
285
- /**
286
- * #getter
287
- */
288
- get recentlyUsedLocalStorageKey() {
289
- return `recentlyUsedTracks-${[postF(), self.assemblyNames.join(',')]
290
- .filter(f => !!f)
291
- .join('-')}`;
292
- },
293
- /**
294
- * #getter
295
- */
296
- get favoritesLocalStorageKey() {
297
- // this has a extra } at the end because that's how it was initially
298
- // released
299
- return `favoriteTracks-${postF()}}`;
300
- },
301
306
  /**
302
307
  * #getter
303
308
  */
@@ -432,35 +437,6 @@ export default function stateTreeFactory(pluginManager) {
432
437
  self.setCategoryCollapsed(path, true);
433
438
  }
434
439
  },
435
- }))
436
- .actions(self => ({
437
- afterCreate() {
438
- if (!self.initialized) {
439
- const session = getSession(self);
440
- if (getConf(session, [
441
- 'hierarchical',
442
- 'defaultCollapsed',
443
- 'topLevelCategories',
444
- ])) {
445
- self.collapseTopLevelCategories();
446
- }
447
- if (getConf(session, [
448
- 'hierarchical',
449
- 'defaultCollapsed',
450
- 'subCategories',
451
- ])) {
452
- self.collapseSubCategories();
453
- }
454
- for (const entry of getConf(session, [
455
- 'hierarchical',
456
- 'defaultCollapsed',
457
- 'categoryNames',
458
- ])) {
459
- self.collapsed.set(entry, true);
460
- }
461
- self.initialized = true;
462
- }
463
- },
464
440
  }))
465
441
  .views(self => ({
466
442
  /**
@@ -474,13 +450,46 @@ export default function stateTreeFactory(pluginManager) {
474
450
  afterAttach() {
475
451
  // this should be the first autorun to properly initialize
476
452
  addDisposer(self, autorun(() => {
477
- self.setRecentlyUsed(JSON.parse(localStorageGetItem(self.recentlyUsedLocalStorageKey) || '[]'));
478
- self.setFavorites(JSON.parse(localStorageGetItem(self.favoritesLocalStorageKey) || '[]'));
453
+ const { assemblyNames, view } = self;
454
+ self.setRecentlyUsed(localStorageGetJSON(recentlyUsedK(assemblyNames), '[]'));
455
+ const val = localStorageGetItem(collapsedK(assemblyNames, view.type));
456
+ if (!val) {
457
+ self.expandAllCategories();
458
+ const session = getSession(self);
459
+ if (getConf(session, [
460
+ 'hierarchical',
461
+ 'defaultCollapsed',
462
+ 'topLevelCategories',
463
+ ])) {
464
+ self.collapseTopLevelCategories();
465
+ }
466
+ if (getConf(session, [
467
+ 'hierarchical',
468
+ 'defaultCollapsed',
469
+ 'subCategories',
470
+ ])) {
471
+ self.collapseSubCategories();
472
+ }
473
+ for (const entry of getConf(session, [
474
+ 'hierarchical',
475
+ 'defaultCollapsed',
476
+ 'categoryNames',
477
+ ])) {
478
+ self.setCategoryCollapsed(`Tracks-${entry}`, true);
479
+ }
480
+ }
481
+ else {
482
+ self.setCollapsedCategories(JSON.parse(val));
483
+ }
479
484
  }));
480
485
  // this should be the second autorun
481
486
  addDisposer(self, autorun(() => {
482
- localStorageSetItem(self.favoritesLocalStorageKey, JSON.stringify(self.favorites));
483
- localStorageSetItem(self.recentlyUsedLocalStorageKey, JSON.stringify(self.recentlyUsed));
487
+ const { assemblyNames, collapsed, view } = self;
488
+ localStorageSetJSON(recentlyUsedK(assemblyNames), self.recentlyUsed);
489
+ localStorageSetJSON(collapsedK(assemblyNames, view.type), collapsed);
490
+ localStorageSetJSON(favoritesK(), self.favorites);
491
+ localStorageSetJSON(sortTrackNamesK(), self.sortTrackNames);
492
+ localStorageSetJSON(sortCategoriesK(), self.sortCategories);
484
493
  }));
485
494
  },
486
495
  }));
@@ -7,6 +7,6 @@ interface Node {
7
7
  children: Node[];
8
8
  id: string;
9
9
  }
10
- export declare function findSubCategories(obj: Node[], paths: string[]): boolean;
10
+ export declare function findSubCategories(obj: Node[], paths: string[], depth?: number): boolean;
11
11
  export declare function findTopLevelCategories(obj: Node[], paths: string[]): void;
12
12
  export {};
@@ -21,12 +21,13 @@ export function matches(query, conf, session) {
21
21
  return (getTrackName(conf, session).toLowerCase().includes(queryLower) ||
22
22
  !!categories.filter(c => c.toLowerCase().includes(queryLower)).length);
23
23
  }
24
- export function findSubCategories(obj, paths) {
24
+ export function findSubCategories(obj, paths, depth = 0) {
25
25
  let hasSubs = false;
26
26
  for (const elt of obj) {
27
27
  if (elt.children.length) {
28
- const hasSubCategories = findSubCategories(elt.children, paths);
29
- if (hasSubCategories) {
28
+ const hasSubCategories = findSubCategories(elt.children, paths, depth + 1);
29
+ // avoid pushing the root "Tracks" node by checking depth>0
30
+ if (hasSubCategories && depth > 0) {
30
31
  paths.push(elt.id);
31
32
  }
32
33
  }
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function PluginStoreWidgetF(pluginManager: PluginManager): void;
@@ -3,7 +3,7 @@ import { WidgetType } from '@jbrowse/core/pluggableElementTypes';
3
3
  import { lazy } from 'react';
4
4
  import stateModelFactory from './model';
5
5
  const configSchema = ConfigurationSchema('PluginStoreWidget', {});
6
- export default (pluginManager) => {
6
+ export default function PluginStoreWidgetF(pluginManager) {
7
7
  pluginManager.addWidgetType(() => {
8
8
  return new WidgetType({
9
9
  name: 'PluginStoreWidget',
@@ -13,4 +13,4 @@ export default (pluginManager) => {
13
13
  ReactComponent: lazy(() => import('./components/PluginStoreWidget')),
14
14
  });
15
15
  });
16
- };
16
+ }
package/esm/index.d.ts CHANGED
@@ -5,7 +5,7 @@ declare const AssemblyManager: import("react").LazyExoticComponent<({ rootModel,
5
5
  rootModel: any;
6
6
  onClose: (arg: boolean) => void;
7
7
  }) => import("react").JSX.Element>;
8
- export default class extends Plugin {
8
+ export default class DataManagementPlugin extends Plugin {
9
9
  name: string;
10
10
  exports: {
11
11
  AssemblyManager: import("react").LazyExoticComponent<({ rootModel, onClose, }: {
package/esm/index.js CHANGED
@@ -6,7 +6,7 @@ import AddConnectionWidgetF from './AddConnectionWidget';
6
6
  import PluginStoreWidgetF from './PluginStoreWidget';
7
7
  import HierarchicalTrackSelectorWidgetF from './HierarchicalTrackSelectorWidget';
8
8
  const AssemblyManager = lazy(() => import('./AssemblyManager'));
9
- export default class extends Plugin {
9
+ export default class DataManagementPlugin extends Plugin {
10
10
  constructor() {
11
11
  super(...arguments);
12
12
  this.name = 'DataManagementPlugin';
@@ -1,3 +1,2 @@
1
1
  import PluginManager from '@jbrowse/core/PluginManager';
2
- declare const _default: (pluginManager: PluginManager) => void;
3
- export default _default;
2
+ export default function UCSCTrackHubConnectionF(pluginManager: PluginManager): void;
@@ -1,7 +1,7 @@
1
1
  import { ConnectionType } from '@jbrowse/core/pluggableElementTypes';
2
2
  import stateModelFactory from './model';
3
3
  import configSchema from './configSchema';
4
- export default (pluginManager) => {
4
+ export default function UCSCTrackHubConnectionF(pluginManager) {
5
5
  pluginManager.addConnectionType(() => new ConnectionType({
6
6
  name: 'UCSCTrackHubConnection',
7
7
  configSchema,
@@ -10,4 +10,4 @@ export default (pluginManager) => {
10
10
  description: 'A track or assembly hub in the Track Hub format',
11
11
  url: '//genome.ucsc.edu/goldenPath/help/hgTrackHubHelp.html#Intro',
12
12
  }));
13
- };
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-data-management",
3
- "version": "2.11.0",
3
+ "version": "2.11.1",
4
4
  "description": "JBrowse 2 linear genome view",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -60,5 +60,5 @@
60
60
  "distModule": "esm/index.js",
61
61
  "srcModule": "src/index.ts",
62
62
  "module": "esm/index.js",
63
- "gitHead": "3d43a820b9274a6160aa4dc15616147f390d9094"
63
+ "gitHead": "11b28d66d782eb06f92ccb993108bb6c3c82819e"
64
64
  }