@jbrowse/core 2.7.0 → 2.7.2
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/PluginLoader.d.ts +1 -0
- package/PluginLoader.js +2 -1
- package/package.json +2 -2
- package/pluggableElementTypes/models/BaseConnectionModelFactory.d.ts +5 -0
- package/pluggableElementTypes/models/BaseConnectionModelFactory.js +6 -1
- package/pluggableElementTypes/models/baseTrackConfig.js +5 -7
- package/pluggableElementTypes/renderers/RendererType.js +1 -1
- package/rpc/BaseRpcDriver.js +2 -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 +33 -10
- package/util/index.js +42 -30
- package/util/layouts/SceneGraph.js +0 -13
- package/util/offscreenCanvasUtils.js +2 -2
- package/util/types/index.d.ts +4 -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
|
@@ -13,23 +13,40 @@ export * from './range';
|
|
|
13
13
|
export * from './dedupe';
|
|
14
14
|
export * from './offscreenCanvasPonyfill';
|
|
15
15
|
export * from './offscreenCanvasUtils';
|
|
16
|
-
export declare const inDevelopment: boolean;
|
|
17
|
-
export declare const inProduction: boolean;
|
|
18
16
|
export declare function useDebounce<T>(value: T, delay: number): T;
|
|
19
17
|
export declare function useWidthSetter(view: {
|
|
20
18
|
setWidth: (arg: number) => void;
|
|
21
19
|
}, padding: string): import("react").RefObject<HTMLDivElement>;
|
|
22
20
|
export declare function useDebouncedCallback<T>(callback: (...args: T[]) => void, wait?: number): (...args: T[]) => void;
|
|
23
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* find the first node in the hierarchy that matches the given predicate
|
|
23
|
+
*/
|
|
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
|
+
/**
|
|
27
|
+
* find the first node in the hierarchy that matches the given 'is' typescript
|
|
28
|
+
* type guard predicate
|
|
29
|
+
*/
|
|
26
30
|
export declare function findParentThatIs<T extends (a: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: T): TypeTestedByPredicate<T>;
|
|
27
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* get the current JBrowse session model, starting at any node in the state
|
|
33
|
+
* tree
|
|
34
|
+
*/
|
|
28
35
|
export declare function getSession(node: IAnyStateTreeNode): import("./types").AbstractSessionModel;
|
|
29
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* get the state model of the view in the state tree that contains the given
|
|
38
|
+
* node
|
|
39
|
+
*/
|
|
30
40
|
export declare function getContainingView(node: IAnyStateTreeNode): import("./types").AbstractViewModel;
|
|
31
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* get the state model of the view in the state tree that contains the given
|
|
43
|
+
* node
|
|
44
|
+
*/
|
|
32
45
|
export declare function getContainingTrack(node: IAnyStateTreeNode): import("./types").AbstractTrackModel;
|
|
46
|
+
/**
|
|
47
|
+
* get the state model of the display in the state tree that contains the given
|
|
48
|
+
* node
|
|
49
|
+
*/
|
|
33
50
|
export declare function getContainingDisplay(node: IAnyStateTreeNode): import("./types").AbstractDisplayModel;
|
|
34
51
|
/**
|
|
35
52
|
* Assemble a 1-based "locString" from an interbase genomic location
|
|
@@ -159,10 +176,14 @@ export declare function iterMap<T, U>(iter: Iterable<T>, func: (arg: T) => U, si
|
|
|
159
176
|
/**
|
|
160
177
|
* Returns the index of the last element in the array where predicate is true,
|
|
161
178
|
* and -1 otherwise.
|
|
179
|
+
* Based on https://stackoverflow.com/a/53187807
|
|
180
|
+
*
|
|
162
181
|
* @param array - The source array to search in
|
|
182
|
+
*
|
|
163
183
|
* @param predicate - find calls predicate once for each element of the array, in
|
|
164
|
-
* descending order, until it finds one where predicate returns true.
|
|
165
|
-
*
|
|
184
|
+
* descending order, until it finds one where predicate returns true.
|
|
185
|
+
*
|
|
186
|
+
* @returns findLastIndex returns element index where predicate is true.
|
|
166
187
|
* Otherwise, findLastIndex returns -1.
|
|
167
188
|
*/
|
|
168
189
|
export declare function findLastIndex<T>(array: T[], predicate: (value: T, index: number, obj: T[]) => boolean): number;
|
|
@@ -212,7 +233,6 @@ export declare const isElectron: boolean;
|
|
|
212
233
|
export declare function revcom(seqString: string): string;
|
|
213
234
|
export declare function reverse(seqString: string): string;
|
|
214
235
|
export declare const complement: (seqString: string) => string;
|
|
215
|
-
export declare function blobToDataURL(blob: Blob): Promise<string>;
|
|
216
236
|
export declare const rIC: (((callback: IdleRequestCallback, options?: IdleRequestOptions | undefined) => number) & typeof requestIdleCallback) | ((cb: Function) => any);
|
|
217
237
|
export declare function measureText(str: unknown, fontSize?: number): number;
|
|
218
238
|
export declare const defaultStarts: string[];
|
|
@@ -339,6 +359,8 @@ export declare function getUriLink(value: {
|
|
|
339
359
|
baseUri?: string;
|
|
340
360
|
}): string;
|
|
341
361
|
export declare function getStr(obj: unknown): string;
|
|
362
|
+
export declare function coarseStripHTML(s: string): string;
|
|
363
|
+
export declare function linkify(s: string): string;
|
|
342
364
|
export declare function measureGridWidth(elements: unknown[], args?: {
|
|
343
365
|
minWidth?: number;
|
|
344
366
|
fontSize?: number;
|
|
@@ -355,7 +377,7 @@ export declare function max(arr: number[], init?: number): number;
|
|
|
355
377
|
export declare function min(arr: number[], init?: number): number;
|
|
356
378
|
export declare function sum(arr: number[]): number;
|
|
357
379
|
export declare function avg(arr: number[]): number;
|
|
358
|
-
export declare function groupBy<T>(array: T
|
|
380
|
+
export declare function groupBy<T>(array: Iterable<T>, predicate: (v: T) => string): Record<string, T[] | undefined>;
|
|
359
381
|
export declare function notEmpty<T>(value: T | null | undefined): value is T;
|
|
360
382
|
export declare function mergeIntervals<T extends {
|
|
361
383
|
start: number;
|
|
@@ -369,3 +391,4 @@ interface BasicFeature {
|
|
|
369
391
|
export declare function gatherOverlaps(regions: BasicFeature[]): BasicFeature[];
|
|
370
392
|
export { default as SimpleFeature, type Feature, type SimpleFeatureSerialized, isFeature, } from './simpleFeature';
|
|
371
393
|
export declare function stripAlpha(str: string): string;
|
|
394
|
+
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.
|
|
20
|
+
exports.toLocale = exports.getBpDisplayStr = 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 = 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 = 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"));
|
|
@@ -37,10 +37,6 @@ __exportStar(require("./range"), exports);
|
|
|
37
37
|
__exportStar(require("./dedupe"), exports);
|
|
38
38
|
__exportStar(require("./offscreenCanvasPonyfill"), exports);
|
|
39
39
|
__exportStar(require("./offscreenCanvasUtils"), exports);
|
|
40
|
-
exports.inDevelopment = typeof process === 'object' &&
|
|
41
|
-
process.env &&
|
|
42
|
-
process.env.NODE_ENV === 'development';
|
|
43
|
-
exports.inProduction = !exports.inDevelopment;
|
|
44
40
|
function useDebounce(value, delay) {
|
|
45
41
|
const [debouncedValue, setDebouncedValue] = (0, react_1.useState)(value);
|
|
46
42
|
(0, react_1.useEffect)(() => {
|
|
@@ -78,7 +74,8 @@ function useDebouncedCallback(callback, wait = 400) {
|
|
|
78
74
|
clearTimeout(timeout.current);
|
|
79
75
|
}
|
|
80
76
|
}
|
|
81
|
-
// make sure our timeout gets cleared if our consuming component gets
|
|
77
|
+
// make sure our timeout gets cleared if our consuming component gets
|
|
78
|
+
// unmounted
|
|
82
79
|
(0, react_1.useEffect)(() => cleanup, []);
|
|
83
80
|
return function debouncedCallback(...args) {
|
|
84
81
|
// capture latest args
|
|
@@ -94,7 +91,9 @@ function useDebouncedCallback(callback, wait = 400) {
|
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
93
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
97
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* find the first node in the hierarchy that matches the given predicate
|
|
96
|
+
*/
|
|
98
97
|
function findParentThat(node, predicate) {
|
|
99
98
|
if (!(0, mobx_state_tree_1.hasParent)(node)) {
|
|
100
99
|
throw new Error('node does not have parent');
|
|
@@ -161,12 +160,18 @@ function springAnimate(fromValue, toValue, setValue, onFinish = () => { }, preci
|
|
|
161
160
|
];
|
|
162
161
|
}
|
|
163
162
|
exports.springAnimate = springAnimate;
|
|
164
|
-
|
|
163
|
+
/**
|
|
164
|
+
* find the first node in the hierarchy that matches the given 'is' typescript
|
|
165
|
+
* type guard predicate
|
|
166
|
+
*/
|
|
165
167
|
function findParentThatIs(node, predicate) {
|
|
166
168
|
return findParentThat(node, predicate);
|
|
167
169
|
}
|
|
168
170
|
exports.findParentThatIs = findParentThatIs;
|
|
169
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* get the current JBrowse session model, starting at any node in the state
|
|
173
|
+
* tree
|
|
174
|
+
*/
|
|
170
175
|
function getSession(node) {
|
|
171
176
|
try {
|
|
172
177
|
return findParentThatIs(node, types_1.isSessionModel);
|
|
@@ -176,7 +181,10 @@ function getSession(node) {
|
|
|
176
181
|
}
|
|
177
182
|
}
|
|
178
183
|
exports.getSession = getSession;
|
|
179
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* get the state model of the view in the state tree that contains the given
|
|
186
|
+
* node
|
|
187
|
+
*/
|
|
180
188
|
function getContainingView(node) {
|
|
181
189
|
try {
|
|
182
190
|
return findParentThatIs(node, types_1.isViewModel);
|
|
@@ -186,7 +194,10 @@ function getContainingView(node) {
|
|
|
186
194
|
}
|
|
187
195
|
}
|
|
188
196
|
exports.getContainingView = getContainingView;
|
|
189
|
-
/**
|
|
197
|
+
/**
|
|
198
|
+
* get the state model of the view in the state tree that contains the given
|
|
199
|
+
* node
|
|
200
|
+
*/
|
|
190
201
|
function getContainingTrack(node) {
|
|
191
202
|
try {
|
|
192
203
|
return findParentThatIs(node, types_1.isTrackModel);
|
|
@@ -196,6 +207,10 @@ function getContainingTrack(node) {
|
|
|
196
207
|
}
|
|
197
208
|
}
|
|
198
209
|
exports.getContainingTrack = getContainingTrack;
|
|
210
|
+
/**
|
|
211
|
+
* get the state model of the display in the state tree that contains the given
|
|
212
|
+
* node
|
|
213
|
+
*/
|
|
199
214
|
function getContainingDisplay(node) {
|
|
200
215
|
try {
|
|
201
216
|
return findParentThatIs(node, types_1.isDisplayModel);
|
|
@@ -516,14 +531,17 @@ function iterMap(iter, func, sizeHint) {
|
|
|
516
531
|
return results;
|
|
517
532
|
}
|
|
518
533
|
exports.iterMap = iterMap;
|
|
519
|
-
// https://stackoverflow.com/a/53187807
|
|
520
534
|
/**
|
|
521
535
|
* Returns the index of the last element in the array where predicate is true,
|
|
522
536
|
* and -1 otherwise.
|
|
537
|
+
* Based on https://stackoverflow.com/a/53187807
|
|
538
|
+
*
|
|
523
539
|
* @param array - The source array to search in
|
|
540
|
+
*
|
|
524
541
|
* @param predicate - find calls predicate once for each element of the array, in
|
|
525
|
-
* descending order, until it finds one where predicate returns true.
|
|
526
|
-
*
|
|
542
|
+
* descending order, until it finds one where predicate returns true.
|
|
543
|
+
*
|
|
544
|
+
* @returns findLastIndex returns element index where predicate is true.
|
|
527
545
|
* Otherwise, findLastIndex returns -1.
|
|
528
546
|
*/
|
|
529
547
|
function findLastIndex(array, predicate) {
|
|
@@ -733,21 +751,6 @@ exports.complement = (() => {
|
|
|
733
751
|
return seqString.replaceAll(complementRegex, m => complementTable[m] || '');
|
|
734
752
|
};
|
|
735
753
|
})();
|
|
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
754
|
// requires immediate execution in jest environment, because (hypothesis) it
|
|
752
755
|
// otherwise listens for prerendered_canvas but reads empty pixels, and doesn't
|
|
753
756
|
// get the contents of the canvas
|
|
@@ -1012,6 +1015,13 @@ exports.getStr = getStr;
|
|
|
1012
1015
|
function coarseStripHTML(s) {
|
|
1013
1016
|
return s.replaceAll(/(<([^>]+)>)/gi, '');
|
|
1014
1017
|
}
|
|
1018
|
+
exports.coarseStripHTML = coarseStripHTML;
|
|
1019
|
+
// based on autolink-js, license MIT
|
|
1020
|
+
function linkify(s) {
|
|
1021
|
+
const pattern = /(^|[\s\n]|<[A-Za-z]*\/?>)((?:https?|ftp):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/gi;
|
|
1022
|
+
return s.replaceAll(pattern, '$1<a href=\'$2\' target="_blank">$2</a>');
|
|
1023
|
+
}
|
|
1024
|
+
exports.linkify = linkify;
|
|
1015
1025
|
// heuristic measurement for a column of a @mui/x-data-grid, pass in values from a column
|
|
1016
1026
|
function measureGridWidth(elements, args) {
|
|
1017
1027
|
const { padding = 30, minWidth = 80, fontSize = 12, maxWidth = 1000, stripHTML = false, } = args || {};
|
|
@@ -1130,3 +1140,5 @@ function stripAlpha(str) {
|
|
|
1130
1140
|
return c.alpha(1).toHex();
|
|
1131
1141
|
}
|
|
1132
1142
|
exports.stripAlpha = stripAlpha;
|
|
1143
|
+
var blobToDataURL_1 = require("./blobToDataURL");
|
|
1144
|
+
Object.defineProperty(exports, "blobToDataURL", { enumerable: true, get: function () { return blobToDataURL_1.blobToDataURL; } });
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const __1 = require("..");
|
|
4
3
|
class SceneGraph {
|
|
5
4
|
/**
|
|
6
5
|
* note: all coordinates are inter-base or inter-pixel coordinates
|
|
@@ -14,18 +13,6 @@ class SceneGraph {
|
|
|
14
13
|
this.width = width;
|
|
15
14
|
this.height = height;
|
|
16
15
|
this.data = data;
|
|
17
|
-
if (__1.inDevelopment &&
|
|
18
|
-
(typeof name !== 'string' ||
|
|
19
|
-
typeof left !== 'number' ||
|
|
20
|
-
Number.isNaN(left) ||
|
|
21
|
-
typeof top !== 'number' ||
|
|
22
|
-
Number.isNaN(top) ||
|
|
23
|
-
typeof width !== 'number' ||
|
|
24
|
-
Number.isNaN(width) ||
|
|
25
|
-
typeof height !== 'number' ||
|
|
26
|
-
Number.isNaN(height))) {
|
|
27
|
-
throw new TypeError('invalid SceneGraph arguments');
|
|
28
|
-
}
|
|
29
16
|
this.children = new Map();
|
|
30
17
|
this.absoluteCache = { dirty: true };
|
|
31
18
|
}
|
|
@@ -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') })),
|
package/util/types/index.d.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface AbstractSessionModel extends AbstractViewContainer {
|
|
|
52
52
|
selection?: unknown;
|
|
53
53
|
focusedViewId?: string;
|
|
54
54
|
themeName?: string;
|
|
55
|
+
hovered: unknown;
|
|
56
|
+
setHovered: (arg: unknown) => void;
|
|
55
57
|
setFocusedViewId?: (id: string) => void;
|
|
56
58
|
allThemes?: () => Record<string, ThemeOptions | undefined>;
|
|
57
59
|
setSelection: (feature: Feature) => void;
|
|
@@ -117,9 +119,9 @@ export interface Widget {
|
|
|
117
119
|
export interface SessionWithWidgets extends AbstractSessionModel {
|
|
118
120
|
minimized: boolean;
|
|
119
121
|
visibleWidget?: Widget;
|
|
120
|
-
widgets: Map<string, Widget>;
|
|
122
|
+
widgets: Map<string | number, Widget>;
|
|
121
123
|
hideAllWidgets: () => void;
|
|
122
|
-
activeWidgets: Map<string, Widget>;
|
|
124
|
+
activeWidgets: Map<string | number, Widget>;
|
|
123
125
|
addWidget(typeName: string, id: string, initialState?: Record<string, unknown>, configuration?: {
|
|
124
126
|
type: string;
|
|
125
127
|
}): Widget;
|
|
@@ -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;
|