@jbrowse/plugin-data-management 1.5.1 → 1.5.5

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.
@@ -1,7 +1,13 @@
1
1
  /// <reference types="react" />
2
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema';
2
3
  declare const AssemblyTable: ({ rootModel, setIsAssemblyBeingEdited, setAssemblyBeingEdited, }: {
3
- rootModel: any;
4
+ rootModel: {
5
+ jbrowse: {
6
+ removeAssemblyConf: (arg: string) => void;
7
+ assemblies: AnyConfigurationModel[];
8
+ };
9
+ };
4
10
  setIsAssemblyBeingEdited(arg: boolean): void;
5
- setAssemblyBeingEdited(arg: any): void;
11
+ setAssemblyBeingEdited(arg: AnyConfigurationModel): void;
6
12
  }) => JSX.Element;
7
13
  export default AssemblyTable;
@@ -2,7 +2,7 @@
2
2
  import { PluginStoreModel } from '../model';
3
3
  declare function CustomPluginForm({ open, onClose, model, }: {
4
4
  open: boolean;
5
- onClose: () => void;
5
+ onClose(): void;
6
6
  model: PluginStoreModel;
7
7
  }): JSX.Element;
8
8
  declare const _default: typeof CustomPluginForm;
@@ -40,14 +40,15 @@ var core = require('@material-ui/core');
40
40
  var ExpandMoreIcon = _interopDefault(require('@material-ui/icons/ExpandMore'));
41
41
  var ClearIcon = _interopDefault(require('@material-ui/icons/Clear'));
42
42
  var InfoOutlinedIcon = _interopDefault(require('@material-ui/icons/InfoOutlined'));
43
- var styles = require('@material-ui/core/styles');
44
43
  var CloseIcon = _interopDefault(require('@material-ui/icons/Close'));
45
44
  var LockIcon = _interopDefault(require('@material-ui/icons/Lock'));
46
45
  var types = require('@jbrowse/core/util/types');
47
46
  var PersonIcon = _interopDefault(require('@material-ui/icons/Person'));
48
47
  var AddIcon = _interopDefault(require('@material-ui/icons/Add'));
49
48
  var CheckIcon = _interopDefault(require('@material-ui/icons/Check'));
49
+ var clsx = _interopDefault(require('clsx'));
50
50
  var IconButton = _interopDefault(require('@material-ui/core/IconButton'));
51
+ var styles = require('@material-ui/core/styles');
51
52
  var ArrowBackIosIcon = _interopDefault(require('@material-ui/icons/ArrowBackIos'));
52
53
  var CreateIcon = _interopDefault(require('@material-ui/icons/Create'));
53
54
  var DeleteIcon = _interopDefault(require('@material-ui/icons/Delete'));
@@ -78,14 +79,9 @@ function ownKeys(object, enumerableOnly) {
78
79
 
79
80
  if (Object.getOwnPropertySymbols) {
80
81
  var symbols = Object.getOwnPropertySymbols(object);
81
-
82
- if (enumerableOnly) {
83
- symbols = symbols.filter(function (sym) {
84
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
85
- });
86
- }
87
-
88
- keys.push.apply(keys, symbols);
82
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
83
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
84
+ })), keys.push.apply(keys, symbols);
89
85
  }
90
86
 
91
87
  return keys;
@@ -93,19 +89,12 @@ function ownKeys(object, enumerableOnly) {
93
89
 
94
90
  function _objectSpread2(target) {
95
91
  for (var i = 1; i < arguments.length; i++) {
96
- var source = arguments[i] != null ? arguments[i] : {};
97
-
98
- if (i % 2) {
99
- ownKeys(Object(source), true).forEach(function (key) {
100
- _defineProperty(target, key, source[key]);
101
- });
102
- } else if (Object.getOwnPropertyDescriptors) {
103
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
104
- } else {
105
- ownKeys(Object(source)).forEach(function (key) {
106
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
107
- });
108
- }
92
+ var source = null != arguments[i] ? arguments[i] : {};
93
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
94
+ _defineProperty(target, key, source[key]);
95
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
96
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
97
+ });
109
98
  }
110
99
 
111
100
  return target;
@@ -114,17 +103,11 @@ function _objectSpread2(target) {
114
103
  function _typeof(obj) {
115
104
  "@babel/helpers - typeof";
116
105
 
117
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
118
- _typeof = function (obj) {
119
- return typeof obj;
120
- };
121
- } else {
122
- _typeof = function (obj) {
123
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
124
- };
125
- }
126
-
127
- return _typeof(obj);
106
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
107
+ return typeof obj;
108
+ } : function (obj) {
109
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
110
+ }, _typeof(obj);
128
111
  }
129
112
 
130
113
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -182,6 +165,9 @@ function _defineProperties(target, props) {
182
165
  function _createClass(Constructor, protoProps, staticProps) {
183
166
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
184
167
  if (staticProps) _defineProperties(Constructor, staticProps);
168
+ Object.defineProperty(Constructor, "prototype", {
169
+ writable: false
170
+ });
185
171
  return Constructor;
186
172
  }
187
173
 
@@ -205,12 +191,15 @@ function _inherits(subClass, superClass) {
205
191
  throw new TypeError("Super expression must either be null or a function");
206
192
  }
207
193
 
208
- subClass.prototype = Object.create(superClass && superClass.prototype, {
209
- constructor: {
210
- value: subClass,
211
- writable: true,
212
- configurable: true
213
- }
194
+ Object.defineProperty(subClass, "prototype", {
195
+ value: Object.create(superClass && superClass.prototype, {
196
+ constructor: {
197
+ value: subClass,
198
+ writable: true,
199
+ configurable: true
200
+ }
201
+ }),
202
+ writable: false
214
203
  });
215
204
  if (superClass) _setPrototypeOf(subClass, superClass);
216
205
  }
@@ -1799,7 +1788,8 @@ function f(pluginManager) {
1799
1788
 
1800
1789
  var track = self.trackData,
1801
1790
  index = self.indexTrackData;
1802
- return !!(index !== null && index !== void 0 && (_index$uri = index.uri) !== null && _index$uri !== void 0 && _index$uri.startsWith('ftp://') || track !== null && track !== void 0 && (_track$uri = track.uri) !== null && _track$uri !== void 0 && _track$uri.startsWith('ftp://'));
1791
+ return !!( // @ts-ignore
1792
+ index !== null && index !== void 0 && (_index$uri = index.uri) !== null && _index$uri !== void 0 && _index$uri.startsWith('ftp://') || track !== null && track !== void 0 && (_track$uri = track.uri) !== null && _track$uri !== void 0 && _track$uri.startsWith('ftp://'));
1803
1793
  },
1804
1794
 
1805
1795
  get isRelativeTrackUrl() {
@@ -1895,9 +1885,9 @@ var hasAnyOverlap = function hasAnyOverlap() {
1895
1885
  function passesFilter(filter, config) {
1896
1886
  var name = getTrackName(config);
1897
1887
  var categories = configuration.readConfObject(config, 'category') || [];
1898
- var regexp = new RegExp(filter, 'i');
1899
- return !!name.match(regexp) || categories.filter(function (cat) {
1900
- return !!cat.match(regexp);
1888
+ var filterLower = filter.toLowerCase();
1889
+ return !!name.toLowerCase().includes(filterLower) || categories.filter(function (cat) {
1890
+ return !!cat.toLowerCase().includes(filterLower);
1901
1891
  }).length;
1902
1892
  }
1903
1893
 
@@ -2163,7 +2153,7 @@ var HierarchicalTrackSelectorStateModelFactory = (function (pluginManager) {
2163
2153
 
2164
2154
  var configSchema$2 = /*#__PURE__*/configuration.ConfigurationSchema('HierarchicalTrackSelectorWidget', {});
2165
2155
 
2166
- var useStyles = /*#__PURE__*/styles.makeStyles(function () {
2156
+ var useStyles = /*#__PURE__*/core.makeStyles(function () {
2167
2157
  return {
2168
2158
  closeDialog: {
2169
2159
  position: 'absolute',
@@ -2202,7 +2192,7 @@ function PluginDialog(_ref) {
2202
2192
  onClick: function onClick() {
2203
2193
  return _onClose();
2204
2194
  }
2205
- }, /*#__PURE__*/React__default.createElement(CloseIcon, null))), /*#__PURE__*/React__default.createElement(core.DialogContent, null, /*#__PURE__*/React__default.createElement(core.Typography, null, "Please confirm that you want to remove ", plugin, ":"), /*#__PURE__*/React__default.createElement(core.DialogActions, null, /*#__PURE__*/React__default.createElement(core.Button, {
2195
+ }, /*#__PURE__*/React__default.createElement(CloseIcon, null))), /*#__PURE__*/React__default.createElement(core.DialogContent, null, /*#__PURE__*/React__default.createElement(core.Typography, null, "Please confirm that you want to remove ", plugin, ". Note: if any resources in this session still use this plugin, it may cause your session to crash"), /*#__PURE__*/React__default.createElement(core.DialogActions, null, /*#__PURE__*/React__default.createElement(core.Button, {
2206
2196
  variant: "contained",
2207
2197
  color: "primary",
2208
2198
  onClick: function onClick() {
@@ -2230,8 +2220,7 @@ function InstalledPlugin(_ref2) {
2230
2220
  dialogPlugin = _useState2[0],
2231
2221
  setDialogPlugin = _useState2[1];
2232
2222
 
2233
- var session = util.getSession(model); // @ts-ignore
2234
-
2223
+ var session = util.getSession(model);
2235
2224
  var sessionPlugins = session.sessionPlugins;
2236
2225
  var isSessionPlugin = sessionPlugins === null || sessionPlugins === void 0 ? void 0 : sessionPlugins.some(function (p) {
2237
2226
  return pluginManager.pluginMetadata[plugin.name].url === p.url;
@@ -2244,12 +2233,11 @@ function InstalledPlugin(_ref2) {
2244
2233
  onClose: function onClose(name) {
2245
2234
  if (name) {
2246
2235
  var pluginMetadata = pluginManager.pluginMetadata[plugin.name];
2247
- var pluginUrl = pluginMetadata.url;
2248
2236
 
2249
2237
  if (adminMode) {
2250
- jbrowse.removePlugin(pluginUrl);
2238
+ jbrowse.removePlugin(pluginMetadata);
2251
2239
  } else if (types.isSessionWithSessionPlugins(session)) {
2252
- session.removeSessionPlugin(pluginUrl);
2240
+ session.removeSessionPlugin(pluginMetadata);
2253
2241
  }
2254
2242
  }
2255
2243
 
@@ -2380,87 +2368,182 @@ function PluginCard(_ref) {
2380
2368
 
2381
2369
  var PluginCard$1 = /*#__PURE__*/mobxReact.observer(PluginCard);
2382
2370
 
2383
- var useStyles$2 = /*#__PURE__*/core.makeStyles(function () {
2371
+ var useStyles$2 = /*#__PURE__*/core.makeStyles(function (theme) {
2384
2372
  return {
2385
- closeDialog: {
2373
+ closeButton: {
2386
2374
  position: 'absolute',
2387
- right: 0,
2388
- top: 0
2375
+ right: theme.spacing(1),
2376
+ top: theme.spacing(1)
2389
2377
  },
2390
- dialogContainer: {
2391
- margin: 15,
2378
+ dialogContent: {
2392
2379
  display: 'flex',
2393
2380
  flexDirection: 'column'
2381
+ },
2382
+ expand: {
2383
+ transform: 'rotate(0deg)',
2384
+ marginLeft: 'auto',
2385
+ transition: theme.transitions.create('transform', {
2386
+ duration: theme.transitions.duration.shortest
2387
+ })
2388
+ },
2389
+ expandOpen: {
2390
+ transform: 'rotate(180deg)'
2394
2391
  }
2395
2392
  };
2396
2393
  });
2397
2394
 
2398
2395
  function CustomPluginForm(_ref) {
2399
2396
  var open = _ref.open,
2400
- _onClose = _ref.onClose,
2397
+ onClose = _ref.onClose,
2401
2398
  model = _ref.model;
2402
2399
  var classes = useStyles$2();
2403
2400
 
2404
2401
  var _useState = React.useState(''),
2405
2402
  _useState2 = _slicedToArray(_useState, 2),
2406
- formName = _useState2[0],
2407
- setFormName = _useState2[1];
2403
+ umdPluginName = _useState2[0],
2404
+ setUMDPluginName = _useState2[1];
2408
2405
 
2409
2406
  var _useState3 = React.useState(''),
2410
2407
  _useState4 = _slicedToArray(_useState3, 2),
2411
- formUrl = _useState4[0],
2412
- setFormUrl = _useState4[1];
2408
+ umdPluginUrl = _useState4[0],
2409
+ setUMDPluginUrl = _useState4[1];
2410
+
2411
+ var _useState5 = React.useState(''),
2412
+ _useState6 = _slicedToArray(_useState5, 2),
2413
+ esmPluginUrl = _useState6[0],
2414
+ setESMPluginUrl = _useState6[1];
2415
+
2416
+ var _useState7 = React.useState(''),
2417
+ _useState8 = _slicedToArray(_useState7, 2),
2418
+ cjsPluginUrl = _useState8[0],
2419
+ setCJSPluginUrl = _useState8[1];
2420
+
2421
+ var _useState9 = React.useState(false),
2422
+ _useState10 = _slicedToArray(_useState9, 2),
2423
+ advancedOptionsOpen = _useState10[0],
2424
+ setAdvancedOptionsOpen = _useState10[1];
2425
+
2426
+ function handleChange(event) {
2427
+ var _event$target = event.target,
2428
+ name = _event$target.name,
2429
+ value = _event$target.value;
2430
+
2431
+ if (name === 'umdName') {
2432
+ setUMDPluginName(value);
2433
+ }
2434
+
2435
+ if (name === 'umdUrl') {
2436
+ setUMDPluginUrl(value);
2437
+ }
2438
+
2439
+ if (name === 'esmUrl') {
2440
+ setESMPluginUrl(value);
2441
+ }
2442
+
2443
+ if (name === 'cjsUrl') {
2444
+ setCJSPluginUrl(value);
2445
+ }
2446
+ }
2447
+
2448
+ function handleOpenAdvancedOptions() {
2449
+ setAdvancedOptionsOpen(!advancedOptionsOpen);
2450
+ }
2413
2451
 
2414
2452
  var rootModel = mobxStateTree.getRoot(model);
2415
2453
  var jbrowse = rootModel.jbrowse;
2454
+ var ready = Boolean(umdPluginName && umdPluginUrl || esmPluginUrl || cjsPluginUrl);
2455
+
2456
+ function handleSubmit() {
2457
+ if (!ready) {
2458
+ return;
2459
+ }
2460
+
2461
+ var pluginDefinition = {};
2462
+
2463
+ if (umdPluginName && umdPluginUrl) {
2464
+ pluginDefinition.name = umdPluginName;
2465
+ pluginDefinition.umdUrl = umdPluginUrl;
2466
+ }
2467
+
2468
+ if (esmPluginUrl) {
2469
+ pluginDefinition.esmUrl = esmPluginUrl;
2470
+ }
2471
+
2472
+ if (cjsPluginUrl) {
2473
+ pluginDefinition.cjsUrl = cjsPluginUrl;
2474
+ }
2475
+
2476
+ jbrowse.addPlugin(pluginDefinition);
2477
+ }
2478
+
2479
+ function handleClose() {
2480
+ setUMDPluginName('');
2481
+ setUMDPluginUrl('');
2482
+ setESMPluginUrl('');
2483
+ setCJSPluginUrl('');
2484
+ onClose();
2485
+ }
2486
+
2416
2487
  return /*#__PURE__*/React__default.createElement(core.Dialog, {
2417
2488
  open: open,
2418
- onClose: function onClose() {
2419
- return _onClose();
2420
- }
2489
+ onClose: handleClose
2421
2490
  }, /*#__PURE__*/React__default.createElement(core.DialogTitle, null, "Add custom plugin", /*#__PURE__*/React__default.createElement(IconButton, {
2422
- className: classes.closeDialog,
2491
+ size: "medium",
2492
+ className: classes.closeButton,
2423
2493
  onClick: function onClick() {
2424
- return _onClose();
2494
+ return onClose();
2425
2495
  }
2426
- }, /*#__PURE__*/React__default.createElement(CloseIcon, null))), /*#__PURE__*/React__default.createElement(core.DialogContent, null, /*#__PURE__*/React__default.createElement("div", {
2427
- className: classes.dialogContainer
2428
- }, /*#__PURE__*/React__default.createElement(core.Typography, null, "Specify the name and URL path of your plugin source"), /*#__PURE__*/React__default.createElement(core.TextField, {
2429
- id: "name-input",
2430
- name: "name",
2496
+ }, /*#__PURE__*/React__default.createElement(CloseIcon, null))), /*#__PURE__*/React__default.createElement("form", {
2497
+ onSubmit: handleSubmit
2498
+ }, /*#__PURE__*/React__default.createElement(core.DialogContent, {
2499
+ className: classes.dialogContent
2500
+ }, /*#__PURE__*/React__default.createElement(core.DialogContentText, null, "Enter the name of the plugin and its URL. The name should match what is defined in the plugin's build."), /*#__PURE__*/React__default.createElement(core.TextField, {
2501
+ id: "umd-name-input",
2502
+ name: "umdName",
2431
2503
  label: "Plugin name",
2432
2504
  variant: "outlined",
2433
- value: formName,
2434
- onChange: function onChange(event) {
2435
- return setFormName(event.target.value);
2436
- }
2505
+ value: umdPluginName,
2506
+ onChange: handleChange
2437
2507
  }), /*#__PURE__*/React__default.createElement(core.TextField, {
2438
- id: "url-input",
2439
- name: "url",
2508
+ id: "umd-url-input",
2509
+ name: "umdUrl",
2440
2510
  label: "Plugin URL",
2441
2511
  variant: "outlined",
2442
- value: formUrl,
2443
- onChange: function onChange(event) {
2444
- return setFormUrl(event.target.value);
2445
- }
2446
- }))), /*#__PURE__*/React__default.createElement(core.DialogActions, null, /*#__PURE__*/React__default.createElement(core.Button, {
2512
+ value: umdPluginUrl,
2513
+ onChange: handleChange
2514
+ }), /*#__PURE__*/React__default.createElement(core.DialogContentText, {
2515
+ onClick: handleOpenAdvancedOptions
2516
+ }, /*#__PURE__*/React__default.createElement(IconButton, {
2517
+ className: clsx(classes.expand, _defineProperty({}, classes.expandOpen, advancedOptionsOpen)),
2518
+ "aria-expanded": advancedOptionsOpen,
2519
+ "aria-label": "show more"
2520
+ }, /*#__PURE__*/React__default.createElement(ExpandMoreIcon, null)), "Advanced options"), /*#__PURE__*/React__default.createElement(core.Collapse, {
2521
+ "in": advancedOptionsOpen
2522
+ }, /*#__PURE__*/React__default.createElement("div", {
2523
+ className: classes.dialogContent
2524
+ }, /*#__PURE__*/React__default.createElement(core.DialogContentText, null, "The above fields assume that the plugin is built in UMD format. If your plugin is in another format, or you have additional builds you want to add (such as a CJS build for using NodeJS APIs in desktop), you can enter the URLs for those builds below."), /*#__PURE__*/React__default.createElement(core.TextField, {
2525
+ id: "esm-url-input",
2526
+ name: "esmUrl",
2527
+ label: "ESM build URL",
2528
+ variant: "outlined",
2529
+ value: esmPluginUrl,
2530
+ onChange: handleChange
2531
+ }), /*#__PURE__*/React__default.createElement(core.TextField, {
2532
+ id: "cjs-url-input",
2533
+ name: "cjsUrl",
2534
+ label: "CJS build URL",
2535
+ variant: "outlined",
2536
+ value: cjsPluginUrl,
2537
+ onChange: handleChange
2538
+ })))), /*#__PURE__*/React__default.createElement(core.DialogActions, null, /*#__PURE__*/React__default.createElement(core.Button, {
2447
2539
  variant: "contained",
2448
- color: "secondary",
2449
- onClick: function onClick() {
2450
- return _onClose();
2451
- }
2540
+ onClick: handleClose
2452
2541
  }, "Cancel"), /*#__PURE__*/React__default.createElement(core.Button, {
2453
2542
  variant: "contained",
2454
2543
  color: "primary",
2455
- onClick: function onClick() {
2456
- jbrowse.addPlugin({
2457
- name: formName,
2458
- url: formUrl
2459
- });
2460
-
2461
- _onClose();
2462
- }
2463
- }, "Submit")));
2544
+ onClick: handleSubmit,
2545
+ disabled: !ready
2546
+ }, "Submit"))));
2464
2547
  }
2465
2548
 
2466
2549
  var CustomPluginForm$1 = /*#__PURE__*/mobxReact.observer(CustomPluginForm);
@@ -2516,7 +2599,8 @@ function PluginStoreWidget(_ref) {
2516
2599
  pluginManager = _getEnv.pluginManager;
2517
2600
 
2518
2601
  React.useEffect(function () {
2519
- var killed = false;
2602
+ var controller = new AbortController();
2603
+ var signal = controller.signal;
2520
2604
 
2521
2605
  _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2522
2606
  var response, err, array;
@@ -2526,7 +2610,9 @@ function PluginStoreWidget(_ref) {
2526
2610
  case 0:
2527
2611
  _context.prev = 0;
2528
2612
  _context.next = 3;
2529
- return fetch('https://jbrowse.org/plugin-store/plugins.json');
2613
+ return fetch('https://jbrowse.org/plugin-store/plugins.json', {
2614
+ signal: signal
2615
+ });
2530
2616
 
2531
2617
  case 3:
2532
2618
  response = _context.sent;
@@ -2550,7 +2636,7 @@ function PluginStoreWidget(_ref) {
2550
2636
  case 11:
2551
2637
  array = _context.sent;
2552
2638
 
2553
- if (!killed) {
2639
+ if (!signal.aborted) {
2554
2640
  setPluginArray(array.plugins);
2555
2641
  }
2556
2642
 
@@ -2572,7 +2658,7 @@ function PluginStoreWidget(_ref) {
2572
2658
  }))();
2573
2659
 
2574
2660
  return function () {
2575
- killed = true;
2661
+ controller.abort();
2576
2662
  };
2577
2663
  }, []);
2578
2664
  return /*#__PURE__*/React__default.createElement("div", {
@@ -2640,6 +2726,11 @@ function PluginStoreWidget(_ref) {
2640
2726
  }, "Available plugins")), error ? /*#__PURE__*/React__default.createElement(core.Typography, {
2641
2727
  color: "error"
2642
2728
  }, "".concat(error)) : pluginArray ? pluginArray.filter(function (plugin) {
2729
+ // If pugin only has cjsUrl, don't display outside desktop
2730
+ if (!util.isElectron && !(plugin.esmUrl || plugin.url || plugin.umdUrl)) {
2731
+ return false;
2732
+ }
2733
+
2643
2734
  return plugin.name.toLowerCase().includes(model.filterText.toLowerCase());
2644
2735
  }).map(function (plugin) {
2645
2736
  return /*#__PURE__*/React__default.createElement(PluginCard$1, {