@jbrowse/core 2.1.4 → 2.1.6

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 (65) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +4 -3
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +16 -17
  3. package/BaseFeatureWidget/SequenceBox.d.ts +29 -0
  4. package/BaseFeatureWidget/SequenceBox.js +61 -0
  5. package/BaseFeatureWidget/SequenceFeatureDetails.d.ts +2 -8
  6. package/BaseFeatureWidget/SequenceFeatureDetails.js +123 -135
  7. package/BaseFeatureWidget/SequenceFeatureSettingsDialog.d.ts +9 -0
  8. package/BaseFeatureWidget/SequenceFeatureSettingsDialog.js +71 -0
  9. package/BaseFeatureWidget/SequenceHelpDialog.d.ts +4 -0
  10. package/BaseFeatureWidget/SequenceHelpDialog.js +51 -0
  11. package/BaseFeatureWidget/SequencePanel.d.ts +10 -0
  12. package/BaseFeatureWidget/SequencePanel.js +72 -0
  13. package/BaseFeatureWidget/index.d.ts +7 -0
  14. package/BaseFeatureWidget/index.js +21 -5
  15. package/BaseFeatureWidget/test_data/DLGAP3.d.ts +80 -0
  16. package/BaseFeatureWidget/test_data/DLGAP3.js +585 -0
  17. package/BaseFeatureWidget/test_data/NCDN.d.ts +141 -0
  18. package/BaseFeatureWidget/test_data/NCDN.js +1118 -0
  19. package/BaseFeatureWidget/types.d.ts +2 -2
  20. package/BaseFeatureWidget/util.d.ts +13 -2
  21. package/BaseFeatureWidget/util.js +13 -1
  22. package/PluginLoader.d.ts +29 -13
  23. package/PluginLoader.js +47 -77
  24. package/PluginManager.d.ts +4 -3
  25. package/PluginManager.js +16 -8
  26. package/assemblyManager/assembly.d.ts +8 -15
  27. package/assemblyManager/assembly.js +14 -17
  28. package/assemblyManager/assemblyManager.d.ts +37 -86
  29. package/assemblyManager/assemblyManager.js +2 -1
  30. package/configuration/configurationSlot.js +2 -1
  31. package/data_adapters/CytobandAdapter.js +1 -1
  32. package/package.json +3 -3
  33. package/pluggableElementTypes/ViewType.d.ts +2 -0
  34. package/pluggableElementTypes/ViewType.js +1 -0
  35. package/pluggableElementTypes/models/BaseConnectionModelFactory.d.ts +7 -5
  36. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +3 -2
  37. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +1 -1
  38. package/pluggableElementTypes/models/BaseDisplayModel.js +3 -2
  39. package/pluggableElementTypes/models/BaseTrackModel.d.ts +1 -1
  40. package/pluggableElementTypes/models/BaseTrackModel.js +1 -1
  41. package/pluggableElementTypes/models/baseTrackConfig.js +16 -4
  42. package/rpc/RpcManager.d.ts +1 -1
  43. package/rpc/RpcManager.js +4 -1
  44. package/rpc/WebWorkerRpcDriver.d.ts +2 -0
  45. package/rpc/WebWorkerRpcDriver.js +21 -11
  46. package/rpc/configSchema.js +4 -1
  47. package/tsconfig.build.tsbuildinfo +1 -1
  48. package/ui/AboutDialog.d.ts +6 -0
  49. package/ui/AboutDialog.js +42 -20
  50. package/ui/App.d.ts +1 -1
  51. package/ui/App.js +49 -42
  52. package/ui/DrawerWidget.js +11 -6
  53. package/ui/FatalErrorDialog.d.ts +6 -22
  54. package/ui/FatalErrorDialog.js +10 -29
  55. package/ui/theme.d.ts +18 -171
  56. package/ui/theme.js +17 -20
  57. package/util/calculateStaticBlocks.js +3 -8
  58. package/util/index.d.ts +5 -1
  59. package/util/index.js +34 -11
  60. package/util/simpleFeature.d.ts +1 -2
  61. package/util/stats.js +7 -5
  62. package/util/tracks.d.ts +5 -2
  63. package/util/tracks.js +15 -5
  64. package/util/types/index.d.ts +1 -1
  65. package/util/types/index.js +3 -1
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { IAnyStateTreeNode } from 'mobx-state-tree';
3
- import { SimpleFeatureSerialized } from '../util/simpleFeature';
3
+ import { SimpleFeatureSerializedNoId } from '../util/simpleFeature';
4
4
  import { AbstractViewModel } from '../util';
5
5
  export interface BaseProps extends BaseCardProps {
6
- feature: SimpleFeatureSerialized;
6
+ feature: SimpleFeatureSerializedNoId;
7
7
  formatter?: (val: unknown, key: string) => React.ReactNode;
8
8
  descriptions?: Record<string, React.ReactNode>;
9
9
  model?: IAnyStateTreeNode & {
@@ -6,13 +6,19 @@ export interface Feat {
6
6
  id?: string;
7
7
  }
8
8
  export interface ParentFeat extends Feat {
9
+ uniqueId: string;
9
10
  strand?: number;
11
+ refName: string;
10
12
  subfeatures?: Feat[];
13
+ parentId?: string;
11
14
  }
12
15
  export interface SeqState {
13
16
  seq: string;
14
- upstream: string;
15
- downstream: string;
17
+ upstream?: string;
18
+ downstream?: string;
19
+ }
20
+ export interface ErrorState {
21
+ error: string;
16
22
  }
17
23
  export declare function stitch(subfeats: Feat[], sequence: string): string;
18
24
  export declare function dedupe(list: Feat[]): Feat[];
@@ -28,4 +34,9 @@ export declare function calculateUTRs(cds: Feat[], exons: Feat[]): {
28
34
  start: number;
29
35
  end: number;
30
36
  }[];
37
+ export declare function calculateUTRs2(cds: Feat[], parentFeat: Feat): {
38
+ type: string;
39
+ start: number;
40
+ end: number;
41
+ }[];
31
42
  export declare function ellipses(slug: string): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ellipses = exports.calculateUTRs = exports.revlist = exports.dedupe = exports.stitch = void 0;
3
+ exports.ellipses = exports.calculateUTRs2 = exports.calculateUTRs = exports.revlist = exports.dedupe = exports.stitch = void 0;
4
4
  function stitch(subfeats, sequence) {
5
5
  return subfeats.map(sub => sequence.slice(sub.start, sub.end)).join('');
6
6
  }
@@ -43,6 +43,18 @@ function calculateUTRs(cds, exons) {
43
43
  return [...fiveUTRs, ...threeUTRs];
44
44
  }
45
45
  exports.calculateUTRs = calculateUTRs;
46
+ // calculates UTRs using impliedUTRs logic, but there are no exon subfeatures
47
+ function calculateUTRs2(cds, parentFeat) {
48
+ const firstCds = cds[0];
49
+ const lastCds = cds[cds.length - 1];
50
+ const fiveUTRs = [{ start: parentFeat.start, end: firstCds.start }].map(elt => ({ ...elt, type: 'five_prime_UTR' }));
51
+ const threeUTRs = [{ start: lastCds.end, end: parentFeat.end }].map(elt => ({
52
+ ...elt,
53
+ type: 'three_prime_UTR',
54
+ }));
55
+ return [...fiveUTRs, ...threeUTRs];
56
+ }
57
+ exports.calculateUTRs2 = calculateUTRs2;
46
58
  function ellipses(slug) {
47
59
  return slug.length > 20 ? `${slug.slice(0, 20)}...` : slug;
48
60
  }
package/PluginLoader.d.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  import { PluginConstructor } from './Plugin';
2
- export declare const PluginSourceConfigurationSchema: import("./configuration").AnyConfigurationSchemaType;
3
- export interface UMDPluginDefinition {
2
+ export interface UMDLocPluginDefinition {
3
+ umdLoc: {
4
+ uri: string;
5
+ baseUri?: string;
6
+ };
7
+ name: string;
8
+ }
9
+ export interface UMDUrlPluginDefinition {
4
10
  umdUrl: string;
5
11
  name: string;
6
12
  }
@@ -8,16 +14,24 @@ export interface LegacyUMDPluginDefinition {
8
14
  url: string;
9
15
  name: string;
10
16
  }
11
- export declare function isUMDPluginDefinition(pluginDefinition: PluginDefinition): pluginDefinition is UMDPluginDefinition | LegacyUMDPluginDefinition;
12
- export interface ESMPluginDefinition {
17
+ declare type UMDPluginDefinition = UMDLocPluginDefinition | UMDUrlPluginDefinition;
18
+ export declare function isUMDPluginDefinition(def: PluginDefinition): def is UMDPluginDefinition | LegacyUMDPluginDefinition;
19
+ export interface ESMLocPluginDefinition {
20
+ esmLoc: {
21
+ uri: string;
22
+ baseUri?: string;
23
+ };
24
+ }
25
+ export interface ESMUrlPluginDefinition {
13
26
  esmUrl: string;
14
27
  }
15
- export declare function isESMPluginDefinition(pluginDefinition: PluginDefinition): pluginDefinition is ESMPluginDefinition;
28
+ export declare type ESMPluginDefinition = ESMLocPluginDefinition | ESMUrlPluginDefinition;
29
+ export declare function isESMPluginDefinition(def: PluginDefinition): def is ESMPluginDefinition;
16
30
  export interface CJSPluginDefinition {
17
31
  cjsUrl: string;
18
32
  }
19
- export declare function isCJSPluginDefinition(pluginDefinition: PluginDefinition): pluginDefinition is CJSPluginDefinition;
20
- export interface PluginDefinition extends Partial<UMDPluginDefinition>, Partial<LegacyUMDPluginDefinition>, Partial<ESMPluginDefinition>, Partial<CJSPluginDefinition> {
33
+ export declare function isCJSPluginDefinition(def: PluginDefinition): def is CJSPluginDefinition;
34
+ export interface PluginDefinition extends Partial<UMDUrlPluginDefinition>, Partial<UMDLocPluginDefinition>, Partial<LegacyUMDPluginDefinition>, Partial<ESMLocPluginDefinition>, Partial<ESMUrlPluginDefinition>, Partial<CJSPluginDefinition> {
21
35
  }
22
36
  export interface PluginRecord {
23
37
  plugin: PluginConstructor;
@@ -26,24 +40,26 @@ export interface PluginRecord {
26
40
  export interface LoadedPlugin {
27
41
  default: PluginConstructor;
28
42
  }
43
+ export declare function getWindowPath(windowHref: string): string;
29
44
  export default class PluginLoader {
30
45
  definitions: PluginDefinition[];
31
46
  fetchESM?: (url: string) => Promise<unknown>;
32
47
  fetchCJS?: (url: string) => Promise<LoadedPlugin>;
33
- constructor(pluginDefinitions?: PluginDefinition[], args?: {
48
+ constructor(defs?: PluginDefinition[], args?: {
34
49
  fetchESM?: (url: string) => Promise<unknown>;
35
50
  fetchCJS?: (url: string) => Promise<LoadedPlugin>;
36
51
  });
37
52
  loadScript(scriptUrl: string): Promise<void>;
38
- loadCJSPlugin({ cjsUrl }: CJSPluginDefinition): Promise<LoadedPlugin>;
39
- loadESMPlugin(pluginDefinition: ESMPluginDefinition): Promise<LoadedPlugin>;
40
- loadUMDPlugin(pluginDefinition: UMDPluginDefinition | LegacyUMDPluginDefinition): Promise<{
53
+ loadCJSPlugin(def: CJSPluginDefinition, windowHref: string): Promise<LoadedPlugin>;
54
+ loadESMPlugin(def: ESMPluginDefinition, windowHref: string): Promise<LoadedPlugin>;
55
+ loadUMDPlugin(def: UMDPluginDefinition | LegacyUMDPluginDefinition, windowHref: string): Promise<{
41
56
  default: PluginConstructor;
42
57
  }>;
43
- loadPlugin(definition: PluginDefinition): Promise<PluginConstructor>;
58
+ loadPlugin(def: PluginDefinition, windowHref: string): Promise<PluginConstructor>;
44
59
  installGlobalReExports(target: WindowOrWorkerGlobalScope): void;
45
- load(): Promise<{
60
+ load(windowHref?: string): Promise<{
46
61
  plugin: PluginConstructor;
47
62
  definition: PluginDefinition;
48
63
  }[]>;
49
64
  }
65
+ export {};
package/PluginLoader.js CHANGED
@@ -3,36 +3,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isCJSPluginDefinition = exports.isESMPluginDefinition = exports.isUMDPluginDefinition = exports.PluginSourceConfigurationSchema = void 0;
6
+ exports.getWindowPath = exports.isCJSPluginDefinition = exports.isESMPluginDefinition = exports.isUMDPluginDefinition = void 0;
7
7
  const load_script2_1 = __importDefault(require("load-script2"));
8
- const configuration_1 = require("./configuration");
9
8
  const ReExports_1 = __importDefault(require("./ReExports"));
10
9
  const util_1 = require("./util");
11
- exports.PluginSourceConfigurationSchema = (0, configuration_1.ConfigurationSchema)('PluginSource', {
12
- name: {
13
- type: 'string',
14
- defaultValue: '',
15
- },
16
- url: {
17
- type: 'string',
18
- defaultValue: '',
19
- },
20
- });
21
- function isUMDPluginDefinition(pluginDefinition) {
22
- return ((pluginDefinition.umdUrl !== undefined ||
23
- pluginDefinition.url !== undefined) &&
24
- pluginDefinition
25
- .name !== undefined);
10
+ function isUMDPluginDefinition(def) {
11
+ return ((def.umdUrl !== undefined ||
12
+ def.url !== undefined ||
13
+ def.umdLoc !== undefined) &&
14
+ def.name !== undefined);
26
15
  }
27
16
  exports.isUMDPluginDefinition = isUMDPluginDefinition;
28
- function isESMPluginDefinition(pluginDefinition) {
29
- return pluginDefinition.esmUrl !== undefined;
17
+ function isESMPluginDefinition(def) {
18
+ return (def.esmUrl !== undefined ||
19
+ def.esmLoc !== undefined);
30
20
  }
31
21
  exports.isESMPluginDefinition = isESMPluginDefinition;
32
- function isCJSPluginDefinition(pluginDefinition) {
33
- return pluginDefinition.cjsUrl !== undefined;
22
+ function isCJSPluginDefinition(def) {
23
+ return def.cjsUrl !== undefined;
34
24
  }
35
25
  exports.isCJSPluginDefinition = isCJSPluginDefinition;
26
+ function getWindowPath(windowHref) {
27
+ return window.location.href + windowHref;
28
+ }
29
+ exports.getWindowPath = getWindowPath;
36
30
  function getGlobalObject() {
37
31
  // Based on window-or-global
38
32
  // https://github.com/purposeindustries/window-or-global/blob/322abc71de0010c9e5d9d0729df40959e1ef8775/lib/index.js
@@ -47,42 +41,27 @@ function isInWebWorker(globalObject) {
47
41
  return Boolean('WorkerGlobalScope' in globalObject);
48
42
  }
49
43
  class PluginLoader {
50
- constructor(pluginDefinitions = [], args) {
44
+ constructor(defs = [], args) {
51
45
  this.definitions = [];
52
46
  this.fetchESM = args === null || args === void 0 ? void 0 : args.fetchESM;
53
47
  this.fetchCJS = args === null || args === void 0 ? void 0 : args.fetchCJS;
54
- this.definitions = JSON.parse(JSON.stringify(pluginDefinitions));
48
+ this.definitions = JSON.parse(JSON.stringify(defs));
55
49
  }
56
- loadScript(scriptUrl) {
50
+ async loadScript(scriptUrl) {
57
51
  const globalObject = getGlobalObject();
58
52
  if (!isInWebWorker(globalObject)) {
59
53
  return (0, load_script2_1.default)(scriptUrl);
60
54
  }
61
55
  // @ts-ignore
62
- if (globalObject && globalObject.importScripts) {
63
- return new Promise((resolve, reject) => {
64
- try {
65
- // @ts-ignore
66
- globalObject.importScripts(scriptUrl);
67
- }
68
- catch (error) {
69
- reject(error || new Error(`failed to load ${scriptUrl}`));
70
- return;
71
- }
72
- resolve();
73
- });
56
+ if (globalObject === null || globalObject === void 0 ? void 0 : globalObject.importScripts) {
57
+ // @ts-ignore
58
+ await globalObject.importScripts(scriptUrl);
59
+ return;
74
60
  }
75
61
  throw new Error('cannot figure out how to load external JS scripts in this environment');
76
62
  }
77
- async loadCJSPlugin({ cjsUrl }) {
78
- let parsedUrl;
79
- try {
80
- parsedUrl = new URL(cjsUrl, getGlobalObject().location.href);
81
- }
82
- catch (error) {
83
- console.error(error);
84
- throw new Error(`Error parsing URL: ${cjsUrl}`);
85
- }
63
+ async loadCJSPlugin(def, windowHref) {
64
+ const parsedUrl = new URL(def.cjsUrl, windowHref);
86
65
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
87
66
  throw new Error(`Cannot load plugins using protocol "${parsedUrl.protocol}"`);
88
67
  }
@@ -91,16 +70,11 @@ class PluginLoader {
91
70
  }
92
71
  return this.fetchCJS(parsedUrl.href);
93
72
  }
94
- async loadESMPlugin(pluginDefinition) {
73
+ async loadESMPlugin(def, windowHref) {
95
74
  var _a;
96
- let parsedUrl;
97
- try {
98
- parsedUrl = new URL(pluginDefinition.esmUrl, getGlobalObject().location.href);
99
- }
100
- catch (error) {
101
- console.error(error);
102
- throw new Error(`Error parsing URL: ${pluginDefinition.esmUrl}`);
103
- }
75
+ const parsedUrl = 'esmUrl' in def
76
+ ? new URL(def.esmUrl, windowHref)
77
+ : new URL(def.esmLoc.uri, def.esmLoc.baseUri);
104
78
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
105
79
  throw new Error(`cannot load plugins using protocol "${parsedUrl.protocol}"`);
106
80
  }
@@ -110,21 +84,17 @@ class PluginLoader {
110
84
  }
111
85
  return plugin;
112
86
  }
113
- async loadUMDPlugin(pluginDefinition) {
114
- const umdUrl = 'url' in pluginDefinition ? pluginDefinition.url : pluginDefinition.umdUrl;
115
- let parsedUrl;
116
- try {
117
- parsedUrl = new URL(umdUrl, getGlobalObject().location.href);
118
- }
119
- catch (error) {
120
- console.error(error);
121
- throw new Error(`Error parsing URL: ${umdUrl}`);
122
- }
87
+ async loadUMDPlugin(def, windowHref) {
88
+ const parsedUrl = 'url' in def
89
+ ? new URL(def.url, windowHref)
90
+ : 'umdUrl' in def
91
+ ? new URL(def.umdUrl, windowHref)
92
+ : new URL(def.umdLoc.uri, def.umdLoc.baseUri);
123
93
  if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
124
94
  throw new Error(`cannot load plugins using protocol "${parsedUrl.protocol}"`);
125
95
  }
126
96
  await this.loadScript(parsedUrl.href);
127
- const moduleName = pluginDefinition.name;
97
+ const moduleName = def.name;
128
98
  const umdName = `JBrowsePlugin${moduleName}`;
129
99
  const globalObject = getGlobalObject();
130
100
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -134,22 +104,22 @@ class PluginLoader {
134
104
  }
135
105
  return plugin;
136
106
  }
137
- async loadPlugin(definition) {
107
+ async loadPlugin(def, windowHref) {
138
108
  let plugin;
139
- if (util_1.isElectron && isCJSPluginDefinition(definition)) {
140
- plugin = await this.loadCJSPlugin(definition);
109
+ if (util_1.isElectron && isCJSPluginDefinition(def)) {
110
+ plugin = await this.loadCJSPlugin(def, windowHref);
141
111
  }
142
- else if (isESMPluginDefinition(definition)) {
143
- plugin = await this.loadESMPlugin(definition);
112
+ else if (isESMPluginDefinition(def)) {
113
+ plugin = await this.loadESMPlugin(def, windowHref);
144
114
  }
145
- else if (isUMDPluginDefinition(definition)) {
146
- plugin = await this.loadUMDPlugin(definition);
115
+ else if (isUMDPluginDefinition(def)) {
116
+ plugin = await this.loadUMDPlugin(def, windowHref);
147
117
  }
148
- else if (!util_1.isElectron && isCJSPluginDefinition(definition)) {
149
- throw new Error(`Only CommonJS plugin found, but not in a NodeJS environment: ${JSON.stringify(definition)}`);
118
+ else if (!util_1.isElectron && isCJSPluginDefinition(def)) {
119
+ throw new Error(`CommonJS plugin found, but not in a NodeJS environment: ${JSON.stringify(def)}`);
150
120
  }
151
121
  else {
152
- throw new Error(`Could not determine plugin type: ${JSON.stringify(definition)}`);
122
+ throw new Error(`Could not determine plugin type: ${JSON.stringify(def)}`);
153
123
  }
154
124
  return plugin.default;
155
125
  }
@@ -159,9 +129,9 @@ class PluginLoader {
159
129
  return [moduleName, module];
160
130
  }));
161
131
  }
162
- async load() {
132
+ async load(windowHref = '') {
163
133
  return Promise.all(this.definitions.map(async (definition) => ({
164
- plugin: await this.loadPlugin(definition),
134
+ plugin: await this.loadPlugin(definition, windowHref),
165
135
  definition,
166
136
  })));
167
137
  }
@@ -98,6 +98,7 @@ export default class PluginManager {
98
98
  addElementType(groupName: PluggableElementTypeGroup, creationCallback: (pluginManager: PluginManager) => PluggableElementType): this;
99
99
  getElementType(groupName: PluggableElementTypeGroup, typeName: string): PluggableElementBase;
100
100
  getElementTypesInGroup(groupName: PluggableElementTypeGroup): PluggableElementBase[];
101
+ getRpcElements(): RpcMethodType[];
101
102
  /** get a MST type for the union of all specified pluggable MST types */
102
103
  pluggableMstType(groupName: PluggableElementTypeGroup, fieldName: PluggableElementMember, fallback?: IAnyType): IAnyType;
103
104
  /** get a MST type for the union of all specified pluggable config schemas */
@@ -279,8 +280,8 @@ export default class PluginManager {
279
280
  addRpcMethod(cb: (pm: PluginManager) => RpcMethodType): this;
280
281
  addInternetAccountType(cb: (pm: PluginManager) => InternetAccountType): this;
281
282
  addAddTrackWorkflowType(cb: (pm: PluginManager) => AddTrackWorkflowType): this;
282
- addToExtensionPoint<T>(extensionPointName: string, callback: (extendee: T) => T): void;
283
- evaluateExtensionPoint(extensionPointName: string, extendee: unknown): unknown;
284
- evaluateAsyncExtensionPoint(extensionPointName: string, extendee: unknown): Promise<unknown>;
283
+ addToExtensionPoint<T>(extensionPointName: string, callback: (extendee: T, props: Record<string, unknown>) => T): void;
284
+ evaluateExtensionPoint(extensionPointName: string, extendee: unknown, props?: Record<string, unknown>): unknown;
285
+ evaluateAsyncExtensionPoint(extensionPointName: string, extendee: unknown, props?: Record<string, unknown>): Promise<unknown>;
285
286
  }
286
287
  export {};
package/PluginManager.js CHANGED
@@ -16,7 +16,6 @@ const InternetAccountType_1 = __importDefault(require("./pluggableElementTypes/I
16
16
  const TextSearchAdapterType_1 = __importDefault(require("./pluggableElementTypes/TextSearchAdapterType"));
17
17
  const AddTrackWorkflowType_1 = __importDefault(require("./pluggableElementTypes/AddTrackWorkflowType"));
18
18
  const configuration_1 = require("./configuration");
19
- const Plugin_1 = __importDefault(require("./Plugin"));
20
19
  const ReExports_1 = __importDefault(require("./ReExports"));
21
20
  const CorePlugin_1 = __importDefault(require("./CorePlugin"));
22
21
  const jexl_1 = __importDefault(require("./util/jexl"));
@@ -140,12 +139,17 @@ class PluginManager {
140
139
  if (this.configured) {
141
140
  throw new Error('JBrowse already configured, cannot add plugins');
142
141
  }
143
- const [plugin, metadata = {}] = load instanceof Plugin_1.default ? [load, {}] : [load.plugin, load.metadata];
142
+ // check for availability of 'install' and 'configure' as a proxy for being
143
+ // an 'instanceof Plugin'
144
+ const [plugin, metadata = {}] = 'install' in load && 'configure' in load
145
+ ? [load, {}]
146
+ : [load.plugin, load.metadata];
144
147
  if (this.plugins.includes(plugin)) {
145
148
  throw new Error('plugin already installed');
146
149
  }
147
150
  this.pluginMetadata[plugin.name] = metadata;
148
151
  if ('definition' in load) {
152
+ // @ts-ignore
149
153
  this.runtimePluginDefinitions.push(load.definition);
150
154
  }
151
155
  plugin.install(this);
@@ -176,7 +180,6 @@ class PluginManager {
176
180
  }
177
181
  this.plugins.forEach(plugin => plugin.configure(this));
178
182
  this.configured = true;
179
- // console.log(JSON.stringify(getSnapshot(model)))
180
183
  return this;
181
184
  }
182
185
  getElementTypeRecord(groupName) {
@@ -231,6 +234,9 @@ class PluginManager {
231
234
  getElementTypesInGroup(groupName) {
232
235
  return this.getElementTypeRecord(groupName).all();
233
236
  }
237
+ getRpcElements() {
238
+ return this.getElementTypesInGroup('rpc method');
239
+ }
234
240
  /** get a MST type for the union of all specified pluggable MST types */
235
241
  pluggableMstType(groupName, fieldName, fallback = mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.null)) {
236
242
  const pluggableTypes = this.getElementTypeRecord(groupName)
@@ -329,7 +335,9 @@ class PluginManager {
329
335
  const displays = this.getElementTypesInGroup('display');
330
336
  displays.forEach(display => {
331
337
  // view may have already added the displayType in its callback
332
- if (display.viewType === newView.name &&
338
+ // see ViewType for description of extendedName
339
+ if ((display.viewType === newView.name ||
340
+ display.viewType === newView.extendedName) &&
333
341
  !newView.displayTypes.includes(display)) {
334
342
  newView.addDisplayType(display);
335
343
  }
@@ -361,13 +369,13 @@ class PluginManager {
361
369
  }
362
370
  callbacks.push(callback);
363
371
  }
364
- evaluateExtensionPoint(extensionPointName, extendee) {
372
+ evaluateExtensionPoint(extensionPointName, extendee, props) {
365
373
  const callbacks = this.extensionPoints.get(extensionPointName);
366
374
  let accumulator = extendee;
367
375
  if (callbacks) {
368
376
  for (const callback of callbacks) {
369
377
  try {
370
- accumulator = callback(accumulator);
378
+ accumulator = callback(accumulator, props);
371
379
  }
372
380
  catch (error) {
373
381
  console.error(error);
@@ -376,13 +384,13 @@ class PluginManager {
376
384
  }
377
385
  return accumulator;
378
386
  }
379
- async evaluateAsyncExtensionPoint(extensionPointName, extendee) {
387
+ async evaluateAsyncExtensionPoint(extensionPointName, extendee, props) {
380
388
  const callbacks = this.extensionPoints.get(extensionPointName);
381
389
  let accumulator = extendee;
382
390
  if (callbacks) {
383
391
  for (const callback of callbacks) {
384
392
  try {
385
- accumulator = await callback(accumulator);
393
+ accumulator = await callback(accumulator, props);
386
394
  }
387
395
  catch (error) {
388
396
  console.error(error);
@@ -7,6 +7,10 @@ export interface BaseOptions {
7
7
  sessionId: string;
8
8
  statusCallback?: Function;
9
9
  }
10
+ export interface RefNameMap {
11
+ forwardMap: RefNameAliases;
12
+ reverseMap: RefNameAliases;
13
+ }
10
14
  export interface BasicRegion {
11
15
  start: number;
12
16
  end: number;
@@ -48,30 +52,19 @@ export default function assemblyFactory(assemblyConfigType: IAnyType, pluginMana
48
52
  }): void;
49
53
  setError(e: Error): void;
50
54
  setRegions(regions: Region[]): void;
51
- setRefNameAliases(refNameAliases: RefNameAliases, lowerCaseRefNameAliases: RefNameAliases): void;
55
+ setRefNameAliases(aliases: RefNameAliases, lowerCase: RefNameAliases): void;
52
56
  setCytobands(cytobands: Feature[]): void;
53
57
  afterAttach(): void;
54
58
  } & {
55
- getAdapterMapEntry(adapterConf: unknown, options: BaseOptions): Promise<{
56
- forwardMap: {
57
- [key: string]: string;
58
- };
59
- reverseMap: {
60
- [key: string]: string;
61
- };
62
- }>;
59
+ getAdapterMapEntry(adapterConf: unknown, options: BaseOptions): Promise<RefNameMap>;
63
60
  /**
64
61
  * get Map of `canonical-name -> adapter-specific-name`
65
62
  */
66
- getRefNameMapForAdapter(adapterConf: unknown, opts: BaseOptions): Promise<{
67
- [key: string]: string;
68
- }>;
63
+ getRefNameMapForAdapter(adapterConf: unknown, opts: BaseOptions): Promise<RefNameAliases>;
69
64
  /**
70
65
  * get Map of `adapter-specific-name -> canonical-name`
71
66
  */
72
- getReverseRefNameMapForAdapter(adapterConf: unknown, opts: BaseOptions): Promise<{
73
- [key: string]: string;
74
- }>;
67
+ getReverseRefNameMapForAdapter(adapterConf: unknown, opts: BaseOptions): Promise<RefNameAliases>;
75
68
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
76
69
  export declare type AssemblyModel = ReturnType<typeof assemblyFactory>;
77
70
  export declare type Assembly = Instance<AssemblyModel>;
@@ -186,9 +186,9 @@ function assemblyFactory(assemblyConfigType, pluginManager) {
186
186
  setRegions(regions) {
187
187
  self.regions = regions;
188
188
  },
189
- setRefNameAliases(refNameAliases, lowerCaseRefNameAliases) {
190
- self.refNameAliases = refNameAliases;
191
- self.lowerCaseRefNameAliases = lowerCaseRefNameAliases;
189
+ setRefNameAliases(aliases, lowerCase) {
190
+ self.refNameAliases = aliases;
191
+ self.lowerCaseRefNameAliases = lowerCase;
192
192
  },
193
193
  setCytobands(cytobands) {
194
194
  self.cytobands = cytobands;
@@ -292,25 +292,22 @@ async function loadAssemblyReaction(props, signal) {
292
292
  cytobands,
293
293
  };
294
294
  }
295
- async function getRefNameAliases(config, pluginManager, signal) {
296
- var _a;
297
- const type = pluginManager.getAdapterType(config.type);
298
- const CLASS = await ((_a = type.getAdapterClass) === null || _a === void 0 ? void 0 : _a.call(type));
299
- const adapter = new CLASS(config, undefined, pluginManager);
300
- return adapter.getRefNameAliases({
301
- signal,
302
- });
295
+ async function getRefNameAliases(config, pm, signal) {
296
+ const type = pm.getAdapterType(config.type);
297
+ const CLASS = await type.getAdapterClass();
298
+ const adapter = new CLASS(config, undefined, pm);
299
+ return adapter.getRefNameAliases({ signal });
303
300
  }
304
- async function getCytobands(config, pluginManager) {
305
- const type = pluginManager.getAdapterType(config.type);
301
+ async function getCytobands(config, pm) {
302
+ const type = pm.getAdapterType(config.type);
306
303
  const CLASS = await type.getAdapterClass();
307
- const adapter = new CLASS(config, undefined, pluginManager);
304
+ const adapter = new CLASS(config, undefined, pm);
308
305
  // @ts-ignore
309
306
  return adapter.getData();
310
307
  }
311
- async function getAssemblyRegions(config, pluginManager, signal) {
312
- const type = pluginManager.getAdapterType(config.type);
308
+ async function getAssemblyRegions(config, pm, signal) {
309
+ const type = pm.getAdapterType(config.type);
313
310
  const CLASS = await type.getAdapterClass();
314
- const adapter = new CLASS(config, undefined, pluginManager);
311
+ const adapter = new CLASS(config, undefined, pm);
315
312
  return adapter.getRegions({ signal });
316
313
  }