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