@jbrowse/core 1.7.11 → 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.
- package/BaseFeatureWidget/BaseFeatureDetail.d.ts +20 -4
- package/BaseFeatureWidget/BaseFeatureDetail.js +313 -558
- package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -473
- package/BaseFeatureWidget/index.d.ts +2 -2
- package/BaseFeatureWidget/index.js +88 -124
- package/BaseFeatureWidget/types.d.ts +1 -0
- package/BaseFeatureWidget/types.js +1 -4
- package/BaseFeatureWidget/util.js +40 -75
- package/CorePlugin.js +55 -94
- package/Plugin.js +9 -34
- package/PluginLoader.js +153 -422
- package/PluginManager.d.ts +84 -117
- package/PluginManager.js +377 -666
- package/ReExports/Attributes.d.ts +2 -0
- package/ReExports/Attributes.js +5 -0
- package/ReExports/BaseCard.d.ts +2 -0
- package/ReExports/BaseCard.js +5 -0
- package/ReExports/DataGrid.d.ts +2 -0
- package/ReExports/DataGrid.js +6 -0
- package/ReExports/FeatureDetails.d.ts +2 -0
- package/ReExports/FeatureDetails.js +5 -0
- package/ReExports/index.js +6 -12
- package/ReExports/list.d.ts +5 -0
- package/ReExports/list.js +271 -7
- package/ReExports/material-ui-colors.d.ts +1 -19
- package/ReExports/material-ui-colors.js +16 -158
- package/ReExports/modules.d.ts +68 -109
- package/ReExports/modules.js +455 -244
- package/TextSearch/BaseResults.js +51 -123
- package/TextSearch/TextSearchManager.d.ts +3 -1
- package/TextSearch/TextSearchManager.js +66 -144
- package/assemblyManager/assembly.js +280 -554
- package/assemblyManager/assemblyConfigSchema.js +47 -64
- package/assemblyManager/assemblyManager.d.ts +12 -10
- package/assemblyManager/assemblyManager.js +126 -270
- package/assemblyManager/index.js +9 -22
- package/configuration/configurationSchema.js +167 -203
- package/configuration/configurationSlot.js +248 -326
- package/configuration/index.js +19 -35
- package/configuration/util.d.ts +1 -1
- package/configuration/util.js +131 -173
- package/data_adapters/BaseAdapter.d.ts +2 -2
- package/data_adapters/BaseAdapter.js +132 -521
- package/data_adapters/CytobandAdapter.js +40 -126
- package/data_adapters/dataAdapterCache.js +77 -158
- package/package.json +16 -18
- package/pluggableElementTypes/AdapterType.js +24 -79
- package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
- package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
- package/pluggableElementTypes/ConnectionType.js +22 -65
- package/pluggableElementTypes/DisplayType.js +35 -82
- package/pluggableElementTypes/InternetAccountType.js +23 -64
- package/pluggableElementTypes/PluggableElementBase.js +8 -20
- package/pluggableElementTypes/RpcMethodType.js +85 -427
- package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
- package/pluggableElementTypes/TrackType.js +26 -70
- package/pluggableElementTypes/ViewType.js +21 -63
- package/pluggableElementTypes/WidgetType.js +21 -64
- package/pluggableElementTypes/index.d.ts +4 -3
- package/pluggableElementTypes/index.js +42 -125
- package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
- package/pluggableElementTypes/models/BaseDisplayModel.d.ts +10 -10
- package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
- package/pluggableElementTypes/models/BaseTrackModel.d.ts +1 -1
- package/pluggableElementTypes/models/BaseTrackModel.js +139 -200
- package/pluggableElementTypes/models/BaseViewModel.js +24 -40
- package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
- package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
- package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
- package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
- package/pluggableElementTypes/models/index.js +21 -70
- package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
- package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
- package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
- package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -255
- package/pluggableElementTypes/renderers/RendererType.js +31 -105
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
- package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +2 -2
- package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
- package/pluggableElementTypes/renderers/index.js +19 -62
- package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
- package/rpc/BaseRpcDriver.js +169 -405
- package/rpc/MainThreadRpcDriver.js +27 -150
- package/rpc/RpcManager.js +58 -159
- package/rpc/WebWorkerRpcDriver.js +54 -171
- package/rpc/configSchema.js +25 -49
- package/rpc/coreRpcMethods.d.ts +1 -3
- package/rpc/coreRpcMethods.js +221 -959
- package/rpc/remoteAbortSignals.js +46 -70
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/AboutDialog.js +107 -158
- package/ui/App.js +157 -261
- package/ui/AssemblySelector.d.ts +1 -1
- package/ui/AssemblySelector.js +59 -115
- package/ui/CascadingMenu.js +100 -199
- package/ui/ColorPicker.d.ts +16 -0
- package/ui/ColorPicker.js +97 -0
- package/ui/Drawer.js +28 -58
- package/ui/DrawerWidget.js +109 -209
- package/ui/DropDownMenu.d.ts +0 -8
- package/ui/DropDownMenu.js +60 -97
- package/ui/EditableTypography.d.ts +1 -1
- package/ui/EditableTypography.js +87 -155
- package/ui/ErrorMessage.js +41 -66
- package/ui/FactoryResetDialog.js +24 -57
- package/ui/FatalErrorDialog.js +59 -91
- package/ui/FileSelector/FileSelector.js +123 -189
- package/ui/FileSelector/LocalFileChooser.js +44 -71
- package/ui/FileSelector/UrlChooser.js +17 -38
- package/ui/FileSelector/index.js +6 -12
- package/ui/Icons.d.ts +1 -1
- package/ui/Icons.js +45 -69
- package/ui/Logo.js +57 -110
- package/ui/Menu.d.ts +1 -1
- package/ui/Menu.js +232 -355
- package/ui/PrerenderedCanvas.js +63 -78
- package/ui/ResizeHandle.js +87 -114
- package/ui/ReturnToImportFormDialog.js +32 -59
- package/ui/SanitizedHTML.js +63 -52
- package/ui/Snackbar.js +74 -99
- package/ui/SnackbarModel.js +37 -51
- package/ui/Tooltip.d.ts +3 -1
- package/ui/Tooltip.js +49 -74
- package/ui/ViewContainer.js +113 -183
- package/ui/colors.d.ts +10 -0
- package/ui/colors.js +78 -0
- package/ui/index.js +51 -181
- package/ui/react-colorful.d.ts +17 -0
- package/ui/react-colorful.js +455 -0
- package/ui/theme.d.ts +279 -131
- package/ui/theme.js +197 -225
- package/util/Base1DUtils.d.ts +32 -0
- package/util/Base1DUtils.js +174 -0
- package/util/Base1DViewModel.d.ts +16 -37
- package/util/Base1DViewModel.js +116 -295
- package/util/QuickLRU.js +84 -332
- package/util/TimeTraveller.d.ts +19 -0
- package/util/TimeTraveller.js +86 -0
- package/util/aborting.js +49 -127
- package/util/analytics.js +91 -154
- package/util/blockTypes.js +106 -240
- package/util/calculateDynamicBlocks.js +98 -128
- package/util/calculateStaticBlocks.js +105 -125
- package/util/color/cssColorsLevel4.js +156 -160
- package/util/color/index.js +33 -55
- package/util/compositeMap.js +49 -333
- package/util/formatFastaStrings.js +9 -14
- package/util/idMaker.js +18 -31
- package/util/index.d.ts +18 -39
- package/util/index.js +743 -1236
- package/util/io/RemoteFileWithRangeCache.js +88 -257
- package/util/io/index.js +95 -169
- package/util/jexl.js +60 -115
- package/util/jexlStrings.js +24 -29
- package/util/layouts/BaseLayout.js +1 -4
- package/util/layouts/GranularRectLayout.js +388 -557
- package/util/layouts/MultiLayout.js +41 -109
- package/util/layouts/PrecomputedLayout.js +56 -114
- package/util/layouts/PrecomputedMultiLayout.js +22 -59
- package/util/layouts/SceneGraph.js +127 -197
- package/util/layouts/index.js +29 -66
- package/util/mst-reflection.js +55 -71
- package/util/offscreenCanvasPonyfill.js +66 -134
- package/util/offscreenCanvasUtils.d.ts +2 -7
- package/util/offscreenCanvasUtils.js +49 -146
- package/util/range.js +29 -40
- package/util/rxjs.js +20 -27
- package/util/simpleFeature.js +88 -152
- package/util/stats.js +91 -151
- package/util/tracks.js +130 -171
- package/util/types/index.d.ts +3 -3
- package/util/types/index.js +110 -179
- package/util/types/mst.d.ts +3 -3
- package/util/types/mst.js +91 -142
- package/util/types/util.js +1 -4
- package/util/when.js +54 -101
- package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
- package/BaseFeatureWidget/index.test.js +0 -51
- package/TextSearch/BaseResults.test.js +0 -42
- package/configuration/configurationSchema.test.js +0 -266
- package/configuration/configurationSlot.test.js +0 -69
- package/configuration/util.test.js +0 -39
- package/data_adapters/BaseAdapter.test.js +0 -200
- package/declare.d.js +0 -1
- package/pluggableElementTypes/RpcMethodType.test.js +0 -118
- package/pluggableElementTypes/renderers/declare.d.js +0 -1
- package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
- package/rpc/BaseRpcDriver.test.js +0 -540
- package/rpc/declaration.d.js +0 -1
- package/ui/FatalErrorDialog.test.js +0 -82
- package/ui/SanitizedHTML.test.js +0 -36
- package/ui/theme.test.js +0 -111
- package/util/Base1DViewModel.test.js +0 -130
- package/util/calculateDynamicBlocks.test.js +0 -74
- package/util/calculateStaticBlocks.test.js +0 -297
- package/util/declare.d.js +0 -1
- package/util/formatFastaStrings.test.js +0 -40
- package/util/index.test.js +0 -213
- package/util/jexlStrings.test.js +0 -48
- package/util/layouts/GranularRectLayout.test.js +0 -99
- package/util/range.test.js +0 -64
- package/util/simpleFeature.test.js +0 -34
- package/util/stats.test.js +0 -172
package/PluginLoader.js
CHANGED
|
@@ -1,438 +1,169 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
+
return pluginDefinition.esmUrl !== undefined;
|
|
53
30
|
}
|
|
54
|
-
|
|
31
|
+
exports.isESMPluginDefinition = isESMPluginDefinition;
|
|
55
32
|
function isCJSPluginDefinition(pluginDefinition) {
|
|
56
|
-
|
|
33
|
+
return pluginDefinition.cjsUrl !== undefined;
|
|
57
34
|
}
|
|
58
|
-
|
|
35
|
+
exports.isCJSPluginDefinition = isCJSPluginDefinition;
|
|
59
36
|
function getGlobalObject() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
47
|
+
return Boolean('WorkerGlobalScope' in globalObject);
|
|
70
48
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
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;
|