@jbrowse/core 1.4.1 → 1.5.2

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 (159) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +4 -4
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +27 -8
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +10 -10
  4. package/BaseFeatureWidget/index.js +1 -1
  5. package/BaseFeatureWidget/types.d.ts +1 -1
  6. package/BaseFeatureWidget/util.js +3 -3
  7. package/CorePlugin.d.ts +0 -1
  8. package/CorePlugin.js +13 -1
  9. package/PluginLoader.d.ts +26 -4
  10. package/PluginLoader.js +337 -51
  11. package/PluginManager.d.ts +18 -11
  12. package/PluginManager.js +53 -31
  13. package/ReExports/list.js +1 -1
  14. package/ReExports/material-ui-colors.js +38 -38
  15. package/ReExports/modules.d.ts +19 -20
  16. package/ReExports/modules.js +10 -3
  17. package/TextSearch/BaseResults.d.ts +5 -14
  18. package/TextSearch/BaseResults.js +16 -58
  19. package/TextSearch/BaseResults.test.js +1 -11
  20. package/TextSearch/TextSearchManager.d.ts +3 -3
  21. package/TextSearch/TextSearchManager.js +1 -1
  22. package/assemblyManager/assembly.d.ts +21 -8
  23. package/assemblyManager/assembly.js +163 -120
  24. package/assemblyManager/assemblyConfigSchema.d.ts +3 -0
  25. package/assemblyManager/{assemblyConfigSchemas.js → assemblyConfigSchema.js} +35 -27
  26. package/assemblyManager/assemblyManager.d.ts +169 -60
  27. package/assemblyManager/index.d.ts +1 -1
  28. package/assemblyManager/index.js +5 -5
  29. package/configuration/configurationSchema.d.ts +3 -2
  30. package/configuration/configurationSchema.js +7 -10
  31. package/configuration/configurationSchema.test.js +4 -2
  32. package/configuration/configurationSlot.js +5 -4
  33. package/configuration/index.js +4 -4
  34. package/configuration/util.js +5 -5
  35. package/data_adapters/BaseAdapter.d.ts +5 -3
  36. package/data_adapters/BaseAdapter.js +7 -4
  37. package/data_adapters/BaseAdapter.test.js +4 -2
  38. package/data_adapters/CytobandAdapter.d.ts +8 -0
  39. package/data_adapters/CytobandAdapter.js +128 -0
  40. package/data_adapters/dataAdapterCache.js +3 -3
  41. package/package.json +7 -6
  42. package/pluggableElementTypes/AdapterType.d.ts +9 -1
  43. package/pluggableElementTypes/AdapterType.js +20 -0
  44. package/pluggableElementTypes/InternetAccountType.d.ts +12 -0
  45. package/pluggableElementTypes/InternetAccountType.js +64 -0
  46. package/pluggableElementTypes/PluggableElementBase.d.ts +1 -2
  47. package/pluggableElementTypes/PluggableElementBase.js +2 -3
  48. package/pluggableElementTypes/RpcMethodType.d.ts +3 -0
  49. package/pluggableElementTypes/RpcMethodType.js +269 -26
  50. package/pluggableElementTypes/RpcMethodType.test.d.ts +4 -0
  51. package/pluggableElementTypes/RpcMethodType.test.js +118 -0
  52. package/pluggableElementTypes/ViewType.d.ts +1 -1
  53. package/pluggableElementTypes/WidgetType.d.ts +1 -0
  54. package/pluggableElementTypes/index.d.ts +7 -3
  55. package/pluggableElementTypes/index.js +127 -1
  56. package/pluggableElementTypes/models/BaseDisplayModel.d.ts +6 -6
  57. package/pluggableElementTypes/models/BaseDisplayModel.js +1 -3
  58. package/pluggableElementTypes/models/BaseViewModel.js +13 -15
  59. package/pluggableElementTypes/models/InternetAccountModel.d.ts +24 -0
  60. package/pluggableElementTypes/models/InternetAccountModel.js +85 -0
  61. package/pluggableElementTypes/models/baseInternetAccountConfig.d.ts +4 -0
  62. package/pluggableElementTypes/models/baseInternetAccountConfig.js +25 -0
  63. package/pluggableElementTypes/models/index.d.ts +3 -0
  64. package/pluggableElementTypes/models/index.js +24 -8
  65. package/pluggableElementTypes/renderers/BoxRendererType.js +1 -1
  66. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.d.ts +1 -1
  67. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +15 -6
  68. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +3 -3
  69. package/pluggableElementTypes/renderers/FeatureRendererType.js +17 -8
  70. package/pluggableElementTypes/renderers/RendererType.d.ts +1 -0
  71. package/pluggableElementTypes/renderers/RendererType.js +4 -1
  72. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +1 -1
  73. package/pluggableElementTypes/renderers/index.d.ts +9 -0
  74. package/pluggableElementTypes/renderers/index.js +63 -0
  75. package/rpc/BaseRpcDriver.js +5 -9
  76. package/rpc/BaseRpcDriver.test.js +6 -6
  77. package/rpc/RpcManager.d.ts +1 -1
  78. package/rpc/RpcManager.js +44 -16
  79. package/rpc/WebWorkerRpcDriver.js +3 -3
  80. package/rpc/coreRpcMethods.d.ts +2 -1
  81. package/rpc/coreRpcMethods.js +109 -75
  82. package/rpc/remoteAbortSignals.js +2 -2
  83. package/ui/App.d.ts +17 -4
  84. package/ui/App.js +55 -41
  85. package/ui/Drawer.d.ts +6 -14
  86. package/ui/Drawer.js +11 -12
  87. package/ui/DrawerWidget.d.ts +5 -3
  88. package/ui/DrawerWidget.js +100 -61
  89. package/ui/ErrorMessage.d.ts +5 -0
  90. package/ui/ErrorMessage.js +54 -0
  91. package/ui/FileSelector/FileSelector.d.ts +11 -0
  92. package/ui/FileSelector/FileSelector.js +198 -0
  93. package/ui/FileSelector/LocalFileChooser.d.ts +7 -0
  94. package/ui/FileSelector/LocalFileChooser.js +79 -0
  95. package/ui/FileSelector/UrlChooser.d.ts +9 -0
  96. package/ui/FileSelector/UrlChooser.js +41 -0
  97. package/ui/FileSelector/index.d.ts +2 -0
  98. package/ui/FileSelector/index.js +13 -0
  99. package/ui/Icons.d.ts +4 -0
  100. package/ui/Icons.js +34 -0
  101. package/ui/Logo.js +1 -1
  102. package/ui/PrerenderedCanvas.d.ts +1 -0
  103. package/ui/PrerenderedCanvas.js +4 -1
  104. package/ui/ResizeHandle.d.ts +2 -3
  105. package/ui/ResizeHandle.js +6 -7
  106. package/ui/SanitizedHTML.js +1 -1
  107. package/ui/Snackbar.js +4 -6
  108. package/ui/SnackbarModel.d.ts +16 -0
  109. package/ui/SnackbarModel.js +56 -0
  110. package/ui/Tooltip.d.ts +1 -1
  111. package/ui/index.js +24 -24
  112. package/ui/theme.js +5 -5
  113. package/util/QuickLRU.d.ts +1 -1
  114. package/util/QuickLRU.js +3 -3
  115. package/util/aborting.d.ts +1 -1
  116. package/util/aborting.js +10 -11
  117. package/util/analytics.d.ts +2 -2
  118. package/util/analytics.js +20 -7
  119. package/util/blockTypes.d.ts +11 -6
  120. package/util/blockTypes.js +7 -1
  121. package/util/color/cssColorsLevel4.js +1 -1
  122. package/util/color/index.js +5 -5
  123. package/util/compositeMap.js +3 -3
  124. package/util/index.d.ts +6 -16
  125. package/util/index.js +76 -100
  126. package/util/io/RemoteFileWithRangeCache.d.ts +17 -0
  127. package/util/io/RemoteFileWithRangeCache.js +266 -0
  128. package/util/io/index.d.ts +4 -2
  129. package/util/io/index.js +134 -25
  130. package/util/jexl.js +4 -1
  131. package/util/layouts/BaseLayout.d.ts +3 -0
  132. package/util/layouts/GranularRectLayout.d.ts +19 -10
  133. package/util/layouts/GranularRectLayout.js +459 -100
  134. package/util/layouts/GranularRectLayout.test.js +57 -10
  135. package/util/layouts/PrecomputedLayout.js +2 -1
  136. package/util/layouts/index.d.ts +7 -0
  137. package/util/layouts/index.js +68 -0
  138. package/util/mst-reflection.js +3 -3
  139. package/util/offscreenCanvasPonyfill.js +1 -1
  140. package/util/range.js +1 -1
  141. package/util/simpleFeature.js +1 -1
  142. package/util/stats.js +2 -2
  143. package/util/tracks.d.ts +31 -362
  144. package/util/tracks.js +74 -190
  145. package/util/types/index.d.ts +54 -10
  146. package/util/types/index.js +110 -8
  147. package/util/types/mst.d.ts +46 -2
  148. package/util/types/mst.js +56 -8
  149. package/util/types/util.d.ts +1 -1
  150. package/util/when.js +1 -1
  151. package/assemblyManager/assemblyConfigSchemas.d.ts +0 -7
  152. package/ui/FileSelector.d.ts +0 -9
  153. package/ui/FileSelector.js +0 -150
  154. package/util/io/LocalFile.d.ts +0 -18
  155. package/util/io/LocalFile.js +0 -220
  156. package/util/io/rangeFetcher.d.ts +0 -3
  157. package/util/io/rangeFetcher.js +0 -236
  158. package/value.d.ts +0 -1
  159. package/value.js +0 -10
package/PluginLoader.js CHANGED
@@ -2,17 +2,20 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.default = exports.PluginSourceConfigurationSchema = void 0;
11
+ exports.isCJSPluginDefinition = isCJSPluginDefinition;
12
+ exports.isESMPluginDefinition = isESMPluginDefinition;
13
+ exports.isUMDPluginDefinition = isUMDPluginDefinition;
9
14
 
10
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
16
 
12
17
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
18
 
14
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
-
16
19
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
20
 
18
21
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -21,15 +24,22 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
21
24
 
22
25
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
26
 
24
- var _url = _interopRequireDefault(require("url"));
27
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
25
28
 
26
29
  var _loadScript = _interopRequireDefault(require("load-script2"));
27
30
 
31
+ var _sanitizeFilename = _interopRequireDefault(require("sanitize-filename"));
32
+
28
33
  var _configuration = require("./configuration");
29
34
 
30
35
  var _ReExports = _interopRequireDefault(require("./ReExports"));
31
36
 
32
- /* eslint-disable no-restricted-globals */
37
+ var _util = require("./util");
38
+
39
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
40
+
41
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
42
+
33
43
  var PluginSourceConfigurationSchema = (0, _configuration.ConfigurationSchema)('PluginSource', {
34
44
  name: {
35
45
  type: 'string',
@@ -42,6 +52,32 @@ var PluginSourceConfigurationSchema = (0, _configuration.ConfigurationSchema)('P
42
52
  });
43
53
  exports.PluginSourceConfigurationSchema = PluginSourceConfigurationSchema;
44
54
 
55
+ function isUMDPluginDefinition(pluginDefinition) {
56
+ return (pluginDefinition.umdUrl !== undefined || pluginDefinition.url !== undefined) && pluginDefinition.name !== undefined;
57
+ }
58
+
59
+ function isESMPluginDefinition(pluginDefinition) {
60
+ return pluginDefinition.esmUrl !== undefined;
61
+ }
62
+
63
+ function isCJSPluginDefinition(pluginDefinition) {
64
+ return pluginDefinition.cjsUrl !== undefined;
65
+ }
66
+
67
+ function getGlobalObject() {
68
+ // Based on window-or-global
69
+ // https://github.com/purposeindustries/window-or-global/blob/322abc71de0010c9e5d9d0729df40959e1ef8775/lib/index.js
70
+ return (
71
+ /* eslint-disable-next-line no-restricted-globals */
72
+ (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
73
+ this
74
+ );
75
+ }
76
+
77
+ function isInWebWorker(globalObject) {
78
+ return Boolean('WorkerGlobalScope' in globalObject);
79
+ }
80
+
45
81
  var PluginLoader = /*#__PURE__*/function () {
46
82
  function PluginLoader() {
47
83
  var pluginDefinitions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -53,16 +89,18 @@ var PluginLoader = /*#__PURE__*/function () {
53
89
  (0, _createClass2.default)(PluginLoader, [{
54
90
  key: "loadScript",
55
91
  value: function loadScript(scriptUrl) {
56
- if (document && document.getElementsByTagName) {
92
+ var globalObject = getGlobalObject();
93
+
94
+ if (!isInWebWorker(globalObject)) {
57
95
  return (0, _loadScript.default)(scriptUrl);
58
96
  } // @ts-ignore
59
97
 
60
98
 
61
- if (self && self.importScripts) {
99
+ if (globalObject && globalObject.importScripts) {
62
100
  return new Promise(function (resolve, reject) {
63
101
  try {
64
102
  // @ts-ignore
65
- self.importScripts(scriptUrl);
103
+ globalObject.importScripts(scriptUrl);
66
104
  } catch (error) {
67
105
  reject(error || new Error("failed to load ".concat(scriptUrl)));
68
106
  return;
@@ -75,55 +113,305 @@ var PluginLoader = /*#__PURE__*/function () {
75
113
  throw new Error('cannot figure out how to load external JS scripts in this environment');
76
114
  }
77
115
  }, {
78
- key: "loadPlugin",
116
+ key: "loadCJSPlugin",
79
117
  value: function () {
80
- var _loadPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(definition) {
81
- var parsedUrl, moduleName, umdName, scope, plugin;
118
+ var _loadCJSPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(pluginDefinition) {
119
+ var parsedUrl, fs, path, os, http, fsPromises, systemTmp, tmpDir, plugin, pluginLocation, pluginLocationRelative, pluginDownload;
82
120
  return _regenerator.default.wrap(function _callee$(_context) {
83
121
  while (1) {
84
122
  switch (_context.prev = _context.next) {
85
123
  case 0:
86
- parsedUrl = _url.default.parse(definition.url);
124
+ _context.prev = 0;
125
+ parsedUrl = new URL(pluginDefinition.cjsUrl, getGlobalObject().location.href);
126
+ _context.next = 8;
127
+ break;
87
128
 
88
- if (!(!parsedUrl.protocol || parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:')) {
89
- _context.next = 11;
129
+ case 4:
130
+ _context.prev = 4;
131
+ _context.t0 = _context["catch"](0);
132
+ console.error(_context.t0);
133
+ throw new Error("Error parsing URL: ".concat(pluginDefinition.cjsUrl));
134
+
135
+ case 8:
136
+ if (!(parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:')) {
137
+ _context.next = 10;
138
+ break;
139
+ }
140
+
141
+ throw new Error("cannot load plugins using protocol \"".concat(parsedUrl.protocol, "\""));
142
+
143
+ case 10:
144
+ fs = require('fs');
145
+ path = require('path');
146
+ os = require('os');
147
+ http = require('http');
148
+ fsPromises = fs.promises; // On macOS `os.tmpdir()` returns the path to a symlink, see:
149
+ // https://github.com/nodejs/node/issues/11422
150
+
151
+ _context.next = 17;
152
+ return fsPromises.realpath(os.tmpdir());
153
+
154
+ case 17:
155
+ systemTmp = _context.sent;
156
+ _context.next = 20;
157
+ return fsPromises.mkdtemp(path.join(systemTmp, 'jbrowse-plugin-'));
158
+
159
+ case 20:
160
+ tmpDir = _context.sent;
161
+ plugin = undefined;
162
+ _context.prev = 22;
163
+ pluginLocation = path.join(tmpDir, (0, _sanitizeFilename.default)(parsedUrl.href));
164
+ pluginLocationRelative = path.relative('.', pluginLocation);
165
+ pluginDownload = new Promise(function (resolve, reject) {
166
+ var file = fs.createWriteStream(pluginLocation);
167
+ http.get(parsedUrl.href, function (response) {
168
+ response.pipe(file);
169
+ file.on('finish', function () {
170
+ resolve();
171
+ });
172
+ }).on('error', function (err) {
173
+ fs.unlinkSync(pluginLocation);
174
+ reject(err);
175
+ });
176
+ });
177
+ _context.next = 28;
178
+ return pluginDownload;
179
+
180
+ case 28:
181
+ plugin = __non_webpack_require__(pluginLocationRelative);
182
+
183
+ case 29:
184
+ _context.prev = 29;
185
+ fsPromises.rmdir(tmpDir, {
186
+ recursive: true
187
+ });
188
+ return _context.finish(29);
189
+
190
+ case 32:
191
+ if (plugin) {
192
+ _context.next = 34;
90
193
  break;
91
194
  }
92
195
 
93
- _context.next = 4;
94
- return this.loadScript(definition.url);
196
+ throw new Error("Could not load CJS plugin: ".concat(parsedUrl));
197
+
198
+ case 34:
199
+ return _context.abrupt("return", plugin);
200
+
201
+ case 35:
202
+ case "end":
203
+ return _context.stop();
204
+ }
205
+ }
206
+ }, _callee, null, [[0, 4], [22,, 29, 32]]);
207
+ }));
208
+
209
+ function loadCJSPlugin(_x) {
210
+ return _loadCJSPlugin.apply(this, arguments);
211
+ }
212
+
213
+ return loadCJSPlugin;
214
+ }()
215
+ }, {
216
+ key: "loadESMPlugin",
217
+ value: function () {
218
+ var _loadESMPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(pluginDefinition) {
219
+ var parsedUrl, plugin;
220
+ return _regenerator.default.wrap(function _callee2$(_context2) {
221
+ while (1) {
222
+ switch (_context2.prev = _context2.next) {
223
+ case 0:
224
+ _context2.prev = 0;
225
+ parsedUrl = new URL(pluginDefinition.esmUrl, getGlobalObject().location.href);
226
+ _context2.next = 8;
227
+ break;
95
228
 
96
229
  case 4:
97
- moduleName = definition.name;
98
- umdName = "JBrowsePlugin".concat(moduleName); // Based on window-or-global
99
- // https://github.com/purposeindustries/window-or-global/blob/322abc71de0010c9e5d9d0729df40959e1ef8775/lib/index.js
230
+ _context2.prev = 4;
231
+ _context2.t0 = _context2["catch"](0);
232
+ console.error(_context2.t0);
233
+ throw new Error("Error parsing URL: ".concat(pluginDefinition.esmUrl));
234
+
235
+ case 8:
236
+ if (!(parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:')) {
237
+ _context2.next = 10;
238
+ break;
239
+ }
100
240
 
101
- scope = (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 || this; // eslint-disable-next-line @typescript-eslint/no-explicit-any
241
+ throw new Error("cannot load plugins using protocol \"".concat(parsedUrl.protocol, "\""));
102
242
 
103
- plugin = scope[umdName];
243
+ case 10:
244
+ _context2.next = 12;
245
+ return Promise.resolve("".concat(
246
+ /* webpackIgnore: true */
247
+ parsedUrl.href)).then(function (s) {
248
+ return _interopRequireWildcard(require(s));
249
+ });
250
+
251
+ case 12:
252
+ plugin = _context2.sent;
104
253
 
105
254
  if (plugin) {
106
- _context.next = 10;
255
+ _context2.next = 15;
107
256
  break;
108
257
  }
109
258
 
110
- throw new Error("plugin ".concat(moduleName, " failed to load, ").concat(scope.constructor.name, ".").concat(umdName, " is undefined"));
259
+ throw new Error("Could not load ESM plugin: ".concat(parsedUrl));
111
260
 
112
- case 10:
113
- return _context.abrupt("return", plugin.default);
261
+ case 15:
262
+ return _context2.abrupt("return", plugin);
263
+
264
+ case 16:
265
+ case "end":
266
+ return _context2.stop();
267
+ }
268
+ }
269
+ }, _callee2, null, [[0, 4]]);
270
+ }));
271
+
272
+ function loadESMPlugin(_x2) {
273
+ return _loadESMPlugin.apply(this, arguments);
274
+ }
275
+
276
+ return loadESMPlugin;
277
+ }()
278
+ }, {
279
+ key: "loadUMDPlugin",
280
+ value: function () {
281
+ var _loadUMDPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(pluginDefinition) {
282
+ var umdUrl, parsedUrl, moduleName, umdName, globalObject, plugin;
283
+ return _regenerator.default.wrap(function _callee3$(_context3) {
284
+ while (1) {
285
+ switch (_context3.prev = _context3.next) {
286
+ case 0:
287
+ umdUrl = 'url' in pluginDefinition ? pluginDefinition.url : pluginDefinition.umdUrl;
288
+ _context3.prev = 1;
289
+ parsedUrl = new URL(umdUrl, getGlobalObject().location.href);
290
+ _context3.next = 9;
291
+ break;
292
+
293
+ case 5:
294
+ _context3.prev = 5;
295
+ _context3.t0 = _context3["catch"](1);
296
+ console.error(_context3.t0);
297
+ throw new Error("Error parsing URL: ".concat(umdUrl));
298
+
299
+ case 9:
300
+ if (!(parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:')) {
301
+ _context3.next = 11;
302
+ break;
303
+ }
114
304
 
115
- case 11:
116
305
  throw new Error("cannot load plugins using protocol \"".concat(parsedUrl.protocol, "\""));
117
306
 
307
+ case 11:
308
+ _context3.next = 13;
309
+ return this.loadScript(parsedUrl.href);
310
+
311
+ case 13:
312
+ moduleName = pluginDefinition.name;
313
+ umdName = "JBrowsePlugin".concat(moduleName);
314
+ globalObject = getGlobalObject(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
315
+
316
+ plugin = globalObject[umdName];
317
+
318
+ if (plugin) {
319
+ _context3.next = 19;
320
+ break;
321
+ }
322
+
323
+ throw new Error("Failed to load UMD bundle for ".concat(moduleName, ", ").concat(globalObject.constructor.name, ".").concat(umdName, " is undefined"));
324
+
325
+ case 19:
326
+ return _context3.abrupt("return", plugin);
327
+
328
+ case 20:
329
+ case "end":
330
+ return _context3.stop();
331
+ }
332
+ }
333
+ }, _callee3, this, [[1, 5]]);
334
+ }));
335
+
336
+ function loadUMDPlugin(_x3) {
337
+ return _loadUMDPlugin.apply(this, arguments);
338
+ }
339
+
340
+ return loadUMDPlugin;
341
+ }()
342
+ }, {
343
+ key: "loadPlugin",
344
+ value: function () {
345
+ var _loadPlugin = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(definition) {
346
+ var plugin;
347
+ return _regenerator.default.wrap(function _callee4$(_context4) {
348
+ while (1) {
349
+ switch (_context4.prev = _context4.next) {
350
+ case 0:
351
+ if (!(_util.isElectron && isCJSPluginDefinition(definition))) {
352
+ _context4.next = 6;
353
+ break;
354
+ }
355
+
356
+ _context4.next = 3;
357
+ return this.loadCJSPlugin(definition);
358
+
359
+ case 3:
360
+ plugin = _context4.sent;
361
+ _context4.next = 23;
362
+ break;
363
+
364
+ case 6:
365
+ if (!isESMPluginDefinition(definition)) {
366
+ _context4.next = 12;
367
+ break;
368
+ }
369
+
370
+ _context4.next = 9;
371
+ return this.loadESMPlugin(definition);
372
+
373
+ case 9:
374
+ plugin = _context4.sent;
375
+ _context4.next = 23;
376
+ break;
377
+
118
378
  case 12:
379
+ if (!isUMDPluginDefinition(definition)) {
380
+ _context4.next = 18;
381
+ break;
382
+ }
383
+
384
+ _context4.next = 15;
385
+ return this.loadUMDPlugin(definition);
386
+
387
+ case 15:
388
+ plugin = _context4.sent;
389
+ _context4.next = 23;
390
+ break;
391
+
392
+ case 18:
393
+ if (!(!_util.isElectron && isCJSPluginDefinition(definition))) {
394
+ _context4.next = 22;
395
+ break;
396
+ }
397
+
398
+ throw new Error("Only CommonJS plugin found, but not in a NodeJS environment: ".concat(JSON.stringify(definition)));
399
+
400
+ case 22:
401
+ throw new Error("Could not determine plugin type: ".concat(JSON.stringify(definition)));
402
+
403
+ case 23:
404
+ return _context4.abrupt("return", plugin.default);
405
+
406
+ case 24:
119
407
  case "end":
120
- return _context.stop();
408
+ return _context4.stop();
121
409
  }
122
410
  }
123
- }, _callee, this);
411
+ }, _callee4, this);
124
412
  }));
125
413
 
126
- function loadPlugin(_x) {
414
+ function loadPlugin(_x4) {
127
415
  return _loadPlugin.apply(this, arguments);
128
416
  }
129
417
 
@@ -133,62 +421,60 @@ var PluginLoader = /*#__PURE__*/function () {
133
421
  key: "installGlobalReExports",
134
422
  value: function installGlobalReExports(target) {
135
423
  // @ts-ignore
136
- target.JBrowseExports = {};
137
- Object.entries(_ReExports.default).forEach(function (_ref) {
424
+ target.JBrowseExports = Object.fromEntries(Object.entries(_ReExports.default).map(function (_ref) {
138
425
  var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
139
426
  moduleName = _ref2[0],
140
427
  module = _ref2[1];
141
428
 
142
- // @ts-ignore
143
- target.JBrowseExports[moduleName] = module;
144
- });
429
+ return [moduleName, module];
430
+ }));
145
431
  }
146
432
  }, {
147
433
  key: "load",
148
434
  value: function () {
149
- var _load = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
435
+ var _load = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
150
436
  var _this = this;
151
437
 
152
- return _regenerator.default.wrap(function _callee3$(_context3) {
438
+ return _regenerator.default.wrap(function _callee6$(_context6) {
153
439
  while (1) {
154
- switch (_context3.prev = _context3.next) {
440
+ switch (_context6.prev = _context6.next) {
155
441
  case 0:
156
- return _context3.abrupt("return", Promise.all(this.definitions.map( /*#__PURE__*/function () {
157
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(definition) {
158
- return _regenerator.default.wrap(function _callee2$(_context2) {
442
+ return _context6.abrupt("return", Promise.all(this.definitions.map( /*#__PURE__*/function () {
443
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(definition) {
444
+ return _regenerator.default.wrap(function _callee5$(_context5) {
159
445
  while (1) {
160
- switch (_context2.prev = _context2.next) {
446
+ switch (_context5.prev = _context5.next) {
161
447
  case 0:
162
- _context2.next = 2;
448
+ _context5.next = 2;
163
449
  return _this.loadPlugin(definition);
164
450
 
165
451
  case 2:
166
- _context2.t0 = _context2.sent;
167
- _context2.t1 = definition;
168
- return _context2.abrupt("return", {
169
- plugin: _context2.t0,
170
- definition: _context2.t1
452
+ _context5.t0 = _context5.sent;
453
+ _context5.t1 = definition;
454
+ return _context5.abrupt("return", {
455
+ plugin: _context5.t0,
456
+ definition: _context5.t1
171
457
  });
172
458
 
173
459
  case 5:
174
460
  case "end":
175
- return _context2.stop();
461
+ return _context5.stop();
176
462
  }
177
463
  }
178
- }, _callee2);
464
+ }, _callee5);
179
465
  }));
180
466
 
181
- return function (_x2) {
467
+ return function (_x5) {
182
468
  return _ref3.apply(this, arguments);
183
469
  };
184
470
  }())));
185
471
 
186
472
  case 1:
187
473
  case "end":
188
- return _context3.stop();
474
+ return _context6.stop();
189
475
  }
190
476
  }
191
- }, _callee3, this);
477
+ }, _callee6, this);
192
478
  }));
193
479
 
194
480
  function load() {