@jbrowse/core 2.0.0 → 2.1.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 (184) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +9 -3
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +313 -581
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -478
  4. package/BaseFeatureWidget/index.js +88 -126
  5. package/BaseFeatureWidget/types.d.ts +1 -0
  6. package/BaseFeatureWidget/types.js +1 -4
  7. package/BaseFeatureWidget/util.js +40 -75
  8. package/CorePlugin.js +55 -94
  9. package/Plugin.js +9 -34
  10. package/PluginLoader.js +153 -422
  11. package/PluginManager.d.ts +28 -33
  12. package/PluginManager.js +377 -666
  13. package/ReExports/Attributes.js +3 -10
  14. package/ReExports/BaseCard.js +3 -10
  15. package/ReExports/DataGrid.js +5 -12
  16. package/ReExports/FeatureDetails.js +3 -10
  17. package/ReExports/index.js +6 -12
  18. package/ReExports/list.d.ts +5 -0
  19. package/ReExports/list.js +271 -7
  20. package/ReExports/material-ui-colors.js +15 -16
  21. package/ReExports/modules.d.ts +11 -20
  22. package/ReExports/modules.js +453 -798
  23. package/TextSearch/BaseResults.js +51 -123
  24. package/TextSearch/TextSearchManager.js +66 -144
  25. package/assemblyManager/assembly.js +280 -555
  26. package/assemblyManager/assemblyConfigSchema.js +47 -64
  27. package/assemblyManager/assemblyManager.js +126 -272
  28. package/assemblyManager/index.js +9 -22
  29. package/configuration/configurationSchema.js +167 -203
  30. package/configuration/configurationSlot.js +248 -326
  31. package/configuration/index.js +19 -35
  32. package/configuration/util.js +131 -173
  33. package/data_adapters/BaseAdapter.d.ts +2 -2
  34. package/data_adapters/BaseAdapter.js +132 -521
  35. package/data_adapters/CytobandAdapter.js +40 -126
  36. package/data_adapters/dataAdapterCache.js +77 -158
  37. package/package.json +4 -5
  38. package/pluggableElementTypes/AdapterType.js +24 -79
  39. package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
  40. package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
  41. package/pluggableElementTypes/ConnectionType.js +22 -65
  42. package/pluggableElementTypes/DisplayType.js +35 -82
  43. package/pluggableElementTypes/InternetAccountType.js +23 -64
  44. package/pluggableElementTypes/PluggableElementBase.js +8 -20
  45. package/pluggableElementTypes/RpcMethodType.js +85 -427
  46. package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
  47. package/pluggableElementTypes/TrackType.js +26 -70
  48. package/pluggableElementTypes/ViewType.js +21 -63
  49. package/pluggableElementTypes/WidgetType.js +21 -64
  50. package/pluggableElementTypes/index.d.ts +4 -3
  51. package/pluggableElementTypes/index.js +42 -125
  52. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
  53. package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
  54. package/pluggableElementTypes/models/BaseTrackModel.js +139 -199
  55. package/pluggableElementTypes/models/BaseViewModel.js +24 -40
  56. package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
  57. package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
  58. package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
  59. package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
  60. package/pluggableElementTypes/models/index.js +21 -70
  61. package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
  62. package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
  63. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
  64. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
  65. package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -255
  66. package/pluggableElementTypes/renderers/RendererType.js +31 -105
  67. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
  68. package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
  69. package/pluggableElementTypes/renderers/index.js +19 -62
  70. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
  71. package/rpc/BaseRpcDriver.js +169 -405
  72. package/rpc/MainThreadRpcDriver.js +27 -150
  73. package/rpc/RpcManager.js +58 -159
  74. package/rpc/WebWorkerRpcDriver.js +54 -171
  75. package/rpc/configSchema.js +25 -49
  76. package/rpc/coreRpcMethods.d.ts +1 -3
  77. package/rpc/coreRpcMethods.js +221 -959
  78. package/rpc/remoteAbortSignals.js +46 -70
  79. package/tsconfig.build.tsbuildinfo +1 -1
  80. package/ui/AboutDialog.js +106 -162
  81. package/ui/App.js +157 -242
  82. package/ui/AssemblySelector.js +59 -120
  83. package/ui/CascadingMenu.js +101 -196
  84. package/ui/ColorPicker.d.ts +16 -0
  85. package/ui/ColorPicker.js +97 -0
  86. package/ui/Drawer.js +28 -61
  87. package/ui/DrawerWidget.js +108 -202
  88. package/ui/DropDownMenu.js +60 -91
  89. package/ui/EditableTypography.js +87 -149
  90. package/ui/ErrorMessage.js +41 -56
  91. package/ui/FactoryResetDialog.js +24 -57
  92. package/ui/FatalErrorDialog.js +59 -91
  93. package/ui/FileSelector/FileSelector.js +123 -189
  94. package/ui/FileSelector/LocalFileChooser.js +44 -75
  95. package/ui/FileSelector/UrlChooser.js +17 -38
  96. package/ui/FileSelector/index.js +6 -12
  97. package/ui/Icons.js +45 -69
  98. package/ui/Logo.js +57 -110
  99. package/ui/Menu.js +232 -354
  100. package/ui/PrerenderedCanvas.js +63 -87
  101. package/ui/ResizeHandle.js +87 -116
  102. package/ui/ReturnToImportFormDialog.js +32 -63
  103. package/ui/SanitizedHTML.js +64 -47
  104. package/ui/Snackbar.js +74 -101
  105. package/ui/SnackbarModel.js +37 -51
  106. package/ui/Tooltip.js +49 -76
  107. package/ui/ViewContainer.js +113 -196
  108. package/ui/colors.d.ts +10 -0
  109. package/ui/colors.js +78 -0
  110. package/ui/index.js +51 -181
  111. package/ui/react-colorful.d.ts +17 -0
  112. package/ui/react-colorful.js +455 -0
  113. package/ui/theme.d.ts +23 -1
  114. package/ui/theme.js +199 -247
  115. package/util/Base1DUtils.d.ts +32 -0
  116. package/util/Base1DUtils.js +174 -0
  117. package/util/Base1DViewModel.d.ts +16 -30
  118. package/util/Base1DViewModel.js +116 -293
  119. package/util/QuickLRU.js +84 -332
  120. package/util/TimeTraveller.d.ts +19 -0
  121. package/util/TimeTraveller.js +86 -0
  122. package/util/aborting.js +49 -127
  123. package/util/analytics.js +91 -154
  124. package/util/blockTypes.js +106 -240
  125. package/util/calculateDynamicBlocks.js +98 -128
  126. package/util/calculateStaticBlocks.js +105 -125
  127. package/util/color/cssColorsLevel4.js +156 -160
  128. package/util/color/index.js +33 -55
  129. package/util/compositeMap.js +49 -333
  130. package/util/formatFastaStrings.js +9 -14
  131. package/util/idMaker.js +18 -31
  132. package/util/index.d.ts +18 -32
  133. package/util/index.js +747 -1226
  134. package/util/io/RemoteFileWithRangeCache.js +88 -257
  135. package/util/io/index.js +95 -169
  136. package/util/jexl.js +60 -115
  137. package/util/jexlStrings.js +24 -29
  138. package/util/layouts/BaseLayout.js +1 -4
  139. package/util/layouts/GranularRectLayout.js +388 -555
  140. package/util/layouts/MultiLayout.js +41 -109
  141. package/util/layouts/PrecomputedLayout.js +56 -112
  142. package/util/layouts/PrecomputedMultiLayout.js +22 -59
  143. package/util/layouts/SceneGraph.js +127 -197
  144. package/util/layouts/index.js +29 -66
  145. package/util/mst-reflection.js +55 -71
  146. package/util/offscreenCanvasPonyfill.js +66 -134
  147. package/util/offscreenCanvasUtils.d.ts +2 -7
  148. package/util/offscreenCanvasUtils.js +49 -146
  149. package/util/range.js +29 -40
  150. package/util/rxjs.js +20 -27
  151. package/util/simpleFeature.js +88 -152
  152. package/util/stats.js +91 -151
  153. package/util/tracks.js +130 -173
  154. package/util/types/index.js +110 -179
  155. package/util/types/mst.js +91 -146
  156. package/util/types/util.js +1 -4
  157. package/util/when.js +54 -101
  158. package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
  159. package/BaseFeatureWidget/index.test.js +0 -69
  160. package/TextSearch/BaseResults.test.js +0 -42
  161. package/configuration/configurationSchema.test.js +0 -266
  162. package/configuration/configurationSlot.test.js +0 -69
  163. package/configuration/util.test.js +0 -39
  164. package/data_adapters/BaseAdapter.test.js +0 -200
  165. package/declare.d.js +0 -1
  166. package/pluggableElementTypes/RpcMethodType.test.js +0 -118
  167. package/pluggableElementTypes/renderers/declare.d.js +0 -1
  168. package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
  169. package/rpc/BaseRpcDriver.test.js +0 -540
  170. package/rpc/declaration.d.js +0 -1
  171. package/ui/FatalErrorDialog.test.js +0 -82
  172. package/ui/SanitizedHTML.test.js +0 -36
  173. package/ui/theme.test.js +0 -92
  174. package/util/Base1DViewModel.test.js +0 -130
  175. package/util/calculateDynamicBlocks.test.js +0 -74
  176. package/util/calculateStaticBlocks.test.js +0 -297
  177. package/util/declare.d.js +0 -1
  178. package/util/formatFastaStrings.test.js +0 -40
  179. package/util/index.test.js +0 -213
  180. package/util/jexlStrings.test.js +0 -48
  181. package/util/layouts/GranularRectLayout.test.js +0 -99
  182. package/util/range.test.js +0 -64
  183. package/util/simpleFeature.test.js +0 -34
  184. package/util/stats.test.js +0 -172
package/PluginManager.js CHANGED
@@ -1,684 +1,395 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
-
20
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
-
22
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
- var _mobxStateTree = require("mobx-state-tree");
25
-
26
- var _RendererType = _interopRequireDefault(require("./pluggableElementTypes/renderers/RendererType"));
27
-
28
- var _AdapterType = _interopRequireDefault(require("./pluggableElementTypes/AdapterType"));
29
-
30
- var _TrackType = _interopRequireDefault(require("./pluggableElementTypes/TrackType"));
31
-
32
- var _DisplayType = _interopRequireDefault(require("./pluggableElementTypes/DisplayType"));
33
-
34
- var _ViewType = _interopRequireDefault(require("./pluggableElementTypes/ViewType"));
35
-
36
- var _WidgetType = _interopRequireDefault(require("./pluggableElementTypes/WidgetType"));
37
-
38
- var _ConnectionType = _interopRequireDefault(require("./pluggableElementTypes/ConnectionType"));
39
-
40
- var _RpcMethodType = _interopRequireDefault(require("./pluggableElementTypes/RpcMethodType"));
41
-
42
- var _InternetAccountType = _interopRequireDefault(require("./pluggableElementTypes/InternetAccountType"));
43
-
44
- var _TextSearchAdapterType = _interopRequireDefault(require("./pluggableElementTypes/TextSearchAdapterType"));
45
-
46
- var _configuration = require("./configuration");
47
-
48
- var _Plugin = _interopRequireDefault(require("./Plugin"));
49
-
50
- var _ReExports = _interopRequireDefault(require("./ReExports"));
51
-
52
- var _CorePlugin = _interopRequireDefault(require("./CorePlugin"));
53
-
54
- var _jexl = _interopRequireDefault(require("./util/jexl"));
55
-
56
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
57
-
58
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
59
-
60
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
61
-
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
+ const mobx_state_tree_1 = require("mobx-state-tree");
7
+ const RendererType_1 = __importDefault(require("./pluggableElementTypes/renderers/RendererType"));
8
+ const AdapterType_1 = __importDefault(require("./pluggableElementTypes/AdapterType"));
9
+ const TrackType_1 = __importDefault(require("./pluggableElementTypes/TrackType"));
10
+ const DisplayType_1 = __importDefault(require("./pluggableElementTypes/DisplayType"));
11
+ const ViewType_1 = __importDefault(require("./pluggableElementTypes/ViewType"));
12
+ const WidgetType_1 = __importDefault(require("./pluggableElementTypes/WidgetType"));
13
+ const ConnectionType_1 = __importDefault(require("./pluggableElementTypes/ConnectionType"));
14
+ const RpcMethodType_1 = __importDefault(require("./pluggableElementTypes/RpcMethodType"));
15
+ const InternetAccountType_1 = __importDefault(require("./pluggableElementTypes/InternetAccountType"));
16
+ const TextSearchAdapterType_1 = __importDefault(require("./pluggableElementTypes/TextSearchAdapterType"));
17
+ const AddTrackWorkflowType_1 = __importDefault(require("./pluggableElementTypes/AddTrackWorkflowType"));
18
+ const configuration_1 = require("./configuration");
19
+ const Plugin_1 = __importDefault(require("./Plugin"));
20
+ const ReExports_1 = __importDefault(require("./ReExports"));
21
+ const CorePlugin_1 = __importDefault(require("./CorePlugin"));
22
+ const jexl_1 = __importDefault(require("./util/jexl"));
62
23
  /** little helper class that keeps groups of callbacks that are
63
24
  then run in a specified order by group */
64
- var PhasedScheduler = /*#__PURE__*/function () {
65
- function PhasedScheduler() {
66
- (0, _classCallCheck2.default)(this, PhasedScheduler);
67
- (0, _defineProperty2.default)(this, "phaseCallbacks", new Map());
68
- (0, _defineProperty2.default)(this, "phaseOrder", []);
69
-
70
- for (var _len = arguments.length, phaseOrder = new Array(_len), _key = 0; _key < _len; _key++) {
71
- phaseOrder[_key] = arguments[_key];
72
- }
73
-
74
- this.phaseOrder = phaseOrder;
75
- }
76
-
77
- (0, _createClass2.default)(PhasedScheduler, [{
78
- key: "add",
79
- value: function add(phase, callback) {
80
- if (!this.phaseOrder.includes(phase)) {
81
- throw new Error("unknown phase ".concat(phase));
82
- }
83
-
84
- var phaseCallbacks = this.phaseCallbacks.get(phase);
85
-
86
- if (!phaseCallbacks) {
87
- phaseCallbacks = [];
88
- this.phaseCallbacks.set(phase, phaseCallbacks);
89
- }
90
-
91
- phaseCallbacks.push(callback);
92
- }
93
- }, {
94
- key: "run",
95
- value: function run() {
96
- var _this = this;
97
-
98
- this.phaseOrder.forEach(function (phaseName) {
99
- var _this$phaseCallbacks$;
100
-
101
- (_this$phaseCallbacks$ = _this.phaseCallbacks.get(phaseName)) === null || _this$phaseCallbacks$ === void 0 ? void 0 : _this$phaseCallbacks$.forEach(function (callback) {
102
- return callback();
25
+ class PhasedScheduler {
26
+ constructor(...phaseOrder) {
27
+ this.phaseCallbacks = new Map();
28
+ this.phaseOrder = [];
29
+ this.phaseOrder = phaseOrder;
30
+ }
31
+ add(phase, callback) {
32
+ if (!this.phaseOrder.includes(phase)) {
33
+ throw new Error(`unknown phase ${phase}`);
34
+ }
35
+ let phaseCallbacks = this.phaseCallbacks.get(phase);
36
+ if (!phaseCallbacks) {
37
+ phaseCallbacks = [];
38
+ this.phaseCallbacks.set(phase, phaseCallbacks);
39
+ }
40
+ phaseCallbacks.push(callback);
41
+ }
42
+ run() {
43
+ this.phaseOrder.forEach(phaseName => {
44
+ var _a;
45
+ (_a = this.phaseCallbacks.get(phaseName)) === null || _a === void 0 ? void 0 : _a.forEach(callback => callback());
103
46
  });
104
- });
105
47
  }
106
- }]);
107
- return PhasedScheduler;
108
- }();
109
-
48
+ }
110
49
  /** internal class that holds the info for a certain element type */
111
- var TypeRecord = /*#__PURE__*/function () {
112
- function TypeRecord(typeName, baseClass) {
113
- (0, _classCallCheck2.default)(this, TypeRecord);
114
- this.typeName = typeName;
115
- this.baseClass = baseClass;
116
- (0, _defineProperty2.default)(this, "registeredTypes", {});
117
- }
118
-
119
- (0, _createClass2.default)(TypeRecord, [{
120
- key: "add",
121
- value: function add(name, t) {
122
- this.registeredTypes[name] = t;
123
- }
124
- }, {
125
- key: "has",
126
- value: function has(name) {
127
- return name in this.registeredTypes;
128
- }
129
- }, {
130
- key: "get",
131
- value: function get(name) {
132
- if (!this.has(name)) {
133
- throw new Error("".concat(this.typeName, " '").concat(name, "' not found, perhaps its plugin is not loaded or its plugin has not added it."));
134
- }
135
-
136
- return this.registeredTypes[name];
137
- }
138
- }, {
139
- key: "all",
140
- value: function all() {
141
- return Object.values(this.registeredTypes);
142
- }
143
- }]);
144
- return TypeRecord;
145
- }(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
-
147
-
148
- var PluginManager = /*#__PURE__*/function () {
149
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
150
- function PluginManager() {
151
- var _this2 = this;
152
-
153
- var initialPlugins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
154
- (0, _classCallCheck2.default)(this, PluginManager);
155
- (0, _defineProperty2.default)(this, "plugins", []);
156
- (0, _defineProperty2.default)(this, "jexl", (0, _jexl.default)());
157
- (0, _defineProperty2.default)(this, "pluginMetadata", {});
158
- (0, _defineProperty2.default)(this, "runtimePluginDefinitions", []);
159
- (0, _defineProperty2.default)(this, "elementCreationSchedule", new PhasedScheduler('renderer', 'adapter', 'text search adapter', 'display', 'track', 'connection', 'view', 'widget', 'rpc method', 'internet account'));
160
- (0, _defineProperty2.default)(this, "rendererTypes", new TypeRecord('RendererType', _RendererType.default));
161
- (0, _defineProperty2.default)(this, "adapterTypes", new TypeRecord('AdapterType', _AdapterType.default));
162
- (0, _defineProperty2.default)(this, "textSearchAdapterTypes", new TypeRecord('TextSearchAdapterType', _TextSearchAdapterType.default));
163
- (0, _defineProperty2.default)(this, "trackTypes", new TypeRecord('TrackType', _TrackType.default));
164
- (0, _defineProperty2.default)(this, "displayTypes", new TypeRecord('DisplayType', _DisplayType.default));
165
- (0, _defineProperty2.default)(this, "connectionTypes", new TypeRecord('ConnectionType', _ConnectionType.default));
166
- (0, _defineProperty2.default)(this, "viewTypes", new TypeRecord('ViewType', _ViewType.default));
167
- (0, _defineProperty2.default)(this, "widgetTypes", new TypeRecord('WidgetType', _WidgetType.default));
168
- (0, _defineProperty2.default)(this, "rpcMethods", new TypeRecord('RpcMethodType', _RpcMethodType.default));
169
- (0, _defineProperty2.default)(this, "internetAccountTypes", new TypeRecord('InternetAccountType', _InternetAccountType.default));
170
- (0, _defineProperty2.default)(this, "configured", false);
171
- (0, _defineProperty2.default)(this, "rootModel", void 0);
172
- (0, _defineProperty2.default)(this, "extensionPoints", new Map());
173
- (0, _defineProperty2.default)(this, "jbrequireCache", new Map());
174
- (0, _defineProperty2.default)(this, "lib", _ReExports.default);
175
- (0, _defineProperty2.default)(this, "load", function (lib) {
176
- if (!_this2.jbrequireCache.has(lib)) {
177
- _this2.jbrequireCache.set(lib, lib(_this2));
178
- }
179
-
180
- return _this2.jbrequireCache.get(lib);
181
- });
182
- (0, _defineProperty2.default)(this, "jbrequire", function (lib // eslint-disable-next-line @typescript-eslint/no-explicit-any
183
- ) {
184
- if (typeof lib === 'string') {
185
- var pack = _this2.lib[lib];
186
-
187
- if (!pack) {
188
- throw new TypeError("No jbrequire re-export defined for package '".concat(lib, "'. If this package must be shared between plugins, add it to ReExports.js. If it does not need to be shared, just import it normally."));
50
+ class TypeRecord {
51
+ constructor(typeName, baseClass) {
52
+ this.typeName = typeName;
53
+ this.baseClass = baseClass;
54
+ this.registeredTypes = {};
55
+ }
56
+ add(name, t) {
57
+ this.registeredTypes[name] = t;
58
+ }
59
+ has(name) {
60
+ return name in this.registeredTypes;
61
+ }
62
+ get(name) {
63
+ if (!this.has(name)) {
64
+ throw new Error(`${this.typeName} '${name}' not found, perhaps its plugin is not loaded or its plugin has not added it.`);
189
65
  }
190
-
191
- return pack;
192
- }
193
-
194
- if (typeof lib === 'function') {
195
- return _this2.load(lib);
196
- }
197
-
198
- if (lib.default) {
199
- return _this2.jbrequire(lib.default);
200
- }
201
-
202
- throw new TypeError('lib passed to jbrequire must be either a string or a function');
203
- });
204
- // add the core plugin
205
- this.addPlugin({
206
- plugin: new _CorePlugin.default(),
207
- metadata: {
208
- isCore: true
209
- }
210
- }); // add all the initial plugins
211
-
212
- initialPlugins.forEach(function (plugin) {
213
- _this2.addPlugin(plugin);
214
- });
215
- }
216
-
217
- (0, _createClass2.default)(PluginManager, [{
218
- key: "pluginConfigurationSchemas",
219
- value: function pluginConfigurationSchemas() {
220
- var configurationSchemas = {};
221
- this.plugins.forEach(function (plugin) {
222
- if (plugin.configurationSchema) {
223
- configurationSchemas[plugin.name] = plugin.configurationSchema;
66
+ return this.registeredTypes[name];
67
+ }
68
+ all() {
69
+ return Object.values(this.registeredTypes);
70
+ }
71
+ }
72
+ class PluginManager {
73
+ constructor(initialPlugins = []) {
74
+ this.plugins = [];
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ this.jexl = (0, jexl_1.default)();
77
+ this.pluginMetadata = {};
78
+ this.runtimePluginDefinitions = [];
79
+ this.elementCreationSchedule = new PhasedScheduler('renderer', 'adapter', 'text search adapter', 'display', 'track', 'connection', 'view', 'widget', 'rpc method', 'internet account', 'add track workflow');
80
+ this.rendererTypes = new TypeRecord('RendererType', RendererType_1.default);
81
+ this.adapterTypes = new TypeRecord('AdapterType', AdapterType_1.default);
82
+ this.textSearchAdapterTypes = new TypeRecord('TextSearchAdapterType', TextSearchAdapterType_1.default);
83
+ this.trackTypes = new TypeRecord('TrackType', TrackType_1.default);
84
+ this.displayTypes = new TypeRecord('DisplayType', DisplayType_1.default);
85
+ this.connectionTypes = new TypeRecord('ConnectionType', ConnectionType_1.default);
86
+ this.viewTypes = new TypeRecord('ViewType', ViewType_1.default);
87
+ this.widgetTypes = new TypeRecord('WidgetType', WidgetType_1.default);
88
+ this.rpcMethods = new TypeRecord('RpcMethodType', RpcMethodType_1.default);
89
+ this.addTrackWidgets = new TypeRecord('AddTrackWorkflow', AddTrackWorkflowType_1.default);
90
+ this.internetAccountTypes = new TypeRecord('InternetAccountType', InternetAccountType_1.default);
91
+ this.configured = false;
92
+ this.extensionPoints = new Map();
93
+ this.jbrequireCache = new Map();
94
+ this.lib = ReExports_1.default;
95
+ this.load = (lib) => {
96
+ if (!this.jbrequireCache.has(lib)) {
97
+ this.jbrequireCache.set(lib, lib(this));
98
+ }
99
+ return this.jbrequireCache.get(lib);
100
+ };
101
+ /**
102
+ * Get the re-exported version of the given package name.
103
+ * Throws an error if the package is not re-exported by the plugin manager.
104
+ *
105
+ * @returns the library's default export
106
+ */
107
+ this.jbrequire = (lib) => {
108
+ if (typeof lib === 'string') {
109
+ const pack = this.lib[lib];
110
+ if (!pack) {
111
+ throw new TypeError(`No jbrequire re-export defined for package '${lib}'. If this package must be shared between plugins, add it to ReExports.js. If it does not need to be shared, just import it normally.`);
112
+ }
113
+ return pack;
114
+ }
115
+ if (typeof lib === 'function') {
116
+ return this.load(lib);
117
+ }
118
+ if (lib.default) {
119
+ return this.jbrequire(lib.default);
120
+ }
121
+ throw new TypeError('lib passed to jbrequire must be either a string or a function');
122
+ };
123
+ // add the core plugin
124
+ this.addPlugin({ plugin: new CorePlugin_1.default(), metadata: { isCore: true } });
125
+ // add all the initial plugins
126
+ initialPlugins.forEach(plugin => {
127
+ this.addPlugin(plugin);
128
+ });
129
+ }
130
+ pluginConfigurationSchemas() {
131
+ const configurationSchemas = {};
132
+ this.plugins.forEach(plugin => {
133
+ if (plugin.configurationSchema) {
134
+ configurationSchemas[plugin.name] = plugin.configurationSchema;
135
+ }
136
+ });
137
+ return configurationSchemas;
138
+ }
139
+ addPlugin(load) {
140
+ if (this.configured) {
141
+ throw new Error('JBrowse already configured, cannot add plugins');
224
142
  }
225
- });
226
- return configurationSchemas;
227
- }
228
- }, {
229
- key: "addPlugin",
230
- value: function addPlugin(load) {
231
- if (this.configured) {
232
- throw new Error('JBrowse already configured, cannot add plugins');
233
- }
234
-
235
- var _ref = load instanceof _Plugin.default ? [load, {}] : [load.plugin, load.metadata],
236
- _ref2 = (0, _slicedToArray2.default)(_ref, 2),
237
- plugin = _ref2[0],
238
- _ref2$ = _ref2[1],
239
- metadata = _ref2$ === void 0 ? {} : _ref2$;
240
-
241
- if (this.plugins.includes(plugin)) {
242
- throw new Error('plugin already installed');
243
- }
244
-
245
- this.pluginMetadata[plugin.name] = metadata;
246
-
247
- if ('definition' in load) {
248
- this.runtimePluginDefinitions.push(load.definition);
249
- }
250
-
251
- plugin.install(this);
252
- this.plugins.push(plugin);
253
- return this;
254
- }
255
- }, {
256
- key: "getPlugin",
257
- value: function getPlugin(name) {
258
- return this.plugins.find(function (p) {
259
- return p.name === name;
260
- });
261
- }
262
- }, {
263
- key: "hasPlugin",
264
- value: function hasPlugin(name) {
265
- return this.getPlugin(name) !== undefined;
266
- }
267
- }, {
268
- key: "createPluggableElements",
269
- value: function createPluggableElements() {
270
- // run the creation callbacks for each element type in order.
271
- // see elementCreationSchedule above for the creation order
272
- if (this.elementCreationSchedule) {
273
- this.elementCreationSchedule.run();
274
- delete this.elementCreationSchedule;
275
- }
276
-
277
- return this;
278
- }
279
- }, {
280
- key: "setRootModel",
281
- value: function setRootModel(rootModel) {
282
- this.rootModel = rootModel;
283
- }
284
- }, {
285
- key: "configure",
286
- value: function configure() {
287
- var _this3 = this;
288
-
289
- if (this.configured) {
290
- throw new Error('already configured');
291
- }
292
-
293
- this.plugins.forEach(function (plugin) {
294
- return plugin.configure(_this3);
295
- });
296
- this.configured = true; // console.log(JSON.stringify(getSnapshot(model)))
297
-
298
- return this;
299
- }
300
- }, {
301
- key: "getElementTypeRecord",
302
- value: function getElementTypeRecord(groupName) {
303
- switch (groupName) {
304
- case 'adapter':
305
- return this.adapterTypes;
306
-
307
- case 'text search adapter':
308
- return this.textSearchAdapterTypes;
309
-
310
- case 'connection':
311
- return this.connectionTypes;
312
-
313
- case 'widget':
314
- return this.widgetTypes;
315
-
316
- case 'renderer':
317
- return this.rendererTypes;
318
-
319
- case 'display':
320
- return this.displayTypes;
321
-
322
- case 'track':
323
- return this.trackTypes;
324
-
325
- case 'view':
326
- return this.viewTypes;
327
-
328
- case 'rpc method':
329
- return this.rpcMethods;
330
-
331
- case 'internet account':
332
- return this.internetAccountTypes;
333
-
334
- default:
335
- throw new Error("invalid element type '".concat(groupName, "'"));
336
- }
337
- }
338
- }, {
339
- key: "addElementType",
340
- value: function addElementType(groupName, creationCallback) {
341
- var _this4 = this;
342
-
343
- if (typeof creationCallback !== 'function') {
344
- throw new Error('must provide a callback function that returns the new type object');
345
- }
346
-
347
- var typeRecord = this.getElementTypeRecord(groupName);
348
-
349
- if (this.elementCreationSchedule) {
350
- this.elementCreationSchedule.add(groupName, function () {
351
- var newElement = creationCallback(_this4);
352
-
353
- if (!newElement.name) {
354
- throw new Error("cannot add a ".concat(groupName, " with no name"));
355
- }
356
-
357
- if (typeRecord.has(newElement.name)) {
358
- throw new Error("".concat(groupName, " ").concat(newElement.name, " already registered, cannot register it again"));
359
- }
360
-
361
- newElement = _this4.evaluateExtensionPoint('Core-extendPluggableElement', newElement);
362
- typeRecord.add(newElement.name, newElement);
143
+ const [plugin, metadata = {}] = load instanceof Plugin_1.default ? [load, {}] : [load.plugin, load.metadata];
144
+ if (this.plugins.includes(plugin)) {
145
+ throw new Error('plugin already installed');
146
+ }
147
+ this.pluginMetadata[plugin.name] = metadata;
148
+ if ('definition' in load) {
149
+ this.runtimePluginDefinitions.push(load.definition);
150
+ }
151
+ plugin.install(this);
152
+ this.plugins.push(plugin);
153
+ return this;
154
+ }
155
+ getPlugin(name) {
156
+ return this.plugins.find(p => p.name === name);
157
+ }
158
+ hasPlugin(name) {
159
+ return this.getPlugin(name) !== undefined;
160
+ }
161
+ createPluggableElements() {
162
+ // run the creation callbacks for each element type in order.
163
+ // see elementCreationSchedule above for the creation order
164
+ if (this.elementCreationSchedule) {
165
+ this.elementCreationSchedule.run();
166
+ delete this.elementCreationSchedule;
167
+ }
168
+ return this;
169
+ }
170
+ setRootModel(rootModel) {
171
+ this.rootModel = rootModel;
172
+ }
173
+ configure() {
174
+ if (this.configured) {
175
+ throw new Error('already configured');
176
+ }
177
+ this.plugins.forEach(plugin => plugin.configure(this));
178
+ this.configured = true;
179
+ // console.log(JSON.stringify(getSnapshot(model)))
180
+ return this;
181
+ }
182
+ getElementTypeRecord(groupName) {
183
+ switch (groupName) {
184
+ case 'adapter':
185
+ return this.adapterTypes;
186
+ case 'text search adapter':
187
+ return this.textSearchAdapterTypes;
188
+ case 'connection':
189
+ return this.connectionTypes;
190
+ case 'widget':
191
+ return this.widgetTypes;
192
+ case 'renderer':
193
+ return this.rendererTypes;
194
+ case 'display':
195
+ return this.displayTypes;
196
+ case 'track':
197
+ return this.trackTypes;
198
+ case 'view':
199
+ return this.viewTypes;
200
+ case 'rpc method':
201
+ return this.rpcMethods;
202
+ case 'internet account':
203
+ return this.internetAccountTypes;
204
+ case 'add track workflow':
205
+ return this.addTrackWidgets;
206
+ default:
207
+ throw new Error(`invalid element type '${groupName}'`);
208
+ }
209
+ }
210
+ addElementType(groupName, creationCallback) {
211
+ var _a;
212
+ if (typeof creationCallback !== 'function') {
213
+ throw new Error('must provide a callback function that returns the new type object');
214
+ }
215
+ const typeRecord = this.getElementTypeRecord(groupName);
216
+ (_a = this.elementCreationSchedule) === null || _a === void 0 ? void 0 : _a.add(groupName, () => {
217
+ const newElement = creationCallback(this);
218
+ if (!newElement.name) {
219
+ throw new Error(`cannot add a ${groupName} with no name`);
220
+ }
221
+ if (typeRecord.has(newElement.name)) {
222
+ throw new Error(`${groupName} ${newElement.name} already registered, cannot register it again`);
223
+ }
224
+ typeRecord.add(newElement.name, this.evaluateExtensionPoint('Core-extendPluggableElement', newElement));
363
225
  });
364
- }
365
-
366
- return this;
367
- }
368
- }, {
369
- key: "getElementType",
370
- value: function getElementType(groupName, typeName) {
371
- var typeRecord = this.getElementTypeRecord(groupName);
372
- return typeRecord.get(typeName);
373
- }
374
- }, {
375
- key: "getElementTypesInGroup",
376
- value: function getElementTypesInGroup(groupName) {
377
- var typeRecord = this.getElementTypeRecord(groupName);
378
- return typeRecord.all();
226
+ return this;
227
+ }
228
+ getElementType(groupName, typeName) {
229
+ return this.getElementTypeRecord(groupName).get(typeName);
230
+ }
231
+ getElementTypesInGroup(groupName) {
232
+ return this.getElementTypeRecord(groupName).all();
379
233
  }
380
234
  /** get a MST type for the union of all specified pluggable MST types */
381
-
382
- }, {
383
- key: "pluggableMstType",
384
- value: function pluggableMstType(typeGroup, fieldName) {
385
- var fallback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _mobxStateTree.types.maybe(_mobxStateTree.types.null);
386
- var pluggableTypes = this.getElementTypeRecord(typeGroup).all() // @ts-ignore
387
- .map(function (t) {
388
- return t[fieldName];
389
- }).filter(function (t) {
390
- return (0, _mobxStateTree.isType)(t) && (0, _mobxStateTree.isModelType)(t);
391
- }); // try to smooth over the case when no types are registered, mostly
392
- // encountered in tests
393
-
394
- if (pluggableTypes.length === 0) {
395
- console.warn("No JBrowse pluggable types found matching ('".concat(typeGroup, "','").concat(fieldName, "')"));
396
- return fallback;
397
- }
398
-
399
- return _mobxStateTree.types.union.apply(_mobxStateTree.types, (0, _toConsumableArray2.default)(pluggableTypes));
235
+ pluggableMstType(groupName, fieldName, fallback = mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.null)) {
236
+ const pluggableTypes = this.getElementTypeRecord(groupName)
237
+ .all()
238
+ // @ts-ignore
239
+ .map(t => t[fieldName])
240
+ .filter(t => (0, mobx_state_tree_1.isType)(t) && (0, mobx_state_tree_1.isModelType)(t));
241
+ // try to smooth over the case when no types are registered, mostly
242
+ // encountered in tests
243
+ if (pluggableTypes.length === 0) {
244
+ console.warn(`No pluggable types found matching ('${groupName}','${fieldName}')`);
245
+ return fallback;
246
+ }
247
+ return mobx_state_tree_1.types.union(...pluggableTypes);
400
248
  }
401
249
  /** get a MST type for the union of all specified pluggable config schemas */
402
-
403
- }, {
404
- key: "pluggableConfigSchemaType",
405
- value: function pluggableConfigSchemaType(typeGroup) {
406
- var fieldName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'configSchema';
407
- var pluggableTypes = this.getElementTypeRecord(typeGroup).all() // @ts-ignore
408
- .map(function (t) {
409
- return t[fieldName];
410
- }).filter(function (t) {
411
- return (0, _configuration.isBareConfigurationSchemaType)(t);
412
- });
413
-
414
- if (pluggableTypes.length === 0) {
415
- pluggableTypes.push((0, _configuration.ConfigurationSchema)('Null', {}));
416
- }
417
-
418
- return _mobxStateTree.types.union.apply(_mobxStateTree.types, (0, _toConsumableArray2.default)(pluggableTypes));
419
- }
420
- }, {
421
- key: "getRendererType",
422
- value: function getRendererType(typeName) {
423
- return this.rendererTypes.get(typeName);
424
- }
425
- }, {
426
- key: "getRendererTypes",
427
- value: function getRendererTypes() {
428
- return this.rendererTypes.all();
429
- }
430
- }, {
431
- key: "getAdapterType",
432
- value: function getAdapterType(typeName) {
433
- return this.adapterTypes.get(typeName);
434
- }
435
- }, {
436
- key: "getTextSearchAdapterType",
437
- value: function getTextSearchAdapterType(typeName) {
438
- return this.textSearchAdapterTypes.get(typeName);
439
- }
440
- }, {
441
- key: "getTrackType",
442
- value: function getTrackType(typeName) {
443
- return this.trackTypes.get(typeName);
444
- }
445
- }, {
446
- key: "getDisplayType",
447
- value: function getDisplayType(typeName) {
448
- return this.displayTypes.get(typeName);
449
- }
450
- }, {
451
- key: "getViewType",
452
- value: function getViewType(typeName) {
453
- return this.viewTypes.get(typeName);
454
- }
455
- }, {
456
- key: "getWidgetType",
457
- value: function getWidgetType(typeName) {
458
- return this.widgetTypes.get(typeName);
459
- }
460
- }, {
461
- key: "getConnectionType",
462
- value: function getConnectionType(typeName) {
463
- return this.connectionTypes.get(typeName);
464
- }
465
- }, {
466
- key: "getRpcMethodType",
467
- value: function getRpcMethodType(methodName) {
468
- return this.rpcMethods.get(methodName);
469
- }
470
- }, {
471
- key: "getInternetAccountType",
472
- value: function getInternetAccountType(internetAccountName) {
473
- return this.internetAccountTypes.get(internetAccountName);
474
- }
475
- }, {
476
- key: "addRendererType",
477
- value: function addRendererType(creationCallback) {
478
- return this.addElementType('renderer', creationCallback);
479
- }
480
- }, {
481
- key: "addAdapterType",
482
- value: function addAdapterType(creationCallback) {
483
- return this.addElementType('adapter', creationCallback);
484
- }
485
- }, {
486
- key: "addTextSearchAdapterType",
487
- value: function addTextSearchAdapterType(creationCallback) {
488
- return this.addElementType('text search adapter', creationCallback);
489
- }
490
- }, {
491
- key: "addTrackType",
492
- value: function addTrackType(creationCallback) {
493
- var _this5 = this;
494
-
495
- // Goes through the already-created displays and registers the ones that
496
- // specify this track type
497
- var callback = function callback() {
498
- var track = creationCallback(_this5);
499
-
500
- _this5.getElementTypesInGroup('display').forEach(function (display) {
501
- if (display.trackType === track.name && // track may have already added the displayType in its creationCallback
502
- !track.displayTypes.includes(display)) {
503
- track.addDisplayType(display);
504
- }
505
- });
506
-
507
- return track;
508
- };
509
-
510
- return this.addElementType('track', callback);
511
- }
512
- }, {
513
- key: "addDisplayType",
514
- value: function addDisplayType(creationCallback) {
515
- return this.addElementType('display', creationCallback);
516
- }
517
- }, {
518
- key: "addViewType",
519
- value: function addViewType(creationCallback) {
520
- var _this6 = this;
521
-
522
- var callback = function callback() {
523
- var newView = creationCallback(_this6);
524
-
525
- _this6.getElementTypesInGroup('display').forEach(function (display) {
526
- if (display.viewType === newView.name && // view may have already added the displayType in its creationCallback
527
- !newView.displayTypes.includes(display)) {
528
- newView.addDisplayType(display);
529
- }
530
- });
531
-
532
- return newView;
533
- };
534
-
535
- return this.addElementType('view', callback);
536
- }
537
- }, {
538
- key: "addWidgetType",
539
- value: function addWidgetType(creationCallback) {
540
- return this.addElementType('widget', creationCallback);
541
- }
542
- }, {
543
- key: "addConnectionType",
544
- value: function addConnectionType(creationCallback) {
545
- return this.addElementType('connection', creationCallback);
546
- }
547
- }, {
548
- key: "addRpcMethod",
549
- value: function addRpcMethod(creationCallback) {
550
- return this.addElementType('rpc method', creationCallback);
551
- }
552
- }, {
553
- key: "addInternetAccountType",
554
- value: function addInternetAccountType(creationCallback) {
555
- return this.addElementType('internet account', creationCallback);
556
- }
557
- }, {
558
- key: "addToExtensionPoint",
559
- value: function addToExtensionPoint(extensionPointName, callback) {
560
- var callbacks = this.extensionPoints.get(extensionPointName);
561
-
562
- if (!callbacks) {
563
- callbacks = [];
564
- this.extensionPoints.set(extensionPointName, callbacks);
565
- }
566
-
567
- callbacks.push(callback);
568
- }
569
- }, {
570
- key: "evaluateExtensionPoint",
571
- value: function evaluateExtensionPoint(extensionPointName, extendee) {
572
- var callbacks = this.extensionPoints.get(extensionPointName);
573
- var accumulator = extendee;
574
-
575
- if (callbacks) {
576
- var _iterator = _createForOfIteratorHelper(callbacks),
577
- _step;
578
-
579
- try {
580
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
581
- var callback = _step.value;
582
-
583
- try {
584
- accumulator = callback(accumulator);
585
- } catch (error) {
586
- console.error(error);
250
+ pluggableConfigSchemaType(typeGroup, fieldName = 'configSchema') {
251
+ const pluggableTypes = this.getElementTypeRecord(typeGroup)
252
+ .all()
253
+ // @ts-ignore
254
+ .map(t => t[fieldName])
255
+ .filter(t => (0, configuration_1.isBareConfigurationSchemaType)(t));
256
+ if (pluggableTypes.length === 0) {
257
+ pluggableTypes.push((0, configuration_1.ConfigurationSchema)('Null', {}));
258
+ }
259
+ return mobx_state_tree_1.types.union(...pluggableTypes);
260
+ }
261
+ getRendererType(typeName) {
262
+ return this.rendererTypes.get(typeName);
263
+ }
264
+ getRendererTypes() {
265
+ return this.rendererTypes.all();
266
+ }
267
+ getAdapterType(typeName) {
268
+ return this.adapterTypes.get(typeName);
269
+ }
270
+ getTextSearchAdapterType(typeName) {
271
+ return this.textSearchAdapterTypes.get(typeName);
272
+ }
273
+ getTrackType(typeName) {
274
+ return this.trackTypes.get(typeName);
275
+ }
276
+ getDisplayType(typeName) {
277
+ return this.displayTypes.get(typeName);
278
+ }
279
+ getViewType(typeName) {
280
+ return this.viewTypes.get(typeName);
281
+ }
282
+ getAddTrackWorkflow(typeName) {
283
+ return this.addTrackWidgets.get(typeName);
284
+ }
285
+ getWidgetType(typeName) {
286
+ return this.widgetTypes.get(typeName);
287
+ }
288
+ getConnectionType(typeName) {
289
+ return this.connectionTypes.get(typeName);
290
+ }
291
+ getRpcMethodType(methodName) {
292
+ return this.rpcMethods.get(methodName);
293
+ }
294
+ getInternetAccountType(name) {
295
+ return this.internetAccountTypes.get(name);
296
+ }
297
+ addRendererType(cb) {
298
+ return this.addElementType('renderer', cb);
299
+ }
300
+ addAdapterType(cb) {
301
+ return this.addElementType('adapter', cb);
302
+ }
303
+ addTextSearchAdapterType(cb) {
304
+ return this.addElementType('text search adapter', cb);
305
+ }
306
+ addTrackType(cb) {
307
+ // Goes through the already-created displays and registers the ones that
308
+ // specify this track type
309
+ const callback = () => {
310
+ const track = cb(this);
311
+ const displays = this.getElementTypesInGroup('display');
312
+ displays.forEach(display => {
313
+ // track may have already added the displayType in its cb
314
+ if (display.trackType === track.name &&
315
+ !track.displayTypes.includes(display)) {
316
+ track.addDisplayType(display);
317
+ }
318
+ });
319
+ return track;
320
+ };
321
+ return this.addElementType('track', callback);
322
+ }
323
+ addDisplayType(cb) {
324
+ return this.addElementType('display', cb);
325
+ }
326
+ addViewType(cb) {
327
+ const callback = () => {
328
+ const newView = cb(this);
329
+ const displays = this.getElementTypesInGroup('display');
330
+ displays.forEach(display => {
331
+ // view may have already added the displayType in its callback
332
+ if (display.viewType === newView.name &&
333
+ !newView.displayTypes.includes(display)) {
334
+ newView.addDisplayType(display);
335
+ }
336
+ });
337
+ return newView;
338
+ };
339
+ return this.addElementType('view', callback);
340
+ }
341
+ addWidgetType(cb) {
342
+ return this.addElementType('widget', cb);
343
+ }
344
+ addConnectionType(cb) {
345
+ return this.addElementType('connection', cb);
346
+ }
347
+ addRpcMethod(cb) {
348
+ return this.addElementType('rpc method', cb);
349
+ }
350
+ addInternetAccountType(cb) {
351
+ return this.addElementType('internet account', cb);
352
+ }
353
+ addAddTrackWorkflowType(cb) {
354
+ return this.addElementType('add track workflow', cb);
355
+ }
356
+ addToExtensionPoint(extensionPointName, callback) {
357
+ let callbacks = this.extensionPoints.get(extensionPointName);
358
+ if (!callbacks) {
359
+ callbacks = [];
360
+ this.extensionPoints.set(extensionPointName, callbacks);
361
+ }
362
+ callbacks.push(callback);
363
+ }
364
+ evaluateExtensionPoint(extensionPointName, extendee) {
365
+ const callbacks = this.extensionPoints.get(extensionPointName);
366
+ let accumulator = extendee;
367
+ if (callbacks) {
368
+ for (const callback of callbacks) {
369
+ try {
370
+ accumulator = callback(accumulator);
371
+ }
372
+ catch (error) {
373
+ console.error(error);
374
+ }
587
375
  }
588
- }
589
- } catch (err) {
590
- _iterator.e(err);
591
- } finally {
592
- _iterator.f();
593
376
  }
594
- }
595
-
596
- return accumulator;
597
- }
598
- }, {
599
- key: "evaluateAsyncExtensionPoint",
600
- value: function () {
601
- var _evaluateAsyncExtensionPoint = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(extensionPointName, extendee) {
602
- var callbacks, accumulator, _iterator2, _step2, callback;
603
-
604
- return _regenerator.default.wrap(function _callee$(_context) {
605
- while (1) {
606
- switch (_context.prev = _context.next) {
607
- case 0:
608
- callbacks = this.extensionPoints.get(extensionPointName);
609
- accumulator = extendee;
610
-
611
- if (!callbacks) {
612
- _context.next = 27;
613
- break;
377
+ return accumulator;
378
+ }
379
+ async evaluateAsyncExtensionPoint(extensionPointName, extendee) {
380
+ const callbacks = this.extensionPoints.get(extensionPointName);
381
+ let accumulator = extendee;
382
+ if (callbacks) {
383
+ for (const callback of callbacks) {
384
+ try {
385
+ accumulator = await callback(accumulator);
614
386
  }
615
-
616
- _iterator2 = _createForOfIteratorHelper(callbacks);
617
- _context.prev = 4;
618
-
619
- _iterator2.s();
620
-
621
- case 6:
622
- if ((_step2 = _iterator2.n()).done) {
623
- _context.next = 19;
624
- break;
387
+ catch (error) {
388
+ console.error(error);
625
389
  }
626
-
627
- callback = _step2.value;
628
- _context.prev = 8;
629
- _context.next = 11;
630
- return callback(accumulator);
631
-
632
- case 11:
633
- accumulator = _context.sent;
634
- _context.next = 17;
635
- break;
636
-
637
- case 14:
638
- _context.prev = 14;
639
- _context.t0 = _context["catch"](8);
640
- console.error(_context.t0);
641
-
642
- case 17:
643
- _context.next = 6;
644
- break;
645
-
646
- case 19:
647
- _context.next = 24;
648
- break;
649
-
650
- case 21:
651
- _context.prev = 21;
652
- _context.t1 = _context["catch"](4);
653
-
654
- _iterator2.e(_context.t1);
655
-
656
- case 24:
657
- _context.prev = 24;
658
-
659
- _iterator2.f();
660
-
661
- return _context.finish(24);
662
-
663
- case 27:
664
- return _context.abrupt("return", accumulator);
665
-
666
- case 28:
667
- case "end":
668
- return _context.stop();
669
390
  }
670
- }
671
- }, _callee, this, [[4, 21, 24, 27], [8, 14]]);
672
- }));
673
-
674
- function evaluateAsyncExtensionPoint(_x, _x2) {
675
- return _evaluateAsyncExtensionPoint.apply(this, arguments);
676
- }
677
-
678
- return evaluateAsyncExtensionPoint;
679
- }()
680
- }]);
681
- return PluginManager;
682
- }();
683
-
684
- exports.default = PluginManager;
391
+ }
392
+ return accumulator;
393
+ }
394
+ }
395
+ exports.default = PluginManager;