@vitessce/vit-s 2.0.3 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +44072 -0
- package/dist-tsc/CallbackPublisher.d.ts +18 -0
- package/dist-tsc/CallbackPublisher.d.ts.map +1 -0
- package/dist-tsc/CallbackPublisher.js +62 -0
- package/dist-tsc/LoadingIndicator.d.ts +2 -0
- package/dist-tsc/LoadingIndicator.d.ts.map +1 -0
- package/dist-tsc/LoadingIndicator.js +26 -0
- package/dist-tsc/TitleInfo.d.ts +2 -0
- package/dist-tsc/TitleInfo.d.ts.map +1 -0
- package/dist-tsc/TitleInfo.js +74 -0
- package/dist-tsc/VitS.d.ts +50 -0
- package/dist-tsc/VitS.d.ts.map +1 -0
- package/dist-tsc/VitS.js +139 -0
- package/dist-tsc/VitessceGrid.d.ts +23 -0
- package/dist-tsc/VitessceGrid.d.ts.map +1 -0
- package/dist-tsc/VitessceGrid.js +63 -0
- package/dist-tsc/VitessceGrid.test.d.ts +2 -0
- package/dist-tsc/VitessceGrid.test.d.ts.map +1 -0
- package/dist-tsc/VitessceGrid.test.js +43 -0
- package/dist-tsc/Warning.d.ts +2 -0
- package/dist-tsc/Warning.d.ts.map +1 -0
- package/dist-tsc/Warning.js +45 -0
- package/dist-tsc/classNames.d.ts +8 -0
- package/dist-tsc/classNames.d.ts.map +1 -0
- package/dist-tsc/classNames.js +8 -0
- package/dist-tsc/data/AbstractLoader.d.ts +22 -0
- package/dist-tsc/data/AbstractLoader.d.ts.map +1 -0
- package/dist-tsc/data/AbstractLoader.js +18 -0
- package/dist-tsc/data/AbstractTwoStepLoader.d.ts +6 -0
- package/dist-tsc/data/AbstractTwoStepLoader.d.ts.map +1 -0
- package/dist-tsc/data/AbstractTwoStepLoader.js +7 -0
- package/dist-tsc/data/LoaderResult.d.ts +12 -0
- package/dist-tsc/data/LoaderResult.d.ts.map +1 -0
- package/dist-tsc/data/LoaderResult.js +12 -0
- package/dist-tsc/data/index.d.ts +4 -0
- package/dist-tsc/data/index.d.ts.map +1 -0
- package/dist-tsc/data/index.js +3 -0
- package/dist-tsc/data/loader-registry.d.ts +9 -0
- package/dist-tsc/data/loader-registry.d.ts.map +1 -0
- package/dist-tsc/data/loader-registry.js +27 -0
- package/dist-tsc/data-hook-utils.d.ts +65 -0
- package/dist-tsc/data-hook-utils.d.ts.map +1 -0
- package/dist-tsc/data-hook-utils.js +191 -0
- package/dist-tsc/data-hooks.d.ts +73 -0
- package/dist-tsc/data-hooks.d.ts.map +1 -0
- package/dist-tsc/data-hooks.js +254 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts +10 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts.map +1 -0
- package/dist-tsc/errors/AbstractLoaderError.js +13 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts +8 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts.map +1 -0
- package/dist-tsc/errors/DataSourceFetchError.js +13 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts +6 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts.map +1 -0
- package/dist-tsc/errors/DatasetNotFoundError.js +17 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts +10 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts.map +1 -0
- package/dist-tsc/errors/LoaderNotFoundError.js +17 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts +10 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts.map +1 -0
- package/dist-tsc/errors/LoaderValidationError.js +15 -0
- package/dist-tsc/errors/index.d.ts +6 -0
- package/dist-tsc/errors/index.d.ts.map +1 -0
- package/dist-tsc/errors/index.js +5 -0
- package/dist-tsc/hooks.d.ts +76 -0
- package/dist-tsc/hooks.d.ts.map +1 -0
- package/dist-tsc/hooks.js +262 -0
- package/dist-tsc/index.d.ts +12 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +11 -17
- package/dist-tsc/mui-utils.d.ts +2 -0
- package/dist-tsc/mui-utils.d.ts.map +1 -0
- package/dist-tsc/mui-utils.js +44 -0
- package/dist-tsc/plugins.test.fixtures.d.ts +61 -0
- package/dist-tsc/plugins.test.fixtures.d.ts.map +1 -0
- package/dist-tsc/plugins.test.fixtures.js +76 -0
- package/dist-tsc/shared-mui/components.d.ts +2 -0
- package/dist-tsc/shared-mui/components.d.ts.map +1 -0
- package/dist-tsc/shared-mui/components.js +29 -0
- package/dist-tsc/shared-mui/container.d.ts +2 -0
- package/dist-tsc/shared-mui/container.d.ts.map +1 -0
- package/dist-tsc/shared-mui/container.js +211 -0
- package/dist-tsc/shared-mui/styles.d.ts +5 -0
- package/dist-tsc/shared-mui/styles.d.ts.map +1 -0
- package/dist-tsc/shared-mui/styles.js +109 -0
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts +2 -0
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/CellColorEncodingOption.js +17 -0
- package/dist-tsc/shared-plot-options/OptionSelect.d.ts +2 -0
- package/dist-tsc/shared-plot-options/OptionSelect.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/OptionSelect.js +12 -0
- package/dist-tsc/shared-plot-options/OptionsContainer.d.ts +2 -0
- package/dist-tsc/shared-plot-options/OptionsContainer.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/OptionsContainer.js +9 -0
- package/dist-tsc/shared-plot-options/index.d.ts +5 -0
- package/dist-tsc/shared-plot-options/index.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/index.js +4 -0
- package/dist-tsc/shared-plot-options/styles.d.ts +2 -0
- package/dist-tsc/shared-plot-options/styles.d.ts.map +1 -0
- package/dist-tsc/shared-plot-options/styles.js +48 -0
- package/dist-tsc/state/hooks.d.ts +242 -0
- package/dist-tsc/state/hooks.d.ts.map +1 -0
- package/dist-tsc/state/hooks.js +615 -0
- package/dist-tsc/title-styles.d.ts +2 -0
- package/dist-tsc/title-styles.d.ts.map +1 -0
- package/dist-tsc/title-styles.js +72 -0
- package/dist-tsc/view-config-utils.d.ts +31 -0
- package/dist-tsc/view-config-utils.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.js +240 -0
- package/dist-tsc/view-config-utils.test.d.ts +2 -0
- package/dist-tsc/view-config-utils.test.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.test.fixtures.d.ts +1049 -0
- package/dist-tsc/view-config-utils.test.fixtures.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.test.fixtures.js +883 -0
- package/dist-tsc/view-config-utils.test.js +210 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts +8 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.js +114 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.js +48 -0
- package/dist-tsc/vitessce-grid-layout/index.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/index.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/index.js +1 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts +15 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.js +61 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts +2 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.js +149 -0
- package/dist-tsc/vitessce-grid-utils.d.ts +13 -0
- package/dist-tsc/vitessce-grid-utils.d.ts.map +1 -0
- package/dist-tsc/vitessce-grid-utils.js +141 -0
- package/package.json +25 -11
- package/src/CallbackPublisher.js +7 -11
- package/src/LoadingIndicator.js +1 -2
- package/src/TitleInfo.js +12 -85
- package/src/VitS.js +143 -85
- package/src/VitessceGrid.js +35 -21
- package/src/VitessceGrid.test.jsx +23 -8
- package/src/Warning.js +4 -4
- package/src/data/AbstractLoader.js +2 -25
- package/src/data/AbstractTwoStepLoader.js +1 -1
- package/src/data/LoaderResult.js +5 -0
- package/src/data/index.js +3 -3
- package/src/data/loader-registry.js +22 -13
- package/src/data-hook-utils.js +119 -86
- package/src/data-hooks.js +150 -131
- package/src/errors/DataSourceFetchError.js +2 -2
- package/src/errors/DatasetNotFoundError.js +1 -1
- package/src/errors/LoaderNotFoundError.js +1 -1
- package/src/errors/LoaderValidationError.js +1 -1
- package/src/errors/index.js +5 -6
- package/src/hooks.js +81 -26
- package/src/index.js +23 -46
- package/src/mui-utils.js +52 -0
- package/src/shared-mui/components.js +10 -8
- package/src/shared-mui/container.js +1 -1
- package/src/shared-mui/styles.js +5 -2
- package/src/shared-plot-options/CellColorEncodingOption.js +3 -4
- package/src/shared-plot-options/OptionSelect.js +3 -3
- package/src/shared-plot-options/OptionsContainer.js +2 -5
- package/src/shared-plot-options/index.js +4 -4
- package/src/shared-plot-options/styles.js +2 -2
- package/src/state/hooks.js +75 -23
- package/src/title-styles.js +73 -0
- package/src/view-config-utils.js +54 -98
- package/src/view-config-utils.test.jsx +223 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.js +51 -30
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +17 -9
- package/src/vitessce-grid-layout/index.js +1 -1
- package/src/vitessce-grid-layout/layout-utils.js +1 -1
- package/src/vitessce-grid-layout/layout-utils.test.js +2 -1
- package/src/vitessce-grid-utils.js +27 -15
- package/dist/index.mjs +0 -84801
- package/src/component-registry.js +0 -21
- package/src/errors/OptionsValidationError.js +0 -25
- package/src/file-options-schemas-legacy.js +0 -139
- package/src/file-options-schemas-legacy.test.js +0 -138
- package/src/file-options-schemas.js +0 -327
- package/src/file-options-schemas.test.js +0 -26
- package/src/joint-file-types-legacy.js +0 -298
- package/src/joint-file-types-legacy.test.js +0 -412
- package/src/joint-file-types.js +0 -171
- package/src/joint-file-types.test.js +0 -144
- package/src/json-schemas.js +0 -9
- package/src/plugins.js +0 -186
- package/src/plugins.test.js +0 -42
- package/src/schemas/config-0.1.0.schema.json +0 -85
- package/src/schemas/config-1.0.0.schema.json +0 -733
- package/src/schemas/config-1.0.1.schema.json +0 -909
- package/src/schemas/config-1.0.10.schema.json +0 -969
- package/src/schemas/config-1.0.11.schema.json +0 -990
- package/src/schemas/config-1.0.12.schema.json +0 -997
- package/src/schemas/config-1.0.13.schema.json +0 -1013
- package/src/schemas/config-1.0.14.schema.json +0 -1048
- package/src/schemas/config-1.0.15.schema.json +0 -1048
- package/src/schemas/config-1.0.16.schema.json +0 -1069
- package/src/schemas/config-1.0.16.schema.test.js +0 -32
- package/src/schemas/config-1.0.2.schema.json +0 -911
- package/src/schemas/config-1.0.3.schema.json +0 -911
- package/src/schemas/config-1.0.4.schema.json +0 -949
- package/src/schemas/config-1.0.5.schema.json +0 -949
- package/src/schemas/config-1.0.6.schema.json +0 -950
- package/src/schemas/config-1.0.7.schema.json +0 -950
- package/src/schemas/config-1.0.8.schema.json +0 -966
- package/src/schemas/config-1.0.9.schema.json +0 -965
- package/src/schemas/obsSets.schema.js +0 -195
- package/src/schemas/obsSetsTabular.schema.js +0 -39
- package/src/schemas/raster.schema.js +0 -121
- package/src/schemas/schema-schema.sh +0 -34
- package/src/schemas/schema.test-old.js +0 -49
- package/src/view-config-upgraders.js +0 -628
- package/src/view-config-utils.test.js +0 -95
- package/src/view-config-versions.js +0 -68
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { useState, useEffect, useRef, } from 'react';
|
|
2
|
+
import { InternMap } from 'internmap';
|
|
3
|
+
import { isEqual, pick } from 'lodash-es';
|
|
4
|
+
import { fromEntries } from '@vitessce/utils';
|
|
5
|
+
import { DATA_TYPE_COORDINATION_VALUE_USAGE } from '@vitessce/constants-internal';
|
|
6
|
+
import { getSourceAndLoaderFromFileType, getDataTypeFromFileType } from './data/loader-registry.js';
|
|
7
|
+
/**
|
|
8
|
+
* Return the bottom coordinate of the layout.
|
|
9
|
+
* https://github.com/STRML/react-grid-layout/blob/20dac73f91274526034c00968b5bedb9c2ed36b9/lib/utils.js#L82
|
|
10
|
+
* @param {array} layout react-grid-layout layout array.
|
|
11
|
+
* @returns {number} Bottom coordinate.
|
|
12
|
+
*/
|
|
13
|
+
function getNumRows(layout) {
|
|
14
|
+
let max = 0;
|
|
15
|
+
let bottomY;
|
|
16
|
+
// eslint-disable-next-line no-plusplus
|
|
17
|
+
for (let i = 0, len = layout.length; i < len; i++) {
|
|
18
|
+
bottomY = layout[i].y + layout[i].h;
|
|
19
|
+
if (bottomY > max)
|
|
20
|
+
max = bottomY;
|
|
21
|
+
}
|
|
22
|
+
return max;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compute the row height based on the container height, number of rows,
|
|
26
|
+
* and margin/padding. Basically the reverse of the react-grid-layout's
|
|
27
|
+
* `.containerHeight()` function.
|
|
28
|
+
* https://github.com/STRML/react-grid-layout/blob/83251e5e682abfa3252ff89d4bacf47fdc1f4270/lib/ReactGridLayout.jsx#L223
|
|
29
|
+
* @param {number} containerHeight The height of the .vitessce-container element.
|
|
30
|
+
* @param {number} numRows The number of rows in the layout.
|
|
31
|
+
* @param {number} margin The margin value that will be passed to VitessceGrid.
|
|
32
|
+
* @param {number} padding The padding value that will be passed to VitessceGrid.
|
|
33
|
+
* @returns {number} The new row height value.
|
|
34
|
+
*/
|
|
35
|
+
function getRowHeight(containerHeight, numRows, margin, padding) {
|
|
36
|
+
const effectiveContainerHeight = containerHeight - 2 * padding - (numRows - 1) * margin;
|
|
37
|
+
return effectiveContainerHeight / numRows;
|
|
38
|
+
}
|
|
39
|
+
export function useRowHeight(config, initialRowHeight, height, margin, padding) {
|
|
40
|
+
const [containerHeight, setContainerHeight] = useState(height);
|
|
41
|
+
const [rowHeight, setRowHeight] = useState(initialRowHeight);
|
|
42
|
+
const containerRef = useRef();
|
|
43
|
+
// Detect when the `config` or `containerHeight` variables
|
|
44
|
+
// have changed, and update `rowHeight` in response.
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const numRows = getNumRows(config.layout);
|
|
47
|
+
const newRowHeight = getRowHeight(containerHeight, numRows, margin, padding);
|
|
48
|
+
setRowHeight(newRowHeight);
|
|
49
|
+
}, [containerHeight, config, margin, padding]);
|
|
50
|
+
// Update the `containerHeight` state when the `height` prop has changed.
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (height !== null && height !== undefined) {
|
|
53
|
+
setContainerHeight(height);
|
|
54
|
+
}
|
|
55
|
+
}, [height]);
|
|
56
|
+
// If no height prop has been provided, set the `containerHeight`
|
|
57
|
+
// using height of the `.vitessce-container` element.
|
|
58
|
+
// Check the container element height whenever the window has been
|
|
59
|
+
// resized, as it may change if `.vitessce-container` should be
|
|
60
|
+
// sized relative to its parent (and by extension, potentially the window).
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (height !== null && height !== undefined) {
|
|
63
|
+
// eslint will complain if the return value is inconsistent,
|
|
64
|
+
// so return a no-op function.
|
|
65
|
+
return () => { };
|
|
66
|
+
}
|
|
67
|
+
function onWindowResize() {
|
|
68
|
+
if (!containerRef.current)
|
|
69
|
+
return;
|
|
70
|
+
const containerRect = containerRef.current.getBoundingClientRect();
|
|
71
|
+
setContainerHeight(containerRect.height);
|
|
72
|
+
}
|
|
73
|
+
window.addEventListener('resize', onWindowResize);
|
|
74
|
+
onWindowResize();
|
|
75
|
+
return () => {
|
|
76
|
+
window.removeEventListener('resize', onWindowResize);
|
|
77
|
+
};
|
|
78
|
+
}, [containerRef, height]);
|
|
79
|
+
return [rowHeight, containerRef];
|
|
80
|
+
}
|
|
81
|
+
function withDefaults(coordinationValues, dataType, fileType, datasetUid, defaultCoordinationValues) {
|
|
82
|
+
const defaultKeys = DATA_TYPE_COORDINATION_VALUE_USAGE[dataType]
|
|
83
|
+
.filter(k => (Object.keys(defaultCoordinationValues).includes(k)
|
|
84
|
+
&& defaultCoordinationValues[k]
|
|
85
|
+
&& !Object.keys(coordinationValues).includes(k)));
|
|
86
|
+
const defaultValues = pick(defaultCoordinationValues, defaultKeys);
|
|
87
|
+
const coordinationValuesWithDefaults = {
|
|
88
|
+
...defaultValues,
|
|
89
|
+
// The user-provided values should take precedence.
|
|
90
|
+
...coordinationValues,
|
|
91
|
+
};
|
|
92
|
+
if (!isEqual(coordinationValues, coordinationValuesWithDefaults)) {
|
|
93
|
+
// eslint-disable-next-line max-len
|
|
94
|
+
console.warn(`Using coordination value defaults for file type ${fileType} in dataset ${datasetUid}\nBefore: ${JSON.stringify(coordinationValues)}\nAfter: ${JSON.stringify(coordinationValuesWithDefaults)}`);
|
|
95
|
+
}
|
|
96
|
+
return coordinationValuesWithDefaults;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Create a mapping from dataset ID to loader objects by data type.
|
|
100
|
+
* @param {object[]} datasets The datasets array from the view config.
|
|
101
|
+
* @param {string} configDescription The top-level description in the
|
|
102
|
+
* @param {PluginFileType[]} fileTypes
|
|
103
|
+
* @param {PluginCoordinationType[]} coordinationTypes
|
|
104
|
+
* view config.
|
|
105
|
+
* @returns {object} Mapping from dataset ID to data type to loader
|
|
106
|
+
* instance.
|
|
107
|
+
*/
|
|
108
|
+
export function createLoaders(datasets, configDescription, fileTypes, coordinationTypes) {
|
|
109
|
+
const result = {};
|
|
110
|
+
const dataSources = {};
|
|
111
|
+
const defaultCoordinationValues = fromEntries(coordinationTypes.map(ct => ([ct.name, ct.defaultValue])));
|
|
112
|
+
datasets.forEach((dataset) => {
|
|
113
|
+
const datasetLoaders = {
|
|
114
|
+
name: dataset.name,
|
|
115
|
+
description: dataset.description || configDescription,
|
|
116
|
+
loaders: {},
|
|
117
|
+
};
|
|
118
|
+
dataset.files.forEach((file) => {
|
|
119
|
+
const { url, options, requestInit, fileType, coordinationValues = {}, } = file;
|
|
120
|
+
const dataType = getDataTypeFromFileType(fileType, fileTypes);
|
|
121
|
+
const coordinationValuesWithDefaults = withDefaults(coordinationValues, dataType, fileType, dataset.uid, defaultCoordinationValues);
|
|
122
|
+
const [DataSourceClass, LoaderClass] = getSourceAndLoaderFromFileType(fileType, fileTypes);
|
|
123
|
+
// Create _one_ DataSourceClass instance per URL. Derived loaders share this object.
|
|
124
|
+
const fileId = url || JSON.stringify(options);
|
|
125
|
+
if (!(fileId in dataSources)) {
|
|
126
|
+
dataSources[fileId] = new DataSourceClass({ url, requestInit });
|
|
127
|
+
}
|
|
128
|
+
const loader = new LoaderClass(dataSources[fileId], file);
|
|
129
|
+
if (datasetLoaders.loaders[dataType]) {
|
|
130
|
+
datasetLoaders.loaders[dataType].set(coordinationValuesWithDefaults, loader);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
datasetLoaders.loaders[dataType] = new InternMap([
|
|
134
|
+
[coordinationValuesWithDefaults, loader],
|
|
135
|
+
], JSON.stringify);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
result[dataset.uid] = datasetLoaders;
|
|
139
|
+
});
|
|
140
|
+
return result;
|
|
141
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/vit-s",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -8,36 +8,50 @@
|
|
|
8
8
|
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.js",
|
|
12
13
|
"files": [
|
|
14
|
+
"src",
|
|
13
15
|
"dist",
|
|
14
|
-
"
|
|
16
|
+
"dist-tsc"
|
|
15
17
|
],
|
|
16
18
|
"dependencies": {
|
|
17
19
|
"@material-ui/core": "~4.12.3",
|
|
18
20
|
"@material-ui/icons": "~4.11.2",
|
|
19
|
-
"
|
|
21
|
+
"@tanstack/react-query": "^4.29.12",
|
|
20
22
|
"clsx": "^1.1.1",
|
|
23
|
+
"d3-array": "^2.4.0",
|
|
21
24
|
"fast-deep-equal": "^3.1.3",
|
|
22
25
|
"internmap": "^2.0.3",
|
|
23
26
|
"jss-plugin-global": "^10.9.2",
|
|
24
|
-
"lodash": "^4.17.21",
|
|
27
|
+
"lodash-es": "^4.17.21",
|
|
25
28
|
"react-grid-layout-with-lodash": "^1.3.5",
|
|
26
|
-
"uuid": "^
|
|
29
|
+
"uuid": "^9.0.0",
|
|
27
30
|
"zustand": "^3.5.10",
|
|
28
|
-
"@vitessce/constants-internal": "
|
|
29
|
-
"@vitessce/
|
|
31
|
+
"@vitessce/constants-internal": "3.0.1",
|
|
32
|
+
"@vitessce/plugins": "3.0.1",
|
|
33
|
+
"@vitessce/schemas": "3.0.1",
|
|
34
|
+
"@vitessce/utils": "3.0.1"
|
|
30
35
|
},
|
|
31
36
|
"devDependencies": {
|
|
37
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
38
|
+
"@testing-library/react": "^13.3.0",
|
|
32
39
|
"react": "^18.0.0",
|
|
33
|
-
"vite": "^3.0
|
|
34
|
-
"vitest": "^0.
|
|
40
|
+
"vite": "^4.3.0",
|
|
41
|
+
"vitest": "^0.32.2"
|
|
35
42
|
},
|
|
36
43
|
"peerDependencies": {
|
|
37
44
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
38
45
|
},
|
|
39
46
|
"scripts": {
|
|
40
47
|
"bundle": "pnpm exec vite build -c ../../scripts/vite.config.js",
|
|
41
|
-
"test": "pnpm exec vitest --run
|
|
48
|
+
"test": "pnpm exec vitest --run"
|
|
49
|
+
},
|
|
50
|
+
"module": "dist/index.js",
|
|
51
|
+
"exports": {
|
|
52
|
+
".": {
|
|
53
|
+
"types": "./dist-tsc/index.d.ts",
|
|
54
|
+
"import": "./dist/index.js"
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
57
|
}
|
package/src/CallbackPublisher.js
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { useViewConfigStoreApi, useLoaders, useWarning } from './state/hooks';
|
|
2
|
+
import { useViewConfigStoreApi, useLoaders, useWarning } from './state/hooks.js';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
function validateViewConfig(viewConfig, pluginSpecificConfigSchema) {
|
|
6
6
|
// Need the try-catch here since Zustand will actually
|
|
7
7
|
// just catch and ignore errors in its subscription callbacks.
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
const valid = validate(viewConfig);
|
|
11
|
-
if (!valid) {
|
|
12
|
-
const failureReason = JSON.stringify(validate.errors, null, 2);
|
|
13
|
-
throw new Error(`Config validation failed: ${failureReason}`);
|
|
14
|
-
}
|
|
9
|
+
pluginSpecificConfigSchema.parse(viewConfig);
|
|
15
10
|
} catch (e) {
|
|
16
11
|
console.error(e);
|
|
17
12
|
}
|
|
@@ -36,6 +31,7 @@ export default function CallbackPublisher(props) {
|
|
|
36
31
|
onConfigChange,
|
|
37
32
|
onLoaderChange,
|
|
38
33
|
validateOnConfigChange,
|
|
34
|
+
pluginSpecificConfigSchema,
|
|
39
35
|
} = props;
|
|
40
36
|
|
|
41
37
|
const warning = useWarning();
|
|
@@ -51,7 +47,7 @@ export default function CallbackPublisher(props) {
|
|
|
51
47
|
// The function to run on each publish.
|
|
52
48
|
(viewConfig) => {
|
|
53
49
|
if (validateOnConfigChange && viewConfig) {
|
|
54
|
-
validateViewConfig(viewConfig);
|
|
50
|
+
validateViewConfig(viewConfig, pluginSpecificConfigSchema);
|
|
55
51
|
}
|
|
56
52
|
if (onConfigChange && viewConfig) {
|
|
57
53
|
onConfigChange(viewConfig);
|
|
@@ -60,7 +56,7 @@ export default function CallbackPublisher(props) {
|
|
|
60
56
|
// The function to specify which part of the store
|
|
61
57
|
// we want to subscribe to.
|
|
62
58
|
state => state.viewConfig,
|
|
63
|
-
), [onConfigChange, validateOnConfigChange, viewConfigStoreApi]);
|
|
59
|
+
), [onConfigChange, validateOnConfigChange, viewConfigStoreApi, pluginSpecificConfigSchema]);
|
|
64
60
|
|
|
65
61
|
// Emit updates to the warning message.
|
|
66
62
|
useEffect(() => {
|
package/src/LoadingIndicator.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { makeStyles } from '@material-ui/core
|
|
3
|
-
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
2
|
+
import { makeStyles, CircularProgress } from '@material-ui/core';
|
|
4
3
|
|
|
5
4
|
const useStyles = makeStyles(() => ({
|
|
6
5
|
loadingIndicatorBackdrop: {
|
package/src/TitleInfo.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import { makeStyles } from '@material-ui/core
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import CloseIcon from '@material-ui/icons/Close';
|
|
3
|
+
import { makeStyles, MenuItem, IconButton, Link } from '@material-ui/core';
|
|
4
|
+
import {
|
|
5
|
+
CloudDownload as CloudDownloadIcon,
|
|
6
|
+
ArrowDropDown as ArrowDropDownIcon,
|
|
7
|
+
ArrowDropUp as ArrowDropUpIcon,
|
|
8
|
+
Settings as SettingsIcon,
|
|
9
|
+
Close as CloseIcon,
|
|
10
|
+
} from '@material-ui/icons';
|
|
12
11
|
|
|
13
|
-
import { TOOLTIP_ANCESTOR } from './classNames';
|
|
14
|
-
import LoadingIndicator from './LoadingIndicator';
|
|
15
|
-
import { PopperMenu } from './shared-mui/components';
|
|
12
|
+
import { TOOLTIP_ANCESTOR } from './classNames.js';
|
|
13
|
+
import LoadingIndicator from './LoadingIndicator.js';
|
|
14
|
+
import { PopperMenu } from './shared-mui/components.js';
|
|
15
|
+
import { useTitleStyles } from './title-styles.js';
|
|
16
16
|
|
|
17
17
|
const useStyles = makeStyles(theme => ({
|
|
18
18
|
iconButton: {
|
|
@@ -117,79 +117,6 @@ function ClosePaneButton(props) {
|
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
export const useTitleStyles = makeStyles(theme => ({
|
|
121
|
-
title: {
|
|
122
|
-
color: theme.palette.primaryForeground,
|
|
123
|
-
overflowX: 'hidden',
|
|
124
|
-
display: 'flex',
|
|
125
|
-
flexDirection: 'row',
|
|
126
|
-
flexShrink: '0',
|
|
127
|
-
},
|
|
128
|
-
titleLeft: {
|
|
129
|
-
flexShrink: '1',
|
|
130
|
-
textOverflow: 'ellipsis',
|
|
131
|
-
whiteSpace: 'nowrap',
|
|
132
|
-
},
|
|
133
|
-
titleInfo: {
|
|
134
|
-
width: '100%',
|
|
135
|
-
textOverflow: 'ellipsis',
|
|
136
|
-
whiteSpace: 'nowrap',
|
|
137
|
-
overflow: 'hidden',
|
|
138
|
-
fontSize: '80% !important',
|
|
139
|
-
opacity: '.8',
|
|
140
|
-
padding: '0 4px',
|
|
141
|
-
justifyContent: 'center',
|
|
142
|
-
lineHeight: '25px !important',
|
|
143
|
-
flexShrink: '1',
|
|
144
|
-
textAlign: 'right !important',
|
|
145
|
-
},
|
|
146
|
-
titleButtons: {
|
|
147
|
-
display: 'flex',
|
|
148
|
-
flexDirection: 'row',
|
|
149
|
-
flexGrow: '1',
|
|
150
|
-
flexShrink: '0',
|
|
151
|
-
justifyContent: 'right',
|
|
152
|
-
'& div': {
|
|
153
|
-
display: 'inline-block',
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
card: {
|
|
157
|
-
border: `1px solid ${theme.palette.cardBorder}`,
|
|
158
|
-
flex: '1 1 auto',
|
|
159
|
-
minHeight: '1px',
|
|
160
|
-
padding: '12px',
|
|
161
|
-
marginTop: '8px',
|
|
162
|
-
marginBottom: '8px',
|
|
163
|
-
position: 'relative',
|
|
164
|
-
display: 'flex',
|
|
165
|
-
flexDirection: 'column',
|
|
166
|
-
minWidth: '0',
|
|
167
|
-
wordWrap: 'break-word',
|
|
168
|
-
backgroundClip: 'border-box',
|
|
169
|
-
borderRadius: '4px',
|
|
170
|
-
},
|
|
171
|
-
noScrollCard: {
|
|
172
|
-
backgroundColor: theme.palette.secondaryBackground,
|
|
173
|
-
color: theme.palette.secondaryForeground,
|
|
174
|
-
},
|
|
175
|
-
scrollCard: {
|
|
176
|
-
backgroundColor: theme.palette.primaryBackground,
|
|
177
|
-
color: theme.palette.primaryForeground,
|
|
178
|
-
'& a': {
|
|
179
|
-
color: theme.palette.primaryForegroundActive,
|
|
180
|
-
},
|
|
181
|
-
overflowY: 'auto',
|
|
182
|
-
},
|
|
183
|
-
spatialCard: {
|
|
184
|
-
backgroundColor: theme.palette.black,
|
|
185
|
-
color: theme.palette.white,
|
|
186
|
-
'& a': {
|
|
187
|
-
color: theme.palette.white,
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
}));
|
|
191
|
-
|
|
192
|
-
|
|
193
120
|
export function TitleInfo(props) {
|
|
194
121
|
const {
|
|
195
122
|
title, info, children, isScroll, isSpatial, removeGridComponent, urls,
|