@jbrowse/core 2.4.1 → 2.4.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.d.ts +1 -3
- package/BaseFeatureWidget/SequenceFeatureDetails.js +3 -10
- package/BaseFeatureWidget/index.d.ts +1 -1
- package/BaseFeatureWidget/index.js +6 -9
- package/PluginManager.d.ts +1 -3
- package/ReExports/modules.d.ts +1 -3
- package/configuration/configurationSchema.d.ts +3 -1
- package/configuration/configurationSlot.d.ts +1 -0
- package/package.json +2 -3
- package/pluggableElementTypes/models/baseTrackConfig.js +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/ViewContainer.d.ts +2 -3
- package/ui/ViewContainer.js +7 -39
- package/ui/ViewContainerTitle.d.ts +6 -0
- package/ui/ViewContainerTitle.js +42 -0
- package/util/index.d.ts +5 -2
- package/util/index.js +19 -4
- package/util/io/index.d.ts +3 -1
- package/util/io/index.js +9 -4
- package/util/mst-reflection.d.ts +12 -17
- package/util/mst-reflection.js +13 -12
- package/util/types/index.d.ts +1 -0
- package/util/useMeasure.d.ts +5 -0
- package/util/useMeasure.js +34 -0
package/ui/ViewContainer.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IBaseViewModel } from '../pluggableElementTypes/models';
|
|
3
|
-
declare const
|
|
3
|
+
declare const _default: ({ view, onClose, onMinimize, children, }: {
|
|
4
4
|
view: IBaseViewModel;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
onMinimize: () => void;
|
|
7
|
-
style?: React.CSSProperties | undefined;
|
|
8
7
|
children: React.ReactNode;
|
|
9
8
|
}) => JSX.Element;
|
|
10
|
-
export default
|
|
9
|
+
export default _default;
|
package/ui/ViewContainer.js
CHANGED
|
@@ -30,19 +30,19 @@ const react_1 = __importStar(require("react"));
|
|
|
30
30
|
const material_1 = require("@mui/material");
|
|
31
31
|
const mui_1 = require("tss-react/mui");
|
|
32
32
|
const mobx_react_1 = require("mobx-react");
|
|
33
|
-
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
34
|
-
const react_use_measure_1 = __importDefault(require("react-use-measure"));
|
|
35
33
|
// icons
|
|
36
34
|
const Close_1 = __importDefault(require("@mui/icons-material/Close"));
|
|
37
35
|
const Minimize_1 = __importDefault(require("@mui/icons-material/Minimize"));
|
|
38
36
|
const Add_1 = __importDefault(require("@mui/icons-material/Add"));
|
|
39
|
-
const EditableTypography_1 = __importDefault(require("./EditableTypography"));
|
|
40
37
|
const ViewMenu_1 = __importDefault(require("./ViewMenu"));
|
|
38
|
+
const util_1 = require("../util");
|
|
39
|
+
const ViewContainerTitle_1 = __importDefault(require("./ViewContainerTitle"));
|
|
41
40
|
const useStyles = (0, mui_1.makeStyles)()(theme => ({
|
|
42
41
|
viewContainer: {
|
|
43
42
|
overflow: 'hidden',
|
|
44
43
|
background: theme.palette.secondary.main,
|
|
45
44
|
margin: theme.spacing(0.5),
|
|
45
|
+
padding: `0 ${theme.spacing(1)} ${theme.spacing(1)}`,
|
|
46
46
|
},
|
|
47
47
|
icon: {
|
|
48
48
|
color: theme.palette.secondary.contrastText,
|
|
@@ -50,34 +50,11 @@ const useStyles = (0, mui_1.makeStyles)()(theme => ({
|
|
|
50
50
|
grow: {
|
|
51
51
|
flexGrow: 1,
|
|
52
52
|
},
|
|
53
|
-
input: {
|
|
54
|
-
paddingBottom: 0,
|
|
55
|
-
paddingTop: 2,
|
|
56
|
-
},
|
|
57
|
-
inputBase: {
|
|
58
|
-
color: theme.palette.secondary.contrastText,
|
|
59
|
-
},
|
|
60
|
-
inputRoot: {
|
|
61
|
-
'&:hover': {
|
|
62
|
-
backgroundColor: theme.palette.secondary.light,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
inputFocused: {
|
|
66
|
-
borderColor: theme.palette.primary.main,
|
|
67
|
-
backgroundColor: theme.palette.secondary.light,
|
|
68
|
-
},
|
|
69
53
|
}));
|
|
70
|
-
|
|
71
|
-
var _a;
|
|
54
|
+
exports.default = (0, mobx_react_1.observer)(function ({ view, onClose, onMinimize, children, }) {
|
|
72
55
|
const { classes } = useStyles();
|
|
73
56
|
const theme = (0, material_1.useTheme)();
|
|
74
|
-
const
|
|
75
|
-
const [ref, { width }] = (0, react_use_measure_1.default)();
|
|
76
|
-
(0, react_1.useEffect)(() => {
|
|
77
|
-
if (width && (0, mobx_state_tree_1.isAlive)(view)) {
|
|
78
|
-
view.setWidth(width - Number.parseInt(padWidth, 10) * 2);
|
|
79
|
-
}
|
|
80
|
-
}, [padWidth, view, width]);
|
|
57
|
+
const ref = (0, util_1.useWidthSetter)(view, theme.spacing(1));
|
|
81
58
|
const scrollRef = (0, react_1.useRef)(null);
|
|
82
59
|
// scroll the view into view when first mounted
|
|
83
60
|
// note that this effect will run only once, because of
|
|
@@ -86,23 +63,14 @@ const ViewContainer = (0, mobx_react_1.observer)(function ({ view, onClose, onMi
|
|
|
86
63
|
var _a, _b;
|
|
87
64
|
(_b = (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'center' });
|
|
88
65
|
}, []);
|
|
89
|
-
return (react_1.default.createElement(material_1.Paper, { ref: ref, elevation: 12, className: classes.viewContainer
|
|
66
|
+
return (react_1.default.createElement(material_1.Paper, { ref: ref, elevation: 12, className: classes.viewContainer },
|
|
90
67
|
react_1.default.createElement("div", { ref: scrollRef, style: { display: 'flex' } },
|
|
91
68
|
react_1.default.createElement(ViewMenu_1.default, { model: view, IconProps: { className: classes.icon } }),
|
|
92
69
|
react_1.default.createElement("div", { className: classes.grow }),
|
|
93
|
-
react_1.default.createElement(
|
|
94
|
-
react_1.default.createElement(EditableTypography_1.default, { value: view.displayName ||
|
|
95
|
-
// @ts-expect-error
|
|
96
|
-
`${((_a = view.assemblyNames) === null || _a === void 0 ? void 0 : _a.join(',')) || 'Untitled view'}${view.minimized ? ' (minimized)' : ''}`, setValue: val => view.setDisplayName(val), variant: "body2", classes: {
|
|
97
|
-
input: classes.input,
|
|
98
|
-
inputBase: classes.inputBase,
|
|
99
|
-
inputRoot: classes.inputRoot,
|
|
100
|
-
inputFocused: classes.inputFocused,
|
|
101
|
-
} })),
|
|
70
|
+
react_1.default.createElement(ViewContainerTitle_1.default, { view: view }),
|
|
102
71
|
react_1.default.createElement("div", { className: classes.grow }),
|
|
103
72
|
react_1.default.createElement(material_1.IconButton, { "data-testid": "minimize_view", onClick: onMinimize }, view.minimized ? (react_1.default.createElement(Add_1.default, { className: classes.icon, fontSize: "small" })) : (react_1.default.createElement(Minimize_1.default, { className: classes.icon, fontSize: "small" }))),
|
|
104
73
|
react_1.default.createElement(material_1.IconButton, { "data-testid": "close_view", onClick: onClose },
|
|
105
74
|
react_1.default.createElement(Close_1.default, { className: classes.icon, fontSize: "small" }))),
|
|
106
75
|
react_1.default.createElement(material_1.Paper, null, children)));
|
|
107
76
|
});
|
|
108
|
-
exports.default = ViewContainer;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 material_1 = require("@mui/material");
|
|
8
|
+
const mui_1 = require("tss-react/mui");
|
|
9
|
+
const mobx_react_1 = require("mobx-react");
|
|
10
|
+
// locals
|
|
11
|
+
const EditableTypography_1 = __importDefault(require("./EditableTypography"));
|
|
12
|
+
const useStyles = (0, mui_1.makeStyles)()(theme => ({
|
|
13
|
+
input: {
|
|
14
|
+
paddingBottom: 0,
|
|
15
|
+
paddingTop: 2,
|
|
16
|
+
},
|
|
17
|
+
inputBase: {
|
|
18
|
+
color: theme.palette.secondary.contrastText,
|
|
19
|
+
},
|
|
20
|
+
inputRoot: {
|
|
21
|
+
'&:hover': {
|
|
22
|
+
backgroundColor: theme.palette.secondary.light,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
inputFocused: {
|
|
26
|
+
borderColor: theme.palette.primary.main,
|
|
27
|
+
backgroundColor: theme.palette.secondary.light,
|
|
28
|
+
},
|
|
29
|
+
}));
|
|
30
|
+
exports.default = (0, mobx_react_1.observer)(function ViewContainerTitle({ view, }) {
|
|
31
|
+
var _a;
|
|
32
|
+
const { classes } = useStyles();
|
|
33
|
+
return (react_1.default.createElement(material_1.Tooltip, { title: "Rename view", arrow: true },
|
|
34
|
+
react_1.default.createElement(EditableTypography_1.default, { value: view.displayName ||
|
|
35
|
+
// @ts-expect-error
|
|
36
|
+
`${((_a = view.assemblyNames) === null || _a === void 0 ? void 0 : _a.join(',')) || 'Untitled view'}${view.minimized ? ' (minimized)' : ''}`, setValue: val => view.setDisplayName(val), variant: "body2", classes: {
|
|
37
|
+
input: classes.input,
|
|
38
|
+
inputBase: classes.inputBase,
|
|
39
|
+
inputRoot: classes.inputRoot,
|
|
40
|
+
inputFocused: classes.inputFocused,
|
|
41
|
+
} })));
|
|
42
|
+
});
|
package/util/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import PluginManager from '../PluginManager';
|
|
2
3
|
import { IAnyStateTreeNode, IStateTreeNode } from 'mobx-state-tree';
|
|
3
4
|
import { IReactionPublic, IReactionOptions } from 'mobx';
|
|
@@ -14,12 +15,14 @@ export * from './offscreenCanvasUtils';
|
|
|
14
15
|
export declare const inDevelopment: boolean;
|
|
15
16
|
export declare const inProduction: boolean;
|
|
16
17
|
export declare function useDebounce<T>(value: T, delay: number): T;
|
|
18
|
+
export declare function useWidthSetter(view: {
|
|
19
|
+
setWidth: (arg: number) => void;
|
|
20
|
+
}, padding: string): import("react").RefObject<HTMLDivElement>;
|
|
17
21
|
export declare function useDebouncedCallback<T>(callback: (...args: T[]) => void, wait?: number): (...args: T[]) => void;
|
|
18
22
|
/** find the first node in the hierarchy that matches the given predicate */
|
|
19
23
|
export declare function findParentThat(node: IAnyStateTreeNode, predicate: (thing: IAnyStateTreeNode) => boolean): IAnyStateTreeNode;
|
|
20
24
|
export declare function springAnimate(fromValue: number, toValue: number, setValue: (value: number) => void, onFinish?: () => void, precision?: number, tension?: number, friction?: number): (() => void)[];
|
|
21
|
-
|
|
22
|
-
export declare function findParentThatIs<PREDICATE extends (thing: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: PREDICATE): TypeTestedByPredicate<PREDICATE> & IAnyStateTreeNode;
|
|
25
|
+
export declare function findParentThatIs<T extends (a: IAnyStateTreeNode) => boolean>(node: IAnyStateTreeNode, predicate: T): TypeTestedByPredicate<T> & IAnyStateTreeNode;
|
|
23
26
|
/** get the current JBrowse session model, starting at any node in the state tree */
|
|
24
27
|
export declare function getSession(node: IAnyStateTreeNode): import("./types").AbstractSessionModel & IAnyStateTreeNode;
|
|
25
28
|
/** get the state model of the view in the state tree that contains the given node */
|
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.
|
|
21
|
-
exports.isFeature = exports.SimpleFeature = 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 = void 0;
|
|
20
|
+
exports.supportedIndexingAdapters = exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.blobToDataURL = exports.complement = exports.reverse = exports.revcom = exports.isElectron = exports.stringify = exports.shorten = exports.minmax = exports.renameRegionsIfNeeded = exports.renameRegionIfNeeded = exports.makeAbortableReaction = 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.isFeature = exports.SimpleFeature = 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 = 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,6 +27,7 @@ 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
|
+
const useMeasure_1 = __importDefault(require("@jbrowse/core/util/useMeasure"));
|
|
30
31
|
__exportStar(require("./types"), exports);
|
|
31
32
|
__exportStar(require("./aborting"), exports);
|
|
32
33
|
__exportStar(require("./when"), exports);
|
|
@@ -51,6 +52,20 @@ function useDebounce(value, delay) {
|
|
|
51
52
|
return debouncedValue;
|
|
52
53
|
}
|
|
53
54
|
exports.useDebounce = useDebounce;
|
|
55
|
+
// used in ViewContainer files to get the width
|
|
56
|
+
function useWidthSetter(view, padding) {
|
|
57
|
+
const [ref, { width }] = (0, useMeasure_1.default)();
|
|
58
|
+
(0, react_1.useEffect)(() => {
|
|
59
|
+
if (width && (0, mobx_state_tree_1.isAlive)(view)) {
|
|
60
|
+
// sets after a requestAnimationFrame
|
|
61
|
+
// https://stackoverflow.com/a/58701523/2129219
|
|
62
|
+
// avoids ResizeObserver loop error being shown during development
|
|
63
|
+
requestAnimationFrame(() => view.setWidth(width - Number.parseInt(padding, 10) * 2));
|
|
64
|
+
}
|
|
65
|
+
}, [padding, view, width]);
|
|
66
|
+
return ref;
|
|
67
|
+
}
|
|
68
|
+
exports.useWidthSetter = useWidthSetter;
|
|
54
69
|
// https://stackoverflow.com/questions/56283920/
|
|
55
70
|
function useDebouncedCallback(callback, wait = 400) {
|
|
56
71
|
// track args & timeout handle between calls
|
|
@@ -144,7 +159,7 @@ function springAnimate(fromValue, toValue, setValue, onFinish = () => { }, preci
|
|
|
144
159
|
];
|
|
145
160
|
}
|
|
146
161
|
exports.springAnimate = springAnimate;
|
|
147
|
-
|
|
162
|
+
// find the first node in the hierarchy that matches the given 'is' typescript type guard predicate
|
|
148
163
|
function findParentThatIs(node, predicate) {
|
|
149
164
|
return findParentThat(node, predicate);
|
|
150
165
|
}
|
|
@@ -616,7 +631,7 @@ async function renameRegionsIfNeeded(assemblyManager, args) {
|
|
|
616
631
|
throw new Error('sessionId is required');
|
|
617
632
|
}
|
|
618
633
|
const assemblyNames = regions.map(region => region.assemblyName);
|
|
619
|
-
const assemblyMaps = Object.fromEntries(await Promise.all(assemblyNames.map(async (assemblyName) => {
|
|
634
|
+
const assemblyMaps = Object.fromEntries(await Promise.all([...new Set(assemblyNames)].map(async (assemblyName) => {
|
|
620
635
|
return [
|
|
621
636
|
assemblyName,
|
|
622
637
|
await assemblyManager.getRefNameMapForAdapter(adapterConfig, assemblyName, args),
|
package/util/io/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { GenericFilehandle, Fetcher } from 'generic-filehandle';
|
|
2
|
-
import { FileLocation } from '../types';
|
|
2
|
+
import { FileLocation, UriLocation } from '../types';
|
|
3
3
|
import PluginManager from '../../PluginManager';
|
|
4
|
+
/** if a UriLocation has a baseUri, resolves its uri with respect to that base */
|
|
5
|
+
export declare function resolveUriLocation(location: UriLocation): UriLocation;
|
|
4
6
|
export declare function openLocation(location: FileLocation, pluginManager?: PluginManager): GenericFilehandle;
|
|
5
7
|
export declare function getFetcher(location: FileLocation, pluginManager?: PluginManager): Fetcher;
|
|
6
8
|
export { RemoteFileWithRangeCache } from './RemoteFileWithRangeCache';
|
package/util/io/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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
|
-
exports.RemoteFileWithRangeCache = exports.getFetcher = exports.openLocation = void 0;
|
|
6
|
+
exports.RemoteFileWithRangeCache = exports.getFetcher = exports.openLocation = exports.resolveUriLocation = void 0;
|
|
7
7
|
const generic_filehandle_1 = require("generic-filehandle");
|
|
8
8
|
const detect_node_1 = __importDefault(require("detect-node"));
|
|
9
9
|
// locals
|
|
@@ -17,6 +17,13 @@ function isLocalPathLocation(location) {
|
|
|
17
17
|
function isBlobLocation(location) {
|
|
18
18
|
return 'blobId' in location;
|
|
19
19
|
}
|
|
20
|
+
/** if a UriLocation has a baseUri, resolves its uri with respect to that base */
|
|
21
|
+
function resolveUriLocation(location) {
|
|
22
|
+
return location.baseUri
|
|
23
|
+
? { ...location, uri: new URL(location.uri, location.baseUri).href }
|
|
24
|
+
: location;
|
|
25
|
+
}
|
|
26
|
+
exports.resolveUriLocation = resolveUriLocation;
|
|
20
27
|
function openLocation(location, pluginManager) {
|
|
21
28
|
if (!location) {
|
|
22
29
|
throw new Error('must provide a location to openLocation');
|
|
@@ -46,9 +53,7 @@ function openLocation(location, pluginManager) {
|
|
|
46
53
|
throw new Error('No URI provided');
|
|
47
54
|
}
|
|
48
55
|
// Resolve any relative URLs to absolute URLs
|
|
49
|
-
const absoluteLocation = location
|
|
50
|
-
? { ...location, uri: new URL(location.uri, location.baseUri).href }
|
|
51
|
-
: location;
|
|
56
|
+
const absoluteLocation = resolveUriLocation(location);
|
|
52
57
|
// If there is a plugin manager, we can try internet accounts
|
|
53
58
|
if (pluginManager) {
|
|
54
59
|
const internetAccount = getInternetAccount(location, pluginManager);
|
package/util/mst-reflection.d.ts
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
|
+
import { IAnyType, IModelReflectionPropertiesData, IAnyComplexType, ISimpleType, UnionStringArray } from 'mobx-state-tree';
|
|
2
|
+
export interface ILiteralType<T> extends ISimpleType<T> {
|
|
3
|
+
value: T;
|
|
4
|
+
}
|
|
1
5
|
/**
|
|
2
6
|
* get the inner type of an MST optional, array, or late type object
|
|
3
|
-
*
|
|
4
|
-
* @param {IModelType} type
|
|
5
|
-
* @returns {IModelType}
|
|
6
7
|
*/
|
|
7
|
-
export function getSubType(type:
|
|
8
|
+
export declare function getSubType(type: IAnyType): IAnyType;
|
|
8
9
|
/**
|
|
9
|
-
* get the array of
|
|
10
|
-
* @param {MST Union Type obj} unionType
|
|
11
|
-
* @returns {Array<IModelType>}
|
|
10
|
+
* get the array of the subtypes in a union
|
|
12
11
|
*/
|
|
13
|
-
export function getUnionSubTypes(unionType:
|
|
12
|
+
export declare function getUnionSubTypes(unionType: IAnyType): IAnyType[];
|
|
14
13
|
/**
|
|
15
14
|
* get the type of one of the properties of the given MST model type
|
|
16
|
-
*
|
|
17
|
-
* @param {IModelType} type
|
|
18
|
-
* @param {string} propertyName
|
|
19
|
-
* @returns {IModelType}
|
|
20
15
|
*/
|
|
21
|
-
export function getPropertyType(type:
|
|
16
|
+
export declare function getPropertyType(type: IModelReflectionPropertiesData, propertyName: string): IAnyType;
|
|
22
17
|
/**
|
|
23
18
|
* get the base type from inside an MST optional type
|
|
24
|
-
* @param {*} type
|
|
25
19
|
*/
|
|
26
|
-
export function getDefaultValue(type:
|
|
20
|
+
export declare function getDefaultValue(type: IAnyType): any;
|
|
21
|
+
export type IEnumerationType<T extends string> = ISimpleType<UnionStringArray<T[]>>;
|
|
27
22
|
/** get the string values of an MST enumeration type */
|
|
28
|
-
export function getEnumerationValues(type:
|
|
29
|
-
export function resolveLateType(maybeLate:
|
|
23
|
+
export declare function getEnumerationValues(type: IAnyComplexType): string[];
|
|
24
|
+
export declare function resolveLateType(maybeLate: IAnyType): any;
|
package/util/mst-reflection.js
CHANGED
|
@@ -5,19 +5,20 @@ exports.resolveLateType = exports.getEnumerationValues = exports.getDefaultValue
|
|
|
5
5
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
6
6
|
/**
|
|
7
7
|
* get the inner type of an MST optional, array, or late type object
|
|
8
|
-
*
|
|
9
|
-
* @param {IModelType} type
|
|
10
|
-
* @returns {IModelType}
|
|
11
8
|
*/
|
|
12
9
|
function getSubType(type) {
|
|
13
10
|
let t;
|
|
14
11
|
if ((0, mobx_state_tree_1.isOptionalType)(type)) {
|
|
12
|
+
// @ts-expect-error
|
|
15
13
|
t = type._subtype || type.type;
|
|
16
14
|
}
|
|
17
15
|
else if ((0, mobx_state_tree_1.isArrayType)(type) || (0, mobx_state_tree_1.isMapType)(type)) {
|
|
16
|
+
// @ts-expect-error
|
|
18
17
|
t = type._subtype || type._subType || type.subType;
|
|
18
|
+
// @ts-expect-error
|
|
19
19
|
}
|
|
20
20
|
else if (typeof type.getSubType === 'function') {
|
|
21
|
+
// @ts-expect-error
|
|
21
22
|
return type.getSubType();
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
@@ -31,17 +32,20 @@ function getSubType(type) {
|
|
|
31
32
|
}
|
|
32
33
|
exports.getSubType = getSubType;
|
|
33
34
|
/**
|
|
34
|
-
* get the array of
|
|
35
|
-
* @param {MST Union Type obj} unionType
|
|
36
|
-
* @returns {Array<IModelType>}
|
|
35
|
+
* get the array of the subtypes in a union
|
|
37
36
|
*/
|
|
38
37
|
function getUnionSubTypes(unionType) {
|
|
39
38
|
if (!(0, mobx_state_tree_1.isUnionType)(unionType)) {
|
|
40
39
|
throw new TypeError('not an MST union type');
|
|
41
40
|
}
|
|
42
|
-
const t =
|
|
41
|
+
const t =
|
|
42
|
+
// @ts-expect-error
|
|
43
|
+
unionType._types ||
|
|
44
|
+
// @ts-expect-error
|
|
43
45
|
unionType.types ||
|
|
46
|
+
// @ts-expect-error
|
|
44
47
|
getSubType(unionType)._types ||
|
|
48
|
+
// @ts-expect-error
|
|
45
49
|
getSubType(unionType).types;
|
|
46
50
|
if (!t) {
|
|
47
51
|
// debugger
|
|
@@ -52,10 +56,6 @@ function getUnionSubTypes(unionType) {
|
|
|
52
56
|
exports.getUnionSubTypes = getUnionSubTypes;
|
|
53
57
|
/**
|
|
54
58
|
* get the type of one of the properties of the given MST model type
|
|
55
|
-
*
|
|
56
|
-
* @param {IModelType} type
|
|
57
|
-
* @param {string} propertyName
|
|
58
|
-
* @returns {IModelType}
|
|
59
59
|
*/
|
|
60
60
|
function getPropertyType(type, propertyName) {
|
|
61
61
|
const propertyType = type.properties[propertyName];
|
|
@@ -64,12 +64,12 @@ function getPropertyType(type, propertyName) {
|
|
|
64
64
|
exports.getPropertyType = getPropertyType;
|
|
65
65
|
/**
|
|
66
66
|
* get the base type from inside an MST optional type
|
|
67
|
-
* @param {*} type
|
|
68
67
|
*/
|
|
69
68
|
function getDefaultValue(type) {
|
|
70
69
|
if (!(0, mobx_state_tree_1.isOptionalType)(type)) {
|
|
71
70
|
throw new TypeError('type must be an optional type');
|
|
72
71
|
}
|
|
72
|
+
// @ts-expect-error
|
|
73
73
|
return type._defaultValue || type.defaultValue;
|
|
74
74
|
}
|
|
75
75
|
exports.getDefaultValue = getDefaultValue;
|
|
@@ -84,6 +84,7 @@ function resolveLateType(maybeLate) {
|
|
|
84
84
|
if (!(0, mobx_state_tree_1.isUnionType)(maybeLate) &&
|
|
85
85
|
!(0, mobx_state_tree_1.isArrayType)(maybeLate) &&
|
|
86
86
|
(0, mobx_state_tree_1.isLateType)(maybeLate)) {
|
|
87
|
+
// @ts-expect-error
|
|
87
88
|
return maybeLate.getSubType();
|
|
88
89
|
}
|
|
89
90
|
return maybeLate;
|
package/util/types/index.d.ts
CHANGED
|
@@ -194,6 +194,7 @@ export interface AbstractMenuManager {
|
|
|
194
194
|
export declare function isAbstractMenuManager(thing: unknown): thing is AbstractMenuManager;
|
|
195
195
|
export interface NoAssemblyRegion extends SnapshotIn<typeof MUNoAssemblyRegion> {
|
|
196
196
|
}
|
|
197
|
+
/** a description of a specific genomic region. assemblyName, refName, start, end, and reversed */
|
|
197
198
|
export interface Region extends SnapshotIn<typeof MUIRegion> {
|
|
198
199
|
}
|
|
199
200
|
export interface AugmentedRegion extends Region {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
function useMeasure() {
|
|
5
|
+
const ref = (0, react_1.useRef)(null);
|
|
6
|
+
const [dims, setDims] = (0, react_1.useState)({
|
|
7
|
+
width: undefined,
|
|
8
|
+
height: undefined,
|
|
9
|
+
});
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
if (!ref.current) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const RS = typeof window !== 'undefined' && 'ResizeObserver' in window
|
|
15
|
+
? window.ResizeObserver
|
|
16
|
+
: undefined;
|
|
17
|
+
if (!RS) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const observer = new RS(entries => {
|
|
21
|
+
setDims({
|
|
22
|
+
width: entries[0].contentRect.width,
|
|
23
|
+
height: entries[0].contentRect.height,
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
observer.observe(ref.current);
|
|
27
|
+
// Callback fired when component is unmounted
|
|
28
|
+
return () => {
|
|
29
|
+
observer.disconnect();
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
return [ref, dims];
|
|
33
|
+
}
|
|
34
|
+
exports.default = useMeasure;
|