@jbrowse/core 2.8.0 → 2.10.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.
@@ -57,8 +57,8 @@ function DataGridDetails({ value, prefix, name, }) {
57
57
  const rows = Object.entries(value).map(([k, val]) => {
58
58
  const { id, ...rest } = val;
59
59
  return {
60
- id: k,
61
- identifier: id,
60
+ id: k, // used by material UI
61
+ identifier: id, // renamed from id to identifier
62
62
  ...rest,
63
63
  };
64
64
  });
@@ -125,6 +125,7 @@ const BaseAttributes = (props) => {
125
125
  exports.BaseAttributes = BaseAttributes;
126
126
  function FeatureDetails(props) {
127
127
  const { omit = [], model, feature, depth = 0 } = props;
128
+ const { maxDepth } = model;
128
129
  const { mate, name = '', id = '', type = '', subfeatures, uniqueId } = feature;
129
130
  const pm = (0, util_1.getEnv)(model).pluginManager;
130
131
  const session = (0, util_1.getSession)(model);
@@ -149,7 +150,7 @@ function FeatureDetails(props) {
149
150
  react_1.default.createElement(material_1.Divider, null),
150
151
  react_1.default.createElement(BaseCard, { title: ExtraPanel.name },
151
152
  react_1.default.createElement(ExtraPanel.Component, { ...props })))) : null,
152
- (subfeatures === null || subfeatures === void 0 ? void 0 : subfeatures.length) ? (react_1.default.createElement(BaseCard, { title: "Subfeatures", defaultExpanded: depth < 1 }, subfeatures.map((sub, idx) => (react_1.default.createElement(FeatureDetails, { key: JSON.stringify(sub), feature: { ...sub, uniqueId: `${uniqueId}_${idx}` }, model: model, depth: depth + 1 }))))) : null));
153
+ depth < maxDepth && (subfeatures === null || subfeatures === void 0 ? void 0 : subfeatures.length) ? (react_1.default.createElement(BaseCard, { title: "Subfeatures", defaultExpanded: depth < 1 }, subfeatures.map((sub, idx) => (react_1.default.createElement(FeatureDetails, { key: JSON.stringify(sub), feature: { ...sub, uniqueId: `${uniqueId}_${idx}` }, model: model, depth: depth + 1 }))))) : null));
153
154
  }
154
155
  exports.FeatureDetails = FeatureDetails;
155
156
  const BaseFeatureDetail = (0, mobx_react_1.observer)(function ({ model }) {
@@ -1,35 +1,119 @@
1
1
  import PluginManager from '../PluginManager';
2
2
  declare const configSchema: import("../configuration/configurationSchema").ConfigurationSchemaType<{}, import("../configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
3
+ /**
4
+ * #stateModel BaseFeatureWidget
5
+ * displays data about features, allowing configuration callbacks to modify the
6
+ * contents of what is displayed
7
+ *
8
+ * see: formatDetails-\>feature,formatDetails-\>subfeatures
9
+ */
3
10
  export default function stateModelFactory(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
11
+ /**
12
+ * #property
13
+ */
4
14
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
15
+ /**
16
+ * #property
17
+ */
5
18
  type: import("mobx-state-tree").ISimpleType<"BaseFeatureWidget">;
19
+ /**
20
+ * #property
21
+ */
6
22
  featureData: import("mobx-state-tree").IType<any, any, any>;
23
+ /**
24
+ * #property
25
+ */
7
26
  formattedFields: import("mobx-state-tree").IType<any, any, any>;
27
+ /**
28
+ * #property
29
+ */
8
30
  unformattedFeatureData: import("mobx-state-tree").IType<any, any, any>;
31
+ /**
32
+ * #property
33
+ */
9
34
  view: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IReferenceType<import("mobx-state-tree").IAnyType>>;
35
+ /**
36
+ * #property
37
+ */
10
38
  track: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IReferenceType<import("mobx-state-tree").IAnyType>>;
39
+ /**
40
+ * #property
41
+ */
11
42
  trackId: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
43
+ /**
44
+ * #property
45
+ */
12
46
  trackType: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
47
+ /**
48
+ * #property
49
+ */
50
+ maxDepth: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<number>>;
13
51
  }, {
14
52
  error: unknown;
15
53
  } & {
54
+ /**
55
+ * #action
56
+ */
16
57
  setFeatureData(featureData: Record<string, unknown>): void;
58
+ /**
59
+ * #action
60
+ */
17
61
  clearFeatureData(): void;
62
+ /**
63
+ * #action
64
+ */
18
65
  setFormattedData(feat: Record<string, unknown>): void;
19
- setExtra(type?: string, trackId?: string): void;
66
+ /**
67
+ * #action
68
+ */
69
+ setExtra(type?: string, trackId?: string, maxDepth?: number): void;
70
+ /**
71
+ * #action
72
+ */
20
73
  setError(e: unknown): void;
21
74
  } & {
22
75
  afterCreate(): void;
23
76
  }, import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<{
77
+ /**
78
+ * #property
79
+ */
24
80
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
81
+ /**
82
+ * #property
83
+ */
25
84
  type: import("mobx-state-tree").ISimpleType<"BaseFeatureWidget">;
85
+ /**
86
+ * #property
87
+ */
26
88
  featureData: import("mobx-state-tree").IType<any, any, any>;
89
+ /**
90
+ * #property
91
+ */
27
92
  formattedFields: import("mobx-state-tree").IType<any, any, any>;
93
+ /**
94
+ * #property
95
+ */
28
96
  unformattedFeatureData: import("mobx-state-tree").IType<any, any, any>;
97
+ /**
98
+ * #property
99
+ */
29
100
  view: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IReferenceType<import("mobx-state-tree").IAnyType>>;
101
+ /**
102
+ * #property
103
+ */
30
104
  track: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IReferenceType<import("mobx-state-tree").IAnyType>>;
105
+ /**
106
+ * #property
107
+ */
31
108
  trackId: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
109
+ /**
110
+ * #property
111
+ */
32
112
  trackType: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
113
+ /**
114
+ * #property
115
+ */
116
+ maxDepth: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<number>>;
33
117
  }>>, {
34
118
  type: "BaseFeatureWidget";
35
119
  id: string;
@@ -37,6 +121,7 @@ export default function stateModelFactory(pluginManager: PluginManager): import(
37
121
  view: import("mobx-state-tree").ReferenceIdentifier | undefined;
38
122
  trackId: string | undefined;
39
123
  trackType: string | undefined;
124
+ maxDepth: number | undefined;
40
125
  formattedFields: any;
41
126
  finalizedFeatureData: any;
42
127
  }>;
@@ -15,44 +15,97 @@ exports.configSchema = configSchema;
15
15
  function formatSubfeatures(obj, depth, parse, currentDepth = 0, returnObj = {}) {
16
16
  var _a;
17
17
  if (depth <= currentDepth) {
18
- return returnObj;
18
+ return;
19
19
  }
20
- returnObj.subfeatures = (_a = obj.subfeatures) === null || _a === void 0 ? void 0 : _a.map(sub => {
20
+ (_a = obj.subfeatures) === null || _a === void 0 ? void 0 : _a.map(sub => {
21
21
  formatSubfeatures(sub, depth, parse, currentDepth + 1, returnObj);
22
- return parse(sub);
22
+ parse(sub);
23
23
  });
24
- return returnObj;
25
24
  }
25
+ /**
26
+ * #stateModel BaseFeatureWidget
27
+ * displays data about features, allowing configuration callbacks to modify the
28
+ * contents of what is displayed
29
+ *
30
+ * see: formatDetails-\>feature,formatDetails-\>subfeatures
31
+ */
26
32
  function stateModelFactory(pluginManager) {
27
33
  return mobx_state_tree_1.types
28
34
  .model('BaseFeatureWidget', {
35
+ /**
36
+ * #property
37
+ */
29
38
  id: mst_1.ElementId,
39
+ /**
40
+ * #property
41
+ */
30
42
  type: mobx_state_tree_1.types.literal('BaseFeatureWidget'),
43
+ /**
44
+ * #property
45
+ */
31
46
  featureData: mobx_state_tree_1.types.frozen(),
47
+ /**
48
+ * #property
49
+ */
32
50
  formattedFields: mobx_state_tree_1.types.frozen(),
51
+ /**
52
+ * #property
53
+ */
33
54
  unformattedFeatureData: mobx_state_tree_1.types.frozen(),
55
+ /**
56
+ * #property
57
+ */
34
58
  view: mobx_state_tree_1.types.safeReference(pluginManager.pluggableMstType('view', 'stateModel')),
59
+ /**
60
+ * #property
61
+ */
35
62
  track: mobx_state_tree_1.types.safeReference(pluginManager.pluggableMstType('track', 'stateModel')),
63
+ /**
64
+ * #property
65
+ */
36
66
  trackId: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.string),
67
+ /**
68
+ * #property
69
+ */
37
70
  trackType: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.string),
71
+ /**
72
+ * #property
73
+ */
74
+ maxDepth: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.number),
38
75
  })
39
76
  .volatile(() => ({
40
77
  error: undefined,
41
78
  }))
42
79
  .actions(self => ({
80
+ /**
81
+ * #action
82
+ */
43
83
  setFeatureData(featureData) {
44
84
  self.unformattedFeatureData = featureData;
45
85
  },
86
+ /**
87
+ * #action
88
+ */
46
89
  clearFeatureData() {
47
90
  self.featureData = undefined;
48
91
  },
92
+ /**
93
+ * #action
94
+ */
49
95
  setFormattedData(feat) {
50
96
  self.featureData = feat;
51
97
  },
52
- setExtra(type, trackId) {
98
+ /**
99
+ * #action
100
+ */
101
+ setExtra(type, trackId, maxDepth) {
53
102
  self.trackId = trackId;
54
103
  self.trackType = type;
104
+ self.maxDepth = maxDepth;
55
105
  },
106
+ /**
107
+ * #action
108
+ */
56
109
  setError(e) {
57
110
  self.error = e;
58
111
  },
@@ -60,11 +113,12 @@ function stateModelFactory(pluginManager) {
60
113
  .actions(self => ({
61
114
  afterCreate() {
62
115
  (0, mobx_state_tree_1.addDisposer)(self, (0, mobx_1.autorun)(() => {
63
- var _a, _b;
64
116
  try {
65
- self.setExtra((_a = self.track) === null || _a === void 0 ? void 0 : _a.type, (_b = self.track) === null || _b === void 0 ? void 0 : _b.configuration.trackId);
66
117
  const { unformattedFeatureData, track } = self;
67
118
  const session = (0, util_1.getSession)(self);
119
+ if (track) {
120
+ self.setExtra(track.type, track.configuration.trackId, (0, configuration_1.getConf)(track, ['formatDetails', 'maxDepth']));
121
+ }
68
122
  if (unformattedFeatureData) {
69
123
  const feature = (0, clone_1.default)(unformattedFeatureData);
70
124
  const combine = (arg2, feature) => ({
@@ -74,8 +128,7 @@ function stateModelFactory(pluginManager) {
74
128
  if (track) {
75
129
  // eslint-disable-next-line no-underscore-dangle
76
130
  feature.__jbrowsefmt = combine('feature', feature);
77
- const depth = (0, configuration_1.getConf)(track, ['formatDetails', 'depth']);
78
- formatSubfeatures(feature, depth, sub => {
131
+ formatSubfeatures(feature, (0, configuration_1.getConf)(track, ['formatDetails', 'depth']), sub => {
79
132
  // eslint-disable-next-line no-underscore-dangle
80
133
  sub.__jbrowsefmt = combine('subfeatures', sub);
81
134
  });
@@ -60,7 +60,26 @@ export interface RuntimePluginLoadRecord extends PluginLoadRecord {
60
60
  }
61
61
  export default class PluginManager {
62
62
  plugins: Plugin[];
63
- jexl: any;
63
+ jexl: {
64
+ addBinaryOp: (operator: string, precedence: number, fn: (left: any, right: any) => any) => void;
65
+ addUnaryOp: (operator: string, fn: (right: any) => any) => void;
66
+ addTransform: (name: string, fn: (value: any, ...args: any[]) => any) => void;
67
+ addTransforms: (map: {
68
+ [key: string]: (value: any, ...args: any[]) => any;
69
+ }) => void;
70
+ getTransform: (name: string) => (value: any, ...args: any[]) => any;
71
+ addFunction: (name: string, fn: (value: any, ...args: any[]) => any) => void;
72
+ addFunctions: (map: {
73
+ [key: string]: (value: any, ...args: any[]) => any;
74
+ }) => void;
75
+ getFunction: (name: string) => (value: any, ...args: any[]) => any;
76
+ eval: (expression: string, context?: import("jexl/Expression").Context | undefined) => Promise<any>;
77
+ evalSync: (expression: string, context?: import("jexl/Expression").Context | undefined) => any;
78
+ compile: (expression: string) => import("jexl/Expression").default;
79
+ createExpression: (expression: string) => import("jexl/Expression").default;
80
+ removeOp: (operator: string) => void;
81
+ _grammar: import("jexl/Grammar").default;
82
+ };
64
83
  pluginMetadata: Record<string, PluginMetadata>;
65
84
  runtimePluginDefinitions: PluginDefinition[];
66
85
  elementCreationSchedule: PhasedScheduler<PluggableElementTypeGroup> | undefined;
package/PluginManager.js CHANGED
@@ -71,7 +71,6 @@ class TypeRecord {
71
71
  class PluginManager {
72
72
  constructor(initialPlugins = []) {
73
73
  this.plugins = [];
74
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
74
  this.jexl = (0, jexl_1.default)();
76
75
  this.pluginMetadata = {};
77
76
  this.runtimePluginDefinitions = [];
@@ -3,6 +3,7 @@ import { BaseOptions } from '../data_adapters/BaseAdapter';
3
3
  import PluginManager from '../PluginManager';
4
4
  import { Region, Feature } from '../util';
5
5
  import RpcManager from '../rpc/RpcManager';
6
+ type AdapterConf = Record<string, unknown>;
6
7
  type RefNameAliases = Record<string, string | undefined>;
7
8
  export interface RefNameMap {
8
9
  forwardMap: RefNameAliases;
@@ -145,17 +146,17 @@ export default function assemblyFactory(assemblyConfigType: IAnyType, pm: Plugin
145
146
  /**
146
147
  * #method
147
148
  */
148
- getAdapterMapEntry(adapterConf: unknown, options: BaseOptions): Promise<RefNameMap>;
149
+ getAdapterMapEntry(adapterConf: AdapterConf, options: BaseOptions): Promise<RefNameMap>;
149
150
  /**
150
151
  * #method
151
152
  * get Map of `canonical-name -> adapter-specific-name`
152
153
  */
153
- getRefNameMapForAdapter(adapterConf: unknown, opts: BaseOptions): Promise<RefNameAliases>;
154
+ getRefNameMapForAdapter(adapterConf: AdapterConf, opts: BaseOptions): Promise<RefNameAliases>;
154
155
  /**
155
156
  * #method
156
157
  * get Map of `adapter-specific-name -> canonical-name`
157
158
  */
158
- getReverseRefNameMapForAdapter(adapterConf: unknown, opts: BaseOptions): Promise<RefNameAliases>;
159
+ getReverseRefNameMapForAdapter(adapterConf: AdapterConf, opts: BaseOptions): Promise<RefNameAliases>;
159
160
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
160
161
  export type AssemblyModel = ReturnType<typeof assemblyFactory>;
161
162
  export type Assembly = Instance<AssemblyModel>;
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const mobx_state_tree_1 = require("mobx-state-tree");
7
- const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
8
7
  const abortable_promise_cache_1 = __importDefault(require("abortable-promise-cache"));
9
8
  // locals
10
9
  const configuration_1 = require("../configuration");
11
10
  const util_1 = require("../util");
12
11
  const QuickLRU_1 = __importDefault(require("../util/QuickLRU"));
12
+ const dataAdapterCache_1 = require("../data_adapters/dataAdapterCache");
13
13
  const refNameRegex = new RegExp('[0-9A-Za-z!#$%&+./:;?@^_|~-][0-9A-Za-z!#$%&*+./:;=?@^_|~-]*');
14
14
  // Based on the UCSC Genome Browser chromosome color palette:
15
15
  // https://github.com/ucscGenomeBrowser/kent/blob/a50ed53aff81d6fb3e34e6913ce18578292bc24e/src/hg/inc/chromColors.h
@@ -22,25 +22,25 @@ const refNameColors = [
22
22
  'rgb(204, 0, 0)',
23
23
  'rgb(255, 0, 0)',
24
24
  'rgb(255, 0, 204)',
25
- 'rgb(165, 132, 132)',
26
- 'rgb(204, 122, 0)',
27
- 'rgb(178, 142, 0)',
28
- 'rgb(153, 153, 0)',
29
- 'rgb(122, 153, 0)',
30
- 'rgb(0, 165, 0)',
25
+ 'rgb(165, 132, 132)', // originally 'rgb(255, 204, 204)'
26
+ 'rgb(204, 122, 0)', // originally rgb(255, 153, 0)'
27
+ 'rgb(178, 142, 0)', // originally 'rgb(255, 204, 0)'
28
+ 'rgb(153, 153, 0)', // originally 'rgb(255, 255, 0)'
29
+ 'rgb(122, 153, 0)', // originally 'rgb(204, 255, 0)'
30
+ 'rgb(0, 165, 0)', // originally 'rgb(0, 255, 0)'
31
31
  'rgb(53, 128, 0)',
32
32
  'rgb(0, 0, 204)',
33
- 'rgb(96, 145, 242)',
34
- 'rgb(107, 142, 178)',
35
- 'rgb(0, 165, 165)',
36
- 'rgb(122, 153, 153)',
33
+ 'rgb(96, 145, 242)', // originally 'rgb(102, 153, 255)'
34
+ 'rgb(107, 142, 178)', // originally 'rgb(153, 204, 255)'
35
+ 'rgb(0, 165, 165)', // originally 'rgb(0, 255, 255)'
36
+ 'rgb(122, 153, 153)', // originally 'rgb(204, 255, 255)'
37
37
  'rgb(153, 0, 204)',
38
38
  'rgb(204, 51, 255)',
39
- 'rgb(173, 130, 216)',
39
+ 'rgb(173, 130, 216)', // originally 'rgb(204, 153, 255)'
40
40
  'rgb(102, 102, 102)',
41
- 'rgb(145, 145, 145)',
42
- 'rgb(142, 142, 142)',
43
- 'rgb(142, 142, 107)',
41
+ 'rgb(145, 145, 145)', // originally 'rgb(153, 153, 153)'
42
+ 'rgb(142, 142, 142)', // originally 'rgb(204, 204, 204)'
43
+ 'rgb(142, 142, 107)', // originally 'rgb(204, 204, 153)'
44
44
  'rgb(96, 163, 48)', // originally 'rgb(121, 204, 61)'
45
45
  ];
46
46
  async function loadRefNameMap(assembly, adapterConfig, options, signal) {
@@ -78,9 +78,6 @@ function checkRefName(refName) {
78
78
  throw new Error(`Encountered invalid refName: "${refName}"`);
79
79
  }
80
80
  }
81
- function getAdapterId(adapterConf) {
82
- return (0, json_stable_stringify_1.default)(adapterConf);
83
- }
84
81
  /**
85
82
  * #stateModel Assembly
86
83
  */
@@ -348,8 +345,7 @@ function assemblyFactory(assemblyConfigType, pm) {
348
345
  if (!options.sessionId) {
349
346
  throw new Error('sessionId is required');
350
347
  }
351
- const adapterId = getAdapterId(adapterConf);
352
- return adapterLoads.get(adapterId, {
348
+ return adapterLoads.get((0, dataAdapterCache_1.adapterConfigCacheKey)(adapterConf), {
353
349
  adapterConf,
354
350
  self: self,
355
351
  options: rest,