@jbrowse/plugin-legacy-jbrowse 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 (48) hide show
  1. package/dist/JBrowse1Connection/configSchema.d.ts +2 -2
  2. package/dist/JBrowse1Connection/configSchema.js +30 -0
  3. package/dist/JBrowse1Connection/index.d.ts +2 -2
  4. package/dist/JBrowse1Connection/index.js +23 -0
  5. package/dist/JBrowse1Connection/jb1ConfigLoad.d.ts +36 -36
  6. package/dist/JBrowse1Connection/jb1ConfigLoad.js +555 -0
  7. package/dist/JBrowse1Connection/jb1ConfigParse.d.ts +11 -11
  8. package/dist/JBrowse1Connection/jb1ConfigParse.js +476 -0
  9. package/dist/JBrowse1Connection/jb1ToJb2.d.ts +47 -47
  10. package/dist/JBrowse1Connection/jb1ToJb2.js +556 -0
  11. package/dist/JBrowse1Connection/model.d.ts +15 -4
  12. package/dist/JBrowse1Connection/model.js +58 -0
  13. package/dist/JBrowse1Connection/types.d.ts +91 -91
  14. package/dist/JBrowse1Connection/types.js +5 -0
  15. package/dist/JBrowse1Connection/util.d.ts +26 -26
  16. package/dist/JBrowse1Connection/util.js +177 -0
  17. package/dist/JBrowse1TextSeachAdapter/HttpMap.d.ts +39 -39
  18. package/dist/JBrowse1TextSeachAdapter/HttpMap.js +350 -0
  19. package/dist/JBrowse1TextSeachAdapter/HttpMap.test.js +118 -0
  20. package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.d.ts +33 -33
  21. package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.js +191 -0
  22. package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.test.js +98 -0
  23. package/dist/JBrowse1TextSeachAdapter/configSchema.d.ts +2 -2
  24. package/dist/JBrowse1TextSeachAdapter/configSchema.js +35 -0
  25. package/dist/JBrowse1TextSeachAdapter/index.d.ts +2 -2
  26. package/dist/JBrowse1TextSeachAdapter/index.js +23 -0
  27. package/dist/NCListAdapter/NCListAdapter.d.ts +31 -31
  28. package/dist/NCListAdapter/NCListAdapter.js +237 -0
  29. package/dist/NCListAdapter/NCListAdapter.test.js +108 -0
  30. package/dist/NCListAdapter/NCListFeature.d.ts +31 -31
  31. package/dist/NCListAdapter/NCListFeature.js +142 -0
  32. package/dist/NCListAdapter/configSchema.d.ts +2 -2
  33. package/dist/NCListAdapter/configSchema.js +27 -0
  34. package/dist/NCListAdapter/index.d.ts +1 -1
  35. package/dist/NCListAdapter/index.js +15 -0
  36. package/dist/declare.d.js +1 -0
  37. package/dist/index.d.ts +6 -6
  38. package/dist/index.js +122 -6
  39. package/dist/index.test.js +44 -0
  40. package/package.json +5 -7
  41. package/src/JBrowse1Connection/jb1ConfigLoad.ts +1 -1
  42. package/dist/index.test.d.ts +0 -1
  43. package/dist/plugin-legacy-jbrowse.cjs.development.js +0 -3567
  44. package/dist/plugin-legacy-jbrowse.cjs.development.js.map +0 -1
  45. package/dist/plugin-legacy-jbrowse.cjs.production.min.js +0 -2
  46. package/dist/plugin-legacy-jbrowse.cjs.production.min.js.map +0 -1
  47. package/dist/plugin-legacy-jbrowse.esm.js +0 -3561
  48. package/dist/plugin-legacy-jbrowse.esm.js.map +0 -1
@@ -1,3567 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var AdapterType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/AdapterType'));
8
- var TextSearchAdapterType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/TextSearchAdapterType'));
9
- var ConnectionType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/ConnectionType'));
10
- var Plugin = _interopDefault(require('@jbrowse/core/Plugin'));
11
- var configuration = require('@jbrowse/core/configuration');
12
- var BaseAdapter = require('@jbrowse/core/data_adapters/BaseAdapter');
13
- var BaseResult = _interopDefault(require('@jbrowse/core/TextSearch/BaseResults'));
14
- var crc32 = _interopDefault(require('buffer-crc32'));
15
- var tracks = require('@jbrowse/core/util/tracks');
16
- var util = require('@jbrowse/core/util');
17
- var models = require('@jbrowse/core/pluggableElementTypes/models');
18
- var mobxStateTree = require('mobx-state-tree');
19
- var io = require('@jbrowse/core/util/io');
20
- var getValue = _interopDefault(require('get-value'));
21
- var setValue = _interopDefault(require('set-value'));
22
- var NCListStore = _interopDefault(require('@gmod/nclist'));
23
- var rxjs = require('@jbrowse/core/util/rxjs');
24
- var genericFilehandle = require('generic-filehandle');
25
-
26
- function _asyncIterator(iterable) {
27
- var method,
28
- async,
29
- sync,
30
- retry = 2;
31
-
32
- for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) {
33
- if (async && null != (method = iterable[async])) return method.call(iterable);
34
- if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable));
35
- async = "@@asyncIterator", sync = "@@iterator";
36
- }
37
-
38
- throw new TypeError("Object is not async iterable");
39
- }
40
-
41
- function AsyncFromSyncIterator(s) {
42
- function AsyncFromSyncIteratorContinuation(r) {
43
- if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object."));
44
- var done = r.done;
45
- return Promise.resolve(r.value).then(function (value) {
46
- return {
47
- value: value,
48
- done: done
49
- };
50
- });
51
- }
52
-
53
- return AsyncFromSyncIterator = function (s) {
54
- this.s = s, this.n = s.next;
55
- }, AsyncFromSyncIterator.prototype = {
56
- s: null,
57
- n: null,
58
- next: function () {
59
- return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
60
- },
61
- return: function (value) {
62
- var ret = this.s.return;
63
- return void 0 === ret ? Promise.resolve({
64
- value: value,
65
- done: !0
66
- }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
67
- },
68
- throw: function (value) {
69
- var thr = this.s.return;
70
- return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
71
- }
72
- }, new AsyncFromSyncIterator(s);
73
- }
74
-
75
- function ownKeys(object, enumerableOnly) {
76
- var keys = Object.keys(object);
77
-
78
- if (Object.getOwnPropertySymbols) {
79
- var symbols = Object.getOwnPropertySymbols(object);
80
- enumerableOnly && (symbols = symbols.filter(function (sym) {
81
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
82
- })), keys.push.apply(keys, symbols);
83
- }
84
-
85
- return keys;
86
- }
87
-
88
- function _objectSpread2(target) {
89
- for (var i = 1; i < arguments.length; i++) {
90
- var source = null != arguments[i] ? arguments[i] : {};
91
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
92
- _defineProperty(target, key, source[key]);
93
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
94
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
95
- });
96
- }
97
-
98
- return target;
99
- }
100
-
101
- function _typeof(obj) {
102
- "@babel/helpers - typeof";
103
-
104
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
105
- return typeof obj;
106
- } : function (obj) {
107
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
108
- }, _typeof(obj);
109
- }
110
-
111
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
112
- try {
113
- var info = gen[key](arg);
114
- var value = info.value;
115
- } catch (error) {
116
- reject(error);
117
- return;
118
- }
119
-
120
- if (info.done) {
121
- resolve(value);
122
- } else {
123
- Promise.resolve(value).then(_next, _throw);
124
- }
125
- }
126
-
127
- function _asyncToGenerator(fn) {
128
- return function () {
129
- var self = this,
130
- args = arguments;
131
- return new Promise(function (resolve, reject) {
132
- var gen = fn.apply(self, args);
133
-
134
- function _next(value) {
135
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
136
- }
137
-
138
- function _throw(err) {
139
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
140
- }
141
-
142
- _next(undefined);
143
- });
144
- };
145
- }
146
-
147
- function _classCallCheck(instance, Constructor) {
148
- if (!(instance instanceof Constructor)) {
149
- throw new TypeError("Cannot call a class as a function");
150
- }
151
- }
152
-
153
- function _defineProperties(target, props) {
154
- for (var i = 0; i < props.length; i++) {
155
- var descriptor = props[i];
156
- descriptor.enumerable = descriptor.enumerable || false;
157
- descriptor.configurable = true;
158
- if ("value" in descriptor) descriptor.writable = true;
159
- Object.defineProperty(target, descriptor.key, descriptor);
160
- }
161
- }
162
-
163
- function _createClass(Constructor, protoProps, staticProps) {
164
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
165
- if (staticProps) _defineProperties(Constructor, staticProps);
166
- Object.defineProperty(Constructor, "prototype", {
167
- writable: false
168
- });
169
- return Constructor;
170
- }
171
-
172
- function _defineProperty(obj, key, value) {
173
- if (key in obj) {
174
- Object.defineProperty(obj, key, {
175
- value: value,
176
- enumerable: true,
177
- configurable: true,
178
- writable: true
179
- });
180
- } else {
181
- obj[key] = value;
182
- }
183
-
184
- return obj;
185
- }
186
-
187
- function _inherits(subClass, superClass) {
188
- if (typeof superClass !== "function" && superClass !== null) {
189
- throw new TypeError("Super expression must either be null or a function");
190
- }
191
-
192
- subClass.prototype = Object.create(superClass && superClass.prototype, {
193
- constructor: {
194
- value: subClass,
195
- writable: true,
196
- configurable: true
197
- }
198
- });
199
- Object.defineProperty(subClass, "prototype", {
200
- writable: false
201
- });
202
- if (superClass) _setPrototypeOf(subClass, superClass);
203
- }
204
-
205
- function _getPrototypeOf(o) {
206
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
207
- return o.__proto__ || Object.getPrototypeOf(o);
208
- };
209
- return _getPrototypeOf(o);
210
- }
211
-
212
- function _setPrototypeOf(o, p) {
213
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
214
- o.__proto__ = p;
215
- return o;
216
- };
217
-
218
- return _setPrototypeOf(o, p);
219
- }
220
-
221
- function _isNativeReflectConstruct() {
222
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
223
- if (Reflect.construct.sham) return false;
224
- if (typeof Proxy === "function") return true;
225
-
226
- try {
227
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
228
- return true;
229
- } catch (e) {
230
- return false;
231
- }
232
- }
233
-
234
- function _assertThisInitialized(self) {
235
- if (self === void 0) {
236
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
237
- }
238
-
239
- return self;
240
- }
241
-
242
- function _possibleConstructorReturn(self, call) {
243
- if (call && (typeof call === "object" || typeof call === "function")) {
244
- return call;
245
- } else if (call !== void 0) {
246
- throw new TypeError("Derived constructors may only return object or undefined");
247
- }
248
-
249
- return _assertThisInitialized(self);
250
- }
251
-
252
- function _createSuper(Derived) {
253
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
254
-
255
- return function _createSuperInternal() {
256
- var Super = _getPrototypeOf(Derived),
257
- result;
258
-
259
- if (hasNativeReflectConstruct) {
260
- var NewTarget = _getPrototypeOf(this).constructor;
261
-
262
- result = Reflect.construct(Super, arguments, NewTarget);
263
- } else {
264
- result = Super.apply(this, arguments);
265
- }
266
-
267
- return _possibleConstructorReturn(this, result);
268
- };
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
- var ncListAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('NCListAdapter', {
347
- rootUrlTemplate: {
348
- type: 'fileLocation',
349
- defaultValue: {
350
- uri: '/path/to/my/{refseq}/trackData.json',
351
- locationType: 'UriLocation'
352
- }
353
- },
354
- refNames: {
355
- type: 'stringArray',
356
- defaultValue: [],
357
- description: 'List of refNames used by the NCList used for aliasing'
358
- }
359
- }, {
360
- explicitlyTyped: true
361
- });
362
-
363
- function createCommonjsModule(fn, module) {
364
- return module = { exports: {} }, fn(module, module.exports), module.exports;
365
- }
366
-
367
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
368
- /**
369
- * Copyright (c) 2014-present, Facebook, Inc.
370
- *
371
- * This source code is licensed under the MIT license found in the
372
- * LICENSE file in the root directory of this source tree.
373
- */
374
- var runtime = function (exports) {
375
-
376
- var Op = Object.prototype;
377
- var hasOwn = Op.hasOwnProperty;
378
- var undefined$1; // More compressible than void 0.
379
-
380
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
381
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
382
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
383
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
384
-
385
- function define(obj, key, value) {
386
- Object.defineProperty(obj, key, {
387
- value: value,
388
- enumerable: true,
389
- configurable: true,
390
- writable: true
391
- });
392
- return obj[key];
393
- }
394
-
395
- try {
396
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
397
- define({}, "");
398
- } catch (err) {
399
- define = function define(obj, key, value) {
400
- return obj[key] = value;
401
- };
402
- }
403
-
404
- function wrap(innerFn, outerFn, self, tryLocsList) {
405
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
406
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
407
- var generator = Object.create(protoGenerator.prototype);
408
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
409
- // .throw, and .return methods.
410
-
411
- generator._invoke = makeInvokeMethod(innerFn, self, context);
412
- return generator;
413
- }
414
-
415
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
416
- // record like context.tryEntries[i].completion. This interface could
417
- // have been (and was previously) designed to take a closure to be
418
- // invoked without arguments, but in all the cases we care about we
419
- // already have an existing method we want to call, so there's no need
420
- // to create a new function object. We can even get away with assuming
421
- // the method takes exactly one argument, since that happens to be true
422
- // in every case, so we don't have to touch the arguments object. The
423
- // only additional allocation required is the completion record, which
424
- // has a stable shape and so hopefully should be cheap to allocate.
425
-
426
- function tryCatch(fn, obj, arg) {
427
- try {
428
- return {
429
- type: "normal",
430
- arg: fn.call(obj, arg)
431
- };
432
- } catch (err) {
433
- return {
434
- type: "throw",
435
- arg: err
436
- };
437
- }
438
- }
439
-
440
- var GenStateSuspendedStart = "suspendedStart";
441
- var GenStateSuspendedYield = "suspendedYield";
442
- var GenStateExecuting = "executing";
443
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
444
- // breaking out of the dispatch switch statement.
445
-
446
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
447
- // .constructor.prototype properties for functions that return Generator
448
- // objects. For full spec compliance, you may wish to configure your
449
- // minifier not to mangle the names of these two functions.
450
-
451
- function Generator() {}
452
-
453
- function GeneratorFunction() {}
454
-
455
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
456
- // don't natively support it.
457
-
458
-
459
- var IteratorPrototype = {};
460
- define(IteratorPrototype, iteratorSymbol, function () {
461
- return this;
462
- });
463
- var getProto = Object.getPrototypeOf;
464
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
465
-
466
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
467
- // This environment has a native %IteratorPrototype%; use it instead
468
- // of the polyfill.
469
- IteratorPrototype = NativeIteratorPrototype;
470
- }
471
-
472
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
473
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
474
- define(Gp, "constructor", GeneratorFunctionPrototype);
475
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
476
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
477
- // Iterator interface in terms of a single ._invoke method.
478
-
479
- function defineIteratorMethods(prototype) {
480
- ["next", "throw", "return"].forEach(function (method) {
481
- define(prototype, method, function (arg) {
482
- return this._invoke(method, arg);
483
- });
484
- });
485
- }
486
-
487
- exports.isGeneratorFunction = function (genFun) {
488
- var ctor = typeof genFun === "function" && genFun.constructor;
489
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
490
- // do is to check its .name property.
491
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
492
- };
493
-
494
- exports.mark = function (genFun) {
495
- if (Object.setPrototypeOf) {
496
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
497
- } else {
498
- genFun.__proto__ = GeneratorFunctionPrototype;
499
- define(genFun, toStringTagSymbol, "GeneratorFunction");
500
- }
501
-
502
- genFun.prototype = Object.create(Gp);
503
- return genFun;
504
- }; // Within the body of any async function, `await x` is transformed to
505
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
506
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
507
- // meant to be awaited.
508
-
509
-
510
- exports.awrap = function (arg) {
511
- return {
512
- __await: arg
513
- };
514
- };
515
-
516
- function AsyncIterator(generator, PromiseImpl) {
517
- function invoke(method, arg, resolve, reject) {
518
- var record = tryCatch(generator[method], generator, arg);
519
-
520
- if (record.type === "throw") {
521
- reject(record.arg);
522
- } else {
523
- var result = record.arg;
524
- var value = result.value;
525
-
526
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
527
- return PromiseImpl.resolve(value.__await).then(function (value) {
528
- invoke("next", value, resolve, reject);
529
- }, function (err) {
530
- invoke("throw", err, resolve, reject);
531
- });
532
- }
533
-
534
- return PromiseImpl.resolve(value).then(function (unwrapped) {
535
- // When a yielded Promise is resolved, its final value becomes
536
- // the .value of the Promise<{value,done}> result for the
537
- // current iteration.
538
- result.value = unwrapped;
539
- resolve(result);
540
- }, function (error) {
541
- // If a rejected Promise was yielded, throw the rejection back
542
- // into the async generator function so it can be handled there.
543
- return invoke("throw", error, resolve, reject);
544
- });
545
- }
546
- }
547
-
548
- var previousPromise;
549
-
550
- function enqueue(method, arg) {
551
- function callInvokeWithMethodAndArg() {
552
- return new PromiseImpl(function (resolve, reject) {
553
- invoke(method, arg, resolve, reject);
554
- });
555
- }
556
-
557
- return previousPromise = // If enqueue has been called before, then we want to wait until
558
- // all previous Promises have been resolved before calling invoke,
559
- // so that results are always delivered in the correct order. If
560
- // enqueue has not been called before, then it is important to
561
- // call invoke immediately, without waiting on a callback to fire,
562
- // so that the async generator function has the opportunity to do
563
- // any necessary setup in a predictable way. This predictability
564
- // is why the Promise constructor synchronously invokes its
565
- // executor callback, and why async functions synchronously
566
- // execute code before the first await. Since we implement simple
567
- // async functions in terms of async generators, it is especially
568
- // important to get this right, even though it requires care.
569
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
570
- // invocations of the iterator.
571
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
572
- } // Define the unified helper method that is used to implement .next,
573
- // .throw, and .return (see defineIteratorMethods).
574
-
575
-
576
- this._invoke = enqueue;
577
- }
578
-
579
- defineIteratorMethods(AsyncIterator.prototype);
580
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
581
- return this;
582
- });
583
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
584
- // AsyncIterator objects; they just return a Promise for the value of
585
- // the final result produced by the iterator.
586
-
587
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
588
- if (PromiseImpl === void 0) PromiseImpl = Promise;
589
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
590
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
591
- : iter.next().then(function (result) {
592
- return result.done ? result.value : iter.next();
593
- });
594
- };
595
-
596
- function makeInvokeMethod(innerFn, self, context) {
597
- var state = GenStateSuspendedStart;
598
- return function invoke(method, arg) {
599
- if (state === GenStateExecuting) {
600
- throw new Error("Generator is already running");
601
- }
602
-
603
- if (state === GenStateCompleted) {
604
- if (method === "throw") {
605
- throw arg;
606
- } // Be forgiving, per 25.3.3.3.3 of the spec:
607
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
608
-
609
-
610
- return doneResult();
611
- }
612
-
613
- context.method = method;
614
- context.arg = arg;
615
-
616
- while (true) {
617
- var delegate = context.delegate;
618
-
619
- if (delegate) {
620
- var delegateResult = maybeInvokeDelegate(delegate, context);
621
-
622
- if (delegateResult) {
623
- if (delegateResult === ContinueSentinel) continue;
624
- return delegateResult;
625
- }
626
- }
627
-
628
- if (context.method === "next") {
629
- // Setting context._sent for legacy support of Babel's
630
- // function.sent implementation.
631
- context.sent = context._sent = context.arg;
632
- } else if (context.method === "throw") {
633
- if (state === GenStateSuspendedStart) {
634
- state = GenStateCompleted;
635
- throw context.arg;
636
- }
637
-
638
- context.dispatchException(context.arg);
639
- } else if (context.method === "return") {
640
- context.abrupt("return", context.arg);
641
- }
642
-
643
- state = GenStateExecuting;
644
- var record = tryCatch(innerFn, self, context);
645
-
646
- if (record.type === "normal") {
647
- // If an exception is thrown from innerFn, we leave state ===
648
- // GenStateExecuting and loop back for another invocation.
649
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
650
-
651
- if (record.arg === ContinueSentinel) {
652
- continue;
653
- }
654
-
655
- return {
656
- value: record.arg,
657
- done: context.done
658
- };
659
- } else if (record.type === "throw") {
660
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
661
- // context.dispatchException(context.arg) call above.
662
-
663
- context.method = "throw";
664
- context.arg = record.arg;
665
- }
666
- }
667
- };
668
- } // Call delegate.iterator[context.method](context.arg) and handle the
669
- // result, either by returning a { value, done } result from the
670
- // delegate iterator, or by modifying context.method and context.arg,
671
- // setting context.delegate to null, and returning the ContinueSentinel.
672
-
673
-
674
- function maybeInvokeDelegate(delegate, context) {
675
- var method = delegate.iterator[context.method];
676
-
677
- if (method === undefined$1) {
678
- // A .throw or .return when the delegate iterator has no .throw
679
- // method always terminates the yield* loop.
680
- context.delegate = null;
681
-
682
- if (context.method === "throw") {
683
- // Note: ["return"] must be used for ES3 parsing compatibility.
684
- if (delegate.iterator["return"]) {
685
- // If the delegate iterator has a return method, give it a
686
- // chance to clean up.
687
- context.method = "return";
688
- context.arg = undefined$1;
689
- maybeInvokeDelegate(delegate, context);
690
-
691
- if (context.method === "throw") {
692
- // If maybeInvokeDelegate(context) changed context.method from
693
- // "return" to "throw", let that override the TypeError below.
694
- return ContinueSentinel;
695
- }
696
- }
697
-
698
- context.method = "throw";
699
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
700
- }
701
-
702
- return ContinueSentinel;
703
- }
704
-
705
- var record = tryCatch(method, delegate.iterator, context.arg);
706
-
707
- if (record.type === "throw") {
708
- context.method = "throw";
709
- context.arg = record.arg;
710
- context.delegate = null;
711
- return ContinueSentinel;
712
- }
713
-
714
- var info = record.arg;
715
-
716
- if (!info) {
717
- context.method = "throw";
718
- context.arg = new TypeError("iterator result is not an object");
719
- context.delegate = null;
720
- return ContinueSentinel;
721
- }
722
-
723
- if (info.done) {
724
- // Assign the result of the finished delegate to the temporary
725
- // variable specified by delegate.resultName (see delegateYield).
726
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
727
-
728
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
729
- // exception, let the outer generator proceed normally. If
730
- // context.method was "next", forget context.arg since it has been
731
- // "consumed" by the delegate iterator. If context.method was
732
- // "return", allow the original .return call to continue in the
733
- // outer generator.
734
-
735
- if (context.method !== "return") {
736
- context.method = "next";
737
- context.arg = undefined$1;
738
- }
739
- } else {
740
- // Re-yield the result returned by the delegate method.
741
- return info;
742
- } // The delegate iterator is finished, so forget it and continue with
743
- // the outer generator.
744
-
745
-
746
- context.delegate = null;
747
- return ContinueSentinel;
748
- } // Define Generator.prototype.{next,throw,return} in terms of the
749
- // unified ._invoke helper method.
750
-
751
-
752
- defineIteratorMethods(Gp);
753
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
754
- // @@iterator function is called on it. Some browsers' implementations of the
755
- // iterator prototype chain incorrectly implement this, causing the Generator
756
- // object to not be returned from this call. This ensures that doesn't happen.
757
- // See https://github.com/facebook/regenerator/issues/274 for more details.
758
-
759
- define(Gp, iteratorSymbol, function () {
760
- return this;
761
- });
762
- define(Gp, "toString", function () {
763
- return "[object Generator]";
764
- });
765
-
766
- function pushTryEntry(locs) {
767
- var entry = {
768
- tryLoc: locs[0]
769
- };
770
-
771
- if (1 in locs) {
772
- entry.catchLoc = locs[1];
773
- }
774
-
775
- if (2 in locs) {
776
- entry.finallyLoc = locs[2];
777
- entry.afterLoc = locs[3];
778
- }
779
-
780
- this.tryEntries.push(entry);
781
- }
782
-
783
- function resetTryEntry(entry) {
784
- var record = entry.completion || {};
785
- record.type = "normal";
786
- delete record.arg;
787
- entry.completion = record;
788
- }
789
-
790
- function Context(tryLocsList) {
791
- // The root entry object (effectively a try statement without a catch
792
- // or a finally block) gives us a place to store values thrown from
793
- // locations where there is no enclosing try statement.
794
- this.tryEntries = [{
795
- tryLoc: "root"
796
- }];
797
- tryLocsList.forEach(pushTryEntry, this);
798
- this.reset(true);
799
- }
800
-
801
- exports.keys = function (object) {
802
- var keys = [];
803
-
804
- for (var key in object) {
805
- keys.push(key);
806
- }
807
-
808
- keys.reverse(); // Rather than returning an object with a next method, we keep
809
- // things simple and return the next function itself.
810
-
811
- return function next() {
812
- while (keys.length) {
813
- var key = keys.pop();
814
-
815
- if (key in object) {
816
- next.value = key;
817
- next.done = false;
818
- return next;
819
- }
820
- } // To avoid creating an additional object, we just hang the .value
821
- // and .done properties off the next function object itself. This
822
- // also ensures that the minifier will not anonymize the function.
823
-
824
-
825
- next.done = true;
826
- return next;
827
- };
828
- };
829
-
830
- function values(iterable) {
831
- if (iterable) {
832
- var iteratorMethod = iterable[iteratorSymbol];
833
-
834
- if (iteratorMethod) {
835
- return iteratorMethod.call(iterable);
836
- }
837
-
838
- if (typeof iterable.next === "function") {
839
- return iterable;
840
- }
841
-
842
- if (!isNaN(iterable.length)) {
843
- var i = -1,
844
- next = function next() {
845
- while (++i < iterable.length) {
846
- if (hasOwn.call(iterable, i)) {
847
- next.value = iterable[i];
848
- next.done = false;
849
- return next;
850
- }
851
- }
852
-
853
- next.value = undefined$1;
854
- next.done = true;
855
- return next;
856
- };
857
-
858
- return next.next = next;
859
- }
860
- } // Return an iterator with no values.
861
-
862
-
863
- return {
864
- next: doneResult
865
- };
866
- }
867
-
868
- exports.values = values;
869
-
870
- function doneResult() {
871
- return {
872
- value: undefined$1,
873
- done: true
874
- };
875
- }
876
-
877
- Context.prototype = {
878
- constructor: Context,
879
- reset: function reset(skipTempReset) {
880
- this.prev = 0;
881
- this.next = 0; // Resetting context._sent for legacy support of Babel's
882
- // function.sent implementation.
883
-
884
- this.sent = this._sent = undefined$1;
885
- this.done = false;
886
- this.delegate = null;
887
- this.method = "next";
888
- this.arg = undefined$1;
889
- this.tryEntries.forEach(resetTryEntry);
890
-
891
- if (!skipTempReset) {
892
- for (var name in this) {
893
- // Not sure about the optimal order of these conditions:
894
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
895
- this[name] = undefined$1;
896
- }
897
- }
898
- }
899
- },
900
- stop: function stop() {
901
- this.done = true;
902
- var rootEntry = this.tryEntries[0];
903
- var rootRecord = rootEntry.completion;
904
-
905
- if (rootRecord.type === "throw") {
906
- throw rootRecord.arg;
907
- }
908
-
909
- return this.rval;
910
- },
911
- dispatchException: function dispatchException(exception) {
912
- if (this.done) {
913
- throw exception;
914
- }
915
-
916
- var context = this;
917
-
918
- function handle(loc, caught) {
919
- record.type = "throw";
920
- record.arg = exception;
921
- context.next = loc;
922
-
923
- if (caught) {
924
- // If the dispatched exception was caught by a catch block,
925
- // then let that catch block handle the exception normally.
926
- context.method = "next";
927
- context.arg = undefined$1;
928
- }
929
-
930
- return !!caught;
931
- }
932
-
933
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
934
- var entry = this.tryEntries[i];
935
- var record = entry.completion;
936
-
937
- if (entry.tryLoc === "root") {
938
- // Exception thrown outside of any try block that could handle
939
- // it, so set the completion value of the entire function to
940
- // throw the exception.
941
- return handle("end");
942
- }
943
-
944
- if (entry.tryLoc <= this.prev) {
945
- var hasCatch = hasOwn.call(entry, "catchLoc");
946
- var hasFinally = hasOwn.call(entry, "finallyLoc");
947
-
948
- if (hasCatch && hasFinally) {
949
- if (this.prev < entry.catchLoc) {
950
- return handle(entry.catchLoc, true);
951
- } else if (this.prev < entry.finallyLoc) {
952
- return handle(entry.finallyLoc);
953
- }
954
- } else if (hasCatch) {
955
- if (this.prev < entry.catchLoc) {
956
- return handle(entry.catchLoc, true);
957
- }
958
- } else if (hasFinally) {
959
- if (this.prev < entry.finallyLoc) {
960
- return handle(entry.finallyLoc);
961
- }
962
- } else {
963
- throw new Error("try statement without catch or finally");
964
- }
965
- }
966
- }
967
- },
968
- abrupt: function abrupt(type, arg) {
969
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
970
- var entry = this.tryEntries[i];
971
-
972
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
973
- var finallyEntry = entry;
974
- break;
975
- }
976
- }
977
-
978
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
979
- // Ignore the finally entry if control is not jumping to a
980
- // location outside the try/catch block.
981
- finallyEntry = null;
982
- }
983
-
984
- var record = finallyEntry ? finallyEntry.completion : {};
985
- record.type = type;
986
- record.arg = arg;
987
-
988
- if (finallyEntry) {
989
- this.method = "next";
990
- this.next = finallyEntry.finallyLoc;
991
- return ContinueSentinel;
992
- }
993
-
994
- return this.complete(record);
995
- },
996
- complete: function complete(record, afterLoc) {
997
- if (record.type === "throw") {
998
- throw record.arg;
999
- }
1000
-
1001
- if (record.type === "break" || record.type === "continue") {
1002
- this.next = record.arg;
1003
- } else if (record.type === "return") {
1004
- this.rval = this.arg = record.arg;
1005
- this.method = "return";
1006
- this.next = "end";
1007
- } else if (record.type === "normal" && afterLoc) {
1008
- this.next = afterLoc;
1009
- }
1010
-
1011
- return ContinueSentinel;
1012
- },
1013
- finish: function finish(finallyLoc) {
1014
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1015
- var entry = this.tryEntries[i];
1016
-
1017
- if (entry.finallyLoc === finallyLoc) {
1018
- this.complete(entry.completion, entry.afterLoc);
1019
- resetTryEntry(entry);
1020
- return ContinueSentinel;
1021
- }
1022
- }
1023
- },
1024
- "catch": function _catch(tryLoc) {
1025
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1026
- var entry = this.tryEntries[i];
1027
-
1028
- if (entry.tryLoc === tryLoc) {
1029
- var record = entry.completion;
1030
-
1031
- if (record.type === "throw") {
1032
- var thrown = record.arg;
1033
- resetTryEntry(entry);
1034
- }
1035
-
1036
- return thrown;
1037
- }
1038
- } // The context.catch method must only be called with a location
1039
- // argument that corresponds to a known catch block.
1040
-
1041
-
1042
- throw new Error("illegal catch attempt");
1043
- },
1044
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1045
- this.delegate = {
1046
- iterator: values(iterable),
1047
- resultName: resultName,
1048
- nextLoc: nextLoc
1049
- };
1050
-
1051
- if (this.method === "next") {
1052
- // Deliberately forget the last sent value so that we don't
1053
- // accidentally pass it on to the delegate.
1054
- this.arg = undefined$1;
1055
- }
1056
-
1057
- return ContinueSentinel;
1058
- }
1059
- }; // Regardless of whether this script is executing as a CommonJS module
1060
- // or not, return the runtime object so that we can declare the variable
1061
- // regeneratorRuntime in the outer scope, which allows this module to be
1062
- // injected easily by `bin/regenerator --include-runtime script.js`.
1063
-
1064
- return exports;
1065
- }( // If this script is executing as a CommonJS module, use module.exports
1066
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1067
- // object. Either way, the resulting object will be used to initialize
1068
- // the regeneratorRuntime variable at the top of this file.
1069
- module.exports );
1070
-
1071
- try {
1072
- regeneratorRuntime = runtime;
1073
- } catch (accidentalStrictMode) {
1074
- // This module should not be running in strict mode, so the above
1075
- // assignment should always work unless something is misconfigured. Just
1076
- // in case runtime.js accidentally runs in strict mode, in modern engines
1077
- // we can explicitly access globalThis. In older engines we can escape
1078
- // strict mode using a global Function call. This could conceivably fail
1079
- // if a Content Security Policy forbids using Function, but in that case
1080
- // the proper solution is to fix the accidental strict mode problem. If
1081
- // you've misconfigured your bundler to force strict mode and applied a
1082
- // CSP to forbid Function, and you're not willing to fix either of those
1083
- // problems, please detail your unique predicament in a GitHub issue.
1084
- if (typeof globalThis === "object") {
1085
- globalThis.regeneratorRuntime = runtime;
1086
- } else {
1087
- Function("r", "regeneratorRuntime = r")(runtime);
1088
- }
1089
- }
1090
- });
1091
-
1092
- var HttpMap = /*#__PURE__*/function () {
1093
- function HttpMap(args) {
1094
- _classCallCheck(this, HttpMap);
1095
-
1096
- // make sure url has a trailing slash
1097
- this.url = /\/$/.test(args.url) ? args.url : "".concat(args.url, "/");
1098
- }
1099
- /**
1100
- * loads meta.json file from names directory and reads number of hash_bits used
1101
- */
1102
-
1103
-
1104
- _createClass(HttpMap, [{
1105
- key: "readMeta",
1106
- value: function () {
1107
- var _readMeta = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1108
- var meta, compress, tracks, hashHexCharacters;
1109
- return runtime_1.wrap(function _callee$(_context) {
1110
- while (1) {
1111
- switch (_context.prev = _context.next) {
1112
- case 0:
1113
- _context.next = 2;
1114
- return this.loadFile('meta.json');
1115
-
1116
- case 2:
1117
- meta = _context.sent;
1118
- compress = meta.compress, tracks = meta.track_names;
1119
- hashHexCharacters = Math.ceil(meta.hash_bits / 4);
1120
- return _context.abrupt("return", {
1121
- hashHexCharacters: hashHexCharacters,
1122
- compress: compress,
1123
- tracks: tracks
1124
- });
1125
-
1126
- case 6:
1127
- case "end":
1128
- return _context.stop();
1129
- }
1130
- }
1131
- }, _callee, this);
1132
- }));
1133
-
1134
- function readMeta() {
1135
- return _readMeta.apply(this, arguments);
1136
- }
1137
-
1138
- return readMeta;
1139
- }()
1140
- }, {
1141
- key: "getHashHexCharacters",
1142
- value: function () {
1143
- var _getHashHexCharacters = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1144
- var meta;
1145
- return runtime_1.wrap(function _callee2$(_context2) {
1146
- while (1) {
1147
- switch (_context2.prev = _context2.next) {
1148
- case 0:
1149
- _context2.next = 2;
1150
- return this.readMeta();
1151
-
1152
- case 2:
1153
- meta = _context2.sent;
1154
- return _context2.abrupt("return", meta.hashHexCharacters);
1155
-
1156
- case 4:
1157
- case "end":
1158
- return _context2.stop();
1159
- }
1160
- }
1161
- }, _callee2, this);
1162
- }));
1163
-
1164
- function getHashHexCharacters() {
1165
- return _getHashHexCharacters.apply(this, arguments);
1166
- }
1167
-
1168
- return getHashHexCharacters;
1169
- }()
1170
- }, {
1171
- key: "getCompress",
1172
- value: function () {
1173
- var _getCompress = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
1174
- var meta;
1175
- return runtime_1.wrap(function _callee3$(_context3) {
1176
- while (1) {
1177
- switch (_context3.prev = _context3.next) {
1178
- case 0:
1179
- _context3.next = 2;
1180
- return this.readMeta();
1181
-
1182
- case 2:
1183
- meta = _context3.sent;
1184
- return _context3.abrupt("return", meta.compress);
1185
-
1186
- case 4:
1187
- case "end":
1188
- return _context3.stop();
1189
- }
1190
- }
1191
- }, _callee3, this);
1192
- }));
1193
-
1194
- function getCompress() {
1195
- return _getCompress.apply(this, arguments);
1196
- }
1197
-
1198
- return getCompress;
1199
- }()
1200
- }, {
1201
- key: "getTrackNames",
1202
- value: function () {
1203
- var _getTrackNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
1204
- var meta;
1205
- return runtime_1.wrap(function _callee4$(_context4) {
1206
- while (1) {
1207
- switch (_context4.prev = _context4.next) {
1208
- case 0:
1209
- _context4.next = 2;
1210
- return this.readMeta();
1211
-
1212
- case 2:
1213
- meta = _context4.sent;
1214
- return _context4.abrupt("return", meta.tracks);
1215
-
1216
- case 4:
1217
- case "end":
1218
- return _context4.stop();
1219
- }
1220
- }
1221
- }, _callee4, this);
1222
- }));
1223
-
1224
- function getTrackNames() {
1225
- return _getTrackNames.apply(this, arguments);
1226
- }
1227
-
1228
- return getTrackNames;
1229
- }()
1230
- /**
1231
- * Returns contents of a bucket given a key
1232
- * @param key - string
1233
- */
1234
-
1235
- }, {
1236
- key: "get",
1237
- value: function () {
1238
- var _get = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(key) {
1239
- var bucket;
1240
- return runtime_1.wrap(function _callee5$(_context5) {
1241
- while (1) {
1242
- switch (_context5.prev = _context5.next) {
1243
- case 0:
1244
- _context5.next = 2;
1245
- return this.getBucket(key);
1246
-
1247
- case 2:
1248
- bucket = _context5.sent;
1249
- return _context5.abrupt("return", bucket[key]);
1250
-
1251
- case 4:
1252
- case "end":
1253
- return _context5.stop();
1254
- }
1255
- }
1256
- }, _callee5, this);
1257
- }));
1258
-
1259
- function get(_x) {
1260
- return _get.apply(this, arguments);
1261
- }
1262
-
1263
- return get;
1264
- }()
1265
- /**
1266
- * Returns a bucket given a key
1267
- * @param key - string
1268
- */
1269
-
1270
- }, {
1271
- key: "getBucket",
1272
- value: function () {
1273
- var _getBucket = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(key) {
1274
- var bucketIdent, hexToDirPath;
1275
- return runtime_1.wrap(function _callee6$(_context6) {
1276
- while (1) {
1277
- switch (_context6.prev = _context6.next) {
1278
- case 0:
1279
- bucketIdent = this.hash(key);
1280
- _context6.next = 3;
1281
- return this.hexToDirPath(bucketIdent);
1282
-
1283
- case 3:
1284
- hexToDirPath = _context6.sent;
1285
- return _context6.abrupt("return", this.loadFile(hexToDirPath));
1286
-
1287
- case 5:
1288
- case "end":
1289
- return _context6.stop();
1290
- }
1291
- }
1292
- }, _callee6, this);
1293
- }));
1294
-
1295
- function getBucket(_x2) {
1296
- return _getBucket.apply(this, arguments);
1297
- }
1298
-
1299
- return getBucket;
1300
- }()
1301
- /**
1302
- * Loads a file using the url and provided id.
1303
- * Returns response object with contents of the file
1304
- * @param id - string
1305
- */
1306
-
1307
- }, {
1308
- key: "loadFile",
1309
- value: function () {
1310
- var _loadFile = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(id) {
1311
- var response;
1312
- return runtime_1.wrap(function _callee7$(_context7) {
1313
- while (1) {
1314
- switch (_context7.prev = _context7.next) {
1315
- case 0:
1316
- _context7.next = 2;
1317
- return fetch("".concat(this.url).concat(id));
1318
-
1319
- case 2:
1320
- response = _context7.sent;
1321
-
1322
- if (response.ok) {
1323
- _context7.next = 5;
1324
- break;
1325
- }
1326
-
1327
- throw new Error("HTTP ".concat(response.status, " ").concat(response.statusText));
1328
-
1329
- case 5:
1330
- return _context7.abrupt("return", response.json());
1331
-
1332
- case 6:
1333
- case "end":
1334
- return _context7.stop();
1335
- }
1336
- }
1337
- }, _callee7, this);
1338
- }));
1339
-
1340
- function loadFile(_x3) {
1341
- return _loadFile.apply(this, arguments);
1342
- }
1343
-
1344
- return loadFile;
1345
- }()
1346
- /**
1347
- * Returns the corresponding path of the file given a hex string
1348
- * @param hex - hex string
1349
- */
1350
-
1351
- }, {
1352
- key: "hexToDirPath",
1353
- value: function () {
1354
- var _hexToDirPath = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8(hex) {
1355
- var hashHexCharacters, compress, dirpath, i;
1356
- return runtime_1.wrap(function _callee8$(_context8) {
1357
- while (1) {
1358
- switch (_context8.prev = _context8.next) {
1359
- case 0:
1360
- _context8.next = 2;
1361
- return this.getHashHexCharacters();
1362
-
1363
- case 2:
1364
- hashHexCharacters = _context8.sent;
1365
-
1366
- if (!hashHexCharacters) {
1367
- _context8.next = 12;
1368
- break;
1369
- }
1370
-
1371
- _context8.next = 6;
1372
- return this.getCompress();
1373
-
1374
- case 6:
1375
- compress = _context8.sent;
1376
-
1377
- while (hex.length < 8) {
1378
- hex = "0".concat(hex);
1379
- }
1380
-
1381
- hex = hex.substr(8 - hashHexCharacters);
1382
- dirpath = [];
1383
-
1384
- for (i = 0; i < hex.length; i += 3) {
1385
- dirpath.push(hex.substring(i, i + 3));
1386
- }
1387
-
1388
- return _context8.abrupt("return", "".concat(dirpath.join('/'), ".json").concat(compress ? 'z' : ''));
1389
-
1390
- case 12:
1391
- return _context8.abrupt("return", '');
1392
-
1393
- case 13:
1394
- case "end":
1395
- return _context8.stop();
1396
- }
1397
- }
1398
- }, _callee8, this);
1399
- }));
1400
-
1401
- function hexToDirPath(_x4) {
1402
- return _hexToDirPath.apply(this, arguments);
1403
- }
1404
-
1405
- return hexToDirPath;
1406
- }()
1407
- }, {
1408
- key: "hash",
1409
- value: function hash(data) {
1410
- return crc32(Buffer.from(data)).toString('hex').toLowerCase().replace('-', 'n');
1411
- }
1412
- }]);
1413
-
1414
- return HttpMap;
1415
- }();
1416
-
1417
- // Uses index built by generate-names.pl
1418
-
1419
- var JBrowse1TextSearchAdapter = /*#__PURE__*/function (_BaseAdapter) {
1420
- _inherits(JBrowse1TextSearchAdapter, _BaseAdapter);
1421
-
1422
- var _super = /*#__PURE__*/_createSuper(JBrowse1TextSearchAdapter);
1423
-
1424
- function JBrowse1TextSearchAdapter(config, getSubAdapter, pluginManager) {
1425
- var _this;
1426
-
1427
- _classCallCheck(this, JBrowse1TextSearchAdapter);
1428
-
1429
- _this = _super.call(this, config, getSubAdapter, pluginManager);
1430
- var namesIndexLocation = configuration.readConfObject(config, 'namesIndexLocation');
1431
-
1432
- if (!namesIndexLocation) {
1433
- throw new Error('must provide namesIndexLocation');
1434
- }
1435
-
1436
- _this.httpMap = new HttpMap({
1437
- url: namesIndexLocation.baseUri ? new URL(namesIndexLocation.uri, namesIndexLocation.baseUri).href : namesIndexLocation.uri
1438
- });
1439
- return _this;
1440
- }
1441
- /**
1442
- * Returns the contents of the file containing the query if it exists
1443
- * else it returns empty
1444
- * @param query - string query
1445
- */
1446
-
1447
-
1448
- _createClass(JBrowse1TextSearchAdapter, [{
1449
- key: "loadIndexFile",
1450
- value: function () {
1451
- var _loadIndexFile = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(query) {
1452
- return runtime_1.wrap(function _callee$(_context) {
1453
- while (1) {
1454
- switch (_context.prev = _context.next) {
1455
- case 0:
1456
- return _context.abrupt("return", this.httpMap.getBucket(query));
1457
-
1458
- case 1:
1459
- case "end":
1460
- return _context.stop();
1461
- }
1462
- }
1463
- }, _callee, this);
1464
- }));
1465
-
1466
- function loadIndexFile(_x) {
1467
- return _loadIndexFile.apply(this, arguments);
1468
- }
1469
-
1470
- return loadIndexFile;
1471
- }()
1472
- }, {
1473
- key: "searchIndex",
1474
- value: function () {
1475
- var _searchIndex = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(args) {
1476
- var searchType, queryString, tracks, entries;
1477
- return runtime_1.wrap(function _callee2$(_context2) {
1478
- while (1) {
1479
- switch (_context2.prev = _context2.next) {
1480
- case 0:
1481
- searchType = args.searchType, queryString = args.queryString;
1482
- _context2.t0 = this.tracksNames;
1483
-
1484
- if (_context2.t0) {
1485
- _context2.next = 6;
1486
- break;
1487
- }
1488
-
1489
- _context2.next = 5;
1490
- return this.httpMap.getTrackNames();
1491
-
1492
- case 5:
1493
- _context2.t0 = _context2.sent;
1494
-
1495
- case 6:
1496
- tracks = _context2.t0;
1497
- _context2.next = 9;
1498
- return this.loadIndexFile(queryString.toLowerCase());
1499
-
1500
- case 9:
1501
- entries = _context2.sent;
1502
-
1503
- if (!entries[queryString]) {
1504
- _context2.next = 12;
1505
- break;
1506
- }
1507
-
1508
- return _context2.abrupt("return", this.formatResults(entries[queryString], tracks, searchType));
1509
-
1510
- case 12:
1511
- return _context2.abrupt("return", []);
1512
-
1513
- case 13:
1514
- case "end":
1515
- return _context2.stop();
1516
- }
1517
- }
1518
- }, _callee2, this);
1519
- }));
1520
-
1521
- function searchIndex(_x2) {
1522
- return _searchIndex.apply(this, arguments);
1523
- }
1524
-
1525
- return searchIndex;
1526
- }()
1527
- }, {
1528
- key: "formatResults",
1529
- value: function formatResults(results, tracks, searchType) {
1530
- return [].concat(_toConsumableArray(searchType === 'exact' ? [] : results.prefix.map(function (result) {
1531
- return new BaseResult({
1532
- label: _typeof(result) === 'object' ? result.name : result,
1533
- matchedAttribute: 'name',
1534
- matchedObject: {
1535
- result: result
1536
- }
1537
- });
1538
- })), _toConsumableArray(results.exact.map(function (result) {
1539
- var name = result[0];
1540
- var trackIndex = result[1];
1541
- var refName = result[3];
1542
- var start = result[4];
1543
- var end = result[5];
1544
- var locstring = "".concat(refName || name, ":").concat(start, "-").concat(end);
1545
- return new BaseResult({
1546
- locString: locstring,
1547
- label: name,
1548
- matchedAttribute: 'name',
1549
- matchedObject: result,
1550
- trackId: tracks[trackIndex]
1551
- });
1552
- }))).filter(function (result) {
1553
- return result.getLabel() !== 'too many matches';
1554
- });
1555
- }
1556
- }, {
1557
- key: "freeResources",
1558
- value: function freeResources() {}
1559
- }]);
1560
-
1561
- return JBrowse1TextSearchAdapter;
1562
- }(BaseAdapter.BaseAdapter);
1563
-
1564
- var jbrowse1AdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('JBrowse1TextSearchAdapter', {
1565
- // metadata about tracks and assemblies covered by text search adapter
1566
- namesIndexLocation: {
1567
- type: 'fileLocation',
1568
- defaultValue: {
1569
- uri: '/volvox/names',
1570
- locationType: 'UriLocation'
1571
- },
1572
- description: 'the location of the JBrowse1 names index data directory'
1573
- },
1574
- tracks: {
1575
- type: 'stringArray',
1576
- defaultValue: [],
1577
- description: 'List of tracks covered by text search adapter'
1578
- },
1579
- assemblyNames: {
1580
- type: 'stringArray',
1581
- defaultValue: [],
1582
- description: 'List of assemblies covered by text search adapter'
1583
- }
1584
- }, {
1585
- explicitlyTyped: true,
1586
- explicitIdentifier: 'textSearchAdapterId'
1587
- });
1588
-
1589
- var jbrowse1ConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('JBrowse1Connection', {
1590
- dataDirLocation: {
1591
- type: 'fileLocation',
1592
- defaultValue: {
1593
- uri: 'http://mysite.com/jbrowse/data/',
1594
- locationType: 'UriLocation'
1595
- },
1596
- description: 'the location of the JBrowse 1 data directory, often something like http://mysite.com/jbrowse/data/'
1597
- },
1598
- assemblyNames: {
1599
- description: 'name of the assembly the connection belongs to, should be a single entry',
1600
- type: 'stringArray',
1601
- defaultValue: []
1602
- }
1603
- }, {
1604
- baseConfiguration: models.baseConnectionConfig
1605
- });
1606
-
1607
- function isTrack(arg) {
1608
- return arg && arg.label && typeof arg.label === 'string';
1609
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
1610
-
1611
- function isSource(arg) {
1612
- return arg && arg.url && typeof arg.url === 'string';
1613
- }
1614
- function deepUpdate(a, b) {
1615
- for (var _i = 0, _Object$keys = Object.keys(b); _i < _Object$keys.length; _i++) {
1616
- var prop = _Object$keys[_i];
1617
-
1618
- if (prop in a && _typeof(b[prop]) === 'object' && _typeof(a[prop]) === 'object') {
1619
- deepUpdate(a[prop], b[prop]);
1620
- } else if (typeof a[prop] === 'undefined' || typeof b[prop] !== 'undefined') {
1621
- a[prop] = b[prop];
1622
- }
1623
- }
1624
-
1625
- return a;
1626
- }
1627
- /**
1628
- * replace variables in a template string with values
1629
- * @param template - String with variable names in curly brackets
1630
- * e.g., `http://foo/{bar}?arg={baz.foo}`
1631
- * @param fillWith - object with attribute-value mappings
1632
- * e.g., `{ 'bar': 'someurl', 'baz': { 'foo': 42 } }`
1633
- * @returns the template string with variables in fillWith replaced
1634
- * e.g., 'htp://foo/someurl?arg=valueforbaz'
1635
- */
1636
-
1637
- function fillTemplate(template, fillWith) {
1638
- var _this = this;
1639
-
1640
- return template.replace(/\{([\w\s.]+)\}/g, function (match, varName) {
1641
- varName = varName.replace(/\s+/g, ''); // remove all whitespace
1642
-
1643
- var fill = getValue(fillWith, varName);
1644
-
1645
- if (fill !== undefined) {
1646
- if (typeof fill === 'function') {
1647
- return fill(varName);
1648
- }
1649
-
1650
- return fill;
1651
- }
1652
-
1653
- if (fillWith.callback) {
1654
- // @ts-ignore
1655
- var v = fillWith.callback.call(_this, varName);
1656
-
1657
- if (v !== undefined) {
1658
- return v;
1659
- }
1660
- }
1661
-
1662
- return match;
1663
- });
1664
- }
1665
- /**
1666
- * Clones objects (including DOM nodes) and all children.
1667
- * Warning: do not clone cyclic structures
1668
- * (Lifted from dojo https://github.com/dojo/dojo/blob/master/_base/lang.js)
1669
- * @param src - The object to clone
1670
- */
1671
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1672
-
1673
- function clone(src) {
1674
- if (!src || _typeof(src) !== 'object' || Object.prototype.toString.call(src) === '[object Function]') {
1675
- // null, undefined, any non-object, or function
1676
- return src; // anything
1677
- }
1678
-
1679
- if (src.nodeType && 'cloneNode' in src) {
1680
- // DOM Node
1681
- return src.cloneNode(true); // Node
1682
- }
1683
-
1684
- if (src instanceof Date) {
1685
- // Date
1686
- return new Date(src.getTime()); // Date
1687
- }
1688
-
1689
- if (src instanceof RegExp) {
1690
- // RegExp
1691
- return new RegExp(src); // RegExp
1692
- }
1693
-
1694
- var r;
1695
- var i;
1696
- var l;
1697
-
1698
- if (Array.isArray(src)) {
1699
- // array
1700
- r = [];
1701
-
1702
- for (i = 0, l = src.length; i < l; ++i) {
1703
- if (i in src) {
1704
- r[i] = clone(src[i]);
1705
- }
1706
- } // we don't clone functions for performance reasons
1707
- // }else if(d.isFunction(src)){
1708
- // // function
1709
- // r = function(){ return src.apply(this, arguments); };
1710
-
1711
- } else {
1712
- // generic objects
1713
- r = src.constructor ? new src.constructor() : {};
1714
- }
1715
-
1716
- return mixin(r, src, clone);
1717
- }
1718
- /**
1719
- * Copies/adds all properties of source to dest; returns dest.
1720
- * (Lifted from dojo https://github.com/dojo/dojo/blob/master/_base/lang.js)
1721
- *
1722
- * All properties, including functions (sometimes termed "methods"), excluding
1723
- * any non-standard extensions found in Object.prototype, are copied/added to
1724
- * dest. Copying/adding each particular property is delegated to copyFunc
1725
- * (if any); copyFunc defaults to the Javascript assignment operator if not
1726
- * provided. Notice that by default, mixin executes a so-called "shallow copy"
1727
- * and aggregate types are copied/added by reference.
1728
- * @param dest - The object to which to copy/add all properties contained in
1729
- * source.
1730
- * @param source - The object from which to draw all properties to copy into dest.
1731
- * @param copyFunc - The process used to copy/add a property in source; defaults
1732
- * to the Javascript assignment operator.
1733
- * @returns dest, as modified
1734
- */
1735
-
1736
- function mixin(dest, source, copyFunc) {
1737
- var name;
1738
- var s;
1739
- var empty = {};
1740
-
1741
- for (name in source) {
1742
- // the (!(name in empty) || empty[name] !== s) condition avoids copying
1743
- // properties in "source" inherited from Object.prototype. For example,
1744
- // if dest has a custom toString() method, don't overwrite it with the
1745
- // toString() method that source inherited from Object.prototype
1746
- s = source[name];
1747
-
1748
- if (!(name in dest) || // @ts-ignore
1749
- dest[name] !== s && (!(name in empty) || empty[name] !== s)) {
1750
- dest[name] = copyFunc ? copyFunc(s) : s;
1751
- }
1752
- }
1753
-
1754
- return dest; // Object
1755
- }
1756
-
1757
- function parseJB1Json(config, url) {
1758
- if (typeof config === 'string') {
1759
- var parsedConf;
1760
-
1761
- try {
1762
- parsedConf = JSON.parse(config);
1763
- } catch (error) {
1764
- throw new Error("".concat(error, " when parsing configuration."));
1765
- }
1766
-
1767
- return regularizeConf(parsedConf, url);
1768
- }
1769
-
1770
- return regularizeConf(config, url);
1771
- }
1772
- function parseJB1Conf(config, url) {
1773
- var parsedConf;
1774
-
1775
- try {
1776
- parsedConf = parse(config, url);
1777
- } catch (error) {
1778
- throw new Error("".concat(error, " when parsing configuration."));
1779
- }
1780
-
1781
- return regularizeConf(parsedConf, url);
1782
- }
1783
-
1784
- function isAlwaysArray(varName) {
1785
- if (varName === 'include') {
1786
- return true;
1787
- }
1788
-
1789
- return false;
1790
- }
1791
-
1792
- function parse(text, url) {
1793
- var section = [];
1794
- var keyPath;
1795
- var operation;
1796
- var value;
1797
- var data = {
1798
- tracks: {}
1799
- };
1800
- var lineNumber;
1801
-
1802
- function recordVal() {
1803
- if (value !== undefined) {
1804
- var parsedValue;
1805
-
1806
- try {
1807
- // parse json
1808
- var match = value.match(/^json:(.+)/i);
1809
-
1810
- if (match) {
1811
- parsedValue = JSON.parse(match[1]);
1812
- } // parse numbers if it looks numeric
1813
- else if (/^[+-]?[\d.,]+([eE][-+]?\d+)?$/.test(value)) {
1814
- parsedValue = parseFloat(value.replace(/,/g, ''));
1815
- } else {
1816
- parsedValue = value;
1817
- }
1818
-
1819
- if (!keyPath) {
1820
- throw new Error("Error parsing in section ".concat(section.join(' - ')));
1821
- }
1822
-
1823
- var path = section.concat(keyPath).join('.');
1824
-
1825
- if (operation === '+=') {
1826
- var existing = getValue(data, path);
1827
-
1828
- if (existing) {
1829
- if (!Array.isArray(existing)) {
1830
- existing = [existing];
1831
- }
1832
- } else {
1833
- existing = [];
1834
- }
1835
-
1836
- existing.push(parsedValue);
1837
- parsedValue = existing;
1838
- }
1839
-
1840
- if (parsedValue === 'true') {
1841
- parsedValue = true;
1842
- }
1843
-
1844
- if (parsedValue === 'false') {
1845
- parsedValue = false;
1846
- }
1847
-
1848
- setValue(data, path, parsedValue);
1849
- } catch (e) {
1850
- throw new Error("syntax error".concat(url ? " in ".concat(url) : '').concat(lineNumber ? " at line ".concat(lineNumber - 1) : ''));
1851
- }
1852
- }
1853
- }
1854
-
1855
- text.split('\n').forEach(function (textLine, i) {
1856
- lineNumber = i + 1;
1857
- var line = textLine.replace(/^\s*#.+/, ''); // new section
1858
-
1859
- var match;
1860
-
1861
- if (match = line.match(/^\s*\[([^\]]+)/)) {
1862
- // new section
1863
- recordVal();
1864
- keyPath = undefined;
1865
- value = undefined;
1866
- section = match[1].trim().split(/\s*\.\s*/);
1867
-
1868
- if (section.length === 1 && section[0].toLowerCase() === 'general') {
1869
- section = [];
1870
- }
1871
- } // new value
1872
- else if (match = line.match(value === undefined ? /^([^+=]+)(\+?=)(.*)/ : /^(\S[^+=]+)(\+?=)(.*)/)) {
1873
- recordVal();
1874
- keyPath = match[1].trim().split(/\s*\.\s*/);
1875
- var _match = match;
1876
-
1877
- var _match2 = _slicedToArray(_match, 3);
1878
-
1879
- operation = _match2[2];
1880
-
1881
- if (isAlwaysArray(section.concat(keyPath).join('.'))) {
1882
- operation = '+=';
1883
- }
1884
-
1885
- value = match[3].trim();
1886
- } // add to existing array value
1887
- else if (keyPath !== undefined && (match = line.match(/^\s{0,4}\+\s*(.+)/))) {
1888
- recordVal();
1889
- operation = '+=';
1890
- value = match[1].trim();
1891
- } // add to existing value
1892
- else if (value !== undefined && (match = line.match(/^\s+(\S.*)/))) {
1893
- value += value.length ? " ".concat(match[1].trim()) : match[1].trim();
1894
- } // done with last value
1895
- else {
1896
- recordVal();
1897
- keyPath = undefined;
1898
- value = undefined;
1899
- }
1900
- });
1901
- recordVal();
1902
- return data;
1903
- }
1904
- /**
1905
- * Applies defaults and any other necessary tweaks to the loaded configuration.
1906
- * @param conf - the object containing the configuration, which it modifies
1907
- * in-place
1908
- * @param url - URL of the config file
1909
- * @returns the same object it was passed
1910
- */
1911
-
1912
-
1913
- function regularizeConf(conf, url) {
1914
- // if tracks is not an array, convert it to one
1915
- if (conf.tracks && !Array.isArray(conf.tracks)) {
1916
- // if it's a single track config, wrap it in an arrayref
1917
- if (isTrack(conf.tracks)) {
1918
- conf.tracks = [conf.tracks];
1919
- } // otherwise, coerce it to an array
1920
- else {
1921
- var tracks = [];
1922
-
1923
- for (var _i = 0, _Object$keys = Object.keys(conf.tracks); _i < _Object$keys.length; _i++) {
1924
- var label = _Object$keys[_i];
1925
- var track = conf.tracks[label];
1926
-
1927
- if (isTrack(track)) {
1928
- tracks.push(track);
1929
- } else {
1930
- tracks.push(_objectSpread2({
1931
- label: label
1932
- }, track));
1933
- }
1934
- }
1935
-
1936
- conf.tracks = tracks;
1937
- }
1938
- } // regularize trackMetadata.sources
1939
-
1940
-
1941
- var meta = conf.trackMetadata;
1942
-
1943
- if (meta && meta.sources) {
1944
- // if it's a single source config, wrap it in an arrayref
1945
- if (typeof meta.sources === 'string') {
1946
- meta.sources = [meta.sources];
1947
- }
1948
-
1949
- if (isSource(meta.sources)) {
1950
- meta.sources = [meta.sources];
1951
- }
1952
-
1953
- if (!Array.isArray(meta.sources)) {
1954
- var sources = [];
1955
-
1956
- for (var _i2 = 0, _Object$keys2 = Object.keys(meta.sources); _i2 < _Object$keys2.length; _i2++) {
1957
- var name = _Object$keys2[_i2];
1958
- var source = meta.sources[name];
1959
-
1960
- if (!('name' in source)) {
1961
- source.name = name;
1962
- }
1963
-
1964
- sources.push(source);
1965
- }
1966
-
1967
- meta.sources = sources;
1968
- } // coerce any string source defs to be URLs, and try to detect their types
1969
-
1970
-
1971
- meta.sources = meta.sources.map(function (sourceDef) {
1972
- if (typeof sourceDef === 'string') {
1973
- var newSourceDef = {
1974
- url: sourceDef
1975
- };
1976
- var typeMatch = sourceDef.match(/\.(\w+)$/);
1977
-
1978
- if (typeMatch) {
1979
- newSourceDef.type = typeMatch[1].toLowerCase();
1980
- }
1981
-
1982
- return newSourceDef;
1983
- }
1984
-
1985
- return sourceDef;
1986
- });
1987
- }
1988
-
1989
- conf.sourceUrl = conf.sourceUrl || url;
1990
-
1991
- if (conf.sourceUrl.startsWith('/')) {
1992
- conf.sourceUrl = new URL(conf.sourceUrl, window.location.href).href;
1993
- }
1994
-
1995
- conf.baseUrl = conf.baseUrl || new URL('.', conf.sourceUrl).href;
1996
-
1997
- if (conf.baseUrl.length && !conf.baseUrl.endsWith('/')) {
1998
- conf.baseUrl += '/';
1999
- }
2000
-
2001
- if (conf.sourceUrl) {
2002
- // set a default baseUrl in each of the track and store confs, and the names
2003
- // conf, if needed
2004
- var addBase = [];
2005
-
2006
- if (conf.tracks) {
2007
- addBase.push.apply(addBase, _toConsumableArray(conf.tracks));
2008
- }
2009
-
2010
- if (conf.stores) {
2011
- addBase.push.apply(addBase, _toConsumableArray(Object.values(conf.stores)));
2012
- }
2013
-
2014
- if (conf.names) {
2015
- addBase.push(conf.names);
2016
- }
2017
-
2018
- addBase.forEach(function (t) {
2019
- if (!t.baseUrl) {
2020
- t.baseUrl = conf.baseUrl || '/';
2021
- }
2022
- }); // resolve the refSeqs and nameUrl if present
2023
-
2024
- if (conf.refSeqs && typeof conf.refSeqs === 'string') {
2025
- conf.refSeqs = new URL(conf.refSeqs, conf.sourceUrl).href;
2026
- }
2027
-
2028
- if (conf.nameUrl) {
2029
- conf.nameUrl = new URL(conf.nameUrl, conf.sourceUrl).href;
2030
- }
2031
- }
2032
-
2033
- conf.stores = conf.stores || {};
2034
- (conf.tracks || []).forEach(function (trackConfig) {
2035
- // if there is a `config` subpart, just copy its keys in to the top-level
2036
- // config
2037
- if (trackConfig.config) {
2038
- var c = trackConfig.config;
2039
- delete trackConfig.config;
2040
- trackConfig = _objectSpread2(_objectSpread2({}, c), trackConfig);
2041
- } // skip if it's a new-style track def
2042
-
2043
-
2044
- if (trackConfig.store) {
2045
- return;
2046
- }
2047
-
2048
- var trackClassName;
2049
-
2050
- if (trackConfig.type === 'FeatureTrack') {
2051
- trackClassName = 'JBrowse/View/Track/HTMLFeatures';
2052
- } else if (trackConfig.type === 'ImageTrack') {
2053
- trackClassName = 'JBrowse/View/Track/FixedImage';
2054
- } else if (trackConfig.type === 'ImageTrack.Wiggle') {
2055
- trackClassName = 'JBrowse/View/Track/FixedImage/Wiggle';
2056
- } else if (trackConfig.type === 'SequenceTrack') {
2057
- trackClassName = 'JBrowse/View/Track/Sequence';
2058
- } else {
2059
- trackClassName = regularizeClass('JBrowse/View/Track', trackConfig.type);
2060
- }
2061
-
2062
- trackConfig.type = trackClassName;
2063
- synthesizeTrackStoreConfig(conf, trackConfig);
2064
-
2065
- if (trackConfig.histograms) {
2066
- if (!trackConfig.histograms.baseUrl) {
2067
- trackConfig.histograms.baseUrl = trackConfig.baseUrl;
2068
- }
2069
-
2070
- synthesizeTrackStoreConfig(conf, trackConfig.histograms);
2071
- }
2072
- });
2073
- return conf;
2074
- }
2075
- /**
2076
- * prefix class name with `root` if it contains no slashes
2077
- * @param root - Prefix root
2078
- * @param className - class name
2079
- */
2080
-
2081
- function regularizeClass(root, className) {
2082
- if (!className) {
2083
- return '';
2084
- }
2085
-
2086
- if (!className.includes('/')) {
2087
- className = "".concat(root, "/").concat(className);
2088
- }
2089
-
2090
- className = className.replace(/^\//, '');
2091
- return className;
2092
- }
2093
-
2094
- function guessStoreClass(trackConfig, urlTemplate) {
2095
- if (!trackConfig) {
2096
- return '';
2097
- }
2098
-
2099
- if (trackConfig.type && trackConfig.type.includes('/FixedImage')) {
2100
- return "JBrowse/Store/TiledImage/Fixed".concat(trackConfig.backendVersion === 0 ? '_v0' : '');
2101
- }
2102
-
2103
- if (/\.jsonz?$/i.test(urlTemplate)) {
2104
- return "JBrowse/Store/SeqFeature/NCList".concat(trackConfig.backendVersion === 0 ? '_v0' : '');
2105
- }
2106
-
2107
- if (/\.bam$/i.test(urlTemplate)) {
2108
- return 'JBrowse/Store/SeqFeature/BAM';
2109
- }
2110
-
2111
- if (/\.cram$/i.test(urlTemplate)) {
2112
- return 'JBrowse/Store/SeqFeature/CRAM';
2113
- }
2114
-
2115
- if (/\.gff3?$/i.test(urlTemplate)) {
2116
- return 'JBrowse/Store/SeqFeature/GFF3';
2117
- }
2118
-
2119
- if (/\.bed$/i.test(urlTemplate)) {
2120
- return 'JBrowse/Store/SeqFeature/BED';
2121
- }
2122
-
2123
- if (/\.vcf.b?gz$/i.test(urlTemplate)) {
2124
- return 'JBrowse/Store/SeqFeature/VCFTabix';
2125
- }
2126
-
2127
- if (/\.gff3?.b?gz$/i.test(urlTemplate)) {
2128
- return 'JBrowse/Store/SeqFeature/GFF3Tabix';
2129
- }
2130
-
2131
- if (/\.bed.b?gz$/i.test(urlTemplate)) {
2132
- return 'JBrowse/Store/SeqFeature/BEDTabix';
2133
- }
2134
-
2135
- if (/\.(bw|bigwig)$/i.test(urlTemplate)) {
2136
- return 'JBrowse/Store/SeqFeature/BigWig';
2137
- }
2138
-
2139
- if (/\.(bb|bigbed)$/i.test(urlTemplate)) {
2140
- return 'JBrowse/Store/SeqFeature/BigBed';
2141
- }
2142
-
2143
- if (/\.(fa|fasta)$/i.test(urlTemplate)) {
2144
- return 'JBrowse/Store/SeqFeature/IndexedFasta';
2145
- }
2146
-
2147
- if (/\.(fa|fasta)\.b?gz$/i.test(urlTemplate)) {
2148
- return 'JBrowse/Store/SeqFeature/BgzipIndexedFasta';
2149
- }
2150
-
2151
- if (/\.2bit$/i.test(urlTemplate)) {
2152
- return 'JBrowse/Store/SeqFeature/TwoBit';
2153
- }
2154
-
2155
- if (trackConfig.type && trackConfig.type.endsWith('/Sequence')) {
2156
- return 'JBrowse/Store/Sequence/StaticChunked';
2157
- }
2158
-
2159
- return '';
2160
- }
2161
-
2162
- function synthesizeTrackStoreConfig(mainConf, trackConfig) {
2163
- // figure out what data store class to use with the track, applying some
2164
- // defaults if it is not explicit in the configuration
2165
- var _trackConfig$urlTempl = trackConfig.urlTemplate,
2166
- urlTemplate = _trackConfig$urlTempl === void 0 ? '' : _trackConfig$urlTempl;
2167
- var storeClass;
2168
-
2169
- if (trackConfig.storeClass) {
2170
- storeClass = regularizeClass('JBrowse/Store', trackConfig.storeClass);
2171
- } else {
2172
- storeClass = guessStoreClass(trackConfig, urlTemplate);
2173
- }
2174
-
2175
- if (!storeClass) {
2176
- console.warn("Unable to determine an appropriate data store to use with track '".concat(trackConfig.label, "', please explicitly specify a storeClass in the configuration."));
2177
- return;
2178
- } // synthesize a separate store conf
2179
-
2180
-
2181
- var storeConf = _objectSpread2(_objectSpread2({}, trackConfig), {}, {
2182
- type: storeClass
2183
- }); // if this is the first sequence store we see, and we have no refseqs store
2184
- // defined explicitly, make this the refseqs store.
2185
-
2186
-
2187
- if ((storeClass === 'JBrowse/Store/Sequence/StaticChunked' || storeClass === 'JBrowse/Store/Sequence/IndexedFasta' || storeClass === 'JBrowse/Store/SeqFeature/IndexedFasta' || storeClass === 'JBrowse/Store/SeqFeature/BgzipIndexedFasta' || storeClass === 'JBrowse/Store/SeqFeature/TwoBit' || storeClass === 'JBrowse/Store/Sequence/TwoBit' || trackConfig.useAsRefSeqStore) && !(mainConf.stores && mainConf.stores.refseqs)) {
2188
- storeConf.name = 'refseqs';
2189
- } else {
2190
- storeConf.name = "store".concat(util.objectHash(storeConf));
2191
- } // record it
2192
-
2193
-
2194
- if (!mainConf.stores) {
2195
- mainConf.stores = {};
2196
- }
2197
-
2198
- mainConf.stores[storeConf.name] = storeConf; // connect it to the track conf
2199
-
2200
- trackConfig.store = storeConf.name;
2201
- }
2202
-
2203
- function isUriLocation(location) {
2204
- return location.uri !== undefined;
2205
- }
2206
-
2207
- function isLocalPathLocation(location) {
2208
- return location.localPath !== undefined;
2209
- }
2210
-
2211
- function fetchJb1() {
2212
- return _fetchJb.apply(this, arguments);
2213
- }
2214
-
2215
- function _fetchJb() {
2216
- _fetchJb = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2217
- var dataRoot,
2218
- baseConfig,
2219
- baseConfigRoot,
2220
- protocol,
2221
- dataRootReg,
2222
- dataRootLocation,
2223
- baseProtocol,
2224
- baseConfigLocation,
2225
- _newConfig,
2226
- _i3,
2227
- _arr,
2228
- conf,
2229
- fetchedConfig,
2230
- newConfig,
2231
- _args = arguments;
2232
-
2233
- return runtime_1.wrap(function _callee$(_context) {
2234
- while (1) {
2235
- switch (_context.prev = _context.next) {
2236
- case 0:
2237
- dataRoot = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
2238
- uri: '',
2239
- locationType: 'UriLocation'
2240
- };
2241
- baseConfig = _args.length > 1 && _args[1] !== undefined ? _args[1] : {
2242
- include: ['{dataRoot}/trackList.json', '{dataRoot}/tracks.conf']
2243
- };
2244
- baseConfigRoot = _args.length > 2 && _args[2] !== undefined ? _args[2] : {
2245
- uri: '',
2246
- locationType: 'UriLocation'
2247
- };
2248
- protocol = 'uri' in dataRoot ? 'uri' : 'localPath';
2249
- dataRootReg = JSON.parse(JSON.stringify(dataRoot));
2250
- dataRootLocation = '';
2251
-
2252
- if (isUriLocation(dataRoot)) {
2253
- dataRootLocation = dataRoot.uri;
2254
- }
2255
-
2256
- if (isLocalPathLocation(dataRoot)) {
2257
- dataRootLocation = dataRoot.localPath;
2258
- }
2259
-
2260
- if (dataRootLocation.endsWith('/')) {
2261
- dataRootReg[protocol] = dataRootLocation.slice(0, dataRootLocation.length - 1);
2262
- }
2263
-
2264
- if (!(isUriLocation(baseConfigRoot) && baseConfigRoot.uri || isLocalPathLocation(baseConfigRoot) && baseConfigRoot.localPath)) {
2265
- _context.next = 35;
2266
- break;
2267
- }
2268
-
2269
- baseProtocol = 'uri' in baseConfigRoot ? 'uri' : 'localPath';
2270
- baseConfigLocation = '';
2271
-
2272
- if (isUriLocation(baseConfigRoot)) {
2273
- baseConfigLocation = baseConfigRoot.uri;
2274
- }
2275
-
2276
- if (isLocalPathLocation(baseConfigRoot)) {
2277
- baseConfigLocation = baseConfigRoot.localPath;
2278
- }
2279
-
2280
- if (baseConfigLocation.endsWith('/')) {
2281
- baseConfigLocation = baseConfigLocation.slice(0, baseConfigLocation.length - 1);
2282
- }
2283
-
2284
- _newConfig = {};
2285
- _i3 = 0, _arr = ['jbrowse.conf', 'jbrowse_conf.json'];
2286
-
2287
- case 17:
2288
- if (!(_i3 < _arr.length)) {
2289
- _context.next = 33;
2290
- break;
2291
- }
2292
-
2293
- conf = _arr[_i3];
2294
- fetchedConfig = null;
2295
- _context.prev = 20;
2296
- _context.next = 23;
2297
- return fetchConfigFile(_defineProperty({}, baseProtocol, "".concat(baseConfigLocation, "/").concat(conf)));
2298
-
2299
- case 23:
2300
- fetchedConfig = _context.sent;
2301
- _context.next = 29;
2302
- break;
2303
-
2304
- case 26:
2305
- _context.prev = 26;
2306
- _context.t0 = _context["catch"](20);
2307
- console.error("tried to access ".concat(baseConfigLocation, "/").concat(conf, ", but failed"));
2308
-
2309
- case 29:
2310
- _newConfig = mergeConfigs(_newConfig, fetchedConfig) || {};
2311
-
2312
- case 30:
2313
- _i3++;
2314
- _context.next = 17;
2315
- break;
2316
-
2317
- case 33:
2318
- if (dataRootReg[protocol]) {
2319
- _newConfig.dataRoot = dataRootReg[protocol];
2320
- }
2321
-
2322
- return _context.abrupt("return", createFinalConfig(_newConfig));
2323
-
2324
- case 35:
2325
- newConfig = regularizeConf(baseConfig, window.location.href);
2326
-
2327
- if (dataRootReg[protocol]) {
2328
- newConfig.dataRoot = dataRootReg[protocol];
2329
- }
2330
-
2331
- return _context.abrupt("return", createFinalConfig(newConfig));
2332
-
2333
- case 38:
2334
- case "end":
2335
- return _context.stop();
2336
- }
2337
- }
2338
- }, _callee, null, [[20, 26]]);
2339
- }));
2340
- return _fetchJb.apply(this, arguments);
2341
- }
2342
-
2343
- function createFinalConfig(_x) {
2344
- return _createFinalConfig.apply(this, arguments);
2345
- }
2346
-
2347
- function _createFinalConfig() {
2348
- _createFinalConfig = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(baseConfig) {
2349
- var defaults,
2350
- configWithDefaults,
2351
- finalConfig,
2352
- _args2 = arguments;
2353
- return runtime_1.wrap(function _callee2$(_context2) {
2354
- while (1) {
2355
- switch (_context2.prev = _context2.next) {
2356
- case 0:
2357
- defaults = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : configDefaults;
2358
- configWithDefaults = deepUpdate(clone(defaults), baseConfig);
2359
- _context2.next = 4;
2360
- return loadIncludes(configWithDefaults);
2361
-
2362
- case 4:
2363
- finalConfig = _context2.sent;
2364
- finalConfig = mergeConfigs(finalConfig, baseConfig) || finalConfig;
2365
- fillTemplates(finalConfig, finalConfig);
2366
- validateConfig(finalConfig);
2367
- return _context2.abrupt("return", finalConfig);
2368
-
2369
- case 9:
2370
- case "end":
2371
- return _context2.stop();
2372
- }
2373
- }
2374
- }, _callee2);
2375
- }));
2376
- return _createFinalConfig.apply(this, arguments);
2377
- }
2378
-
2379
- function fetchConfigFile(_x2) {
2380
- return _fetchConfigFile.apply(this, arguments);
2381
- }
2382
-
2383
- function _fetchConfigFile() {
2384
- _fetchConfigFile = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(location) {
2385
- var result;
2386
- return runtime_1.wrap(function _callee3$(_context3) {
2387
- while (1) {
2388
- switch (_context3.prev = _context3.next) {
2389
- case 0:
2390
- _context3.next = 2;
2391
- return io.openLocation(location).readFile('utf8');
2392
-
2393
- case 2:
2394
- result = _context3.sent;
2395
-
2396
- if (!isUriLocation(location)) {
2397
- _context3.next = 5;
2398
- break;
2399
- }
2400
-
2401
- return _context3.abrupt("return", parseJb1(result, location.uri));
2402
-
2403
- case 5:
2404
- if (!isLocalPathLocation(location)) {
2405
- _context3.next = 7;
2406
- break;
2407
- }
2408
-
2409
- return _context3.abrupt("return", parseJb1(result, location.localPath));
2410
-
2411
- case 7:
2412
- return _context3.abrupt("return", parseJb1(result));
2413
-
2414
- case 8:
2415
- case "end":
2416
- return _context3.stop();
2417
- }
2418
- }
2419
- }, _callee3);
2420
- }));
2421
- return _fetchConfigFile.apply(this, arguments);
2422
- }
2423
-
2424
- function parseJb1(config) {
2425
- var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2426
-
2427
- if (config.trim().startsWith('{')) {
2428
- return parseJB1Json(config, url);
2429
- }
2430
-
2431
- return parseJB1Conf(config, url);
2432
- }
2433
- /**
2434
- * Merges config object b into a. Properties in b override those in a.
2435
- */
2436
-
2437
- function mergeConfigs(a, b) {
2438
- if (b === null) {
2439
- return null;
2440
- }
2441
-
2442
- if (a === null) {
2443
- a = {};
2444
- }
2445
-
2446
- for (var _i = 0, _Object$keys = Object.keys(b); _i < _Object$keys.length; _i++) {
2447
- var prop = _Object$keys[_i];
2448
-
2449
- if (prop === 'tracks' && prop in a) {
2450
- var aTracks = a[prop] || [];
2451
- var bTracks = b[prop] || [];
2452
-
2453
- if (Array.isArray(aTracks) && Array.isArray(bTracks)) {
2454
- a[prop] = mergeTrackConfigs(aTracks || [], bTracks || []);
2455
- } else {
2456
- throw new Error("Track config has not been properly regularized: ".concat(aTracks, " ").concat(bTracks));
2457
- }
2458
- } else if (!noRecursiveMerge(prop) && prop in a && // @ts-ignore
2459
- _typeof(b[prop]) === 'object' && // @ts-ignore
2460
- _typeof(a[prop]) === 'object') {
2461
- // @ts-ignore
2462
- a[prop] = deepUpdate(a[prop], b[prop]);
2463
- } else if (prop === 'dataRoot') {
2464
- if (a[prop] === undefined || a[prop] === 'data' && b[prop] !== undefined) {
2465
- a[prop] = b[prop];
2466
- } // @ts-ignore
2467
-
2468
- } else if (a[prop] === undefined || b[prop] !== undefined) {
2469
- // @ts-ignore
2470
- a[prop] = b[prop];
2471
- }
2472
- }
2473
-
2474
- return a;
2475
- }
2476
- /**
2477
- * Special-case merging of two `tracks` configuration arrays.
2478
- */
2479
-
2480
-
2481
- function mergeTrackConfigs(a, b) {
2482
- if (!b.length) {
2483
- return a;
2484
- } // index the tracks in `a` by track label
2485
-
2486
-
2487
- var aTracks = {};
2488
- a.forEach(function (t, i) {
2489
- t.index = i;
2490
- aTracks[t.label] = t;
2491
- });
2492
- b.forEach(function (bT) {
2493
- var aT = aTracks[bT.label];
2494
-
2495
- if (aT) {
2496
- mergeConfigs(aT, bT);
2497
- } else {
2498
- a.push(bT);
2499
- }
2500
- });
2501
- return a;
2502
- }
2503
- /**
2504
- * Recursively fetch, parse, and merge all the includes in the given config
2505
- * object. Calls the callback with the resulting configuration when finished.
2506
- * @param inputConfig - Config to load includes into
2507
- */
2508
-
2509
-
2510
- function loadIncludes(_x3) {
2511
- return _loadIncludes.apply(this, arguments);
2512
- }
2513
-
2514
- function _loadIncludes() {
2515
- _loadIncludes = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(inputConfig) {
2516
- var loadRecur, _loadRecur;
2517
-
2518
- return runtime_1.wrap(function _callee6$(_context6) {
2519
- while (1) {
2520
- switch (_context6.prev = _context6.next) {
2521
- case 0:
2522
- _loadRecur = function _loadRecur3() {
2523
- _loadRecur = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(config, upstreamConf) {
2524
- var sourceUrl, newUpstreamConf, includes, loads, includedDataObjects;
2525
- return runtime_1.wrap(function _callee5$(_context5) {
2526
- while (1) {
2527
- switch (_context5.prev = _context5.next) {
2528
- case 0:
2529
- sourceUrl = config.sourceUrl || config.baseUrl;
2530
-
2531
- if (sourceUrl) {
2532
- _context5.next = 3;
2533
- break;
2534
- }
2535
-
2536
- throw new Error("Could not determine source URL: ".concat(JSON.stringify(config)));
2537
-
2538
- case 3:
2539
- newUpstreamConf = mergeConfigs(clone(upstreamConf), config);
2540
-
2541
- if (newUpstreamConf) {
2542
- _context5.next = 6;
2543
- break;
2544
- }
2545
-
2546
- throw new Error('Problem merging configs');
2547
-
2548
- case 6:
2549
- includes = fillTemplates(regularizeIncludes(config.include || []), newUpstreamConf);
2550
- delete config.include;
2551
- loads = includes.map( /*#__PURE__*/function () {
2552
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(include) {
2553
- var includedData;
2554
- return runtime_1.wrap(function _callee4$(_context4) {
2555
- while (1) {
2556
- switch (_context4.prev = _context4.next) {
2557
- case 0:
2558
- include.cacheBuster = inputConfig.cacheBuster;
2559
- _context4.next = 3;
2560
- return fetchConfigFile({
2561
- uri: new URL(include.url, sourceUrl).href,
2562
- locationType: 'UriLocation'
2563
- });
2564
-
2565
- case 3:
2566
- includedData = _context4.sent;
2567
- return _context4.abrupt("return", loadRecur(includedData, newUpstreamConf));
2568
-
2569
- case 5:
2570
- case "end":
2571
- return _context4.stop();
2572
- }
2573
- }
2574
- }, _callee4);
2575
- }));
2576
-
2577
- return function (_x6) {
2578
- return _ref.apply(this, arguments);
2579
- };
2580
- }());
2581
- _context5.next = 11;
2582
- return Promise.all(loads);
2583
-
2584
- case 11:
2585
- includedDataObjects = _context5.sent;
2586
- includedDataObjects.forEach(function (includedData) {
2587
- config = mergeConfigs(config, includedData) || config;
2588
- });
2589
- return _context5.abrupt("return", config);
2590
-
2591
- case 14:
2592
- case "end":
2593
- return _context5.stop();
2594
- }
2595
- }
2596
- }, _callee5);
2597
- }));
2598
- return _loadRecur.apply(this, arguments);
2599
- };
2600
-
2601
- loadRecur = function _loadRecur2(_x4, _x5) {
2602
- return _loadRecur.apply(this, arguments);
2603
- };
2604
-
2605
- inputConfig = clone(inputConfig);
2606
- return _context6.abrupt("return", loadRecur(inputConfig, {}));
2607
-
2608
- case 4:
2609
- case "end":
2610
- return _context6.stop();
2611
- }
2612
- }
2613
- }, _callee6);
2614
- }));
2615
- return _loadIncludes.apply(this, arguments);
2616
- }
2617
-
2618
- function regularizeIncludes(includes) {
2619
- if (!includes) {
2620
- return [];
2621
- } // coerce include to an array
2622
-
2623
-
2624
- if (!Array.isArray(includes)) {
2625
- includes = [includes];
2626
- }
2627
-
2628
- return includes.map(function (include) {
2629
- // coerce bare strings in the includes to URLs
2630
- if (typeof include === 'string') {
2631
- include = {
2632
- url: include
2633
- };
2634
- } // set defaults for format and version
2635
-
2636
-
2637
- if (!('format' in include)) {
2638
- include.format = include.url.endsWith('.conf') ? 'conf' : 'JB_json';
2639
- }
2640
-
2641
- if (include.format === 'JB_json' && !('version' in include)) {
2642
- include.version = 1;
2643
- }
2644
-
2645
- return include;
2646
- });
2647
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
2648
-
2649
-
2650
- function fillTemplates(subconfig, config) {
2651
- if (!subconfig) {
2652
- return subconfig;
2653
- }
2654
-
2655
- if (Array.isArray(subconfig)) {
2656
- for (var i = 0; i < subconfig.length; i += 1) {
2657
- subconfig[i] = fillTemplates(subconfig[i], config);
2658
- }
2659
- } else if (_typeof(subconfig) === 'object') {
2660
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2661
- var sub = subconfig;
2662
-
2663
- for (var _i2 = 0, _Object$keys2 = Object.keys(sub); _i2 < _Object$keys2.length; _i2++) {
2664
- var name = _Object$keys2[_i2];
2665
- sub[name] = fillTemplates(sub[name], config);
2666
- }
2667
- } else if (typeof subconfig === 'string') {
2668
- // @ts-ignore
2669
- return fillTemplate(subconfig, config);
2670
- }
2671
-
2672
- return subconfig;
2673
- }
2674
- /**
2675
- * list of config properties that should not be recursively merged
2676
- * @param propName - name of config property
2677
- */
2678
-
2679
-
2680
- function noRecursiveMerge(propName) {
2681
- return propName === 'datasets';
2682
- }
2683
-
2684
- var configDefaults = {
2685
- tracks: [],
2686
- containerID: 'GenomeBrowser',
2687
- dataRoot: 'data',
2688
- show_tracklist: true,
2689
- show_nav: true,
2690
- show_menu: true,
2691
- show_overview: true,
2692
- show_fullviewlink: true,
2693
- update_browser_title: true,
2694
- updateBrowserURL: true,
2695
- refSeqs: '{dataRoot}/seq/refSeqs.json',
2696
- include: ['jbrowse.conf', 'jbrowse_conf.json'],
2697
- nameUrl: '{dataRoot}/names/root.json',
2698
- datasets: {
2699
- _DEFAULT_EXAMPLES: true,
2700
- volvox: {
2701
- url: '?data=sample_data/json/volvox',
2702
- name: 'Volvox Example'
2703
- },
2704
- modencode: {
2705
- url: '?data=sample_data/json/modencode',
2706
- name: 'MODEncode Example'
2707
- },
2708
- yeast: {
2709
- url: '?data=sample_data/json/yeast',
2710
- name: 'Yeast Example'
2711
- }
2712
- },
2713
- highlightSearchedRegions: false,
2714
- highResolutionMode: 'auto'
2715
- };
2716
- /**
2717
- * Examine the loaded and merged configuration for errors. Throws
2718
- * exceptions if it finds anything amiss.
2719
- * @returns nothing meaningful
2720
- */
2721
-
2722
- function validateConfig(config) {
2723
- if (!config.tracks) {
2724
- config.tracks = [];
2725
- }
2726
-
2727
- if (!config.baseUrl) {
2728
- throw new Error('Must provide a `baseUrl` in configuration');
2729
- }
2730
- }
2731
-
2732
- function convertTrackConfig(jb1TrackConfig, dataRoot, sequenceAdapter) {
2733
- var jb2TrackConfig = {
2734
- trackId: util.objectHash(jb1TrackConfig),
2735
- name: jb1TrackConfig.key || jb1TrackConfig.label
2736
- };
2737
- var description = jb1TrackConfig.metadata && (jb1TrackConfig.metadata.description || jb1TrackConfig.metadata.Description);
2738
-
2739
- if (description) {
2740
- jb2TrackConfig.description = description;
2741
- }
2742
-
2743
- var category = jb1TrackConfig.category || jb1TrackConfig.metadata && jb1TrackConfig.metadata.category;
2744
- jb2TrackConfig.category = category ? category.split(/\s*\/\s*/) : [];
2745
- var storeClass = jb1TrackConfig.storeClass;
2746
-
2747
- if (!jb1TrackConfig.urlTemplate) {
2748
- if (!(storeClass && storeClass.endsWith('FromConfig'))) {
2749
- var trackIdentifier = jb1TrackConfig.key || jb1TrackConfig.label;
2750
- console.warn("Could not import JBrowse1 track \"".concat(trackIdentifier, "\" because it does not have a \"urlTemplate\" or is not a \"FromConfig\" track"));
2751
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, trackIdentifier, jb2TrackConfig.category);
2752
- }
2753
-
2754
- return generateFromConfigTrackConfig(jb1TrackConfig, jb2TrackConfig);
2755
- }
2756
-
2757
- var resolveUrlTemplate = function resolveUrlTemplate(urlTemplate) {
2758
- return new URL(urlTemplate, "".concat(dataRoot, "/")).href.replace(/%7B/gi, '{').replace(/%7D/gi, '}');
2759
- };
2760
-
2761
- var urlTemplate = resolveUrlTemplate(jb1TrackConfig.urlTemplate);
2762
-
2763
- if (storeClass) {
2764
- if (storeClass === 'JBrowse/Store/SeqFeature/BAM') {
2765
- var adapter = {
2766
- type: 'BamAdapter',
2767
- bamLocation: {
2768
- uri: urlTemplate,
2769
- locationType: 'UriLocation'
2770
- }
2771
- };
2772
-
2773
- if (jb1TrackConfig.baiUrlTemplate) {
2774
- adapter.index = {
2775
- location: {
2776
- uri: resolveUrlTemplate(jb1TrackConfig.baiUrlTemplate),
2777
- locationType: 'UriLocation'
2778
- }
2779
- };
2780
- } else if (jb1TrackConfig.csiUrlTemplate) {
2781
- adapter.index = {
2782
- location: {
2783
- uri: resolveUrlTemplate(jb1TrackConfig.csiUrlTemplate),
2784
- locationType: 'UriLocation'
2785
- },
2786
- indexType: 'CSI'
2787
- };
2788
- } else {
2789
- adapter.index = {
2790
- location: {
2791
- uri: "".concat(urlTemplate, ".bai"),
2792
- locationType: 'UriLocation'
2793
- }
2794
- };
2795
- }
2796
-
2797
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
2798
- type: 'AlignmentsTrack',
2799
- adapter: adapter
2800
- });
2801
- }
2802
-
2803
- if (storeClass === 'JBrowse/Store/SeqFeature/CRAM') {
2804
- var _adapter = {
2805
- type: 'CramAdapter',
2806
- cramLocation: {
2807
- uri: urlTemplate,
2808
- locationType: 'UriLocation'
2809
- },
2810
- sequenceAdapter: sequenceAdapter
2811
- };
2812
-
2813
- if (jb1TrackConfig.craiUrlTemplate) {
2814
- _adapter.craiLocation = {
2815
- uri: resolveUrlTemplate(jb1TrackConfig.craiUrlTemplate),
2816
- locationType: 'UriLocation'
2817
- };
2818
- } else {
2819
- _adapter.craiLocation = {
2820
- uri: "".concat(urlTemplate, ".crai"),
2821
- locationType: 'UriLocation'
2822
- };
2823
- }
2824
-
2825
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
2826
- type: 'AlignmentsTrack',
2827
- adapter: _adapter
2828
- });
2829
- }
2830
-
2831
- if (storeClass === 'JBrowse/Store/SeqFeature/NCList') {
2832
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
2833
- type: 'FeatureTrack',
2834
- adapter: {
2835
- type: 'NCListAdapter',
2836
- rootUrlTemplate: {
2837
- uri: urlTemplate,
2838
- locationType: 'UriLocation'
2839
- }
2840
- }
2841
- });
2842
- }
2843
-
2844
- if (storeClass === 'JBrowse/Store/SeqFeature/BigWig' || storeClass === 'JBrowse/Store/BigWig') {
2845
- if (jb1TrackConfig.type && jb1TrackConfig.type.endsWith('XYPlot')) {
2846
- jb2TrackConfig.defaultRendering = 'xyplot';
2847
- } else if (jb1TrackConfig.type && jb1TrackConfig.type.endsWith('Density')) {
2848
- jb2TrackConfig.defaultRendering = 'density';
2849
- }
2850
-
2851
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
2852
- type: 'QuantitativeTrack',
2853
- adapter: {
2854
- type: 'BigWigAdapter',
2855
- bigWigLocation: {
2856
- uri: urlTemplate,
2857
- locationType: 'UriLocation'
2858
- }
2859
- }
2860
- });
2861
- }
2862
-
2863
- if (storeClass === 'JBrowse/Store/SeqFeature/VCFTabix') {
2864
- var _adapter2 = {
2865
- type: 'VcfTabixAdapter',
2866
- vcfGzLocation: {
2867
- uri: urlTemplate,
2868
- locationType: 'UriLocation'
2869
- }
2870
- };
2871
-
2872
- if (jb1TrackConfig.tbiUrlTemplate) {
2873
- _adapter2.index = {
2874
- location: {
2875
- uri: resolveUrlTemplate(jb1TrackConfig.tbiUrlTemplate),
2876
- locationType: 'UriLocation'
2877
- }
2878
- };
2879
- } else if (jb1TrackConfig.csiUrlTemplate) {
2880
- _adapter2.index = {
2881
- location: {
2882
- uri: resolveUrlTemplate(jb1TrackConfig.csiUrlTemplate),
2883
- locationType: 'UriLocation'
2884
- },
2885
- indexType: 'CSI'
2886
- };
2887
- } else {
2888
- _adapter2.index = {
2889
- location: {
2890
- uri: "".concat(urlTemplate, ".tbi"),
2891
- locationType: 'UriLocation'
2892
- }
2893
- };
2894
- }
2895
-
2896
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
2897
- type: 'VariantTrack',
2898
- adapter: _adapter2
2899
- });
2900
- }
2901
-
2902
- if (storeClass === 'JBrowse/Store/SeqFeature/VCFTribble') {
2903
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, "VCFTribble (".concat(urlTemplate, ")"), jb2TrackConfig.category);
2904
- }
2905
-
2906
- if (storeClass === 'JBrowse/Store/SeqFeature/GFF3') {
2907
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, "GFF3 (".concat(urlTemplate, ")"), jb2TrackConfig.category);
2908
- }
2909
-
2910
- if (storeClass === 'JBrowse/Store/SeqFeature/BigBed') {
2911
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
2912
- type: 'FeatureTrack',
2913
- adapter: {
2914
- type: 'BigBedAdapter',
2915
- bigBedLocation: {
2916
- uri: urlTemplate,
2917
- locationType: 'UriLocation'
2918
- }
2919
- }
2920
- });
2921
- }
2922
-
2923
- if (storeClass === 'JBrowse/Store/SeqFeature/GFF3Tabix') {
2924
- var _adapter3 = {
2925
- type: 'Gff3TabixAdapter',
2926
- gffGzLocation: {
2927
- uri: urlTemplate,
2928
- locationType: 'UriLocation'
2929
- }
2930
- };
2931
-
2932
- if (jb1TrackConfig.tbiUrlTemplate) {
2933
- _adapter3.index = {
2934
- location: {
2935
- uri: resolveUrlTemplate(jb1TrackConfig.tbiUrlTemplate),
2936
- locationType: 'UriLocation'
2937
- }
2938
- };
2939
- } else if (jb1TrackConfig.csiUrlTemplate) {
2940
- _adapter3.index = {
2941
- location: {
2942
- uri: resolveUrlTemplate(jb1TrackConfig.csiUrlTemplate),
2943
- locationType: 'UriLocation'
2944
- },
2945
- indexType: 'CSI'
2946
- };
2947
- } else {
2948
- _adapter3.index = {
2949
- location: {
2950
- uri: "".concat(urlTemplate, ".tbi"),
2951
- locationType: 'UriLocation'
2952
- }
2953
- };
2954
- }
2955
-
2956
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
2957
- type: 'FeatureTrack',
2958
- adapter: _adapter3
2959
- });
2960
- }
2961
-
2962
- if (storeClass === 'JBrowse/Store/SeqFeature/BED') {
2963
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, "BED (".concat(urlTemplate, ")"), jb2TrackConfig.category);
2964
- }
2965
-
2966
- if (storeClass === 'JBrowse/Store/SeqFeature/BEDTabix') {
2967
- var _adapter4 = {
2968
- type: 'BedTabixAdapter',
2969
- bedGzLocation: {
2970
- uri: urlTemplate,
2971
- locationType: 'UriLocation'
2972
- }
2973
- };
2974
-
2975
- if (jb1TrackConfig.tbiUrlTemplate) {
2976
- _adapter4.index = {
2977
- location: {
2978
- uri: resolveUrlTemplate(jb1TrackConfig.tbiUrlTemplate),
2979
- locationType: 'UriLocation'
2980
- }
2981
- };
2982
- } else if (jb1TrackConfig.csiUrlTemplate) {
2983
- _adapter4.index = {
2984
- location: {
2985
- uri: resolveUrlTemplate(jb1TrackConfig.csiUrlTemplate),
2986
- locationType: 'UriLocation'
2987
- },
2988
- indexType: 'CSI'
2989
- };
2990
- } else {
2991
- _adapter4.index = {
2992
- location: {
2993
- uri: "".concat(urlTemplate, ".tbi"),
2994
- locationType: 'UriLocation'
2995
- }
2996
- };
2997
- }
2998
-
2999
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
3000
- type: 'FeatureTrack',
3001
- adapter: _adapter4
3002
- });
3003
- }
3004
-
3005
- if (storeClass === 'JBrowse/Store/SeqFeature/GTF') {
3006
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, "GTF (".concat(urlTemplate, ")"), jb2TrackConfig.category);
3007
- }
3008
-
3009
- if (storeClass === 'JBrowse/Store/SeqFeature/StaticChunked' || storeClass === 'JBrowse/Store/Sequence/StaticChunked') {
3010
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, "StaticChunked (".concat(urlTemplate, ")"), jb2TrackConfig.category);
3011
- }
3012
-
3013
- if (storeClass === 'JBrowse/Store/SeqFeature/UnindexedFasta') {
3014
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, "UnindexedFasta (".concat(urlTemplate, ")"), jb2TrackConfig.category);
3015
- }
3016
-
3017
- if (storeClass === 'JBrowse/Store/SeqFeature/IndexedFasta') {
3018
- var _adapter5 = {
3019
- type: 'IndexedFastaAdapter',
3020
- fastaLocation: {
3021
- uri: urlTemplate,
3022
- locationType: 'UriLocation'
3023
- }
3024
- };
3025
-
3026
- if (jb1TrackConfig.faiUrlTemplate) {
3027
- _adapter5.faiLocation = {
3028
- uri: resolveUrlTemplate(jb1TrackConfig.faiUrlTemplate),
3029
- locationType: 'UriLocation'
3030
- };
3031
- } else {
3032
- _adapter5.faiLocation = {
3033
- uri: "".concat(urlTemplate, ".fai"),
3034
- locationType: 'UriLocation'
3035
- };
3036
- }
3037
-
3038
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
3039
- type: 'SequenceTrack',
3040
- adapter: _adapter5
3041
- });
3042
- }
3043
-
3044
- if (storeClass === 'JBrowse/Store/SeqFeature/BgzipIndexedFasta') {
3045
- var _adapter6 = {
3046
- type: 'BgzipFastaAdapter',
3047
- fastaLocation: {
3048
- uri: urlTemplate,
3049
- locationType: 'UriLocation'
3050
- }
3051
- };
3052
-
3053
- if (jb1TrackConfig.faiUrlTemplate) {
3054
- _adapter6.faiLocation = {
3055
- uri: resolveUrlTemplate(jb1TrackConfig.faiUrlTemplate),
3056
- locationType: 'UriLocation'
3057
- };
3058
- } else {
3059
- _adapter6.faiLocation = {
3060
- uri: "".concat(urlTemplate, ".fai"),
3061
- locationType: 'UriLocation'
3062
- };
3063
- }
3064
-
3065
- if (jb1TrackConfig.gziUrlTemplate) {
3066
- _adapter6.gziLocation = {
3067
- uri: resolveUrlTemplate(jb1TrackConfig.gziUrlTemplate),
3068
- locationType: 'UriLocation'
3069
- };
3070
- } else {
3071
- _adapter6.gziLocation = {
3072
- uri: "".concat(urlTemplate, ".gzi"),
3073
- locationType: 'UriLocation'
3074
- };
3075
- }
3076
-
3077
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
3078
- type: 'ReferenceSequenceTrack',
3079
- adapter: _adapter6
3080
- });
3081
- }
3082
-
3083
- if (storeClass === 'JBrowse/Store/SeqFeature/TwoBit') {
3084
- return _objectSpread2(_objectSpread2({}, jb2TrackConfig), {}, {
3085
- type: 'ReferenceSequenceTrack',
3086
- adapter: {
3087
- type: 'TwoBitAdapter',
3088
- twoBitLocation: {
3089
- uri: urlTemplate,
3090
- locationType: 'UriLocation'
3091
- }
3092
- }
3093
- });
3094
- }
3095
- } // If we don't recogize the store class, make a best effort to guess by file type
3096
-
3097
-
3098
- jb2TrackConfig.adapter = tracks.guessAdapter({
3099
- uri: urlTemplate,
3100
- locationType: 'UriLocation'
3101
- }, undefined, urlTemplate);
3102
-
3103
- if (!jb2TrackConfig.adapter) {
3104
- throw new Error('Could not determine adapter');
3105
- }
3106
-
3107
- if (jb2TrackConfig.adapter.type === tracks.UNSUPPORTED) {
3108
- return tracks.generateUnsupportedTrackConf(jb2TrackConfig.name, urlTemplate, jb2TrackConfig.category);
3109
- }
3110
-
3111
- if (jb2TrackConfig.adapter.type === tracks.UNKNOWN) {
3112
- return tracks.generateUnknownTrackConf(jb2TrackConfig.name, urlTemplate, jb2TrackConfig.category);
3113
- }
3114
-
3115
- jb2TrackConfig.type = tracks.guessTrackType(jb2TrackConfig.adapter.type);
3116
-
3117
- if (jb2TrackConfig.type === 'QuantitativeTrack') {
3118
- if (jb1TrackConfig.type && jb1TrackConfig.type.endsWith('XYPlot')) {
3119
- jb2TrackConfig.defaultRendering = 'xyplot';
3120
- } else if (jb1TrackConfig.type && jb1TrackConfig.type.endsWith('Density')) {
3121
- jb2TrackConfig.defaultRendering = 'density';
3122
- }
3123
- }
3124
-
3125
- return jb2TrackConfig;
3126
- }
3127
-
3128
- function generateFromConfigTrackConfig(jb1TrackConfig, jb2TrackConfig) {
3129
- var jb1Features = jb1TrackConfig.features || [];
3130
- var jb2Features = jb1Features.map(function (feature) {
3131
- var jb2Feature = JSON.parse(JSON.stringify(feature));
3132
- jb2Feature.refName = feature.seq_id;
3133
- jb2Feature.uniqueId = "".concat(feature.seq_id, ":").concat(feature.start, "-").concat(feature.end, ":").concat(feature.name || '');
3134
- return jb2Feature;
3135
- });
3136
- jb2TrackConfig.adapter = {
3137
- type: 'FromConfigAdapter',
3138
- features: jb2Features
3139
- };
3140
- jb2TrackConfig.type = 'FeatureTrack';
3141
- return jb2TrackConfig;
3142
- }
3143
-
3144
- function jbrowse1ModelFactory (pluginManager) {
3145
- return mobxStateTree.types.compose('JBrowse1Connection', models.BaseConnectionModelFactory(pluginManager), mobxStateTree.types.model({
3146
- configuration: configuration.ConfigurationReference(jbrowse1ConfigSchema),
3147
- type: mobxStateTree.types.literal('JBrowse1Connection')
3148
- }).actions(function (self) {
3149
- return {
3150
- connect: function connect() {
3151
- var dataDirLocation = configuration.readConfObject(self.configuration, 'dataDirLocation');
3152
- var session = util.getSession(self);
3153
- fetchJb1(dataDirLocation).then(function (config) {
3154
- var assemblyName = configuration.readConfObject(self.configuration, 'assemblyNames')[0];
3155
-
3156
- if (!assemblyName) {
3157
- throw new Error('assembly name required for JBrowse 1 connection');
3158
- }
3159
-
3160
- var assemblyConf = session.assemblies.find(function (assembly) {
3161
- return configuration.readConfObject(assembly, 'name') === assemblyName;
3162
- });
3163
- var sequenceAdapter = configuration.readConfObject(assemblyConf, ['sequence', 'adapter']);
3164
- var jb2Tracks = config.tracks.map(function (jb1Track) {
3165
- var jb2Track = convertTrackConfig(jb1Track, config.dataRoot, sequenceAdapter);
3166
- jb2Track.assemblyNames = [assemblyName];
3167
- return jb2Track;
3168
- });
3169
- self.setTrackConfs(jb2Tracks);
3170
- })["catch"](function (error) {
3171
- console.error(error);
3172
- session.notify("There was a problem connecting to the JBrowse 1 data directory \"".concat(self.name, "\". Please make sure you have entered a valid location. The error that was thrown is: \"").concat(error, "\""), 'error');
3173
- session.breakConnection(self.configuration);
3174
- });
3175
- }
3176
- };
3177
- }));
3178
- }
3179
-
3180
- var LegacyJBrowsePlugin = /*#__PURE__*/function (_Plugin) {
3181
- _inherits(LegacyJBrowsePlugin, _Plugin);
3182
-
3183
- var _super = /*#__PURE__*/_createSuper(LegacyJBrowsePlugin);
3184
-
3185
- function LegacyJBrowsePlugin() {
3186
- var _this;
3187
-
3188
- _classCallCheck(this, LegacyJBrowsePlugin);
3189
-
3190
- _this = _super.apply(this, arguments);
3191
- _this.name = 'LegacyJBrowsePlugin';
3192
- return _this;
3193
- }
3194
-
3195
- _createClass(LegacyJBrowsePlugin, [{
3196
- key: "install",
3197
- value: function install(pluginManager) {
3198
- pluginManager.addAdapterType(function () {
3199
- return new AdapterType({
3200
- name: 'NCListAdapter',
3201
- configSchema: ncListAdapterConfigSchema,
3202
- getAdapterClass: function getAdapterClass() {
3203
- return Promise.resolve().then(function () { return NCListAdapter$1; }).then(function (r) {
3204
- return r["default"];
3205
- });
3206
- }
3207
- });
3208
- });
3209
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
3210
- return function (file, index, adapterHint) {
3211
- var regexGuess = /trackData.jsonz?$/i;
3212
- var adapterName = 'NCListAdapter';
3213
- var fileName = tracks.getFileName(file);
3214
-
3215
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
3216
- return {
3217
- type: adapterName,
3218
- rootUrlTemplate: file
3219
- };
3220
- }
3221
-
3222
- return adapterGuesser(file, index, adapterHint);
3223
- };
3224
- });
3225
- pluginManager.addTextSearchAdapterType(function () {
3226
- return new TextSearchAdapterType({
3227
- name: 'JBrowse1TextSearchAdapter',
3228
- configSchema: jbrowse1AdapterConfigSchema,
3229
- AdapterClass: JBrowse1TextSearchAdapter,
3230
- description: 'A JBrowse 1 text search adapter'
3231
- });
3232
- });
3233
- pluginManager.addConnectionType(function () {
3234
- return new ConnectionType({
3235
- name: 'JBrowse1Connection',
3236
- configSchema: jbrowse1ConfigSchema,
3237
- stateModel: jbrowse1ModelFactory(pluginManager),
3238
- displayName: 'JBrowse 1 Data',
3239
- description: 'A JBrowse 1 data directory',
3240
- url: '//jbrowse.org/'
3241
- });
3242
- });
3243
- }
3244
- }]);
3245
-
3246
- return LegacyJBrowsePlugin;
3247
- }(Plugin);
3248
-
3249
- var jb2ToJb1 = {
3250
- refName: 'seq_id'
3251
- };
3252
- var jb1ToJb2 = {
3253
- seq_id: 'refName'
3254
- };
3255
- /**
3256
- * wrapper to adapt nclist features to act like jbrowse 2 features
3257
- */
3258
-
3259
- var NCListFeature = /*#__PURE__*/function () {
3260
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3261
- function NCListFeature(ncFeature, parent, id) {
3262
- _classCallCheck(this, NCListFeature);
3263
-
3264
- this.ncFeature = ncFeature;
3265
- this.uniqueId = id || ncFeature.id();
3266
- this.parentHandle = parent;
3267
- }
3268
-
3269
- _createClass(NCListFeature, [{
3270
- key: "set",
3271
- value: function set() {
3272
- throw new Error('not implemented');
3273
- }
3274
- }, {
3275
- key: "jb2TagToJb1Tag",
3276
- value: function jb2TagToJb1Tag(tag) {
3277
- // @ts-ignore
3278
- var mapped = jb2ToJb1[tag] || tag;
3279
- return mapped.toLowerCase();
3280
- }
3281
- }, {
3282
- key: "jb1TagToJb2Tag",
3283
- value: function jb1TagToJb2Tag(tag) {
3284
- var t = tag.toLowerCase(); // @ts-ignore
3285
-
3286
- var mapped = jb1ToJb2[t] || t;
3287
- return mapped;
3288
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
3289
-
3290
- }, {
3291
- key: "get",
3292
- value: function get(attrName) {
3293
- var _this = this;
3294
-
3295
- var attr = this.ncFeature.get(this.jb2TagToJb1Tag(attrName));
3296
-
3297
- if (attr && attrName === 'subfeatures') {
3298
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3299
- return attr.map(function (subfeature) {
3300
- return new NCListFeature(subfeature, _this);
3301
- });
3302
- }
3303
-
3304
- return attr;
3305
- }
3306
- /**
3307
- * Get an array listing which data keys are present in this feature.
3308
- */
3309
-
3310
- }, {
3311
- key: "tags",
3312
- value: function tags() {
3313
- var _this2 = this;
3314
-
3315
- return this.ncFeature.tags().map(function (t) {
3316
- return _this2.jb1TagToJb2Tag(t);
3317
- });
3318
- }
3319
- /**
3320
- * Get the unique ID of this feature.
3321
- */
3322
-
3323
- }, {
3324
- key: "id",
3325
- value: function id() {
3326
- return this.uniqueId;
3327
- }
3328
- /**
3329
- * Get this feature's parent feature, or undefined if none.
3330
- */
3331
-
3332
- }, {
3333
- key: "parent",
3334
- value: function parent() {
3335
- return this.parentHandle;
3336
- }
3337
- /**
3338
- * Get an array of child features, or undefined if none.
3339
- */
3340
-
3341
- }, {
3342
- key: "children",
3343
- value: function children() {
3344
- return this.get('subfeatures');
3345
- }
3346
- }, {
3347
- key: "toJSON",
3348
- value: function toJSON() {
3349
- var _this3 = this;
3350
-
3351
- var data = {
3352
- uniqueId: this.id()
3353
- };
3354
- this.ncFeature.tags().forEach(function (tag) {
3355
- var mappedTag = _this3.jb1TagToJb2Tag(tag);
3356
-
3357
- var value = _this3.ncFeature.get(tag);
3358
-
3359
- if (mappedTag === 'subfeatures') {
3360
- data.subfeatures = (value || []).map(function (f) {
3361
- // note: was new NCListFeature(f, `${this.id()}-${i}`, this).toJSON()
3362
- return new NCListFeature(f, _this3).toJSON();
3363
- });
3364
- } else {
3365
- data[mappedTag] = value;
3366
- }
3367
- });
3368
- return data;
3369
- }
3370
- }]);
3371
-
3372
- return NCListFeature;
3373
- }();
3374
-
3375
- var NCListAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
3376
- _inherits(NCListAdapter, _BaseFeatureDataAdapt);
3377
-
3378
- var _super = /*#__PURE__*/_createSuper(NCListAdapter);
3379
-
3380
- function NCListAdapter(config, getSubAdapter, pluginManager) {
3381
- var _this;
3382
-
3383
- _classCallCheck(this, NCListAdapter);
3384
-
3385
- _this = _super.call(this, config, getSubAdapter, pluginManager);
3386
- var refNames = configuration.readConfObject(config, 'refNames');
3387
- var rootUrlTemplate = configuration.readConfObject(config, 'rootUrlTemplate');
3388
- _this.configRefNames = refNames;
3389
- _this.nclist = new NCListStore({
3390
- baseUrl: '',
3391
- urlTemplate: rootUrlTemplate.uri,
3392
- readFile: function readFile(url) {
3393
- return new genericFilehandle.RemoteFile(String(rootUrlTemplate.baseUri ? new URL(url, rootUrlTemplate.baseUri).toString() : url)).readFile();
3394
- }
3395
- });
3396
- return _this;
3397
- }
3398
- /**
3399
- * Fetch features for a certain region. Use getFeaturesInRegion() if you also
3400
- * want to verify that the store has features for the given reference sequence
3401
- * before fetching.
3402
- * @param region -
3403
- * @param opts - [signal] optional signalling object for aborting the fetch
3404
- * @returns Observable of Feature objects in the region
3405
- */
3406
-
3407
-
3408
- _createClass(NCListAdapter, [{
3409
- key: "getFeatures",
3410
- value: function getFeatures(region) {
3411
- var _this2 = this;
3412
-
3413
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3414
- return rxjs.ObservableCreate( /*#__PURE__*/function () {
3415
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(observer) {
3416
- var signal, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, feature;
3417
-
3418
- return runtime_1.wrap(function _callee$(_context) {
3419
- while (1) {
3420
- switch (_context.prev = _context.next) {
3421
- case 0:
3422
- signal = opts.signal;
3423
- _iteratorAbruptCompletion = false;
3424
- _didIteratorError = false;
3425
- _context.prev = 3;
3426
- _iterator = _asyncIterator(_this2.nclist.getFeatures(region, opts));
3427
-
3428
- case 5:
3429
- _context.next = 7;
3430
- return _iterator.next();
3431
-
3432
- case 7:
3433
- if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
3434
- _context.next = 14;
3435
- break;
3436
- }
3437
-
3438
- feature = _step.value;
3439
- util.checkAbortSignal(signal);
3440
- observer.next(_this2.wrapFeature(feature));
3441
-
3442
- case 11:
3443
- _iteratorAbruptCompletion = false;
3444
- _context.next = 5;
3445
- break;
3446
-
3447
- case 14:
3448
- _context.next = 20;
3449
- break;
3450
-
3451
- case 16:
3452
- _context.prev = 16;
3453
- _context.t0 = _context["catch"](3);
3454
- _didIteratorError = true;
3455
- _iteratorError = _context.t0;
3456
-
3457
- case 20:
3458
- _context.prev = 20;
3459
- _context.prev = 21;
3460
-
3461
- if (!(_iteratorAbruptCompletion && _iterator["return"] != null)) {
3462
- _context.next = 25;
3463
- break;
3464
- }
3465
-
3466
- _context.next = 25;
3467
- return _iterator["return"]();
3468
-
3469
- case 25:
3470
- _context.prev = 25;
3471
-
3472
- if (!_didIteratorError) {
3473
- _context.next = 28;
3474
- break;
3475
- }
3476
-
3477
- throw _iteratorError;
3478
-
3479
- case 28:
3480
- return _context.finish(25);
3481
-
3482
- case 29:
3483
- return _context.finish(20);
3484
-
3485
- case 30:
3486
- observer.complete();
3487
-
3488
- case 31:
3489
- case "end":
3490
- return _context.stop();
3491
- }
3492
- }
3493
- }, _callee, null, [[3, 16, 20, 30], [21,, 25, 29]]);
3494
- }));
3495
-
3496
- return function (_x) {
3497
- return _ref.apply(this, arguments);
3498
- };
3499
- }());
3500
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
3501
-
3502
- }, {
3503
- key: "wrapFeature",
3504
- value: function wrapFeature(ncFeature) {
3505
- return new NCListFeature(ncFeature, undefined, "".concat(this.id, "-").concat(ncFeature.id()));
3506
- }
3507
- }, {
3508
- key: "hasDataForRefName",
3509
- value: function () {
3510
- var _hasDataForRefName = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(refName) {
3511
- var root;
3512
- return runtime_1.wrap(function _callee2$(_context2) {
3513
- while (1) {
3514
- switch (_context2.prev = _context2.next) {
3515
- case 0:
3516
- _context2.next = 2;
3517
- return this.nclist.getDataRoot(refName);
3518
-
3519
- case 2:
3520
- root = _context2.sent;
3521
- return _context2.abrupt("return", !!(root && root.stats && root.stats.featureCount));
3522
-
3523
- case 4:
3524
- case "end":
3525
- return _context2.stop();
3526
- }
3527
- }
3528
- }, _callee2, this);
3529
- }));
3530
-
3531
- function hasDataForRefName(_x2) {
3532
- return _hasDataForRefName.apply(this, arguments);
3533
- }
3534
-
3535
- return hasDataForRefName;
3536
- }()
3537
- /*
3538
- * NCList is unable to get list of ref names so returns empty
3539
- * @return Promise<string[]> of empty list
3540
- */
3541
-
3542
- }, {
3543
- key: "getRefNames",
3544
- value: function getRefNames() {
3545
- return Promise.resolve(this.configRefNames || []);
3546
- }
3547
- /**
3548
- * called to provide a hint that data tied to a certain region
3549
- * will not be needed for the forseeable future and can be purged
3550
- * from caches, etc
3551
- */
3552
-
3553
- }, {
3554
- key: "freeResources",
3555
- value: function freeResources() {}
3556
- }]);
3557
-
3558
- return NCListAdapter;
3559
- }(BaseAdapter.BaseFeatureDataAdapter);
3560
-
3561
- var NCListAdapter$1 = {
3562
- __proto__: null,
3563
- 'default': NCListAdapter
3564
- };
3565
-
3566
- exports.default = LegacyJBrowsePlugin;
3567
- //# sourceMappingURL=plugin-legacy-jbrowse.cjs.development.js.map