@jbrowse/core 2.6.3 → 2.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.d.ts +0 -9
- package/BaseFeatureWidget/BaseFeatureDetail/ArrayValue.js +2 -3
- package/BaseFeatureWidget/BaseFeatureDetail/Attributes.d.ts +1 -3
- package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.d.ts +0 -9
- package/BaseFeatureWidget/BaseFeatureDetail/BasicValue.js +2 -3
- package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.d.ts +0 -9
- package/BaseFeatureWidget/BaseFeatureDetail/DataGridDetails.js +18 -8
- package/BaseFeatureWidget/BaseFeatureDetail/FieldName.d.ts +0 -9
- package/BaseFeatureWidget/BaseFeatureDetail/FieldName.js +2 -3
- package/BaseFeatureWidget/BaseFeatureDetail/SimpleField.d.ts +0 -9
- package/BaseFeatureWidget/BaseFeatureDetail/SimpleField.js +2 -3
- package/BaseFeatureWidget/BaseFeatureDetail/UriField.d.ts +0 -9
- package/BaseFeatureWidget/BaseFeatureDetail/UriField.js +2 -3
- package/BaseFeatureWidget/BaseFeatureDetail/index.d.ts +2 -11
- package/BaseFeatureWidget/BaseFeatureDetail/index.js +5 -4
- package/BaseFeatureWidget/SequenceFeatureDetails/ProteinSequence.d.ts +1 -3
- package/BaseFeatureWidget/SequenceFeatureDetails/SequencePanel.js +1 -1
- package/BaseFeatureWidget/util.js +0 -4
- package/PluginManager.d.ts +9 -17
- package/ReExports/modules.d.ts +5 -5
- package/ReExports/modules.js +24 -18
- package/TextSearch/TextSearchManager.d.ts +1 -1
- package/assemblyManager/assembly.d.ts +2 -0
- package/assemblyManager/assembly.js +9 -4
- package/assemblyManager/assemblyManager.d.ts +123 -111
- package/assemblyManager/assemblyManager.js +1 -1
- package/configuration/configurationSchema.js +2 -2
- package/configuration/configurationSlot.js +3 -6
- package/data_adapters/BaseAdapter/index.d.ts +1 -3
- package/data_adapters/dataAdapterCache.js +2 -2
- package/package.json +5 -6
- package/pluggableElementTypes/AdapterType.d.ts +2 -2
- package/pluggableElementTypes/models/BaseTrackModel.d.ts +5 -5
- package/pluggableElementTypes/models/BaseTrackModel.js +1 -16
- package/pluggableElementTypes/models/InternetAccountModel.d.ts +2 -2
- package/pluggableElementTypes/models/InternetAccountModel.js +2 -2
- package/pluggableElementTypes/renderers/BoxRendererType.d.ts +1 -3
- package/pluggableElementTypes/renderers/CircularChordRendererType.d.ts +3 -0
- package/pluggableElementTypes/renderers/RendererType.js +1 -1
- package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.d.ts +7 -3
- package/pluggableElementTypes/renderers/RpcRenderedSvgGroup.js +45 -2
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.d.ts +2 -2
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +49 -12
- package/pluggableElementTypes/renderers/util/serializableFilterChain.js +2 -2
- package/rpc/RpcManager.d.ts +2 -2
- package/rpc/WebWorkerRpcDriver.js +3 -3
- package/rpc/methods/CoreGetFeatureDensityStats.js +0 -1
- package/rpc/methods/CoreGetFeatureDetails.js +0 -1
- package/rpc/methods/CoreGetFeatures.js +0 -1
- package/rpc/methods/CoreRender.js +0 -1
- package/rpc/remoteAbortSignals.d.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/ColorPicker.js +3 -6
- package/ui/Dialog.d.ts +2 -2
- package/ui/Dialog.js +2 -1
- package/ui/DropDownMenu.d.ts +3 -4
- package/ui/DropDownMenu.js +8 -12
- package/ui/EditableTypography.js +7 -5
- package/ui/FactoryResetDialog.d.ts +3 -4
- package/ui/FactoryResetDialog.js +3 -2
- package/ui/FileSelector/FileSelector.d.ts +2 -2
- package/ui/FileSelector/FileSelector.js +2 -1
- package/ui/FileSelector/LocalFileChooser.d.ts +2 -2
- package/ui/FileSelector/LocalFileChooser.js +4 -3
- package/ui/FileSelector/UrlChooser.d.ts +5 -5
- package/ui/FileSelector/UrlChooser.js +2 -2
- package/ui/Menu.js +1 -1
- package/ui/MenuButton.d.ts +8 -0
- package/ui/MenuButton.js +42 -0
- package/ui/ResizeBar.d.ts +0 -4
- package/ui/ResizeBar.js +12 -31
- package/ui/ResizeHandle.d.ts +3 -2
- package/ui/ResizeHandle.js +10 -7
- package/ui/ReturnToImportFormDialog.d.ts +4 -5
- package/ui/ReturnToImportFormDialog.js +3 -3
- package/ui/SanitizedHTML.d.ts +1 -2
- package/ui/SanitizedHTML.js +4 -3
- package/ui/Snackbar.d.ts +2 -2
- package/ui/Snackbar.js +2 -1
- package/ui/Tooltip.d.ts +4 -7
- package/ui/Tooltip.js +3 -3
- package/ui/theme.d.ts +1 -3
- package/ui/theme.js +2 -2
- package/ui/useResizeBar.d.ts +5 -0
- package/ui/useResizeBar.js +22 -0
- package/util/Base1DUtils.js +0 -1
- package/util/blobToDataURL.d.ts +1 -0
- package/util/blobToDataURL.js +18 -0
- package/util/blockTypes.d.ts +1 -9
- package/util/blockTypes.js +5 -21
- package/util/calculateDynamicBlocks.js +3 -2
- package/util/calculateStaticBlocks.js +3 -4
- package/util/colord.d.ts +1 -0
- package/util/colord.js +13 -0
- package/util/dedupe.js +1 -2
- package/util/index.d.ts +16 -17
- package/util/index.js +27 -26
- package/util/io/RemoteFileWithRangeCache.js +2 -2
- package/util/layouts/GranularRectLayout.js +1 -2
- package/util/map-obj.d.ts +1 -1
- package/util/nanoid.d.ts +5 -0
- package/util/nanoid.js +73 -0
- package/util/offscreenCanvasPonyfill.js +1 -2
- package/util/offscreenCanvasUtils.js +3 -2
- package/util/tracks.d.ts +2 -6
- package/util/types/index.d.ts +36 -10
- package/util/types/index.js +5 -1
- package/util/types/mst.js +2 -2
- package/BaseFeatureWidget/BaseFeatureDetail/UriLink.d.ts +0 -7
- package/BaseFeatureWidget/BaseFeatureDetail/UriLink.js +0 -13
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useResizeBar = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useResizeBar() {
|
|
6
|
+
const ref = (0, react_1.useRef)(null);
|
|
7
|
+
const [scrollLeft, setScrollLeft] = (0, react_1.useState)(0);
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
const timer = setInterval(() => {
|
|
10
|
+
var _a;
|
|
11
|
+
const elt = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelector('.MuiDataGrid-virtualScroller');
|
|
12
|
+
if (elt) {
|
|
13
|
+
setScrollLeft(elt.scrollLeft);
|
|
14
|
+
}
|
|
15
|
+
}, 100);
|
|
16
|
+
return () => {
|
|
17
|
+
clearInterval(timer);
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
return { ref, scrollLeft };
|
|
21
|
+
}
|
|
22
|
+
exports.useResizeBar = useResizeBar;
|
package/util/Base1DUtils.js
CHANGED
|
@@ -109,7 +109,6 @@ function pxToBp(self, px) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
if (bp >= bpSoFar && displayedRegions.length > 0) {
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
112
|
const r = displayedRegions.at(-1);
|
|
114
113
|
const len = r.end - r.start;
|
|
115
114
|
const offset = bp - bpSoFar + len;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function blobToDataURL(blob: Blob): Promise<string>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blobToDataURL = void 0;
|
|
4
|
+
function blobToDataURL(blob) {
|
|
5
|
+
const a = new FileReader();
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
a.onload = e => {
|
|
8
|
+
if (e.target) {
|
|
9
|
+
resolve(e.target.result);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
reject(new Error('unknown result reading blob from canvas'));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
a.readAsDataURL(blob);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.blobToDataURL = blobToDataURL;
|
package/util/blockTypes.d.ts
CHANGED
|
@@ -35,15 +35,7 @@ export declare class BaseBlock {
|
|
|
35
35
|
/**
|
|
36
36
|
* a block that should be shown as filled with data
|
|
37
37
|
*/
|
|
38
|
-
constructor(data: any);
|
|
39
|
-
/**
|
|
40
|
-
* rename the reference sequence of this block and return a new one
|
|
41
|
-
*
|
|
42
|
-
* @param refName -
|
|
43
|
-
* @returns either a new block with a renamed reference sequence,
|
|
44
|
-
* or the same block, if the ref name is not actually different
|
|
45
|
-
*/
|
|
46
|
-
renameReference(refName: string): any;
|
|
38
|
+
constructor(data: Record<string, any>);
|
|
47
39
|
toRegion(): {
|
|
48
40
|
refName: string;
|
|
49
41
|
start: number;
|
package/util/blockTypes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InterRegionPaddingBlock = exports.ElidedBlock = exports.ContentBlock = exports.BaseBlock = exports.BlockSet = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
4
5
|
class BlockSet {
|
|
5
6
|
constructor(blocks = []) {
|
|
6
7
|
this.blocks = blocks;
|
|
@@ -34,15 +35,14 @@ class BlockSet {
|
|
|
34
35
|
}
|
|
35
36
|
get totalWidthPx() {
|
|
36
37
|
return this.blocks.length > 0
|
|
37
|
-
? this.blocks.map(blocks => blocks.widthPx)
|
|
38
|
+
? (0, _1.sum)(this.blocks.map(blocks => blocks.widthPx))
|
|
38
39
|
: 0;
|
|
39
40
|
}
|
|
40
41
|
get totalWidthPxWithoutBorders() {
|
|
41
42
|
return this.blocks.length > 0
|
|
42
|
-
? this.blocks
|
|
43
|
+
? (0, _1.sum)(this.blocks
|
|
43
44
|
.filter(block => block.variant !== 'boundary')
|
|
44
|
-
.map(blocks => blocks.widthPx)
|
|
45
|
-
.reduce((a, b) => a + b)
|
|
45
|
+
.map(blocks => blocks.widthPx))
|
|
46
46
|
: 0;
|
|
47
47
|
}
|
|
48
48
|
get offsetPx() {
|
|
@@ -52,9 +52,7 @@ class BlockSet {
|
|
|
52
52
|
return this.blocks.filter(block => block instanceof ContentBlock);
|
|
53
53
|
}
|
|
54
54
|
get totalBp() {
|
|
55
|
-
return this.contentBlocks
|
|
56
|
-
.map(block => block.end - block.start)
|
|
57
|
-
.reduce((a, b) => a + b, 0);
|
|
55
|
+
return (0, _1.sum)(this.contentBlocks.map(block => block.end - block.start));
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
exports.BlockSet = BlockSet;
|
|
@@ -73,20 +71,6 @@ class BaseBlock {
|
|
|
73
71
|
this.key = data.key;
|
|
74
72
|
this.offsetPx = data.offsetPx;
|
|
75
73
|
}
|
|
76
|
-
/**
|
|
77
|
-
* rename the reference sequence of this block and return a new one
|
|
78
|
-
*
|
|
79
|
-
* @param refName -
|
|
80
|
-
* @returns either a new block with a renamed reference sequence,
|
|
81
|
-
* or the same block, if the ref name is not actually different
|
|
82
|
-
*/
|
|
83
|
-
renameReference(refName) {
|
|
84
|
-
if (this.refName && refName !== this.refName) {
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
return new this.constructor({ ...this, refName });
|
|
87
|
-
}
|
|
88
|
-
return this;
|
|
89
|
-
}
|
|
90
74
|
toRegion() {
|
|
91
75
|
return {
|
|
92
76
|
refName: this.refName,
|
|
@@ -32,7 +32,8 @@ function calculateDynamicBlocks(model, padding = true, elision = true) {
|
|
|
32
32
|
let displayedRegionLeftPx = 0;
|
|
33
33
|
const windowLeftPx = offsetPx;
|
|
34
34
|
const windowRightPx = windowLeftPx + width;
|
|
35
|
-
displayedRegions.
|
|
35
|
+
for (let regionNumber = 0; regionNumber < displayedRegions.length; regionNumber++) {
|
|
36
|
+
const region = displayedRegions[regionNumber];
|
|
36
37
|
const { assemblyName, refName, start: regionStart, end: regionEnd, reversed, } = region;
|
|
37
38
|
const displayedRegionRightPx = displayedRegionLeftPx + (regionEnd - regionStart) / bpPerPx;
|
|
38
39
|
const regionWidthPx = (regionEnd - regionStart) / bpPerPx;
|
|
@@ -115,7 +116,7 @@ function calculateDynamicBlocks(model, padding = true, elision = true) {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
displayedRegionLeftPx += (regionEnd - regionStart) / bpPerPx;
|
|
118
|
-
}
|
|
119
|
+
}
|
|
119
120
|
return blocks;
|
|
120
121
|
}
|
|
121
122
|
exports.default = calculateDynamicBlocks;
|
|
@@ -12,9 +12,8 @@ function calculateStaticBlocks(model, padding = true, elision = true, extra = 0,
|
|
|
12
12
|
// for each displayed region
|
|
13
13
|
let regionBpOffset = 0;
|
|
14
14
|
const blocks = new blockTypes_1.BlockSet();
|
|
15
|
-
displayedRegions.
|
|
16
|
-
|
|
17
|
-
// clamp those to the region range, and then make blocks for that range
|
|
15
|
+
for (let regionNumber = 0; regionNumber < displayedRegions.length; regionNumber++) {
|
|
16
|
+
const region = displayedRegions[regionNumber];
|
|
18
17
|
const { assemblyName, refName, start: regionStart, end: regionEnd, reversed, } = region;
|
|
19
18
|
const regionBlockCount = Math.ceil((regionEnd - regionStart) / blockSizeBp);
|
|
20
19
|
const parentRegion = (0, mobx_state_tree_1.isStateTreeNode)(region) ? (0, mobx_state_tree_1.getSnapshot)(region) : region;
|
|
@@ -99,7 +98,7 @@ function calculateStaticBlocks(model, padding = true, elision = true, extra = 0,
|
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
regionBpOffset += regionEnd - regionStart;
|
|
102
|
-
}
|
|
101
|
+
}
|
|
103
102
|
return blocks;
|
|
104
103
|
}
|
|
105
104
|
exports.default = calculateStaticBlocks;
|
package/util/colord.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Colord, colord } from 'colord';
|
package/util/colord.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
exports.colord = exports.Colord = void 0;
|
|
7
|
+
const colord_1 = require("colord");
|
|
8
|
+
const mix_1 = __importDefault(require("colord/plugins/mix"));
|
|
9
|
+
const names_1 = __importDefault(require("colord/plugins/names"));
|
|
10
|
+
(0, colord_1.extend)([mix_1.default, names_1.default]);
|
|
11
|
+
var colord_2 = require("colord");
|
|
12
|
+
Object.defineProperty(exports, "Colord", { enumerable: true, get: function () { return colord_2.Colord; } });
|
|
13
|
+
Object.defineProperty(exports, "colord", { enumerable: true, get: function () { return colord_2.colord; } });
|
package/util/dedupe.js
CHANGED
|
@@ -5,8 +5,7 @@ exports.dedupe = void 0;
|
|
|
5
5
|
function dedupe(list, hasher = JSON.stringify) {
|
|
6
6
|
const clone = [];
|
|
7
7
|
const lookup = new Set();
|
|
8
|
-
for (
|
|
9
|
-
const entry = list[i];
|
|
8
|
+
for (const entry of list) {
|
|
10
9
|
const hashed = hasher(entry);
|
|
11
10
|
if (!lookup.has(hashed)) {
|
|
12
11
|
clone.push(entry);
|
package/util/index.d.ts
CHANGED
|
@@ -23,14 +23,14 @@ export declare function useDebouncedCallback<T>(callback: (...args: T[]) => void
|
|
|
23
23
|
/** find the first node in the hierarchy that matches the given predicate */
|
|
24
24
|
export declare function findParentThat(node: IAnyStateTreeNode, predicate: (thing: IAnyStateTreeNode) => boolean): IAnyStateTreeNode;
|
|
25
25
|
export declare function springAnimate(fromValue: number, toValue: number, setValue: (value: number) => void, onFinish?: () => void, precision?: number, tension?: number, friction?: number): (() => void)[];
|
|
26
|
-
export declare function findParentThatIs<T extends (a: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: T): TypeTestedByPredicate<T
|
|
26
|
+
export declare function findParentThatIs<T extends (a: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: T): TypeTestedByPredicate<T>;
|
|
27
27
|
/** get the current JBrowse session model, starting at any node in the state tree */
|
|
28
|
-
export declare function getSession(node: IAnyStateTreeNode): import("./types").AbstractSessionModel
|
|
28
|
+
export declare function getSession(node: IAnyStateTreeNode): import("./types").AbstractSessionModel;
|
|
29
29
|
/** get the state model of the view in the state tree that contains the given node */
|
|
30
|
-
export declare function getContainingView(node: IAnyStateTreeNode): import("./types").AbstractViewModel
|
|
30
|
+
export declare function getContainingView(node: IAnyStateTreeNode): import("./types").AbstractViewModel;
|
|
31
31
|
/** get the state model of the view in the state tree that contains the given node */
|
|
32
|
-
export declare function getContainingTrack(node: IAnyStateTreeNode): import("./types").AbstractTrackModel
|
|
33
|
-
export declare function getContainingDisplay(node: IAnyStateTreeNode): import("./types").AbstractDisplayModel
|
|
32
|
+
export declare function getContainingTrack(node: IAnyStateTreeNode): import("./types").AbstractTrackModel;
|
|
33
|
+
export declare function getContainingDisplay(node: IAnyStateTreeNode): import("./types").AbstractDisplayModel;
|
|
34
34
|
/**
|
|
35
35
|
* Assemble a 1-based "locString" from an interbase genomic location
|
|
36
36
|
* @param region - Region
|
|
@@ -165,8 +165,8 @@ export declare function iterMap<T, U>(iter: Iterable<T>, func: (arg: T) => U, si
|
|
|
165
165
|
* element is found, findLastIndex immediately returns that element index.
|
|
166
166
|
* Otherwise, findLastIndex returns -1.
|
|
167
167
|
*/
|
|
168
|
-
export declare function findLastIndex<T>(array:
|
|
169
|
-
export declare function findLast<T>(array:
|
|
168
|
+
export declare function findLastIndex<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
|
|
169
|
+
export declare function findLast<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): T | undefined;
|
|
170
170
|
/**
|
|
171
171
|
* makes a mobx reaction with the given functions, that calls actions on the
|
|
172
172
|
* model for each stage of execution, and to abort the reaction function when
|
|
@@ -212,7 +212,6 @@ export declare const isElectron: boolean;
|
|
|
212
212
|
export declare function revcom(seqString: string): string;
|
|
213
213
|
export declare function reverse(seqString: string): string;
|
|
214
214
|
export declare const complement: (seqString: string) => string;
|
|
215
|
-
export declare function blobToDataURL(blob: Blob): Promise<string>;
|
|
216
215
|
export declare const rIC: (((callback: IdleRequestCallback, options?: IdleRequestOptions | undefined) => number) & typeof requestIdleCallback) | ((cb: Function) => any);
|
|
217
216
|
export declare function measureText(str: unknown, fontSize?: number): number;
|
|
218
217
|
export declare const defaultStarts: string[];
|
|
@@ -287,9 +286,7 @@ export declare const defaultCodonTable: {
|
|
|
287
286
|
* take CodonTable above and generate larger codon table that includes all
|
|
288
287
|
* permutations of upper and lower case nucleotides
|
|
289
288
|
*/
|
|
290
|
-
export declare function generateCodonTable(table: any):
|
|
291
|
-
[key: string]: string;
|
|
292
|
-
};
|
|
289
|
+
export declare function generateCodonTable(table: any): Record<string, string>;
|
|
293
290
|
export declare function updateStatus<U>(msg: string, cb: (arg: string) => void, fn: () => U | Promise<U>): Promise<U>;
|
|
294
291
|
export declare function hashCode(str: string): number;
|
|
295
292
|
export declare function objectHash(obj: Record<string, any>): string;
|
|
@@ -303,7 +300,7 @@ interface Block {
|
|
|
303
300
|
export declare function bytesForRegions(regions: Region[], index: {
|
|
304
301
|
blocksForRange: (ref: string, start: number, end: number) => Promise<Block[]>;
|
|
305
302
|
}): Promise<number>;
|
|
306
|
-
export
|
|
303
|
+
export interface ViewSnap {
|
|
307
304
|
bpPerPx: number;
|
|
308
305
|
interRegionPaddingWidth: number;
|
|
309
306
|
minimumBlockWidth: number;
|
|
@@ -320,8 +317,8 @@ export type ViewSnap = {
|
|
|
320
317
|
reversed: boolean;
|
|
321
318
|
assemblyName: string;
|
|
322
319
|
})[];
|
|
323
|
-
}
|
|
324
|
-
export declare function
|
|
320
|
+
}
|
|
321
|
+
export declare function isSupportedIndexingAdapter(type: string): boolean;
|
|
325
322
|
export declare function getBpDisplayStr(totalBp: number): string;
|
|
326
323
|
export declare function toLocale(n: number): string;
|
|
327
324
|
export declare function getTickDisplayStr(totalBp: number, bpPerPx: number): string;
|
|
@@ -341,6 +338,8 @@ export declare function getUriLink(value: {
|
|
|
341
338
|
baseUri?: string;
|
|
342
339
|
}): string;
|
|
343
340
|
export declare function getStr(obj: unknown): string;
|
|
341
|
+
export declare function coarseStripHTML(s: string): string;
|
|
342
|
+
export declare function linkify(s: string): string;
|
|
344
343
|
export declare function measureGridWidth(elements: unknown[], args?: {
|
|
345
344
|
minWidth?: number;
|
|
346
345
|
fontSize?: number;
|
|
@@ -357,9 +356,7 @@ export declare function max(arr: number[], init?: number): number;
|
|
|
357
356
|
export declare function min(arr: number[], init?: number): number;
|
|
358
357
|
export declare function sum(arr: number[]): number;
|
|
359
358
|
export declare function avg(arr: number[]): number;
|
|
360
|
-
export declare function groupBy<T>(array: T
|
|
361
|
-
[key: string]: T[];
|
|
362
|
-
};
|
|
359
|
+
export declare function groupBy<T>(array: Iterable<T>, predicate: (v: T) => string): Record<string, T[] | undefined>;
|
|
363
360
|
export declare function notEmpty<T>(value: T | null | undefined): value is T;
|
|
364
361
|
export declare function mergeIntervals<T extends {
|
|
365
362
|
start: number;
|
|
@@ -372,3 +369,5 @@ interface BasicFeature {
|
|
|
372
369
|
}
|
|
373
370
|
export declare function gatherOverlaps(regions: BasicFeature[]): BasicFeature[];
|
|
374
371
|
export { default as SimpleFeature, type Feature, type SimpleFeatureSerialized, isFeature, } from './simpleFeature';
|
|
372
|
+
export declare function stripAlpha(str: string): string;
|
|
373
|
+
export { blobToDataURL } from './blobToDataURL';
|
package/util/index.js
CHANGED
|
@@ -17,8 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.
|
|
21
|
-
exports.isFeature = exports.SimpleFeature = exports.gatherOverlaps = exports.mergeIntervals = exports.notEmpty = exports.groupBy = exports.avg = exports.sum = exports.min = exports.max = exports.localStorageSetItem = exports.localStorageGetItem = exports.getEnv = exports.measureGridWidth = exports.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = exports.toLocale = exports.getBpDisplayStr =
|
|
20
|
+
exports.isSupportedIndexingAdapter = exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.complement = exports.reverse = exports.revcom = exports.isElectron = exports.stringify = exports.shorten = exports.minmax = exports.renameRegionsIfNeeded = exports.renameRegionIfNeeded = exports.makeAbortableReaction = exports.findLast = exports.findLastIndex = exports.iterMap = exports.bpSpanPx = exports.featureSpanPx = exports.cartesianToPolar = exports.polarToCartesian = exports.degToRad = exports.radToDeg = exports.bpToPx = exports.clamp = exports.compareLocStrings = exports.compareLocs = exports.parseLocString = exports.parseLocStringOneBased = exports.assembleLocStringFast = exports.assembleLocString = exports.getContainingDisplay = exports.getContainingTrack = exports.getContainingView = exports.getSession = exports.findParentThatIs = exports.springAnimate = exports.findParentThat = exports.useDebouncedCallback = exports.useWidthSetter = exports.useDebounce = exports.inProduction = exports.inDevelopment = void 0;
|
|
21
|
+
exports.blobToDataURL = exports.stripAlpha = exports.isFeature = exports.SimpleFeature = exports.gatherOverlaps = exports.mergeIntervals = exports.notEmpty = exports.groupBy = exports.avg = exports.sum = exports.min = exports.max = exports.localStorageSetItem = exports.localStorageGetItem = exports.getEnv = exports.measureGridWidth = exports.linkify = exports.coarseStripHTML = exports.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = exports.toLocale = exports.getBpDisplayStr = void 0;
|
|
22
22
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
23
23
|
const react_1 = require("react");
|
|
24
24
|
const is_object_1 = __importDefault(require("is-object"));
|
|
@@ -27,7 +27,9 @@ const mobx_1 = require("mobx");
|
|
|
27
27
|
const types_1 = require("./types");
|
|
28
28
|
const aborting_1 = require("./aborting");
|
|
29
29
|
const types_2 = require("./types");
|
|
30
|
+
// has to be the full path and not the relative path to get the jest mock
|
|
30
31
|
const useMeasure_1 = __importDefault(require("@jbrowse/core/util/useMeasure"));
|
|
32
|
+
const colord_1 = require("./colord");
|
|
31
33
|
__exportStar(require("./types"), exports);
|
|
32
34
|
__exportStar(require("./aborting"), exports);
|
|
33
35
|
__exportStar(require("./when"), exports);
|
|
@@ -731,21 +733,6 @@ exports.complement = (() => {
|
|
|
731
733
|
return seqString.replaceAll(complementRegex, m => complementTable[m] || '');
|
|
732
734
|
};
|
|
733
735
|
})();
|
|
734
|
-
function blobToDataURL(blob) {
|
|
735
|
-
const a = new FileReader();
|
|
736
|
-
return new Promise((resolve, reject) => {
|
|
737
|
-
a.onload = e => {
|
|
738
|
-
if (e.target) {
|
|
739
|
-
resolve(e.target.result);
|
|
740
|
-
}
|
|
741
|
-
else {
|
|
742
|
-
reject(new Error('unknown result reading blob from canvas'));
|
|
743
|
-
}
|
|
744
|
-
};
|
|
745
|
-
a.readAsDataURL(blob);
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
exports.blobToDataURL = blobToDataURL;
|
|
749
736
|
// requires immediate execution in jest environment, because (hypothesis) it
|
|
750
737
|
// otherwise listens for prerendered_canvas but reads empty pixels, and doesn't
|
|
751
738
|
// get the contents of the canvas
|
|
@@ -905,7 +892,7 @@ async function bytesForRegions(regions, index) {
|
|
|
905
892
|
exports.bytesForRegions = bytesForRegions;
|
|
906
893
|
// supported adapter types by text indexer
|
|
907
894
|
// ensure that this matches the method found in @jbrowse/text-indexing/util
|
|
908
|
-
function
|
|
895
|
+
function isSupportedIndexingAdapter(type) {
|
|
909
896
|
return [
|
|
910
897
|
'Gff3TabixAdapter',
|
|
911
898
|
'VcfTabixAdapter',
|
|
@@ -913,7 +900,7 @@ function supportedIndexingAdapters(type) {
|
|
|
913
900
|
'VcfAdapter',
|
|
914
901
|
].includes(type);
|
|
915
902
|
}
|
|
916
|
-
exports.
|
|
903
|
+
exports.isSupportedIndexingAdapter = isSupportedIndexingAdapter;
|
|
917
904
|
function getBpDisplayStr(totalBp) {
|
|
918
905
|
let str;
|
|
919
906
|
if (Math.floor(totalBp / 1000000) > 0) {
|
|
@@ -939,6 +926,7 @@ function getTickDisplayStr(totalBp, bpPerPx) {
|
|
|
939
926
|
}
|
|
940
927
|
exports.getTickDisplayStr = getTickDisplayStr;
|
|
941
928
|
function getViewParams(model, exportSVG) {
|
|
929
|
+
// @ts-expect-error
|
|
942
930
|
const { dynamicBlocks, staticBlocks, offsetPx } = getContainingView(model);
|
|
943
931
|
const b = (dynamicBlocks === null || dynamicBlocks === void 0 ? void 0 : dynamicBlocks.contentBlocks[0]) || {};
|
|
944
932
|
const staticblock = (staticBlocks === null || staticBlocks === void 0 ? void 0 : staticBlocks.contentBlocks[0]) || {};
|
|
@@ -1009,6 +997,13 @@ exports.getStr = getStr;
|
|
|
1009
997
|
function coarseStripHTML(s) {
|
|
1010
998
|
return s.replaceAll(/(<([^>]+)>)/gi, '');
|
|
1011
999
|
}
|
|
1000
|
+
exports.coarseStripHTML = coarseStripHTML;
|
|
1001
|
+
// based on autolink-js, license MIT
|
|
1002
|
+
function linkify(s) {
|
|
1003
|
+
const pattern = /(^|[\s\n]|<[A-Za-z]*\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
|
|
1004
|
+
return s.replaceAll(pattern, '$1<a href=\'$2\' target="_blank">$2</a>');
|
|
1005
|
+
}
|
|
1006
|
+
exports.linkify = linkify;
|
|
1012
1007
|
// heuristic measurement for a column of a @mui/x-data-grid, pass in values from a column
|
|
1013
1008
|
function measureGridWidth(elements, args) {
|
|
1014
1009
|
const { padding = 30, minWidth = 80, fontSize = 12, maxWidth = 1000, stripHTML = false, } = args || {};
|
|
@@ -1037,24 +1032,24 @@ function localStorageSetItem(str, item) {
|
|
|
1037
1032
|
exports.localStorageSetItem = localStorageSetItem;
|
|
1038
1033
|
function max(arr, init = -Infinity) {
|
|
1039
1034
|
let max = init;
|
|
1040
|
-
for (
|
|
1041
|
-
max =
|
|
1035
|
+
for (const entry of arr) {
|
|
1036
|
+
max = entry > max ? entry : max;
|
|
1042
1037
|
}
|
|
1043
1038
|
return max;
|
|
1044
1039
|
}
|
|
1045
1040
|
exports.max = max;
|
|
1046
1041
|
function min(arr, init = Infinity) {
|
|
1047
1042
|
let min = init;
|
|
1048
|
-
for (
|
|
1049
|
-
min =
|
|
1043
|
+
for (const entry of arr) {
|
|
1044
|
+
min = entry < min ? entry : min;
|
|
1050
1045
|
}
|
|
1051
1046
|
return min;
|
|
1052
1047
|
}
|
|
1053
1048
|
exports.min = min;
|
|
1054
1049
|
function sum(arr) {
|
|
1055
1050
|
let sum = 0;
|
|
1056
|
-
for (
|
|
1057
|
-
sum +=
|
|
1051
|
+
for (const entry of arr) {
|
|
1052
|
+
sum += entry;
|
|
1058
1053
|
}
|
|
1059
1054
|
return sum;
|
|
1060
1055
|
}
|
|
@@ -1091,7 +1086,6 @@ function mergeIntervals(intervals, w = 5000) {
|
|
|
1091
1086
|
// start from the next interval and merge if needed
|
|
1092
1087
|
for (let i = 1; i < intervals.length; i++) {
|
|
1093
1088
|
// get the top element
|
|
1094
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1095
1089
|
top = stack.at(-1);
|
|
1096
1090
|
// if the current interval doesn't overlap with the
|
|
1097
1091
|
// stack top element, push it to the stack
|
|
@@ -1123,3 +1117,10 @@ exports.gatherOverlaps = gatherOverlaps;
|
|
|
1123
1117
|
var simpleFeature_1 = require("./simpleFeature");
|
|
1124
1118
|
Object.defineProperty(exports, "SimpleFeature", { enumerable: true, get: function () { return __importDefault(simpleFeature_1).default; } });
|
|
1125
1119
|
Object.defineProperty(exports, "isFeature", { enumerable: true, get: function () { return simpleFeature_1.isFeature; } });
|
|
1120
|
+
function stripAlpha(str) {
|
|
1121
|
+
const c = (0, colord_1.colord)(str);
|
|
1122
|
+
return c.alpha(1).toHex();
|
|
1123
|
+
}
|
|
1124
|
+
exports.stripAlpha = stripAlpha;
|
|
1125
|
+
var blobToDataURL_1 = require("./blobToDataURL");
|
|
1126
|
+
Object.defineProperty(exports, "blobToDataURL", { enumerable: true, get: function () { return blobToDataURL_1.blobToDataURL; } });
|
|
@@ -29,7 +29,7 @@ class RemoteFileWithRangeCache extends generic_filehandle_1.RemoteFile {
|
|
|
29
29
|
fetchers[String(url)] = this.fetchBinaryRange.bind(this);
|
|
30
30
|
}
|
|
31
31
|
// if it is a range request, route it through the range cache
|
|
32
|
-
const requestHeaders = init
|
|
32
|
+
const requestHeaders = init === null || init === void 0 ? void 0 : init.headers;
|
|
33
33
|
let range;
|
|
34
34
|
if (requestHeaders) {
|
|
35
35
|
if (requestHeaders instanceof Headers) {
|
|
@@ -53,7 +53,7 @@ class RemoteFileWithRangeCache extends generic_filehandle_1.RemoteFile {
|
|
|
53
53
|
const s = Number.parseInt(start, 10);
|
|
54
54
|
const e = Number.parseInt(end, 10);
|
|
55
55
|
const response = (await globalRangeCache.getRange(url, s, e - s + 1, {
|
|
56
|
-
signal: init
|
|
56
|
+
signal: init === null || init === void 0 ? void 0 : init.signal,
|
|
57
57
|
}));
|
|
58
58
|
const { headers } = response;
|
|
59
59
|
return new Response(response.buffer, { status: 206, headers });
|
|
@@ -332,8 +332,7 @@ class GranularRectLayout {
|
|
|
332
332
|
const pLeft = Math.floor(left / this.pitchX);
|
|
333
333
|
const pRight = Math.floor(right / this.pitchX);
|
|
334
334
|
const { bitmap } = this;
|
|
335
|
-
for (
|
|
336
|
-
const row = bitmap[y];
|
|
335
|
+
for (const row of bitmap) {
|
|
337
336
|
if (row) {
|
|
338
337
|
row.discardRange(pLeft, pRight);
|
|
339
338
|
}
|
package/util/map-obj.d.ts
CHANGED
package/util/nanoid.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const urlAlphabet: "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
2
|
+
export function random(bytes: any): Uint8Array;
|
|
3
|
+
export function customRandom(alphabet: any, defaultSize: any, getRandom: any): (size?: any) => string;
|
|
4
|
+
export function customAlphabet(alphabet: any, size?: number): (size?: any) => string;
|
|
5
|
+
export function nanoid(size?: number): string;
|
package/util/nanoid.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
3
|
+
// according to `browser` config in `package.json`.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.nanoid = exports.customAlphabet = exports.customRandom = exports.random = exports.urlAlphabet = void 0;
|
|
6
|
+
// This alphabet uses `A-Za-z0-9_-` symbols.
|
|
7
|
+
// The order of characters is optimized for better gzip and brotli compression.
|
|
8
|
+
// Same as in non-secure/index.js
|
|
9
|
+
exports.urlAlphabet = 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
|
|
10
|
+
let random = bytes => crypto.getRandomValues(new Uint8Array(bytes));
|
|
11
|
+
exports.random = random;
|
|
12
|
+
let customRandom = (alphabet, defaultSize, getRandom) => {
|
|
13
|
+
// First, a bitmask is necessary to generate the ID. The bitmask makes bytes
|
|
14
|
+
// values closer to the alphabet size. The bitmask calculates the closest
|
|
15
|
+
// `2^31 - 1` number, which exceeds the alphabet size.
|
|
16
|
+
// For example, the bitmask for the alphabet size 30 is 31 (00011111).
|
|
17
|
+
// `Math.clz32` is not used, because it is not available in browsers.
|
|
18
|
+
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1;
|
|
19
|
+
// Though, the bitmask solution is not perfect since the bytes exceeding
|
|
20
|
+
// the alphabet size are refused. Therefore, to reliably generate the ID,
|
|
21
|
+
// the random bytes redundancy has to be satisfied.
|
|
22
|
+
// Note: every hardware random generator call is performance expensive,
|
|
23
|
+
// because the system call for entropy collection takes a lot of time.
|
|
24
|
+
// So, to avoid additional system calls, extra bytes are requested in advance.
|
|
25
|
+
// Next, a step determines how many random bytes to generate.
|
|
26
|
+
// The number of random bytes gets decided upon the ID size, mask,
|
|
27
|
+
// alphabet size, and magic number 1.6 (using 1.6 peaks at performance
|
|
28
|
+
// according to benchmarks).
|
|
29
|
+
// `-~f => Math.ceil(f)` if f is a float
|
|
30
|
+
// `-~i => i + 1` if i is an integer
|
|
31
|
+
let step = -~((1.6 * mask * defaultSize) / alphabet.length);
|
|
32
|
+
return (size = defaultSize) => {
|
|
33
|
+
let id = '';
|
|
34
|
+
while (true) {
|
|
35
|
+
let bytes = getRandom(step);
|
|
36
|
+
// A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
37
|
+
let j = step;
|
|
38
|
+
while (j--) {
|
|
39
|
+
// Adding `|| ''` refuses a random byte that exceeds the alphabet size.
|
|
40
|
+
id += alphabet[bytes[j] & mask] || '';
|
|
41
|
+
if (id.length === size)
|
|
42
|
+
return id;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
exports.customRandom = customRandom;
|
|
48
|
+
let customAlphabet = (alphabet, size = 21) => (0, exports.customRandom)(alphabet, size, exports.random);
|
|
49
|
+
exports.customAlphabet = customAlphabet;
|
|
50
|
+
let nanoid = (size = 21) => crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
51
|
+
// It is incorrect to use bytes exceeding the alphabet size.
|
|
52
|
+
// The following mask reduces the random byte in the 0-255 value
|
|
53
|
+
// range to the 0-63 value range. Therefore, adding hacks, such
|
|
54
|
+
// as empty string fallback or magic numbers, is unnecessary because
|
|
55
|
+
// the bitmask trims bytes down to the alphabet size.
|
|
56
|
+
byte &= 63;
|
|
57
|
+
if (byte < 36) {
|
|
58
|
+
// `0-9a-z`
|
|
59
|
+
id += byte.toString(36);
|
|
60
|
+
}
|
|
61
|
+
else if (byte < 62) {
|
|
62
|
+
// `A-Z`
|
|
63
|
+
id += (byte - 26).toString(36).toUpperCase();
|
|
64
|
+
}
|
|
65
|
+
else if (byte > 62) {
|
|
66
|
+
id += '-';
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
id += '_';
|
|
70
|
+
}
|
|
71
|
+
return id;
|
|
72
|
+
}, '');
|
|
73
|
+
exports.nanoid = nanoid;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
3
|
// This file is a ponyfill for the HTML5 OffscreenCanvas API.
|
|
3
4
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
5
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
@@ -25,9 +26,7 @@ const weHave = {
|
|
|
25
26
|
};
|
|
26
27
|
if (weHave.realOffscreenCanvas) {
|
|
27
28
|
exports.createCanvas = (width, height) => new OffscreenCanvas(width, height);
|
|
28
|
-
// eslint-disable-next-line no-restricted-globals
|
|
29
29
|
exports.createImageBitmap = window.createImageBitmap || self.createImageBitmap;
|
|
30
|
-
// eslint-disable-next-line no-restricted-globals
|
|
31
30
|
exports.ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
|
|
32
31
|
}
|
|
33
32
|
else if (weHave.node) {
|
|
@@ -27,11 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.ReactRendering = exports.getSerializedSvg = exports.renderToAbstractCanvas = void 0;
|
|
30
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
30
31
|
const react_1 = __importDefault(require("react"));
|
|
31
32
|
const canvas_sequencer_1 = require("canvas-sequencer");
|
|
32
33
|
// locals
|
|
33
34
|
const offscreenCanvasPonyfill_1 = require("./offscreenCanvasPonyfill");
|
|
34
|
-
const
|
|
35
|
+
const blobToDataURL_1 = require("./blobToDataURL");
|
|
35
36
|
async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
36
37
|
const { exportSVG, highResolutionScaling = 1 } = opts;
|
|
37
38
|
if (exportSVG) {
|
|
@@ -57,7 +58,7 @@ async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
|
57
58
|
return {
|
|
58
59
|
...result,
|
|
59
60
|
reactElement: (react_1.default.createElement("image", { width: width, height: height, xlinkHref: 'convertToBlob' in canvas
|
|
60
|
-
? await (0,
|
|
61
|
+
? await (0, blobToDataURL_1.blobToDataURL)(await canvas.convertToBlob({
|
|
61
62
|
type: 'image/png',
|
|
62
63
|
}))
|
|
63
64
|
: canvas.toDataURL('image/png') })),
|
package/util/tracks.d.ts
CHANGED
|
@@ -16,12 +16,8 @@ export declare function getParentRenderProps(node: IAnyStateTreeNode): any;
|
|
|
16
16
|
export declare const UNKNOWN = "UNKNOWN";
|
|
17
17
|
export declare const UNSUPPORTED = "UNSUPPORTED";
|
|
18
18
|
export declare function getBlob(id: string): File;
|
|
19
|
-
export declare function getBlobMap():
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
export declare function setBlobMap(map: {
|
|
23
|
-
[key: string]: File;
|
|
24
|
-
}): void;
|
|
19
|
+
export declare function getBlobMap(): Record<string, File>;
|
|
20
|
+
export declare function setBlobMap(map: Record<string, File>): void;
|
|
25
21
|
export declare function storeBlobLocation(location: PreFileLocation): import("./types").PreUriLocation | import("./types").PreLocalPathLocation | {
|
|
26
22
|
name: string;
|
|
27
23
|
blobId: string;
|