@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,262 @@
|
|
|
1
|
+
import { useRef, useState, useEffect, useCallback, useMemo, } from 'react';
|
|
2
|
+
import { debounce, every } from 'lodash-es';
|
|
3
|
+
import { extent } from 'd3-array';
|
|
4
|
+
import { capitalize, fromEntries } from '@vitessce/utils';
|
|
5
|
+
import { STATUS } from '@vitessce/constants-internal';
|
|
6
|
+
import { useGridResize, useEmitGridResize } from './state/hooks.js';
|
|
7
|
+
import { VITESSCE_CONTAINER } from './classNames.js';
|
|
8
|
+
function getWindowDimensions() {
|
|
9
|
+
const { innerWidth: width, innerHeight: height } = window;
|
|
10
|
+
return {
|
|
11
|
+
width,
|
|
12
|
+
height,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function useVitessceContainer(ref) {
|
|
16
|
+
return useCallback(() => {
|
|
17
|
+
if (ref.current) {
|
|
18
|
+
return ref.current.closest(`.${VITESSCE_CONTAINER}`);
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}, [ref]);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Custom hook, gets the full window dimensions.
|
|
25
|
+
* @returns {array} `[width, height]` where width and height
|
|
26
|
+
* are numbers.
|
|
27
|
+
*/
|
|
28
|
+
export function useWindowDimensions() {
|
|
29
|
+
const [windowDimensions, setWindowDimensions] = useState(getWindowDimensions());
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
function handleResize() {
|
|
32
|
+
setWindowDimensions(getWindowDimensions());
|
|
33
|
+
}
|
|
34
|
+
const onResizeDebounced = debounce(handleResize, 100, { trailing: true });
|
|
35
|
+
window.addEventListener('resize', onResizeDebounced);
|
|
36
|
+
return () => window.removeEventListener('resize', onResizeDebounced);
|
|
37
|
+
}, []);
|
|
38
|
+
return windowDimensions;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Custom hook, subscribes to GRID_RESIZE and window resize events.
|
|
42
|
+
* @returns {array} `[width, height, containerRef]` where width and height
|
|
43
|
+
* are numbers and containerRef is a React ref.
|
|
44
|
+
*/
|
|
45
|
+
export function useGridItemSize() {
|
|
46
|
+
const containerRef = useRef();
|
|
47
|
+
const [height, setHeight] = useState();
|
|
48
|
+
const [width, setWidth] = useState();
|
|
49
|
+
const resizeCount = useGridResize();
|
|
50
|
+
const incrementResizeCount = useEmitGridResize();
|
|
51
|
+
// On window resize events, increment the grid resize count.
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
function onWindowResize() {
|
|
54
|
+
incrementResizeCount();
|
|
55
|
+
}
|
|
56
|
+
const onResizeDebounced = debounce(onWindowResize, 100, { trailing: true });
|
|
57
|
+
window.addEventListener('resize', onResizeDebounced);
|
|
58
|
+
onWindowResize();
|
|
59
|
+
return () => {
|
|
60
|
+
window.removeEventListener('resize', onResizeDebounced);
|
|
61
|
+
};
|
|
62
|
+
}, [incrementResizeCount]);
|
|
63
|
+
// On new grid resize counts, re-compute the component
|
|
64
|
+
// width/height.
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!containerRef.current)
|
|
67
|
+
return;
|
|
68
|
+
const container = containerRef.current;
|
|
69
|
+
const containerRect = container.getBoundingClientRect();
|
|
70
|
+
setHeight(containerRect.height);
|
|
71
|
+
setWidth(containerRect.width);
|
|
72
|
+
}, [resizeCount]);
|
|
73
|
+
return [width, height, containerRef];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Custom hook, subscribes to GRID_RESIZE and window resize events.
|
|
77
|
+
* @returns {array} `[width, height, deckRef]` where width and height
|
|
78
|
+
* are numbers and deckRef is a React ref to be used with
|
|
79
|
+
* a <DeckGL/> element (or a forwardRef to one).
|
|
80
|
+
*/
|
|
81
|
+
export function useDeckCanvasSize() {
|
|
82
|
+
const deckRef = useRef();
|
|
83
|
+
const [height, setHeight] = useState();
|
|
84
|
+
const [width, setWidth] = useState();
|
|
85
|
+
const resizeCount = useGridResize();
|
|
86
|
+
const incrementResizeCount = useEmitGridResize();
|
|
87
|
+
// On window resize events, increment the grid resize count.
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
function onWindowResize() {
|
|
90
|
+
incrementResizeCount();
|
|
91
|
+
}
|
|
92
|
+
const onResizeDebounced = debounce(onWindowResize, 100, { trailing: true });
|
|
93
|
+
window.addEventListener('resize', onResizeDebounced);
|
|
94
|
+
onWindowResize();
|
|
95
|
+
return () => {
|
|
96
|
+
window.removeEventListener('resize', onResizeDebounced);
|
|
97
|
+
};
|
|
98
|
+
}, [incrementResizeCount]);
|
|
99
|
+
// On new grid resize counts, re-compute the DeckGL canvas
|
|
100
|
+
// width/height.
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!deckRef.current)
|
|
103
|
+
return;
|
|
104
|
+
const { canvas } = deckRef.current.deck;
|
|
105
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
106
|
+
setHeight(canvasRect.height);
|
|
107
|
+
setWidth(canvasRect.width);
|
|
108
|
+
}, [resizeCount]);
|
|
109
|
+
return [width, height, deckRef];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* This hook handles a boolean isReady value,
|
|
113
|
+
* which only returns true once every item in the
|
|
114
|
+
* input list has been marked as "ready".
|
|
115
|
+
* @param {string[]} statusValues The items to wait on.
|
|
116
|
+
* @returns {boolean} Whether the status values are all success.
|
|
117
|
+
*/
|
|
118
|
+
export function useReady(statusValues) {
|
|
119
|
+
return useMemo(() => every(statusValues, val => val !== STATUS.LOADING), statusValues);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* This hook helps manage a list of URLs.
|
|
123
|
+
* @param {(null|object[])[]} urls Array of (null or array of { url, name }).
|
|
124
|
+
* @returns {array} An array of { url, name } objects (flattened from the input).
|
|
125
|
+
*/
|
|
126
|
+
export function useUrls(urls) {
|
|
127
|
+
const mergedUrls = useMemo(() => urls.filter(a => Array.isArray(a)).flat(),
|
|
128
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
+
urls);
|
|
130
|
+
return mergedUrls;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Custom hook, subscribes to the width and height of the closest .vitessce-container
|
|
134
|
+
* element and updates upon window resize events.
|
|
135
|
+
* @param {Ref} ref A React ref object within the `.vitessce-container`.
|
|
136
|
+
* @returns {array} `[width, height]` where width and height
|
|
137
|
+
* are numbers.
|
|
138
|
+
*/
|
|
139
|
+
export function useClosestVitessceContainerSize(ref) {
|
|
140
|
+
const [height, setHeight] = useState();
|
|
141
|
+
const [width, setWidth] = useState();
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
function onWindowResize() {
|
|
144
|
+
if (ref.current) {
|
|
145
|
+
const { clientHeight: componentHeight, clientWidth: componentWidth, } = ref.current.closest(`.${VITESSCE_CONTAINER}`);
|
|
146
|
+
setWidth(componentWidth);
|
|
147
|
+
setHeight(componentHeight);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const onResizeDebounced = debounce(onWindowResize, 100, { trailing: true });
|
|
151
|
+
window.addEventListener('resize', onResizeDebounced);
|
|
152
|
+
onWindowResize();
|
|
153
|
+
return () => {
|
|
154
|
+
window.removeEventListener('resize', onResizeDebounced);
|
|
155
|
+
};
|
|
156
|
+
}, [ref]);
|
|
157
|
+
return [width, height];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Normalize an obsFeatureMatrix to a Uint8Array.
|
|
161
|
+
* @param {object} params
|
|
162
|
+
* @param {object} params.obsFeatureMatrix The obsFeatureMatrix
|
|
163
|
+
* returned by the useObsFeatureMatrix hook.
|
|
164
|
+
* @returns {array} A tuple [obsFeatureMatrix, dataExtent]
|
|
165
|
+
* where obsFeatureMatrix
|
|
166
|
+
* is a Uint8Array with the same shape as
|
|
167
|
+
* params.obsFeatureMatrix.data, and dataExtent is the
|
|
168
|
+
* [min, max] of the original data.
|
|
169
|
+
*/
|
|
170
|
+
export function useUint8ObsFeatureMatrix({ obsFeatureMatrix }) {
|
|
171
|
+
return useMemo(() => {
|
|
172
|
+
if (obsFeatureMatrix && obsFeatureMatrix.data) {
|
|
173
|
+
const dataExtent = extent(obsFeatureMatrix.data);
|
|
174
|
+
const [min, max] = dataExtent;
|
|
175
|
+
const ratio = 255 / (max - min);
|
|
176
|
+
const data = new Uint8Array(obsFeatureMatrix.data.map(i => Math.floor((i - min) * ratio)));
|
|
177
|
+
return [{ data }, dataExtent];
|
|
178
|
+
}
|
|
179
|
+
return [null, null];
|
|
180
|
+
}, [obsFeatureMatrix]);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Normalize a feature selection (data for selected
|
|
184
|
+
* columns of an obsFeatureMatrix) to a Uint8Array.
|
|
185
|
+
* @param {array|null} expressionData The expressionData
|
|
186
|
+
* returned by the useFeatureSelection hook,
|
|
187
|
+
* where each element corresponds to an
|
|
188
|
+
* array of values for a selected feature.
|
|
189
|
+
* @returns {array} A tuple [normData, extents] where
|
|
190
|
+
* normData is an array of Uint8Arrays (or null), and extents is
|
|
191
|
+
* an array of [min, max] values for each feature (or null).
|
|
192
|
+
*/
|
|
193
|
+
export function useUint8FeatureSelection(expressionData) {
|
|
194
|
+
return useMemo(() => {
|
|
195
|
+
if (expressionData && expressionData[0]) {
|
|
196
|
+
const extents = expressionData.map(arr => extent(arr));
|
|
197
|
+
const normData = expressionData.map((arr, i) => {
|
|
198
|
+
const [min, max] = extents[i];
|
|
199
|
+
const ratio = 255 / (max - min);
|
|
200
|
+
return new Uint8Array(arr.map(j => Math.floor((j - min) * ratio)));
|
|
201
|
+
});
|
|
202
|
+
return [normData, extents];
|
|
203
|
+
}
|
|
204
|
+
return [null, null];
|
|
205
|
+
}, [expressionData]);
|
|
206
|
+
}
|
|
207
|
+
export function useExpressionValueGetter({ instanceObsIndex, matrixObsIndex, expressionData }) {
|
|
208
|
+
// Get a mapping from cell ID to row index in the gene expression matrix.
|
|
209
|
+
// Since the two obsIndices (instanceObsIndex = the obsIndex from obsEmbedding)
|
|
210
|
+
// may be ordered differently (matrixObsIndex = the obsIndex from obsFeatureMatrix),
|
|
211
|
+
// we need a way to look up an obsFeatureMatrix obsIndex index
|
|
212
|
+
// given an obsEmbedding obsIndex index.
|
|
213
|
+
const toMatrixIndexMap = useMemo(() => {
|
|
214
|
+
if (instanceObsIndex && matrixObsIndex) {
|
|
215
|
+
const matrixIndexMap = new Map(matrixObsIndex.map((key, i) => ([key, i])));
|
|
216
|
+
return instanceObsIndex.map(key => matrixIndexMap.get(key));
|
|
217
|
+
}
|
|
218
|
+
return null;
|
|
219
|
+
}, [instanceObsIndex, matrixObsIndex]);
|
|
220
|
+
// Set up a getter function for gene expression values, to be used
|
|
221
|
+
// by the DeckGL layer to obtain values for instanced attributes.
|
|
222
|
+
const getExpressionValue = useCallback((entry, { index: instanceIndex }) => {
|
|
223
|
+
if (toMatrixIndexMap && expressionData && expressionData[0]) {
|
|
224
|
+
const rowIndex = toMatrixIndexMap[instanceIndex];
|
|
225
|
+
const val = expressionData[0][rowIndex];
|
|
226
|
+
return val;
|
|
227
|
+
}
|
|
228
|
+
return 0;
|
|
229
|
+
}, [toMatrixIndexMap, expressionData]);
|
|
230
|
+
return getExpressionValue;
|
|
231
|
+
}
|
|
232
|
+
export function useGetObsMembership(obsSetsMembership) {
|
|
233
|
+
return useCallback((obsId) => {
|
|
234
|
+
if (obsId) {
|
|
235
|
+
return obsSetsMembership?.get(obsId) || [];
|
|
236
|
+
}
|
|
237
|
+
return [];
|
|
238
|
+
}, [obsSetsMembership]);
|
|
239
|
+
}
|
|
240
|
+
export function useGetObsInfo(obsType, obsLabelsTypes, obsLabelsData, obsSetsMembership) {
|
|
241
|
+
return useCallback((obsId) => {
|
|
242
|
+
if (obsId) {
|
|
243
|
+
const obsMembership = obsSetsMembership?.get(obsId) || [];
|
|
244
|
+
return {
|
|
245
|
+
[`${capitalize(obsType)} ID`]: obsId,
|
|
246
|
+
...fromEntries(obsMembership.flatMap(path => path.slice(1).map((pathEl, elLevel) => ([
|
|
247
|
+
`${path[0]}${path.length > 2 ? ` L${elLevel + 1}` : ''}`,
|
|
248
|
+
pathEl,
|
|
249
|
+
])))),
|
|
250
|
+
...fromEntries(Object.entries(obsLabelsTypes).map(([scopeKey, obsLabelsType]) => ([
|
|
251
|
+
obsLabelsType,
|
|
252
|
+
obsLabelsData?.[scopeKey]?.obsLabels?.[
|
|
253
|
+
// TODO: Maybe all loaders that return obsIndex should also return an obsIndexMap
|
|
254
|
+
// with keys: obsId, values: obsIdx
|
|
255
|
+
// which would avoid the indexOf calls.
|
|
256
|
+
obsLabelsData?.[scopeKey]?.obsIndex?.indexOf(obsId)],
|
|
257
|
+
])).filter(([obsLabelsType]) => Boolean(obsLabelsType))),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
}, [obsType, obsLabelsTypes, obsLabelsData, obsSetsMembership]);
|
|
262
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { VitS } from "./VitS.js";
|
|
2
|
+
export { TitleInfo } from "./TitleInfo.js";
|
|
3
|
+
export { PopperMenu } from "./shared-mui/components.js";
|
|
4
|
+
export { useHasLoader } from "./data-hook-utils.js";
|
|
5
|
+
export { logConfig } from "./view-config-utils.js";
|
|
6
|
+
export { useReady, useUrls, useVitessceContainer, useDeckCanvasSize, useUint8ObsFeatureMatrix, useUint8FeatureSelection, useExpressionValueGetter, useGetObsMembership, useGetObsInfo, useClosestVitessceContainerSize, useWindowDimensions, useGridItemSize } from "./hooks.js";
|
|
7
|
+
export { useInitialCoordination, useCoordination, useComplexCoordination, useMultiCoordinationValues, useMultiDatasetCoordination, useDatasetUids, useLoaders, useMatchingLoader, useViewConfigStore, useViewConfigStoreApi, useComponentHover, useSetComponentHover, useComponentViewInfo, useSetComponentViewInfo, useWarning, useSetWarning, useAuxiliaryCoordination, useComponentLayout } from "./state/hooks.js";
|
|
8
|
+
export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useFeatureSelection, useObsFeatureMatrixIndices, useMultiObsLabels, useObsLocationsData, useObsSegmentationsData, useNeighborhoodsData, useObsLabelsData, useObsFeatureMatrixData, useFeatureLabelsData, useGenomicProfilesData } from "./data-hooks.js";
|
|
9
|
+
export { AbstractLoader, AbstractTwoStepLoader, LoaderResult } from "./data/index.js";
|
|
10
|
+
export { AbstractLoaderError, DatasetNotFoundError, LoaderNotFoundError, LoaderValidationError, DataSourceFetchError } from "./errors/index.js";
|
|
11
|
+
export { CellColorEncodingOption, OptionsContainer, OptionSelect, usePlotOptionsStyles } from "./shared-plot-options/index.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|
package/dist-tsc/index.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
export { VitS } from './VitS';
|
|
2
|
-
export { TitleInfo } from './TitleInfo';
|
|
3
|
-
export { PopperMenu } from './shared-mui/components';
|
|
4
|
-
export { registerPluginViewType, registerPluginCoordinationType, registerPluginFileType, registerPluginJointFileType, } from './plugins';
|
|
1
|
+
export { VitS } from './VitS.js';
|
|
2
|
+
export { TitleInfo } from './TitleInfo.js';
|
|
3
|
+
export { PopperMenu } from './shared-mui/components.js';
|
|
5
4
|
// For plugin view types:
|
|
6
|
-
export { useReady, useUrls, useVitessceContainer, useDeckCanvasSize, useExpressionValueGetter, useGetObsInfo, useClosestVitessceContainerSize, useWindowDimensions, useGridItemSize, } from './hooks';
|
|
7
|
-
export { useCoordination, useComplexCoordination, useMultiCoordinationValues, useMultiDatasetCoordination, useDatasetUids, useLoaders, useMatchingLoader, useViewConfigStore, useViewConfigStoreApi, useComponentHover, useSetComponentHover, useComponentViewInfo, useSetComponentViewInfo, useWarning, useSetWarning, useAuxiliaryCoordination, useComponentLayout, } from './state/hooks';
|
|
8
|
-
export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useFeatureSelection, useObsFeatureMatrixIndices, useMultiObsLabels, useObsLocationsData, useObsSegmentationsData, useNeighborhoodsData, useObsLabelsData, useObsFeatureMatrixData, useFeatureLabelsData, useGenomicProfilesData, } from './data-hooks';
|
|
9
|
-
export { useHasLoader, } from './data-hook-utils';
|
|
10
|
-
export { AbstractLoader, AbstractTwoStepLoader, LoaderResult, } from './data/index';
|
|
11
|
-
export { AbstractLoaderError, DatasetNotFoundError, LoaderNotFoundError, LoaderValidationError,
|
|
12
|
-
export {
|
|
13
|
-
|
|
14
|
-
obsEmbeddingAnndataSchema, obsLocationsAnndataSchema, obsSegmentationsAnndataSchema, obsSetsAnndataSchema, obsFeatureMatrixAnndataSchema, obsLabelsAnndataSchema, featureLabelsAnndataSchema, obsEmbeddingCsvSchema, obsLocationsCsvSchema, obsLabelsCsvSchema, featureLabelsCsvSchema, obsSetsCsvSchema, anndataZarrSchema, emptySchema, } from './file-options-schemas';
|
|
15
|
-
export { SCHEMA_HANDLERS, LATEST_VERSION, } from './view-config-versions';
|
|
16
|
-
export { upgradeAndValidate, } from './view-config-utils';
|
|
17
|
-
export { CellColorEncodingOption, OptionsContainer, OptionSelect, usePlotOptionsStyles, } from './shared-plot-options';
|
|
18
|
-
export * from './json-schemas';
|
|
5
|
+
export { useReady, useUrls, useVitessceContainer, useDeckCanvasSize, useUint8ObsFeatureMatrix, useUint8FeatureSelection, useExpressionValueGetter, useGetObsMembership, useGetObsInfo, useClosestVitessceContainerSize, useWindowDimensions, useGridItemSize, } from './hooks.js';
|
|
6
|
+
export { useInitialCoordination, useCoordination, useComplexCoordination, useMultiCoordinationValues, useMultiDatasetCoordination, useDatasetUids, useLoaders, useMatchingLoader, useViewConfigStore, useViewConfigStoreApi, useComponentHover, useSetComponentHover, useComponentViewInfo, useSetComponentViewInfo, useWarning, useSetWarning, useAuxiliaryCoordination, useComponentLayout, } from './state/hooks.js';
|
|
7
|
+
export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useFeatureSelection, useObsFeatureMatrixIndices, useMultiObsLabels, useObsLocationsData, useObsSegmentationsData, useNeighborhoodsData, useObsLabelsData, useObsFeatureMatrixData, useFeatureLabelsData, useGenomicProfilesData, } from './data-hooks.js';
|
|
8
|
+
export { useHasLoader, } from './data-hook-utils.js';
|
|
9
|
+
export { AbstractLoader, AbstractTwoStepLoader, LoaderResult, } from './data/index.js';
|
|
10
|
+
export { AbstractLoaderError, DatasetNotFoundError, LoaderNotFoundError, LoaderValidationError, DataSourceFetchError, } from './errors/index.js';
|
|
11
|
+
export { CellColorEncodingOption, OptionsContainer, OptionSelect, usePlotOptionsStyles, } from './shared-plot-options/index.js';
|
|
12
|
+
export { logConfig } from './view-config-utils.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mui-utils.d.ts","sourceRoot":"","sources":["../src/mui-utils.js"],"names":[],"mappings":"AAyBA,mGA0BC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// This function has been copied from MUI v4
|
|
2
|
+
// with logic related to randomness / random numbers removed.
|
|
3
|
+
// Reference: https://github.com/mui/material-ui/blob/0adada09/packages/mui-styles/src/createGenerateClassName/createGenerateClassName.js#L29
|
|
4
|
+
/**
|
|
5
|
+
* This is the list of the style rule name we use as drop in replacement for the built-in
|
|
6
|
+
* pseudo classes (:checked, :disabled, :focused, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Why do they exist in the first place?
|
|
9
|
+
* These classes are used at a specificity of 2.
|
|
10
|
+
* It allows them to override previously defined styles as well as
|
|
11
|
+
* being untouched by simple user overrides.
|
|
12
|
+
*/
|
|
13
|
+
const stateClasses = [
|
|
14
|
+
'checked',
|
|
15
|
+
'disabled',
|
|
16
|
+
'error',
|
|
17
|
+
'focused',
|
|
18
|
+
'focusVisible',
|
|
19
|
+
'required',
|
|
20
|
+
'expanded',
|
|
21
|
+
'selected',
|
|
22
|
+
];
|
|
23
|
+
const defaultPrefix = 'vit-';
|
|
24
|
+
export function createGenerateClassName(customPrefix) {
|
|
25
|
+
return (rule, styleSheet) => {
|
|
26
|
+
const { name: styleSheetName, link: styleSheetLink, classNamePrefix, } = styleSheet.options;
|
|
27
|
+
const { key: ruleKey } = rule;
|
|
28
|
+
const seedPrefix = customPrefix ? `${customPrefix}-` : defaultPrefix;
|
|
29
|
+
// Is a global static MUI style?
|
|
30
|
+
if (styleSheetName && styleSheetName.indexOf('Mui') === 0 && !styleSheetLink) {
|
|
31
|
+
// We can use a shorthand class name, we never use the keys to style the components.
|
|
32
|
+
if (stateClasses.indexOf(ruleKey) !== -1) {
|
|
33
|
+
return `Mui-${ruleKey}`;
|
|
34
|
+
}
|
|
35
|
+
const prefix = `${seedPrefix}${styleSheetName}-${ruleKey}`;
|
|
36
|
+
return prefix;
|
|
37
|
+
}
|
|
38
|
+
// Help with debuggability.
|
|
39
|
+
if (classNamePrefix) {
|
|
40
|
+
return `${seedPrefix}${classNamePrefix}-${ruleKey}`;
|
|
41
|
+
}
|
|
42
|
+
return `${seedPrefix}${ruleKey}`;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export function pluginExpandAnnDataConvenience(fileDef: any): {
|
|
2
|
+
fileType: string;
|
|
3
|
+
url: any;
|
|
4
|
+
options: any;
|
|
5
|
+
}[];
|
|
6
|
+
export namespace convenienceFileDefsCollapsed {
|
|
7
|
+
const version: string;
|
|
8
|
+
const name: string;
|
|
9
|
+
const description: string;
|
|
10
|
+
const initStrategy: string;
|
|
11
|
+
const datasets: {
|
|
12
|
+
files: {
|
|
13
|
+
fileType: string;
|
|
14
|
+
url: string;
|
|
15
|
+
options: {
|
|
16
|
+
cells: {
|
|
17
|
+
xy: string;
|
|
18
|
+
};
|
|
19
|
+
cellSets: {
|
|
20
|
+
groupName: string;
|
|
21
|
+
setName: string;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
}[];
|
|
25
|
+
name: string;
|
|
26
|
+
uid: string;
|
|
27
|
+
}[];
|
|
28
|
+
const layout: never[];
|
|
29
|
+
}
|
|
30
|
+
export namespace convenienceFileDefsExpanded {
|
|
31
|
+
const version_1: string;
|
|
32
|
+
export { version_1 as version };
|
|
33
|
+
const name_1: string;
|
|
34
|
+
export { name_1 as name };
|
|
35
|
+
const description_1: string;
|
|
36
|
+
export { description_1 as description };
|
|
37
|
+
const initStrategy_1: string;
|
|
38
|
+
export { initStrategy_1 as initStrategy };
|
|
39
|
+
const datasets_1: {
|
|
40
|
+
files: ({
|
|
41
|
+
fileType: string;
|
|
42
|
+
url: string;
|
|
43
|
+
options: {
|
|
44
|
+
xy: string;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
fileType: string;
|
|
48
|
+
url: string;
|
|
49
|
+
options: {
|
|
50
|
+
groupName: string;
|
|
51
|
+
setName: string;
|
|
52
|
+
}[];
|
|
53
|
+
})[];
|
|
54
|
+
name: string;
|
|
55
|
+
uid: string;
|
|
56
|
+
}[];
|
|
57
|
+
export { datasets_1 as datasets };
|
|
58
|
+
const layout_1: never[];
|
|
59
|
+
export { layout_1 as layout };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=plugins.test.fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.test.fixtures.d.ts","sourceRoot":"","sources":["../src/plugins.test.fixtures.js"],"names":[],"mappings":"AA+BA;;;;IAaC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export const convenienceFileDefsCollapsed = {
|
|
2
|
+
version: '1.0.15',
|
|
3
|
+
name: 'My config name',
|
|
4
|
+
description: 'My config description',
|
|
5
|
+
initStrategy: 'auto',
|
|
6
|
+
datasets: [
|
|
7
|
+
{
|
|
8
|
+
files: [
|
|
9
|
+
{
|
|
10
|
+
fileType: 'anndata.convenience.zarr',
|
|
11
|
+
url: 'http://localhost:8000/my_anndata.zarr',
|
|
12
|
+
options: {
|
|
13
|
+
cells: {
|
|
14
|
+
xy: 'obsm/centroids',
|
|
15
|
+
},
|
|
16
|
+
cellSets: [
|
|
17
|
+
{
|
|
18
|
+
groupName: 'Leiden',
|
|
19
|
+
setName: 'obs/leiden',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
name: 'A',
|
|
26
|
+
uid: 'A',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
layout: [],
|
|
30
|
+
};
|
|
31
|
+
export function pluginExpandAnnDataConvenience(fileDef) {
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
fileType: 'anndata-cells.zarr',
|
|
35
|
+
url: fileDef.url,
|
|
36
|
+
options: fileDef.options.cells,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
fileType: 'anndata-cell-sets.zarr',
|
|
40
|
+
url: fileDef.url,
|
|
41
|
+
options: fileDef.options.cellSets,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
export const convenienceFileDefsExpanded = {
|
|
46
|
+
version: '1.0.15',
|
|
47
|
+
name: 'My config name',
|
|
48
|
+
description: 'My config description',
|
|
49
|
+
initStrategy: 'auto',
|
|
50
|
+
datasets: [
|
|
51
|
+
{
|
|
52
|
+
files: [
|
|
53
|
+
{
|
|
54
|
+
fileType: 'anndata-cells.zarr',
|
|
55
|
+
url: 'http://localhost:8000/my_anndata.zarr',
|
|
56
|
+
options: {
|
|
57
|
+
xy: 'obsm/centroids',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
fileType: 'anndata-cell-sets.zarr',
|
|
62
|
+
url: 'http://localhost:8000/my_anndata.zarr',
|
|
63
|
+
options: [
|
|
64
|
+
{
|
|
65
|
+
groupName: 'Leiden',
|
|
66
|
+
setName: 'obs/leiden',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
name: 'A',
|
|
72
|
+
uid: 'A',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
layout: [],
|
|
76
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/shared-mui/components.js"],"names":[],"mappings":"AAwBA,oDAwDC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import { makeStyles, Paper, Popper, IconButton, MenuList, ClickAwayListener, Fade, } from '@material-ui/core';
|
|
4
|
+
import { useVitessceContainer } from '../hooks.js';
|
|
5
|
+
const useStyles = makeStyles(() => ({
|
|
6
|
+
paper: {
|
|
7
|
+
maxHeight: 200,
|
|
8
|
+
overflow: 'auto',
|
|
9
|
+
},
|
|
10
|
+
container: {
|
|
11
|
+
position: 'relative',
|
|
12
|
+
left: 0,
|
|
13
|
+
top: 0,
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
export function PopperMenu(props) {
|
|
17
|
+
const { buttonIcon, open, setOpen, children, buttonClassName, placement = 'bottom-end', } = props;
|
|
18
|
+
const classes = useStyles();
|
|
19
|
+
const anchorRef = useRef();
|
|
20
|
+
const handleClick = () => {
|
|
21
|
+
setOpen(prev => !prev);
|
|
22
|
+
};
|
|
23
|
+
const handleClose = () => {
|
|
24
|
+
setOpen(false);
|
|
25
|
+
};
|
|
26
|
+
const id = open ? 'v-popover-menu' : undefined;
|
|
27
|
+
const getTooltipContainer = useVitessceContainer(anchorRef);
|
|
28
|
+
return (_jsxs("div", { ref: anchorRef, className: classes.container, children: [_jsx(IconButton, { "aria-describedby": id, onClick: handleClick, size: "small", className: buttonClassName, children: buttonIcon }), _jsx(Popper, { id: id, open: open, anchorEl: anchorRef && anchorRef.current, container: getTooltipContainer, onClose: handleClose, placement: placement, transition: true, children: ({ TransitionProps }) => (_jsx(ClickAwayListener, { onClickAway: handleClose, children: _jsx(Fade, { ...TransitionProps, timeout: 100, children: _jsx(Paper, { elevation: 4, className: classes.paper, children: _jsx(MenuList, { children: children }) }) }) })) })] }));
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/shared-mui/container.js"],"names":[],"mappings":"AAEA,0IAiNI"}
|