@vitessce/vit-s 2.0.3-beta.0 → 2.0.3
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/dist/index.mjs +84801 -0
- package/{dist → dist-tsc}/index.js +2 -2
- package/package.json +7 -7
- package/src/CallbackPublisher.js +81 -0
- package/src/LoadingIndicator.js +34 -0
- package/src/TitleInfo.js +240 -0
- package/src/VitS.js +180 -0
- package/src/VitessceGrid.js +110 -0
- package/src/VitessceGrid.test.jsx +48 -0
- package/src/Warning.js +62 -0
- package/{dist → src}/classNames.js +0 -0
- package/src/component-registry.js +21 -0
- package/src/data/AbstractLoader.js +46 -0
- package/{dist → src}/data/AbstractTwoStepLoader.js +5 -4
- package/src/data/LoaderResult.js +8 -0
- package/{dist → src}/data/index.js +0 -0
- package/src/data/loader-registry.js +19 -0
- package/src/data-hook-utils.js +197 -0
- package/src/data-hooks.js +354 -0
- package/src/errors/AbstractLoaderError.js +14 -0
- package/src/errors/DataSourceFetchError.js +15 -0
- package/src/errors/DatasetNotFoundError.js +23 -0
- package/src/errors/LoaderNotFoundError.js +24 -0
- package/src/errors/LoaderValidationError.js +23 -0
- package/src/errors/OptionsValidationError.js +25 -0
- package/{dist → src}/errors/index.js +0 -0
- package/src/file-options-schemas-legacy.js +139 -0
- package/src/file-options-schemas-legacy.test.js +138 -0
- package/src/file-options-schemas.js +327 -0
- package/src/file-options-schemas.test.js +26 -0
- package/src/hooks.js +252 -0
- package/src/index.js +101 -0
- package/src/joint-file-types-legacy.js +298 -0
- package/src/joint-file-types-legacy.test.js +412 -0
- package/src/joint-file-types.js +171 -0
- package/src/joint-file-types.test.js +144 -0
- package/{dist/schemas.js → src/json-schemas.js} +6 -1
- package/{dist → src}/plugins.js +102 -70
- package/src/plugins.test.fixtures.js +78 -0
- package/src/plugins.test.js +42 -0
- package/src/schemas/config-0.1.0.schema.json +85 -0
- package/src/schemas/config-1.0.0.schema.json +733 -0
- package/src/schemas/config-1.0.1.schema.json +909 -0
- package/src/schemas/config-1.0.10.schema.json +969 -0
- package/src/schemas/config-1.0.11.schema.json +990 -0
- package/src/schemas/config-1.0.12.schema.json +997 -0
- package/src/schemas/config-1.0.13.schema.json +1013 -0
- package/src/schemas/config-1.0.14.schema.json +1048 -0
- package/src/schemas/config-1.0.15.schema.json +1048 -0
- package/src/schemas/config-1.0.16.schema.json +1069 -0
- package/src/schemas/config-1.0.16.schema.test.js +32 -0
- package/src/schemas/config-1.0.2.schema.json +911 -0
- package/src/schemas/config-1.0.3.schema.json +911 -0
- package/src/schemas/config-1.0.4.schema.json +949 -0
- package/src/schemas/config-1.0.5.schema.json +949 -0
- package/src/schemas/config-1.0.6.schema.json +950 -0
- package/src/schemas/config-1.0.7.schema.json +950 -0
- package/src/schemas/config-1.0.8.schema.json +966 -0
- package/src/schemas/config-1.0.9.schema.json +965 -0
- package/src/schemas/fixtures/cellSets.good.json +16 -0
- package/src/schemas/fixtures/config-1.0.1.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.1.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.1.good.json +37 -0
- package/src/schemas/fixtures/config-1.0.2.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.2.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.2.good.json +38 -0
- package/src/schemas/fixtures/config-1.0.3.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.3.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.3.good.json +38 -0
- package/src/schemas/fixtures/obsSets.bad.json +1 -0
- package/src/schemas/fixtures/obsSets.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSets.good.json +16 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.json +1 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSetsTabular.good.json +26 -0
- package/src/schemas/fixtures/raster.bad.json +1 -0
- package/src/schemas/fixtures/raster.bad.message.json +11 -0
- package/src/schemas/fixtures/raster.good.json +39 -0
- package/src/schemas/obsSets.schema.js +195 -0
- package/src/schemas/obsSetsTabular.schema.js +39 -0
- package/src/schemas/raster.schema.js +121 -0
- package/src/schemas/schema-schema.sh +34 -0
- package/{dist → src}/schemas/schema.test-old.js +0 -1
- package/src/shared-mui/components.js +79 -0
- package/src/shared-mui/container.js +212 -0
- package/src/shared-mui/styles.js +110 -0
- package/src/shared-plot-options/CellColorEncodingOption.js +43 -0
- package/src/shared-plot-options/OptionSelect.js +19 -0
- package/src/shared-plot-options/OptionsContainer.js +26 -0
- package/{dist → src}/shared-plot-options/index.js +0 -0
- package/src/shared-plot-options/styles.js +49 -0
- package/src/state/hooks.js +633 -0
- package/src/view-config-upgraders.js +628 -0
- package/src/view-config-utils.js +315 -0
- package/src/view-config-utils.test.fixtures.js +893 -0
- package/src/view-config-utils.test.js +95 -0
- package/src/view-config-versions.js +68 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.js +158 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +56 -0
- package/{dist → src}/vitessce-grid-layout/index.js +0 -0
- package/src/vitessce-grid-layout/layout-utils.js +76 -0
- package/src/vitessce-grid-layout/layout-utils.test.js +167 -0
- package/src/vitessce-grid-utils.js +160 -0
- package/dist/CallbackPublisher.js +0 -68
- package/dist/LoadingIndicator.js +0 -27
- package/dist/TitleInfo.js +0 -151
- package/dist/VitS.js +0 -117
- package/dist/Vitessce.integration.test.js +0 -36
- package/dist/Vitessce.js +0 -101
- package/dist/VitessceGrid.js +0 -59
- package/dist/VitessceGrid.test.js +0 -36
- package/dist/Warning.js +0 -45
- package/dist/component-registry.js +0 -16
- package/dist/data/AbstractLoader.js +0 -35
- package/dist/data/LoaderResult.js +0 -7
- package/dist/data/loader-registry.js +0 -15
- package/dist/data-hook-utils.js +0 -175
- package/dist/data-hooks.js +0 -241
- package/dist/errors/AbstractLoaderError.js +0 -13
- package/dist/errors/DataSourceFetchError.js +0 -13
- package/dist/errors/DatasetNotFoundError.js +0 -17
- package/dist/errors/LoaderNotFoundError.js +0 -17
- package/dist/errors/LoaderValidationError.js +0 -15
- package/dist/errors/OptionsValidationError.js +0 -15
- package/dist/export-utils.js +0 -70
- package/dist/export-utils.test.js +0 -66
- package/dist/file-options-schemas-legacy.js +0 -136
- package/dist/file-options-schemas-legacy.test.js +0 -126
- package/dist/file-options-schemas.js +0 -322
- package/dist/file-options-schemas.test.js +0 -23
- package/dist/hooks.js +0 -215
- package/dist/joint-file-types-legacy.js +0 -278
- package/dist/joint-file-types-legacy.test.js +0 -400
- package/dist/joint-file-types.js +0 -148
- package/dist/joint-file-types.test.js +0 -139
- package/dist/loader-registry.js +0 -98
- package/dist/plugins.test.fixtures.js +0 -76
- package/dist/plugins.test.js +0 -30
- package/dist/schemas/PrettyJsonSchema.js +0 -34
- package/dist/schemas/config-0.1.0.schema.json +0 -84
- package/dist/schemas/config-1.0.0.schema.json +0 -733
- package/dist/schemas/config-1.0.1.schema.json +0 -909
- package/dist/schemas/config-1.0.10.schema.json +0 -969
- package/dist/schemas/config-1.0.11.schema.json +0 -990
- package/dist/schemas/config-1.0.12.schema.json +0 -997
- package/dist/schemas/config-1.0.13.schema.json +0 -1013
- package/dist/schemas/config-1.0.14.schema.json +0 -1048
- package/dist/schemas/config-1.0.15.schema.json +0 -1048
- package/dist/schemas/config-1.0.15.schema.test.js +0 -22
- package/dist/schemas/config-1.0.16.schema.json +0 -1109
- package/dist/schemas/config-1.0.16.schema.test.js +0 -22
- package/dist/schemas/config-1.0.2.schema.json +0 -910
- package/dist/schemas/config-1.0.3.schema.json +0 -910
- package/dist/schemas/config-1.0.4.schema.json +0 -949
- package/dist/schemas/config-1.0.5.schema.json +0 -949
- package/dist/schemas/config-1.0.6.schema.json +0 -949
- package/dist/schemas/config-1.0.7.schema.json +0 -949
- package/dist/schemas/config-1.0.8.schema.json +0 -965
- package/dist/schemas/config-1.0.9.schema.json +0 -965
- package/dist/schemas/obs-sets-tabular.schema.js +0 -37
- package/dist/schemas/obs-sets.schema.js +0 -194
- package/dist/schemas/obsSets.schema.js +0 -195
- package/dist/schemas/obsSetsTabular.schema.js +0 -38
- package/dist/schemas/raster.schema.js +0 -120
- package/dist/schemas/schema.test.js +0 -46
- package/dist/schemas-extra.js +0 -3
- package/dist/shared-mui/components.js +0 -35
- package/dist/shared-mui/container.js +0 -211
- package/dist/shared-mui/styles.js +0 -107
- package/dist/shared-plot-options/CellColorEncodingOption.js +0 -18
- package/dist/shared-plot-options/OptionSelect.js +0 -12
- package/dist/shared-plot-options/OptionsContainer.js +0 -12
- package/dist/shared-plot-options/styles.js +0 -48
- package/dist/state/hooks.js +0 -549
- package/dist/view-config-upgraders.js +0 -525
- package/dist/view-config-utils.js +0 -286
- package/dist/view-config-utils.test.fixtures.js +0 -765
- package/dist/view-config-utils.test.js +0 -66
- package/dist/view-config-versions.js +0 -47
- package/dist/vitessce-grid-layout/VitessceGridLayout.js +0 -95
- package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +0 -40
- package/dist/vitessce-grid-layout/layout-utils.js +0 -60
- package/dist/vitessce-grid-layout/layout-utils.test.js +0 -146
- package/dist/vitessce-grid-utils.js +0 -140
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useState, useEffect, useRef,
|
|
3
|
+
} from 'react';
|
|
4
|
+
import { InternMap } from 'internmap';
|
|
5
|
+
import isEqual from 'lodash/isEqual';
|
|
6
|
+
import pick from 'lodash/pick';
|
|
7
|
+
import { DEFAULT_COORDINATION_VALUES, DATA_TYPE_COORDINATION_VALUE_USAGE } from '@vitessce/constants-internal';
|
|
8
|
+
import { getSourceAndLoaderFromFileType } from './data/loader-registry';
|
|
9
|
+
import { getFileTypeDataTypeMapping } from './plugins';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Return the bottom coordinate of the layout.
|
|
13
|
+
* https://github.com/STRML/react-grid-layout/blob/20dac73f91274526034c00968b5bedb9c2ed36b9/lib/utils.js#L82
|
|
14
|
+
* @param {array} layout react-grid-layout layout array.
|
|
15
|
+
* @returns {number} Bottom coordinate.
|
|
16
|
+
*/
|
|
17
|
+
function getNumRows(layout) {
|
|
18
|
+
let max = 0;
|
|
19
|
+
let bottomY;
|
|
20
|
+
// eslint-disable-next-line no-plusplus
|
|
21
|
+
for (let i = 0, len = layout.length; i < len; i++) {
|
|
22
|
+
bottomY = layout[i].y + layout[i].h;
|
|
23
|
+
if (bottomY > max) max = bottomY;
|
|
24
|
+
}
|
|
25
|
+
return max;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Compute the row height based on the container height, number of rows,
|
|
30
|
+
* and margin/padding. Basically the reverse of the react-grid-layout's
|
|
31
|
+
* `.containerHeight()` function.
|
|
32
|
+
* https://github.com/STRML/react-grid-layout/blob/83251e5e682abfa3252ff89d4bacf47fdc1f4270/lib/ReactGridLayout.jsx#L223
|
|
33
|
+
* @param {number} containerHeight The height of the .vitessce-container element.
|
|
34
|
+
* @param {number} numRows The number of rows in the layout.
|
|
35
|
+
* @param {number} margin The margin value that will be passed to VitessceGrid.
|
|
36
|
+
* @param {number} padding The padding value that will be passed to VitessceGrid.
|
|
37
|
+
* @returns {number} The new row height value.
|
|
38
|
+
*/
|
|
39
|
+
function getRowHeight(containerHeight, numRows, margin, padding) {
|
|
40
|
+
const effectiveContainerHeight = containerHeight - 2 * padding - (numRows - 1) * margin;
|
|
41
|
+
return effectiveContainerHeight / numRows;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function useRowHeight(config, initialRowHeight, height, margin, padding) {
|
|
45
|
+
const [containerHeight, setContainerHeight] = useState(height);
|
|
46
|
+
const [rowHeight, setRowHeight] = useState(initialRowHeight);
|
|
47
|
+
const containerRef = useRef();
|
|
48
|
+
|
|
49
|
+
// Detect when the `config` or `containerHeight` variables
|
|
50
|
+
// have changed, and update `rowHeight` in response.
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const numRows = getNumRows(config.layout);
|
|
53
|
+
const newRowHeight = getRowHeight(containerHeight, numRows, margin, padding);
|
|
54
|
+
setRowHeight(newRowHeight);
|
|
55
|
+
}, [containerHeight, config, margin, padding]);
|
|
56
|
+
|
|
57
|
+
// Update the `containerHeight` state when the `height` prop has changed.
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (height !== null && height !== undefined) {
|
|
60
|
+
setContainerHeight(height);
|
|
61
|
+
}
|
|
62
|
+
}, [height]);
|
|
63
|
+
|
|
64
|
+
// If no height prop has been provided, set the `containerHeight`
|
|
65
|
+
// using height of the `.vitessce-container` element.
|
|
66
|
+
// Check the container element height whenever the window has been
|
|
67
|
+
// resized, as it may change if `.vitessce-container` should be
|
|
68
|
+
// sized relative to its parent (and by extension, potentially the window).
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (height !== null && height !== undefined) {
|
|
71
|
+
// eslint will complain if the return value is inconsistent,
|
|
72
|
+
// so return a no-op function.
|
|
73
|
+
return () => {};
|
|
74
|
+
}
|
|
75
|
+
function onWindowResize() {
|
|
76
|
+
if (!containerRef.current) return;
|
|
77
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
78
|
+
setContainerHeight(containerRect.height);
|
|
79
|
+
}
|
|
80
|
+
window.addEventListener('resize', onWindowResize);
|
|
81
|
+
onWindowResize();
|
|
82
|
+
return () => {
|
|
83
|
+
window.removeEventListener('resize', onWindowResize);
|
|
84
|
+
};
|
|
85
|
+
}, [containerRef, height]);
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
return [rowHeight, containerRef];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function withDefaults(coordinationValues, dataType, fileType, datasetUid) {
|
|
92
|
+
const defaultKeys = DATA_TYPE_COORDINATION_VALUE_USAGE[dataType]
|
|
93
|
+
.filter(k => (
|
|
94
|
+
Object.keys(DEFAULT_COORDINATION_VALUES).includes(k)
|
|
95
|
+
&& DEFAULT_COORDINATION_VALUES[k]
|
|
96
|
+
&& !Object.keys(coordinationValues).includes(k)
|
|
97
|
+
));
|
|
98
|
+
const defaultValues = pick(DEFAULT_COORDINATION_VALUES, defaultKeys);
|
|
99
|
+
const coordinationValuesWithDefaults = {
|
|
100
|
+
...defaultValues,
|
|
101
|
+
// The user-provided values should take precedence.
|
|
102
|
+
...coordinationValues,
|
|
103
|
+
};
|
|
104
|
+
if (!isEqual(coordinationValues, coordinationValuesWithDefaults)) {
|
|
105
|
+
// eslint-disable-next-line max-len
|
|
106
|
+
console.warn(`Using coordination value defaults for file type ${fileType} in dataset ${datasetUid}\nBefore: ${JSON.stringify(coordinationValues)}\nAfter: ${JSON.stringify(coordinationValuesWithDefaults)}`);
|
|
107
|
+
}
|
|
108
|
+
return coordinationValuesWithDefaults;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Create a mapping from dataset ID to loader objects by data type.
|
|
113
|
+
* @param {object[]} datasets The datasets array from the view config.
|
|
114
|
+
* @param {string} configDescription The top-level description in the
|
|
115
|
+
* view config.
|
|
116
|
+
* @returns {object} Mapping from dataset ID to data type to loader
|
|
117
|
+
* instance.
|
|
118
|
+
*/
|
|
119
|
+
export function createLoaders(datasets, configDescription) {
|
|
120
|
+
const result = {};
|
|
121
|
+
const dataSources = {};
|
|
122
|
+
const fileTypeDataTypeMapping = getFileTypeDataTypeMapping();
|
|
123
|
+
datasets.forEach((dataset) => {
|
|
124
|
+
const datasetLoaders = {
|
|
125
|
+
name: dataset.name,
|
|
126
|
+
description: dataset.description || configDescription,
|
|
127
|
+
loaders: {},
|
|
128
|
+
};
|
|
129
|
+
dataset.files.forEach((file) => {
|
|
130
|
+
const {
|
|
131
|
+
url,
|
|
132
|
+
options,
|
|
133
|
+
requestInit,
|
|
134
|
+
fileType,
|
|
135
|
+
coordinationValues = {},
|
|
136
|
+
} = file;
|
|
137
|
+
const dataType = fileTypeDataTypeMapping[fileType];
|
|
138
|
+
const coordinationValuesWithDefaults = withDefaults(
|
|
139
|
+
coordinationValues, dataType,
|
|
140
|
+
fileType, dataset.uid,
|
|
141
|
+
);
|
|
142
|
+
const [DataSourceClass, LoaderClass] = getSourceAndLoaderFromFileType(fileType);
|
|
143
|
+
// Create _one_ DataSourceClass instance per URL. Derived loaders share this object.
|
|
144
|
+
const fileId = url || JSON.stringify(options);
|
|
145
|
+
if (!(fileId in dataSources)) {
|
|
146
|
+
dataSources[fileId] = new DataSourceClass({ url, requestInit });
|
|
147
|
+
}
|
|
148
|
+
const loader = new LoaderClass(dataSources[fileId], file);
|
|
149
|
+
if (datasetLoaders.loaders[dataType]) {
|
|
150
|
+
datasetLoaders.loaders[dataType].set(coordinationValuesWithDefaults, loader);
|
|
151
|
+
} else {
|
|
152
|
+
datasetLoaders.loaders[dataType] = new InternMap([
|
|
153
|
+
[coordinationValuesWithDefaults, loader],
|
|
154
|
+
], JSON.stringify);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
result[dataset.uid] = datasetLoaders;
|
|
158
|
+
});
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { SCHEMA_HANDLERS, LATEST_VERSION } from './view-config-versions';
|
|
3
|
-
import { useViewConfigStoreApi, useLoaders, useWarning } from './state/hooks';
|
|
4
|
-
function validateViewConfig(viewConfig) {
|
|
5
|
-
// Need the try-catch here since Zustand will actually
|
|
6
|
-
// just catch and ignore errors in its subscription callbacks.
|
|
7
|
-
try {
|
|
8
|
-
const validate = SCHEMA_HANDLERS[LATEST_VERSION][0];
|
|
9
|
-
const valid = validate(viewConfig);
|
|
10
|
-
if (!valid) {
|
|
11
|
-
const failureReason = JSON.stringify(validate.errors, null, 2);
|
|
12
|
-
throw new Error(`Config validation failed: ${failureReason}`);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
catch (e) {
|
|
16
|
-
console.error(e);
|
|
17
|
-
}
|
|
18
|
-
// Do nothing if successful.
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* This is a dummy component which handles
|
|
22
|
-
* publishing new view configs and loaders to
|
|
23
|
-
* the provided callbacks on changes.
|
|
24
|
-
* @param {object} props
|
|
25
|
-
* @param {function} props.onConfigChange A callback function
|
|
26
|
-
* to execute on each change of the Vitessce view config.
|
|
27
|
-
* @param {function} props.onLoaderChange A callback function
|
|
28
|
-
* to execute on each change of the loaders object.
|
|
29
|
-
* @param {boolean} props.validateOnConfigChange Whether to validate
|
|
30
|
-
* against the view config schema when publishing changes.
|
|
31
|
-
*/
|
|
32
|
-
export default function CallbackPublisher(props) {
|
|
33
|
-
const { onWarn, onConfigChange, onLoaderChange, validateOnConfigChange, } = props;
|
|
34
|
-
const warning = useWarning();
|
|
35
|
-
const loaders = useLoaders();
|
|
36
|
-
const viewConfigStoreApi = useViewConfigStoreApi();
|
|
37
|
-
// View config updates are often-occurring, so
|
|
38
|
-
// we want to use the "transient update" approach
|
|
39
|
-
// to subscribe to view config changes.
|
|
40
|
-
// Reference: https://github.com/react-spring/zustand#transient-updates-for-often-occuring-state-changes
|
|
41
|
-
useEffect(() => viewConfigStoreApi.subscribe(
|
|
42
|
-
// The function to run on each publish.
|
|
43
|
-
(viewConfig) => {
|
|
44
|
-
if (validateOnConfigChange && viewConfig) {
|
|
45
|
-
validateViewConfig(viewConfig);
|
|
46
|
-
}
|
|
47
|
-
if (onConfigChange && viewConfig) {
|
|
48
|
-
onConfigChange(viewConfig);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
// The function to specify which part of the store
|
|
52
|
-
// we want to subscribe to.
|
|
53
|
-
state => state.viewConfig), [onConfigChange, validateOnConfigChange, viewConfigStoreApi]);
|
|
54
|
-
// Emit updates to the warning message.
|
|
55
|
-
useEffect(() => {
|
|
56
|
-
if (onWarn && warning) {
|
|
57
|
-
onWarn(warning);
|
|
58
|
-
}
|
|
59
|
-
}, [warning, onWarn]);
|
|
60
|
-
// Emit updates to the loaders.
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (onLoaderChange && loaders) {
|
|
63
|
-
onLoaderChange(loaders);
|
|
64
|
-
}
|
|
65
|
-
}, [loaders, onLoaderChange]);
|
|
66
|
-
// Render nothing.
|
|
67
|
-
return null;
|
|
68
|
-
}
|
package/dist/LoadingIndicator.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
4
|
-
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
5
|
-
const useStyles = makeStyles(() => ({
|
|
6
|
-
loadingIndicatorBackdrop: {
|
|
7
|
-
position: 'absolute',
|
|
8
|
-
top: '0',
|
|
9
|
-
left: '0',
|
|
10
|
-
zIndex: '1040',
|
|
11
|
-
width: '100%',
|
|
12
|
-
height: '100%',
|
|
13
|
-
borderRadius: '4px',
|
|
14
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
15
|
-
},
|
|
16
|
-
loadingIndicatorContainer: {
|
|
17
|
-
display: 'grid',
|
|
18
|
-
placeItems: 'center',
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
width: '100%',
|
|
21
|
-
height: '100%',
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
24
|
-
export default function LoadingIndicator() {
|
|
25
|
-
const classes = useStyles();
|
|
26
|
-
return (_jsx("div", { className: classes.loadingIndicatorBackdrop, children: _jsx("div", { className: classes.loadingIndicatorContainer, children: _jsx(CircularProgress, {}) }) }));
|
|
27
|
-
}
|
package/dist/TitleInfo.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
-
import CloudDownloadIcon from '@material-ui/icons/CloudDownload';
|
|
6
|
-
import MenuItem from '@material-ui/core/MenuItem';
|
|
7
|
-
import IconButton from '@material-ui/core/IconButton';
|
|
8
|
-
import Link from '@material-ui/core/Link';
|
|
9
|
-
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
|
|
10
|
-
import ArrowDropUpIcon from '@material-ui/icons/ArrowDropUp';
|
|
11
|
-
import SettingsIcon from '@material-ui/icons/Settings';
|
|
12
|
-
import CloseIcon from '@material-ui/icons/Close';
|
|
13
|
-
import { TOOLTIP_ANCESTOR } from './classNames';
|
|
14
|
-
import LoadingIndicator from './LoadingIndicator';
|
|
15
|
-
import { PopperMenu } from './shared-mui/components';
|
|
16
|
-
const useStyles = makeStyles(theme => ({
|
|
17
|
-
iconButton: {
|
|
18
|
-
border: 'none',
|
|
19
|
-
marginLeft: 0,
|
|
20
|
-
background: 'none',
|
|
21
|
-
color: theme.palette.primaryForeground,
|
|
22
|
-
paddingLeft: '0.25em',
|
|
23
|
-
paddingRight: '0.25em',
|
|
24
|
-
borderRadius: '2px',
|
|
25
|
-
'&:hover': {
|
|
26
|
-
backgroundColor: theme.palette.primaryBackgroundLight,
|
|
27
|
-
},
|
|
28
|
-
'&:first-child': {
|
|
29
|
-
marginLeft: '0.25em',
|
|
30
|
-
},
|
|
31
|
-
'&:last-child': {
|
|
32
|
-
marginRight: '0.25em',
|
|
33
|
-
},
|
|
34
|
-
'& svg': {
|
|
35
|
-
width: '0.7em',
|
|
36
|
-
height: '0.7em',
|
|
37
|
-
verticalAlign: 'middle',
|
|
38
|
-
overflow: 'visible',
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
downloadLink: {
|
|
42
|
-
color: theme.palette.primaryForeground,
|
|
43
|
-
},
|
|
44
|
-
}));
|
|
45
|
-
function SettingsIconWithArrow({ open }) {
|
|
46
|
-
return (_jsxs(_Fragment, { children: [_jsx(SettingsIcon, {}), open ? _jsx(ArrowDropUpIcon, {}) : _jsx(ArrowDropDownIcon, {})] }));
|
|
47
|
-
}
|
|
48
|
-
function PlotOptions(props) {
|
|
49
|
-
const { options } = props;
|
|
50
|
-
const [open, setOpen] = useState(false);
|
|
51
|
-
const classes = useStyles();
|
|
52
|
-
return (options ? (_jsx(PopperMenu, { open: open, setOpen: setOpen, buttonIcon: _jsx(SettingsIconWithArrow, { open: open }), buttonClassName: classes.iconButton, placement: "bottom-end", children: options })) : null);
|
|
53
|
-
}
|
|
54
|
-
function CloudDownloadIconWithArrow({ open }) {
|
|
55
|
-
return (_jsxs(_Fragment, { children: [_jsx(CloudDownloadIcon, {}), open ? _jsx(ArrowDropUpIcon, {}) : _jsx(ArrowDropDownIcon, {})] }));
|
|
56
|
-
}
|
|
57
|
-
function DownloadOptions(props) {
|
|
58
|
-
const { urls } = props;
|
|
59
|
-
const [open, setOpen] = useState(false);
|
|
60
|
-
const classes = useStyles();
|
|
61
|
-
return (urls && urls.length ? (_jsx(PopperMenu, { open: open, setOpen: setOpen, buttonIcon: _jsx(CloudDownloadIconWithArrow, { open: open }), buttonClassName: classes.iconButton, placement: "bottom-end", children: urls.map(({ url, name }) => (_jsx(MenuItem, { dense: true, children: _jsxs(Link, { underline: "none", href: url, target: "_blank", rel: "noopener", className: classes.downloadLink, children: ["Download ", name] }) }, `${url}_${name}`))) })) : null);
|
|
62
|
-
}
|
|
63
|
-
function ClosePaneButton(props) {
|
|
64
|
-
const { removeGridComponent } = props;
|
|
65
|
-
const classes = useStyles();
|
|
66
|
-
return (_jsx(IconButton, { onClick: removeGridComponent, size: "small", className: classes.iconButton, title: "close", children: _jsx(CloseIcon, {}) }));
|
|
67
|
-
}
|
|
68
|
-
export const useTitleStyles = makeStyles(theme => ({
|
|
69
|
-
title: {
|
|
70
|
-
color: theme.palette.primaryForeground,
|
|
71
|
-
overflowX: 'hidden',
|
|
72
|
-
display: 'flex',
|
|
73
|
-
flexDirection: 'row',
|
|
74
|
-
flexShrink: '0',
|
|
75
|
-
},
|
|
76
|
-
titleLeft: {
|
|
77
|
-
flexShrink: '1',
|
|
78
|
-
textOverflow: 'ellipsis',
|
|
79
|
-
whiteSpace: 'nowrap',
|
|
80
|
-
},
|
|
81
|
-
titleInfo: {
|
|
82
|
-
width: '100%',
|
|
83
|
-
textOverflow: 'ellipsis',
|
|
84
|
-
whiteSpace: 'nowrap',
|
|
85
|
-
overflow: 'hidden',
|
|
86
|
-
fontSize: '80% !important',
|
|
87
|
-
opacity: '.8',
|
|
88
|
-
padding: '0 4px',
|
|
89
|
-
justifyContent: 'center',
|
|
90
|
-
lineHeight: '25px !important',
|
|
91
|
-
flexShrink: '1',
|
|
92
|
-
textAlign: 'right !important',
|
|
93
|
-
},
|
|
94
|
-
titleButtons: {
|
|
95
|
-
display: 'flex',
|
|
96
|
-
flexDirection: 'row',
|
|
97
|
-
flexGrow: '1',
|
|
98
|
-
flexShrink: '0',
|
|
99
|
-
justifyContent: 'right',
|
|
100
|
-
'& div': {
|
|
101
|
-
display: 'inline-block',
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
card: {
|
|
105
|
-
border: `1px solid ${theme.palette.cardBorder}`,
|
|
106
|
-
flex: '1 1 auto',
|
|
107
|
-
minHeight: '1px',
|
|
108
|
-
padding: '12px',
|
|
109
|
-
marginTop: '8px',
|
|
110
|
-
marginBottom: '8px',
|
|
111
|
-
position: 'relative',
|
|
112
|
-
display: 'flex',
|
|
113
|
-
flexDirection: 'column',
|
|
114
|
-
minWidth: '0',
|
|
115
|
-
wordWrap: 'break-word',
|
|
116
|
-
backgroundClip: 'border-box',
|
|
117
|
-
borderRadius: '4px',
|
|
118
|
-
},
|
|
119
|
-
noScrollCard: {
|
|
120
|
-
backgroundColor: theme.palette.secondaryBackground,
|
|
121
|
-
color: theme.palette.secondaryForeground,
|
|
122
|
-
},
|
|
123
|
-
scrollCard: {
|
|
124
|
-
backgroundColor: theme.palette.primaryBackground,
|
|
125
|
-
color: theme.palette.primaryForeground,
|
|
126
|
-
'& a': {
|
|
127
|
-
color: theme.palette.primaryForegroundActive,
|
|
128
|
-
},
|
|
129
|
-
overflowY: 'auto',
|
|
130
|
-
},
|
|
131
|
-
spatialCard: {
|
|
132
|
-
backgroundColor: theme.palette.black,
|
|
133
|
-
color: theme.palette.white,
|
|
134
|
-
'& a': {
|
|
135
|
-
color: theme.palette.white,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
}));
|
|
139
|
-
export function TitleInfo(props) {
|
|
140
|
-
const { title, info, children, isScroll, isSpatial, removeGridComponent, urls, isReady, options, } = props;
|
|
141
|
-
const classes = useTitleStyles();
|
|
142
|
-
return (
|
|
143
|
-
// d-flex without wrapping div is not always full height; I don't understand the root cause.
|
|
144
|
-
_jsxs(_Fragment, { children: [_jsxs("div", { className: classes.title, children: [_jsx("div", { className: classes.titleLeft, children: title }), _jsx("div", { className: classes.titleInfo, title: info, children: info }), _jsxs("div", { className: classes.titleButtons, children: [_jsx(PlotOptions, { options: options }), _jsx(DownloadOptions, { urls: urls }), _jsx(ClosePaneButton, { removeGridComponent: removeGridComponent })] })] }), _jsxs("div", { className: clsx(TOOLTIP_ANCESTOR, classes.card, {
|
|
145
|
-
[classes.scrollCard]: isScroll,
|
|
146
|
-
[classes.spatialCard]: isSpatial,
|
|
147
|
-
[classes.noScrollCard]: !isScroll && !isSpatial,
|
|
148
|
-
}), children: [!isReady && _jsx(LoadingIndicator, {}), children] })] })
|
|
149
|
-
// "pl-2" only matters when the window is very narrow.
|
|
150
|
-
);
|
|
151
|
-
}
|
package/dist/VitS.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable camelcase */
|
|
3
|
-
import React, { useEffect, useMemo } from 'react';
|
|
4
|
-
import { ThemeProvider, StylesProvider, createGenerateClassName, } from '@material-ui/core/styles';
|
|
5
|
-
import isEqual from 'lodash/isEqual';
|
|
6
|
-
import { META_VERSION } from '@vitessce/constants-internal';
|
|
7
|
-
import { muiTheme } from './shared-mui/styles';
|
|
8
|
-
import { ViewConfigProvider, createViewConfigStore, AuxiliaryProvider, createAuxiliaryStore, } from './state/hooks';
|
|
9
|
-
import VitessceGrid from './VitessceGrid';
|
|
10
|
-
import { Warning } from './Warning';
|
|
11
|
-
import CallbackPublisher from './CallbackPublisher';
|
|
12
|
-
import { getComponent } from './component-registry';
|
|
13
|
-
import { checkTypes, initialize, upgradeAndValidate, } from './view-config-utils';
|
|
14
|
-
function logConfig(config, name) {
|
|
15
|
-
console.groupCollapsed(`🚄 Vitessce (${META_VERSION.version}) ${name}`);
|
|
16
|
-
console.info(`data:,${JSON.stringify(config)}`);
|
|
17
|
-
console.info(JSON.stringify(config, null, 2));
|
|
18
|
-
console.groupEnd();
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The Vitessce component.
|
|
22
|
-
* @param {object} props
|
|
23
|
-
* @param {object} props.config A Vitessce view config.
|
|
24
|
-
* If the config is valid, the VitessceGrid will be rendered as a child.
|
|
25
|
-
* If the config is invalid, a Warning will be rendered instead.
|
|
26
|
-
* @param {number} props.rowHeight Row height for grid layout. Optional.
|
|
27
|
-
* @param {number} props.height Total height for grid layout. Optional.
|
|
28
|
-
* @param {string} props.theme The theme, used for styling as
|
|
29
|
-
* light or dark. Optional. By default, "dark"
|
|
30
|
-
* @param {function} props.onWarn A callback for warning messages. Optional.
|
|
31
|
-
* @param {function} props.onConfigChange A callback for view config
|
|
32
|
-
* updates. Optional.
|
|
33
|
-
* @param {function} props.onLoaderChange A callback for loader
|
|
34
|
-
* updates. Optional.
|
|
35
|
-
* @param {boolean} props.validateOnConfigChange Whether to validate
|
|
36
|
-
* against the view config schema when publishing changes. Use for debugging
|
|
37
|
-
* purposes, as this may have a performance impact. By default, false.
|
|
38
|
-
* @param {undefined|string} props.uid A unique identifier for this Vitessce instance,
|
|
39
|
-
* for the purpose of avoiding CSS autogenerated class name conflicts. Must be valid as part
|
|
40
|
-
* of a CSS class name string.
|
|
41
|
-
*/
|
|
42
|
-
export function VitS(props) {
|
|
43
|
-
const { config, rowHeight, height, theme, onWarn, onConfigChange, onLoaderChange, validateOnConfigChange = false, onConfigUpgrade, isBounded = false, uid, } = props;
|
|
44
|
-
const generateClassName = useMemo(() => createGenerateClassName({
|
|
45
|
-
disableGlobal: false,
|
|
46
|
-
// Avoid conflicts with portal-ui MUI class names,
|
|
47
|
-
// and allow setting a UID.
|
|
48
|
-
productionPrefix: (uid ? `vit${uid}` : 'vit'),
|
|
49
|
-
}), [uid]);
|
|
50
|
-
// Process the view config and memoize the result:
|
|
51
|
-
// - Validate.
|
|
52
|
-
// - Upgrade, if legacy schema.
|
|
53
|
-
// - Validate after upgrade, if legacy schema.
|
|
54
|
-
// - Initialize (based on initStrategy).
|
|
55
|
-
const [configOrWarning, success] = useMemo(() => {
|
|
56
|
-
// If the config value is undefined, show a warning message.
|
|
57
|
-
if (!config) {
|
|
58
|
-
return [
|
|
59
|
-
{
|
|
60
|
-
title: 'No such dataset',
|
|
61
|
-
unformatted: 'The dataset configuration could not be found.',
|
|
62
|
-
},
|
|
63
|
-
false,
|
|
64
|
-
];
|
|
65
|
-
}
|
|
66
|
-
// If the view config is missing a version, show a warning message.
|
|
67
|
-
if (!config.version) {
|
|
68
|
-
return [
|
|
69
|
-
{
|
|
70
|
-
title: 'Missing version',
|
|
71
|
-
unformatted: 'The dataset configuration is missing a version, preventing validation.',
|
|
72
|
-
},
|
|
73
|
-
false,
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
logConfig(config, 'input view config');
|
|
77
|
-
// Check if this is a "legacy" view config.
|
|
78
|
-
const [upgradedConfig, upgradeSuccess] = upgradeAndValidate(config, onConfigUpgrade);
|
|
79
|
-
if (upgradeSuccess) {
|
|
80
|
-
logConfig(upgradedConfig, 'upgraded view config');
|
|
81
|
-
// Initialize the view config according to the initStrategy.
|
|
82
|
-
const [typeCheckSuccess, typeCheckMessage] = checkTypes(upgradedConfig);
|
|
83
|
-
if (typeCheckSuccess) {
|
|
84
|
-
try {
|
|
85
|
-
const initializedConfig = initialize(upgradedConfig);
|
|
86
|
-
logConfig(initializedConfig, 'initialized view config');
|
|
87
|
-
return [initializedConfig, true];
|
|
88
|
-
}
|
|
89
|
-
catch (e) {
|
|
90
|
-
return [
|
|
91
|
-
{
|
|
92
|
-
title: 'View config initialization failed.',
|
|
93
|
-
unformatted: e.message,
|
|
94
|
-
},
|
|
95
|
-
false,
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return [
|
|
100
|
-
{
|
|
101
|
-
title: 'View config checks failed.',
|
|
102
|
-
unformatted: typeCheckMessage,
|
|
103
|
-
},
|
|
104
|
-
false,
|
|
105
|
-
];
|
|
106
|
-
}
|
|
107
|
-
return [upgradedConfig, false];
|
|
108
|
-
}, [config, onConfigUpgrade]);
|
|
109
|
-
// Emit the upgraded/initialized view config
|
|
110
|
-
// to onConfigChange if necessary.
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
if (success && !isEqual(configOrWarning, config) && onConfigChange) {
|
|
113
|
-
onConfigChange(configOrWarning);
|
|
114
|
-
}
|
|
115
|
-
}, [success, config, configOrWarning, onConfigChange]);
|
|
116
|
-
return success ? (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(ViewConfigProvider, { createStore: createViewConfigStore, children: _jsxs(AuxiliaryProvider, { createStore: createAuxiliaryStore, children: [_jsx(VitessceGrid, { config: configOrWarning, getComponent: getComponent, rowHeight: rowHeight, height: height, theme: theme, isBounded: isBounded }), _jsx(CallbackPublisher, { onWarn: onWarn, onConfigChange: onConfigChange, onLoaderChange: onLoaderChange, validateOnConfigChange: validateOnConfigChange })] }) }) }) })) : (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(Warning, { ...configOrWarning }) }) }));
|
|
117
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* eslint-disable max-len */
|
|
3
|
-
// import React from 'react';
|
|
4
|
-
// import Adapter from 'enzyme-adapter-react-16';
|
|
5
|
-
// import { mount, configure } from 'enzyme';
|
|
6
|
-
// import Ajv from 'ajv';
|
|
7
|
-
// import expect from 'expect';
|
|
8
|
-
// import Vitessce from './Vitessce';
|
|
9
|
-
// import { configs } from './api';
|
|
10
|
-
// import configSchema from '../schemas/config.schema.json';
|
|
11
|
-
// configure({ adapter: new Adapter() });
|
|
12
|
-
// describe('Vitessce.js', () => {
|
|
13
|
-
// describe('<Vitessce />', () => {
|
|
14
|
-
// it('Produces valid view config', (done) => {
|
|
15
|
-
// const config = configs['linnarsson-2018'];
|
|
16
|
-
// let updatedConfig = {};
|
|
17
|
-
// // eslint-disable-next-line no-return-assign
|
|
18
|
-
// const wrapper = mount(<Vitessce config={config} onConfigChange={c => updatedConfig = c} />);
|
|
19
|
-
// setTimeout(() => {
|
|
20
|
-
// // Simulate usage of some of the app
|
|
21
|
-
// wrapper.find('[id^="deckgl-overlay-"]').at(0).simulate('wheel', { deltaY: 1000, deltaX: 1000 });
|
|
22
|
-
// wrapper.find('[id^="deckgl-overlay-"]').at(1).simulate('wheel', { deltaY: 1000, deltaX: 1000 });
|
|
23
|
-
// wrapper.find('[id^="deckgl-overlay-"]').at(2).simulate('wheel', { deltaY: 1000, deltaX: 1000 });
|
|
24
|
-
// const validate = new Ajv().compile(configSchema);
|
|
25
|
-
// const valid = validate(updatedConfig);
|
|
26
|
-
// if (!valid) {
|
|
27
|
-
// const failureReason = JSON.stringify(validate.errors, null, 2);
|
|
28
|
-
// console.error(failureReason);
|
|
29
|
-
// }
|
|
30
|
-
// expect(valid).toEqual(true);
|
|
31
|
-
// wrapper.unmount();
|
|
32
|
-
// done();
|
|
33
|
-
// }, 20000);
|
|
34
|
-
// }).timeout(30000);
|
|
35
|
-
// });
|
|
36
|
-
// });
|
package/dist/Vitessce.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable camelcase */
|
|
3
|
-
import React, { useEffect, useMemo } from 'react';
|
|
4
|
-
import { ThemeProvider, StylesProvider, createGenerateClassName, } from '@material-ui/core/styles';
|
|
5
|
-
import isEqual from 'lodash/isEqual';
|
|
6
|
-
import { muiTheme } from './shared-mui/styles';
|
|
7
|
-
import { ViewConfigProvider, createViewConfigStore, AuxiliaryProvider, createAuxiliaryStore, } from './state/hooks';
|
|
8
|
-
import VitessceGrid from './VitessceGrid';
|
|
9
|
-
import { Warning } from './Warning';
|
|
10
|
-
import CallbackPublisher from './CallbackPublisher';
|
|
11
|
-
import { getComponent } from './component-registry';
|
|
12
|
-
import { checkTypes, initialize, upgradeAndValidate } from './view-config-utils';
|
|
13
|
-
// TODO(monorepo): figure out how to get the current package version from package.json
|
|
14
|
-
// import packageJson from '../package.json';
|
|
15
|
-
const packageJson = { version: 'unk' };
|
|
16
|
-
const generateClassName = createGenerateClassName({
|
|
17
|
-
disableGlobal: true,
|
|
18
|
-
});
|
|
19
|
-
function logConfig(config, name) {
|
|
20
|
-
console.groupCollapsed(`🚄 Vitessce (${packageJson.version}) ${name}`);
|
|
21
|
-
console.info(`data:,${JSON.stringify(config)}`);
|
|
22
|
-
console.info(JSON.stringify(config, null, 2));
|
|
23
|
-
console.groupEnd();
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The Vitessce component.
|
|
27
|
-
* @param {object} props
|
|
28
|
-
* @param {object} props.config A Vitessce view config.
|
|
29
|
-
* If the config is valid, the VitessceGrid will be rendered as a child.
|
|
30
|
-
* If the config is invalid, a Warning will be rendered instead.
|
|
31
|
-
* @param {number} props.rowHeight Row height for grid layout. Optional.
|
|
32
|
-
* @param {number} props.height Total height for grid layout. Optional.
|
|
33
|
-
* @param {string} props.theme The theme, used for styling as
|
|
34
|
-
* light or dark. Optional. By default, "dark"
|
|
35
|
-
* @param {function} props.onWarn A callback for warning messages. Optional.
|
|
36
|
-
* @param {function} props.onConfigChange A callback for view config
|
|
37
|
-
* updates. Optional.
|
|
38
|
-
* @param {function} props.onLoaderChange A callback for loader
|
|
39
|
-
* updates. Optional.
|
|
40
|
-
* @param {boolean} props.validateOnConfigChange Whether to validate
|
|
41
|
-
* against the view config schema when publishing changes. Use for debugging
|
|
42
|
-
* purposes, as this may have a performance impact. By default, false.
|
|
43
|
-
*/
|
|
44
|
-
export function Vitessce(props) {
|
|
45
|
-
const { config, rowHeight, height, theme, onWarn, onConfigChange, onLoaderChange, validateOnConfigChange = false, onConfigUpgrade, isBounded = false, } = props;
|
|
46
|
-
// Process the view config and memoize the result:
|
|
47
|
-
// - Validate.
|
|
48
|
-
// - Upgrade, if legacy schema.
|
|
49
|
-
// - Validate after upgrade, if legacy schema.
|
|
50
|
-
// - Initialize (based on initStrategy).
|
|
51
|
-
const [configOrWarning, success] = useMemo(() => {
|
|
52
|
-
// If the config value is undefined, show a warning message.
|
|
53
|
-
if (!config) {
|
|
54
|
-
return [{
|
|
55
|
-
title: 'No such dataset',
|
|
56
|
-
unformatted: 'The dataset configuration could not be found.',
|
|
57
|
-
}, false];
|
|
58
|
-
}
|
|
59
|
-
// If the view config is missing a version, show a warning message.
|
|
60
|
-
if (!config.version) {
|
|
61
|
-
return [{
|
|
62
|
-
title: 'Missing version',
|
|
63
|
-
unformatted: 'The dataset configuration is missing a version, preventing validation.',
|
|
64
|
-
}, false];
|
|
65
|
-
}
|
|
66
|
-
logConfig(config, 'input view config');
|
|
67
|
-
// Check if this is a "legacy" view config.
|
|
68
|
-
const [upgradedConfig, upgradeSuccess] = upgradeAndValidate(config, onConfigUpgrade);
|
|
69
|
-
if (upgradeSuccess) {
|
|
70
|
-
logConfig(upgradedConfig, 'upgraded view config');
|
|
71
|
-
// Initialize the view config according to the initStrategy.
|
|
72
|
-
const [typeCheckSuccess, typeCheckMessage] = checkTypes(upgradedConfig);
|
|
73
|
-
if (typeCheckSuccess) {
|
|
74
|
-
try {
|
|
75
|
-
const initializedConfig = initialize(upgradedConfig);
|
|
76
|
-
logConfig(initializedConfig, 'initialized view config');
|
|
77
|
-
return [initializedConfig, true];
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
return [{
|
|
81
|
-
title: 'View config initialization failed.',
|
|
82
|
-
unformatted: e.message,
|
|
83
|
-
}, false];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return [{
|
|
87
|
-
title: 'View config checks failed.',
|
|
88
|
-
unformatted: typeCheckMessage,
|
|
89
|
-
}, false];
|
|
90
|
-
}
|
|
91
|
-
return [upgradedConfig, false];
|
|
92
|
-
}, [config, onConfigUpgrade]);
|
|
93
|
-
// Emit the upgraded/initialized view config
|
|
94
|
-
// to onConfigChange if necessary.
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
if (success && !isEqual(configOrWarning, config) && onConfigChange) {
|
|
97
|
-
onConfigChange(configOrWarning);
|
|
98
|
-
}
|
|
99
|
-
}, [success, config, configOrWarning, onConfigChange]);
|
|
100
|
-
return success ? (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(ViewConfigProvider, { createStore: createViewConfigStore, children: _jsxs(AuxiliaryProvider, { createStore: createAuxiliaryStore, children: [_jsx(VitessceGrid, { config: configOrWarning, getComponent: getComponent, rowHeight: rowHeight, height: height, theme: theme, isBounded: isBounded }), _jsx(CallbackPublisher, { onWarn: onWarn, onConfigChange: onConfigChange, onLoaderChange: onLoaderChange, validateOnConfigChange: validateOnConfigChange })] }) }) }) })) : (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(Warning, { ...configOrWarning }) }) }));
|
|
101
|
-
}
|