@vitessce/vit-s 2.0.3 → 3.0.0
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 +41348 -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 +45 -0
- package/dist-tsc/VitS.d.ts.map +1 -0
- package/dist-tsc/VitS.js +119 -0
- package/dist-tsc/VitessceGrid.d.ts +23 -0
- package/dist-tsc/VitessceGrid.d.ts.map +1 -0
- package/dist-tsc/VitessceGrid.js +60 -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 +40 -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 +7 -0
- package/dist-tsc/data/LoaderResult.d.ts.map +1 -0
- package/dist-tsc/data/LoaderResult.js +7 -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 +69 -0
- package/dist-tsc/data-hook-utils.d.ts.map +1 -0
- package/dist-tsc/data-hook-utils.js +173 -0
- package/dist-tsc/data-hooks.d.ts +77 -0
- package/dist-tsc/data-hooks.d.ts.map +1 -0
- package/dist-tsc/data-hooks.js +241 -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 +80 -0
- package/dist-tsc/hooks.d.ts.map +1 -0
- package/dist-tsc/hooks.js +271 -0
- package/dist-tsc/index.d.ts +11 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +10 -17
- 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/schemas/config-0.1.0.schema.json +84 -0
- package/dist-tsc/schemas/config-1.0.0.schema.json +733 -0
- package/dist-tsc/schemas/config-1.0.1.schema.json +909 -0
- package/dist-tsc/schemas/config-1.0.10.schema.json +969 -0
- package/dist-tsc/schemas/config-1.0.11.schema.json +990 -0
- package/dist-tsc/schemas/config-1.0.12.schema.json +997 -0
- package/dist-tsc/schemas/config-1.0.13.schema.json +1013 -0
- package/dist-tsc/schemas/config-1.0.14.schema.json +1048 -0
- package/dist-tsc/schemas/config-1.0.15.schema.json +1048 -0
- package/dist-tsc/schemas/config-1.0.16.schema.json +1089 -0
- package/dist-tsc/schemas/config-1.0.2.schema.json +910 -0
- package/dist-tsc/schemas/config-1.0.3.schema.json +910 -0
- package/dist-tsc/schemas/config-1.0.4.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.5.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.6.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.7.schema.json +949 -0
- package/dist-tsc/schemas/config-1.0.8.schema.json +965 -0
- package/dist-tsc/schemas/config-1.0.9.schema.json +965 -0
- package/dist-tsc/schemas/obsSets.schema.d.ts +179 -0
- package/dist-tsc/schemas/obsSets.schema.d.ts.map +1 -0
- package/dist-tsc/schemas/obsSets.schema.js +195 -0
- package/dist-tsc/schemas/obsSetsTabular.schema.d.ts +57 -0
- package/dist-tsc/schemas/obsSetsTabular.schema.d.ts.map +1 -0
- package/dist-tsc/schemas/obsSetsTabular.schema.js +38 -0
- package/dist-tsc/schemas/raster.schema.d.ts +239 -0
- package/dist-tsc/schemas/raster.schema.d.ts.map +1 -0
- package/dist-tsc/schemas/raster.schema.js +120 -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 +216 -0
- package/dist-tsc/state/hooks.d.ts.map +1 -0
- package/dist-tsc/state/hooks.js +575 -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 +30 -0
- package/dist-tsc/view-config-utils.d.ts.map +1 -0
- package/dist-tsc/view-config-utils.js +234 -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 +209 -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 +148 -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 +23 -10
- package/src/CallbackPublisher.js +7 -11
- package/src/LoadingIndicator.js +1 -2
- package/src/TitleInfo.js +12 -85
- package/src/VitS.js +72 -50
- package/src/VitessceGrid.js +21 -13
- package/src/VitessceGrid.test.jsx +16 -7
- package/src/Warning.js +2 -2
- package/src/data/AbstractLoader.js +2 -25
- package/src/data/AbstractTwoStepLoader.js +1 -1
- package/src/data/index.js +3 -3
- package/src/data/loader-registry.js +22 -13
- package/src/data-hook-utils.js +4 -6
- package/src/data-hooks.js +4 -4
- package/src/errors/DataSourceFetchError.js +1 -1
- 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 +70 -5
- package/src/index.js +21 -46
- package/src/schemas/config-1.0.16.schema.json +21 -1
- 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 +2 -2
- 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 +1 -1
- package/src/state/hooks.js +10 -3
- package/src/title-styles.js +73 -0
- package/src/view-config-utils.js +46 -98
- package/src/view-config-utils.test.jsx +222 -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 +1 -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-1.0.16.schema.test.js +0 -32
- 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
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import '@testing-library/jest-dom';
|
|
2
|
-
import { cleanup, render, screen } from '@testing-library/react'
|
|
3
|
-
import { afterEach } from 'vitest'
|
|
2
|
+
import { cleanup, render, screen } from '@testing-library/react';
|
|
3
|
+
import { afterEach } from 'vitest';
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { PluginViewType } from '@vitessce/plugins';
|
|
7
|
+
import VitessceGrid from './VitessceGrid.js';
|
|
6
8
|
import {
|
|
7
9
|
ViewConfigProvider, createViewConfigStore,
|
|
8
10
|
AuxiliaryProvider, createAuxiliaryStore,
|
|
9
|
-
} from './state/hooks';
|
|
11
|
+
} from './state/hooks.js';
|
|
10
12
|
|
|
11
13
|
afterEach(() => {
|
|
12
|
-
cleanup()
|
|
14
|
+
cleanup();
|
|
13
15
|
});
|
|
14
16
|
|
|
15
17
|
describe('VitessceGrid.js', () => {
|
|
@@ -34,11 +36,18 @@ describe('VitessceGrid.js', () => {
|
|
|
34
36
|
function FakeComponent() {
|
|
35
37
|
return <p>FakeComponent!</p>;
|
|
36
38
|
}
|
|
37
|
-
const
|
|
39
|
+
const viewTypes = [new PluginViewType('FakeComponent', FakeComponent, [])];
|
|
40
|
+
const fileTypes = [];
|
|
41
|
+
const coordinationTypes = [];
|
|
38
42
|
render(
|
|
39
43
|
<ViewConfigProvider createStore={createViewConfigStore}>
|
|
40
44
|
<AuxiliaryProvider createStore={createAuxiliaryStore}>
|
|
41
|
-
<VitessceGrid
|
|
45
|
+
<VitessceGrid
|
|
46
|
+
config={config}
|
|
47
|
+
viewTypes={viewTypes}
|
|
48
|
+
fileTypes={fileTypes}
|
|
49
|
+
coordinationTypes={coordinationTypes}
|
|
50
|
+
/>
|
|
42
51
|
</AuxiliaryProvider>
|
|
43
52
|
</ViewConfigProvider>,
|
|
44
53
|
);
|
package/src/Warning.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import { makeStyles } from '@material-ui/core
|
|
3
|
-
import { VITESSCE_CONTAINER } from './classNames';
|
|
2
|
+
import { makeStyles } from '@material-ui/core';
|
|
3
|
+
import { VITESSCE_CONTAINER } from './classNames.js';
|
|
4
4
|
|
|
5
5
|
const useStyles = makeStyles(theme => ({
|
|
6
6
|
warningLayout: {
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import Ajv from 'ajv';
|
|
2
|
-
import { OptionsValidationError } from '../errors/index';
|
|
3
|
-
import { emptySchema } from '../file-options-schemas';
|
|
4
|
-
|
|
5
1
|
/**
|
|
6
2
|
* A loader ancestor class containing a default constructor
|
|
7
3
|
* and a stub for the required load() method.
|
|
@@ -18,29 +14,10 @@ export default class AbstractLoader {
|
|
|
18
14
|
this.requestInit = requestInit;
|
|
19
15
|
this.options = options;
|
|
20
16
|
this.coordinationValues = coordinationValues;
|
|
21
|
-
this.optionsSchema = emptySchema;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
validateOptions() {
|
|
25
|
-
const { optionsSchema, options } = this;
|
|
26
|
-
const validate = new Ajv().compile(optionsSchema);
|
|
27
|
-
const valid = validate(options || null);
|
|
28
|
-
if (!valid) {
|
|
29
|
-
return [false, validate.errors];
|
|
30
|
-
}
|
|
31
|
-
return [true, null];
|
|
32
17
|
}
|
|
33
18
|
|
|
19
|
+
// eslint-disable-next-line class-methods-use-this
|
|
34
20
|
load() {
|
|
35
|
-
|
|
36
|
-
fileType, url, options,
|
|
37
|
-
} = this;
|
|
38
|
-
const [optionsAreValid, optionsFailureReason] = this.validateOptions();
|
|
39
|
-
if (!optionsAreValid) {
|
|
40
|
-
return Promise.reject(
|
|
41
|
-
new OptionsValidationError(fileType, url, options, optionsFailureReason),
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return Promise.resolve(optionsAreValid);
|
|
21
|
+
return Promise.resolve(true);
|
|
45
22
|
}
|
|
46
23
|
}
|
package/src/data/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as AbstractLoader } from './AbstractLoader';
|
|
2
|
-
export { default as AbstractTwoStepLoader } from './AbstractTwoStepLoader';
|
|
3
|
-
export { default as LoaderResult } from './LoaderResult';
|
|
1
|
+
export { default as AbstractLoader } from './AbstractLoader.js';
|
|
2
|
+
export { default as AbstractTwoStepLoader } from './AbstractTwoStepLoader.js';
|
|
3
|
+
export { default as LoaderResult } from './LoaderResult.js';
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export function getSourceAndLoaderFromFileType(type) {
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return pluginFileType;
|
|
1
|
+
/**
|
|
2
|
+
* Get the data source and data loader class.
|
|
3
|
+
* @param {string} type The fileType name.
|
|
4
|
+
* @param {PluginFileType[]} fileTypes The array of file types.
|
|
5
|
+
* @returns {array} [dataSourceClass, dataLoaderClass].
|
|
6
|
+
*/
|
|
7
|
+
export function getSourceAndLoaderFromFileType(type, fileTypes) {
|
|
8
|
+
if (Array.isArray(fileTypes)) {
|
|
9
|
+
const matchingFileType = fileTypes.find(ft => ft.name === type);
|
|
10
|
+
if (matchingFileType) {
|
|
11
|
+
return matchingFileType.getSourceAndLoader();
|
|
12
|
+
}
|
|
14
13
|
}
|
|
15
14
|
// Fallback to JSON.
|
|
16
15
|
// TODO(monorepo)
|
|
17
16
|
// return [JsonSource, JsonLoader];
|
|
18
17
|
return [null, null];
|
|
19
18
|
}
|
|
19
|
+
|
|
20
|
+
export function getDataTypeFromFileType(type, fileTypes) {
|
|
21
|
+
if (Array.isArray(fileTypes)) {
|
|
22
|
+
const matchingFileType = fileTypes.find(ft => ft.name === type);
|
|
23
|
+
if (matchingFileType) {
|
|
24
|
+
return matchingFileType.dataType;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
package/src/data-hook-utils.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
-
import equal from 'fast-deep-equal';
|
|
3
2
|
import { capitalize } from '@vitessce/utils';
|
|
4
3
|
import { STATUS } from '@vitessce/constants-internal';
|
|
5
|
-
import { useMatchingLoader, useMatchingLoaders, useSetWarning } from './state/hooks';
|
|
4
|
+
import { useMatchingLoader, useMatchingLoaders, useSetWarning } from './state/hooks.js';
|
|
6
5
|
import {
|
|
7
6
|
AbstractLoaderError,
|
|
8
7
|
LoaderNotFoundError,
|
|
9
|
-
} from './errors/index';
|
|
10
|
-
import { getDefaultCoordinationValues } from './plugins';
|
|
8
|
+
} from './errors/index.js';
|
|
11
9
|
|
|
12
10
|
/**
|
|
13
11
|
* Warn via publishing to the console
|
|
@@ -38,12 +36,12 @@ export function initCoordinationSpace(values, setters, initialValues) {
|
|
|
38
36
|
if (!values || !setters) {
|
|
39
37
|
return;
|
|
40
38
|
}
|
|
41
|
-
const defaultCoordinationValues = getDefaultCoordinationValues();
|
|
42
39
|
Object.entries(values).forEach(([coordinationType, value]) => {
|
|
43
40
|
const setterName = `set${capitalize(coordinationType)}`;
|
|
44
41
|
const setterFunc = setters[setterName];
|
|
45
42
|
const initialValue = initialValues && initialValues[coordinationType];
|
|
46
|
-
|
|
43
|
+
// Interpret null as "uninitialized" and therefore needing initialization.
|
|
44
|
+
const shouldInit = initialValue === null;
|
|
47
45
|
if (shouldInit && setterFunc) {
|
|
48
46
|
setterFunc(value);
|
|
49
47
|
}
|
package/src/data-hooks.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { useState, useEffect, useMemo } from 'react';
|
|
2
2
|
import { CoordinationType, DataType, STATUS } from '@vitessce/constants-internal';
|
|
3
3
|
import { fromEntries } from '@vitessce/utils';
|
|
4
|
-
import { useMatchingLoader, useMultiCoordinationValues, useSetWarning } from './state/hooks';
|
|
4
|
+
import { useMatchingLoader, useMultiCoordinationValues, useSetWarning } from './state/hooks.js';
|
|
5
5
|
import {
|
|
6
6
|
LoaderNotFoundError,
|
|
7
|
-
} from './errors/index';
|
|
7
|
+
} from './errors/index.js';
|
|
8
8
|
import {
|
|
9
9
|
warn,
|
|
10
10
|
useDataType,
|
|
11
11
|
useDataTypeMulti,
|
|
12
|
-
} from './data-hook-utils';
|
|
12
|
+
} from './data-hook-utils.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Get the dataset description string.
|
|
@@ -232,7 +232,7 @@ export function useFeatureSelection(
|
|
|
232
232
|
const geneIndex = featureIndex.indexOf(sel);
|
|
233
233
|
const numGenes = featureIndex.length;
|
|
234
234
|
const numCells = obsIndex.length;
|
|
235
|
-
const expressionData = new
|
|
235
|
+
const expressionData = new Float32Array(numCells);
|
|
236
236
|
for (let cellIndex = 0; cellIndex < numCells; cellIndex += 1) {
|
|
237
237
|
expressionData[cellIndex] = obsFeatureMatrix.data[cellIndex * numGenes + geneIndex];
|
|
238
238
|
}
|
package/src/errors/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export { default as AbstractLoaderError } from './AbstractLoaderError';
|
|
2
|
-
export { default as LoaderValidationError } from './LoaderValidationError';
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export { default as DataSourceFetchError } from './DataSourceFetchError';
|
|
1
|
+
export { default as AbstractLoaderError } from './AbstractLoaderError.js';
|
|
2
|
+
export { default as LoaderValidationError } from './LoaderValidationError.js';
|
|
3
|
+
export { default as LoaderNotFoundError } from './LoaderNotFoundError.js';
|
|
4
|
+
export { default as DatasetNotFoundError } from './DatasetNotFoundError.js';
|
|
5
|
+
export { default as DataSourceFetchError } from './DataSourceFetchError.js';
|
package/src/hooks.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useRef, useState, useEffect, useCallback, useMemo,
|
|
3
3
|
} from 'react';
|
|
4
|
-
import debounce from 'lodash
|
|
5
|
-
import
|
|
4
|
+
import { debounce, every } from 'lodash-es';
|
|
5
|
+
import { extent } from 'd3-array';
|
|
6
6
|
import { capitalize, fromEntries } from '@vitessce/utils';
|
|
7
|
-
import { useGridResize, useEmitGridResize } from './state/hooks';
|
|
8
|
-
import { VITESSCE_CONTAINER } from './classNames';
|
|
7
|
+
import { useGridResize, useEmitGridResize } from './state/hooks.js';
|
|
8
|
+
import { VITESSCE_CONTAINER } from './classNames.js';
|
|
9
9
|
|
|
10
10
|
function getWindowDimensions() {
|
|
11
11
|
const { innerWidth: width, innerHeight: height } = window;
|
|
@@ -199,7 +199,63 @@ export function useClosestVitessceContainerSize(ref) {
|
|
|
199
199
|
return [width, height];
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Normalize an obsFeatureMatrix to a Uint8Array.
|
|
204
|
+
* @param {object} params
|
|
205
|
+
* @param {object} params.obsFeatureMatrix The obsFeatureMatrix
|
|
206
|
+
* returned by the useObsFeatureMatrix hook.
|
|
207
|
+
* @returns {array} A tuple [obsFeatureMatrix, dataExtent]
|
|
208
|
+
* where obsFeatureMatrix
|
|
209
|
+
* is a Uint8Array with the same shape as
|
|
210
|
+
* params.obsFeatureMatrix.data, and dataExtent is the
|
|
211
|
+
* [min, max] of the original data.
|
|
212
|
+
*/
|
|
213
|
+
export function useUint8ObsFeatureMatrix({ obsFeatureMatrix }) {
|
|
214
|
+
return useMemo(() => {
|
|
215
|
+
if (obsFeatureMatrix && obsFeatureMatrix.data) {
|
|
216
|
+
const dataExtent = extent(obsFeatureMatrix.data);
|
|
217
|
+
const [min, max] = dataExtent;
|
|
218
|
+
const ratio = 255 / (max - min);
|
|
219
|
+
const data = new Uint8Array(
|
|
220
|
+
obsFeatureMatrix.data.map(i => Math.floor((i - min) * ratio)),
|
|
221
|
+
);
|
|
222
|
+
return [{ data }, dataExtent];
|
|
223
|
+
}
|
|
224
|
+
return [null, null];
|
|
225
|
+
}, [obsFeatureMatrix]);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Normalize a feature selection (data for selected
|
|
230
|
+
* columns of an obsFeatureMatrix) to a Uint8Array.
|
|
231
|
+
* @param {array|null} expressionData The expressionData
|
|
232
|
+
* returned by the useFeatureSelection hook,
|
|
233
|
+
* where each element corresponds to an
|
|
234
|
+
* array of values for a selected feature.
|
|
235
|
+
* @returns {array} A tuple [normData, extents] where
|
|
236
|
+
* normData is an array of Uint8Arrays (or null), and extents is
|
|
237
|
+
* an array of [min, max] values for each feature (or null).
|
|
238
|
+
*/
|
|
239
|
+
export function useUint8FeatureSelection(expressionData) {
|
|
240
|
+
return useMemo(() => {
|
|
241
|
+
if (expressionData && expressionData[0]) {
|
|
242
|
+
const extents = expressionData.map(arr => extent(arr));
|
|
243
|
+
const normData = expressionData.map((arr, i) => {
|
|
244
|
+
const [min, max] = extents[i];
|
|
245
|
+
const ratio = 255 / (max - min);
|
|
246
|
+
return new Uint8Array(
|
|
247
|
+
arr.map(j => Math.floor((j - min) * ratio)),
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
return [normData, extents];
|
|
251
|
+
}
|
|
252
|
+
return [null, null];
|
|
253
|
+
}, [expressionData]);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function useExpressionValueGetter(
|
|
257
|
+
{ instanceObsIndex, matrixObsIndex, expressionData },
|
|
258
|
+
) {
|
|
203
259
|
// Get a mapping from cell ID to row index in the gene expression matrix.
|
|
204
260
|
// Since the two obsIndices (instanceObsIndex = the obsIndex from obsEmbedding)
|
|
205
261
|
// may be ordered differently (matrixObsIndex = the obsIndex from obsFeatureMatrix),
|
|
@@ -226,6 +282,15 @@ export function useExpressionValueGetter({ instanceObsIndex, matrixObsIndex, exp
|
|
|
226
282
|
return getExpressionValue;
|
|
227
283
|
}
|
|
228
284
|
|
|
285
|
+
export function useGetObsMembership(obsSetsMembership) {
|
|
286
|
+
return useCallback((obsId) => {
|
|
287
|
+
if (obsId) {
|
|
288
|
+
return obsSetsMembership?.get(obsId) || [];
|
|
289
|
+
}
|
|
290
|
+
return [];
|
|
291
|
+
}, [obsSetsMembership]);
|
|
292
|
+
}
|
|
293
|
+
|
|
229
294
|
export function useGetObsInfo(obsType, obsLabelsTypes, obsLabelsData, obsSetsMembership) {
|
|
230
295
|
return useCallback((obsId) => {
|
|
231
296
|
if (obsId) {
|
package/src/index.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
export { VitS } from './VitS';
|
|
2
|
-
export { TitleInfo } from './TitleInfo';
|
|
3
|
-
export { PopperMenu } from './shared-mui/components';
|
|
4
|
-
export {
|
|
5
|
-
registerPluginViewType,
|
|
6
|
-
registerPluginCoordinationType,
|
|
7
|
-
registerPluginFileType,
|
|
8
|
-
registerPluginJointFileType,
|
|
9
|
-
} from './plugins';
|
|
1
|
+
export { VitS } from './VitS.js';
|
|
2
|
+
export { TitleInfo } from './TitleInfo.js';
|
|
3
|
+
export { PopperMenu } from './shared-mui/components.js';
|
|
10
4
|
// For plugin view types:
|
|
11
5
|
export {
|
|
12
|
-
useReady,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
useReady,
|
|
7
|
+
useUrls,
|
|
8
|
+
useVitessceContainer,
|
|
9
|
+
useDeckCanvasSize,
|
|
10
|
+
useUint8ObsFeatureMatrix,
|
|
11
|
+
useUint8FeatureSelection,
|
|
12
|
+
useExpressionValueGetter,
|
|
13
|
+
useGetObsMembership,
|
|
14
|
+
useGetObsInfo,
|
|
15
|
+
useClosestVitessceContainerSize,
|
|
16
|
+
useWindowDimensions,
|
|
16
17
|
useGridItemSize,
|
|
17
|
-
} from './hooks';
|
|
18
|
+
} from './hooks.js';
|
|
18
19
|
export {
|
|
19
20
|
useCoordination,
|
|
20
21
|
useComplexCoordination,
|
|
@@ -33,7 +34,7 @@ export {
|
|
|
33
34
|
useSetWarning,
|
|
34
35
|
useAuxiliaryCoordination,
|
|
35
36
|
useComponentLayout,
|
|
36
|
-
} from './state/hooks';
|
|
37
|
+
} from './state/hooks.js';
|
|
37
38
|
export {
|
|
38
39
|
useDescription,
|
|
39
40
|
useImageData,
|
|
@@ -51,51 +52,25 @@ export {
|
|
|
51
52
|
useObsFeatureMatrixData,
|
|
52
53
|
useFeatureLabelsData,
|
|
53
54
|
useGenomicProfilesData,
|
|
54
|
-
} from './data-hooks';
|
|
55
|
+
} from './data-hooks.js';
|
|
55
56
|
export {
|
|
56
57
|
useHasLoader,
|
|
57
|
-
} from './data-hook-utils';
|
|
58
|
+
} from './data-hook-utils.js';
|
|
58
59
|
export {
|
|
59
60
|
AbstractLoader,
|
|
60
61
|
AbstractTwoStepLoader,
|
|
61
62
|
LoaderResult,
|
|
62
|
-
} from './data/index';
|
|
63
|
+
} from './data/index.js';
|
|
63
64
|
export {
|
|
64
65
|
AbstractLoaderError,
|
|
65
66
|
DatasetNotFoundError,
|
|
66
67
|
LoaderNotFoundError,
|
|
67
68
|
LoaderValidationError,
|
|
68
|
-
OptionsValidationError,
|
|
69
69
|
DataSourceFetchError,
|
|
70
|
-
} from './errors/index';
|
|
71
|
-
export {
|
|
72
|
-
// TODO(monorepo): should these be in here? or within file-types/
|
|
73
|
-
obsEmbeddingAnndataSchema,
|
|
74
|
-
obsLocationsAnndataSchema,
|
|
75
|
-
obsSegmentationsAnndataSchema,
|
|
76
|
-
obsSetsAnndataSchema,
|
|
77
|
-
obsFeatureMatrixAnndataSchema,
|
|
78
|
-
obsLabelsAnndataSchema,
|
|
79
|
-
featureLabelsAnndataSchema,
|
|
80
|
-
obsEmbeddingCsvSchema,
|
|
81
|
-
obsLocationsCsvSchema,
|
|
82
|
-
obsLabelsCsvSchema,
|
|
83
|
-
featureLabelsCsvSchema,
|
|
84
|
-
obsSetsCsvSchema,
|
|
85
|
-
anndataZarrSchema,
|
|
86
|
-
emptySchema,
|
|
87
|
-
} from './file-options-schemas';
|
|
88
|
-
export {
|
|
89
|
-
SCHEMA_HANDLERS,
|
|
90
|
-
LATEST_VERSION,
|
|
91
|
-
} from './view-config-versions';
|
|
92
|
-
export {
|
|
93
|
-
upgradeAndValidate,
|
|
94
|
-
} from './view-config-utils';
|
|
70
|
+
} from './errors/index.js';
|
|
95
71
|
export {
|
|
96
72
|
CellColorEncodingOption,
|
|
97
73
|
OptionsContainer,
|
|
98
74
|
OptionSelect,
|
|
99
75
|
usePlotOptionsStyles,
|
|
100
|
-
} from './shared-plot-options';
|
|
101
|
-
export * from './json-schemas';
|
|
76
|
+
} from './shared-plot-options/index.js';
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"obsFilter": { "$ref": "#/definitions/stringOrStringArray" },
|
|
60
60
|
"obsHighlight": { "$ref": "#/definitions/stringOrStringArray" },
|
|
61
61
|
"obsSetSelection": { "$ref": "#/definitions/stringOrStringArray" },
|
|
62
|
+
"obsSetExpansion": { "$ref": "#/definitions/stringOrStringArray" },
|
|
62
63
|
"obsSetHighlight": { "$ref": "#/definitions/stringOrStringArray" },
|
|
63
64
|
"obsSetColor": { "$ref": "#/definitions/stringOrStringArray" },
|
|
64
65
|
"featureFilter": { "$ref": "#/definitions/stringOrStringArray" },
|
|
@@ -80,7 +81,8 @@
|
|
|
80
81
|
"additionalObsSets": { "$ref": "#/definitions/stringOrStringArray" },
|
|
81
82
|
"moleculeHighlight": { "$ref": "#/definitions/stringOrStringArray" },
|
|
82
83
|
"gatingFeatureSelectionX": { "$ref": "#/definitions/stringOrStringArray" },
|
|
83
|
-
"gatingFeatureSelectionY": { "$ref": "#/definitions/stringOrStringArray" }
|
|
84
|
+
"gatingFeatureSelectionY": { "$ref": "#/definitions/stringOrStringArray" },
|
|
85
|
+
"tooltipsVisible": { "type": "boolean" }
|
|
84
86
|
}
|
|
85
87
|
},
|
|
86
88
|
"componentCoordinationScopesBy": {
|
|
@@ -845,6 +847,20 @@
|
|
|
845
847
|
}
|
|
846
848
|
}
|
|
847
849
|
},
|
|
850
|
+
"obsSetExpansion": {
|
|
851
|
+
"type": "object",
|
|
852
|
+
"patternProperties": {
|
|
853
|
+
".": {
|
|
854
|
+
"oneOf": [
|
|
855
|
+
{
|
|
856
|
+
"type": "null",
|
|
857
|
+
"description": "If null is provided and auto cell set initialization is enabled, cell set expansions will be automatically initialized."
|
|
858
|
+
},
|
|
859
|
+
{ "type": "array" }
|
|
860
|
+
]
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
},
|
|
848
864
|
"obsSetHighlight": {
|
|
849
865
|
"type": "object",
|
|
850
866
|
"patternProperties": {
|
|
@@ -1051,6 +1067,10 @@
|
|
|
1051
1067
|
]
|
|
1052
1068
|
}
|
|
1053
1069
|
}
|
|
1070
|
+
},
|
|
1071
|
+
"tooltipsVisible": {
|
|
1072
|
+
"type": "boolean",
|
|
1073
|
+
"default": true
|
|
1054
1074
|
}
|
|
1055
1075
|
}
|
|
1056
1076
|
},
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React, { useRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import {
|
|
3
|
+
makeStyles,
|
|
4
|
+
Paper,
|
|
5
|
+
Popper,
|
|
6
|
+
IconButton,
|
|
7
|
+
MenuList,
|
|
8
|
+
ClickAwayListener,
|
|
9
|
+
Fade,
|
|
10
|
+
} from '@material-ui/core';
|
|
11
|
+
import { useVitessceContainer } from '../hooks.js';
|
|
10
12
|
|
|
11
13
|
const useStyles = makeStyles(() => ({
|
|
12
14
|
paper: {
|
package/src/shared-mui/styles.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createTheme } from '@material-ui/core
|
|
2
|
-
|
|
1
|
+
import { createTheme, colors } from '@material-ui/core';
|
|
2
|
+
|
|
3
|
+
const { grey } = colors;
|
|
3
4
|
|
|
4
5
|
const globalColors = {
|
|
5
6
|
white: '#FFFFFF',
|
|
@@ -78,6 +79,7 @@ export const muiTheme = {
|
|
|
78
79
|
secondaryForeground: '#D3D3D3',
|
|
79
80
|
gridLayoutBackground: '#333333',
|
|
80
81
|
cardBorder: 'rgba(0, 0, 0, 0.125)',
|
|
82
|
+
tooltipText: '#FFFFFF',
|
|
81
83
|
...globalColors,
|
|
82
84
|
},
|
|
83
85
|
...sharedThemeOptions,
|
|
@@ -103,6 +105,7 @@ export const muiTheme = {
|
|
|
103
105
|
secondaryForeground: '#222222',
|
|
104
106
|
gridLayoutBackground: '#FFFFFF',
|
|
105
107
|
cardBorder: 'rgba(241, 241, 241, 0.125)',
|
|
108
|
+
tooltipText: 'rgba(0, 0, 0, 0.87)',
|
|
106
109
|
...globalColors,
|
|
107
110
|
},
|
|
108
111
|
...sharedThemeOptions,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import TableCell from '@material-ui/core
|
|
3
|
-
import TableRow from '@material-ui/core/TableRow';
|
|
2
|
+
import { TableCell, TableRow } from '@material-ui/core';
|
|
4
3
|
import { capitalize } from '@vitessce/utils';
|
|
5
|
-
import OptionSelect from './OptionSelect';
|
|
6
|
-
import { useStyles } from './styles';
|
|
4
|
+
import OptionSelect from './OptionSelect.js';
|
|
5
|
+
import { useStyles } from './styles.js';
|
|
7
6
|
|
|
8
7
|
export default function CellColorEncodingOption(props) {
|
|
9
8
|
const {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Select from '@material-ui/core
|
|
3
|
-
import { useStyles } from './styles';
|
|
2
|
+
import { Select } from '@material-ui/core';
|
|
3
|
+
import { useStyles } from './styles.js';
|
|
4
4
|
|
|
5
5
|
export default function OptionSelect(props) {
|
|
6
6
|
const { classes: classesProp = {} } = props;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Box from '@material-ui/core
|
|
3
|
-
import
|
|
4
|
-
import TableBody from '@material-ui/core/TableBody';
|
|
5
|
-
import TableContainer from '@material-ui/core/TableContainer';
|
|
6
|
-
import { useStyles } from './styles';
|
|
2
|
+
import { Box, Table, TableBody, TableContainer } from '@material-ui/core';
|
|
3
|
+
import { useStyles } from './styles.js';
|
|
7
4
|
|
|
8
5
|
export default function OptionsContainer(props) {
|
|
9
6
|
const {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as CellColorEncodingOption } from './CellColorEncodingOption';
|
|
2
|
-
export { default as OptionsContainer } from './OptionsContainer';
|
|
3
|
-
export { default as OptionSelect } from './OptionSelect';
|
|
4
|
-
export { useStyles as usePlotOptionsStyles } from './styles';
|
|
1
|
+
export { default as CellColorEncodingOption } from './CellColorEncodingOption.js';
|
|
2
|
+
export { default as OptionsContainer } from './OptionsContainer.js';
|
|
3
|
+
export { default as OptionSelect } from './OptionSelect.js';
|
|
4
|
+
export { useStyles as usePlotOptionsStyles } from './styles.js';
|
package/src/state/hooks.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
1
2
|
import { useRef, useCallback, useMemo } from 'react';
|
|
2
3
|
import create from 'zustand';
|
|
3
4
|
import createContext from 'zustand/context';
|
|
4
5
|
import shallow from 'zustand/shallow';
|
|
5
|
-
import isMatch from 'lodash
|
|
6
|
+
import { isMatch } from 'lodash-es';
|
|
6
7
|
import { CoordinationType } from '@vitessce/constants-internal';
|
|
7
8
|
import { fromEntries, capitalize } from '@vitessce/utils';
|
|
8
9
|
|
|
@@ -31,7 +32,10 @@ export const useAuxiliaryStore = useAuxiliaryStoreLocal;
|
|
|
31
32
|
* The useViewConfigStore hook is initialized via the zustand
|
|
32
33
|
* create() function, which sets up both the state variables
|
|
33
34
|
* and the reducer-type functions.
|
|
34
|
-
*
|
|
35
|
+
* References:
|
|
36
|
+
* - https://github.com/react-spring/zustand
|
|
37
|
+
* - https://github.com/pmndrs/zustand/releases/tag/v3.6.0
|
|
38
|
+
* - https://github.com/pmndrs/zustand#using-subscribe-with-selector
|
|
35
39
|
* @returns {function} The useStore hook.
|
|
36
40
|
*/
|
|
37
41
|
export const createViewConfigStore = () => create(set => ({
|
|
@@ -609,7 +613,10 @@ export function useComponentViewInfo(uuid) {
|
|
|
609
613
|
*/
|
|
610
614
|
export function useSetComponentViewInfo(uuid) {
|
|
611
615
|
const setViewInfoRef = useRef(useViewInfoStore.getState().setComponentViewInfo);
|
|
612
|
-
const setComponentViewInfo =
|
|
616
|
+
const setComponentViewInfo = useCallback(
|
|
617
|
+
viewInfo => setViewInfoRef.current(uuid, viewInfo),
|
|
618
|
+
[uuid],
|
|
619
|
+
);
|
|
613
620
|
return setComponentViewInfo;
|
|
614
621
|
}
|
|
615
622
|
|