@jbrowse/core 3.5.0 → 3.5.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.
@@ -53,7 +53,7 @@ function DataGridDetails({ value, prefix, name, }) {
53
53
  if (unionKeys.size < keys.length + 5) {
54
54
  return ((0, jsx_runtime_1.jsxs)("div", { className: classes.margin, children: [(0, jsx_runtime_1.jsx)(FieldName_1.default, { prefix: prefix, name: name }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Checkbox, { checked: checked, onChange: event => {
55
55
  setChecked(event.target.checked);
56
- } }), label: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: "Show options" }) }), (0, jsx_runtime_1.jsx)(DataGridFlexContainer_1.default, { children: (0, jsx_runtime_1.jsx)(x_data_grid_1.DataGrid, { rows: rows, rowHeight: 20, columnHeaderHeight: 35, hideFooter: rows.length < 25, showToolbar: checked, columns: colNames.map((val, index) => ({
56
+ } }), label: (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", children: "Show options" }) }), (0, jsx_runtime_1.jsx)(DataGridFlexContainer_1.default, { children: (0, jsx_runtime_1.jsx)(x_data_grid_1.DataGrid, { disableRowSelectionOnClick: true, rows: rows, rowHeight: 20, columnHeaderHeight: 35, hideFooter: rows.length < 25, showToolbar: checked, columns: colNames.map((val, index) => ({
57
57
  field: val,
58
58
  width: widths[index],
59
59
  renderCell: ({ value }) => ((0, jsx_runtime_1.jsx)("div", { className: classes.cell, children: (0, jsx_runtime_1.jsx)(ui_1.SanitizedHTML, { html: (0, util_1.getStr)(value || '') }) })),
@@ -0,0 +1,7 @@
1
+ export default class PhasedScheduler<PhaseName extends string> {
2
+ phaseCallbacks: Map<PhaseName, Function[]>;
3
+ phaseOrder: PhaseName[];
4
+ constructor(...phaseOrder: PhaseName[]);
5
+ add(phase: PhaseName, callback: Function): void;
6
+ run(): void;
7
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class PhasedScheduler {
4
+ constructor(...phaseOrder) {
5
+ this.phaseCallbacks = new Map();
6
+ this.phaseOrder = [];
7
+ this.phaseOrder = phaseOrder;
8
+ }
9
+ add(phase, callback) {
10
+ if (!this.phaseOrder.includes(phase)) {
11
+ throw new Error(`unknown phase ${phase}`);
12
+ }
13
+ let phaseCallbacks = this.phaseCallbacks.get(phase);
14
+ if (!phaseCallbacks) {
15
+ phaseCallbacks = [];
16
+ this.phaseCallbacks.set(phase, phaseCallbacks);
17
+ }
18
+ phaseCallbacks.push(callback);
19
+ }
20
+ run() {
21
+ for (const phaseName of this.phaseOrder) {
22
+ for (const callback of this.phaseCallbacks.get(phaseName) || []) {
23
+ callback();
24
+ }
25
+ }
26
+ }
27
+ }
28
+ exports.default = PhasedScheduler;
package/Plugin.d.ts CHANGED
@@ -7,5 +7,7 @@ export default abstract class Plugin {
7
7
  install(_pluginManager: PluginManager): void;
8
8
  configure(_pluginManager: PluginManager): void;
9
9
  configurationSchema?: AnyConfigurationSchemaType;
10
+ configurationSchemaUnnamespaced?: AnyConfigurationSchemaType;
11
+ rootConfigurationSchema?: (arg: PluginManager) => AnyConfigurationSchemaType;
10
12
  }
11
13
  export type PluginConstructor = new (...args: unknown[]) => Plugin;
@@ -1,3 +1,4 @@
1
+ import PhasedScheduler from './PhasedScheduler';
1
2
  import ReExports from './ReExports';
2
3
  import AdapterType from './pluggableElementTypes/AdapterType';
3
4
  import AddTrackWorkflowType from './pluggableElementTypes/AddTrackWorkflowType';
@@ -16,13 +17,6 @@ import type { PluggableElementMember, PluggableElementType } from './pluggableEl
16
17
  import type PluggableElementBase from './pluggableElementTypes/PluggableElementBase';
17
18
  import type { AbstractRootModel } from './util';
18
19
  import type { IAnyModelType, IAnyType } from 'mobx-state-tree';
19
- declare class PhasedScheduler<PhaseName extends string> {
20
- phaseCallbacks: Map<PhaseName, Function[]>;
21
- phaseOrder: PhaseName[];
22
- constructor(...phaseOrder: PhaseName[]);
23
- add(phase: PhaseName, callback: Function): void;
24
- run(): void;
25
- }
26
20
  type PluggableElementTypeGroup = 'renderer' | 'adapter' | 'display' | 'track' | 'connection' | 'view' | 'widget' | 'rpc method' | 'internet account' | 'text search adapter' | 'add track workflow';
27
21
  declare class TypeRecord<ElementClass extends PluggableElementBase> {
28
22
  typeName: string;
@@ -87,7 +81,9 @@ export default class PluginManager {
87
81
  rootModel?: AbstractRootModel;
88
82
  extensionPoints: Map<string, Function[]>;
89
83
  constructor(initialPlugins?: (Plugin | PluginLoadRecord)[]);
90
- pluginConfigurationSchemas(): Record<string, unknown>;
84
+ pluginConfigurationNamespacedSchemas(): Record<string, unknown>;
85
+ pluginConfigurationUnnamespacedSchemas(): Record<string, unknown>;
86
+ pluginConfigurationRootSchemas(): Record<string, unknown>;
91
87
  addPlugin(load: Plugin | PluginLoadRecord | RuntimePluginLoadRecord): this;
92
88
  getPlugin(name: string): Plugin | undefined;
93
89
  hasPlugin(name: string): boolean;
package/PluginManager.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const mobx_state_tree_1 = require("mobx-state-tree");
7
7
  const CorePlugin_1 = __importDefault(require("./CorePlugin"));
8
+ const PhasedScheduler_1 = __importDefault(require("./PhasedScheduler"));
8
9
  const ReExports_1 = __importDefault(require("./ReExports"));
9
10
  const configuration_1 = require("./configuration");
10
11
  const AdapterType_1 = __importDefault(require("./pluggableElementTypes/AdapterType"));
@@ -19,31 +20,6 @@ const ViewType_1 = __importDefault(require("./pluggableElementTypes/ViewType"));
19
20
  const WidgetType_1 = __importDefault(require("./pluggableElementTypes/WidgetType"));
20
21
  const RendererType_1 = __importDefault(require("./pluggableElementTypes/renderers/RendererType"));
21
22
  const jexl_1 = __importDefault(require("./util/jexl"));
22
- class PhasedScheduler {
23
- constructor(...phaseOrder) {
24
- this.phaseCallbacks = new Map();
25
- this.phaseOrder = [];
26
- this.phaseOrder = phaseOrder;
27
- }
28
- add(phase, callback) {
29
- if (!this.phaseOrder.includes(phase)) {
30
- throw new Error(`unknown phase ${phase}`);
31
- }
32
- let phaseCallbacks = this.phaseCallbacks.get(phase);
33
- if (!phaseCallbacks) {
34
- phaseCallbacks = [];
35
- this.phaseCallbacks.set(phase, phaseCallbacks);
36
- }
37
- phaseCallbacks.push(callback);
38
- }
39
- run() {
40
- for (const phaseName of this.phaseOrder) {
41
- for (const callback of this.phaseCallbacks.get(phaseName) || []) {
42
- callback();
43
- }
44
- }
45
- }
46
- }
47
23
  class TypeRecord {
48
24
  constructor(typeName, baseClass) {
49
25
  this.typeName = typeName;
@@ -72,7 +48,7 @@ class PluginManager {
72
48
  this.jexl = (0, jexl_1.default)();
73
49
  this.pluginMetadata = {};
74
50
  this.runtimePluginDefinitions = [];
75
- this.elementCreationSchedule = new PhasedScheduler('renderer', 'adapter', 'text search adapter', 'display', 'track', 'connection', 'view', 'widget', 'rpc method', 'internet account', 'add track workflow');
51
+ this.elementCreationSchedule = new PhasedScheduler_1.default('renderer', 'adapter', 'text search adapter', 'display', 'track', 'connection', 'view', 'widget', 'rpc method', 'internet account', 'add track workflow');
76
52
  this.rendererTypes = new TypeRecord('RendererType', RendererType_1.default);
77
53
  this.adapterTypes = new TypeRecord('AdapterType', AdapterType_1.default);
78
54
  this.textSearchAdapterTypes = new TypeRecord('TextSearchAdapterType', TextSearchAdapterType_1.default);
@@ -121,7 +97,7 @@ class PluginManager {
121
97
  this.addPlugin(plugin);
122
98
  }
123
99
  }
124
- pluginConfigurationSchemas() {
100
+ pluginConfigurationNamespacedSchemas() {
125
101
  const configurationSchemas = {};
126
102
  for (const plugin of this.plugins) {
127
103
  if (plugin.configurationSchema) {
@@ -130,6 +106,30 @@ class PluginManager {
130
106
  }
131
107
  return configurationSchemas;
132
108
  }
109
+ pluginConfigurationUnnamespacedSchemas() {
110
+ let configurationSchemas = {};
111
+ for (const plugin of this.plugins) {
112
+ if (plugin.configurationSchemaUnnamespaced) {
113
+ configurationSchemas = {
114
+ ...configurationSchemas,
115
+ ...plugin.configurationSchemaUnnamespaced,
116
+ };
117
+ }
118
+ }
119
+ return configurationSchemas;
120
+ }
121
+ pluginConfigurationRootSchemas() {
122
+ let configurationSchemas = {};
123
+ for (const plugin of this.plugins) {
124
+ if (plugin.rootConfigurationSchema) {
125
+ configurationSchemas = {
126
+ ...configurationSchemas,
127
+ ...plugin.rootConfigurationSchema(this),
128
+ };
129
+ }
130
+ }
131
+ return configurationSchemas;
132
+ }
133
133
  addPlugin(load) {
134
134
  if (this.configured) {
135
135
  throw new Error('JBrowse already configured, cannot add plugins');
@@ -22,16 +22,18 @@ export default function assemblyFactory(assemblyConfigType: IAnyType, pluginMana
22
22
  loadingP: Promise<void> | undefined;
23
23
  volatileRegions: BasicRegion[] | undefined;
24
24
  refNameAliases: RefNameAliases | undefined;
25
- lowerCaseRefNameAliases: RefNameAliases | undefined;
26
25
  cytobands: Feature[] | undefined;
27
26
  } & {
28
27
  getConf(arg: string): any;
28
+ readonly lowerCaseRefNameAliases: {
29
+ [k: string]: string;
30
+ } | undefined;
29
31
  } & {
30
32
  readonly initialized: boolean;
31
33
  readonly name: string;
32
34
  readonly regions: BasicRegion[] | undefined;
33
35
  readonly aliases: string[];
34
- readonly displayName: string | undefined;
36
+ readonly displayName: string;
35
37
  hasName(name: string): boolean;
36
38
  readonly allAliases: string[];
37
39
  readonly allRefNames: string[] | undefined;
@@ -46,15 +48,14 @@ export default function assemblyFactory(assemblyConfigType: IAnyType, pluginMana
46
48
  getRefNameColor(refName: string): string | undefined;
47
49
  isValidRefName(refName: string): boolean;
48
50
  } & {
49
- setLoaded({ regions, refNameAliases, lowerCaseRefNameAliases, cytobands, }: {
51
+ setLoaded({ regions, refNameAliases, cytobands, }: {
50
52
  regions: Region[];
51
53
  refNameAliases: RefNameAliases;
52
- lowerCaseRefNameAliases: RefNameAliases;
53
54
  cytobands: Feature[];
54
55
  }): void;
55
56
  setError(e: unknown): void;
56
57
  setRegions(regions: Region[]): void;
57
- setRefNameAliases(aliases: RefNameAliases, lowerCaseAliases: RefNameAliases): void;
58
+ setRefNameAliases(aliases: RefNameAliases): void;
58
59
  setCytobands(cytobands: Feature[]): void;
59
60
  setLoadingP(p?: Promise<void>): void;
60
61
  load(): Promise<void>;
@@ -63,6 +64,7 @@ export default function assemblyFactory(assemblyConfigType: IAnyType, pluginMana
63
64
  getAdapterMapEntry(adapterConf: AdapterConf, options: BaseOptions): Promise<RefNameMap>;
64
65
  getRefNameMapForAdapter(adapterConf: AdapterConf, opts: BaseOptions): Promise<RefNameAliases>;
65
66
  getReverseRefNameMapForAdapter(adapterConf: AdapterConf, opts: BaseOptions): Promise<RefNameAliases>;
67
+ afterCreate(): void;
66
68
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
67
69
  export type AssemblyModel = ReturnType<typeof assemblyFactory>;
68
70
  export type Assembly = Instance<AssemblyModel>;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = assemblyFactory;
7
7
  const abortable_promise_cache_1 = __importDefault(require("@gmod/abortable-promise-cache"));
8
+ const mobx_1 = require("mobx");
8
9
  const mobx_state_tree_1 = require("mobx-state-tree");
9
10
  const configuration_1 = require("../configuration");
10
11
  const util_1 = require("../data_adapters/util");
@@ -87,13 +88,19 @@ function assemblyFactory(assemblyConfigType, pluginManager) {
87
88
  loadingP: undefined,
88
89
  volatileRegions: undefined,
89
90
  refNameAliases: undefined,
90
- lowerCaseRefNameAliases: undefined,
91
91
  cytobands: undefined,
92
92
  }))
93
93
  .views(self => ({
94
94
  getConf(arg) {
95
95
  return self.configuration ? (0, configuration_1.getConf)(self, arg) : undefined;
96
96
  },
97
+ get lowerCaseRefNameAliases() {
98
+ return self.refNameAliases
99
+ ? Object.fromEntries(Object.entries(self.refNameAliases).map(([key, val]) => {
100
+ return [key.toLowerCase(), val];
101
+ }))
102
+ : undefined;
103
+ },
97
104
  }))
98
105
  .views(self => ({
99
106
  get initialized() {
@@ -172,9 +179,9 @@ function assemblyFactory(assemblyConfigType, pluginManager) {
172
179
  },
173
180
  }))
174
181
  .actions(self => ({
175
- setLoaded({ regions, refNameAliases, lowerCaseRefNameAliases, cytobands, }) {
182
+ setLoaded({ regions, refNameAliases, cytobands, }) {
176
183
  this.setRegions(regions);
177
- this.setRefNameAliases(refNameAliases, lowerCaseRefNameAliases);
184
+ this.setRefNameAliases(refNameAliases);
178
185
  this.setCytobands(cytobands);
179
186
  },
180
187
  setError(e) {
@@ -183,9 +190,8 @@ function assemblyFactory(assemblyConfigType, pluginManager) {
183
190
  setRegions(regions) {
184
191
  self.volatileRegions = regions;
185
192
  },
186
- setRefNameAliases(aliases, lowerCaseAliases) {
193
+ setRefNameAliases(aliases) {
187
194
  self.refNameAliases = aliases;
188
- self.lowerCaseRefNameAliases = lowerCaseAliases;
189
195
  },
190
196
  setCytobands(cytobands) {
191
197
  self.cytobands = cytobands;
@@ -214,10 +220,9 @@ function assemblyFactory(assemblyConfigType, pluginManager) {
214
220
  config: sequenceAdapterConf,
215
221
  pluginManager,
216
222
  });
217
- const adapterRegionsWithAssembly = regions.map(r => {
223
+ for (const r of regions) {
218
224
  checkRefName(r.refName);
219
- return { ...r, assemblyName };
220
- });
225
+ }
221
226
  const refNameAliases = {};
222
227
  const refNameAliasCollection = await getRefNameAliases({
223
228
  config: refNameAliasesAdapterConf,
@@ -232,20 +237,16 @@ function assemblyFactory(assemblyConfigType, pluginManager) {
232
237
  refNameAliases[refName] = refName;
233
238
  }
234
239
  }
235
- for (const region of adapterRegionsWithAssembly) {
240
+ for (const region of regions) {
236
241
  refNameAliases[_c = region.refName] || (refNameAliases[_c] = region.refName);
237
242
  }
238
- const lowerCaseRefNameAliases = Object.fromEntries(Object.entries(refNameAliases).map(([key, val]) => [
239
- key.toLowerCase(),
240
- val,
241
- ]));
242
243
  this.setLoaded({
243
244
  refNameAliases,
244
- regions: adapterRegionsWithAssembly.map(r => ({
245
+ regions: regions.map(r => ({
245
246
  ...r,
246
247
  refName: refNameAliases[r.refName] || r.refName,
248
+ assemblyName,
247
249
  })),
248
- lowerCaseRefNameAliases,
249
250
  cytobands: await getCytobands({
250
251
  config: cytobandAdapterConf,
251
252
  pluginManager,
@@ -276,6 +277,11 @@ function assemblyFactory(assemblyConfigType, pluginManager) {
276
277
  const map = await this.getAdapterMapEntry(adapterConf, opts);
277
278
  return map.reverseMap;
278
279
  },
280
+ afterCreate() {
281
+ (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
282
+ self.allRefNamesWithLowerCase;
283
+ }));
284
+ },
279
285
  }));
280
286
  }
281
287
  async function getRefNameAliases({ config, pluginManager, stopToken, }) {