@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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A loader ancestor class containing a default constructor
|
|
3
|
+
* and a stub for the required load() method.
|
|
4
|
+
*/
|
|
5
|
+
export default class AbstractLoader {
|
|
6
|
+
constructor({ type, fileType, url, requestInit, options, coordinationValues, }) {
|
|
7
|
+
this.fileType = fileType;
|
|
8
|
+
this.type = type;
|
|
9
|
+
this.url = url;
|
|
10
|
+
this.requestInit = requestInit;
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.coordinationValues = coordinationValues;
|
|
13
|
+
}
|
|
14
|
+
// eslint-disable-next-line class-methods-use-this
|
|
15
|
+
load() {
|
|
16
|
+
return Promise.resolve(true);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractTwoStepLoader.d.ts","sourceRoot":"","sources":["../../src/data/AbstractTwoStepLoader.js"],"names":[],"mappings":"AAEA;IACE,0CAGC;IADC,gBAA4B;CAE/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default class LoaderResult {
|
|
2
|
+
/**
|
|
3
|
+
* @param {*} data
|
|
4
|
+
* @param {object[]|string|null} url Single URL or array of { url, name } objects.
|
|
5
|
+
* @param {object} coordinationValues
|
|
6
|
+
*/
|
|
7
|
+
constructor(data: any, url: object[] | string | null, coordinationValues?: object);
|
|
8
|
+
data: any;
|
|
9
|
+
url: string | object[] | null;
|
|
10
|
+
coordinationValues: object;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=LoaderResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoaderResult.d.ts","sourceRoot":"","sources":["../../src/data/LoaderResult.js"],"names":[],"mappings":"AACA;IACE;;;;OAIG;IACH,4BAHW,MAAM,EAAE,GAAC,MAAM,GAAC,IAAI,uBACpB,MAAM,EAMhB;IAHC,UAAgB;IAChB,8BAAc;IACd,2BAA4C;CAE/C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default class LoaderResult {
|
|
2
|
+
/**
|
|
3
|
+
* @param {*} data
|
|
4
|
+
* @param {object[]|string|null} url Single URL or array of { url, name } objects.
|
|
5
|
+
* @param {object} coordinationValues
|
|
6
|
+
*/
|
|
7
|
+
constructor(data, url, coordinationValues = null) {
|
|
8
|
+
this.data = data;
|
|
9
|
+
this.url = url;
|
|
10
|
+
this.coordinationValues = coordinationValues;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
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: string, fileTypes: PluginFileType[]): array;
|
|
8
|
+
export function getDataTypeFromFileType(type: any, fileTypes: any): any;
|
|
9
|
+
//# sourceMappingURL=loader-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader-registry.d.ts","sourceRoot":"","sources":["../../src/data/loader-registry.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qDAJW,MAAM,aACN,gBAAgB,SAc1B;AAED,wEAQC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// Fallback to JSON.
|
|
15
|
+
// TODO(monorepo)
|
|
16
|
+
// return [JsonSource, JsonLoader];
|
|
17
|
+
return [null, null];
|
|
18
|
+
}
|
|
19
|
+
export function getDataTypeFromFileType(type, fileTypes) {
|
|
20
|
+
if (Array.isArray(fileTypes)) {
|
|
21
|
+
const matchingFileType = fileTypes.find(ft => ft.name === type);
|
|
22
|
+
if (matchingFileType) {
|
|
23
|
+
return matchingFileType.dataType;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Warn via publishing to the console
|
|
3
|
+
* and to the global warning store.
|
|
4
|
+
* @param {AbstractLoaderError} error An error instance.
|
|
5
|
+
*/
|
|
6
|
+
export function warn(error: AbstractLoaderError, setWarning: any): void;
|
|
7
|
+
/**
|
|
8
|
+
* Initialize values in the coordination space.
|
|
9
|
+
* @param {object} values Object where
|
|
10
|
+
* keys are coordination type names,
|
|
11
|
+
* values are initial coordination values.
|
|
12
|
+
* @param {object} setters Object where
|
|
13
|
+
* keys are coordination type names with the prefix 'set',
|
|
14
|
+
* values are coordination setter functions.
|
|
15
|
+
* @param {object} initialValues Object where
|
|
16
|
+
* keys are coordination type names and keys are values.
|
|
17
|
+
*/
|
|
18
|
+
export function initCoordinationSpace(values: object, setters: object, initialValues: object): void;
|
|
19
|
+
/**
|
|
20
|
+
* Get data from a cells data type loader,
|
|
21
|
+
* updating "ready" and URL state appropriately.
|
|
22
|
+
* Throw warnings if the data is marked as required.
|
|
23
|
+
* Subscribe to loader updates.
|
|
24
|
+
* @param {object} loaders The object mapping
|
|
25
|
+
* datasets and data types to loader instances.
|
|
26
|
+
* @param {string} dataset The key for a dataset,
|
|
27
|
+
* used to identify which loader to use.
|
|
28
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
29
|
+
* loading is unsuccessful?
|
|
30
|
+
* @param {object} coordinationSetters Object where
|
|
31
|
+
* keys are coordination type names with the prefix 'set',
|
|
32
|
+
* values are coordination setter functions.
|
|
33
|
+
* @param {object} initialCoordinationValues Object where
|
|
34
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
35
|
+
* values are initialization preferences as boolean values.
|
|
36
|
+
* @returns {array} [data, status, urls] where
|
|
37
|
+
* cells is an object and cellsCount is the
|
|
38
|
+
* number of items in the cells object.
|
|
39
|
+
*/
|
|
40
|
+
export function useDataType(dataType: any, loaders: object, dataset: string, isRequired: boolean, coordinationSetters: object, initialCoordinationValues: object, matchOn: any): array;
|
|
41
|
+
/**
|
|
42
|
+
* Get data from a cells data type loader,
|
|
43
|
+
* updating "ready" and URL state appropriately.
|
|
44
|
+
* Throw warnings if the data is marked as required.
|
|
45
|
+
* Subscribe to loader updates.
|
|
46
|
+
* @param {object} loaders The object mapping
|
|
47
|
+
* datasets and data types to loader instances.
|
|
48
|
+
* @param {string} dataset The key for a dataset,
|
|
49
|
+
* used to identify which loader to use.
|
|
50
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
51
|
+
* loading is unsuccessful?
|
|
52
|
+
* @param {object} coordinationSetters Object where
|
|
53
|
+
* keys are coordination type names with the prefix 'set',
|
|
54
|
+
* values are coordination setter functions.
|
|
55
|
+
* @param {object} initialCoordinationValues Object where
|
|
56
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
57
|
+
* values are initialization preferences as boolean values.
|
|
58
|
+
* @returns {array} [cells, cellsCount] where
|
|
59
|
+
* cells is an object and cellsCount is the
|
|
60
|
+
* number of items in the cells object.
|
|
61
|
+
*/
|
|
62
|
+
export function useDataTypeMulti(dataType: any, loaders: object, dataset: string, isRequired: boolean, coordinationSetters: object, initialCoordinationValues: object, matchOnObj: any): array;
|
|
63
|
+
export function useHasLoader(loaders: any, dataset: any, dataType: any, matchOn: any): boolean;
|
|
64
|
+
import { AbstractLoaderError } from "./errors/index.js";
|
|
65
|
+
//# sourceMappingURL=data-hook-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-hook-utils.d.ts","sourceRoot":"","sources":["../src/data-hook-utils.js"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,4BAFW,mBAAmB,yBAS7B;AAED;;;;;;;;;;GAUG;AACH,8CATW,MAAM,WAGN,MAAM,iBAGN,MAAM,QAiBhB;AA4BD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oDAhBW,MAAM,WAEN,MAAM,cAEN,OAAO,uBAEP,MAAM,6BAGN,MAAM,uBA+ChB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,yDAhBW,MAAM,WAEN,MAAM,cAEN,OAAO,uBAEP,MAAM,6BAGN,MAAM,0BAkEhB;AAED,+FAGC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { capitalize, fromEntries } from '@vitessce/utils';
|
|
3
|
+
import { STATUS } from '@vitessce/constants-internal';
|
|
4
|
+
import { useQuery, useQueries } from '@tanstack/react-query';
|
|
5
|
+
import { getMatchingLoader, useMatchingLoader, useSetWarning, } from './state/hooks.js';
|
|
6
|
+
import { AbstractLoaderError, LoaderNotFoundError, } from './errors/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Warn via publishing to the console
|
|
9
|
+
* and to the global warning store.
|
|
10
|
+
* @param {AbstractLoaderError} error An error instance.
|
|
11
|
+
*/
|
|
12
|
+
export function warn(error, setWarning) {
|
|
13
|
+
setWarning(error.message);
|
|
14
|
+
console.warn(error.message);
|
|
15
|
+
console.error(error.stack);
|
|
16
|
+
if (error instanceof AbstractLoaderError) {
|
|
17
|
+
error.warnInConsole();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Initialize values in the coordination space.
|
|
22
|
+
* @param {object} values Object where
|
|
23
|
+
* keys are coordination type names,
|
|
24
|
+
* values are initial coordination values.
|
|
25
|
+
* @param {object} setters Object where
|
|
26
|
+
* keys are coordination type names with the prefix 'set',
|
|
27
|
+
* values are coordination setter functions.
|
|
28
|
+
* @param {object} initialValues Object where
|
|
29
|
+
* keys are coordination type names and keys are values.
|
|
30
|
+
*/
|
|
31
|
+
export function initCoordinationSpace(values, setters, initialValues) {
|
|
32
|
+
if (!values || !setters) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
Object.entries(values).forEach(([coordinationType, value]) => {
|
|
36
|
+
const setterName = `set${capitalize(coordinationType)}`;
|
|
37
|
+
const setterFunc = setters[setterName];
|
|
38
|
+
const initialValue = initialValues && initialValues[coordinationType];
|
|
39
|
+
// Interpret null as "uninitialized" and therefore needing initialization.
|
|
40
|
+
const shouldInit = initialValue === null;
|
|
41
|
+
if (shouldInit && setterFunc) {
|
|
42
|
+
setterFunc(value);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async function dataQueryFn(ctx) {
|
|
47
|
+
const { placeholderObject, loaders } = ctx.meta;
|
|
48
|
+
// This ordering of the queryKey must match.
|
|
49
|
+
const [dataset, dataType, matchOn, isRequired] = ctx.queryKey;
|
|
50
|
+
const loader = getMatchingLoader(loaders, dataset, dataType, matchOn);
|
|
51
|
+
if (loader) {
|
|
52
|
+
// TODO: can cacheing logic be removed from all loaders?
|
|
53
|
+
const payload = await loader.load();
|
|
54
|
+
if (!payload)
|
|
55
|
+
return placeholderObject; // TODO: throw error instead?
|
|
56
|
+
const { data, url, coordinationValues } = payload;
|
|
57
|
+
// Status: success
|
|
58
|
+
// Array of objects like { url, name }.
|
|
59
|
+
const urls = Array.isArray(url) ? url : [{ url, name: dataType }];
|
|
60
|
+
return { data, coordinationValues, urls };
|
|
61
|
+
}
|
|
62
|
+
// No loader was found.
|
|
63
|
+
if (isRequired) {
|
|
64
|
+
// Status: error
|
|
65
|
+
throw new LoaderNotFoundError(loaders, dataset, dataType, matchOn);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// Status: success
|
|
69
|
+
return { data: placeholderObject };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get data from a cells data type loader,
|
|
74
|
+
* updating "ready" and URL state appropriately.
|
|
75
|
+
* Throw warnings if the data is marked as required.
|
|
76
|
+
* Subscribe to loader updates.
|
|
77
|
+
* @param {object} loaders The object mapping
|
|
78
|
+
* datasets and data types to loader instances.
|
|
79
|
+
* @param {string} dataset The key for a dataset,
|
|
80
|
+
* used to identify which loader to use.
|
|
81
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
82
|
+
* loading is unsuccessful?
|
|
83
|
+
* @param {object} coordinationSetters Object where
|
|
84
|
+
* keys are coordination type names with the prefix 'set',
|
|
85
|
+
* values are coordination setter functions.
|
|
86
|
+
* @param {object} initialCoordinationValues Object where
|
|
87
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
88
|
+
* values are initialization preferences as boolean values.
|
|
89
|
+
* @returns {array} [data, status, urls] where
|
|
90
|
+
* cells is an object and cellsCount is the
|
|
91
|
+
* number of items in the cells object.
|
|
92
|
+
*/
|
|
93
|
+
export function useDataType(dataType, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
|
|
94
|
+
const setWarning = useSetWarning();
|
|
95
|
+
const placeholderObject = useMemo(() => ({}), []);
|
|
96
|
+
const dataQuery = useQuery({
|
|
97
|
+
// TODO: only enable when loaders has been initialized?
|
|
98
|
+
structuralSharing: false,
|
|
99
|
+
placeholderData: placeholderObject,
|
|
100
|
+
// Include the hook name in the queryKey to prevent the case in which an identical queryKey
|
|
101
|
+
// in a different hook would cause an accidental cache hit.
|
|
102
|
+
queryKey: [dataset, dataType, matchOn, isRequired, 'useDataType'],
|
|
103
|
+
// Query function should return an object
|
|
104
|
+
// { data, dataKey } where dataKey is the loaded gene selection.
|
|
105
|
+
queryFn: dataQueryFn,
|
|
106
|
+
meta: { loaders, placeholderObject },
|
|
107
|
+
});
|
|
108
|
+
const { data, status, isFetching, error } = dataQuery;
|
|
109
|
+
const loadedData = data?.data || placeholderObject;
|
|
110
|
+
const coordinationValues = data?.coordinationValues;
|
|
111
|
+
const urls = data?.urls;
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
initCoordinationSpace(coordinationValues, coordinationSetters, initialCoordinationValues);
|
|
114
|
+
}, [coordinationValues]);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
if (error) {
|
|
117
|
+
warn(error, setWarning);
|
|
118
|
+
}
|
|
119
|
+
}, [error, setWarning]);
|
|
120
|
+
const dataStatus = isFetching ? STATUS.LOADING : status;
|
|
121
|
+
return [loadedData, dataStatus, urls];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get data from a cells data type loader,
|
|
125
|
+
* updating "ready" and URL state appropriately.
|
|
126
|
+
* Throw warnings if the data is marked as required.
|
|
127
|
+
* Subscribe to loader updates.
|
|
128
|
+
* @param {object} loaders The object mapping
|
|
129
|
+
* datasets and data types to loader instances.
|
|
130
|
+
* @param {string} dataset The key for a dataset,
|
|
131
|
+
* used to identify which loader to use.
|
|
132
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
133
|
+
* loading is unsuccessful?
|
|
134
|
+
* @param {object} coordinationSetters Object where
|
|
135
|
+
* keys are coordination type names with the prefix 'set',
|
|
136
|
+
* values are coordination setter functions.
|
|
137
|
+
* @param {object} initialCoordinationValues Object where
|
|
138
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
139
|
+
* values are initialization preferences as boolean values.
|
|
140
|
+
* @returns {array} [cells, cellsCount] where
|
|
141
|
+
* cells is an object and cellsCount is the
|
|
142
|
+
* number of items in the cells object.
|
|
143
|
+
*/
|
|
144
|
+
export function useDataTypeMulti(dataType, loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOnObj) {
|
|
145
|
+
const placeholderObject = useMemo(() => ({}), []);
|
|
146
|
+
const setWarning = useSetWarning();
|
|
147
|
+
const matchOnEntries = matchOnObj ? Object.entries(matchOnObj) : [];
|
|
148
|
+
const dataQueries = useQueries({
|
|
149
|
+
// eslint-disable-next-line no-unused-vars
|
|
150
|
+
queries: matchOnEntries.map(([scopeKey, matchOn]) => ({
|
|
151
|
+
structuralSharing: false,
|
|
152
|
+
placeholderData: placeholderObject,
|
|
153
|
+
// Query key should match useDataType for shared cacheing
|
|
154
|
+
// and correctness of dataQueryFn.
|
|
155
|
+
queryKey: [dataset, dataType, matchOn, isRequired, 'useDataType'],
|
|
156
|
+
// Query function should return an object
|
|
157
|
+
// { data, dataKey } where dataKey is the loaded gene selection.
|
|
158
|
+
queryFn: dataQueryFn,
|
|
159
|
+
meta: { loaders, placeholderObject },
|
|
160
|
+
})),
|
|
161
|
+
});
|
|
162
|
+
const anyLoading = dataQueries.some(q => q.isFetching);
|
|
163
|
+
const anyError = dataQueries.some(q => q.isError);
|
|
164
|
+
// eslint-disable-next-line no-nested-ternary
|
|
165
|
+
const dataStatus = anyLoading ? STATUS.LOADING : (anyError ? STATUS.ERROR : STATUS.SUCCESS);
|
|
166
|
+
const isSuccess = dataStatus === STATUS.SUCCESS;
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
dataQueries
|
|
169
|
+
.map(q => q.data?.coordinationValues)
|
|
170
|
+
.filter(v => Boolean(v))
|
|
171
|
+
.forEach((coordinationValues) => {
|
|
172
|
+
initCoordinationSpace(coordinationValues, coordinationSetters, initialCoordinationValues);
|
|
173
|
+
});
|
|
174
|
+
// Deliberate dependency omissions: use indirect dependencies for efficiency.
|
|
175
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
176
|
+
}, [isSuccess]);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
dataQueries.map(q => q.error).filter(e => Boolean(e)).forEach((error) => {
|
|
179
|
+
warn(error, setWarning);
|
|
180
|
+
});
|
|
181
|
+
// Deliberate dependency omissions: use indirect dependencies for efficiency.
|
|
182
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
183
|
+
}, [anyError, setWarning]);
|
|
184
|
+
// Convert data to object keyed by scopeKey.
|
|
185
|
+
const data = useMemo(() => fromEntries(matchOnEntries.map(([scopeKey], i) => ([scopeKey, dataQueries[i].data?.data]))), [dataQueries]);
|
|
186
|
+
return [data, dataStatus];
|
|
187
|
+
}
|
|
188
|
+
export function useHasLoader(loaders, dataset, dataType, matchOn) {
|
|
189
|
+
const loader = useMatchingLoader(loaders, dataset, dataType, matchOn);
|
|
190
|
+
return loader !== null;
|
|
191
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the dataset description string.
|
|
3
|
+
* @param {object} loaders The object mapping
|
|
4
|
+
* datasets and data types to loader instances.
|
|
5
|
+
* @param {string} dataset The key for a dataset,
|
|
6
|
+
* used to identify which loader to use.
|
|
7
|
+
* @returns {array} [description] where
|
|
8
|
+
* description is a string.
|
|
9
|
+
*/
|
|
10
|
+
export function useDescription(loaders: object, dataset: string): array;
|
|
11
|
+
/**
|
|
12
|
+
* Get data from a cells data type loader,
|
|
13
|
+
* updating "ready" and URL state appropriately.
|
|
14
|
+
* Throw warnings if the data is marked as required.
|
|
15
|
+
* Subscribe to loader updates.
|
|
16
|
+
* @param {object} loaders The object mapping
|
|
17
|
+
* datasets and data types to loader instances.
|
|
18
|
+
* @param {string} dataset The key for a dataset,
|
|
19
|
+
* used to identify which loader to use.
|
|
20
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
21
|
+
* loading is unsuccessful?
|
|
22
|
+
* @param {object} coordinationSetters Object where
|
|
23
|
+
* keys are coordination type names with the prefix 'set',
|
|
24
|
+
* values are coordination setter functions.
|
|
25
|
+
* @param {object} initialCoordinationValues Object where
|
|
26
|
+
* keys are coordination type names with the prefix 'initialize',
|
|
27
|
+
* values are initialization preferences as boolean values.
|
|
28
|
+
* @returns {array} [cells, cellsCount] where
|
|
29
|
+
* cells is an object and cellsCount is the
|
|
30
|
+
* number of items in the cells object.
|
|
31
|
+
*/
|
|
32
|
+
export function useObsEmbeddingData(loaders: object, dataset: string, isRequired: boolean, coordinationSetters: object, initialCoordinationValues: object, matchOn: any): array;
|
|
33
|
+
export function useObsLocationsData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
34
|
+
export function useObsLabelsData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
35
|
+
export function useObsSegmentationsData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
36
|
+
export function useObsSetsData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
37
|
+
export function useObsFeatureMatrixData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
38
|
+
export function useFeatureLabelsData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
39
|
+
export function useImageData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
40
|
+
export function useGenomicProfilesData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
41
|
+
export function useNeighborhoodsData(loaders: any, dataset: any, isRequired: any, coordinationSetters: any, initialCoordinationValues: any, matchOn: any): array;
|
|
42
|
+
/**
|
|
43
|
+
* Get data from the expression matrix data type loader for a given gene selection.
|
|
44
|
+
* Throw warnings if the data is marked as required.
|
|
45
|
+
* Subscribe to loader updates.
|
|
46
|
+
* @param {object} loaders The object mapping
|
|
47
|
+
* datasets and data types to loader instances.
|
|
48
|
+
* @param {string} dataset The key for a dataset,
|
|
49
|
+
* used to identify which loader to use.
|
|
50
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
51
|
+
* loading is unsuccessful?
|
|
52
|
+
* @param {boolean} selection A list of gene names to get expression data for.
|
|
53
|
+
* @returns {array} [geneData] where geneData is an array [Uint8Array, ..., Uint8Array]
|
|
54
|
+
* for however many genes are in the selection.
|
|
55
|
+
*/
|
|
56
|
+
export function useFeatureSelection(loaders: object, dataset: string, isRequired: boolean, selection: boolean, matchOn: any): array;
|
|
57
|
+
/**
|
|
58
|
+
* Get the attributes for the expression matrix data type loader,
|
|
59
|
+
* i.e names of cells and genes.
|
|
60
|
+
* Throw warnings if the data is marked as required.
|
|
61
|
+
* Subscribe to loader updates. Should not be used in conjunction (called in the same component)
|
|
62
|
+
* with useExpressionMatrixData.
|
|
63
|
+
* @param {object} loaders The object mapping
|
|
64
|
+
* datasets and data types to loader instances.
|
|
65
|
+
* @param {string} dataset The key for a dataset,
|
|
66
|
+
* used to identify which loader to use.
|
|
67
|
+
* @param {boolean} isRequired Should a warning be thrown if
|
|
68
|
+
* loading is unsuccessful?
|
|
69
|
+
* @returns {object} [attrs] { rows, cols } object containing cell and gene names.
|
|
70
|
+
*/
|
|
71
|
+
export function useObsFeatureMatrixIndices(loaders: object, dataset: string, isRequired: boolean, matchOn: any): object;
|
|
72
|
+
export function useMultiObsLabels(coordinationScopes: any, obsType: any, loaders: any, dataset: any): any[];
|
|
73
|
+
//# sourceMappingURL=data-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-hooks.d.ts","sourceRoot":"","sources":["../src/data-hooks.js"],"names":[],"mappings":"AAkBA;;;;;;;;GAQG;AACH,wCAPW,MAAM,WAEN,MAAM,SAsBhB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,6CAhBW,MAAM,WAEN,MAAM,cAEN,OAAO,uBAEP,MAAM,6BAGN,MAAM,uBAgBhB;AAED,gKASC;AAED,6JASC;AAED,oKASC;AAED,2JASC;AAED,oKASC;AAED,iKASC;AAED,yJASC;AAED,mKASC;AAED,iKASC;AAED;;;;;;;;;;;;;GAaG;AACH,6CAVW,MAAM,WAEN,MAAM,cAEN,OAAO,aAEP,OAAO,uBA4EjB;AAED;;;;;;;;;;;;;GAaG;AACH,oDARW,MAAM,WAEN,MAAM,cAEN,OAAO,iBAEL,MAAM,CAyElB;AAED,4GAoBC"}
|