@jbrowse/core 2.7.0 → 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/DataGridDetails.js +8 -3
- package/package.json +2 -2
- package/pluggableElementTypes/renderers/RendererType.js +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/MenuButton.d.ts +8 -0
- package/ui/MenuButton.js +42 -0
- package/ui/SanitizedHTML.d.ts +1 -1
- package/ui/SanitizedHTML.js +4 -1
- package/util/blobToDataURL.d.ts +1 -0
- package/util/blobToDataURL.js +18 -0
- package/util/index.d.ts +4 -2
- package/util/index.js +11 -17
- package/util/offscreenCanvasUtils.js +2 -2
- package/BaseFeatureWidget/BaseFeatureDetail/UriLink.d.ts +0 -7
- package/BaseFeatureWidget/BaseFeatureDetail/UriLink.js +0 -13
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuItem } from '@jbrowse/core/ui';
|
|
3
|
+
declare const MenuButton: ({ children, menuItems, ...rest }: {
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
children?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | undefined;
|
|
6
|
+
menuItems: MenuItem[];
|
|
7
|
+
}) => React.JSX.Element;
|
|
8
|
+
export default MenuButton;
|
package/ui/MenuButton.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const Menu_1 = __importDefault(require("@jbrowse/core/ui/Menu"));
|
|
31
|
+
const material_1 = require("@mui/material");
|
|
32
|
+
const mobx_react_1 = require("mobx-react");
|
|
33
|
+
const MenuButton = (0, mobx_react_1.observer)(function MenuButton({ children, menuItems, ...rest }) {
|
|
34
|
+
const [anchorEl, setAnchorEl] = (0, react_1.useState)();
|
|
35
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
36
|
+
react_1.default.createElement(material_1.IconButton, { ...rest, onClick: event => setAnchorEl(event.currentTarget) }, children),
|
|
37
|
+
react_1.default.createElement(Menu_1.default, { open: !!anchorEl, anchorEl: anchorEl, onClose: () => setAnchorEl(undefined), onMenuItemClick: (_, callback) => {
|
|
38
|
+
callback();
|
|
39
|
+
setAnchorEl(undefined);
|
|
40
|
+
}, menuItems: menuItems })));
|
|
41
|
+
});
|
|
42
|
+
exports.default = MenuButton;
|
package/ui/SanitizedHTML.d.ts
CHANGED
package/ui/SanitizedHTML.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const escape_html_1 = __importDefault(require("escape-html"));
|
|
8
8
|
const dompurify_1 = __importDefault(require("dompurify"));
|
|
9
|
+
const util_1 = require("../util");
|
|
9
10
|
// source https://github.com/sindresorhus/html-tags/blob/master/html-tags.json
|
|
10
11
|
// with some random uncommon ones removed. note: we just use this to run the content
|
|
11
12
|
// through dompurify without escaping if we see an htmlTag from this list
|
|
@@ -57,7 +58,9 @@ function isHTML(str) {
|
|
|
57
58
|
// products/jbrowse-web/src/tests/Connection.test.tsx test (can delete mock to
|
|
58
59
|
// see)
|
|
59
60
|
//
|
|
60
|
-
function SanitizedHTML({ html }) {
|
|
61
|
+
function SanitizedHTML({ html: pre }) {
|
|
62
|
+
// try to add links to the text first
|
|
63
|
+
const html = (0, util_1.linkify)(pre);
|
|
61
64
|
const value = isHTML(html) ? html : (0, escape_html_1.default)(html);
|
|
62
65
|
if (!added) {
|
|
63
66
|
added = true;
|
|
@@ -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/index.d.ts
CHANGED
|
@@ -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[];
|
|
@@ -339,6 +338,8 @@ export declare function getUriLink(value: {
|
|
|
339
338
|
baseUri?: string;
|
|
340
339
|
}): string;
|
|
341
340
|
export declare function getStr(obj: unknown): string;
|
|
341
|
+
export declare function coarseStripHTML(s: string): string;
|
|
342
|
+
export declare function linkify(s: string): string;
|
|
342
343
|
export declare function measureGridWidth(elements: unknown[], args?: {
|
|
343
344
|
minWidth?: number;
|
|
344
345
|
fontSize?: number;
|
|
@@ -355,7 +356,7 @@ export declare function max(arr: number[], init?: number): number;
|
|
|
355
356
|
export declare function min(arr: number[], init?: number): number;
|
|
356
357
|
export declare function sum(arr: number[]): number;
|
|
357
358
|
export declare function avg(arr: number[]): number;
|
|
358
|
-
export declare function groupBy<T>(array: T
|
|
359
|
+
export declare function groupBy<T>(array: Iterable<T>, predicate: (v: T) => string): Record<string, T[] | undefined>;
|
|
359
360
|
export declare function notEmpty<T>(value: T | null | undefined): value is T;
|
|
360
361
|
export declare function mergeIntervals<T extends {
|
|
361
362
|
start: number;
|
|
@@ -369,3 +370,4 @@ interface BasicFeature {
|
|
|
369
370
|
export declare function gatherOverlaps(regions: BasicFeature[]): BasicFeature[];
|
|
370
371
|
export { default as SimpleFeature, type Feature, type SimpleFeatureSerialized, isFeature, } from './simpleFeature';
|
|
371
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.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.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"));
|
|
@@ -733,21 +733,6 @@ exports.complement = (() => {
|
|
|
733
733
|
return seqString.replaceAll(complementRegex, m => complementTable[m] || '');
|
|
734
734
|
};
|
|
735
735
|
})();
|
|
736
|
-
function blobToDataURL(blob) {
|
|
737
|
-
const a = new FileReader();
|
|
738
|
-
return new Promise((resolve, reject) => {
|
|
739
|
-
a.onload = e => {
|
|
740
|
-
if (e.target) {
|
|
741
|
-
resolve(e.target.result);
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
reject(new Error('unknown result reading blob from canvas'));
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
a.readAsDataURL(blob);
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
exports.blobToDataURL = blobToDataURL;
|
|
751
736
|
// requires immediate execution in jest environment, because (hypothesis) it
|
|
752
737
|
// otherwise listens for prerendered_canvas but reads empty pixels, and doesn't
|
|
753
738
|
// get the contents of the canvas
|
|
@@ -1012,6 +997,13 @@ exports.getStr = getStr;
|
|
|
1012
997
|
function coarseStripHTML(s) {
|
|
1013
998
|
return s.replaceAll(/(<([^>]+)>)/gi, '');
|
|
1014
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;
|
|
1015
1007
|
// heuristic measurement for a column of a @mui/x-data-grid, pass in values from a column
|
|
1016
1008
|
function measureGridWidth(elements, args) {
|
|
1017
1009
|
const { padding = 30, minWidth = 80, fontSize = 12, maxWidth = 1000, stripHTML = false, } = args || {};
|
|
@@ -1130,3 +1122,5 @@ function stripAlpha(str) {
|
|
|
1130
1122
|
return c.alpha(1).toHex();
|
|
1131
1123
|
}
|
|
1132
1124
|
exports.stripAlpha = stripAlpha;
|
|
1125
|
+
var blobToDataURL_1 = require("./blobToDataURL");
|
|
1126
|
+
Object.defineProperty(exports, "blobToDataURL", { enumerable: true, get: function () { return blobToDataURL_1.blobToDataURL; } });
|
|
@@ -32,7 +32,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
32
32
|
const canvas_sequencer_1 = require("canvas-sequencer");
|
|
33
33
|
// locals
|
|
34
34
|
const offscreenCanvasPonyfill_1 = require("./offscreenCanvasPonyfill");
|
|
35
|
-
const
|
|
35
|
+
const blobToDataURL_1 = require("./blobToDataURL");
|
|
36
36
|
async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
37
37
|
const { exportSVG, highResolutionScaling = 1 } = opts;
|
|
38
38
|
if (exportSVG) {
|
|
@@ -58,7 +58,7 @@ async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
|
58
58
|
return {
|
|
59
59
|
...result,
|
|
60
60
|
reactElement: (react_1.default.createElement("image", { width: width, height: height, xlinkHref: 'convertToBlob' in canvas
|
|
61
|
-
? await (0,
|
|
61
|
+
? await (0, blobToDataURL_1.blobToDataURL)(await canvas.convertToBlob({
|
|
62
62
|
type: 'image/png',
|
|
63
63
|
}))
|
|
64
64
|
: canvas.toDataURL('image/png') })),
|
|
@@ -1,13 +0,0 @@
|
|
|
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 react_1 = __importDefault(require("react"));
|
|
7
|
-
const util_1 = require("../../util");
|
|
8
|
-
const ui_1 = require("../../ui");
|
|
9
|
-
function UriLink({ value, }) {
|
|
10
|
-
const href = (0, util_1.getUriLink)(value);
|
|
11
|
-
return react_1.default.createElement(ui_1.SanitizedHTML, { html: `<a href="${href}">${href}</a>` });
|
|
12
|
-
}
|
|
13
|
-
exports.default = UriLink;
|