@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,179 +1,191 @@
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.parseJB1Conf = parseJB1Conf;
9
- exports.parseJB1Json = parseJB1Json;
10
- exports.regularizeConf = regularizeConf;
11
-
12
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
-
14
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
- var _getValue = _interopRequireDefault(require("get-value"));
19
-
20
- var _setValue = _interopRequireDefault(require("set-value"));
21
-
22
- var _util = require("@jbrowse/core/util");
23
-
24
- var _util2 = require("./util");
25
-
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __read = (this && this.__read) || function (o, n) {
14
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
15
+ if (!m) return o;
16
+ var i = m.call(o), r, ar = [], e;
17
+ try {
18
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
19
+ }
20
+ catch (error) { e = { error: error }; }
21
+ finally {
22
+ try {
23
+ if (r && !r.done && (m = i["return"])) m.call(i);
24
+ }
25
+ finally { if (e) throw e.error; }
26
+ }
27
+ return ar;
28
+ };
29
+ var __values = (this && this.__values) || function(o) {
30
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
31
+ if (m) return m.call(o);
32
+ if (o && typeof o.length === "number") return {
33
+ next: function () {
34
+ if (o && i >= o.length) o = void 0;
35
+ return { value: o && o[i++], done: !o };
36
+ }
37
+ };
38
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
39
+ };
40
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
+ if (ar || !(i in from)) {
43
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
+ ar[i] = from[i];
45
+ }
46
+ }
47
+ return to.concat(ar || Array.prototype.slice.call(from));
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ exports.regularizeConf = exports.parseJB1Conf = exports.parseJB1Json = void 0;
54
+ /* eslint no-cond-assign: ["error", "except-parens"] */
55
+ var get_value_1 = __importDefault(require("get-value"));
56
+ var set_value_1 = __importDefault(require("set-value"));
57
+ var util_1 = require("@jbrowse/core/util");
58
+ var util_2 = require("./util");
30
59
  function parseJB1Json(config, url) {
31
- if (typeof config === 'string') {
60
+ if (typeof config === 'string') {
61
+ var parsedConf = void 0;
62
+ try {
63
+ parsedConf = JSON.parse(config);
64
+ }
65
+ catch (error) {
66
+ throw new Error("".concat(error, " when parsing configuration."));
67
+ }
68
+ return regularizeConf(parsedConf, url);
69
+ }
70
+ return regularizeConf(config, url);
71
+ }
72
+ exports.parseJB1Json = parseJB1Json;
73
+ function parseJB1Conf(config, url) {
32
74
  var parsedConf;
33
-
34
75
  try {
35
- parsedConf = JSON.parse(config);
36
- } catch (error) {
37
- throw new Error("".concat(error, " when parsing configuration."));
76
+ parsedConf = parse(config, url);
77
+ }
78
+ catch (error) {
79
+ throw new Error("".concat(error, " when parsing configuration."));
38
80
  }
39
-
40
81
  return regularizeConf(parsedConf, url);
41
- }
42
-
43
- return regularizeConf(config, url);
44
- }
45
-
46
- function parseJB1Conf(config, url) {
47
- var parsedConf;
48
-
49
- try {
50
- parsedConf = parse(config, url);
51
- } catch (error) {
52
- throw new Error("".concat(error, " when parsing configuration."));
53
- }
54
-
55
- return regularizeConf(parsedConf, url);
56
82
  }
57
-
83
+ exports.parseJB1Conf = parseJB1Conf;
58
84
  function isAlwaysArray(varName) {
59
- if (varName === 'include') {
60
- return true;
61
- }
62
-
63
- return false;
85
+ if (varName === 'include') {
86
+ return true;
87
+ }
88
+ return false;
64
89
  }
65
-
66
90
  function parse(text, url) {
67
- var section = [];
68
- var keyPath;
69
- var operation;
70
- var value;
71
- var data = {
72
- tracks: {}
73
- };
74
- var lineNumber;
75
-
76
- function recordVal() {
77
- if (value !== undefined) {
78
- var parsedValue;
79
-
80
- try {
81
- // parse json
82
- var match = value.match(/^json:(.+)/i);
83
-
84
- if (match) {
85
- parsedValue = JSON.parse(match[1]);
86
- } // parse numbers if it looks numeric
87
- else if (/^[+-]?[\d.,]+([eE][-+]?\d+)?$/.test(value)) {
88
- parsedValue = parseFloat(value.replace(/,/g, ''));
89
- } else {
90
- parsedValue = value;
91
+ var section = [];
92
+ var keyPath;
93
+ var operation;
94
+ var value;
95
+ var data = { tracks: {} };
96
+ var lineNumber;
97
+ function recordVal() {
98
+ if (value !== undefined) {
99
+ var parsedValue = void 0;
100
+ try {
101
+ // parse json
102
+ var match = value.match(/^json:(.+)/i);
103
+ if (match) {
104
+ parsedValue = JSON.parse(match[1]);
105
+ }
106
+ // parse numbers if it looks numeric
107
+ else if (/^[+-]?[\d.,]+([eE][-+]?\d+)?$/.test(value)) {
108
+ parsedValue = parseFloat(value.replace(/,/g, ''));
109
+ }
110
+ else {
111
+ parsedValue = value;
112
+ }
113
+ if (!keyPath) {
114
+ throw new Error("Error parsing in section ".concat(section.join(' - ')));
115
+ }
116
+ var path = section.concat(keyPath).join('.');
117
+ if (operation === '+=') {
118
+ var existing = (0, get_value_1.default)(data, path);
119
+ if (existing) {
120
+ if (!Array.isArray(existing)) {
121
+ existing = [existing];
122
+ }
123
+ }
124
+ else {
125
+ existing = [];
126
+ }
127
+ existing.push(parsedValue);
128
+ parsedValue = existing;
129
+ }
130
+ if (parsedValue === 'true') {
131
+ parsedValue = true;
132
+ }
133
+ if (parsedValue === 'false') {
134
+ parsedValue = false;
135
+ }
136
+ (0, set_value_1.default)(data, path, parsedValue);
137
+ }
138
+ catch (e) {
139
+ throw new Error("syntax error".concat(url ? " in ".concat(url) : '').concat(lineNumber ? " at line ".concat(lineNumber - 1) : ''));
140
+ }
91
141
  }
92
-
93
- if (!keyPath) {
94
- throw new Error("Error parsing in section ".concat(section.join(' - ')));
142
+ }
143
+ text.split('\n').forEach(function (textLine, i) {
144
+ var _a;
145
+ lineNumber = i + 1;
146
+ var line = textLine.replace(/^\s*#.+/, '');
147
+ // new section
148
+ var match;
149
+ if ((match = line.match(/^\s*\[([^\]]+)/))) {
150
+ // new section
151
+ recordVal();
152
+ keyPath = undefined;
153
+ value = undefined;
154
+ section = match[1].trim().split(/\s*\.\s*/);
155
+ if (section.length === 1 && section[0].toLowerCase() === 'general') {
156
+ section = [];
157
+ }
95
158
  }
96
-
97
- var path = section.concat(keyPath).join('.');
98
-
99
- if (operation === '+=') {
100
- var existing = (0, _getValue.default)(data, path);
101
-
102
- if (existing) {
103
- if (!Array.isArray(existing)) {
104
- existing = [existing];
159
+ // new value
160
+ else if ((match = line.match(value === undefined ? /^([^+=]+)(\+?=)(.*)/ : /^(\S[^+=]+)(\+?=)(.*)/))) {
161
+ recordVal();
162
+ keyPath = match[1].trim().split(/\s*\.\s*/);
163
+ _a = __read(match, 3), operation = _a[2];
164
+ if (isAlwaysArray(section.concat(keyPath).join('.'))) {
165
+ operation = '+=';
105
166
  }
106
- } else {
107
- existing = [];
108
- }
109
-
110
- existing.push(parsedValue);
111
- parsedValue = existing;
167
+ value = match[3].trim();
112
168
  }
113
-
114
- if (parsedValue === 'true') {
115
- parsedValue = true;
169
+ // add to existing array value
170
+ else if (keyPath !== undefined &&
171
+ (match = line.match(/^\s{0,4}\+\s*(.+)/))) {
172
+ recordVal();
173
+ operation = '+=';
174
+ value = match[1].trim();
116
175
  }
117
-
118
- if (parsedValue === 'false') {
119
- parsedValue = false;
176
+ // add to existing value
177
+ else if (value !== undefined && (match = line.match(/^\s+(\S.*)/))) {
178
+ value += value.length ? " ".concat(match[1].trim()) : match[1].trim();
120
179
  }
121
-
122
- (0, _setValue.default)(data, path, parsedValue);
123
- } catch (e) {
124
- throw new Error("syntax error".concat(url ? " in ".concat(url) : '').concat(lineNumber ? " at line ".concat(lineNumber - 1) : ''));
125
- }
126
- }
127
- }
128
-
129
- text.split('\n').forEach(function (textLine, i) {
130
- lineNumber = i + 1;
131
- var line = textLine.replace(/^\s*#.+/, ''); // new section
132
-
133
- var match;
134
-
135
- if (match = line.match(/^\s*\[([^\]]+)/)) {
136
- // new section
137
- recordVal();
138
- keyPath = undefined;
139
- value = undefined;
140
- section = match[1].trim().split(/\s*\.\s*/);
141
-
142
- if (section.length === 1 && section[0].toLowerCase() === 'general') {
143
- section = [];
144
- }
145
- } // new value
146
- else if (match = line.match(value === undefined ? /^([^+=]+)(\+?=)(.*)/ : /^(\S[^+=]+)(\+?=)(.*)/)) {
147
- recordVal();
148
- keyPath = match[1].trim().split(/\s*\.\s*/);
149
- var _match = match;
150
-
151
- var _match2 = (0, _slicedToArray2.default)(_match, 3);
152
-
153
- operation = _match2[2];
154
-
155
- if (isAlwaysArray(section.concat(keyPath).join('.'))) {
156
- operation = '+=';
157
- }
158
-
159
- value = match[3].trim();
160
- } // add to existing array value
161
- else if (keyPath !== undefined && (match = line.match(/^\s{0,4}\+\s*(.+)/))) {
162
- recordVal();
163
- operation = '+=';
164
- value = match[1].trim();
165
- } // add to existing value
166
- else if (value !== undefined && (match = line.match(/^\s+(\S.*)/))) {
167
- value += value.length ? " ".concat(match[1].trim()) : match[1].trim();
168
- } // done with last value
169
- else {
170
- recordVal();
171
- keyPath = undefined;
172
- value = undefined;
173
- }
174
- });
175
- recordVal();
176
- return data;
180
+ // done with last value
181
+ else {
182
+ recordVal();
183
+ keyPath = undefined;
184
+ value = undefined;
185
+ }
186
+ });
187
+ recordVal();
188
+ return data;
177
189
  }
178
190
  /**
179
191
  * Applies defaults and any other necessary tweaks to the loaded configuration.
@@ -182,295 +194,262 @@ function parse(text, url) {
182
194
  * @param url - URL of the config file
183
195
  * @returns the same object it was passed
184
196
  */
185
-
186
-
187
197
  function regularizeConf(conf, url) {
188
- // if tracks is not an array, convert it to one
189
- if (conf.tracks && !Array.isArray(conf.tracks)) {
190
- // if it's a single track config, wrap it in an arrayref
191
- if ((0, _util2.isTrack)(conf.tracks)) {
192
- conf.tracks = [conf.tracks];
193
- } // otherwise, coerce it to an array
194
- else {
195
- var tracks = [];
196
-
197
- for (var _i = 0, _Object$keys = Object.keys(conf.tracks); _i < _Object$keys.length; _i++) {
198
- var label = _Object$keys[_i];
199
- var track = conf.tracks[label];
200
-
201
- if ((0, _util2.isTrack)(track)) {
202
- tracks.push(track);
203
- } else {
204
- tracks.push(_objectSpread({
205
- label: label
206
- }, track));
198
+ var e_1, _a, e_2, _b;
199
+ // if tracks is not an array, convert it to one
200
+ if (conf.tracks && !Array.isArray(conf.tracks)) {
201
+ // if it's a single track config, wrap it in an arrayref
202
+ if ((0, util_2.isTrack)(conf.tracks)) {
203
+ conf.tracks = [conf.tracks];
204
+ }
205
+ // otherwise, coerce it to an array
206
+ else {
207
+ var tracks = [];
208
+ try {
209
+ for (var _c = __values(Object.keys(conf.tracks)), _d = _c.next(); !_d.done; _d = _c.next()) {
210
+ var label = _d.value;
211
+ var track = conf.tracks[label];
212
+ if ((0, util_2.isTrack)(track)) {
213
+ tracks.push(track);
214
+ }
215
+ else {
216
+ tracks.push(__assign({ label: label }, track));
217
+ }
218
+ }
219
+ }
220
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
221
+ finally {
222
+ try {
223
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
224
+ }
225
+ finally { if (e_1) throw e_1.error; }
226
+ }
227
+ conf.tracks = tracks;
228
+ }
229
+ }
230
+ // regularize trackMetadata.sources
231
+ var meta = conf.trackMetadata;
232
+ if (meta && meta.sources) {
233
+ // if it's a single source config, wrap it in an arrayref
234
+ if (typeof meta.sources === 'string') {
235
+ meta.sources = [meta.sources];
207
236
  }
208
- }
209
-
210
- conf.tracks = tracks;
211
- }
212
- } // regularize trackMetadata.sources
213
-
214
-
215
- var meta = conf.trackMetadata;
216
-
217
- if (meta && meta.sources) {
218
- // if it's a single source config, wrap it in an arrayref
219
- if (typeof meta.sources === 'string') {
220
- meta.sources = [meta.sources];
221
- }
222
-
223
- if ((0, _util2.isSource)(meta.sources)) {
224
- meta.sources = [meta.sources];
225
- }
226
-
227
- if (!Array.isArray(meta.sources)) {
228
- var sources = [];
229
-
230
- for (var _i2 = 0, _Object$keys2 = Object.keys(meta.sources); _i2 < _Object$keys2.length; _i2++) {
231
- var name = _Object$keys2[_i2];
232
- var source = meta.sources[name];
233
-
234
- if (!('name' in source)) {
235
- source.name = name;
237
+ if ((0, util_2.isSource)(meta.sources)) {
238
+ meta.sources = [meta.sources];
239
+ }
240
+ if (!Array.isArray(meta.sources)) {
241
+ var sources = [];
242
+ try {
243
+ for (var _e = __values(Object.keys(meta.sources)), _f = _e.next(); !_f.done; _f = _e.next()) {
244
+ var name_1 = _f.value;
245
+ var source = meta.sources[name_1];
246
+ if (!('name' in source)) {
247
+ source.name = name_1;
248
+ }
249
+ sources.push(source);
250
+ }
251
+ }
252
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
253
+ finally {
254
+ try {
255
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
256
+ }
257
+ finally { if (e_2) throw e_2.error; }
258
+ }
259
+ meta.sources = sources;
260
+ }
261
+ // coerce any string source defs to be URLs, and try to detect their types
262
+ meta.sources = meta.sources.map(function (sourceDef) {
263
+ if (typeof sourceDef === 'string') {
264
+ var newSourceDef = { url: sourceDef };
265
+ var typeMatch = sourceDef.match(/\.(\w+)$/);
266
+ if (typeMatch) {
267
+ newSourceDef.type = typeMatch[1].toLowerCase();
268
+ }
269
+ return newSourceDef;
270
+ }
271
+ return sourceDef;
272
+ });
273
+ }
274
+ conf.sourceUrl = conf.sourceUrl || url;
275
+ if (conf.sourceUrl.startsWith('/')) {
276
+ conf.sourceUrl = new URL(conf.sourceUrl, window.location.href).href;
277
+ }
278
+ conf.baseUrl = conf.baseUrl || new URL('.', conf.sourceUrl).href;
279
+ if (conf.baseUrl.length && !conf.baseUrl.endsWith('/')) {
280
+ conf.baseUrl += '/';
281
+ }
282
+ if (conf.sourceUrl) {
283
+ // set a default baseUrl in each of the track and store confs, and the names
284
+ // conf, if needed
285
+ var addBase = [];
286
+ if (conf.tracks) {
287
+ addBase.push.apply(addBase, __spreadArray([], __read(conf.tracks), false));
236
288
  }
237
-
238
- sources.push(source);
239
- }
240
-
241
- meta.sources = sources;
242
- } // coerce any string source defs to be URLs, and try to detect their types
243
-
244
-
245
- meta.sources = meta.sources.map(function (sourceDef) {
246
- if (typeof sourceDef === 'string') {
247
- var newSourceDef = {
248
- url: sourceDef
249
- };
250
- var typeMatch = sourceDef.match(/\.(\w+)$/);
251
-
252
- if (typeMatch) {
253
- newSourceDef.type = typeMatch[1].toLowerCase();
289
+ if (conf.stores) {
290
+ addBase.push.apply(addBase, __spreadArray([], __read(Object.values(conf.stores)), false));
291
+ }
292
+ if (conf.names) {
293
+ addBase.push(conf.names);
294
+ }
295
+ addBase.forEach(function (t) {
296
+ if (!t.baseUrl) {
297
+ t.baseUrl = conf.baseUrl || '/';
298
+ }
299
+ });
300
+ // resolve the refSeqs and nameUrl if present
301
+ if (conf.refSeqs && typeof conf.refSeqs === 'string') {
302
+ conf.refSeqs = new URL(conf.refSeqs, conf.sourceUrl).href;
303
+ }
304
+ if (conf.nameUrl) {
305
+ conf.nameUrl = new URL(conf.nameUrl, conf.sourceUrl).href;
306
+ }
307
+ }
308
+ conf.stores = conf.stores || {};
309
+ (conf.tracks || []).forEach(function (trackConfig) {
310
+ // if there is a `config` subpart, just copy its keys in to the top-level
311
+ // config
312
+ if (trackConfig.config) {
313
+ var c = trackConfig.config;
314
+ delete trackConfig.config;
315
+ trackConfig = __assign(__assign({}, c), trackConfig);
316
+ }
317
+ // skip if it's a new-style track def
318
+ if (trackConfig.store) {
319
+ return;
320
+ }
321
+ var trackClassName;
322
+ if (trackConfig.type === 'FeatureTrack') {
323
+ trackClassName = 'JBrowse/View/Track/HTMLFeatures';
324
+ }
325
+ else if (trackConfig.type === 'ImageTrack') {
326
+ trackClassName = 'JBrowse/View/Track/FixedImage';
327
+ }
328
+ else if (trackConfig.type === 'ImageTrack.Wiggle') {
329
+ trackClassName = 'JBrowse/View/Track/FixedImage/Wiggle';
330
+ }
331
+ else if (trackConfig.type === 'SequenceTrack') {
332
+ trackClassName = 'JBrowse/View/Track/Sequence';
333
+ }
334
+ else {
335
+ trackClassName = regularizeClass('JBrowse/View/Track', trackConfig.type);
336
+ }
337
+ trackConfig.type = trackClassName;
338
+ synthesizeTrackStoreConfig(conf, trackConfig);
339
+ if (trackConfig.histograms) {
340
+ if (!trackConfig.histograms.baseUrl) {
341
+ trackConfig.histograms.baseUrl = trackConfig.baseUrl;
342
+ }
343
+ synthesizeTrackStoreConfig(conf, trackConfig.histograms);
254
344
  }
255
-
256
- return newSourceDef;
257
- }
258
-
259
- return sourceDef;
260
345
  });
261
- }
262
-
263
- conf.sourceUrl = conf.sourceUrl || url;
264
-
265
- if (conf.sourceUrl.startsWith('/')) {
266
- conf.sourceUrl = new URL(conf.sourceUrl, window.location.href).href;
267
- }
268
-
269
- conf.baseUrl = conf.baseUrl || new URL('.', conf.sourceUrl).href;
270
-
271
- if (conf.baseUrl.length && !conf.baseUrl.endsWith('/')) {
272
- conf.baseUrl += '/';
273
- }
274
-
275
- if (conf.sourceUrl) {
276
- // set a default baseUrl in each of the track and store confs, and the names
277
- // conf, if needed
278
- var addBase = [];
279
-
280
- if (conf.tracks) {
281
- addBase.push.apply(addBase, (0, _toConsumableArray2.default)(conf.tracks));
282
- }
283
-
284
- if (conf.stores) {
285
- addBase.push.apply(addBase, (0, _toConsumableArray2.default)(Object.values(conf.stores)));
286
- }
287
-
288
- if (conf.names) {
289
- addBase.push(conf.names);
290
- }
291
-
292
- addBase.forEach(function (t) {
293
- if (!t.baseUrl) {
294
- t.baseUrl = conf.baseUrl || '/';
295
- }
296
- }); // resolve the refSeqs and nameUrl if present
297
-
298
- if (conf.refSeqs && typeof conf.refSeqs === 'string') {
299
- conf.refSeqs = new URL(conf.refSeqs, conf.sourceUrl).href;
300
- }
301
-
302
- if (conf.nameUrl) {
303
- conf.nameUrl = new URL(conf.nameUrl, conf.sourceUrl).href;
304
- }
305
- }
306
-
307
- conf.stores = conf.stores || {};
308
- (conf.tracks || []).forEach(function (trackConfig) {
309
- // if there is a `config` subpart, just copy its keys in to the top-level
310
- // config
311
- if (trackConfig.config) {
312
- var c = trackConfig.config;
313
- delete trackConfig.config;
314
- trackConfig = _objectSpread(_objectSpread({}, c), trackConfig);
315
- } // skip if it's a new-style track def
316
-
317
-
318
- if (trackConfig.store) {
319
- return;
320
- }
321
-
322
- var trackClassName;
323
-
324
- if (trackConfig.type === 'FeatureTrack') {
325
- trackClassName = 'JBrowse/View/Track/HTMLFeatures';
326
- } else if (trackConfig.type === 'ImageTrack') {
327
- trackClassName = 'JBrowse/View/Track/FixedImage';
328
- } else if (trackConfig.type === 'ImageTrack.Wiggle') {
329
- trackClassName = 'JBrowse/View/Track/FixedImage/Wiggle';
330
- } else if (trackConfig.type === 'SequenceTrack') {
331
- trackClassName = 'JBrowse/View/Track/Sequence';
332
- } else {
333
- trackClassName = regularizeClass('JBrowse/View/Track', trackConfig.type);
334
- }
335
-
336
- trackConfig.type = trackClassName;
337
- synthesizeTrackStoreConfig(conf, trackConfig);
338
-
339
- if (trackConfig.histograms) {
340
- if (!trackConfig.histograms.baseUrl) {
341
- trackConfig.histograms.baseUrl = trackConfig.baseUrl;
342
- }
343
-
344
- synthesizeTrackStoreConfig(conf, trackConfig.histograms);
345
- }
346
- });
347
- return conf;
346
+ return conf;
348
347
  }
348
+ exports.regularizeConf = regularizeConf;
349
349
  /**
350
350
  * prefix class name with `root` if it contains no slashes
351
351
  * @param root - Prefix root
352
352
  * @param className - class name
353
353
  */
354
-
355
-
356
354
  function regularizeClass(root, className) {
357
- if (!className) {
358
- return '';
359
- }
360
-
361
- if (!className.includes('/')) {
362
- className = "".concat(root, "/").concat(className);
363
- }
364
-
365
- className = className.replace(/^\//, '');
366
- return className;
355
+ if (!className) {
356
+ return '';
357
+ }
358
+ if (!className.includes('/')) {
359
+ className = "".concat(root, "/").concat(className);
360
+ }
361
+ className = className.replace(/^\//, '');
362
+ return className;
367
363
  }
368
-
369
364
  function guessStoreClass(trackConfig, urlTemplate) {
370
- if (!trackConfig) {
365
+ if (!trackConfig) {
366
+ return '';
367
+ }
368
+ if (trackConfig.type && trackConfig.type.includes('/FixedImage')) {
369
+ return "JBrowse/Store/TiledImage/Fixed".concat(trackConfig.backendVersion === 0 ? '_v0' : '');
370
+ }
371
+ if (/\.jsonz?$/i.test(urlTemplate)) {
372
+ return "JBrowse/Store/SeqFeature/NCList".concat(trackConfig.backendVersion === 0 ? '_v0' : '');
373
+ }
374
+ if (/\.bam$/i.test(urlTemplate)) {
375
+ return 'JBrowse/Store/SeqFeature/BAM';
376
+ }
377
+ if (/\.cram$/i.test(urlTemplate)) {
378
+ return 'JBrowse/Store/SeqFeature/CRAM';
379
+ }
380
+ if (/\.gff3?$/i.test(urlTemplate)) {
381
+ return 'JBrowse/Store/SeqFeature/GFF3';
382
+ }
383
+ if (/\.bed$/i.test(urlTemplate)) {
384
+ return 'JBrowse/Store/SeqFeature/BED';
385
+ }
386
+ if (/\.vcf.b?gz$/i.test(urlTemplate)) {
387
+ return 'JBrowse/Store/SeqFeature/VCFTabix';
388
+ }
389
+ if (/\.gff3?.b?gz$/i.test(urlTemplate)) {
390
+ return 'JBrowse/Store/SeqFeature/GFF3Tabix';
391
+ }
392
+ if (/\.bed.b?gz$/i.test(urlTemplate)) {
393
+ return 'JBrowse/Store/SeqFeature/BEDTabix';
394
+ }
395
+ if (/\.(bw|bigwig)$/i.test(urlTemplate)) {
396
+ return 'JBrowse/Store/SeqFeature/BigWig';
397
+ }
398
+ if (/\.(bb|bigbed)$/i.test(urlTemplate)) {
399
+ return 'JBrowse/Store/SeqFeature/BigBed';
400
+ }
401
+ if (/\.(fa|fasta)$/i.test(urlTemplate)) {
402
+ return 'JBrowse/Store/SeqFeature/IndexedFasta';
403
+ }
404
+ if (/\.(fa|fasta)\.b?gz$/i.test(urlTemplate)) {
405
+ return 'JBrowse/Store/SeqFeature/BgzipIndexedFasta';
406
+ }
407
+ if (/\.2bit$/i.test(urlTemplate)) {
408
+ return 'JBrowse/Store/SeqFeature/TwoBit';
409
+ }
410
+ if (trackConfig.type && trackConfig.type.endsWith('/Sequence')) {
411
+ return 'JBrowse/Store/Sequence/StaticChunked';
412
+ }
371
413
  return '';
372
- }
373
-
374
- if (trackConfig.type && trackConfig.type.includes('/FixedImage')) {
375
- return "JBrowse/Store/TiledImage/Fixed".concat(trackConfig.backendVersion === 0 ? '_v0' : '');
376
- }
377
-
378
- if (/\.jsonz?$/i.test(urlTemplate)) {
379
- return "JBrowse/Store/SeqFeature/NCList".concat(trackConfig.backendVersion === 0 ? '_v0' : '');
380
- }
381
-
382
- if (/\.bam$/i.test(urlTemplate)) {
383
- return 'JBrowse/Store/SeqFeature/BAM';
384
- }
385
-
386
- if (/\.cram$/i.test(urlTemplate)) {
387
- return 'JBrowse/Store/SeqFeature/CRAM';
388
- }
389
-
390
- if (/\.gff3?$/i.test(urlTemplate)) {
391
- return 'JBrowse/Store/SeqFeature/GFF3';
392
- }
393
-
394
- if (/\.bed$/i.test(urlTemplate)) {
395
- return 'JBrowse/Store/SeqFeature/BED';
396
- }
397
-
398
- if (/\.vcf.b?gz$/i.test(urlTemplate)) {
399
- return 'JBrowse/Store/SeqFeature/VCFTabix';
400
- }
401
-
402
- if (/\.gff3?.b?gz$/i.test(urlTemplate)) {
403
- return 'JBrowse/Store/SeqFeature/GFF3Tabix';
404
- }
405
-
406
- if (/\.bed.b?gz$/i.test(urlTemplate)) {
407
- return 'JBrowse/Store/SeqFeature/BEDTabix';
408
- }
409
-
410
- if (/\.(bw|bigwig)$/i.test(urlTemplate)) {
411
- return 'JBrowse/Store/SeqFeature/BigWig';
412
- }
413
-
414
- if (/\.(bb|bigbed)$/i.test(urlTemplate)) {
415
- return 'JBrowse/Store/SeqFeature/BigBed';
416
- }
417
-
418
- if (/\.(fa|fasta)$/i.test(urlTemplate)) {
419
- return 'JBrowse/Store/SeqFeature/IndexedFasta';
420
- }
421
-
422
- if (/\.(fa|fasta)\.b?gz$/i.test(urlTemplate)) {
423
- return 'JBrowse/Store/SeqFeature/BgzipIndexedFasta';
424
- }
425
-
426
- if (/\.2bit$/i.test(urlTemplate)) {
427
- return 'JBrowse/Store/SeqFeature/TwoBit';
428
- }
429
-
430
- if (trackConfig.type && trackConfig.type.endsWith('/Sequence')) {
431
- return 'JBrowse/Store/Sequence/StaticChunked';
432
- }
433
-
434
- return '';
435
414
  }
436
-
437
415
  function synthesizeTrackStoreConfig(mainConf, trackConfig) {
438
- // figure out what data store class to use with the track, applying some
439
- // defaults if it is not explicit in the configuration
440
- var _trackConfig$urlTempl = trackConfig.urlTemplate,
441
- urlTemplate = _trackConfig$urlTempl === void 0 ? '' : _trackConfig$urlTempl;
442
- var storeClass;
443
-
444
- if (trackConfig.storeClass) {
445
- storeClass = regularizeClass('JBrowse/Store', trackConfig.storeClass);
446
- } else {
447
- storeClass = guessStoreClass(trackConfig, urlTemplate);
448
- }
449
-
450
- if (!storeClass) {
451
- console.warn("Unable to determine an appropriate data store to use with track '".concat(trackConfig.label, "', please explicitly specify a storeClass in the configuration."));
452
- return;
453
- } // synthesize a separate store conf
454
-
455
-
456
- var storeConf = _objectSpread(_objectSpread({}, trackConfig), {}, {
457
- type: storeClass
458
- }); // if this is the first sequence store we see, and we have no refseqs store
459
- // defined explicitly, make this the refseqs store.
460
-
461
-
462
- 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)) {
463
- storeConf.name = 'refseqs';
464
- } else {
465
- storeConf.name = "store".concat((0, _util.objectHash)(storeConf));
466
- } // record it
467
-
468
-
469
- if (!mainConf.stores) {
470
- mainConf.stores = {};
471
- }
472
-
473
- mainConf.stores[storeConf.name] = storeConf; // connect it to the track conf
474
-
475
- trackConfig.store = storeConf.name;
476
- }
416
+ // figure out what data store class to use with the track, applying some
417
+ // defaults if it is not explicit in the configuration
418
+ var _a = trackConfig.urlTemplate, urlTemplate = _a === void 0 ? '' : _a;
419
+ var storeClass;
420
+ if (trackConfig.storeClass) {
421
+ storeClass = regularizeClass('JBrowse/Store', trackConfig.storeClass);
422
+ }
423
+ else {
424
+ storeClass = guessStoreClass(trackConfig, urlTemplate);
425
+ }
426
+ if (!storeClass) {
427
+ console.warn("Unable to determine an appropriate data store to use with track '".concat(trackConfig.label, "', please explicitly specify a storeClass in the configuration."));
428
+ return;
429
+ }
430
+ // synthesize a separate store conf
431
+ var storeConf = __assign(__assign({}, trackConfig), { type: storeClass });
432
+ // if this is the first sequence store we see, and we have no refseqs store
433
+ // defined explicitly, make this the refseqs store.
434
+ if ((storeClass === 'JBrowse/Store/Sequence/StaticChunked' ||
435
+ storeClass === 'JBrowse/Store/Sequence/IndexedFasta' ||
436
+ storeClass === 'JBrowse/Store/SeqFeature/IndexedFasta' ||
437
+ storeClass === 'JBrowse/Store/SeqFeature/BgzipIndexedFasta' ||
438
+ storeClass === 'JBrowse/Store/SeqFeature/TwoBit' ||
439
+ storeClass === 'JBrowse/Store/Sequence/TwoBit' ||
440
+ trackConfig.useAsRefSeqStore) &&
441
+ !(mainConf.stores && mainConf.stores.refseqs)) {
442
+ storeConf.name = 'refseqs';
443
+ }
444
+ else {
445
+ storeConf.name = "store".concat((0, util_1.objectHash)(storeConf));
446
+ }
447
+ // record it
448
+ if (!mainConf.stores) {
449
+ mainConf.stores = {};
450
+ }
451
+ mainConf.stores[storeConf.name] = storeConf;
452
+ // connect it to the track conf
453
+ trackConfig.store = storeConf.name;
454
+ }
455
+ //# sourceMappingURL=jb1ConfigParse.js.map