@jbrowse/plugin-legacy-jbrowse 1.7.9 → 2.0.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.
Files changed (91) hide show
  1. package/dist/JBrowse1Connection/configSchema.js +18 -28
  2. package/dist/JBrowse1Connection/configSchema.js.map +1 -0
  3. package/dist/JBrowse1Connection/index.js +10 -22
  4. package/dist/JBrowse1Connection/index.js.map +1 -0
  5. package/dist/JBrowse1Connection/jb1ConfigLoad.js +387 -501
  6. package/dist/JBrowse1Connection/jb1ConfigLoad.js.map +1 -0
  7. package/dist/JBrowse1Connection/jb1ConfigParse.js +414 -435
  8. package/dist/JBrowse1Connection/jb1ConfigParse.js.map +1 -0
  9. package/dist/JBrowse1Connection/jb1ToJb2.js +405 -546
  10. package/dist/JBrowse1Connection/jb1ToJb2.js.map +1 -0
  11. package/dist/JBrowse1Connection/model.js +49 -57
  12. package/dist/JBrowse1Connection/model.js.map +1 -0
  13. package/dist/JBrowse1Connection/types.js +2 -4
  14. package/dist/JBrowse1Connection/types.js.map +1 -0
  15. package/dist/JBrowse1Connection/util.js +123 -130
  16. package/dist/JBrowse1Connection/util.js.map +1 -0
  17. package/dist/JBrowse1TextSeachAdapter/HttpMap.js +181 -326
  18. package/dist/JBrowse1TextSeachAdapter/HttpMap.js.map +1 -0
  19. package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.js +164 -185
  20. package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.js.map +1 -0
  21. package/dist/JBrowse1TextSeachAdapter/configSchema.js +20 -33
  22. package/dist/JBrowse1TextSeachAdapter/configSchema.js.map +1 -0
  23. package/dist/JBrowse1TextSeachAdapter/index.js +10 -22
  24. package/dist/JBrowse1TextSeachAdapter/index.js.map +1 -0
  25. package/dist/NCListAdapter/NCListAdapter.js +164 -224
  26. package/dist/NCListAdapter/NCListAdapter.js.map +1 -0
  27. package/dist/NCListAdapter/NCListFeature.js +68 -125
  28. package/dist/NCListAdapter/NCListFeature.js.map +1 -0
  29. package/dist/NCListAdapter/configSchema.js +17 -26
  30. package/dist/NCListAdapter/configSchema.js.map +1 -0
  31. package/dist/NCListAdapter/index.js +8 -14
  32. package/dist/NCListAdapter/index.js.map +1 -0
  33. package/dist/index.js +97 -116
  34. package/dist/index.js.map +1 -0
  35. package/esm/JBrowse1Connection/configSchema.d.ts +2 -0
  36. package/esm/JBrowse1Connection/configSchema.js +18 -0
  37. package/esm/JBrowse1Connection/configSchema.js.map +1 -0
  38. package/esm/JBrowse1Connection/index.d.ts +2 -0
  39. package/esm/JBrowse1Connection/index.js +3 -0
  40. package/esm/JBrowse1Connection/index.js.map +1 -0
  41. package/esm/JBrowse1Connection/jb1ConfigLoad.d.ts +36 -0
  42. package/esm/JBrowse1Connection/jb1ConfigLoad.js +281 -0
  43. package/esm/JBrowse1Connection/jb1ConfigLoad.js.map +1 -0
  44. package/esm/JBrowse1Connection/jb1ConfigParse.d.ts +11 -0
  45. package/esm/JBrowse1Connection/jb1ConfigParse.js +377 -0
  46. package/esm/JBrowse1Connection/jb1ConfigParse.js.map +1 -0
  47. package/esm/JBrowse1Connection/jb1ToJb2.d.ts +49 -0
  48. package/esm/JBrowse1Connection/jb1ToJb2.js +424 -0
  49. package/esm/JBrowse1Connection/jb1ToJb2.js.map +1 -0
  50. package/esm/JBrowse1Connection/model.d.ts +15 -0
  51. package/esm/JBrowse1Connection/model.js +44 -0
  52. package/esm/JBrowse1Connection/model.js.map +1 -0
  53. package/esm/JBrowse1Connection/types.d.ts +91 -0
  54. package/esm/JBrowse1Connection/types.js +2 -0
  55. package/esm/JBrowse1Connection/types.js.map +1 -0
  56. package/esm/JBrowse1Connection/util.d.ts +26 -0
  57. package/esm/JBrowse1Connection/util.js +136 -0
  58. package/esm/JBrowse1Connection/util.js.map +1 -0
  59. package/esm/JBrowse1TextSeachAdapter/HttpMap.d.ts +39 -0
  60. package/esm/JBrowse1TextSeachAdapter/HttpMap.js +89 -0
  61. package/esm/JBrowse1TextSeachAdapter/HttpMap.js.map +1 -0
  62. package/esm/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.d.ts +33 -0
  63. package/esm/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.js +67 -0
  64. package/esm/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.js.map +1 -0
  65. package/esm/JBrowse1TextSeachAdapter/configSchema.d.ts +2 -0
  66. package/esm/JBrowse1TextSeachAdapter/configSchema.js +20 -0
  67. package/esm/JBrowse1TextSeachAdapter/configSchema.js.map +1 -0
  68. package/esm/JBrowse1TextSeachAdapter/index.d.ts +2 -0
  69. package/esm/JBrowse1TextSeachAdapter/index.js +3 -0
  70. package/esm/JBrowse1TextSeachAdapter/index.js.map +1 -0
  71. package/esm/NCListAdapter/NCListAdapter.d.ts +31 -0
  72. package/esm/NCListAdapter/NCListAdapter.js +62 -0
  73. package/esm/NCListAdapter/NCListAdapter.js.map +1 -0
  74. package/esm/NCListAdapter/NCListFeature.d.ts +31 -0
  75. package/esm/NCListAdapter/NCListFeature.js +78 -0
  76. package/esm/NCListAdapter/NCListFeature.js.map +1 -0
  77. package/esm/NCListAdapter/configSchema.d.ts +2 -0
  78. package/esm/NCListAdapter/configSchema.js +16 -0
  79. package/esm/NCListAdapter/configSchema.js.map +1 -0
  80. package/esm/NCListAdapter/index.d.ts +1 -0
  81. package/esm/NCListAdapter/index.js +2 -0
  82. package/esm/NCListAdapter/index.js.map +1 -0
  83. package/esm/index.d.ts +6 -0
  84. package/esm/index.js +50 -0
  85. package/esm/index.js.map +1 -0
  86. package/package.json +15 -6
  87. package/dist/JBrowse1TextSeachAdapter/HttpMap.test.js +0 -118
  88. package/dist/JBrowse1TextSeachAdapter/JBrowse1TextSearchAdapter.test.js +0 -98
  89. package/dist/NCListAdapter/NCListAdapter.test.js +0 -108
  90. package/dist/declare.d.js +0 -1
  91. package/dist/index.test.js +0 -44
@@ -1,555 +1,441 @@
1
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
-
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __values = (this && this.__values) || function(o) {
39
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
40
+ if (m) return m.call(o);
41
+ if (o && typeof o.length === "number") return {
42
+ next: function () {
43
+ if (o && i >= o.length) o = void 0;
44
+ return { value: o && o[i++], done: !o };
45
+ }
46
+ };
47
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.parseJb1 = exports.fetchConfigFile = exports.createFinalConfig = exports.fetchJb1 = void 0;
51
+ var io_1 = require("@jbrowse/core/util/io");
52
+ var jb1ConfigParse_1 = require("./jb1ConfigParse");
53
+ var util_1 = require("./util");
27
54
  function isUriLocation(location) {
28
- return location.uri !== undefined;
55
+ return location.uri !== undefined;
29
56
  }
30
-
31
57
  function isLocalPathLocation(location) {
32
- return location.localPath !== undefined;
58
+ return location.localPath !== undefined;
33
59
  }
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];
60
+ function fetchJb1(dataRoot, baseConfig, baseConfigRoot) {
61
+ if (dataRoot === void 0) { dataRoot = { uri: '', locationType: 'UriLocation' }; }
62
+ if (baseConfig === void 0) { baseConfig = {
63
+ include: ['{dataRoot}/trackList.json', '{dataRoot}/tracks.conf'],
64
+ }; }
65
+ if (baseConfigRoot === void 0) { baseConfigRoot = { uri: '', locationType: 'UriLocation' }; }
66
+ return __awaiter(this, void 0, void 0, function () {
67
+ var protocol, dataRootReg, dataRootLocation, baseProtocol, baseConfigLocation, newConfig_1, _a, _b, conf, fetchedConfig, error_1, e_1_1, newConfig;
68
+ var e_1, _c, _d;
69
+ return __generator(this, function (_e) {
70
+ switch (_e.label) {
71
+ case 0:
72
+ protocol = 'uri' in dataRoot ? 'uri' : 'localPath';
73
+ dataRootReg = JSON.parse(JSON.stringify(dataRoot));
74
+ dataRootLocation = '';
75
+ if (isUriLocation(dataRoot)) {
76
+ dataRootLocation = dataRoot.uri;
77
+ }
78
+ if (isLocalPathLocation(dataRoot)) {
79
+ dataRootLocation = dataRoot.localPath;
80
+ }
81
+ if (dataRootLocation.endsWith('/')) {
82
+ dataRootReg[protocol] = dataRootLocation.slice(0, dataRootLocation.length - 1);
83
+ }
84
+ if (!((isUriLocation(baseConfigRoot) && baseConfigRoot.uri) ||
85
+ (isLocalPathLocation(baseConfigRoot) && baseConfigRoot.localPath))) return [3 /*break*/, 12];
86
+ baseProtocol = 'uri' in baseConfigRoot ? 'uri' : 'localPath';
87
+ baseConfigLocation = '';
88
+ if (isUriLocation(baseConfigRoot)) {
89
+ baseConfigLocation = baseConfigRoot.uri;
90
+ }
91
+ if (isLocalPathLocation(baseConfigRoot)) {
92
+ baseConfigLocation = baseConfigRoot.localPath;
93
+ }
94
+ if (baseConfigLocation.endsWith('/')) {
95
+ baseConfigLocation = baseConfigLocation.slice(0, baseConfigLocation.length - 1);
96
+ }
97
+ newConfig_1 = {};
98
+ _e.label = 1;
99
+ case 1:
100
+ _e.trys.push([1, 9, 10, 11]);
101
+ _a = __values(['jbrowse.conf', 'jbrowse_conf.json']), _b = _a.next();
102
+ _e.label = 2;
103
+ case 2:
104
+ if (!!_b.done) return [3 /*break*/, 8];
105
+ conf = _b.value;
106
+ fetchedConfig = null;
107
+ _e.label = 3;
108
+ case 3:
109
+ _e.trys.push([3, 5, , 6]);
110
+ return [4 /*yield*/, fetchConfigFile((_d = {},
111
+ _d[baseProtocol] = "".concat(baseConfigLocation, "/").concat(conf),
112
+ _d))];
113
+ case 4:
114
+ // @ts-ignore
115
+ fetchedConfig = _e.sent();
116
+ return [3 /*break*/, 6];
117
+ case 5:
118
+ error_1 = _e.sent();
119
+ console.error("tried to access ".concat(baseConfigLocation, "/").concat(conf, ", but failed"));
120
+ return [3 /*break*/, 6];
121
+ case 6:
122
+ newConfig_1 = mergeConfigs(newConfig_1, fetchedConfig) || {};
123
+ _e.label = 7;
124
+ case 7:
125
+ _b = _a.next();
126
+ return [3 /*break*/, 2];
127
+ case 8: return [3 /*break*/, 11];
128
+ case 9:
129
+ e_1_1 = _e.sent();
130
+ e_1 = { error: e_1_1 };
131
+ return [3 /*break*/, 11];
132
+ case 10:
133
+ try {
134
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
135
+ }
136
+ finally { if (e_1) throw e_1.error; }
137
+ return [7 /*endfinally*/];
138
+ case 11:
139
+ if (dataRootReg[protocol]) {
140
+ newConfig_1.dataRoot = dataRootReg[protocol];
141
+ }
142
+ return [2 /*return*/, createFinalConfig(newConfig_1)];
143
+ case 12:
144
+ newConfig = (0, jb1ConfigParse_1.regularizeConf)(baseConfig, window.location.href);
145
+ if (dataRootReg[protocol]) {
146
+ newConfig.dataRoot = dataRootReg[protocol];
147
+ }
148
+ return [2 /*return*/, createFinalConfig(newConfig)];
153
149
  }
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);
150
+ });
151
+ });
205
152
  }
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;
153
+ exports.fetchJb1 = fetchJb1;
154
+ function createFinalConfig(baseConfig, defaults) {
155
+ if (defaults === void 0) { defaults = configDefaults; }
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ var configWithDefaults, finalConfig;
158
+ return __generator(this, function (_a) {
159
+ switch (_a.label) {
160
+ case 0:
161
+ configWithDefaults = (0, util_1.deepUpdate)((0, util_1.clone)(defaults), baseConfig);
162
+ return [4 /*yield*/, loadIncludes(configWithDefaults)];
163
+ case 1:
164
+ finalConfig = _a.sent();
165
+ finalConfig = mergeConfigs(finalConfig, baseConfig) || finalConfig;
166
+ fillTemplates(finalConfig, finalConfig);
167
+ validateConfig(finalConfig);
168
+ return [2 /*return*/, finalConfig];
223
169
  }
224
-
225
- return _context3.abrupt("return", parseJb1(result, location.uri));
226
-
227
- case 5:
228
- if (!isLocalPathLocation(location)) {
229
- _context3.next = 7;
230
- break;
170
+ });
171
+ });
172
+ }
173
+ exports.createFinalConfig = createFinalConfig;
174
+ function fetchConfigFile(location) {
175
+ return __awaiter(this, void 0, void 0, function () {
176
+ var result;
177
+ return __generator(this, function (_a) {
178
+ switch (_a.label) {
179
+ case 0: return [4 /*yield*/, (0, io_1.openLocation)(location).readFile('utf8')];
180
+ case 1:
181
+ result = _a.sent();
182
+ if (isUriLocation(location)) {
183
+ return [2 /*return*/, parseJb1(result, location.uri)];
184
+ }
185
+ if (isLocalPathLocation(location)) {
186
+ return [2 /*return*/, parseJb1(result, location.localPath)];
187
+ }
188
+ return [2 /*return*/, parseJb1(result)];
231
189
  }
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);
190
+ });
191
+ });
246
192
  }
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);
193
+ exports.fetchConfigFile = fetchConfigFile;
194
+ function parseJb1(config, url) {
195
+ if (url === void 0) { url = ''; }
196
+ if (config.trim().startsWith('{')) {
197
+ return (0, jb1ConfigParse_1.parseJB1Json)(config, url);
198
+ }
199
+ return (0, jb1ConfigParse_1.parseJB1Conf)(config, url);
256
200
  }
201
+ exports.parseJb1 = parseJb1;
257
202
  /**
258
203
  * Merges config object b into a. Properties in b override those in a.
259
204
  */
260
-
261
-
262
205
  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];
206
+ var e_2, _a;
207
+ if (b === null) {
208
+ return null;
296
209
  }
297
- }
298
-
299
- return a;
210
+ if (a === null) {
211
+ a = {};
212
+ }
213
+ try {
214
+ for (var _b = __values(Object.keys(b)), _c = _b.next(); !_c.done; _c = _b.next()) {
215
+ var prop = _c.value;
216
+ if (prop === 'tracks' && prop in a) {
217
+ var aTracks = a[prop] || [];
218
+ var bTracks = b[prop] || [];
219
+ if (Array.isArray(aTracks) && Array.isArray(bTracks)) {
220
+ a[prop] = mergeTrackConfigs(aTracks || [], bTracks || []);
221
+ }
222
+ else {
223
+ throw new Error("Track config has not been properly regularized: ".concat(aTracks, " ").concat(bTracks));
224
+ }
225
+ }
226
+ else if (!noRecursiveMerge(prop) &&
227
+ prop in a &&
228
+ // @ts-ignore
229
+ typeof b[prop] === 'object' &&
230
+ // @ts-ignore
231
+ typeof a[prop] === 'object') {
232
+ // @ts-ignore
233
+ a[prop] = (0, util_1.deepUpdate)(a[prop], b[prop]);
234
+ }
235
+ else if (prop === 'dataRoot') {
236
+ if (a[prop] === undefined ||
237
+ (a[prop] === 'data' && b[prop] !== undefined)) {
238
+ a[prop] = b[prop];
239
+ }
240
+ // @ts-ignore
241
+ }
242
+ else if (a[prop] === undefined || b[prop] !== undefined) {
243
+ // @ts-ignore
244
+ a[prop] = b[prop];
245
+ }
246
+ }
247
+ }
248
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
249
+ finally {
250
+ try {
251
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
252
+ }
253
+ finally { if (e_2) throw e_2.error; }
254
+ }
255
+ return a;
300
256
  }
301
257
  /**
302
258
  * Special-case merging of two `tracks` configuration arrays.
303
259
  */
304
-
305
-
306
260
  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);
261
+ if (!b.length) {
262
+ return a;
324
263
  }
325
- });
326
- return a;
264
+ // index the tracks in `a` by track label
265
+ var aTracks = {};
266
+ a.forEach(function (t, i) {
267
+ t.index = i;
268
+ aTracks[t.label] = t;
269
+ });
270
+ b.forEach(function (bT) {
271
+ var aT = aTracks[bT.label];
272
+ if (aT) {
273
+ mergeConfigs(aT, bT);
274
+ }
275
+ else {
276
+ a.push(bT);
277
+ }
278
+ });
279
+ return a;
327
280
  }
328
281
  /**
329
282
  * Recursively fetch, parse, and merge all the includes in the given config
330
283
  * object. Calls the callback with the resulting configuration when finished.
331
284
  * @param inputConfig - Config to load includes into
332
285
  */
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) {
286
+ function loadIncludes(inputConfig) {
287
+ return __awaiter(this, void 0, void 0, function () {
288
+ function loadRecur(config, upstreamConf) {
289
+ return __awaiter(this, void 0, void 0, function () {
349
290
  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();
291
+ var _this = this;
292
+ return __generator(this, function (_a) {
293
+ switch (_a.label) {
294
+ case 0:
295
+ sourceUrl = config.sourceUrl || config.baseUrl;
296
+ if (!sourceUrl) {
297
+ throw new Error("Could not determine source URL: ".concat(JSON.stringify(config)));
298
+ }
299
+ newUpstreamConf = mergeConfigs((0, util_1.clone)(upstreamConf), config);
300
+ if (!newUpstreamConf) {
301
+ throw new Error('Problem merging configs');
302
+ }
303
+ includes = fillTemplates(regularizeIncludes(config.include || []), newUpstreamConf);
304
+ delete config.include;
305
+ loads = includes.map(function (include) { return __awaiter(_this, void 0, void 0, function () {
306
+ var includedData;
307
+ return __generator(this, function (_a) {
308
+ switch (_a.label) {
309
+ case 0:
310
+ include.cacheBuster = inputConfig.cacheBuster;
311
+ return [4 /*yield*/, fetchConfigFile({
312
+ uri: new URL(include.url, sourceUrl).href,
313
+ locationType: 'UriLocation',
314
+ })];
315
+ case 1:
316
+ includedData = _a.sent();
317
+ return [2 /*return*/, loadRecur(includedData, newUpstreamConf)];
318
+ }
319
+ });
320
+ }); });
321
+ return [4 /*yield*/, Promise.all(loads)];
322
+ case 1:
323
+ includedDataObjects = _a.sent();
324
+ includedDataObjects.forEach(function (includedData) {
325
+ config = mergeConfigs(config, includedData) || config;
326
+ });
327
+ return [2 /*return*/, config];
419
328
  }
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();
329
+ });
330
+ });
436
331
  }
437
- }
438
- }, _callee6);
439
- }));
440
- return _loadIncludes.apply(this, arguments);
332
+ return __generator(this, function (_a) {
333
+ inputConfig = (0, util_1.clone)(inputConfig);
334
+ return [2 /*return*/, loadRecur(inputConfig, {})];
335
+ });
336
+ });
441
337
  }
442
-
443
338
  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';
339
+ if (!includes) {
340
+ return [];
464
341
  }
465
-
466
- if (include.format === 'JB_json' && !('version' in include)) {
467
- include.version = 1;
342
+ // coerce include to an array
343
+ if (!Array.isArray(includes)) {
344
+ includes = [includes];
468
345
  }
469
-
470
- return include;
471
- });
472
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unnecessary-type-constraint
473
-
474
-
346
+ return includes.map(function (include) {
347
+ // coerce bare strings in the includes to URLs
348
+ if (typeof include === 'string') {
349
+ include = { url: include };
350
+ }
351
+ // set defaults for format and version
352
+ if (!('format' in include)) {
353
+ include.format = include.url.endsWith('.conf') ? 'conf' : 'JB_json';
354
+ }
355
+ if (include.format === 'JB_json' && !('version' in include)) {
356
+ include.version = 1;
357
+ }
358
+ return include;
359
+ });
360
+ }
361
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unnecessary-type-constraint
475
362
  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);
363
+ var e_3, _a;
364
+ if (!subconfig) {
365
+ return subconfig;
483
366
  }
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);
367
+ if (Array.isArray(subconfig)) {
368
+ for (var i = 0; i < subconfig.length; i += 1) {
369
+ subconfig[i] = fillTemplates(subconfig[i], config);
370
+ }
491
371
  }
492
- } else if (typeof subconfig === 'string') {
493
- // @ts-ignore
494
- return (0, _util.fillTemplate)(subconfig, config);
495
- }
496
-
497
- return subconfig;
372
+ else if (typeof subconfig === 'object') {
373
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
374
+ var sub = subconfig;
375
+ try {
376
+ for (var _b = __values(Object.keys(sub)), _c = _b.next(); !_c.done; _c = _b.next()) {
377
+ var name_1 = _c.value;
378
+ sub[name_1] = fillTemplates(sub[name_1], config);
379
+ }
380
+ }
381
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
382
+ finally {
383
+ try {
384
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
385
+ }
386
+ finally { if (e_3) throw e_3.error; }
387
+ }
388
+ }
389
+ else if (typeof subconfig === 'string') {
390
+ // @ts-ignore
391
+ return (0, util_1.fillTemplate)(subconfig, config);
392
+ }
393
+ return subconfig;
498
394
  }
499
395
  /**
500
396
  * list of config properties that should not be recursively merged
501
397
  * @param propName - name of config property
502
398
  */
503
-
504
-
505
399
  function noRecursiveMerge(propName) {
506
- return propName === 'datasets';
400
+ return propName === 'datasets';
507
401
  }
508
-
509
402
  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'
403
+ tracks: [],
404
+ containerID: 'GenomeBrowser',
405
+ dataRoot: 'data',
406
+ show_tracklist: true,
407
+ show_nav: true,
408
+ show_menu: true,
409
+ show_overview: true,
410
+ show_fullviewlink: true,
411
+ update_browser_title: true,
412
+ updateBrowserURL: true,
413
+ refSeqs: '{dataRoot}/seq/refSeqs.json',
414
+ include: ['jbrowse.conf', 'jbrowse_conf.json'],
415
+ nameUrl: '{dataRoot}/names/root.json',
416
+ datasets: {
417
+ _DEFAULT_EXAMPLES: true,
418
+ volvox: { url: '?data=sample_data/json/volvox', name: 'Volvox Example' },
419
+ modencode: {
420
+ url: '?data=sample_data/json/modencode',
421
+ name: 'MODEncode Example',
422
+ },
423
+ yeast: { url: '?data=sample_data/json/yeast', name: 'Yeast Example' },
532
424
  },
533
- yeast: {
534
- url: '?data=sample_data/json/yeast',
535
- name: 'Yeast Example'
536
- }
537
- },
538
- highlightSearchedRegions: false,
539
- highResolutionMode: 'auto'
425
+ highlightSearchedRegions: false,
426
+ highResolutionMode: 'auto',
540
427
  };
541
428
  /**
542
429
  * Examine the loaded and merged configuration for errors. Throws
543
430
  * exceptions if it finds anything amiss.
544
431
  * @returns nothing meaningful
545
432
  */
546
-
547
433
  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
- }
434
+ if (!config.tracks) {
435
+ config.tracks = [];
436
+ }
437
+ if (!config.baseUrl) {
438
+ throw new Error('Must provide a `baseUrl` in configuration');
439
+ }
440
+ }
441
+ //# sourceMappingURL=jb1ConfigLoad.js.map