@jbrowse/plugin-legacy-jbrowse 1.6.7 → 1.7.0
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.js +30 -0
- package/dist/JBrowse1Connection/index.js +23 -0
- package/dist/JBrowse1Connection/jb1ConfigLoad.js +555 -0
- package/dist/JBrowse1Connection/jb1ConfigParse.js +476 -0
- package/dist/JBrowse1Connection/jb1ToJb2.js +556 -0
- package/dist/JBrowse1Connection/model.js +58 -0
- package/dist/JBrowse1Connection/types.js +5 -0
- package/dist/JBrowse1Connection/util.js +177 -0
- package/dist/JBrowse1TextSeachAdapter/HttpMap.js +350 -0
- package/dist/JBrowse1TextSeachAdapter/HttpMap.test.js +118 -0
- package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.js +191 -0
- package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.test.js +98 -0
- package/dist/JBrowse1TextSeachAdapter/configSchema.js +35 -0
- package/dist/JBrowse1TextSeachAdapter/index.js +23 -0
- package/dist/NCListAdapter/NCListAdapter.js +237 -0
- package/dist/NCListAdapter/NCListAdapter.test.js +108 -0
- package/dist/NCListAdapter/NCListFeature.js +142 -0
- package/dist/NCListAdapter/configSchema.js +27 -0
- package/dist/NCListAdapter/index.js +15 -0
- package/dist/declare.d.js +1 -0
- package/dist/index.js +122 -6
- package/dist/index.test.js +44 -0
- package/package.json +3 -6
- package/src/JBrowse1Connection/jb1ConfigLoad.ts +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _models = require("@jbrowse/core/pluggableElementTypes/models");
|
|
9
|
+
|
|
10
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
11
|
+
|
|
12
|
+
var _default = (0, _configuration.ConfigurationSchema)('JBrowse1Connection', {
|
|
13
|
+
dataDirLocation: {
|
|
14
|
+
type: 'fileLocation',
|
|
15
|
+
defaultValue: {
|
|
16
|
+
uri: 'http://mysite.com/jbrowse/data/',
|
|
17
|
+
locationType: 'UriLocation'
|
|
18
|
+
},
|
|
19
|
+
description: 'the location of the JBrowse 1 data directory, often something like http://mysite.com/jbrowse/data/'
|
|
20
|
+
},
|
|
21
|
+
assemblyNames: {
|
|
22
|
+
description: 'name of the assembly the connection belongs to, should be a single entry',
|
|
23
|
+
type: 'stringArray',
|
|
24
|
+
defaultValue: []
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
baseConfiguration: _models.baseConnectionConfig
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "configSchema", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _configSchema["default"];
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "modelFactory", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _model["default"];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
var _model = _interopRequireDefault(require("./model"));
|
|
22
|
+
|
|
23
|
+
var _configSchema = _interopRequireDefault(require("./configSchema"));
|
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createFinalConfig = createFinalConfig;
|
|
9
|
+
exports.fetchConfigFile = fetchConfigFile;
|
|
10
|
+
exports.fetchJb1 = fetchJb1;
|
|
11
|
+
exports.parseJb1 = parseJb1;
|
|
12
|
+
|
|
13
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
14
|
+
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
|
|
17
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
18
|
+
|
|
19
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
20
|
+
|
|
21
|
+
var _io = require("@jbrowse/core/util/io");
|
|
22
|
+
|
|
23
|
+
var _jb1ConfigParse = require("./jb1ConfigParse");
|
|
24
|
+
|
|
25
|
+
var _util = require("./util");
|
|
26
|
+
|
|
27
|
+
function isUriLocation(location) {
|
|
28
|
+
return location.uri !== undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isLocalPathLocation(location) {
|
|
32
|
+
return location.localPath !== undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function fetchJb1() {
|
|
36
|
+
return _fetchJb.apply(this, arguments);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function _fetchJb() {
|
|
40
|
+
_fetchJb = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
41
|
+
var dataRoot,
|
|
42
|
+
baseConfig,
|
|
43
|
+
baseConfigRoot,
|
|
44
|
+
protocol,
|
|
45
|
+
dataRootReg,
|
|
46
|
+
dataRootLocation,
|
|
47
|
+
baseProtocol,
|
|
48
|
+
baseConfigLocation,
|
|
49
|
+
_newConfig,
|
|
50
|
+
_i3,
|
|
51
|
+
_arr,
|
|
52
|
+
conf,
|
|
53
|
+
fetchedConfig,
|
|
54
|
+
newConfig,
|
|
55
|
+
_args = arguments;
|
|
56
|
+
|
|
57
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
58
|
+
while (1) {
|
|
59
|
+
switch (_context.prev = _context.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
dataRoot = _args.length > 0 && _args[0] !== undefined ? _args[0] : {
|
|
62
|
+
uri: '',
|
|
63
|
+
locationType: 'UriLocation'
|
|
64
|
+
};
|
|
65
|
+
baseConfig = _args.length > 1 && _args[1] !== undefined ? _args[1] : {
|
|
66
|
+
include: ['{dataRoot}/trackList.json', '{dataRoot}/tracks.conf']
|
|
67
|
+
};
|
|
68
|
+
baseConfigRoot = _args.length > 2 && _args[2] !== undefined ? _args[2] : {
|
|
69
|
+
uri: '',
|
|
70
|
+
locationType: 'UriLocation'
|
|
71
|
+
};
|
|
72
|
+
protocol = 'uri' in dataRoot ? 'uri' : 'localPath';
|
|
73
|
+
dataRootReg = JSON.parse(JSON.stringify(dataRoot));
|
|
74
|
+
dataRootLocation = '';
|
|
75
|
+
|
|
76
|
+
if (isUriLocation(dataRoot)) {
|
|
77
|
+
dataRootLocation = dataRoot.uri;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (isLocalPathLocation(dataRoot)) {
|
|
81
|
+
dataRootLocation = dataRoot.localPath;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (dataRootLocation.endsWith('/')) {
|
|
85
|
+
dataRootReg[protocol] = dataRootLocation.slice(0, dataRootLocation.length - 1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!(isUriLocation(baseConfigRoot) && baseConfigRoot.uri || isLocalPathLocation(baseConfigRoot) && baseConfigRoot.localPath)) {
|
|
89
|
+
_context.next = 35;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
baseProtocol = 'uri' in baseConfigRoot ? 'uri' : 'localPath';
|
|
94
|
+
baseConfigLocation = '';
|
|
95
|
+
|
|
96
|
+
if (isUriLocation(baseConfigRoot)) {
|
|
97
|
+
baseConfigLocation = baseConfigRoot.uri;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (isLocalPathLocation(baseConfigRoot)) {
|
|
101
|
+
baseConfigLocation = baseConfigRoot.localPath;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (baseConfigLocation.endsWith('/')) {
|
|
105
|
+
baseConfigLocation = baseConfigLocation.slice(0, baseConfigLocation.length - 1);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_newConfig = {};
|
|
109
|
+
_i3 = 0, _arr = ['jbrowse.conf', 'jbrowse_conf.json'];
|
|
110
|
+
|
|
111
|
+
case 17:
|
|
112
|
+
if (!(_i3 < _arr.length)) {
|
|
113
|
+
_context.next = 33;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
conf = _arr[_i3];
|
|
118
|
+
fetchedConfig = null;
|
|
119
|
+
_context.prev = 20;
|
|
120
|
+
_context.next = 23;
|
|
121
|
+
return fetchConfigFile((0, _defineProperty2["default"])({}, baseProtocol, "".concat(baseConfigLocation, "/").concat(conf)));
|
|
122
|
+
|
|
123
|
+
case 23:
|
|
124
|
+
fetchedConfig = _context.sent;
|
|
125
|
+
_context.next = 29;
|
|
126
|
+
break;
|
|
127
|
+
|
|
128
|
+
case 26:
|
|
129
|
+
_context.prev = 26;
|
|
130
|
+
_context.t0 = _context["catch"](20);
|
|
131
|
+
console.error("tried to access ".concat(baseConfigLocation, "/").concat(conf, ", but failed"));
|
|
132
|
+
|
|
133
|
+
case 29:
|
|
134
|
+
_newConfig = mergeConfigs(_newConfig, fetchedConfig) || {};
|
|
135
|
+
|
|
136
|
+
case 30:
|
|
137
|
+
_i3++;
|
|
138
|
+
_context.next = 17;
|
|
139
|
+
break;
|
|
140
|
+
|
|
141
|
+
case 33:
|
|
142
|
+
if (dataRootReg[protocol]) {
|
|
143
|
+
_newConfig.dataRoot = dataRootReg[protocol];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return _context.abrupt("return", createFinalConfig(_newConfig));
|
|
147
|
+
|
|
148
|
+
case 35:
|
|
149
|
+
newConfig = (0, _jb1ConfigParse.regularizeConf)(baseConfig, window.location.href);
|
|
150
|
+
|
|
151
|
+
if (dataRootReg[protocol]) {
|
|
152
|
+
newConfig.dataRoot = dataRootReg[protocol];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return _context.abrupt("return", createFinalConfig(newConfig));
|
|
156
|
+
|
|
157
|
+
case 38:
|
|
158
|
+
case "end":
|
|
159
|
+
return _context.stop();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}, _callee, null, [[20, 26]]);
|
|
163
|
+
}));
|
|
164
|
+
return _fetchJb.apply(this, arguments);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function createFinalConfig(_x) {
|
|
168
|
+
return _createFinalConfig.apply(this, arguments);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function _createFinalConfig() {
|
|
172
|
+
_createFinalConfig = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(baseConfig) {
|
|
173
|
+
var defaults,
|
|
174
|
+
configWithDefaults,
|
|
175
|
+
finalConfig,
|
|
176
|
+
_args2 = arguments;
|
|
177
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
178
|
+
while (1) {
|
|
179
|
+
switch (_context2.prev = _context2.next) {
|
|
180
|
+
case 0:
|
|
181
|
+
defaults = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : configDefaults;
|
|
182
|
+
configWithDefaults = (0, _util.deepUpdate)((0, _util.clone)(defaults), baseConfig);
|
|
183
|
+
_context2.next = 4;
|
|
184
|
+
return loadIncludes(configWithDefaults);
|
|
185
|
+
|
|
186
|
+
case 4:
|
|
187
|
+
finalConfig = _context2.sent;
|
|
188
|
+
finalConfig = mergeConfigs(finalConfig, baseConfig) || finalConfig;
|
|
189
|
+
fillTemplates(finalConfig, finalConfig);
|
|
190
|
+
validateConfig(finalConfig);
|
|
191
|
+
return _context2.abrupt("return", finalConfig);
|
|
192
|
+
|
|
193
|
+
case 9:
|
|
194
|
+
case "end":
|
|
195
|
+
return _context2.stop();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, _callee2);
|
|
199
|
+
}));
|
|
200
|
+
return _createFinalConfig.apply(this, arguments);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function fetchConfigFile(_x2) {
|
|
204
|
+
return _fetchConfigFile.apply(this, arguments);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function _fetchConfigFile() {
|
|
208
|
+
_fetchConfigFile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(location) {
|
|
209
|
+
var result;
|
|
210
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
211
|
+
while (1) {
|
|
212
|
+
switch (_context3.prev = _context3.next) {
|
|
213
|
+
case 0:
|
|
214
|
+
_context3.next = 2;
|
|
215
|
+
return (0, _io.openLocation)(location).readFile('utf8');
|
|
216
|
+
|
|
217
|
+
case 2:
|
|
218
|
+
result = _context3.sent;
|
|
219
|
+
|
|
220
|
+
if (!isUriLocation(location)) {
|
|
221
|
+
_context3.next = 5;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return _context3.abrupt("return", parseJb1(result, location.uri));
|
|
226
|
+
|
|
227
|
+
case 5:
|
|
228
|
+
if (!isLocalPathLocation(location)) {
|
|
229
|
+
_context3.next = 7;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return _context3.abrupt("return", parseJb1(result, location.localPath));
|
|
234
|
+
|
|
235
|
+
case 7:
|
|
236
|
+
return _context3.abrupt("return", parseJb1(result));
|
|
237
|
+
|
|
238
|
+
case 8:
|
|
239
|
+
case "end":
|
|
240
|
+
return _context3.stop();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}, _callee3);
|
|
244
|
+
}));
|
|
245
|
+
return _fetchConfigFile.apply(this, arguments);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function parseJb1(config) {
|
|
249
|
+
var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
250
|
+
|
|
251
|
+
if (config.trim().startsWith('{')) {
|
|
252
|
+
return (0, _jb1ConfigParse.parseJB1Json)(config, url);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return (0, _jb1ConfigParse.parseJB1Conf)(config, url);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Merges config object b into a. Properties in b override those in a.
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
function mergeConfigs(a, b) {
|
|
263
|
+
if (b === null) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (a === null) {
|
|
268
|
+
a = {};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
for (var _i = 0, _Object$keys = Object.keys(b); _i < _Object$keys.length; _i++) {
|
|
272
|
+
var prop = _Object$keys[_i];
|
|
273
|
+
|
|
274
|
+
if (prop === 'tracks' && prop in a) {
|
|
275
|
+
var aTracks = a[prop] || [];
|
|
276
|
+
var bTracks = b[prop] || [];
|
|
277
|
+
|
|
278
|
+
if (Array.isArray(aTracks) && Array.isArray(bTracks)) {
|
|
279
|
+
a[prop] = mergeTrackConfigs(aTracks || [], bTracks || []);
|
|
280
|
+
} else {
|
|
281
|
+
throw new Error("Track config has not been properly regularized: ".concat(aTracks, " ").concat(bTracks));
|
|
282
|
+
}
|
|
283
|
+
} else if (!noRecursiveMerge(prop) && prop in a && // @ts-ignore
|
|
284
|
+
(0, _typeof2["default"])(b[prop]) === 'object' && // @ts-ignore
|
|
285
|
+
(0, _typeof2["default"])(a[prop]) === 'object') {
|
|
286
|
+
// @ts-ignore
|
|
287
|
+
a[prop] = (0, _util.deepUpdate)(a[prop], b[prop]);
|
|
288
|
+
} else if (prop === 'dataRoot') {
|
|
289
|
+
if (a[prop] === undefined || a[prop] === 'data' && b[prop] !== undefined) {
|
|
290
|
+
a[prop] = b[prop];
|
|
291
|
+
} // @ts-ignore
|
|
292
|
+
|
|
293
|
+
} else if (a[prop] === undefined || b[prop] !== undefined) {
|
|
294
|
+
// @ts-ignore
|
|
295
|
+
a[prop] = b[prop];
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return a;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Special-case merging of two `tracks` configuration arrays.
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
function mergeTrackConfigs(a, b) {
|
|
307
|
+
if (!b.length) {
|
|
308
|
+
return a;
|
|
309
|
+
} // index the tracks in `a` by track label
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
var aTracks = {};
|
|
313
|
+
a.forEach(function (t, i) {
|
|
314
|
+
t.index = i;
|
|
315
|
+
aTracks[t.label] = t;
|
|
316
|
+
});
|
|
317
|
+
b.forEach(function (bT) {
|
|
318
|
+
var aT = aTracks[bT.label];
|
|
319
|
+
|
|
320
|
+
if (aT) {
|
|
321
|
+
mergeConfigs(aT, bT);
|
|
322
|
+
} else {
|
|
323
|
+
a.push(bT);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
return a;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Recursively fetch, parse, and merge all the includes in the given config
|
|
330
|
+
* object. Calls the callback with the resulting configuration when finished.
|
|
331
|
+
* @param inputConfig - Config to load includes into
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
function loadIncludes(_x3) {
|
|
336
|
+
return _loadIncludes.apply(this, arguments);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function _loadIncludes() {
|
|
340
|
+
_loadIncludes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(inputConfig) {
|
|
341
|
+
var loadRecur, _loadRecur;
|
|
342
|
+
|
|
343
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
344
|
+
while (1) {
|
|
345
|
+
switch (_context6.prev = _context6.next) {
|
|
346
|
+
case 0:
|
|
347
|
+
_loadRecur = function _loadRecur3() {
|
|
348
|
+
_loadRecur = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(config, upstreamConf) {
|
|
349
|
+
var sourceUrl, newUpstreamConf, includes, loads, includedDataObjects;
|
|
350
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
351
|
+
while (1) {
|
|
352
|
+
switch (_context5.prev = _context5.next) {
|
|
353
|
+
case 0:
|
|
354
|
+
sourceUrl = config.sourceUrl || config.baseUrl;
|
|
355
|
+
|
|
356
|
+
if (sourceUrl) {
|
|
357
|
+
_context5.next = 3;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
throw new Error("Could not determine source URL: ".concat(JSON.stringify(config)));
|
|
362
|
+
|
|
363
|
+
case 3:
|
|
364
|
+
newUpstreamConf = mergeConfigs((0, _util.clone)(upstreamConf), config);
|
|
365
|
+
|
|
366
|
+
if (newUpstreamConf) {
|
|
367
|
+
_context5.next = 6;
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
throw new Error('Problem merging configs');
|
|
372
|
+
|
|
373
|
+
case 6:
|
|
374
|
+
includes = fillTemplates(regularizeIncludes(config.include || []), newUpstreamConf);
|
|
375
|
+
delete config.include;
|
|
376
|
+
loads = includes.map( /*#__PURE__*/function () {
|
|
377
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(include) {
|
|
378
|
+
var includedData;
|
|
379
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
380
|
+
while (1) {
|
|
381
|
+
switch (_context4.prev = _context4.next) {
|
|
382
|
+
case 0:
|
|
383
|
+
include.cacheBuster = inputConfig.cacheBuster;
|
|
384
|
+
_context4.next = 3;
|
|
385
|
+
return fetchConfigFile({
|
|
386
|
+
uri: new URL(include.url, sourceUrl).href,
|
|
387
|
+
locationType: 'UriLocation'
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
case 3:
|
|
391
|
+
includedData = _context4.sent;
|
|
392
|
+
return _context4.abrupt("return", loadRecur(includedData, newUpstreamConf));
|
|
393
|
+
|
|
394
|
+
case 5:
|
|
395
|
+
case "end":
|
|
396
|
+
return _context4.stop();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}, _callee4);
|
|
400
|
+
}));
|
|
401
|
+
|
|
402
|
+
return function (_x6) {
|
|
403
|
+
return _ref.apply(this, arguments);
|
|
404
|
+
};
|
|
405
|
+
}());
|
|
406
|
+
_context5.next = 11;
|
|
407
|
+
return Promise.all(loads);
|
|
408
|
+
|
|
409
|
+
case 11:
|
|
410
|
+
includedDataObjects = _context5.sent;
|
|
411
|
+
includedDataObjects.forEach(function (includedData) {
|
|
412
|
+
config = mergeConfigs(config, includedData) || config;
|
|
413
|
+
});
|
|
414
|
+
return _context5.abrupt("return", config);
|
|
415
|
+
|
|
416
|
+
case 14:
|
|
417
|
+
case "end":
|
|
418
|
+
return _context5.stop();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}, _callee5);
|
|
422
|
+
}));
|
|
423
|
+
return _loadRecur.apply(this, arguments);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
loadRecur = function _loadRecur2(_x4, _x5) {
|
|
427
|
+
return _loadRecur.apply(this, arguments);
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
inputConfig = (0, _util.clone)(inputConfig);
|
|
431
|
+
return _context6.abrupt("return", loadRecur(inputConfig, {}));
|
|
432
|
+
|
|
433
|
+
case 4:
|
|
434
|
+
case "end":
|
|
435
|
+
return _context6.stop();
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}, _callee6);
|
|
439
|
+
}));
|
|
440
|
+
return _loadIncludes.apply(this, arguments);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
function regularizeIncludes(includes) {
|
|
444
|
+
if (!includes) {
|
|
445
|
+
return [];
|
|
446
|
+
} // coerce include to an array
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
if (!Array.isArray(includes)) {
|
|
450
|
+
includes = [includes];
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
return includes.map(function (include) {
|
|
454
|
+
// coerce bare strings in the includes to URLs
|
|
455
|
+
if (typeof include === 'string') {
|
|
456
|
+
include = {
|
|
457
|
+
url: include
|
|
458
|
+
};
|
|
459
|
+
} // set defaults for format and version
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
if (!('format' in include)) {
|
|
463
|
+
include.format = include.url.endsWith('.conf') ? 'conf' : 'JB_json';
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (include.format === 'JB_json' && !('version' in include)) {
|
|
467
|
+
include.version = 1;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return include;
|
|
471
|
+
});
|
|
472
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unnecessary-type-constraint
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
function fillTemplates(subconfig, config) {
|
|
476
|
+
if (!subconfig) {
|
|
477
|
+
return subconfig;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (Array.isArray(subconfig)) {
|
|
481
|
+
for (var i = 0; i < subconfig.length; i += 1) {
|
|
482
|
+
subconfig[i] = fillTemplates(subconfig[i], config);
|
|
483
|
+
}
|
|
484
|
+
} else if ((0, _typeof2["default"])(subconfig) === 'object') {
|
|
485
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
486
|
+
var sub = subconfig;
|
|
487
|
+
|
|
488
|
+
for (var _i2 = 0, _Object$keys2 = Object.keys(sub); _i2 < _Object$keys2.length; _i2++) {
|
|
489
|
+
var name = _Object$keys2[_i2];
|
|
490
|
+
sub[name] = fillTemplates(sub[name], config);
|
|
491
|
+
}
|
|
492
|
+
} else if (typeof subconfig === 'string') {
|
|
493
|
+
// @ts-ignore
|
|
494
|
+
return (0, _util.fillTemplate)(subconfig, config);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
return subconfig;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* list of config properties that should not be recursively merged
|
|
501
|
+
* @param propName - name of config property
|
|
502
|
+
*/
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
function noRecursiveMerge(propName) {
|
|
506
|
+
return propName === 'datasets';
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
var configDefaults = {
|
|
510
|
+
tracks: [],
|
|
511
|
+
containerID: 'GenomeBrowser',
|
|
512
|
+
dataRoot: 'data',
|
|
513
|
+
show_tracklist: true,
|
|
514
|
+
show_nav: true,
|
|
515
|
+
show_menu: true,
|
|
516
|
+
show_overview: true,
|
|
517
|
+
show_fullviewlink: true,
|
|
518
|
+
update_browser_title: true,
|
|
519
|
+
updateBrowserURL: true,
|
|
520
|
+
refSeqs: '{dataRoot}/seq/refSeqs.json',
|
|
521
|
+
include: ['jbrowse.conf', 'jbrowse_conf.json'],
|
|
522
|
+
nameUrl: '{dataRoot}/names/root.json',
|
|
523
|
+
datasets: {
|
|
524
|
+
_DEFAULT_EXAMPLES: true,
|
|
525
|
+
volvox: {
|
|
526
|
+
url: '?data=sample_data/json/volvox',
|
|
527
|
+
name: 'Volvox Example'
|
|
528
|
+
},
|
|
529
|
+
modencode: {
|
|
530
|
+
url: '?data=sample_data/json/modencode',
|
|
531
|
+
name: 'MODEncode Example'
|
|
532
|
+
},
|
|
533
|
+
yeast: {
|
|
534
|
+
url: '?data=sample_data/json/yeast',
|
|
535
|
+
name: 'Yeast Example'
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
highlightSearchedRegions: false,
|
|
539
|
+
highResolutionMode: 'auto'
|
|
540
|
+
};
|
|
541
|
+
/**
|
|
542
|
+
* Examine the loaded and merged configuration for errors. Throws
|
|
543
|
+
* exceptions if it finds anything amiss.
|
|
544
|
+
* @returns nothing meaningful
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
function validateConfig(config) {
|
|
548
|
+
if (!config.tracks) {
|
|
549
|
+
config.tracks = [];
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
if (!config.baseUrl) {
|
|
553
|
+
throw new Error('Must provide a `baseUrl` in configuration');
|
|
554
|
+
}
|
|
555
|
+
}
|