@jbrowse/core 2.0.1 → 2.1.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.
Files changed (179) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +6 -0
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +313 -592
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -479
  4. package/BaseFeatureWidget/index.js +88 -126
  5. package/BaseFeatureWidget/types.js +1 -4
  6. package/BaseFeatureWidget/util.js +40 -75
  7. package/CorePlugin.js +55 -94
  8. package/Plugin.js +9 -34
  9. package/PluginLoader.js +153 -422
  10. package/PluginManager.d.ts +17 -14
  11. package/PluginManager.js +377 -666
  12. package/ReExports/Attributes.js +3 -10
  13. package/ReExports/BaseCard.js +3 -10
  14. package/ReExports/DataGrid.js +5 -12
  15. package/ReExports/FeatureDetails.js +3 -10
  16. package/ReExports/index.js +6 -12
  17. package/ReExports/list.d.ts +5 -0
  18. package/ReExports/list.js +271 -7
  19. package/ReExports/material-ui-colors.js +15 -16
  20. package/ReExports/modules.d.ts +0 -1
  21. package/ReExports/modules.js +453 -798
  22. package/TextSearch/BaseResults.js +51 -123
  23. package/TextSearch/TextSearchManager.js +66 -144
  24. package/assemblyManager/assembly.js +280 -555
  25. package/assemblyManager/assemblyConfigSchema.js +47 -64
  26. package/assemblyManager/assemblyManager.js +126 -272
  27. package/assemblyManager/index.js +9 -22
  28. package/configuration/configurationSchema.js +167 -203
  29. package/configuration/configurationSlot.js +248 -326
  30. package/configuration/index.js +19 -35
  31. package/configuration/util.js +131 -173
  32. package/data_adapters/BaseAdapter.d.ts +2 -2
  33. package/data_adapters/BaseAdapter.js +132 -521
  34. package/data_adapters/CytobandAdapter.js +40 -126
  35. package/data_adapters/dataAdapterCache.js +77 -158
  36. package/package.json +4 -5
  37. package/pluggableElementTypes/AdapterType.js +24 -79
  38. package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
  39. package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
  40. package/pluggableElementTypes/ConnectionType.js +22 -65
  41. package/pluggableElementTypes/DisplayType.js +35 -82
  42. package/pluggableElementTypes/InternetAccountType.js +23 -64
  43. package/pluggableElementTypes/PluggableElementBase.js +8 -20
  44. package/pluggableElementTypes/RpcMethodType.js +85 -427
  45. package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
  46. package/pluggableElementTypes/TrackType.js +26 -70
  47. package/pluggableElementTypes/ViewType.js +21 -63
  48. package/pluggableElementTypes/WidgetType.js +21 -64
  49. package/pluggableElementTypes/index.d.ts +4 -3
  50. package/pluggableElementTypes/index.js +42 -125
  51. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
  52. package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
  53. package/pluggableElementTypes/models/BaseTrackModel.js +139 -199
  54. package/pluggableElementTypes/models/BaseViewModel.js +24 -40
  55. package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
  56. package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
  57. package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
  58. package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
  59. package/pluggableElementTypes/models/index.js +21 -70
  60. package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
  61. package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
  62. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
  63. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
  64. package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -264
  65. package/pluggableElementTypes/renderers/RendererType.js +31 -105
  66. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
  67. package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
  68. package/pluggableElementTypes/renderers/index.js +19 -62
  69. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
  70. package/rpc/BaseRpcDriver.js +169 -405
  71. package/rpc/MainThreadRpcDriver.js +27 -150
  72. package/rpc/RpcManager.js +58 -159
  73. package/rpc/WebWorkerRpcDriver.js +54 -171
  74. package/rpc/configSchema.js +25 -49
  75. package/rpc/coreRpcMethods.js +221 -959
  76. package/rpc/remoteAbortSignals.js +46 -70
  77. package/tsconfig.build.tsbuildinfo +1 -1
  78. package/ui/AboutDialog.js +106 -162
  79. package/ui/App.js +157 -242
  80. package/ui/AssemblySelector.js +59 -120
  81. package/ui/CascadingMenu.js +101 -196
  82. package/ui/ColorPicker.d.ts +16 -0
  83. package/ui/ColorPicker.js +97 -0
  84. package/ui/Drawer.js +28 -61
  85. package/ui/DrawerWidget.js +108 -202
  86. package/ui/DropDownMenu.js +60 -91
  87. package/ui/EditableTypography.js +87 -149
  88. package/ui/ErrorMessage.js +41 -56
  89. package/ui/FactoryResetDialog.js +24 -57
  90. package/ui/FatalErrorDialog.js +59 -91
  91. package/ui/FileSelector/FileSelector.js +123 -189
  92. package/ui/FileSelector/LocalFileChooser.js +44 -75
  93. package/ui/FileSelector/UrlChooser.js +17 -38
  94. package/ui/FileSelector/index.js +6 -12
  95. package/ui/Icons.js +45 -69
  96. package/ui/Logo.js +57 -110
  97. package/ui/Menu.js +232 -354
  98. package/ui/PrerenderedCanvas.js +63 -87
  99. package/ui/ResizeHandle.js +87 -116
  100. package/ui/ReturnToImportFormDialog.js +32 -63
  101. package/ui/SanitizedHTML.js +64 -47
  102. package/ui/Snackbar.js +74 -101
  103. package/ui/SnackbarModel.js +37 -51
  104. package/ui/Tooltip.js +49 -76
  105. package/ui/ViewContainer.js +113 -196
  106. package/ui/colors.d.ts +10 -0
  107. package/ui/colors.js +78 -0
  108. package/ui/index.js +51 -181
  109. package/ui/react-colorful.d.ts +17 -0
  110. package/ui/react-colorful.js +455 -0
  111. package/ui/theme.js +199 -247
  112. package/util/Base1DUtils.js +163 -202
  113. package/util/Base1DViewModel.js +121 -168
  114. package/util/QuickLRU.js +84 -332
  115. package/util/TimeTraveller.d.ts +19 -0
  116. package/util/TimeTraveller.js +86 -0
  117. package/util/aborting.js +49 -127
  118. package/util/analytics.js +91 -154
  119. package/util/blockTypes.js +106 -240
  120. package/util/calculateDynamicBlocks.js +98 -128
  121. package/util/calculateStaticBlocks.js +105 -125
  122. package/util/color/cssColorsLevel4.js +156 -160
  123. package/util/color/index.js +33 -55
  124. package/util/compositeMap.js +49 -333
  125. package/util/formatFastaStrings.js +9 -14
  126. package/util/idMaker.js +18 -31
  127. package/util/index.d.ts +7 -20
  128. package/util/index.js +742 -1188
  129. package/util/io/RemoteFileWithRangeCache.js +88 -257
  130. package/util/io/index.js +95 -169
  131. package/util/jexl.js +60 -115
  132. package/util/jexlStrings.js +24 -29
  133. package/util/layouts/BaseLayout.js +1 -4
  134. package/util/layouts/GranularRectLayout.js +388 -555
  135. package/util/layouts/MultiLayout.js +41 -109
  136. package/util/layouts/PrecomputedLayout.js +56 -112
  137. package/util/layouts/PrecomputedMultiLayout.js +22 -59
  138. package/util/layouts/SceneGraph.js +127 -197
  139. package/util/layouts/index.js +29 -66
  140. package/util/mst-reflection.js +55 -71
  141. package/util/offscreenCanvasPonyfill.js +66 -134
  142. package/util/offscreenCanvasUtils.d.ts +2 -7
  143. package/util/offscreenCanvasUtils.js +49 -146
  144. package/util/range.js +29 -40
  145. package/util/rxjs.js +20 -27
  146. package/util/simpleFeature.js +88 -152
  147. package/util/stats.js +91 -151
  148. package/util/tracks.js +130 -173
  149. package/util/types/index.js +110 -179
  150. package/util/types/mst.js +91 -146
  151. package/util/types/util.js +1 -4
  152. package/util/when.js +54 -101
  153. package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
  154. package/BaseFeatureWidget/index.test.js +0 -69
  155. package/TextSearch/BaseResults.test.js +0 -42
  156. package/configuration/configurationSchema.test.js +0 -266
  157. package/configuration/configurationSlot.test.js +0 -69
  158. package/configuration/util.test.js +0 -39
  159. package/data_adapters/BaseAdapter.test.js +0 -200
  160. package/declare.d.js +0 -1
  161. package/pluggableElementTypes/RpcMethodType.test.js +0 -118
  162. package/pluggableElementTypes/renderers/declare.d.js +0 -1
  163. package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
  164. package/rpc/BaseRpcDriver.test.js +0 -540
  165. package/rpc/declaration.d.js +0 -1
  166. package/ui/FatalErrorDialog.test.js +0 -82
  167. package/ui/SanitizedHTML.test.js +0 -36
  168. package/ui/theme.test.js +0 -92
  169. package/util/Base1DViewModel.test.js +0 -130
  170. package/util/calculateDynamicBlocks.test.js +0 -74
  171. package/util/calculateStaticBlocks.test.js +0 -297
  172. package/util/declare.d.js +0 -1
  173. package/util/formatFastaStrings.test.js +0 -40
  174. package/util/index.test.js +0 -213
  175. package/util/jexlStrings.test.js +0 -48
  176. package/util/layouts/GranularRectLayout.test.js +0 -99
  177. package/util/range.test.js +0 -64
  178. package/util/simpleFeature.test.js +0 -34
  179. package/util/stats.test.js +0 -172
package/PluginLoader.js CHANGED
@@ -1,438 +1,169 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isCJSPluginDefinition = exports.isESMPluginDefinition = exports.isUMDPluginDefinition = exports.PluginSourceConfigurationSchema = void 0;
7
+ const load_script2_1 = __importDefault(require("load-script2"));
8
+ const configuration_1 = require("./configuration");
9
+ const ReExports_1 = __importDefault(require("./ReExports"));
10
+ 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
+ },
7
20
  });
8
- exports.default = exports.PluginSourceConfigurationSchema = void 0;
9
- exports.isCJSPluginDefinition = isCJSPluginDefinition;
10
- exports.isESMPluginDefinition = isESMPluginDefinition;
11
- exports.isUMDPluginDefinition = isUMDPluginDefinition;
12
-
13
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
14
-
15
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
16
-
17
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
18
-
19
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
20
-
21
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
22
-
23
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
24
-
25
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
26
-
27
- var _loadScript = _interopRequireDefault(require("load-script2"));
28
-
29
- var _configuration = require("./configuration");
30
-
31
- var _ReExports = _interopRequireDefault(require("./ReExports"));
32
-
33
- var _util = require("./util");
34
-
35
- var PluginSourceConfigurationSchema = (0, _configuration.ConfigurationSchema)('PluginSource', {
36
- name: {
37
- type: 'string',
38
- defaultValue: ''
39
- },
40
- url: {
41
- type: 'string',
42
- defaultValue: ''
43
- }
44
- });
45
- exports.PluginSourceConfigurationSchema = PluginSourceConfigurationSchema;
46
-
47
21
  function isUMDPluginDefinition(pluginDefinition) {
48
- return (pluginDefinition.umdUrl !== undefined || pluginDefinition.url !== undefined) && pluginDefinition.name !== undefined;
22
+ return ((pluginDefinition.umdUrl !== undefined ||
23
+ pluginDefinition.url !== undefined) &&
24
+ pluginDefinition
25
+ .name !== undefined);
49
26
  }
50
-
27
+ exports.isUMDPluginDefinition = isUMDPluginDefinition;
51
28
  function isESMPluginDefinition(pluginDefinition) {
52
- return pluginDefinition.esmUrl !== undefined;
29
+ return pluginDefinition.esmUrl !== undefined;
53
30
  }
54
-
31
+ exports.isESMPluginDefinition = isESMPluginDefinition;
55
32
  function isCJSPluginDefinition(pluginDefinition) {
56
- return pluginDefinition.cjsUrl !== undefined;
33
+ return pluginDefinition.cjsUrl !== undefined;
57
34
  }
58
-
35
+ exports.isCJSPluginDefinition = isCJSPluginDefinition;
59
36
  function getGlobalObject() {
60
- // Based on window-or-global
61
- // https://github.com/purposeindustries/window-or-global/blob/322abc71de0010c9e5d9d0729df40959e1ef8775/lib/index.js
62
- return (// eslint-disable-next-line no-restricted-globals
63
- (typeof self === "undefined" ? "undefined" : (0, _typeof2.default)(self)) === 'object' && self.self === self && self || (typeof global === "undefined" ? "undefined" : (0, _typeof2.default)(global)) === 'object' && global.global === global && global || // @ts-ignore
64
- this
65
- );
37
+ // Based on window-or-global
38
+ // https://github.com/purposeindustries/window-or-global/blob/322abc71de0010c9e5d9d0729df40959e1ef8775/lib/index.js
39
+ return (
40
+ // eslint-disable-next-line no-restricted-globals
41
+ (typeof self === 'object' && self.self === self && self) ||
42
+ (typeof global === 'object' && global.global === global && global) ||
43
+ // @ts-ignore
44
+ this);
66
45
  }
67
-
68
46
  function isInWebWorker(globalObject) {
69
- return Boolean('WorkerGlobalScope' in globalObject);
47
+ return Boolean('WorkerGlobalScope' in globalObject);
70
48
  }
71
-
72
- var PluginLoader = /*#__PURE__*/function () {
73
- function PluginLoader() {
74
- var pluginDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
75
- var args = arguments.length > 1 ? arguments[1] : undefined;
76
- (0, _classCallCheck2.default)(this, PluginLoader);
77
- (0, _defineProperty2.default)(this, "definitions", []);
78
- (0, _defineProperty2.default)(this, "fetchESM", void 0);
79
- (0, _defineProperty2.default)(this, "fetchCJS", void 0);
80
- this.fetchESM = args === null || args === void 0 ? void 0 : args.fetchESM;
81
- this.fetchCJS = args === null || args === void 0 ? void 0 : args.fetchCJS;
82
- this.definitions = JSON.parse(JSON.stringify(pluginDefinitions));
83
- }
84
-
85
- (0, _createClass2.default)(PluginLoader, [{
86
- key: "loadScript",
87
- value: function loadScript(scriptUrl) {
88
- var globalObject = getGlobalObject();
89
-
90
- if (!isInWebWorker(globalObject)) {
91
- return (0, _loadScript.default)(scriptUrl);
92
- } // @ts-ignore
93
-
94
-
95
- if (globalObject && globalObject.importScripts) {
96
- return new Promise(function (resolve, reject) {
97
- try {
98
- // @ts-ignore
99
- globalObject.importScripts(scriptUrl);
100
- } catch (error) {
101
- reject(error || new Error("failed to load ".concat(scriptUrl)));
102
- return;
103
- }
104
-
105
- resolve();
106
- });
107
- }
108
-
109
- throw new Error('cannot figure out how to load external JS scripts in this environment');
49
+ class PluginLoader {
50
+ constructor(pluginDefinitions = [], args) {
51
+ this.definitions = [];
52
+ this.fetchESM = args === null || args === void 0 ? void 0 : args.fetchESM;
53
+ this.fetchCJS = args === null || args === void 0 ? void 0 : args.fetchCJS;
54
+ this.definitions = JSON.parse(JSON.stringify(pluginDefinitions));
110
55
  }
111
- }, {
112
- key: "loadCJSPlugin",
113
- value: function () {
114
- var _loadCJSPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
115
- var cjsUrl, parsedUrl;
116
- return _regenerator.default.wrap(function _callee$(_context) {
117
- while (1) {
118
- switch (_context.prev = _context.next) {
119
- case 0:
120
- cjsUrl = _ref.cjsUrl;
121
- _context.prev = 1;
122
- parsedUrl = new URL(cjsUrl, getGlobalObject().location.href);
123
- _context.next = 9;
124
- break;
125
-
126
- case 5:
127
- _context.prev = 5;
128
- _context.t0 = _context["catch"](1);
129
- console.error(_context.t0);
130
- throw new Error("Error parsing URL: ".concat(cjsUrl));
131
-
132
- case 9:
133
- if (!(parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:')) {
134
- _context.next = 11;
135
- break;
136
- }
137
-
138
- throw new Error("Cannot load plugins using protocol \"".concat(parsedUrl.protocol, "\""));
139
-
140
- case 11:
141
- if (this.fetchCJS) {
142
- _context.next = 13;
143
- break;
144
- }
145
-
146
- throw new Error('No fetchCJS callback provided');
147
-
148
- case 13:
149
- return _context.abrupt("return", this.fetchCJS(parsedUrl.href));
150
-
151
- case 14:
152
- case "end":
153
- return _context.stop();
154
- }
155
- }
156
- }, _callee, this, [[1, 5]]);
157
- }));
158
-
159
- function loadCJSPlugin(_x) {
160
- return _loadCJSPlugin.apply(this, arguments);
161
- }
162
-
163
- return loadCJSPlugin;
164
- }()
165
- }, {
166
- key: "loadESMPlugin",
167
- value: function () {
168
- var _loadESMPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(pluginDefinition) {
169
- var _this$fetchESM;
170
-
171
- var parsedUrl, plugin;
172
- return _regenerator.default.wrap(function _callee2$(_context2) {
173
- while (1) {
174
- switch (_context2.prev = _context2.next) {
175
- case 0:
176
- _context2.prev = 0;
177
- parsedUrl = new URL(pluginDefinition.esmUrl, getGlobalObject().location.href);
178
- _context2.next = 8;
179
- break;
180
-
181
- case 4:
182
- _context2.prev = 4;
183
- _context2.t0 = _context2["catch"](0);
184
- console.error(_context2.t0);
185
- throw new Error("Error parsing URL: ".concat(pluginDefinition.esmUrl));
186
-
187
- case 8:
188
- if (!(parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:')) {
189
- _context2.next = 10;
190
- break;
191
- }
192
-
193
- throw new Error("cannot load plugins using protocol \"".concat(parsedUrl.protocol, "\""));
194
-
195
- case 10:
196
- _context2.next = 12;
197
- return (_this$fetchESM = this.fetchESM) === null || _this$fetchESM === void 0 ? void 0 : _this$fetchESM.call(this, parsedUrl.href);
198
-
199
- case 12:
200
- plugin = _context2.sent;
201
-
202
- if (plugin) {
203
- _context2.next = 15;
204
- break;
205
- }
206
-
207
- throw new Error("Could not load ESM plugin: ".concat(parsedUrl));
208
-
209
- case 15:
210
- return _context2.abrupt("return", plugin);
211
-
212
- case 16:
213
- case "end":
214
- return _context2.stop();
215
- }
216
- }
217
- }, _callee2, this, [[0, 4]]);
218
- }));
219
-
220
- function loadESMPlugin(_x2) {
221
- return _loadESMPlugin.apply(this, arguments);
222
- }
223
-
224
- return loadESMPlugin;
225
- }()
226
- }, {
227
- key: "loadUMDPlugin",
228
- value: function () {
229
- var _loadUMDPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(pluginDefinition) {
230
- var umdUrl, parsedUrl, moduleName, umdName, globalObject, plugin;
231
- return _regenerator.default.wrap(function _callee3$(_context3) {
232
- while (1) {
233
- switch (_context3.prev = _context3.next) {
234
- case 0:
235
- umdUrl = 'url' in pluginDefinition ? pluginDefinition.url : pluginDefinition.umdUrl;
236
- _context3.prev = 1;
237
- parsedUrl = new URL(umdUrl, getGlobalObject().location.href);
238
- _context3.next = 9;
239
- break;
240
-
241
- case 5:
242
- _context3.prev = 5;
243
- _context3.t0 = _context3["catch"](1);
244
- console.error(_context3.t0);
245
- throw new Error("Error parsing URL: ".concat(umdUrl));
246
-
247
- case 9:
248
- if (!(parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:')) {
249
- _context3.next = 11;
250
- break;
56
+ loadScript(scriptUrl) {
57
+ const globalObject = getGlobalObject();
58
+ if (!isInWebWorker(globalObject)) {
59
+ return (0, load_script2_1.default)(scriptUrl);
60
+ }
61
+ // @ts-ignore
62
+ if (globalObject && globalObject.importScripts) {
63
+ return new Promise((resolve, reject) => {
64
+ try {
65
+ // @ts-ignore
66
+ globalObject.importScripts(scriptUrl);
251
67
  }
252
-
253
- throw new Error("cannot load plugins using protocol \"".concat(parsedUrl.protocol, "\""));
254
-
255
- case 11:
256
- _context3.next = 13;
257
- return this.loadScript(parsedUrl.href);
258
-
259
- case 13:
260
- moduleName = pluginDefinition.name;
261
- umdName = "JBrowsePlugin".concat(moduleName);
262
- globalObject = getGlobalObject(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
263
-
264
- plugin = globalObject[umdName];
265
-
266
- if (plugin) {
267
- _context3.next = 19;
268
- break;
68
+ catch (error) {
69
+ reject(error || new Error(`failed to load ${scriptUrl}`));
70
+ return;
269
71
  }
270
-
271
- throw new Error("Failed to load UMD bundle for ".concat(moduleName, ", ").concat(globalObject.constructor.name, ".").concat(umdName, " is undefined"));
272
-
273
- case 19:
274
- return _context3.abrupt("return", plugin);
275
-
276
- case 20:
277
- case "end":
278
- return _context3.stop();
279
- }
280
- }
281
- }, _callee3, this, [[1, 5]]);
282
- }));
283
-
284
- function loadUMDPlugin(_x3) {
285
- return _loadUMDPlugin.apply(this, arguments);
286
- }
287
-
288
- return loadUMDPlugin;
289
- }()
290
- }, {
291
- key: "loadPlugin",
292
- value: function () {
293
- var _loadPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(definition) {
294
- var plugin;
295
- return _regenerator.default.wrap(function _callee4$(_context4) {
296
- while (1) {
297
- switch (_context4.prev = _context4.next) {
298
- case 0:
299
- if (!(_util.isElectron && isCJSPluginDefinition(definition))) {
300
- _context4.next = 6;
301
- break;
302
- }
303
-
304
- _context4.next = 3;
305
- return this.loadCJSPlugin(definition);
306
-
307
- case 3:
308
- plugin = _context4.sent;
309
- _context4.next = 23;
310
- break;
311
-
312
- case 6:
313
- if (!isESMPluginDefinition(definition)) {
314
- _context4.next = 12;
315
- break;
316
- }
317
-
318
- _context4.next = 9;
319
- return this.loadESMPlugin(definition);
320
-
321
- case 9:
322
- plugin = _context4.sent;
323
- _context4.next = 23;
324
- break;
325
-
326
- case 12:
327
- if (!isUMDPluginDefinition(definition)) {
328
- _context4.next = 18;
329
- break;
330
- }
331
-
332
- _context4.next = 15;
333
- return this.loadUMDPlugin(definition);
334
-
335
- case 15:
336
- plugin = _context4.sent;
337
- _context4.next = 23;
338
- break;
339
-
340
- case 18:
341
- if (!(!_util.isElectron && isCJSPluginDefinition(definition))) {
342
- _context4.next = 22;
343
- break;
344
- }
345
-
346
- throw new Error("Only CommonJS plugin found, but not in a NodeJS environment: ".concat(JSON.stringify(definition)));
347
-
348
- case 22:
349
- throw new Error("Could not determine plugin type: ".concat(JSON.stringify(definition)));
350
-
351
- case 23:
352
- return _context4.abrupt("return", plugin.default);
353
-
354
- case 24:
355
- case "end":
356
- return _context4.stop();
357
- }
358
- }
359
- }, _callee4, this);
360
- }));
361
-
362
- function loadPlugin(_x4) {
363
- return _loadPlugin.apply(this, arguments);
364
- }
365
-
366
- return loadPlugin;
367
- }()
368
- }, {
369
- key: "installGlobalReExports",
370
- value: function installGlobalReExports(target) {
371
- // @ts-ignore
372
- target.JBrowseExports = Object.fromEntries(Object.entries(_ReExports.default).map(function (_ref2) {
373
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
374
- moduleName = _ref3[0],
375
- module = _ref3[1];
376
-
377
- return [moduleName, module];
378
- }));
72
+ resolve();
73
+ });
74
+ }
75
+ throw new Error('cannot figure out how to load external JS scripts in this environment');
76
+ }
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
+ }
86
+ if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
87
+ throw new Error(`Cannot load plugins using protocol "${parsedUrl.protocol}"`);
88
+ }
89
+ if (!this.fetchCJS) {
90
+ throw new Error('No fetchCJS callback provided');
91
+ }
92
+ return this.fetchCJS(parsedUrl.href);
93
+ }
94
+ async loadESMPlugin(pluginDefinition) {
95
+ 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
+ }
104
+ if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
105
+ throw new Error(`cannot load plugins using protocol "${parsedUrl.protocol}"`);
106
+ }
107
+ const plugin = (await ((_a = this.fetchESM) === null || _a === void 0 ? void 0 : _a.call(this, parsedUrl.href)));
108
+ if (!plugin) {
109
+ throw new Error(`Could not load ESM plugin: ${parsedUrl}`);
110
+ }
111
+ return plugin;
379
112
  }
380
- }, {
381
- key: "load",
382
- value: function () {
383
- var _load = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
384
- var _this = this;
385
-
386
- return _regenerator.default.wrap(function _callee6$(_context6) {
387
- while (1) {
388
- switch (_context6.prev = _context6.next) {
389
- case 0:
390
- return _context6.abrupt("return", Promise.all(this.definitions.map( /*#__PURE__*/function () {
391
- var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(definition) {
392
- return _regenerator.default.wrap(function _callee5$(_context5) {
393
- while (1) {
394
- switch (_context5.prev = _context5.next) {
395
- case 0:
396
- _context5.next = 2;
397
- return _this.loadPlugin(definition);
398
-
399
- case 2:
400
- _context5.t0 = _context5.sent;
401
- _context5.t1 = definition;
402
- return _context5.abrupt("return", {
403
- plugin: _context5.t0,
404
- definition: _context5.t1
405
- });
406
-
407
- case 5:
408
- case "end":
409
- return _context5.stop();
410
- }
411
- }
412
- }, _callee5);
413
- }));
414
-
415
- return function (_x5) {
416
- return _ref4.apply(this, arguments);
417
- };
418
- }())));
419
-
420
- case 1:
421
- case "end":
422
- return _context6.stop();
423
- }
424
- }
425
- }, _callee6, this);
426
- }));
427
-
428
- function load() {
429
- return _load.apply(this, arguments);
430
- }
431
-
432
- return load;
433
- }()
434
- }]);
435
- return PluginLoader;
436
- }();
437
-
438
- exports.default = PluginLoader;
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
+ }
123
+ if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
124
+ throw new Error(`cannot load plugins using protocol "${parsedUrl.protocol}"`);
125
+ }
126
+ await this.loadScript(parsedUrl.href);
127
+ const moduleName = pluginDefinition.name;
128
+ const umdName = `JBrowsePlugin${moduleName}`;
129
+ const globalObject = getGlobalObject();
130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
131
+ const plugin = globalObject[umdName];
132
+ if (!plugin) {
133
+ throw new Error(`Failed to load UMD bundle for ${moduleName}, ${globalObject.constructor.name}.${umdName} is undefined`);
134
+ }
135
+ return plugin;
136
+ }
137
+ async loadPlugin(definition) {
138
+ let plugin;
139
+ if (util_1.isElectron && isCJSPluginDefinition(definition)) {
140
+ plugin = await this.loadCJSPlugin(definition);
141
+ }
142
+ else if (isESMPluginDefinition(definition)) {
143
+ plugin = await this.loadESMPlugin(definition);
144
+ }
145
+ else if (isUMDPluginDefinition(definition)) {
146
+ plugin = await this.loadUMDPlugin(definition);
147
+ }
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)}`);
150
+ }
151
+ else {
152
+ throw new Error(`Could not determine plugin type: ${JSON.stringify(definition)}`);
153
+ }
154
+ return plugin.default;
155
+ }
156
+ installGlobalReExports(target) {
157
+ // @ts-ignore
158
+ target.JBrowseExports = Object.fromEntries(Object.entries(ReExports_1.default).map(([moduleName, module]) => {
159
+ return [moduleName, module];
160
+ }));
161
+ }
162
+ async load() {
163
+ return Promise.all(this.definitions.map(async (definition) => ({
164
+ plugin: await this.loadPlugin(definition),
165
+ definition,
166
+ })));
167
+ }
168
+ }
169
+ exports.default = PluginLoader;
@@ -11,6 +11,7 @@ import ConnectionType from './pluggableElementTypes/ConnectionType';
11
11
  import RpcMethodType from './pluggableElementTypes/RpcMethodType';
12
12
  import InternetAccountType from './pluggableElementTypes/InternetAccountType';
13
13
  import TextSearchAdapterType from './pluggableElementTypes/TextSearchAdapterType';
14
+ import AddTrackWorkflowType from './pluggableElementTypes/AddTrackWorkflowType';
14
15
  import Plugin from './Plugin';
15
16
  import ReExports from './ReExports';
16
17
  import { PluggableElementType, PluggableElementMember } from './pluggableElementTypes';
@@ -25,7 +26,7 @@ declare class PhasedScheduler<PhaseName extends string> {
25
26
  add(phase: PhaseName, callback: Function): void;
26
27
  run(): void;
27
28
  }
28
- declare type PluggableElementTypeGroup = 'renderer' | 'adapter' | 'display' | 'track' | 'connection' | 'view' | 'widget' | 'rpc method' | 'internet account' | 'text search adapter';
29
+ declare type PluggableElementTypeGroup = 'renderer' | 'adapter' | 'display' | 'track' | 'connection' | 'view' | 'widget' | 'rpc method' | 'internet account' | 'text search adapter' | 'add track workflow';
29
30
  /** internal class that holds the info for a certain element type */
30
31
  declare class TypeRecord<ElementClass extends PluggableElementBase> {
31
32
  typeName: string;
@@ -78,6 +79,7 @@ export default class PluginManager {
78
79
  viewTypes: TypeRecord<ViewType>;
79
80
  widgetTypes: TypeRecord<WidgetType>;
80
81
  rpcMethods: TypeRecord<RpcMethodType>;
82
+ addTrackWidgets: TypeRecord<AddTrackWorkflowType>;
81
83
  internetAccountTypes: TypeRecord<InternetAccountType>;
82
84
  configured: boolean;
83
85
  rootModel?: AbstractRootModel;
@@ -97,7 +99,7 @@ export default class PluginManager {
97
99
  getElementType(groupName: PluggableElementTypeGroup, typeName: string): PluggableElementBase;
98
100
  getElementTypesInGroup(groupName: PluggableElementTypeGroup): PluggableElementBase[];
99
101
  /** get a MST type for the union of all specified pluggable MST types */
100
- pluggableMstType(typeGroup: PluggableElementTypeGroup, fieldName: PluggableElementMember, fallback?: IAnyType): IAnyType;
102
+ pluggableMstType(groupName: PluggableElementTypeGroup, fieldName: PluggableElementMember, fallback?: IAnyType): IAnyType;
101
103
  /** get a MST type for the union of all specified pluggable config schemas */
102
104
  pluggableConfigSchemaType(typeGroup: PluggableElementTypeGroup, fieldName?: PluggableElementMember): IAnyModelType;
103
105
  jbrequireCache: Map<any, any>;
@@ -210,7 +212,6 @@ export default class PluginManager {
210
212
  'react-dom': typeof import("react-dom");
211
213
  'mobx-react': typeof import("mobx-react");
212
214
  '@mui/x-data-grid': {
213
- DataGrid: any;
214
215
  useGridApiContext: typeof import("@mui/x-data-grid").useGridApiContext;
215
216
  useGridApiRef: <Api extends import("@mui/x-data-grid").GridApiCommon = import("@mui/x-data-grid/models/api/gridApiCommunity").GridApiCommunity>() => import("react").MutableRefObject<Api>;
216
217
  useGridRootProps: () => import("@mui/x-data-grid/models/props/DataGridProps").DataGridProcessedProps<any>;
@@ -262,20 +263,22 @@ export default class PluginManager {
262
263
  getTrackType(typeName: string): TrackType;
263
264
  getDisplayType(typeName: string): DisplayType;
264
265
  getViewType(typeName: string): ViewType;
266
+ getAddTrackWorkflow(typeName: string): AddTrackWorkflowType;
265
267
  getWidgetType(typeName: string): WidgetType;
266
268
  getConnectionType(typeName: string): ConnectionType;
267
269
  getRpcMethodType(methodName: string): RpcMethodType;
268
- getInternetAccountType(internetAccountName: string): InternetAccountType;
269
- addRendererType(creationCallback: (pluginManager: PluginManager) => RendererType): this;
270
- addAdapterType(creationCallback: (pluginManager: PluginManager) => AdapterType): this;
271
- addTextSearchAdapterType(creationCallback: (pluginManager: PluginManager) => TextSearchAdapterType): this;
272
- addTrackType(creationCallback: (pluginManager: PluginManager) => TrackType): this;
273
- addDisplayType(creationCallback: (pluginManager: PluginManager) => DisplayType): this;
274
- addViewType(creationCallback: (pluginManager: PluginManager) => ViewType): this;
275
- addWidgetType(creationCallback: (pluginManager: PluginManager) => WidgetType): this;
276
- addConnectionType(creationCallback: (pluginManager: PluginManager) => ConnectionType): this;
277
- addRpcMethod(creationCallback: (pluginManager: PluginManager) => RpcMethodType): this;
278
- addInternetAccountType(creationCallback: (pluginManager: PluginManager) => InternetAccountType): this;
270
+ getInternetAccountType(name: string): InternetAccountType;
271
+ addRendererType(cb: (pm: PluginManager) => RendererType): this;
272
+ addAdapterType(cb: (pm: PluginManager) => AdapterType): this;
273
+ addTextSearchAdapterType(cb: (pm: PluginManager) => TextSearchAdapterType): this;
274
+ addTrackType(cb: (pm: PluginManager) => TrackType): this;
275
+ addDisplayType(cb: (pluginManager: PluginManager) => DisplayType): this;
276
+ addViewType(cb: (pluginManager: PluginManager) => ViewType): this;
277
+ addWidgetType(cb: (pm: PluginManager) => WidgetType): this;
278
+ addConnectionType(cb: (pm: PluginManager) => ConnectionType): this;
279
+ addRpcMethod(cb: (pm: PluginManager) => RpcMethodType): this;
280
+ addInternetAccountType(cb: (pm: PluginManager) => InternetAccountType): this;
281
+ addAddTrackWorkflowType(cb: (pm: PluginManager) => AddTrackWorkflowType): this;
279
282
  addToExtensionPoint<T>(extensionPointName: string, callback: (extendee: T) => T): void;
280
283
  evaluateExtensionPoint(extensionPointName: string, extendee: unknown): unknown;
281
284
  evaluateAsyncExtensionPoint(extensionPointName: string, extendee: unknown): Promise<unknown>;