@jbrowse/plugin-config 1.6.9 → 1.7.3

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 (56) hide show
  1. package/dist/ConfigurationEditorWidget/components/CallbackEditor.d.ts +9 -9
  2. package/dist/ConfigurationEditorWidget/components/CallbackEditor.js +123 -0
  3. package/dist/ConfigurationEditorWidget/components/CodeEditor.d.ts +4 -4
  4. package/dist/ConfigurationEditorWidget/components/CodeEditor.js +77 -0
  5. package/dist/ConfigurationEditorWidget/components/ColorEditor.d.ts +44 -44
  6. package/dist/ConfigurationEditorWidget/components/ColorEditor.js +125 -0
  7. package/dist/ConfigurationEditorWidget/components/ColorEditor.test.js +31 -0
  8. package/dist/ConfigurationEditorWidget/components/ColorPicker.d.ts +14 -14
  9. package/dist/ConfigurationEditorWidget/components/ColorPicker.js +72 -0
  10. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +4 -4
  11. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +176 -0
  12. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.test.js +121 -0
  13. package/dist/ConfigurationEditorWidget/components/JsonEditor.d.ts +9 -9
  14. package/dist/ConfigurationEditorWidget/components/JsonEditor.js +82 -0
  15. package/dist/ConfigurationEditorWidget/components/SlotEditor.d.ts +6 -6
  16. package/dist/ConfigurationEditorWidget/components/SlotEditor.js +438 -0
  17. package/dist/ConfigurationEditorWidget/components/TypeSelector.d.ts +7 -7
  18. package/dist/ConfigurationEditorWidget/components/TypeSelector.js +48 -0
  19. package/dist/ConfigurationEditorWidget/index.d.ts +3 -3
  20. package/dist/ConfigurationEditorWidget/index.js +45 -0
  21. package/dist/ConfigurationEditorWidget/model.d.ts +8 -8
  22. package/dist/ConfigurationEditorWidget/model.js +28 -0
  23. package/dist/FromConfigAdapter/FromConfigAdapter.d.ts +24 -24
  24. package/dist/FromConfigAdapter/FromConfigAdapter.js +215 -0
  25. package/dist/FromConfigAdapter/FromConfigAdapter.test.js +100 -0
  26. package/dist/FromConfigAdapter/FromConfigRegionsAdapter.d.ts +23 -23
  27. package/dist/FromConfigAdapter/FromConfigRegionsAdapter.js +154 -0
  28. package/dist/FromConfigAdapter/FromConfigRegionsAdapter.test.js +200 -0
  29. package/dist/FromConfigAdapter/FromConfigSequenceAdapter.d.ts +25 -25
  30. package/dist/FromConfigAdapter/FromConfigSequenceAdapter.js +201 -0
  31. package/dist/FromConfigAdapter/FromConfigSequenceAdapter.test.js +110 -0
  32. package/dist/FromConfigAdapter/configSchema.d.ts +3 -3
  33. package/dist/FromConfigAdapter/configSchema.js +51 -0
  34. package/dist/FromConfigAdapter/index.d.ts +4 -4
  35. package/dist/FromConfigAdapter/index.js +51 -0
  36. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.d.ts +8 -8
  37. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +125 -0
  38. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.test.js +41 -0
  39. package/dist/RefNameAliasAdapter/configSchema.d.ts +2 -2
  40. package/dist/RefNameAliasAdapter/configSchema.js +26 -0
  41. package/dist/RefNameAliasAdapter/index.d.ts +2 -2
  42. package/dist/RefNameAliasAdapter/index.js +23 -0
  43. package/dist/index.d.ts +12 -12
  44. package/dist/index.js +150 -6
  45. package/dist/index.test.js +41 -0
  46. package/package.json +5 -7
  47. package/src/ConfigurationEditorWidget/components/ConfigurationEditor.js +22 -17
  48. package/src/ConfigurationEditorWidget/components/JsonEditor.js +1 -2
  49. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.test.d.ts +0 -1
  50. package/dist/index.test.d.ts +0 -1
  51. package/dist/plugin-config.cjs.development.js +0 -2740
  52. package/dist/plugin-config.cjs.development.js.map +0 -1
  53. package/dist/plugin-config.cjs.production.min.js +0 -2
  54. package/dist/plugin-config.cjs.production.min.js.map +0 -1
  55. package/dist/plugin-config.esm.js +0 -2732
  56. package/dist/plugin-config.esm.js.map +0 -1
@@ -1,2732 +0,0 @@
1
- import React, { useState, useEffect, lazy } from 'react';
2
- import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
3
- import WidgetType from '@jbrowse/core/pluggableElementTypes/WidgetType';
4
- import Plugin from '@jbrowse/core/Plugin';
5
- import { observer, PropTypes } from 'mobx-react';
6
- import { types, isStateTreeNode, getType, getEnv, getPropertyMembers, getMembers } from 'mobx-state-tree';
7
- import { ConfigurationSchema, readConfObject, isConfigurationSchemaType, getTypeNamesFromExplicitlyTypedUnion, isConfigurationSlotType } from '@jbrowse/core/configuration';
8
- import { ElementId } from '@jbrowse/core/util/types/mst';
9
- import { BaseFeatureDataAdapter, BaseAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
10
- import SimpleFeature from '@jbrowse/core/util/simpleFeature';
11
- import { ObservableCreate } from '@jbrowse/core/util/rxjs';
12
- import { toArray } from 'rxjs/operators';
13
- import { openLocation } from '@jbrowse/core/util/io';
14
- import { useDebounce } from '@jbrowse/core/util';
15
- import { FormControl, InputLabel, FormHelperText, makeStyles, useTheme, Tooltip, IconButton, Paper, TextField as TextField$1, SvgIcon, List, ListItem, InputAdornment, Card, CardHeader, CardContent, FormControlLabel, Checkbox, MenuItem, Accordion, AccordionSummary, Typography, AccordionDetails, FormGroup } from '@material-ui/core';
16
- import Editor from 'react-simple-code-editor';
17
- import { Light } from 'react-syntax-highlighter';
18
- import json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json';
19
- import a11yDark from 'react-syntax-highlighter/dist/cjs/styles/hljs/a11y-dark';
20
- import a11yLight from 'react-syntax-highlighter/dist/cjs/styles/hljs/a11y-light';
21
- import { singular } from 'pluralize';
22
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
23
- import { FileSelector } from '@jbrowse/core/ui';
24
- import { getSubType, getUnionSubTypes, getPropertyType } from '@jbrowse/core/util/mst-reflection';
25
- import DeleteIcon from '@material-ui/icons/Delete';
26
- import AddIcon from '@material-ui/icons/Add';
27
- import RadioButtonUncheckedIcon from '@material-ui/icons/RadioButtonUnchecked';
28
- import { stringToJexlExpression } from '@jbrowse/core/util/jexlStrings';
29
- import HelpIcon from '@material-ui/icons/Help';
30
- import ReactPropTypes from 'prop-types';
31
- import TextField from '@material-ui/core/TextField';
32
- import MenuItem$1 from '@material-ui/core/MenuItem';
33
- import Paper$1 from '@material-ui/core/Paper';
34
- import { makeStyles as makeStyles$1 } from '@material-ui/core/styles';
35
- import { ChromePicker } from 'react-color';
36
-
37
- function ownKeys(object, enumerableOnly) {
38
- var keys = Object.keys(object);
39
-
40
- if (Object.getOwnPropertySymbols) {
41
- var symbols = Object.getOwnPropertySymbols(object);
42
- enumerableOnly && (symbols = symbols.filter(function (sym) {
43
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
44
- })), keys.push.apply(keys, symbols);
45
- }
46
-
47
- return keys;
48
- }
49
-
50
- function _objectSpread2(target) {
51
- for (var i = 1; i < arguments.length; i++) {
52
- var source = null != arguments[i] ? arguments[i] : {};
53
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
54
- _defineProperty(target, key, source[key]);
55
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
56
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
57
- });
58
- }
59
-
60
- return target;
61
- }
62
-
63
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
64
- try {
65
- var info = gen[key](arg);
66
- var value = info.value;
67
- } catch (error) {
68
- reject(error);
69
- return;
70
- }
71
-
72
- if (info.done) {
73
- resolve(value);
74
- } else {
75
- Promise.resolve(value).then(_next, _throw);
76
- }
77
- }
78
-
79
- function _asyncToGenerator(fn) {
80
- return function () {
81
- var self = this,
82
- args = arguments;
83
- return new Promise(function (resolve, reject) {
84
- var gen = fn.apply(self, args);
85
-
86
- function _next(value) {
87
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
88
- }
89
-
90
- function _throw(err) {
91
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
92
- }
93
-
94
- _next(undefined);
95
- });
96
- };
97
- }
98
-
99
- function _classCallCheck(instance, Constructor) {
100
- if (!(instance instanceof Constructor)) {
101
- throw new TypeError("Cannot call a class as a function");
102
- }
103
- }
104
-
105
- function _defineProperties(target, props) {
106
- for (var i = 0; i < props.length; i++) {
107
- var descriptor = props[i];
108
- descriptor.enumerable = descriptor.enumerable || false;
109
- descriptor.configurable = true;
110
- if ("value" in descriptor) descriptor.writable = true;
111
- Object.defineProperty(target, descriptor.key, descriptor);
112
- }
113
- }
114
-
115
- function _createClass(Constructor, protoProps, staticProps) {
116
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
117
- if (staticProps) _defineProperties(Constructor, staticProps);
118
- Object.defineProperty(Constructor, "prototype", {
119
- writable: false
120
- });
121
- return Constructor;
122
- }
123
-
124
- function _defineProperty(obj, key, value) {
125
- if (key in obj) {
126
- Object.defineProperty(obj, key, {
127
- value: value,
128
- enumerable: true,
129
- configurable: true,
130
- writable: true
131
- });
132
- } else {
133
- obj[key] = value;
134
- }
135
-
136
- return obj;
137
- }
138
-
139
- function _extends() {
140
- _extends = Object.assign || function (target) {
141
- for (var i = 1; i < arguments.length; i++) {
142
- var source = arguments[i];
143
-
144
- for (var key in source) {
145
- if (Object.prototype.hasOwnProperty.call(source, key)) {
146
- target[key] = source[key];
147
- }
148
- }
149
- }
150
-
151
- return target;
152
- };
153
-
154
- return _extends.apply(this, arguments);
155
- }
156
-
157
- function _inherits(subClass, superClass) {
158
- if (typeof superClass !== "function" && superClass !== null) {
159
- throw new TypeError("Super expression must either be null or a function");
160
- }
161
-
162
- subClass.prototype = Object.create(superClass && superClass.prototype, {
163
- constructor: {
164
- value: subClass,
165
- writable: true,
166
- configurable: true
167
- }
168
- });
169
- Object.defineProperty(subClass, "prototype", {
170
- writable: false
171
- });
172
- if (superClass) _setPrototypeOf(subClass, superClass);
173
- }
174
-
175
- function _getPrototypeOf(o) {
176
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
177
- return o.__proto__ || Object.getPrototypeOf(o);
178
- };
179
- return _getPrototypeOf(o);
180
- }
181
-
182
- function _setPrototypeOf(o, p) {
183
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
184
- o.__proto__ = p;
185
- return o;
186
- };
187
-
188
- return _setPrototypeOf(o, p);
189
- }
190
-
191
- function _isNativeReflectConstruct() {
192
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
193
- if (Reflect.construct.sham) return false;
194
- if (typeof Proxy === "function") return true;
195
-
196
- try {
197
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
198
- return true;
199
- } catch (e) {
200
- return false;
201
- }
202
- }
203
-
204
- function _assertThisInitialized(self) {
205
- if (self === void 0) {
206
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
207
- }
208
-
209
- return self;
210
- }
211
-
212
- function _possibleConstructorReturn(self, call) {
213
- if (call && (typeof call === "object" || typeof call === "function")) {
214
- return call;
215
- } else if (call !== void 0) {
216
- throw new TypeError("Derived constructors may only return object or undefined");
217
- }
218
-
219
- return _assertThisInitialized(self);
220
- }
221
-
222
- function _createSuper(Derived) {
223
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
224
-
225
- return function _createSuperInternal() {
226
- var Super = _getPrototypeOf(Derived),
227
- result;
228
-
229
- if (hasNativeReflectConstruct) {
230
- var NewTarget = _getPrototypeOf(this).constructor;
231
-
232
- result = Reflect.construct(Super, arguments, NewTarget);
233
- } else {
234
- result = Super.apply(this, arguments);
235
- }
236
-
237
- return _possibleConstructorReturn(this, result);
238
- };
239
- }
240
-
241
- function _superPropBase(object, property) {
242
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
243
- object = _getPrototypeOf(object);
244
- if (object === null) break;
245
- }
246
-
247
- return object;
248
- }
249
-
250
- function _get() {
251
- if (typeof Reflect !== "undefined" && Reflect.get) {
252
- _get = Reflect.get;
253
- } else {
254
- _get = function _get(target, property, receiver) {
255
- var base = _superPropBase(target, property);
256
-
257
- if (!base) return;
258
- var desc = Object.getOwnPropertyDescriptor(base, property);
259
-
260
- if (desc.get) {
261
- return desc.get.call(arguments.length < 3 ? target : receiver);
262
- }
263
-
264
- return desc.value;
265
- };
266
- }
267
-
268
- return _get.apply(this, arguments);
269
- }
270
-
271
- function _slicedToArray(arr, i) {
272
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
273
- }
274
-
275
- function _toConsumableArray(arr) {
276
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
277
- }
278
-
279
- function _arrayWithoutHoles(arr) {
280
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
281
- }
282
-
283
- function _arrayWithHoles(arr) {
284
- if (Array.isArray(arr)) return arr;
285
- }
286
-
287
- function _iterableToArray(iter) {
288
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
289
- }
290
-
291
- function _iterableToArrayLimit(arr, i) {
292
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
293
-
294
- if (_i == null) return;
295
- var _arr = [];
296
- var _n = true;
297
- var _d = false;
298
-
299
- var _s, _e;
300
-
301
- try {
302
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
303
- _arr.push(_s.value);
304
-
305
- if (i && _arr.length === i) break;
306
- }
307
- } catch (err) {
308
- _d = true;
309
- _e = err;
310
- } finally {
311
- try {
312
- if (!_n && _i["return"] != null) _i["return"]();
313
- } finally {
314
- if (_d) throw _e;
315
- }
316
- }
317
-
318
- return _arr;
319
- }
320
-
321
- function _unsupportedIterableToArray(o, minLen) {
322
- if (!o) return;
323
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
324
- var n = Object.prototype.toString.call(o).slice(8, -1);
325
- if (n === "Object" && o.constructor) n = o.constructor.name;
326
- if (n === "Map" || n === "Set") return Array.from(o);
327
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
328
- }
329
-
330
- function _arrayLikeToArray(arr, len) {
331
- if (len == null || len > arr.length) len = arr.length;
332
-
333
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
334
-
335
- return arr2;
336
- }
337
-
338
- function _nonIterableSpread() {
339
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
340
- }
341
-
342
- function _nonIterableRest() {
343
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
344
- }
345
-
346
- function _createForOfIteratorHelper(o, allowArrayLike) {
347
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
348
-
349
- if (!it) {
350
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
351
- if (it) o = it;
352
- var i = 0;
353
-
354
- var F = function () {};
355
-
356
- return {
357
- s: F,
358
- n: function () {
359
- if (i >= o.length) return {
360
- done: true
361
- };
362
- return {
363
- done: false,
364
- value: o[i++]
365
- };
366
- },
367
- e: function (e) {
368
- throw e;
369
- },
370
- f: F
371
- };
372
- }
373
-
374
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
375
- }
376
-
377
- var normalCompletion = true,
378
- didErr = false,
379
- err;
380
- return {
381
- s: function () {
382
- it = it.call(o);
383
- },
384
- n: function () {
385
- var step = it.next();
386
- normalCompletion = step.done;
387
- return step;
388
- },
389
- e: function (e) {
390
- didErr = true;
391
- err = e;
392
- },
393
- f: function () {
394
- try {
395
- if (!normalCompletion && it.return != null) it.return();
396
- } finally {
397
- if (didErr) throw err;
398
- }
399
- }
400
- };
401
- }
402
-
403
- var ConfigurationEditorStateModelFactory = (function (pluginManager) {
404
- return types.model('ConfigurationEditorWidget', {
405
- id: ElementId,
406
- type: types.literal('ConfigurationEditorWidget'),
407
- // If you add different types of targets, don't forget to account for that
408
- // in the key of ./components/ConfigurationEditor.js
409
- target: types.safeReference(pluginManager.pluggableConfigSchemaType('track'))
410
- }).actions(function (self) {
411
- return {
412
- setTarget: function setTarget(newTarget) {
413
- self.target = newTarget;
414
- }
415
- };
416
- });
417
- });
418
-
419
- var configSchema = /*#__PURE__*/ConfigurationSchema('ConfigurationEditorWidget', {});
420
- var HeadingComponent = /*#__PURE__*/observer(function (_ref) {
421
- var model = _ref.model;
422
-
423
- if (model && model.target) {
424
- if (model.target.type) {
425
- return "".concat(model.target.type, " settings");
426
- }
427
-
428
- if (isStateTreeNode(model.target)) {
429
- var type = getType(model.target);
430
-
431
- if (type && type.name) {
432
- return "".concat(type.name.replace('ConfigurationSchema', ''), " settings");
433
- }
434
- }
435
- }
436
-
437
- return 'Settings';
438
- });
439
-
440
- function createCommonjsModule(fn, module) {
441
- return module = { exports: {} }, fn(module, module.exports), module.exports;
442
- }
443
-
444
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
445
- /**
446
- * Copyright (c) 2014-present, Facebook, Inc.
447
- *
448
- * This source code is licensed under the MIT license found in the
449
- * LICENSE file in the root directory of this source tree.
450
- */
451
- var runtime = function (exports) {
452
-
453
- var Op = Object.prototype;
454
- var hasOwn = Op.hasOwnProperty;
455
- var undefined$1; // More compressible than void 0.
456
-
457
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
458
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
459
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
460
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
461
-
462
- function define(obj, key, value) {
463
- Object.defineProperty(obj, key, {
464
- value: value,
465
- enumerable: true,
466
- configurable: true,
467
- writable: true
468
- });
469
- return obj[key];
470
- }
471
-
472
- try {
473
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
474
- define({}, "");
475
- } catch (err) {
476
- define = function define(obj, key, value) {
477
- return obj[key] = value;
478
- };
479
- }
480
-
481
- function wrap(innerFn, outerFn, self, tryLocsList) {
482
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
483
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
484
- var generator = Object.create(protoGenerator.prototype);
485
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
486
- // .throw, and .return methods.
487
-
488
- generator._invoke = makeInvokeMethod(innerFn, self, context);
489
- return generator;
490
- }
491
-
492
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
493
- // record like context.tryEntries[i].completion. This interface could
494
- // have been (and was previously) designed to take a closure to be
495
- // invoked without arguments, but in all the cases we care about we
496
- // already have an existing method we want to call, so there's no need
497
- // to create a new function object. We can even get away with assuming
498
- // the method takes exactly one argument, since that happens to be true
499
- // in every case, so we don't have to touch the arguments object. The
500
- // only additional allocation required is the completion record, which
501
- // has a stable shape and so hopefully should be cheap to allocate.
502
-
503
- function tryCatch(fn, obj, arg) {
504
- try {
505
- return {
506
- type: "normal",
507
- arg: fn.call(obj, arg)
508
- };
509
- } catch (err) {
510
- return {
511
- type: "throw",
512
- arg: err
513
- };
514
- }
515
- }
516
-
517
- var GenStateSuspendedStart = "suspendedStart";
518
- var GenStateSuspendedYield = "suspendedYield";
519
- var GenStateExecuting = "executing";
520
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
521
- // breaking out of the dispatch switch statement.
522
-
523
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
524
- // .constructor.prototype properties for functions that return Generator
525
- // objects. For full spec compliance, you may wish to configure your
526
- // minifier not to mangle the names of these two functions.
527
-
528
- function Generator() {}
529
-
530
- function GeneratorFunction() {}
531
-
532
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
533
- // don't natively support it.
534
-
535
-
536
- var IteratorPrototype = {};
537
- define(IteratorPrototype, iteratorSymbol, function () {
538
- return this;
539
- });
540
- var getProto = Object.getPrototypeOf;
541
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
542
-
543
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
544
- // This environment has a native %IteratorPrototype%; use it instead
545
- // of the polyfill.
546
- IteratorPrototype = NativeIteratorPrototype;
547
- }
548
-
549
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
550
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
551
- define(Gp, "constructor", GeneratorFunctionPrototype);
552
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
553
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
554
- // Iterator interface in terms of a single ._invoke method.
555
-
556
- function defineIteratorMethods(prototype) {
557
- ["next", "throw", "return"].forEach(function (method) {
558
- define(prototype, method, function (arg) {
559
- return this._invoke(method, arg);
560
- });
561
- });
562
- }
563
-
564
- exports.isGeneratorFunction = function (genFun) {
565
- var ctor = typeof genFun === "function" && genFun.constructor;
566
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
567
- // do is to check its .name property.
568
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
569
- };
570
-
571
- exports.mark = function (genFun) {
572
- if (Object.setPrototypeOf) {
573
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
574
- } else {
575
- genFun.__proto__ = GeneratorFunctionPrototype;
576
- define(genFun, toStringTagSymbol, "GeneratorFunction");
577
- }
578
-
579
- genFun.prototype = Object.create(Gp);
580
- return genFun;
581
- }; // Within the body of any async function, `await x` is transformed to
582
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
583
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
584
- // meant to be awaited.
585
-
586
-
587
- exports.awrap = function (arg) {
588
- return {
589
- __await: arg
590
- };
591
- };
592
-
593
- function AsyncIterator(generator, PromiseImpl) {
594
- function invoke(method, arg, resolve, reject) {
595
- var record = tryCatch(generator[method], generator, arg);
596
-
597
- if (record.type === "throw") {
598
- reject(record.arg);
599
- } else {
600
- var result = record.arg;
601
- var value = result.value;
602
-
603
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
604
- return PromiseImpl.resolve(value.__await).then(function (value) {
605
- invoke("next", value, resolve, reject);
606
- }, function (err) {
607
- invoke("throw", err, resolve, reject);
608
- });
609
- }
610
-
611
- return PromiseImpl.resolve(value).then(function (unwrapped) {
612
- // When a yielded Promise is resolved, its final value becomes
613
- // the .value of the Promise<{value,done}> result for the
614
- // current iteration.
615
- result.value = unwrapped;
616
- resolve(result);
617
- }, function (error) {
618
- // If a rejected Promise was yielded, throw the rejection back
619
- // into the async generator function so it can be handled there.
620
- return invoke("throw", error, resolve, reject);
621
- });
622
- }
623
- }
624
-
625
- var previousPromise;
626
-
627
- function enqueue(method, arg) {
628
- function callInvokeWithMethodAndArg() {
629
- return new PromiseImpl(function (resolve, reject) {
630
- invoke(method, arg, resolve, reject);
631
- });
632
- }
633
-
634
- return previousPromise = // If enqueue has been called before, then we want to wait until
635
- // all previous Promises have been resolved before calling invoke,
636
- // so that results are always delivered in the correct order. If
637
- // enqueue has not been called before, then it is important to
638
- // call invoke immediately, without waiting on a callback to fire,
639
- // so that the async generator function has the opportunity to do
640
- // any necessary setup in a predictable way. This predictability
641
- // is why the Promise constructor synchronously invokes its
642
- // executor callback, and why async functions synchronously
643
- // execute code before the first await. Since we implement simple
644
- // async functions in terms of async generators, it is especially
645
- // important to get this right, even though it requires care.
646
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
647
- // invocations of the iterator.
648
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
649
- } // Define the unified helper method that is used to implement .next,
650
- // .throw, and .return (see defineIteratorMethods).
651
-
652
-
653
- this._invoke = enqueue;
654
- }
655
-
656
- defineIteratorMethods(AsyncIterator.prototype);
657
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
658
- return this;
659
- });
660
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
661
- // AsyncIterator objects; they just return a Promise for the value of
662
- // the final result produced by the iterator.
663
-
664
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
665
- if (PromiseImpl === void 0) PromiseImpl = Promise;
666
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
667
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
668
- : iter.next().then(function (result) {
669
- return result.done ? result.value : iter.next();
670
- });
671
- };
672
-
673
- function makeInvokeMethod(innerFn, self, context) {
674
- var state = GenStateSuspendedStart;
675
- return function invoke(method, arg) {
676
- if (state === GenStateExecuting) {
677
- throw new Error("Generator is already running");
678
- }
679
-
680
- if (state === GenStateCompleted) {
681
- if (method === "throw") {
682
- throw arg;
683
- } // Be forgiving, per 25.3.3.3.3 of the spec:
684
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
685
-
686
-
687
- return doneResult();
688
- }
689
-
690
- context.method = method;
691
- context.arg = arg;
692
-
693
- while (true) {
694
- var delegate = context.delegate;
695
-
696
- if (delegate) {
697
- var delegateResult = maybeInvokeDelegate(delegate, context);
698
-
699
- if (delegateResult) {
700
- if (delegateResult === ContinueSentinel) continue;
701
- return delegateResult;
702
- }
703
- }
704
-
705
- if (context.method === "next") {
706
- // Setting context._sent for legacy support of Babel's
707
- // function.sent implementation.
708
- context.sent = context._sent = context.arg;
709
- } else if (context.method === "throw") {
710
- if (state === GenStateSuspendedStart) {
711
- state = GenStateCompleted;
712
- throw context.arg;
713
- }
714
-
715
- context.dispatchException(context.arg);
716
- } else if (context.method === "return") {
717
- context.abrupt("return", context.arg);
718
- }
719
-
720
- state = GenStateExecuting;
721
- var record = tryCatch(innerFn, self, context);
722
-
723
- if (record.type === "normal") {
724
- // If an exception is thrown from innerFn, we leave state ===
725
- // GenStateExecuting and loop back for another invocation.
726
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
727
-
728
- if (record.arg === ContinueSentinel) {
729
- continue;
730
- }
731
-
732
- return {
733
- value: record.arg,
734
- done: context.done
735
- };
736
- } else if (record.type === "throw") {
737
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
738
- // context.dispatchException(context.arg) call above.
739
-
740
- context.method = "throw";
741
- context.arg = record.arg;
742
- }
743
- }
744
- };
745
- } // Call delegate.iterator[context.method](context.arg) and handle the
746
- // result, either by returning a { value, done } result from the
747
- // delegate iterator, or by modifying context.method and context.arg,
748
- // setting context.delegate to null, and returning the ContinueSentinel.
749
-
750
-
751
- function maybeInvokeDelegate(delegate, context) {
752
- var method = delegate.iterator[context.method];
753
-
754
- if (method === undefined$1) {
755
- // A .throw or .return when the delegate iterator has no .throw
756
- // method always terminates the yield* loop.
757
- context.delegate = null;
758
-
759
- if (context.method === "throw") {
760
- // Note: ["return"] must be used for ES3 parsing compatibility.
761
- if (delegate.iterator["return"]) {
762
- // If the delegate iterator has a return method, give it a
763
- // chance to clean up.
764
- context.method = "return";
765
- context.arg = undefined$1;
766
- maybeInvokeDelegate(delegate, context);
767
-
768
- if (context.method === "throw") {
769
- // If maybeInvokeDelegate(context) changed context.method from
770
- // "return" to "throw", let that override the TypeError below.
771
- return ContinueSentinel;
772
- }
773
- }
774
-
775
- context.method = "throw";
776
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
777
- }
778
-
779
- return ContinueSentinel;
780
- }
781
-
782
- var record = tryCatch(method, delegate.iterator, context.arg);
783
-
784
- if (record.type === "throw") {
785
- context.method = "throw";
786
- context.arg = record.arg;
787
- context.delegate = null;
788
- return ContinueSentinel;
789
- }
790
-
791
- var info = record.arg;
792
-
793
- if (!info) {
794
- context.method = "throw";
795
- context.arg = new TypeError("iterator result is not an object");
796
- context.delegate = null;
797
- return ContinueSentinel;
798
- }
799
-
800
- if (info.done) {
801
- // Assign the result of the finished delegate to the temporary
802
- // variable specified by delegate.resultName (see delegateYield).
803
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
804
-
805
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
806
- // exception, let the outer generator proceed normally. If
807
- // context.method was "next", forget context.arg since it has been
808
- // "consumed" by the delegate iterator. If context.method was
809
- // "return", allow the original .return call to continue in the
810
- // outer generator.
811
-
812
- if (context.method !== "return") {
813
- context.method = "next";
814
- context.arg = undefined$1;
815
- }
816
- } else {
817
- // Re-yield the result returned by the delegate method.
818
- return info;
819
- } // The delegate iterator is finished, so forget it and continue with
820
- // the outer generator.
821
-
822
-
823
- context.delegate = null;
824
- return ContinueSentinel;
825
- } // Define Generator.prototype.{next,throw,return} in terms of the
826
- // unified ._invoke helper method.
827
-
828
-
829
- defineIteratorMethods(Gp);
830
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
831
- // @@iterator function is called on it. Some browsers' implementations of the
832
- // iterator prototype chain incorrectly implement this, causing the Generator
833
- // object to not be returned from this call. This ensures that doesn't happen.
834
- // See https://github.com/facebook/regenerator/issues/274 for more details.
835
-
836
- define(Gp, iteratorSymbol, function () {
837
- return this;
838
- });
839
- define(Gp, "toString", function () {
840
- return "[object Generator]";
841
- });
842
-
843
- function pushTryEntry(locs) {
844
- var entry = {
845
- tryLoc: locs[0]
846
- };
847
-
848
- if (1 in locs) {
849
- entry.catchLoc = locs[1];
850
- }
851
-
852
- if (2 in locs) {
853
- entry.finallyLoc = locs[2];
854
- entry.afterLoc = locs[3];
855
- }
856
-
857
- this.tryEntries.push(entry);
858
- }
859
-
860
- function resetTryEntry(entry) {
861
- var record = entry.completion || {};
862
- record.type = "normal";
863
- delete record.arg;
864
- entry.completion = record;
865
- }
866
-
867
- function Context(tryLocsList) {
868
- // The root entry object (effectively a try statement without a catch
869
- // or a finally block) gives us a place to store values thrown from
870
- // locations where there is no enclosing try statement.
871
- this.tryEntries = [{
872
- tryLoc: "root"
873
- }];
874
- tryLocsList.forEach(pushTryEntry, this);
875
- this.reset(true);
876
- }
877
-
878
- exports.keys = function (object) {
879
- var keys = [];
880
-
881
- for (var key in object) {
882
- keys.push(key);
883
- }
884
-
885
- keys.reverse(); // Rather than returning an object with a next method, we keep
886
- // things simple and return the next function itself.
887
-
888
- return function next() {
889
- while (keys.length) {
890
- var key = keys.pop();
891
-
892
- if (key in object) {
893
- next.value = key;
894
- next.done = false;
895
- return next;
896
- }
897
- } // To avoid creating an additional object, we just hang the .value
898
- // and .done properties off the next function object itself. This
899
- // also ensures that the minifier will not anonymize the function.
900
-
901
-
902
- next.done = true;
903
- return next;
904
- };
905
- };
906
-
907
- function values(iterable) {
908
- if (iterable) {
909
- var iteratorMethod = iterable[iteratorSymbol];
910
-
911
- if (iteratorMethod) {
912
- return iteratorMethod.call(iterable);
913
- }
914
-
915
- if (typeof iterable.next === "function") {
916
- return iterable;
917
- }
918
-
919
- if (!isNaN(iterable.length)) {
920
- var i = -1,
921
- next = function next() {
922
- while (++i < iterable.length) {
923
- if (hasOwn.call(iterable, i)) {
924
- next.value = iterable[i];
925
- next.done = false;
926
- return next;
927
- }
928
- }
929
-
930
- next.value = undefined$1;
931
- next.done = true;
932
- return next;
933
- };
934
-
935
- return next.next = next;
936
- }
937
- } // Return an iterator with no values.
938
-
939
-
940
- return {
941
- next: doneResult
942
- };
943
- }
944
-
945
- exports.values = values;
946
-
947
- function doneResult() {
948
- return {
949
- value: undefined$1,
950
- done: true
951
- };
952
- }
953
-
954
- Context.prototype = {
955
- constructor: Context,
956
- reset: function reset(skipTempReset) {
957
- this.prev = 0;
958
- this.next = 0; // Resetting context._sent for legacy support of Babel's
959
- // function.sent implementation.
960
-
961
- this.sent = this._sent = undefined$1;
962
- this.done = false;
963
- this.delegate = null;
964
- this.method = "next";
965
- this.arg = undefined$1;
966
- this.tryEntries.forEach(resetTryEntry);
967
-
968
- if (!skipTempReset) {
969
- for (var name in this) {
970
- // Not sure about the optimal order of these conditions:
971
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
972
- this[name] = undefined$1;
973
- }
974
- }
975
- }
976
- },
977
- stop: function stop() {
978
- this.done = true;
979
- var rootEntry = this.tryEntries[0];
980
- var rootRecord = rootEntry.completion;
981
-
982
- if (rootRecord.type === "throw") {
983
- throw rootRecord.arg;
984
- }
985
-
986
- return this.rval;
987
- },
988
- dispatchException: function dispatchException(exception) {
989
- if (this.done) {
990
- throw exception;
991
- }
992
-
993
- var context = this;
994
-
995
- function handle(loc, caught) {
996
- record.type = "throw";
997
- record.arg = exception;
998
- context.next = loc;
999
-
1000
- if (caught) {
1001
- // If the dispatched exception was caught by a catch block,
1002
- // then let that catch block handle the exception normally.
1003
- context.method = "next";
1004
- context.arg = undefined$1;
1005
- }
1006
-
1007
- return !!caught;
1008
- }
1009
-
1010
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1011
- var entry = this.tryEntries[i];
1012
- var record = entry.completion;
1013
-
1014
- if (entry.tryLoc === "root") {
1015
- // Exception thrown outside of any try block that could handle
1016
- // it, so set the completion value of the entire function to
1017
- // throw the exception.
1018
- return handle("end");
1019
- }
1020
-
1021
- if (entry.tryLoc <= this.prev) {
1022
- var hasCatch = hasOwn.call(entry, "catchLoc");
1023
- var hasFinally = hasOwn.call(entry, "finallyLoc");
1024
-
1025
- if (hasCatch && hasFinally) {
1026
- if (this.prev < entry.catchLoc) {
1027
- return handle(entry.catchLoc, true);
1028
- } else if (this.prev < entry.finallyLoc) {
1029
- return handle(entry.finallyLoc);
1030
- }
1031
- } else if (hasCatch) {
1032
- if (this.prev < entry.catchLoc) {
1033
- return handle(entry.catchLoc, true);
1034
- }
1035
- } else if (hasFinally) {
1036
- if (this.prev < entry.finallyLoc) {
1037
- return handle(entry.finallyLoc);
1038
- }
1039
- } else {
1040
- throw new Error("try statement without catch or finally");
1041
- }
1042
- }
1043
- }
1044
- },
1045
- abrupt: function abrupt(type, arg) {
1046
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1047
- var entry = this.tryEntries[i];
1048
-
1049
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1050
- var finallyEntry = entry;
1051
- break;
1052
- }
1053
- }
1054
-
1055
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1056
- // Ignore the finally entry if control is not jumping to a
1057
- // location outside the try/catch block.
1058
- finallyEntry = null;
1059
- }
1060
-
1061
- var record = finallyEntry ? finallyEntry.completion : {};
1062
- record.type = type;
1063
- record.arg = arg;
1064
-
1065
- if (finallyEntry) {
1066
- this.method = "next";
1067
- this.next = finallyEntry.finallyLoc;
1068
- return ContinueSentinel;
1069
- }
1070
-
1071
- return this.complete(record);
1072
- },
1073
- complete: function complete(record, afterLoc) {
1074
- if (record.type === "throw") {
1075
- throw record.arg;
1076
- }
1077
-
1078
- if (record.type === "break" || record.type === "continue") {
1079
- this.next = record.arg;
1080
- } else if (record.type === "return") {
1081
- this.rval = this.arg = record.arg;
1082
- this.method = "return";
1083
- this.next = "end";
1084
- } else if (record.type === "normal" && afterLoc) {
1085
- this.next = afterLoc;
1086
- }
1087
-
1088
- return ContinueSentinel;
1089
- },
1090
- finish: function finish(finallyLoc) {
1091
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1092
- var entry = this.tryEntries[i];
1093
-
1094
- if (entry.finallyLoc === finallyLoc) {
1095
- this.complete(entry.completion, entry.afterLoc);
1096
- resetTryEntry(entry);
1097
- return ContinueSentinel;
1098
- }
1099
- }
1100
- },
1101
- "catch": function _catch(tryLoc) {
1102
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1103
- var entry = this.tryEntries[i];
1104
-
1105
- if (entry.tryLoc === tryLoc) {
1106
- var record = entry.completion;
1107
-
1108
- if (record.type === "throw") {
1109
- var thrown = record.arg;
1110
- resetTryEntry(entry);
1111
- }
1112
-
1113
- return thrown;
1114
- }
1115
- } // The context.catch method must only be called with a location
1116
- // argument that corresponds to a known catch block.
1117
-
1118
-
1119
- throw new Error("illegal catch attempt");
1120
- },
1121
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1122
- this.delegate = {
1123
- iterator: values(iterable),
1124
- resultName: resultName,
1125
- nextLoc: nextLoc
1126
- };
1127
-
1128
- if (this.method === "next") {
1129
- // Deliberately forget the last sent value so that we don't
1130
- // accidentally pass it on to the delegate.
1131
- this.arg = undefined$1;
1132
- }
1133
-
1134
- return ContinueSentinel;
1135
- }
1136
- }; // Regardless of whether this script is executing as a CommonJS module
1137
- // or not, return the runtime object so that we can declare the variable
1138
- // regeneratorRuntime in the outer scope, which allows this module to be
1139
- // injected easily by `bin/regenerator --include-runtime script.js`.
1140
-
1141
- return exports;
1142
- }( // If this script is executing as a CommonJS module, use module.exports
1143
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1144
- // object. Either way, the resulting object will be used to initialize
1145
- // the regeneratorRuntime variable at the top of this file.
1146
- module.exports );
1147
-
1148
- try {
1149
- regeneratorRuntime = runtime;
1150
- } catch (accidentalStrictMode) {
1151
- // This module should not be running in strict mode, so the above
1152
- // assignment should always work unless something is misconfigured. Just
1153
- // in case runtime.js accidentally runs in strict mode, in modern engines
1154
- // we can explicitly access globalThis. In older engines we can escape
1155
- // strict mode using a global Function call. This could conceivably fail
1156
- // if a Content Security Policy forbids using Function, but in that case
1157
- // the proper solution is to fix the accidental strict mode problem. If
1158
- // you've misconfigured your bundler to force strict mode and applied a
1159
- // CSP to forbid Function, and you're not willing to fix either of those
1160
- // problems, please detail your unique predicament in a GitHub issue.
1161
- if (typeof globalThis === "object") {
1162
- globalThis.regeneratorRuntime = runtime;
1163
- } else {
1164
- Function("r", "regeneratorRuntime = r")(runtime);
1165
- }
1166
- }
1167
- });
1168
-
1169
- /**
1170
- * Adapter that just returns the features defined in its `features` configuration
1171
- * key, like:
1172
- * `"features": [ { "refName": "ctgA", "start":1, "end":20 }, ... ]`
1173
- */
1174
-
1175
- var FromConfigAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1176
- _inherits(FromConfigAdapter, _BaseFeatureDataAdapt);
1177
-
1178
- var _super = /*#__PURE__*/_createSuper(FromConfigAdapter);
1179
-
1180
- function FromConfigAdapter(conf, getSubAdapter, pluginManager) {
1181
- var _this;
1182
-
1183
- _classCallCheck(this, FromConfigAdapter);
1184
-
1185
- _this = _super.call(this, conf, getSubAdapter, pluginManager);
1186
- var feats = readConfObject(conf, 'features');
1187
- _this.features = FromConfigAdapter.makeFeatures(feats || []);
1188
- return _this;
1189
- }
1190
-
1191
- _createClass(FromConfigAdapter, [{
1192
- key: "getRefNames",
1193
- value: function () {
1194
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1195
- return runtime_1.wrap(function _callee$(_context) {
1196
- while (1) {
1197
- switch (_context.prev = _context.next) {
1198
- case 0:
1199
- return _context.abrupt("return", _toConsumableArray(this.features.keys()));
1200
-
1201
- case 1:
1202
- case "end":
1203
- return _context.stop();
1204
- }
1205
- }
1206
- }, _callee, this);
1207
- }));
1208
-
1209
- function getRefNames() {
1210
- return _getRefNames.apply(this, arguments);
1211
- }
1212
-
1213
- return getRefNames;
1214
- }()
1215
- }, {
1216
- key: "getRefNameAliases",
1217
- value: function () {
1218
- var _getRefNameAliases = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1219
- return runtime_1.wrap(function _callee2$(_context2) {
1220
- while (1) {
1221
- switch (_context2.prev = _context2.next) {
1222
- case 0:
1223
- return _context2.abrupt("return", Array.from(this.features.values()).map(function (featureArray) {
1224
- return {
1225
- refName: featureArray[0].get('refName'),
1226
- aliases: featureArray[0].get('aliases')
1227
- };
1228
- }));
1229
-
1230
- case 1:
1231
- case "end":
1232
- return _context2.stop();
1233
- }
1234
- }
1235
- }, _callee2, this);
1236
- }));
1237
-
1238
- function getRefNameAliases() {
1239
- return _getRefNameAliases.apply(this, arguments);
1240
- }
1241
-
1242
- return getRefNameAliases;
1243
- }()
1244
- }, {
1245
- key: "getFeatures",
1246
- value: function getFeatures(region) {
1247
- var _this2 = this;
1248
-
1249
- var refName = region.refName,
1250
- start = region.start,
1251
- end = region.end;
1252
- return ObservableCreate( /*#__PURE__*/function () {
1253
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(observer) {
1254
- var features, i, f;
1255
- return runtime_1.wrap(function _callee3$(_context3) {
1256
- while (1) {
1257
- switch (_context3.prev = _context3.next) {
1258
- case 0:
1259
- features = _this2.features.get(refName) || [];
1260
-
1261
- for (i = 0; i < features.length; i++) {
1262
- f = features[i];
1263
-
1264
- if (f.get('end') > start && f.get('start') < end) {
1265
- observer.next(f);
1266
- }
1267
- }
1268
-
1269
- observer.complete();
1270
-
1271
- case 3:
1272
- case "end":
1273
- return _context3.stop();
1274
- }
1275
- }
1276
- }, _callee3);
1277
- }));
1278
-
1279
- return function (_x) {
1280
- return _ref.apply(this, arguments);
1281
- };
1282
- }());
1283
- }
1284
- }, {
1285
- key: "freeResources",
1286
- value: function
1287
- /* { region } */
1288
- freeResources() {}
1289
- }], [{
1290
- key: "makeFeatures",
1291
- value: function makeFeatures(fdata) {
1292
- var features = new Map();
1293
-
1294
- for (var i = 0; i < fdata.length; i += 1) {
1295
- if (fdata[i]) {
1296
- var f = this.makeFeature(fdata[i]);
1297
- var refName = f.get('refName');
1298
- var bucket = features.get(refName);
1299
-
1300
- if (!bucket) {
1301
- bucket = [];
1302
- features.set(refName, bucket);
1303
- }
1304
-
1305
- bucket.push(f);
1306
- }
1307
- } // sort the features on each reference sequence by start coordinate
1308
-
1309
-
1310
- var _iterator = _createForOfIteratorHelper(features.values()),
1311
- _step;
1312
-
1313
- try {
1314
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1315
- var refFeatures = _step.value;
1316
- refFeatures.sort(function (a, b) {
1317
- return a.get('start') - b.get('start');
1318
- });
1319
- }
1320
- } catch (err) {
1321
- _iterator.e(err);
1322
- } finally {
1323
- _iterator.f();
1324
- }
1325
-
1326
- return features;
1327
- }
1328
- }, {
1329
- key: "makeFeature",
1330
- value: function makeFeature(data) {
1331
- return new SimpleFeature(data);
1332
- }
1333
- }]);
1334
-
1335
- return FromConfigAdapter;
1336
- }(BaseFeatureDataAdapter);
1337
-
1338
- /**
1339
- * Adapter that just returns the features defined in its `features` configuration
1340
- * key, like:
1341
- * `"features": [ { "refName": "ctgA", "start":1, "end":20 }, ... ]`
1342
- */
1343
-
1344
- var FromConfigRegionsAdapter = /*#__PURE__*/function (_BaseAdapter) {
1345
- _inherits(FromConfigRegionsAdapter, _BaseAdapter);
1346
-
1347
- var _super = /*#__PURE__*/_createSuper(FromConfigRegionsAdapter);
1348
-
1349
- function FromConfigRegionsAdapter(config, getSubAdapter, pluginManager) {
1350
- var _this;
1351
-
1352
- _classCallCheck(this, FromConfigRegionsAdapter);
1353
-
1354
- _this = _super.call(this, config, getSubAdapter, pluginManager);
1355
- var features = readConfObject(config, 'features');
1356
- _this.features = FromConfigAdapter.makeFeatures(features || []);
1357
- return _this;
1358
- }
1359
- /**
1360
- * Get refName, start, and end for all features after collapsing any overlaps
1361
- */
1362
-
1363
-
1364
- _createClass(FromConfigRegionsAdapter, [{
1365
- key: "getRegions",
1366
- value: function () {
1367
- var _getRegions = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1368
- var regions, _iterator, _step, _step$value, refName, features, currentRegion, _iterator2, _step2, feature;
1369
-
1370
- return runtime_1.wrap(function _callee$(_context) {
1371
- while (1) {
1372
- switch (_context.prev = _context.next) {
1373
- case 0:
1374
- regions = []; // recall: features are stored in this object sorted by start coordinate
1375
-
1376
- _iterator = _createForOfIteratorHelper(this.features);
1377
-
1378
- try {
1379
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1380
- _step$value = _slicedToArray(_step.value, 2), refName = _step$value[0], features = _step$value[1];
1381
- currentRegion = void 0;
1382
- _iterator2 = _createForOfIteratorHelper(features);
1383
-
1384
- try {
1385
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1386
- feature = _step2.value;
1387
-
1388
- if (currentRegion && currentRegion.end >= feature.get('start') && currentRegion.start <= feature.get('end')) {
1389
- currentRegion.end = feature.get('end');
1390
- } else {
1391
- if (currentRegion) {
1392
- regions.push(currentRegion);
1393
- }
1394
-
1395
- currentRegion = {
1396
- refName: refName,
1397
- start: feature.get('start'),
1398
- end: feature.get('end')
1399
- };
1400
- }
1401
- }
1402
- } catch (err) {
1403
- _iterator2.e(err);
1404
- } finally {
1405
- _iterator2.f();
1406
- }
1407
-
1408
- if (currentRegion) {
1409
- regions.push(currentRegion);
1410
- }
1411
- } // sort the regions by refName
1412
-
1413
- } catch (err) {
1414
- _iterator.e(err);
1415
- } finally {
1416
- _iterator.f();
1417
- }
1418
-
1419
- regions.sort(function (a, b) {
1420
- return a.refName.localeCompare(b.refName);
1421
- });
1422
- return _context.abrupt("return", regions);
1423
-
1424
- case 5:
1425
- case "end":
1426
- return _context.stop();
1427
- }
1428
- }
1429
- }, _callee, this);
1430
- }));
1431
-
1432
- function getRegions() {
1433
- return _getRegions.apply(this, arguments);
1434
- }
1435
-
1436
- return getRegions;
1437
- }()
1438
- }, {
1439
- key: "freeResources",
1440
- value: function
1441
- /* { region } */
1442
- freeResources() {}
1443
- }]);
1444
-
1445
- return FromConfigRegionsAdapter;
1446
- }(BaseAdapter);
1447
-
1448
- var FromConfigSequenceAdapter = /*#__PURE__*/function (_FromConfigAdapter) {
1449
- _inherits(FromConfigSequenceAdapter, _FromConfigAdapter);
1450
-
1451
- var _super = /*#__PURE__*/_createSuper(FromConfigSequenceAdapter);
1452
-
1453
- function FromConfigSequenceAdapter() {
1454
- _classCallCheck(this, FromConfigSequenceAdapter);
1455
-
1456
- return _super.apply(this, arguments);
1457
- }
1458
-
1459
- _createClass(FromConfigSequenceAdapter, [{
1460
- key: "getFeatures",
1461
- value:
1462
- /**
1463
- * Fetch features for a certain region
1464
- * @param region - Region
1465
- * @returns Observable of Feature objects in the region
1466
- */
1467
- function getFeatures(region) {
1468
- var _this = this;
1469
-
1470
- // TODO: restore commented version below once TSDX supports Rollup v2
1471
- // xref: https://github.com/rollup/rollup/blob/master/CHANGELOG.md#bug-fixes-45
1472
- // return ObservableCreate<Feature>(async observer => {
1473
- // const feats = await super.getFeatures(region).pipe(toArray()).toPromise()
1474
- var superGetFeatures = _get(_getPrototypeOf(FromConfigSequenceAdapter.prototype), "getFeatures", this);
1475
-
1476
- return ObservableCreate( /*#__PURE__*/function () {
1477
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(observer) {
1478
- var feats, feat;
1479
- return runtime_1.wrap(function _callee$(_context) {
1480
- while (1) {
1481
- switch (_context.prev = _context.next) {
1482
- case 0:
1483
- _context.next = 2;
1484
- return superGetFeatures.call(_this, region).pipe(toArray()).toPromise();
1485
-
1486
- case 2:
1487
- feats = _context.sent;
1488
- feat = feats[0];
1489
- observer.next(new SimpleFeature(_objectSpread2(_objectSpread2({}, feat.toJSON()), {}, {
1490
- uniqueId: "".concat(feat.id(), ":").concat(region.start, "-").concat(region.end),
1491
- end: region.end,
1492
- start: region.start,
1493
- seq: feat.get('seq').slice(Math.max(region.start - feat.get('start'), 0), Math.max(region.end - feat.get('start'), 0))
1494
- })));
1495
- observer.complete();
1496
-
1497
- case 6:
1498
- case "end":
1499
- return _context.stop();
1500
- }
1501
- }
1502
- }, _callee);
1503
- }));
1504
-
1505
- return function (_x) {
1506
- return _ref.apply(this, arguments);
1507
- };
1508
- }());
1509
- }
1510
- /**
1511
- * Get refName, start, and end for all features after collapsing any overlaps
1512
- */
1513
-
1514
- }, {
1515
- key: "getRegions",
1516
- value: function () {
1517
- var _getRegions = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1518
- var regions, _iterator, _step, _step$value, refName, features, currentRegion, _iterator2, _step2, feature;
1519
-
1520
- return runtime_1.wrap(function _callee2$(_context2) {
1521
- while (1) {
1522
- switch (_context2.prev = _context2.next) {
1523
- case 0:
1524
- regions = []; // recall: features are stored in this object sorted by start coordinate
1525
-
1526
- _iterator = _createForOfIteratorHelper(this.features);
1527
-
1528
- try {
1529
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1530
- _step$value = _slicedToArray(_step.value, 2), refName = _step$value[0], features = _step$value[1];
1531
- currentRegion = void 0;
1532
- _iterator2 = _createForOfIteratorHelper(features);
1533
-
1534
- try {
1535
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1536
- feature = _step2.value;
1537
-
1538
- if (currentRegion && currentRegion.end >= feature.get('start') && currentRegion.start <= feature.get('end')) {
1539
- currentRegion.end = feature.get('end');
1540
- } else {
1541
- if (currentRegion) {
1542
- regions.push(currentRegion);
1543
- }
1544
-
1545
- currentRegion = {
1546
- refName: refName,
1547
- start: feature.get('start'),
1548
- end: feature.get('end')
1549
- };
1550
- }
1551
- }
1552
- } catch (err) {
1553
- _iterator2.e(err);
1554
- } finally {
1555
- _iterator2.f();
1556
- }
1557
-
1558
- if (currentRegion) {
1559
- regions.push(currentRegion);
1560
- }
1561
- }
1562
- } catch (err) {
1563
- _iterator.e(err);
1564
- } finally {
1565
- _iterator.f();
1566
- }
1567
-
1568
- return _context2.abrupt("return", regions);
1569
-
1570
- case 4:
1571
- case "end":
1572
- return _context2.stop();
1573
- }
1574
- }
1575
- }, _callee2, this);
1576
- }));
1577
-
1578
- function getRegions() {
1579
- return _getRegions.apply(this, arguments);
1580
- }
1581
-
1582
- return getRegions;
1583
- }()
1584
- /**
1585
- * called to provide a hint that data tied to a certain region
1586
- * will not be needed for the forseeable future and can be purged
1587
- * from caches, etc
1588
- */
1589
-
1590
- }, {
1591
- key: "freeResources",
1592
- value: function
1593
- /* { region } */
1594
- freeResources() {}
1595
- }]);
1596
-
1597
- return FromConfigSequenceAdapter;
1598
- }(FromConfigAdapter);
1599
-
1600
- var configSchema$1 = /*#__PURE__*/ConfigurationSchema('FromConfigAdapter', {
1601
- features: {
1602
- type: 'frozen',
1603
- defaultValue: []
1604
- },
1605
- featureClass: {
1606
- type: 'string',
1607
- defaultValue: 'SimpleFeature'
1608
- }
1609
- }, {
1610
- explicitlyTyped: true,
1611
- implicitIdentifier: 'adapterId'
1612
- });
1613
- var regionsConfigSchema = /*#__PURE__*/ConfigurationSchema('FromConfigRegionsAdapter', {
1614
- features: {
1615
- type: 'frozen',
1616
- defaultValue: []
1617
- },
1618
- featureClass: {
1619
- type: 'string',
1620
- defaultValue: 'SimpleFeature'
1621
- }
1622
- }, {
1623
- explicitlyTyped: true,
1624
- implicitIdentifier: 'adapterId'
1625
- });
1626
- var sequenceConfigSchema = /*#__PURE__*/ConfigurationSchema('FromConfigSequenceAdapter', {
1627
- features: {
1628
- type: 'frozen',
1629
- defaultValue: []
1630
- },
1631
- featureClass: {
1632
- type: 'string',
1633
- defaultValue: 'SimpleFeature'
1634
- }
1635
- }, {
1636
- explicitlyTyped: true,
1637
- implicitIdentifier: 'adapterId'
1638
- });
1639
-
1640
- var RefNameAliasAdapter = /*#__PURE__*/function (_BaseAdapter) {
1641
- _inherits(RefNameAliasAdapter, _BaseAdapter);
1642
-
1643
- var _super = /*#__PURE__*/_createSuper(RefNameAliasAdapter);
1644
-
1645
- function RefNameAliasAdapter() {
1646
- _classCallCheck(this, RefNameAliasAdapter);
1647
-
1648
- return _super.apply(this, arguments);
1649
- }
1650
-
1651
- _createClass(RefNameAliasAdapter, [{
1652
- key: "getRefNameAliases",
1653
- value: function () {
1654
- var _getRefNameAliases = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1655
- var loc, results, refColumn;
1656
- return runtime_1.wrap(function _callee$(_context) {
1657
- while (1) {
1658
- switch (_context.prev = _context.next) {
1659
- case 0:
1660
- loc = readConfObject(this.config, 'location');
1661
-
1662
- if (!(loc.uri === '' || loc.uri === '/path/to/my/aliases.txt')) {
1663
- _context.next = 3;
1664
- break;
1665
- }
1666
-
1667
- return _context.abrupt("return", []);
1668
-
1669
- case 3:
1670
- _context.next = 5;
1671
- return openLocation(loc).readFile('utf8');
1672
-
1673
- case 5:
1674
- results = _context.sent;
1675
- refColumn = readConfObject(this.config, 'refNameColumn');
1676
- return _context.abrupt("return", results.trim().split('\n').filter(function (f) {
1677
- return !!f && !f.startsWith('#');
1678
- }).map(function (row) {
1679
- var aliases = row.split('\t');
1680
-
1681
- var _aliases$splice = aliases.splice(refColumn, 1),
1682
- _aliases$splice2 = _slicedToArray(_aliases$splice, 1),
1683
- refName = _aliases$splice2[0];
1684
-
1685
- return {
1686
- refName: refName,
1687
- aliases: aliases
1688
- };
1689
- }));
1690
-
1691
- case 8:
1692
- case "end":
1693
- return _context.stop();
1694
- }
1695
- }
1696
- }, _callee, this);
1697
- }));
1698
-
1699
- function getRefNameAliases() {
1700
- return _getRefNameAliases.apply(this, arguments);
1701
- }
1702
-
1703
- return getRefNameAliases;
1704
- }()
1705
- }, {
1706
- key: "freeResources",
1707
- value: function () {
1708
- var _freeResources = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1709
- return runtime_1.wrap(function _callee2$(_context2) {
1710
- while (1) {
1711
- switch (_context2.prev = _context2.next) {
1712
- case 0:
1713
- case "end":
1714
- return _context2.stop();
1715
- }
1716
- }
1717
- }, _callee2);
1718
- }));
1719
-
1720
- function freeResources() {
1721
- return _freeResources.apply(this, arguments);
1722
- }
1723
-
1724
- return freeResources;
1725
- }()
1726
- }]);
1727
-
1728
- return RefNameAliasAdapter;
1729
- }(BaseAdapter);
1730
-
1731
- var refNameAliasAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('RefNameAliasAdapter', {
1732
- location: {
1733
- type: 'fileLocation',
1734
- defaultValue: {
1735
- uri: '/path/to/my/aliases.txt',
1736
- locationType: 'UriLocation'
1737
- }
1738
- },
1739
- refNameColumn: {
1740
- type: 'number',
1741
- defaultValue: 0
1742
- }
1743
- }, {
1744
- explicitlyTyped: true
1745
- });
1746
-
1747
- var useStyles = /*#__PURE__*/makeStyles({
1748
- error: {
1749
- color: 'red',
1750
- fontSize: '0.8em'
1751
- }
1752
- });
1753
- var CodeEditor = /*#__PURE__*/lazy(function () {
1754
- return Promise.resolve().then(function () { return CodeEditor$2; });
1755
- });
1756
-
1757
- function JsonEditor(_ref) {
1758
- var slot = _ref.slot;
1759
- var classes = useStyles();
1760
-
1761
- var _useState = useState(JSON.stringify(slot.value, null, ' ')),
1762
- _useState2 = _slicedToArray(_useState, 2),
1763
- contents = _useState2[0],
1764
- setContents = _useState2[1];
1765
-
1766
- var _useState3 = useState(),
1767
- _useState4 = _slicedToArray(_useState3, 2),
1768
- error = _useState4[0],
1769
- setError = _useState4[1];
1770
-
1771
- var debouncedJson = useDebounce(contents, 400);
1772
- useEffect(function () {
1773
- try {
1774
- slot.set(JSON.parse(debouncedJson));
1775
- setError(undefined);
1776
- } catch (e) {
1777
- setError(e.message);
1778
- } // eslint-disable-next-line react-hooks/exhaustive-deps
1779
-
1780
- }, [debouncedJson]);
1781
- return /*#__PURE__*/React.createElement(React.Fragment, null, error ? /*#__PURE__*/React.createElement("p", {
1782
- className: classes.error
1783
- }, error) : null, /*#__PURE__*/React.createElement(FormControl, {
1784
- error: error
1785
- }, /*#__PURE__*/React.createElement(InputLabel, {
1786
- shrink: true,
1787
- htmlFor: "callback-editor"
1788
- }, slot.name), /*#__PURE__*/React.createElement(React.Suspense, {
1789
- fallback: /*#__PURE__*/React.createElement("div", null)
1790
- }, /*#__PURE__*/React.createElement(CodeEditor, {
1791
- contents: contents,
1792
- setContents: setContents
1793
- })), /*#__PURE__*/React.createElement(FormHelperText, null, slot.description)));
1794
- }
1795
-
1796
- JsonEditor.propTypes = {
1797
- slot: PropTypes.objectOrObservableObject.isRequired
1798
- };
1799
- var JsonEditor$1 = /*#__PURE__*/observer(JsonEditor);
1800
-
1801
- var ConfigurationEditorComponent = /*#__PURE__*/lazy(function () {
1802
- return Promise.resolve().then(function () { return ConfigurationEditor$1; });
1803
- });
1804
-
1805
- var _default = /*#__PURE__*/function (_Plugin) {
1806
- _inherits(_default, _Plugin);
1807
-
1808
- var _super = /*#__PURE__*/_createSuper(_default);
1809
-
1810
- function _default() {
1811
- var _this;
1812
-
1813
- _classCallCheck(this, _default);
1814
-
1815
- _this = _super.apply(this, arguments);
1816
- _this.name = 'ConfigurationPlugin';
1817
- return _this;
1818
- }
1819
-
1820
- _createClass(_default, [{
1821
- key: "install",
1822
- value: function install(pluginManager) {
1823
- pluginManager.addAdapterType(function () {
1824
- return new AdapterType({
1825
- name: 'FromConfigAdapter',
1826
- configSchema: configSchema$1,
1827
- AdapterClass: FromConfigAdapter,
1828
- adapterMetadata: {
1829
- category: null,
1830
- hiddenFromGUI: true,
1831
- displayName: null,
1832
- description: null
1833
- }
1834
- });
1835
- });
1836
- pluginManager.addAdapterType(function () {
1837
- return new AdapterType({
1838
- name: 'FromConfigRegionsAdapter',
1839
- configSchema: regionsConfigSchema,
1840
- AdapterClass: FromConfigRegionsAdapter,
1841
- adapterMetadata: {
1842
- category: null,
1843
- hiddenFromGUI: true,
1844
- displayName: null,
1845
- description: null
1846
- }
1847
- });
1848
- });
1849
- pluginManager.addAdapterType(function () {
1850
- return new AdapterType({
1851
- name: 'FromConfigSequenceAdapter',
1852
- configSchema: sequenceConfigSchema,
1853
- AdapterClass: FromConfigSequenceAdapter,
1854
- adapterMetadata: {
1855
- category: null,
1856
- hiddenFromGUI: true,
1857
- displayName: null,
1858
- description: null
1859
- }
1860
- });
1861
- });
1862
- pluginManager.addAdapterType(function () {
1863
- return new AdapterType({
1864
- name: 'RefNameAliasAdapter',
1865
- configSchema: refNameAliasAdapterConfigSchema,
1866
- AdapterClass: RefNameAliasAdapter,
1867
- adapterMetadata: {
1868
- category: null,
1869
- hiddenFromGUI: true,
1870
- displayName: null,
1871
- description: null
1872
- }
1873
- });
1874
- });
1875
- pluginManager.addWidgetType(function () {
1876
- return new WidgetType({
1877
- name: 'ConfigurationEditorWidget',
1878
- HeadingComponent: HeadingComponent,
1879
- configSchema: configSchema,
1880
- stateModel: ConfigurationEditorStateModelFactory(pluginManager),
1881
- ReactComponent: ConfigurationEditorComponent
1882
- });
1883
- });
1884
- }
1885
- }]);
1886
-
1887
- return _default;
1888
- }(Plugin);
1889
-
1890
- var fontSize = '12px'; // Optimize by using system default fonts: https://css-tricks.com/snippets/css/font-stacks/
1891
-
1892
- var fontFamily = 'Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace';
1893
- var useStyles$1 = /*#__PURE__*/makeStyles({
1894
- callbackEditor: {
1895
- fontFamily: fontFamily,
1896
- fontSize: fontSize,
1897
- overflowX: 'auto',
1898
- marginTop: '16px',
1899
- borderBottom: '1px solid rgba(0,0,0,0.42)'
1900
- },
1901
- syntaxHighlighter: {
1902
- margin: 0,
1903
- fontFamily: fontFamily,
1904
- fontSize: fontSize
1905
- }
1906
- }); // eslint-disable-next-line react/prop-types
1907
-
1908
- function CodeEditor$1(_ref) {
1909
- var contents = _ref.contents,
1910
- setContents = _ref.setContents;
1911
- var classes = useStyles$1();
1912
- var theme = useTheme();
1913
- useEffect(function () {
1914
- Light.registerLanguage('json', json);
1915
- }, []);
1916
- return /*#__PURE__*/React.createElement(Editor, {
1917
- className: classes.callbackEditor,
1918
- value: contents,
1919
- onValueChange: setContents,
1920
- highlight: function highlight(newCode) {
1921
- return /*#__PURE__*/React.createElement(Light, {
1922
- language: "json",
1923
- style: theme.palette.type === 'dark' ? a11yDark : a11yLight,
1924
- className: classes.syntaxHighlighter // override some inline style stuff that's higher specificity
1925
- // than className
1926
- ,
1927
- customStyle: {
1928
- background: 'none',
1929
- padding: 0
1930
- }
1931
- }, newCode);
1932
- },
1933
- padding: 10,
1934
- style: {}
1935
- });
1936
- }
1937
-
1938
- var CodeEditor$2 = {
1939
- __proto__: null,
1940
- 'default': CodeEditor$1
1941
- };
1942
-
1943
- var fontSize$1 = '12px'; // Optimize by using system default fonts:
1944
- // https://css-tricks.com/snippets/css/font-stacks/
1945
-
1946
- var fontFamily$1 = 'Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace';
1947
- var useStyles$2 = /*#__PURE__*/makeStyles(function (theme) {
1948
- return {
1949
- callbackEditor: {
1950
- marginTop: '16px',
1951
- borderBottom: "1px solid ".concat(theme.palette.divider),
1952
- fontFamily: fontFamily$1,
1953
- fontSize: fontSize$1
1954
- }
1955
- };
1956
- });
1957
-
1958
- function CallbackEditor(_ref) {
1959
- var slot = _ref.slot;
1960
- var classes = useStyles$2();
1961
-
1962
- var _useState = useState(slot.value),
1963
- _useState2 = _slicedToArray(_useState, 2),
1964
- code = _useState2[0],
1965
- setCode = _useState2[1];
1966
-
1967
- var _useState3 = useState(),
1968
- _useState4 = _slicedToArray(_useState3, 2),
1969
- error = _useState4[0],
1970
- setCodeError = _useState4[1];
1971
-
1972
- var debouncedCode = useDebounce(code, 400);
1973
- useEffect(function () {
1974
- try {
1975
- var _getEnv$pluginManager;
1976
-
1977
- var jexlDebouncedCode = debouncedCode.startsWith('jexl:') ? debouncedCode : "jexl:".concat(debouncedCode);
1978
- stringToJexlExpression(jexlDebouncedCode, (_getEnv$pluginManager = getEnv(slot).pluginManager) === null || _getEnv$pluginManager === void 0 ? void 0 : _getEnv$pluginManager.jexl);
1979
- slot.set(jexlDebouncedCode);
1980
- setCodeError(null);
1981
- } catch (e) {
1982
- console.error({
1983
- e: e
1984
- });
1985
- setCodeError(e);
1986
- }
1987
- }, [debouncedCode, slot]); // if default value is a callback, will have to remove jexl:
1988
- // do this last
1989
-
1990
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(InputLabel, {
1991
- shrink: true,
1992
- htmlFor: "callback-editor"
1993
- }, slot.name), /*#__PURE__*/React.createElement(Editor, {
1994
- className: classes.callbackEditor,
1995
- value: code.startsWith('jexl:') ? code.split('jexl:')[1] : code,
1996
- onValueChange: function onValueChange(newCode) {
1997
- return setCode(newCode);
1998
- },
1999
- highlight: function highlight(newCode) {
2000
- return newCode;
2001
- },
2002
- padding: 10,
2003
- style: {
2004
- background: error ? '#fdd' : undefined
2005
- }
2006
- }), error ? /*#__PURE__*/React.createElement(FormHelperText, {
2007
- style: {
2008
- color: '#f00'
2009
- }
2010
- }, "".concat(error)) : null, /*#__PURE__*/React.createElement(FormHelperText, null, slot.description)), /*#__PURE__*/React.createElement(Tooltip, {
2011
- title: /*#__PURE__*/React.createElement("div", null, "Callbacks are written in Jexl format. Click to learn more.", /*#__PURE__*/React.createElement("br", null), " Names of available context items: ", slot.contextVariable),
2012
- arrow: true
2013
- }, /*#__PURE__*/React.createElement(IconButton, {
2014
- color: "primary",
2015
- onClick: function onClick() {
2016
- var newWindow = window.open('https://github.com/TomFrost/Jexl', '_blank', 'noopener,noreferrer');
2017
-
2018
- if (newWindow) {
2019
- newWindow.opener = null;
2020
- }
2021
- }
2022
- }, /*#__PURE__*/React.createElement(HelpIcon, null))));
2023
- }
2024
-
2025
- CallbackEditor.propTypes = {
2026
- slot: PropTypes.objectOrObservableObject.isRequired
2027
- };
2028
- var CallbackEditor$1 = /*#__PURE__*/observer(CallbackEditor);
2029
-
2030
- var ColorPicker = /*#__PURE__*/lazy(function () {
2031
- return Promise.resolve().then(function () { return ColorPicker$2; });
2032
- }); // this is needed because passing a entire color object into the react-color
2033
- // for alpha, can't pass in an rgba string for example
2034
-
2035
- function serializeColor(color) {
2036
- if (color instanceof Object) {
2037
- var r = color.r,
2038
- g = color.g,
2039
- b = color.b,
2040
- a = color.a;
2041
- return a === undefined ? "rgb(".concat(r, ",").concat(g, ",").concat(b, ")") : "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(a, ")");
2042
- }
2043
-
2044
- return color;
2045
- }
2046
-
2047
- var ColorSlot = function ColorSlot(props) {
2048
- var value = props.value,
2049
- label = props.label,
2050
- TextFieldProps = props.TextFieldProps,
2051
- _onChange = props.onChange;
2052
-
2053
- var _useState = useState(false),
2054
- _useState2 = _slicedToArray(_useState, 2),
2055
- displayed = _useState2[0],
2056
- setDisplayed = _useState2[1];
2057
-
2058
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, Object.assign({
2059
- value: value,
2060
- label: label,
2061
- InputProps: {
2062
- style: {
2063
- color: value,
2064
- borderRightWidth: '25px',
2065
- borderRightStyle: 'solid',
2066
- borderRightColor: value
2067
- }
2068
- },
2069
- onClick: function onClick() {
2070
- return setDisplayed(!displayed);
2071
- },
2072
- onChange: function onChange(event) {
2073
- _onChange(event.target.value);
2074
- }
2075
- }, TextFieldProps)), displayed ? /*#__PURE__*/React.createElement(React.Suspense, {
2076
- fallback: /*#__PURE__*/React.createElement("div", null)
2077
- }, /*#__PURE__*/React.createElement(ColorPicker, {
2078
- color: value,
2079
- onChange: function onChange(event) {
2080
- _onChange(serializeColor(event.rgb));
2081
- }
2082
- })) : null);
2083
- };
2084
- ColorSlot.propTypes = {
2085
- onChange: ReactPropTypes.func.isRequired,
2086
- label: ReactPropTypes.string,
2087
- TextFieldProps: /*#__PURE__*/ReactPropTypes.shape({}),
2088
- value: ReactPropTypes.string
2089
- };
2090
- ColorSlot.defaultProps = {
2091
- label: '',
2092
- value: '#000',
2093
- TextFieldProps: {}
2094
- };
2095
-
2096
- function ColorEditorSlot(props) {
2097
- var slot = props.slot;
2098
- return /*#__PURE__*/React.createElement(ColorSlot, {
2099
- label: slot.name,
2100
- value: slot.value,
2101
- onChange: function onChange(color) {
2102
- slot.set(color);
2103
- },
2104
- TextFieldProps: {
2105
- helperText: slot.description,
2106
- fullWidth: true
2107
- }
2108
- });
2109
- }
2110
-
2111
- ColorEditorSlot.propTypes = {
2112
- slot: /*#__PURE__*/ReactPropTypes.shape({
2113
- name: ReactPropTypes.string.isRequired,
2114
- description: ReactPropTypes.string,
2115
- value: ReactPropTypes.string.isRequired,
2116
- set: ReactPropTypes.func.isRequired
2117
- }).isRequired
2118
- };
2119
- var ColorEditor = /*#__PURE__*/observer(ColorEditorSlot);
2120
-
2121
- var StringEditor = /*#__PURE__*/observer(function (_ref) {
2122
- var slot = _ref.slot;
2123
- return /*#__PURE__*/React.createElement(TextField$1, {
2124
- label: slot.name // error={filterError}
2125
- ,
2126
- helperText: slot.description,
2127
- fullWidth: true,
2128
- value: slot.value,
2129
- onChange: function onChange(evt) {
2130
- return slot.set(evt.target.value);
2131
- }
2132
- });
2133
- });
2134
- var TextEditor = /*#__PURE__*/observer(function (_ref2) {
2135
- var slot = _ref2.slot;
2136
- return /*#__PURE__*/React.createElement(TextField$1, {
2137
- label: slot.name,
2138
- helperText: slot.description,
2139
- fullWidth: true,
2140
- multiline: true,
2141
- value: slot.value,
2142
- onChange: function onChange(evt) {
2143
- return slot.set(evt.target.value);
2144
- }
2145
- });
2146
- }); // checked checkbox, looks like a styled (x)
2147
-
2148
- var SvgCheckbox = function SvgCheckbox() {
2149
- return /*#__PURE__*/React.createElement(SvgIcon, null, /*#__PURE__*/React.createElement("path", {
2150
- d: "M20.41,3C21.8,5.71 22.35,8.84 22,12C21.8,15.16 20.7,18.29 18.83,21L17.3,20C18.91,17.57 19.85,14.8 20,12C20.34,9.2 19.89,6.43 18.7,4L20.41,3M5.17,3L6.7,4C5.09,6.43 4.15,9.2 4,12C3.66,14.8 4.12,17.57 5.3,20L3.61,21C2.21,18.29 1.65,15.17 2,12C2.2,8.84 3.3,5.71 5.17,3M12.08,10.68L14.4,7.45H16.93L13.15,12.45L15.35,17.37H13.09L11.71,14L9.28,17.33H6.76L10.66,12.21L8.53,7.45H10.8L12.08,10.68Z"
2151
- }));
2152
- };
2153
-
2154
- var StringArrayEditor = /*#__PURE__*/observer(function (_ref3) {
2155
- var slot = _ref3.slot;
2156
-
2157
- var _useState = useState(''),
2158
- _useState2 = _slicedToArray(_useState, 2),
2159
- value = _useState2[0],
2160
- setValue = _useState2[1];
2161
-
2162
- return /*#__PURE__*/React.createElement(React.Fragment, null, slot.name ? /*#__PURE__*/React.createElement(InputLabel, null, slot.name) : null, /*#__PURE__*/React.createElement(List, {
2163
- disablePadding: true
2164
- }, slot.value.map(function (val, idx) {
2165
- return /*#__PURE__*/React.createElement(ListItem, {
2166
- key: idx,
2167
- disableGutters: true
2168
- }, /*#__PURE__*/React.createElement(TextField$1, {
2169
- value: val,
2170
- onChange: function onChange(evt) {
2171
- return slot.setAtIndex(idx, evt.target.value);
2172
- },
2173
- InputProps: {
2174
- endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
2175
- position: "end"
2176
- }, /*#__PURE__*/React.createElement(IconButton, {
2177
- color: "secondary",
2178
- onClick: function onClick() {
2179
- return slot.removeAtIndex(idx);
2180
- }
2181
- }, /*#__PURE__*/React.createElement(DeleteIcon, null)))
2182
- }
2183
- }));
2184
- }), /*#__PURE__*/React.createElement(ListItem, {
2185
- disableGutters: true
2186
- }, /*#__PURE__*/React.createElement(TextField$1, {
2187
- value: value,
2188
- placeholder: "add new",
2189
- onChange: function onChange(event) {
2190
- return setValue(event.target.value);
2191
- },
2192
- InputProps: {
2193
- endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
2194
- position: "end"
2195
- }, /*#__PURE__*/React.createElement(IconButton, {
2196
- onClick: function onClick() {
2197
- slot.add(value);
2198
- setValue('');
2199
- },
2200
- disabled: value === '',
2201
- color: "secondary",
2202
- "data-testid": "stringArrayAdd-".concat(slot.name)
2203
- }, /*#__PURE__*/React.createElement(AddIcon, null)))
2204
- }
2205
- }))), /*#__PURE__*/React.createElement(FormHelperText, null, slot.description));
2206
- });
2207
- var useMapEditorStyles = /*#__PURE__*/makeStyles(function (theme) {
2208
- return {
2209
- card: {
2210
- marginTop: theme.spacing(1)
2211
- }
2212
- };
2213
- });
2214
- var StringArrayMapEditor = /*#__PURE__*/observer(function (_ref4) {
2215
- var slot = _ref4.slot;
2216
- var classes = useMapEditorStyles();
2217
-
2218
- var _useState3 = useState(''),
2219
- _useState4 = _slicedToArray(_useState3, 2),
2220
- value = _useState4[0],
2221
- setValue = _useState4[1];
2222
-
2223
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputLabel, null, slot.name), Array.from(slot.value, function (_ref5) {
2224
- var _ref6 = _slicedToArray(_ref5, 2),
2225
- key = _ref6[0],
2226
- val = _ref6[1];
2227
-
2228
- return /*#__PURE__*/React.createElement(Card, {
2229
- raised: true,
2230
- key: key,
2231
- className: classes.card
2232
- }, /*#__PURE__*/React.createElement(CardHeader, {
2233
- title: key,
2234
- action: /*#__PURE__*/React.createElement(IconButton, {
2235
- color: "secondary",
2236
- onClick: function onClick() {
2237
- return slot.remove(key);
2238
- }
2239
- }, /*#__PURE__*/React.createElement(DeleteIcon, null))
2240
- }), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(StringArrayEditor, {
2241
- slot: {
2242
- value: val,
2243
- description: "Values associated with entry ".concat(key),
2244
- setAtIndex: function setAtIndex(idx, strValue) {
2245
- slot.setAtKeyIndex(key, idx, strValue);
2246
- },
2247
- removeAtIndex: function removeAtIndex(idx) {
2248
- slot.removeAtKeyIndex(key, idx);
2249
- },
2250
- add: function add(strValue) {
2251
- slot.addToKey(key, strValue);
2252
- }
2253
- }
2254
- })));
2255
- }), /*#__PURE__*/React.createElement(Card, {
2256
- raised: true,
2257
- className: classes.card
2258
- }, /*#__PURE__*/React.createElement(CardHeader, {
2259
- disableTypography: true,
2260
- title: /*#__PURE__*/React.createElement(TextField$1, {
2261
- fullWidth: true,
2262
- value: value,
2263
- placeholder: "add new",
2264
- onChange: function onChange(event) {
2265
- return setValue(event.target.value);
2266
- },
2267
- InputProps: {
2268
- endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
2269
- position: "end"
2270
- }, /*#__PURE__*/React.createElement(IconButton, {
2271
- disabled: value === '',
2272
- onClick: function onClick() {
2273
- slot.add(value, []);
2274
- setValue('');
2275
- },
2276
- color: "secondary"
2277
- }, /*#__PURE__*/React.createElement(AddIcon, null)))
2278
- }
2279
- })
2280
- })), /*#__PURE__*/React.createElement(FormHelperText, null, slot.description));
2281
- });
2282
- var NumberMapEditor = /*#__PURE__*/observer(function (_ref7) {
2283
- var slot = _ref7.slot;
2284
- var classes = useMapEditorStyles();
2285
-
2286
- var _useState5 = useState(''),
2287
- _useState6 = _slicedToArray(_useState5, 2),
2288
- value = _useState6[0],
2289
- setValue = _useState6[1];
2290
-
2291
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(InputLabel, null, slot.name), Array.from(slot.value, function (_ref8) {
2292
- var _ref9 = _slicedToArray(_ref8, 2),
2293
- key = _ref9[0],
2294
- val = _ref9[1];
2295
-
2296
- return /*#__PURE__*/React.createElement(Card, {
2297
- raised: true,
2298
- key: key,
2299
- className: classes.card
2300
- }, /*#__PURE__*/React.createElement(CardHeader, {
2301
- title: key,
2302
- action: /*#__PURE__*/React.createElement(IconButton, {
2303
- color: "secondary",
2304
- onClick: function onClick() {
2305
- return slot.remove(key);
2306
- }
2307
- }, /*#__PURE__*/React.createElement(DeleteIcon, null))
2308
- }), /*#__PURE__*/React.createElement(CardContent, null, /*#__PURE__*/React.createElement(NumberEditor, {
2309
- slot: {
2310
- value: val,
2311
- set: function set(numValue) {
2312
- return slot.add(key, numValue);
2313
- }
2314
- }
2315
- })));
2316
- }), /*#__PURE__*/React.createElement(Card, {
2317
- raised: true,
2318
- className: classes.card
2319
- }, /*#__PURE__*/React.createElement(CardHeader, {
2320
- disableTypography: true,
2321
- title: /*#__PURE__*/React.createElement(TextField$1, {
2322
- fullWidth: true,
2323
- value: value,
2324
- placeholder: "add new",
2325
- onChange: function onChange(event) {
2326
- return setValue(event.target.value);
2327
- },
2328
- InputProps: {
2329
- endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
2330
- position: "end"
2331
- }, /*#__PURE__*/React.createElement(IconButton, {
2332
- disabled: value === '',
2333
- onClick: function onClick() {
2334
- slot.add(value, 0);
2335
- setValue('');
2336
- },
2337
- color: "secondary"
2338
- }, /*#__PURE__*/React.createElement(AddIcon, null)))
2339
- }
2340
- })
2341
- })), /*#__PURE__*/React.createElement(FormHelperText, null, slot.description));
2342
- });
2343
- var NumberEditor = /*#__PURE__*/observer(function (_ref10) {
2344
- var slot = _ref10.slot;
2345
-
2346
- var _useState7 = useState(slot.value),
2347
- _useState8 = _slicedToArray(_useState7, 2),
2348
- val = _useState8[0],
2349
- setVal = _useState8[1];
2350
-
2351
- useEffect(function () {
2352
- var num = parseFloat(val, 10);
2353
-
2354
- if (!Number.isNaN(num)) {
2355
- slot.set(num);
2356
- } else {
2357
- slot.reset();
2358
- }
2359
- }, [slot, val]);
2360
- return /*#__PURE__*/React.createElement(TextField$1, {
2361
- label: slot.name,
2362
- helperText: slot.description,
2363
- value: val,
2364
- type: "number",
2365
- onChange: function onChange(evt) {
2366
- return setVal(evt.target.value);
2367
- }
2368
- });
2369
- });
2370
- var IntegerEditor = /*#__PURE__*/observer(function (_ref11) {
2371
- var slot = _ref11.slot;
2372
-
2373
- var _useState9 = useState(slot.value),
2374
- _useState10 = _slicedToArray(_useState9, 2),
2375
- val = _useState10[0],
2376
- setVal = _useState10[1];
2377
-
2378
- useEffect(function () {
2379
- var num = parseInt(val, 10);
2380
-
2381
- if (!Number.isNaN(num)) {
2382
- slot.set(num);
2383
- }
2384
- }, [slot, val]);
2385
- return /*#__PURE__*/React.createElement(TextField$1, {
2386
- label: slot.name,
2387
- helperText: slot.description,
2388
- value: val,
2389
- type: "number",
2390
- onChange: function onChange(evt) {
2391
- return setVal(evt.target.value);
2392
- }
2393
- });
2394
- });
2395
- var booleanEditor = /*#__PURE__*/observer(function (_ref12) {
2396
- var slot = _ref12.slot;
2397
- return /*#__PURE__*/React.createElement(FormControl, null, /*#__PURE__*/React.createElement(FormControlLabel, {
2398
- label: slot.name,
2399
- control: /*#__PURE__*/React.createElement(Checkbox, {
2400
- checked: slot.value,
2401
- onChange: function onChange(evt) {
2402
- return slot.set(evt.target.checked);
2403
- }
2404
- })
2405
- }), /*#__PURE__*/React.createElement(FormHelperText, null, slot.description));
2406
- });
2407
- var stringEnumEditor = /*#__PURE__*/observer(function (_ref13) {
2408
- var slot = _ref13.slot,
2409
- slotSchema = _ref13.slotSchema;
2410
- var p = getPropertyMembers(getSubType(slotSchema));
2411
- var choices = getUnionSubTypes(getUnionSubTypes(getSubType(getPropertyType(p, 'value')))[1]).map(function (t) {
2412
- return t.value;
2413
- });
2414
- return /*#__PURE__*/React.createElement(TextField$1, {
2415
- value: slot.value,
2416
- label: slot.name,
2417
- select: true // error={filterError}
2418
- ,
2419
- helperText: slot.description,
2420
- fullWidth: true,
2421
- onChange: function onChange(evt) {
2422
- return slot.set(evt.target.value);
2423
- }
2424
- }, choices.map(function (str) {
2425
- return /*#__PURE__*/React.createElement(MenuItem, {
2426
- key: str,
2427
- value: str
2428
- }, str);
2429
- }));
2430
- });
2431
- var FileSelectorWrapper = /*#__PURE__*/observer(function (_ref14) {
2432
- var _getEnv$pluginManager;
2433
-
2434
- var slot = _ref14.slot;
2435
- return /*#__PURE__*/React.createElement(FileSelector, {
2436
- location: slot.value,
2437
- setLocation: function setLocation(location) {
2438
- return slot.set(location);
2439
- },
2440
- name: slot.name,
2441
- description: slot.description,
2442
- rootModel: (_getEnv$pluginManager = getEnv(slot).pluginManager) === null || _getEnv$pluginManager === void 0 ? void 0 : _getEnv$pluginManager.rootModel
2443
- });
2444
- });
2445
- var valueComponents = {
2446
- string: StringEditor,
2447
- text: TextEditor,
2448
- fileLocation: FileSelectorWrapper,
2449
- stringArray: StringArrayEditor,
2450
- stringArrayMap: StringArrayMapEditor,
2451
- numberMap: NumberMapEditor,
2452
- number: NumberEditor,
2453
- integer: IntegerEditor,
2454
- color: ColorEditor,
2455
- stringEnum: stringEnumEditor,
2456
- "boolean": booleanEditor,
2457
- frozen: JsonEditor$1,
2458
- configRelationships: JsonEditor$1
2459
- };
2460
- var useSlotEditorStyles = /*#__PURE__*/makeStyles(function (theme) {
2461
- return {
2462
- paper: {
2463
- display: 'flex',
2464
- marginBottom: theme.spacing(2),
2465
- position: 'relative'
2466
- },
2467
- paperContent: {
2468
- width: '100%'
2469
- },
2470
- slotModeSwitch: {
2471
- width: 24,
2472
- background: theme.palette.secondary.light,
2473
- display: 'flex',
2474
- justifyContent: 'center',
2475
- alignItems: 'center'
2476
- }
2477
- };
2478
- });
2479
- var SlotEditor = /*#__PURE__*/observer(function (_ref15) {
2480
- var slot = _ref15.slot,
2481
- slotSchema = _ref15.slotSchema;
2482
- var classes = useSlotEditorStyles();
2483
- var type = slot.type;
2484
- var ValueComponent = slot.isCallback ? CallbackEditor$1 : valueComponents[type];
2485
-
2486
- if (!ValueComponent) {
2487
- console.warn("no slot editor defined for ".concat(type, ", editing as string"));
2488
- ValueComponent = StringEditor;
2489
- }
2490
-
2491
- if (!(type in valueComponents)) {
2492
- console.warn("SlotEditor needs to implement ".concat(type));
2493
- }
2494
-
2495
- return /*#__PURE__*/React.createElement(Paper, {
2496
- className: classes.paper
2497
- }, /*#__PURE__*/React.createElement("div", {
2498
- className: classes.paperContent
2499
- }, /*#__PURE__*/React.createElement(ValueComponent, {
2500
- slot: slot,
2501
- slotSchema: slotSchema
2502
- })), /*#__PURE__*/React.createElement("div", {
2503
- className: classes.slotModeSwitch
2504
- }, slot.contextVariable.length ? /*#__PURE__*/React.createElement(IconButton, {
2505
- className: classes.slotModeIcon,
2506
- onClick: function onClick() {
2507
- return slot.isCallback ? slot.convertToValue() : slot.convertToCallback();
2508
- },
2509
- title: "convert to ".concat(slot.isCallback ? 'regular value' : 'callback'),
2510
- color: "secondary"
2511
- }, !slot.isCallback ? /*#__PURE__*/React.createElement(RadioButtonUncheckedIcon, null) : /*#__PURE__*/React.createElement(SvgCheckbox, null)) : null));
2512
- });
2513
-
2514
- var TypeSelector = /*#__PURE__*/observer(function (_ref) {
2515
- var typeNameChoices = _ref.typeNameChoices,
2516
- slot = _ref.slot,
2517
- slotName = _ref.slotName,
2518
- onChange = _ref.onChange;
2519
- var classes = useSlotEditorStyles();
2520
- return /*#__PURE__*/React.createElement(Paper$1, {
2521
- className: classes.paper
2522
- }, /*#__PURE__*/React.createElement("div", {
2523
- className: classes.paperContent
2524
- }, /*#__PURE__*/React.createElement(TextField, {
2525
- value: slot.type,
2526
- label: "Type",
2527
- select: true // error={filterError}
2528
- ,
2529
- helperText: "Type of ".concat(slotName, " to use"),
2530
- fullWidth: true,
2531
- onChange: onChange
2532
- }, typeNameChoices.map(function (str) {
2533
- return /*#__PURE__*/React.createElement(MenuItem$1, {
2534
- key: str,
2535
- value: str
2536
- }, str);
2537
- }))));
2538
- });
2539
-
2540
- var useStyles$3 = /*#__PURE__*/makeStyles(function (theme) {
2541
- return {
2542
- expandIcon: {
2543
- color: '#fff'
2544
- },
2545
- root: {
2546
- padding: theme.spacing(1, 3, 1, 1)
2547
- },
2548
- expansionPanelDetails: {
2549
- display: 'block',
2550
- padding: theme.spacing(1)
2551
- },
2552
- accordion: {
2553
- border: "1px solid ".concat(theme.palette.text.primary)
2554
- }
2555
- };
2556
- });
2557
- var Member = /*#__PURE__*/observer(function (props) {
2558
- var classes = useStyles$3();
2559
- var slotName = props.slotName,
2560
- slotSchema = props.slotSchema,
2561
- schema = props.schema,
2562
- _props$slot = props.slot,
2563
- slot = _props$slot === void 0 ? schema[slotName] : _props$slot,
2564
- _props$path = props.path,
2565
- path = _props$path === void 0 ? [] : _props$path;
2566
- var typeSelector;
2567
-
2568
- if (isConfigurationSchemaType(slotSchema)) {
2569
- if (slot.length) {
2570
- return slot.map(function (subslot, slotIndex) {
2571
- var key = "".concat(singular(slotName), " ").concat(slotIndex + 1);
2572
- return /*#__PURE__*/React.createElement(Member, _extends({}, props, {
2573
- key: key,
2574
- slot: subslot,
2575
- slotName: key
2576
- }));
2577
- });
2578
- } // if this is an explicitly typed schema, make a type-selecting dropdown
2579
- // that can be used to change its type
2580
-
2581
-
2582
- var typeNameChoices = getTypeNamesFromExplicitlyTypedUnion(slotSchema);
2583
-
2584
- if (typeNameChoices.length) {
2585
- typeSelector = /*#__PURE__*/React.createElement(TypeSelector, {
2586
- typeNameChoices: typeNameChoices,
2587
- slotName: slotName,
2588
- slot: slot,
2589
- onChange: function onChange(evt) {
2590
- if (evt.target.value !== slot.type) {
2591
- schema.setSubschema(slotName, {
2592
- type: evt.target.value
2593
- });
2594
- }
2595
- }
2596
- });
2597
- }
2598
-
2599
- return /*#__PURE__*/React.createElement(Accordion, {
2600
- defaultExpanded: true,
2601
- className: classes.accordion,
2602
- TransitionProps: {
2603
- unmountOnExit: true,
2604
- timeout: 150
2605
- }
2606
- }, /*#__PURE__*/React.createElement(AccordionSummary, {
2607
- expandIcon: /*#__PURE__*/React.createElement(ExpandMoreIcon, {
2608
- className: classes.expandIcon
2609
- })
2610
- }, /*#__PURE__*/React.createElement(Typography, null, [].concat(_toConsumableArray(path), [slotName]).join('🡒'))), /*#__PURE__*/React.createElement(AccordionDetails, {
2611
- className: classes.expansionPanelDetails
2612
- }, typeSelector, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Schema, {
2613
- schema: slot,
2614
- path: [].concat(_toConsumableArray(path), [slotName])
2615
- }))));
2616
- }
2617
-
2618
- if (isConfigurationSlotType(slotSchema)) {
2619
- // this is a regular config slot
2620
- return /*#__PURE__*/React.createElement(SlotEditor, {
2621
- key: slotName,
2622
- slot: slot,
2623
- slotSchema: slotSchema
2624
- });
2625
- }
2626
-
2627
- return null;
2628
- });
2629
- var Schema = /*#__PURE__*/observer(function (_ref) {
2630
- var schema = _ref.schema,
2631
- _ref$path = _ref.path,
2632
- path = _ref$path === void 0 ? [] : _ref$path;
2633
- var properties = getMembers(schema).properties;
2634
- return Object.entries(properties).map(function (_ref2) {
2635
- var _ref3 = _slicedToArray(_ref2, 2),
2636
- slotName = _ref3[0],
2637
- slotSchema = _ref3[1];
2638
-
2639
- return /*#__PURE__*/React.createElement(Member, {
2640
- key: slotName,
2641
- slotName: slotName,
2642
- slotSchema: slotSchema,
2643
- path: path,
2644
- schema: schema
2645
- });
2646
- });
2647
- });
2648
- var ConfigurationEditor = /*#__PURE__*/observer(function (_ref4) {
2649
- var model = _ref4.model;
2650
- var classes = useStyles$3(); // key forces a re-render, otherwise the same field can end up being used
2651
- // for different tracks since only the backing model changes for example
2652
- // see pr #804
2653
-
2654
- var key = model.target && readConfObject(model.target, 'trackId');
2655
- var name = model.target && readConfObject(model.target, 'name');
2656
- return /*#__PURE__*/React.createElement(Accordion, {
2657
- key: key,
2658
- defaultExpanded: true,
2659
- className: classes.accordion,
2660
- TransitionProps: {
2661
- unmountOnExit: true,
2662
- timeout: 150
2663
- }
2664
- }, /*#__PURE__*/React.createElement(AccordionSummary, {
2665
- expandIcon: /*#__PURE__*/React.createElement(ExpandMoreIcon, {
2666
- className: classes.expandIcon
2667
- })
2668
- }, /*#__PURE__*/React.createElement(Typography, null, name ? name : 'Configuration')), /*#__PURE__*/React.createElement(AccordionDetails, {
2669
- className: classes.expansionPanelDetails,
2670
- "data-testid": "configEditor"
2671
- }, !model.target ? 'no target set' : /*#__PURE__*/React.createElement(Schema, {
2672
- schema: model.target
2673
- })));
2674
- });
2675
-
2676
- var ConfigurationEditor$1 = {
2677
- __proto__: null,
2678
- 'default': ConfigurationEditor
2679
- };
2680
-
2681
- var useStyles$4 = /*#__PURE__*/makeStyles$1({
2682
- popover: {
2683
- position: 'absolute',
2684
- zIndex: 2
2685
- },
2686
- cover: {
2687
- position: 'fixed',
2688
- top: 0,
2689
- right: 0,
2690
- bottom: 0,
2691
- left: 0
2692
- }
2693
- });
2694
- function ColorPicker$1(props) {
2695
- var color = props.color,
2696
- onChange = props.onChange;
2697
- var classes = useStyles$4();
2698
-
2699
- var _useState = useState(true),
2700
- _useState2 = _slicedToArray(_useState, 2),
2701
- displayColorPicker = _useState2[0],
2702
- setDisplayColorPicker = _useState2[1];
2703
-
2704
- var handleClose = function handleClose() {
2705
- setDisplayColorPicker(false);
2706
- };
2707
-
2708
- return /*#__PURE__*/React.createElement("div", null, displayColorPicker ? /*#__PURE__*/React.createElement("div", {
2709
- className: classes.popover
2710
- }, /*#__PURE__*/React.createElement("div", {
2711
- role: "presentation",
2712
- className: classes.cover,
2713
- onClick: handleClose
2714
- }), /*#__PURE__*/React.createElement(ChromePicker, {
2715
- color: color,
2716
- onChange: onChange
2717
- })) : null);
2718
- }
2719
- ColorPicker$1.propTypes = {
2720
- color: ReactPropTypes.string.isRequired,
2721
- onChange: ReactPropTypes.func.isRequired
2722
- };
2723
-
2724
- var ColorPicker$2 = {
2725
- __proto__: null,
2726
- ColorPicker: ColorPicker$1,
2727
- 'default': ColorPicker$1
2728
- };
2729
-
2730
- export default _default;
2731
- export { ConfigurationEditorComponent as ConfigurationEditor, JsonEditor$1 as JsonEditor };
2732
- //# sourceMappingURL=plugin-config.esm.js.map