@vitessce/vit-s 2.0.3-beta.0 → 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 -18
- package/dist-tsc/CallbackPublisher.d.ts +18 -0
- package/dist-tsc/CallbackPublisher.d.ts.map +1 -0
- package/{dist → dist-tsc}/CallbackPublisher.js +6 -12
- package/dist-tsc/LoadingIndicator.d.ts +2 -0
- package/dist-tsc/LoadingIndicator.d.ts.map +1 -0
- package/{dist → dist-tsc}/LoadingIndicator.js +1 -2
- package/dist-tsc/TitleInfo.d.ts +2 -0
- package/dist-tsc/TitleInfo.d.ts.map +1 -0
- package/{dist → dist-tsc}/TitleInfo.js +6 -83
- 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 → dist-tsc}/VitessceGrid.js +14 -13
- package/dist-tsc/VitessceGrid.test.d.ts +2 -0
- package/dist-tsc/VitessceGrid.test.d.ts.map +1 -0
- package/{dist → dist-tsc}/VitessceGrid.test.js +8 -4
- package/dist-tsc/Warning.d.ts +2 -0
- package/dist-tsc/Warning.d.ts.map +1 -0
- package/{dist → dist-tsc}/Warning.js +2 -2
- package/dist-tsc/classNames.d.ts +8 -0
- package/dist-tsc/classNames.d.ts.map +1 -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 → dist-tsc}/data/AbstractTwoStepLoader.js +1 -1
- package/dist-tsc/data/LoaderResult.d.ts +7 -0
- package/dist-tsc/data/LoaderResult.d.ts.map +1 -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 → dist-tsc}/data-hook-utils.js +4 -6
- package/dist-tsc/data-hooks.d.ts +77 -0
- package/dist-tsc/data-hooks.d.ts.map +1 -0
- package/{dist → dist-tsc}/data-hooks.js +4 -4
- package/dist-tsc/errors/AbstractLoaderError.d.ts +10 -0
- package/dist-tsc/errors/AbstractLoaderError.d.ts.map +1 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts +8 -0
- package/dist-tsc/errors/DataSourceFetchError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/DataSourceFetchError.js +1 -1
- package/dist-tsc/errors/DatasetNotFoundError.d.ts +6 -0
- package/dist-tsc/errors/DatasetNotFoundError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/DatasetNotFoundError.js +1 -1
- package/dist-tsc/errors/LoaderNotFoundError.d.ts +10 -0
- package/dist-tsc/errors/LoaderNotFoundError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/LoaderNotFoundError.js +1 -1
- package/dist-tsc/errors/LoaderValidationError.d.ts +10 -0
- package/dist-tsc/errors/LoaderValidationError.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/LoaderValidationError.js +1 -1
- package/dist-tsc/errors/index.d.ts +6 -0
- package/dist-tsc/errors/index.d.ts.map +1 -0
- package/{dist → dist-tsc}/errors/index.js +5 -6
- package/dist-tsc/hooks.d.ts +80 -0
- package/dist-tsc/hooks.d.ts.map +1 -0
- package/{dist → dist-tsc}/hooks.js +60 -4
- package/dist-tsc/index.d.ts +11 -0
- package/dist-tsc/index.d.ts.map +1 -0
- package/dist-tsc/index.js +11 -0
- package/dist-tsc/plugins.test.fixtures.d.ts +61 -0
- package/dist-tsc/plugins.test.fixtures.d.ts.map +1 -0
- package/{dist → dist-tsc}/schemas/config-1.0.16.schema.json +21 -41
- 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/obsSetsTabular.schema.d.ts +57 -0
- package/dist-tsc/schemas/obsSetsTabular.schema.d.ts.map +1 -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/shared-mui/components.d.ts +2 -0
- package/dist-tsc/shared-mui/components.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-mui/components.js +2 -8
- package/dist-tsc/shared-mui/container.d.ts +2 -0
- package/dist-tsc/shared-mui/container.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-mui/container.js +1 -1
- package/dist-tsc/shared-mui/styles.d.ts +5 -0
- package/dist-tsc/shared-mui/styles.d.ts.map +1 -0
- package/{dist → dist-tsc}/shared-mui/styles.js +4 -2
- 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 → dist-tsc}/shared-plot-options/CellColorEncodingOption.js +3 -4
- 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 → dist-tsc}/shared-plot-options/OptionSelect.js +2 -2
- 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 → dist-tsc}/shared-plot-options/OptionsContainer.js +2 -5
- 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 → dist-tsc}/shared-plot-options/styles.js +1 -1
- package/dist-tsc/state/hooks.d.ts +216 -0
- package/dist-tsc/state/hooks.d.ts.map +1 -0
- package/{dist → dist-tsc}/state/hooks.js +47 -21
- 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 → dist-tsc}/view-config-utils.js +32 -84
- 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 → dist-tsc}/view-config-utils.test.fixtures.js +118 -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 → dist-tsc}/vitessce-grid-layout/VitessceGridLayout.js +47 -28
- 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 → dist-tsc}/vitessce-grid-layout/VitessceGridLayout.test.js +13 -5
- 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 → dist-tsc}/vitessce-grid-layout/layout-utils.js +2 -1
- 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 → dist-tsc}/vitessce-grid-layout/layout-utils.test.js +3 -1
- package/dist-tsc/vitessce-grid-utils.d.ts +13 -0
- package/dist-tsc/vitessce-grid-utils.d.ts.map +1 -0
- package/{dist → dist-tsc}/vitessce-grid-utils.js +15 -14
- package/package.json +24 -11
- package/src/CallbackPublisher.js +77 -0
- package/src/LoadingIndicator.js +33 -0
- package/src/TitleInfo.js +167 -0
- package/src/VitS.js +202 -0
- package/src/VitessceGrid.js +118 -0
- package/src/VitessceGrid.test.jsx +57 -0
- package/src/Warning.js +62 -0
- package/src/classNames.js +8 -0
- package/src/data/AbstractLoader.js +23 -0
- package/src/data/AbstractTwoStepLoader.js +8 -0
- package/src/data/LoaderResult.js +8 -0
- package/src/data/index.js +3 -0
- package/src/data/loader-registry.js +28 -0
- package/src/data-hook-utils.js +195 -0
- package/src/data-hooks.js +354 -0
- package/src/errors/AbstractLoaderError.js +14 -0
- package/src/errors/DataSourceFetchError.js +15 -0
- package/src/errors/DatasetNotFoundError.js +23 -0
- package/src/errors/LoaderNotFoundError.js +24 -0
- package/src/errors/LoaderValidationError.js +23 -0
- package/src/errors/index.js +5 -0
- package/src/hooks.js +317 -0
- package/src/index.js +76 -0
- package/src/plugins.test.fixtures.js +78 -0
- package/src/schemas/config-0.1.0.schema.json +85 -0
- package/src/schemas/config-1.0.0.schema.json +733 -0
- package/src/schemas/config-1.0.1.schema.json +909 -0
- package/src/schemas/config-1.0.10.schema.json +969 -0
- package/src/schemas/config-1.0.11.schema.json +990 -0
- package/src/schemas/config-1.0.12.schema.json +997 -0
- package/src/schemas/config-1.0.13.schema.json +1013 -0
- package/src/schemas/config-1.0.14.schema.json +1048 -0
- package/src/schemas/config-1.0.15.schema.json +1048 -0
- package/src/schemas/config-1.0.16.schema.json +1089 -0
- package/src/schemas/config-1.0.2.schema.json +911 -0
- package/src/schemas/config-1.0.3.schema.json +911 -0
- package/src/schemas/config-1.0.4.schema.json +949 -0
- package/src/schemas/config-1.0.5.schema.json +949 -0
- package/src/schemas/config-1.0.6.schema.json +950 -0
- package/src/schemas/config-1.0.7.schema.json +950 -0
- package/src/schemas/config-1.0.8.schema.json +966 -0
- package/src/schemas/config-1.0.9.schema.json +965 -0
- package/src/schemas/fixtures/cellSets.good.json +16 -0
- package/src/schemas/fixtures/config-1.0.1.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.1.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.1.good.json +37 -0
- package/src/schemas/fixtures/config-1.0.2.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.2.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.2.good.json +38 -0
- package/src/schemas/fixtures/config-1.0.3.bad.json +1 -0
- package/src/schemas/fixtures/config-1.0.3.bad.message.json +11 -0
- package/src/schemas/fixtures/config-1.0.3.good.json +38 -0
- package/src/schemas/fixtures/obsSets.bad.json +1 -0
- package/src/schemas/fixtures/obsSets.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSets.good.json +16 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.json +1 -0
- package/src/schemas/fixtures/obsSetsTabular.bad.message.json +11 -0
- package/src/schemas/fixtures/obsSetsTabular.good.json +26 -0
- package/src/schemas/fixtures/raster.bad.json +1 -0
- package/src/schemas/fixtures/raster.bad.message.json +11 -0
- package/src/schemas/fixtures/raster.good.json +39 -0
- package/src/schemas/obsSets.schema.js +195 -0
- package/src/schemas/obsSetsTabular.schema.js +39 -0
- package/src/schemas/raster.schema.js +121 -0
- package/src/schemas/schema-schema.sh +34 -0
- package/src/shared-mui/components.js +81 -0
- package/src/shared-mui/container.js +212 -0
- package/src/shared-mui/styles.js +113 -0
- package/src/shared-plot-options/CellColorEncodingOption.js +42 -0
- package/src/shared-plot-options/OptionSelect.js +19 -0
- package/src/shared-plot-options/OptionsContainer.js +23 -0
- package/src/shared-plot-options/index.js +4 -0
- package/src/shared-plot-options/styles.js +49 -0
- package/src/state/hooks.js +640 -0
- package/src/title-styles.js +73 -0
- package/src/view-config-utils.js +263 -0
- package/src/view-config-utils.test.fixtures.js +893 -0
- package/src/view-config-utils.test.jsx +222 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.js +179 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +64 -0
- package/src/vitessce-grid-layout/index.js +1 -0
- package/src/vitessce-grid-layout/layout-utils.js +76 -0
- package/src/vitessce-grid-layout/layout-utils.test.js +167 -0
- package/src/vitessce-grid-utils.js +172 -0
- package/dist/VitS.js +0 -117
- package/dist/Vitessce.integration.test.js +0 -36
- package/dist/Vitessce.js +0 -101
- package/dist/component-registry.js +0 -16
- package/dist/data/AbstractLoader.js +0 -35
- package/dist/data/index.js +0 -3
- package/dist/data/loader-registry.js +0 -15
- package/dist/errors/OptionsValidationError.js +0 -15
- package/dist/export-utils.js +0 -70
- package/dist/export-utils.test.js +0 -66
- package/dist/file-options-schemas-legacy.js +0 -136
- package/dist/file-options-schemas-legacy.test.js +0 -126
- package/dist/file-options-schemas.js +0 -322
- package/dist/file-options-schemas.test.js +0 -23
- package/dist/joint-file-types-legacy.js +0 -278
- package/dist/joint-file-types-legacy.test.js +0 -400
- package/dist/joint-file-types.js +0 -148
- package/dist/joint-file-types.test.js +0 -139
- package/dist/loader-registry.js +0 -98
- package/dist/plugins.js +0 -154
- package/dist/plugins.test.js +0 -30
- package/dist/schemas/PrettyJsonSchema.js +0 -34
- package/dist/schemas/config-1.0.15.schema.test.js +0 -22
- package/dist/schemas/config-1.0.16.schema.test.js +0 -22
- package/dist/schemas/obs-sets-tabular.schema.js +0 -37
- package/dist/schemas/obs-sets.schema.js +0 -194
- package/dist/schemas/schema.test-old.js +0 -50
- package/dist/schemas/schema.test.js +0 -46
- package/dist/schemas-extra.js +0 -3
- package/dist/schemas.js +0 -4
- package/dist/shared-plot-options/index.js +0 -4
- package/dist/view-config-upgraders.js +0 -525
- package/dist/view-config-utils.test.js +0 -66
- package/dist/view-config-versions.js +0 -47
- package/dist/vitessce-grid-layout/index.js +0 -1
- /package/{dist → dist-tsc}/classNames.js +0 -0
- /package/{dist → dist-tsc}/data/LoaderResult.js +0 -0
- /package/{dist → dist-tsc}/errors/AbstractLoaderError.js +0 -0
- /package/{dist → dist-tsc}/plugins.test.fixtures.js +0 -0
- /package/{dist → dist-tsc}/schemas/config-0.1.0.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.0.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.1.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.10.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.11.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.12.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.13.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.14.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.15.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.2.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.3.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.4.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.5.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.6.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.7.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.8.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/config-1.0.9.schema.json +0 -0
- /package/{dist → dist-tsc}/schemas/obsSets.schema.js +0 -0
- /package/{dist → dist-tsc}/schemas/obsSetsTabular.schema.js +0 -0
- /package/{dist → dist-tsc}/schemas/raster.schema.js +0 -0
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
/* eslint-disable no-plusplus */
|
|
2
2
|
/* eslint-disable camelcase */
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { getNextScope } from '@vitessce/utils';
|
|
3
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
|
+
import { fromEntries, getNextScope } from '@vitessce/utils';
|
|
6
5
|
import { AUTO_INDEPENDENT_COORDINATION_TYPES, } from '@vitessce/constants-internal';
|
|
7
|
-
import { getViewTypes } from './component-registry';
|
|
8
|
-
import { getComponentCoordinationTypes, getDefaultCoordinationValues, getCoordinationTypes, getFileTypes, getJointFileTypes, } from './plugins';
|
|
9
|
-
import { SCHEMA_HANDLERS } from './view-config-versions';
|
|
10
6
|
/**
|
|
11
7
|
* Get a list of all unique scope names for a
|
|
12
8
|
* particular coordination type, which exist in
|
|
@@ -30,8 +26,8 @@ export function getExistingScopesForCoordinationType(config, coordinationType) {
|
|
|
30
26
|
* to set in the coordination space.
|
|
31
27
|
* @returns {object} The new view config.
|
|
32
28
|
*/
|
|
33
|
-
function coordinateComponentsTogether(config, coordinationType, scopeValue) {
|
|
34
|
-
const componentCoordinationTypes =
|
|
29
|
+
function coordinateComponentsTogether(config, coordinationType, scopeValue, viewTypes) {
|
|
30
|
+
const componentCoordinationTypes = fromEntries(viewTypes.map(vt => ([vt.name, vt.coordinationTypes])));
|
|
35
31
|
const scopeName = getNextScope(getExistingScopesForCoordinationType(config, coordinationType));
|
|
36
32
|
const newConfig = {
|
|
37
33
|
...config,
|
|
@@ -69,8 +65,8 @@ function coordinateComponentsTogether(config, coordinationType, scopeValue) {
|
|
|
69
65
|
* to set in the coordination space.
|
|
70
66
|
* @returns {object} The new view config.
|
|
71
67
|
*/
|
|
72
|
-
function coordinateComponentsIndependent(config, coordinationType, scopeValue) {
|
|
73
|
-
const componentCoordinationTypes =
|
|
68
|
+
function coordinateComponentsIndependent(config, coordinationType, scopeValue, viewTypes) {
|
|
69
|
+
const componentCoordinationTypes = fromEntries(viewTypes.map(vt => ([vt.name, vt.coordinationTypes])));
|
|
74
70
|
const newConfig = {
|
|
75
71
|
...config,
|
|
76
72
|
layout: [...config.layout],
|
|
@@ -105,12 +101,19 @@ function coordinateComponentsIndependent(config, coordinationType, scopeValue) {
|
|
|
105
101
|
};
|
|
106
102
|
return newConfig;
|
|
107
103
|
}
|
|
108
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Perform initialization using initStrategy: "auto".
|
|
106
|
+
* @param {object} config The view config.
|
|
107
|
+
* @param {PluginCoordinationType[]} coordinationTypeObjs
|
|
108
|
+
* @param {PluginViewType[]} viewTypeObjs
|
|
109
|
+
* @returns {object} The config.
|
|
110
|
+
*/
|
|
111
|
+
function initializeAuto(config, coordinationTypeObjs, viewTypeObjs) {
|
|
109
112
|
let newConfig = config;
|
|
110
113
|
const { layout, datasets } = newConfig;
|
|
111
|
-
const componentCoordinationTypes =
|
|
112
|
-
const defaultCoordinationValues =
|
|
113
|
-
const coordinationTypes =
|
|
114
|
+
const componentCoordinationTypes = fromEntries(viewTypeObjs.map(vt => ([vt.name, vt.coordinationTypes])));
|
|
115
|
+
const defaultCoordinationValues = fromEntries(coordinationTypeObjs.map(ct => ([ct.name, ct.defaultValue])));
|
|
116
|
+
const coordinationTypes = coordinationTypeObjs.map(ct => ct.name);
|
|
114
117
|
// For each coordination type, check whether it requires initialization.
|
|
115
118
|
coordinationTypes.forEach((coordinationType) => {
|
|
116
119
|
// A coordination type requires coordination if at least one component is missing
|
|
@@ -134,43 +137,15 @@ function initializeAuto(config) {
|
|
|
134
137
|
// a unique scope for every component ("independent")
|
|
135
138
|
// vs. the same scope for every component ("together").
|
|
136
139
|
if (AUTO_INDEPENDENT_COORDINATION_TYPES.includes(coordinationType)) {
|
|
137
|
-
newConfig = coordinateComponentsIndependent(newConfig, coordinationType, defaultValue);
|
|
140
|
+
newConfig = coordinateComponentsIndependent(newConfig, coordinationType, defaultValue, viewTypeObjs);
|
|
138
141
|
}
|
|
139
142
|
else {
|
|
140
|
-
newConfig = coordinateComponentsTogether(newConfig, coordinationType, defaultValue);
|
|
143
|
+
newConfig = coordinateComponentsTogether(newConfig, coordinationType, defaultValue, viewTypeObjs);
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
146
|
});
|
|
144
147
|
return newConfig;
|
|
145
148
|
}
|
|
146
|
-
export function checkTypes(config) {
|
|
147
|
-
// Add a log message when there are additionalProperties in the coordination space that
|
|
148
|
-
// do not appear in the view config JSON schema,
|
|
149
|
-
// with a note that this indicates either a mistake or custom coordination type usage.
|
|
150
|
-
const coordinationTypesInConfig = Object.keys(config.coordinationSpace || {});
|
|
151
|
-
const allCoordinationTypes = getCoordinationTypes();
|
|
152
|
-
const unknownCoordinationTypes = difference(coordinationTypesInConfig, allCoordinationTypes);
|
|
153
|
-
if (unknownCoordinationTypes.length > 0) {
|
|
154
|
-
return [false, `The following coordination types are not recognized: [${unknownCoordinationTypes}].\nIf these are plugin coordination types, ensure that they have been properly registered.`];
|
|
155
|
-
}
|
|
156
|
-
// Add a log message when there are views in the layout that are neither
|
|
157
|
-
// core views nor registered plugin views.
|
|
158
|
-
const viewTypesInConfig = config.layout.map(c => c.component);
|
|
159
|
-
const allViewTypes = getViewTypes();
|
|
160
|
-
const unknownViewTypes = difference(viewTypesInConfig, allViewTypes);
|
|
161
|
-
if (unknownViewTypes.length > 0) {
|
|
162
|
-
return [false, `The following view types are not recognized: [${unknownViewTypes}].\nIf these are plugin view types, ensure that they have been properly registered.`];
|
|
163
|
-
}
|
|
164
|
-
// Add a log message when there are file definitions with neither
|
|
165
|
-
// core nor registered plugin file types.
|
|
166
|
-
const fileTypesInConfig = config.datasets.flatMap(d => d.files.map(f => f.fileType));
|
|
167
|
-
const allFileTypes = getFileTypes();
|
|
168
|
-
const unknownFileTypes = difference(fileTypesInConfig, allFileTypes);
|
|
169
|
-
if (unknownFileTypes.length > 0) {
|
|
170
|
-
return [false, `The following file types are not recognized: [${unknownFileTypes}].\nIf these are plugin file types, ensure that they have been properly registered.`];
|
|
171
|
-
}
|
|
172
|
-
return [true, 'All view types, coordination types, and file types that appear in the view config are recognized.'];
|
|
173
|
-
}
|
|
174
149
|
/**
|
|
175
150
|
* Assign unique ids for view definitions where
|
|
176
151
|
* they are missing a value for the uid property
|
|
@@ -179,7 +154,7 @@ export function checkTypes(config) {
|
|
|
179
154
|
* @returns The updated view config.
|
|
180
155
|
*/
|
|
181
156
|
function assignViewUids(config) {
|
|
182
|
-
const { layout } = config;
|
|
157
|
+
const { uid, layout } = config;
|
|
183
158
|
const usedIds = layout.map(view => view.uid);
|
|
184
159
|
layout.forEach((view, i) => {
|
|
185
160
|
// Assign uids for views where they are not present.
|
|
@@ -189,8 +164,10 @@ function assignViewUids(config) {
|
|
|
189
164
|
usedIds.push(nextUid);
|
|
190
165
|
}
|
|
191
166
|
});
|
|
167
|
+
const newUid = uid || getNextScope([]);
|
|
192
168
|
return {
|
|
193
169
|
...config,
|
|
170
|
+
uid: newUid,
|
|
194
171
|
layout,
|
|
195
172
|
};
|
|
196
173
|
}
|
|
@@ -202,8 +179,8 @@ function assignViewUids(config) {
|
|
|
202
179
|
* convenience file types.
|
|
203
180
|
* @returns The view config containing expanded minimal file types.
|
|
204
181
|
*/
|
|
205
|
-
function expandConvenienceFileDefs(config) {
|
|
206
|
-
const convenienceFileTypes =
|
|
182
|
+
function expandConvenienceFileDefs(config, jointFileTypes) {
|
|
183
|
+
const convenienceFileTypes = fromEntries(jointFileTypes.map(ft => ([ft.name, ft.expandFunction])));
|
|
207
184
|
const { datasets: currDatasets } = config;
|
|
208
185
|
const datasets = cloneDeep(currDatasets);
|
|
209
186
|
currDatasets.forEach((dataset, i) => {
|
|
@@ -240,47 +217,18 @@ function expandConvenienceFileDefs(config) {
|
|
|
240
217
|
* Should be "stable": if run on the same view config twice, the return value the second
|
|
241
218
|
* time should be identical to the return value the first time.
|
|
242
219
|
* @param {object} config The view config prop.
|
|
220
|
+
* @param {PluginJointFileType[]} jointFileTypes
|
|
221
|
+
* @param {PluginCoordinationType[]} coordinationTypes
|
|
222
|
+
* @param {PluginViewType[]} viewTypes
|
|
243
223
|
* @returns The initialized view config.
|
|
244
224
|
*/
|
|
245
|
-
export function initialize(config) {
|
|
225
|
+
export function initialize(config, jointFileTypes, coordinationTypes, viewTypes) {
|
|
246
226
|
let newConfig = cloneDeep(config);
|
|
247
227
|
if (newConfig.initStrategy === 'auto') {
|
|
248
|
-
|
|
228
|
+
// TODO: pass coordination types with defaults
|
|
229
|
+
// TODO: pass view types with per-view coordination type lists
|
|
230
|
+
newConfig = initializeAuto(config, coordinationTypes, viewTypes);
|
|
249
231
|
}
|
|
250
|
-
newConfig = expandConvenienceFileDefs(newConfig);
|
|
232
|
+
newConfig = expandConvenienceFileDefs(newConfig, jointFileTypes);
|
|
251
233
|
return assignViewUids(newConfig);
|
|
252
234
|
}
|
|
253
|
-
export function upgradeAndValidate(oldConfig, onConfigUpgrade = null) {
|
|
254
|
-
// oldConfig object must have a `version` property.
|
|
255
|
-
let nextConfig = oldConfig;
|
|
256
|
-
let fromVersion;
|
|
257
|
-
let upgradeFunction;
|
|
258
|
-
let validateFunction;
|
|
259
|
-
do {
|
|
260
|
-
fromVersion = nextConfig.version;
|
|
261
|
-
if (!Object.keys(SCHEMA_HANDLERS).includes(fromVersion)) {
|
|
262
|
-
return [{
|
|
263
|
-
title: 'Config validation failed',
|
|
264
|
-
preformatted: 'Unknown config version.',
|
|
265
|
-
}, false];
|
|
266
|
-
}
|
|
267
|
-
[validateFunction, upgradeFunction] = SCHEMA_HANDLERS[fromVersion];
|
|
268
|
-
// Validate under the legacy schema before upgrading.
|
|
269
|
-
const validLegacy = validateFunction(nextConfig);
|
|
270
|
-
if (!validLegacy) {
|
|
271
|
-
const failureReason = JSON.stringify(validateFunction.errors, null, 2);
|
|
272
|
-
return [{
|
|
273
|
-
title: 'Config validation failed',
|
|
274
|
-
preformatted: failureReason,
|
|
275
|
-
}, false];
|
|
276
|
-
}
|
|
277
|
-
if (upgradeFunction) {
|
|
278
|
-
const prevConfig = nextConfig;
|
|
279
|
-
nextConfig = upgradeFunction(nextConfig);
|
|
280
|
-
if (onConfigUpgrade) {
|
|
281
|
-
onConfigUpgrade(prevConfig, nextConfig);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
} while (upgradeFunction);
|
|
285
|
-
return [nextConfig, true];
|
|
286
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-config-utils.test.d.ts","sourceRoot":"","sources":["../src/view-config-utils.test.jsx"],"names":[],"mappings":""}
|