@jbrowse/core 3.6.4 → 3.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.
Files changed (63) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail/CoreDetails.js +1 -1
  2. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceContents.d.ts +1 -1
  3. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceContents.js +31 -33
  4. package/BaseFeatureWidget/SequenceFeatureDetails/SequenceFeatureDetails.js +15 -7
  5. package/BaseFeatureWidget/SequenceFeatureDetails/consts.d.ts +6 -0
  6. package/BaseFeatureWidget/SequenceFeatureDetails/consts.js +9 -0
  7. package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceDialog.d.ts +1 -1
  8. package/BaseFeatureWidget/SequenceFeatureDetails/dialogs/SequenceDialog.js +17 -7
  9. package/BaseFeatureWidget/SequenceFeatureDetails/model.d.ts +6 -3
  10. package/BaseFeatureWidget/SequenceFeatureDetails/model.js +1 -1
  11. package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/CDNASequence.js +4 -3
  12. package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/CDSSequence.js +2 -1
  13. package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/GenomicSequence.js +4 -3
  14. package/BaseFeatureWidget/SequenceFeatureDetails/seqtypes/ProteinSequence.js +11 -10
  15. package/BaseFeatureWidget/SequenceFeatureDetails/useSequenceData.d.ts +13 -0
  16. package/BaseFeatureWidget/SequenceFeatureDetails/useSequenceData.js +67 -0
  17. package/BaseFeatureWidget/SequenceFeatureDetails/util.d.ts +2 -9
  18. package/BaseFeatureWidget/SequenceFeatureDetails/util.js +36 -39
  19. package/BaseFeatureWidget/stateModelFactory.d.ts +4 -4
  20. package/BaseFeatureWidget/util.d.ts +5 -2
  21. package/BaseFeatureWidget/util.js +41 -12
  22. package/PluginLoader.js +1 -1
  23. package/assemblyManager/assembly.d.ts +1 -0
  24. package/assemblyManager/assembly.js +3 -0
  25. package/assemblyManager/assemblyManager.d.ts +8 -0
  26. package/assemblyManager/assemblyManager.js +4 -0
  27. package/configuration/configurationSchema.js +1 -1
  28. package/data_adapters/BaseAdapter/BaseFeatureDataAdapter.js +2 -2
  29. package/package.json +3 -4
  30. package/tsconfig.build.tsbuildinfo +1 -1
  31. package/ui/BaseTooltip.d.ts +1 -1
  32. package/ui/CascadingMenu.js +33 -4
  33. package/ui/ConfirmDialog.d.ts +10 -0
  34. package/ui/ConfirmDialog.js +18 -0
  35. package/ui/EditableTypography.js +1 -8
  36. package/ui/LoadingEllipses.d.ts +2 -1
  37. package/ui/LoadingEllipses.js +1 -1
  38. package/ui/Menu.d.ts +1 -0
  39. package/ui/Menu.js +2 -2
  40. package/ui/SanitizedHTML.js +13 -10
  41. package/util/aborting.js +1 -1
  42. package/util/cluster.js +17 -11
  43. package/util/color/index.d.ts +1 -0
  44. package/util/color/index.js +8 -0
  45. package/util/compositeMap.d.ts +2 -2
  46. package/util/convertCodingSequenceToPeptides.d.ts +6 -0
  47. package/util/convertCodingSequenceToPeptides.js +12 -0
  48. package/util/fetchSeq.d.ts +8 -0
  49. package/util/fetchSeq.js +27 -0
  50. package/util/flatbush/index.d.ts +25 -0
  51. package/util/flatbush/index.js +362 -0
  52. package/util/flatqueue/index.d.ts +11 -0
  53. package/util/flatqueue/index.js +66 -0
  54. package/util/index.js +18 -12
  55. package/util/jexl.js +1 -0
  56. package/util/layouts/PrecomputedLayout.d.ts +3 -1
  57. package/util/layouts/PrecomputedLayout.js +23 -14
  58. package/util/tracks.js +1 -1
  59. package/util/types/index.d.ts +2 -2
  60. package/util/useFeatureSequence.d.ts +19 -0
  61. package/util/useFeatureSequence.js +90 -0
  62. package/BaseFeatureWidget/SequenceFeatureDetails/hooks.d.ts +0 -10
  63. package/BaseFeatureWidget/SequenceFeatureDetails/hooks.js +0 -65
@@ -0,0 +1,362 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const flatqueue_1 = __importDefault(require("../flatqueue"));
7
+ const ARRAY_TYPES = [
8
+ Int8Array,
9
+ Uint8Array,
10
+ Uint8ClampedArray,
11
+ Int16Array,
12
+ Uint16Array,
13
+ Int32Array,
14
+ Uint32Array,
15
+ Float32Array,
16
+ Float64Array,
17
+ ];
18
+ const VERSION = 3;
19
+ class Flatbush {
20
+ static from(data, byteOffset = 0) {
21
+ if (byteOffset % 8 !== 0) {
22
+ throw new Error('byteOffset must be 8-byte aligned.');
23
+ }
24
+ if ((data === null || data === void 0 ? void 0 : data.byteLength) === undefined || data.buffer) {
25
+ throw new Error('Data must be an instance of ArrayBuffer or SharedArrayBuffer.');
26
+ }
27
+ const [magic, versionAndType] = new Uint8Array(data, byteOffset + 0, 2);
28
+ if (magic !== 0xfb) {
29
+ throw new Error('Data does not appear to be in a Flatbush format.');
30
+ }
31
+ const version = versionAndType >> 4;
32
+ if (version !== VERSION) {
33
+ throw new Error(`Got v${version} data when expected v${VERSION}.`);
34
+ }
35
+ const ArrayType = ARRAY_TYPES[versionAndType & 0x0f];
36
+ if (!ArrayType) {
37
+ throw new Error('Unrecognized array type.');
38
+ }
39
+ const [nodeSize] = new Uint16Array(data, byteOffset + 2, 1);
40
+ const [numItems] = new Uint32Array(data, byteOffset + 4, 1);
41
+ return new Flatbush(numItems, nodeSize, ArrayType, undefined, data, byteOffset);
42
+ }
43
+ constructor(numItems, nodeSize = 16, ArrayType = Float64Array, ArrayBufferType = ArrayBuffer, data, byteOffset = 0) {
44
+ if (numItems === undefined) {
45
+ throw new Error('Missing required argument: numItems.');
46
+ }
47
+ if (isNaN(numItems) || numItems <= 0) {
48
+ throw new Error(`Unexpected numItems value: ${numItems}.`);
49
+ }
50
+ this.numItems = +numItems;
51
+ this.nodeSize = Math.min(Math.max(+nodeSize, 2), 65535);
52
+ this.byteOffset = byteOffset;
53
+ let n = numItems;
54
+ let numNodes = n;
55
+ this._levelBounds = [n * 4];
56
+ do {
57
+ n = Math.ceil(n / this.nodeSize);
58
+ numNodes += n;
59
+ this._levelBounds.push(numNodes * 4);
60
+ } while (n !== 1);
61
+ this.ArrayType = ArrayType;
62
+ this.IndexArrayType = numNodes < 16384 ? Uint16Array : Uint32Array;
63
+ const arrayTypeIndex = ARRAY_TYPES.indexOf(ArrayType);
64
+ const nodesByteSize = numNodes * 4 * ArrayType.BYTES_PER_ELEMENT;
65
+ if (arrayTypeIndex === -1) {
66
+ throw new Error(`Unexpected typed array class: ${ArrayType}.`);
67
+ }
68
+ if (data) {
69
+ this.data = data;
70
+ this._boxes = new ArrayType(data, byteOffset + 8, numNodes * 4);
71
+ this._indices = new this.IndexArrayType(data, byteOffset + 8 + nodesByteSize, numNodes);
72
+ this._pos = numNodes * 4;
73
+ this.minX = this._boxes[this._pos - 4];
74
+ this.minY = this._boxes[this._pos - 3];
75
+ this.maxX = this._boxes[this._pos - 2];
76
+ this.maxY = this._boxes[this._pos - 1];
77
+ }
78
+ else {
79
+ const data = (this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT));
80
+ this._boxes = new ArrayType(data, 8, numNodes * 4);
81
+ this._indices = new this.IndexArrayType(data, 8 + nodesByteSize, numNodes);
82
+ this._pos = 0;
83
+ this.minX = Infinity;
84
+ this.minY = Infinity;
85
+ this.maxX = -Infinity;
86
+ this.maxY = -Infinity;
87
+ new Uint8Array(data, 0, 2).set([0xfb, (VERSION << 4) + arrayTypeIndex]);
88
+ new Uint16Array(data, 2, 1)[0] = nodeSize;
89
+ new Uint32Array(data, 4, 1)[0] = numItems;
90
+ }
91
+ this._queue = new flatqueue_1.default();
92
+ }
93
+ add(minX, minY, maxX = minX, maxY = minY) {
94
+ const index = this._pos >> 2;
95
+ const boxes = this._boxes;
96
+ this._indices[index] = index;
97
+ boxes[this._pos++] = minX;
98
+ boxes[this._pos++] = minY;
99
+ boxes[this._pos++] = maxX;
100
+ boxes[this._pos++] = maxY;
101
+ if (minX < this.minX) {
102
+ this.minX = minX;
103
+ }
104
+ if (minY < this.minY) {
105
+ this.minY = minY;
106
+ }
107
+ if (maxX > this.maxX) {
108
+ this.maxX = maxX;
109
+ }
110
+ if (maxY > this.maxY) {
111
+ this.maxY = maxY;
112
+ }
113
+ return index;
114
+ }
115
+ finish() {
116
+ if (this._pos >> 2 !== this.numItems) {
117
+ throw new Error(`Added ${this._pos >> 2} items when expected ${this.numItems}.`);
118
+ }
119
+ const boxes = this._boxes;
120
+ if (this.numItems <= this.nodeSize) {
121
+ boxes[this._pos++] = this.minX;
122
+ boxes[this._pos++] = this.minY;
123
+ boxes[this._pos++] = this.maxX;
124
+ boxes[this._pos++] = this.maxY;
125
+ return;
126
+ }
127
+ const width = this.maxX - this.minX || 1;
128
+ const height = this.maxY - this.minY || 1;
129
+ const hilbertValues = new Uint32Array(this.numItems);
130
+ const hilbertMax = (1 << 16) - 1;
131
+ for (let i = 0, pos = 0; i < this.numItems; i++) {
132
+ const minX = boxes[pos++];
133
+ const minY = boxes[pos++];
134
+ const maxX = boxes[pos++];
135
+ const maxY = boxes[pos++];
136
+ const x = Math.floor((hilbertMax * ((minX + maxX) / 2 - this.minX)) / width);
137
+ const y = Math.floor((hilbertMax * ((minY + maxY) / 2 - this.minY)) / height);
138
+ hilbertValues[i] = hilbert(x, y);
139
+ }
140
+ sort(hilbertValues, boxes, this._indices, 0, this.numItems - 1, this.nodeSize);
141
+ for (let i = 0, pos = 0; i < this._levelBounds.length - 1; i++) {
142
+ const end = this._levelBounds[i];
143
+ while (pos < end) {
144
+ const nodeIndex = pos;
145
+ let nodeMinX = boxes[pos++];
146
+ let nodeMinY = boxes[pos++];
147
+ let nodeMaxX = boxes[pos++];
148
+ let nodeMaxY = boxes[pos++];
149
+ for (let j = 1; j < this.nodeSize && pos < end; j++) {
150
+ nodeMinX = Math.min(nodeMinX, boxes[pos++]);
151
+ nodeMinY = Math.min(nodeMinY, boxes[pos++]);
152
+ nodeMaxX = Math.max(nodeMaxX, boxes[pos++]);
153
+ nodeMaxY = Math.max(nodeMaxY, boxes[pos++]);
154
+ }
155
+ this._indices[this._pos >> 2] = nodeIndex;
156
+ boxes[this._pos++] = nodeMinX;
157
+ boxes[this._pos++] = nodeMinY;
158
+ boxes[this._pos++] = nodeMaxX;
159
+ boxes[this._pos++] = nodeMaxY;
160
+ }
161
+ }
162
+ }
163
+ search(minX, minY, maxX, maxY, filterFn) {
164
+ if (this._pos !== this._boxes.length) {
165
+ throw new Error('Data not yet indexed - call index.finish().');
166
+ }
167
+ let nodeIndex = this._boxes.length - 4;
168
+ const queue = [];
169
+ const results = [];
170
+ while (nodeIndex !== undefined) {
171
+ const end = Math.min(nodeIndex + this.nodeSize * 4, upperBound(nodeIndex, this._levelBounds));
172
+ for (let pos = nodeIndex; pos < end; pos += 4) {
173
+ const x0 = this._boxes[pos];
174
+ if (maxX < x0) {
175
+ continue;
176
+ }
177
+ const y0 = this._boxes[pos + 1];
178
+ if (maxY < y0) {
179
+ continue;
180
+ }
181
+ const x1 = this._boxes[pos + 2];
182
+ if (minX > x1) {
183
+ continue;
184
+ }
185
+ const y1 = this._boxes[pos + 3];
186
+ if (minY > y1) {
187
+ continue;
188
+ }
189
+ const index = this._indices[pos >> 2] | 0;
190
+ if (nodeIndex >= this.numItems * 4) {
191
+ queue.push(index);
192
+ }
193
+ else if (filterFn === undefined || filterFn(index, x0, y0, x1, y1)) {
194
+ results.push(index);
195
+ }
196
+ }
197
+ nodeIndex = queue.pop();
198
+ }
199
+ return results;
200
+ }
201
+ neighbors(x, y, maxResults = Infinity, maxDistance = Infinity, filterFn) {
202
+ if (this._pos !== this._boxes.length) {
203
+ throw new Error('Data not yet indexed - call index.finish().');
204
+ }
205
+ let nodeIndex = this._boxes.length - 4;
206
+ const q = this._queue;
207
+ const results = [];
208
+ const maxDistSquared = maxDistance * maxDistance;
209
+ outer: while (nodeIndex !== undefined) {
210
+ const end = Math.min(nodeIndex + this.nodeSize * 4, upperBound(nodeIndex, this._levelBounds));
211
+ for (let pos = nodeIndex; pos < end; pos += 4) {
212
+ const index = this._indices[pos >> 2] | 0;
213
+ const minX = this._boxes[pos];
214
+ const minY = this._boxes[pos + 1];
215
+ const maxX = this._boxes[pos + 2];
216
+ const maxY = this._boxes[pos + 3];
217
+ const dx = x < minX ? minX - x : x > maxX ? x - maxX : 0;
218
+ const dy = y < minY ? minY - y : y > maxY ? y - maxY : 0;
219
+ const dist = dx * dx + dy * dy;
220
+ if (dist > maxDistSquared) {
221
+ continue;
222
+ }
223
+ if (nodeIndex >= this.numItems * 4) {
224
+ q.push(index << 1, dist);
225
+ }
226
+ else if (filterFn === undefined || filterFn(index)) {
227
+ q.push((index << 1) + 1, dist);
228
+ }
229
+ }
230
+ while (q.length && q.peek() & 1) {
231
+ const dist = q.peekValue();
232
+ if (dist > maxDistSquared) {
233
+ break outer;
234
+ }
235
+ results.push(q.pop() >> 1);
236
+ if (results.length === maxResults) {
237
+ break outer;
238
+ }
239
+ }
240
+ nodeIndex = q.length ? q.pop() >> 1 : undefined;
241
+ }
242
+ q.clear();
243
+ return results;
244
+ }
245
+ }
246
+ exports.default = Flatbush;
247
+ function upperBound(value, arr) {
248
+ let i = 0;
249
+ let j = arr.length - 1;
250
+ while (i < j) {
251
+ const m = (i + j) >> 1;
252
+ if (arr[m] > value) {
253
+ j = m;
254
+ }
255
+ else {
256
+ i = m + 1;
257
+ }
258
+ }
259
+ return arr[i];
260
+ }
261
+ function sort(values, boxes, indices, left, right, nodeSize) {
262
+ if (Math.floor(left / nodeSize) >= Math.floor(right / nodeSize)) {
263
+ return;
264
+ }
265
+ const start = values[left];
266
+ const mid = values[(left + right) >> 1];
267
+ const end = values[right];
268
+ let pivot = end;
269
+ const x = Math.max(start, mid);
270
+ if (end > x) {
271
+ pivot = x;
272
+ }
273
+ else if (x === start) {
274
+ pivot = Math.max(mid, end);
275
+ }
276
+ else if (x === mid) {
277
+ pivot = Math.max(start, end);
278
+ }
279
+ let i = left - 1;
280
+ let j = right + 1;
281
+ while (true) {
282
+ do {
283
+ i++;
284
+ } while (values[i] < pivot);
285
+ do {
286
+ j--;
287
+ } while (values[j] > pivot);
288
+ if (i >= j) {
289
+ break;
290
+ }
291
+ swap(values, boxes, indices, i, j);
292
+ }
293
+ sort(values, boxes, indices, left, j, nodeSize);
294
+ sort(values, boxes, indices, j + 1, right, nodeSize);
295
+ }
296
+ function swap(values, boxes, indices, i, j) {
297
+ const temp = values[i];
298
+ values[i] = values[j];
299
+ values[j] = temp;
300
+ const k = 4 * i;
301
+ const m = 4 * j;
302
+ const a = boxes[k];
303
+ const b = boxes[k + 1];
304
+ const c = boxes[k + 2];
305
+ const d = boxes[k + 3];
306
+ boxes[k] = boxes[m];
307
+ boxes[k + 1] = boxes[m + 1];
308
+ boxes[k + 2] = boxes[m + 2];
309
+ boxes[k + 3] = boxes[m + 3];
310
+ boxes[m] = a;
311
+ boxes[m + 1] = b;
312
+ boxes[m + 2] = c;
313
+ boxes[m + 3] = d;
314
+ const e = indices[i];
315
+ indices[i] = indices[j];
316
+ indices[j] = e;
317
+ }
318
+ function hilbert(x, y) {
319
+ let a = x ^ y;
320
+ let b = 0xffff ^ a;
321
+ let c = 0xffff ^ (x | y);
322
+ let d = x & (y ^ 0xffff);
323
+ let A = a | (b >> 1);
324
+ let B = (a >> 1) ^ a;
325
+ let C = (c >> 1) ^ (b & (d >> 1)) ^ c;
326
+ let D = (a & (c >> 1)) ^ (d >> 1) ^ d;
327
+ a = A;
328
+ b = B;
329
+ c = C;
330
+ d = D;
331
+ A = (a & (a >> 2)) ^ (b & (b >> 2));
332
+ B = (a & (b >> 2)) ^ (b & ((a ^ b) >> 2));
333
+ C ^= (a & (c >> 2)) ^ (b & (d >> 2));
334
+ D ^= (b & (c >> 2)) ^ ((a ^ b) & (d >> 2));
335
+ a = A;
336
+ b = B;
337
+ c = C;
338
+ d = D;
339
+ A = (a & (a >> 4)) ^ (b & (b >> 4));
340
+ B = (a & (b >> 4)) ^ (b & ((a ^ b) >> 4));
341
+ C ^= (a & (c >> 4)) ^ (b & (d >> 4));
342
+ D ^= (b & (c >> 4)) ^ ((a ^ b) & (d >> 4));
343
+ a = A;
344
+ b = B;
345
+ c = C;
346
+ d = D;
347
+ C ^= (a & (c >> 8)) ^ (b & (d >> 8));
348
+ D ^= (b & (c >> 8)) ^ ((a ^ b) & (d >> 8));
349
+ a = C ^ (C >> 1);
350
+ b = D ^ (D >> 1);
351
+ let i0 = x ^ y;
352
+ let i1 = b | (0xffff ^ (i0 | a));
353
+ i0 = (i0 | (i0 << 8)) & 0x00ff00ff;
354
+ i0 = (i0 | (i0 << 4)) & 0x0f0f0f0f;
355
+ i0 = (i0 | (i0 << 2)) & 0x33333333;
356
+ i0 = (i0 | (i0 << 1)) & 0x55555555;
357
+ i1 = (i1 | (i1 << 8)) & 0x00ff00ff;
358
+ i1 = (i1 | (i1 << 4)) & 0x0f0f0f0f;
359
+ i1 = (i1 | (i1 << 2)) & 0x33333333;
360
+ i1 = (i1 | (i1 << 1)) & 0x55555555;
361
+ return ((i1 << 1) | i0) >>> 0;
362
+ }
@@ -0,0 +1,11 @@
1
+ export default class FlatQueue<T> {
2
+ ids: T[];
3
+ values: number[];
4
+ length: number;
5
+ clear(): void;
6
+ push(item: T, priority: number): void;
7
+ pop(): T | undefined;
8
+ peek(): T | undefined;
9
+ peekValue(): number | undefined;
10
+ shrink(): void;
11
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class FlatQueue {
4
+ constructor() {
5
+ this.ids = [];
6
+ this.values = [];
7
+ this.length = 0;
8
+ }
9
+ clear() {
10
+ this.length = 0;
11
+ }
12
+ push(item, priority) {
13
+ let pos = this.length++;
14
+ while (pos > 0) {
15
+ const parent = (pos - 1) >> 1;
16
+ const parentValue = this.values[parent];
17
+ if (priority >= parentValue) {
18
+ break;
19
+ }
20
+ this.ids[pos] = this.ids[parent];
21
+ this.values[pos] = parentValue;
22
+ pos = parent;
23
+ }
24
+ this.ids[pos] = item;
25
+ this.values[pos] = priority;
26
+ }
27
+ pop() {
28
+ if (this.length === 0) {
29
+ return undefined;
30
+ }
31
+ const ids = this.ids;
32
+ const values = this.values;
33
+ const top = ids[0];
34
+ const last = --this.length;
35
+ if (last > 0) {
36
+ const id = ids[last];
37
+ const value = values[last];
38
+ let pos = 0;
39
+ const halfLen = last >> 1;
40
+ while (pos < halfLen) {
41
+ const left = (pos << 1) + 1;
42
+ const right = left + 1;
43
+ const child = left + (+(right < last) & +(values[right] < values[left]));
44
+ if (values[child] >= value) {
45
+ break;
46
+ }
47
+ ids[pos] = ids[child];
48
+ values[pos] = values[child];
49
+ pos = child;
50
+ }
51
+ ids[pos] = id;
52
+ values[pos] = value;
53
+ }
54
+ return top;
55
+ }
56
+ peek() {
57
+ return this.length > 0 ? this.ids[0] : undefined;
58
+ }
59
+ peekValue() {
60
+ return this.length > 0 ? this.values[0] : undefined;
61
+ }
62
+ shrink() {
63
+ this.ids.length = this.values.length = this.length;
64
+ }
65
+ }
66
+ exports.default = FlatQueue;
package/util/index.js CHANGED
@@ -129,11 +129,17 @@ function useDebounce(value, delay) {
129
129
  function useWidthSetter(view, padding) {
130
130
  const [ref, { width }] = (0, useMeasure_1.default)();
131
131
  (0, react_1.useEffect)(() => {
132
+ let token;
132
133
  if (width && (0, mobx_state_tree_1.isAlive)(view)) {
133
- requestAnimationFrame(() => {
134
- view.setWidth(width - Number.parseInt(padding, 10) * 2);
134
+ token = requestAnimationFrame(() => {
135
+ view.setWidth(width);
135
136
  });
136
137
  }
138
+ return () => {
139
+ if (token) {
140
+ cancelAnimationFrame(token);
141
+ }
142
+ };
137
143
  }, [padding, view, width]);
138
144
  return ref;
139
145
  }
@@ -580,26 +586,26 @@ exports.complementTable = {
580
586
  };
581
587
  function revcom(str) {
582
588
  var _a;
583
- let revcomped = '';
589
+ const revcomped = [];
584
590
  for (let i = str.length - 1; i >= 0; i--) {
585
- revcomped += (_a = exports.complementTable[str[i]]) !== null && _a !== void 0 ? _a : str[i];
591
+ revcomped.push((_a = exports.complementTable[str[i]]) !== null && _a !== void 0 ? _a : str[i]);
586
592
  }
587
- return revcomped;
593
+ return revcomped.join('');
588
594
  }
589
595
  function reverse(str) {
590
- let reversed = '';
596
+ const reversed = [];
591
597
  for (let i = str.length - 1; i >= 0; i--) {
592
- reversed += str[i];
598
+ reversed.push(str[i]);
593
599
  }
594
- return reversed;
600
+ return reversed.join('');
595
601
  }
596
602
  function complement(str) {
597
603
  var _a;
598
- let comp = '';
599
- for (const element of str) {
600
- comp += (_a = exports.complementTable[element]) !== null && _a !== void 0 ? _a : element;
604
+ const comp = [];
605
+ for (let i = 0, l = str.length; i < l; i++) {
606
+ comp.push((_a = exports.complementTable[str[i]]) !== null && _a !== void 0 ? _a : str[i]);
601
607
  }
602
- return comp;
608
+ return comp.join('');
603
609
  }
604
610
  exports.rIC = typeof jest === 'undefined'
605
611
  ?
package/util/jexl.js CHANGED
@@ -26,6 +26,7 @@ function JexlF() {
26
26
  j.addFunction('parseInt', Number.parseInt);
27
27
  j.addFunction('parseFloat', Number.parseFloat);
28
28
  j.addFunction('split', (s, char) => s.split(char));
29
+ j.addFunction('join', (k, ...args) => [...args].filter(f => !!f).join(k));
29
30
  j.addFunction('charAt', (s, index) => s.charAt(index));
30
31
  j.addFunction('charCodeAt', (s, index) => s.charCodeAt(index));
31
32
  j.addFunction('codePointAt', (s, pos) => s.codePointAt(pos));
@@ -10,8 +10,10 @@ export default class PrecomputedLayout<T> implements BaseLayout<T> {
10
10
  private rectangles;
11
11
  private totalHeight;
12
12
  maxHeightReached: boolean;
13
- private rbush;
13
+ private index?;
14
+ private indexData;
14
15
  constructor({ rectangles, totalHeight, maxHeightReached }: SerializedLayout);
16
+ private buildIndex;
15
17
  addRect(id: string): number;
16
18
  getRectangles(): Map<string, RectTuple>;
17
19
  getTotalHeight(): number;
@@ -3,22 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const rbush_1 = __importDefault(require("rbush"));
6
+ const flatbush_1 = __importDefault(require("../flatbush"));
7
7
  class PrecomputedLayout {
8
8
  constructor({ rectangles, totalHeight, maxHeightReached }) {
9
+ this.indexData = [];
9
10
  this.rectangles = new Map(Object.entries(rectangles));
10
11
  this.totalHeight = totalHeight;
11
12
  this.maxHeightReached = maxHeightReached;
12
- this.rbush = new rbush_1.default();
13
- for (const [key, layout] of Object.entries(rectangles)) {
14
- this.rbush.insert({
15
- minX: layout[0],
16
- minY: layout[1],
17
- maxX: layout[2],
18
- maxY: layout[3],
19
- name: key,
20
- });
13
+ this.buildIndex();
14
+ }
15
+ buildIndex() {
16
+ if (this.rectangles.size === 0) {
17
+ return;
18
+ }
19
+ this.index = new flatbush_1.default(this.rectangles.size);
20
+ this.indexData = [];
21
+ for (const [name, rect] of this.rectangles) {
22
+ this.index.add(rect[0], rect[1], rect[2], rect[3]);
23
+ this.indexData.push({ name, rect });
21
24
  }
25
+ this.index.finish();
22
26
  }
23
27
  addRect(id) {
24
28
  const rect = this.rectangles.get(id);
@@ -37,10 +41,15 @@ class PrecomputedLayout {
37
41
  throw new Error('Method not implemented.');
38
42
  }
39
43
  getByCoord(x, y) {
40
- const rect = { minX: x, minY: y, maxX: x + 1, maxY: y + 1 };
41
- return this.rbush.collides(rect)
42
- ? this.rbush.search(rect)[0].name
43
- : undefined;
44
+ var _a;
45
+ if (!this.index) {
46
+ return undefined;
47
+ }
48
+ const results = this.index.search(x, y, x + 1, y + 1);
49
+ if (results.length > 0) {
50
+ return (_a = this.indexData[results[0]]) === null || _a === void 0 ? void 0 : _a.name;
51
+ }
52
+ return undefined;
44
53
  }
45
54
  getByID(id) {
46
55
  return this.rectangles.get(id);
package/util/tracks.js CHANGED
@@ -71,7 +71,7 @@ function setBlobMap(map) {
71
71
  let counter = 0;
72
72
  function storeBlobLocation(location) {
73
73
  if ('blob' in location) {
74
- const blobId = `b${+Date.now()}-${counter++}`;
74
+ const blobId = `b${Date.now()}-${counter++}`;
75
75
  blobMap[blobId] = location.blob;
76
76
  return { name: location.blob.name, blobId, locationType: 'BlobLocation' };
77
77
  }
@@ -132,11 +132,11 @@ export interface SessionWithDrawerWidgets extends SessionWithWidgets {
132
132
  setDrawerPosition(arg: string): void;
133
133
  }
134
134
  export declare function isSessionModelWithWidgets(thing: unknown): thing is SessionWithWidgets;
135
- interface SessionWithConnections {
135
+ export interface SessionWithConnections {
136
136
  makeConnection: (arg: AnyConfigurationModel) => void;
137
137
  }
138
138
  export declare function isSessionModelWithConnections(thing: unknown): thing is SessionWithConnections;
139
- interface SessionWithConnectionEditing {
139
+ export interface SessionWithConnectionEditing {
140
140
  addConnectionConf: (arg: AnyConfigurationModel) => void;
141
141
  }
142
142
  export declare function isSessionModelWithConnectionEditing(thing: unknown): thing is SessionWithConnectionEditing;
@@ -0,0 +1,19 @@
1
+ import type { AbstractSessionModel, Feature } from '.';
2
+ export declare function useFeatureSequence({ session, feature, upDownBp, forceLoad, assemblyName, shouldFetch, }: {
3
+ assemblyName: string;
4
+ session?: AbstractSessionModel;
5
+ feature: Feature;
6
+ upDownBp: number;
7
+ forceLoad: boolean;
8
+ shouldFetch?: boolean;
9
+ }): {
10
+ sequence: {
11
+ seq: string;
12
+ upstream: string;
13
+ downstream: string;
14
+ } | {
15
+ error: string;
16
+ } | undefined;
17
+ loading: boolean;
18
+ error: unknown;
19
+ };