@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
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/* eslint-disable no-plusplus */
|
|
2
|
+
/* eslint-disable camelcase */
|
|
3
|
+
import { cloneDeep } from 'lodash-es';
|
|
4
|
+
import { fromEntries, getNextScope } from '@vitessce/utils';
|
|
5
|
+
import {
|
|
6
|
+
AUTO_INDEPENDENT_COORDINATION_TYPES,
|
|
7
|
+
} from '@vitessce/constants-internal';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get a list of all unique scope names for a
|
|
11
|
+
* particular coordination type, which exist in
|
|
12
|
+
* a particular view config.
|
|
13
|
+
* @param {object} config A view config object.
|
|
14
|
+
* @param {string} coordinationType A coordination type,
|
|
15
|
+
* for example 'spatialZoom' or 'dataset'.
|
|
16
|
+
* @returns {string[]} Array of existing coordination scope names.
|
|
17
|
+
*/
|
|
18
|
+
export function getExistingScopesForCoordinationType(config, coordinationType) {
|
|
19
|
+
const spaceScopes = Object.keys(config?.coordinationSpace?.[coordinationType] || {});
|
|
20
|
+
const componentScopes = config.layout.map(c => c.coordinationScopes?.[coordinationType]);
|
|
21
|
+
return Array.from(new Set([...spaceScopes, ...componentScopes]));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Give each component the same scope name for this coordination type.
|
|
26
|
+
* @param {object} config A view config object.
|
|
27
|
+
* @param {string} coordinationType A coordination type,
|
|
28
|
+
* for example 'spatialZoom' or 'dataset'.
|
|
29
|
+
* @param {*} scopeValue The initial value for the coordination scope,
|
|
30
|
+
* to set in the coordination space.
|
|
31
|
+
* @returns {object} The new view config.
|
|
32
|
+
*/
|
|
33
|
+
function coordinateComponentsTogether(config, coordinationType, scopeValue, viewTypes) {
|
|
34
|
+
const componentCoordinationTypes = fromEntries(
|
|
35
|
+
viewTypes.map(vt => ([vt.name, vt.coordinationTypes])),
|
|
36
|
+
);
|
|
37
|
+
const scopeName = getNextScope(getExistingScopesForCoordinationType(config, coordinationType));
|
|
38
|
+
const newConfig = {
|
|
39
|
+
...config,
|
|
40
|
+
coordinationSpace: {
|
|
41
|
+
...config.coordinationSpace,
|
|
42
|
+
[coordinationType]: {
|
|
43
|
+
...config?.coordinationSpace?.[coordinationType],
|
|
44
|
+
// Add the new scope name and value to the coordination space.
|
|
45
|
+
[scopeName]: scopeValue,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
layout: config.layout.map(component => ({
|
|
49
|
+
...component,
|
|
50
|
+
coordinationScopes: {
|
|
51
|
+
...component.coordinationScopes,
|
|
52
|
+
// Only set the coordination scope if this component uses this coordination type,
|
|
53
|
+
// and the component is missing a coordination scope for this coordination type.
|
|
54
|
+
...((
|
|
55
|
+
componentCoordinationTypes[component.component].includes(coordinationType)
|
|
56
|
+
&& !component.coordinationScopes?.[coordinationType]
|
|
57
|
+
) ? {
|
|
58
|
+
// Only set the new scope name if the scope name
|
|
59
|
+
// for this component and coordination type is currently undefined.
|
|
60
|
+
[coordinationType]: scopeName,
|
|
61
|
+
} : {}),
|
|
62
|
+
},
|
|
63
|
+
})),
|
|
64
|
+
};
|
|
65
|
+
return newConfig;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Give each component a different scope name for this coordination type.
|
|
70
|
+
* @param {object} config A view config object.
|
|
71
|
+
* @param {string} coordinationType A coordination type,
|
|
72
|
+
* for example 'spatialZoom' or 'dataset'.
|
|
73
|
+
* @param {*} scopeValue The initial value for the coordination scope,
|
|
74
|
+
* to set in the coordination space.
|
|
75
|
+
* @returns {object} The new view config.
|
|
76
|
+
*/
|
|
77
|
+
function coordinateComponentsIndependent(config, coordinationType, scopeValue, viewTypes) {
|
|
78
|
+
const componentCoordinationTypes = fromEntries(
|
|
79
|
+
viewTypes.map(vt => ([vt.name, vt.coordinationTypes])),
|
|
80
|
+
);
|
|
81
|
+
const newConfig = {
|
|
82
|
+
...config,
|
|
83
|
+
layout: [...config.layout],
|
|
84
|
+
};
|
|
85
|
+
const newScopes = {};
|
|
86
|
+
newConfig.layout.forEach((component, i) => {
|
|
87
|
+
// Only set the coordination scope if this component uses this coordination type,
|
|
88
|
+
// and the component is missing a coordination scope for this coordination type.
|
|
89
|
+
if (componentCoordinationTypes[component.component].includes(coordinationType)
|
|
90
|
+
&& !component.coordinationScopes?.[coordinationType]
|
|
91
|
+
) {
|
|
92
|
+
const scopeName = getNextScope([
|
|
93
|
+
...getExistingScopesForCoordinationType(config, coordinationType),
|
|
94
|
+
...Object.keys(newScopes),
|
|
95
|
+
]);
|
|
96
|
+
newScopes[scopeName] = scopeValue;
|
|
97
|
+
newConfig.layout[i] = {
|
|
98
|
+
...component,
|
|
99
|
+
coordinationScopes: {
|
|
100
|
+
...component.coordinationScopes,
|
|
101
|
+
[coordinationType]: scopeName,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
newConfig.coordinationSpace = {
|
|
107
|
+
...newConfig.coordinationSpace,
|
|
108
|
+
[coordinationType]: {
|
|
109
|
+
...newConfig.coordinationSpace[coordinationType],
|
|
110
|
+
// Add the new scope name and value to the coordination space.
|
|
111
|
+
...newScopes,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
return newConfig;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Perform initialization using initStrategy: "auto".
|
|
119
|
+
* @param {object} config The view config.
|
|
120
|
+
* @param {PluginCoordinationType[]} coordinationTypeObjs
|
|
121
|
+
* @param {PluginViewType[]} viewTypeObjs
|
|
122
|
+
* @returns {object} The config.
|
|
123
|
+
*/
|
|
124
|
+
function initializeAuto(config, coordinationTypeObjs, viewTypeObjs) {
|
|
125
|
+
let newConfig = config;
|
|
126
|
+
const { layout, datasets } = newConfig;
|
|
127
|
+
|
|
128
|
+
const componentCoordinationTypes = fromEntries(
|
|
129
|
+
viewTypeObjs.map(vt => ([vt.name, vt.coordinationTypes])),
|
|
130
|
+
);
|
|
131
|
+
const defaultCoordinationValues = fromEntries(
|
|
132
|
+
coordinationTypeObjs.map(ct => ([ct.name, ct.defaultValue])),
|
|
133
|
+
);
|
|
134
|
+
const coordinationTypes = coordinationTypeObjs.map(ct => ct.name);
|
|
135
|
+
|
|
136
|
+
// For each coordination type, check whether it requires initialization.
|
|
137
|
+
coordinationTypes.forEach((coordinationType) => {
|
|
138
|
+
// A coordination type requires coordination if at least one component is missing
|
|
139
|
+
// a (coordination type, coordination scope) tuple.
|
|
140
|
+
// Components may only use a subset of all coordination types.
|
|
141
|
+
const requiresCoordination = !layout
|
|
142
|
+
.every(c => (
|
|
143
|
+
(!componentCoordinationTypes[c.component].includes(coordinationType))
|
|
144
|
+
|| c.coordinationScopes?.[coordinationType]
|
|
145
|
+
));
|
|
146
|
+
if (requiresCoordination) {
|
|
147
|
+
// Note that the default value may be undefined.
|
|
148
|
+
let defaultValue = defaultCoordinationValues[coordinationType];
|
|
149
|
+
// Check whether this is the special 'dataset' coordination type.
|
|
150
|
+
if (coordinationType === 'dataset' && datasets.length >= 1) {
|
|
151
|
+
// Use the first dataset ID as the default
|
|
152
|
+
// if there is at least one dataset.
|
|
153
|
+
defaultValue = datasets[0].uid;
|
|
154
|
+
}
|
|
155
|
+
// Use the list of "independent" coordination types
|
|
156
|
+
// to determine whether a particular coordination type
|
|
157
|
+
// should be initialized to
|
|
158
|
+
// a unique scope for every component ("independent")
|
|
159
|
+
// vs. the same scope for every component ("together").
|
|
160
|
+
if (AUTO_INDEPENDENT_COORDINATION_TYPES.includes(coordinationType)) {
|
|
161
|
+
newConfig = coordinateComponentsIndependent(
|
|
162
|
+
newConfig, coordinationType, defaultValue, viewTypeObjs,
|
|
163
|
+
);
|
|
164
|
+
} else {
|
|
165
|
+
newConfig = coordinateComponentsTogether(
|
|
166
|
+
newConfig, coordinationType, defaultValue, viewTypeObjs,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
return newConfig;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Assign unique ids for view definitions where
|
|
177
|
+
* they are missing a value for the uid property
|
|
178
|
+
* in layout[].uid.
|
|
179
|
+
* @param {object} config The view config
|
|
180
|
+
* @returns The updated view config.
|
|
181
|
+
*/
|
|
182
|
+
function assignViewUids(config) {
|
|
183
|
+
const { uid, layout } = config;
|
|
184
|
+
const usedIds = layout.map(view => view.uid);
|
|
185
|
+
layout.forEach((view, i) => {
|
|
186
|
+
// Assign uids for views where they are not present.
|
|
187
|
+
if (!view.uid) {
|
|
188
|
+
const nextUid = getNextScope(usedIds);
|
|
189
|
+
layout[i].uid = nextUid;
|
|
190
|
+
usedIds.push(nextUid);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
const newUid = uid || getNextScope([]);
|
|
194
|
+
return {
|
|
195
|
+
...config,
|
|
196
|
+
uid: newUid,
|
|
197
|
+
layout,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Expand convenience file definitions. Each convenience file
|
|
203
|
+
* definition expansion function takes in one file definition and
|
|
204
|
+
* returns an array of file definitions. Not performed recursively.
|
|
205
|
+
* @param {object} config The view config containing collapsed
|
|
206
|
+
* convenience file types.
|
|
207
|
+
* @returns The view config containing expanded minimal file types.
|
|
208
|
+
*/
|
|
209
|
+
function expandConvenienceFileDefs(config, jointFileTypes) {
|
|
210
|
+
const convenienceFileTypes = fromEntries(
|
|
211
|
+
jointFileTypes.map(ft => ([ft.name, ft.expandFunction])),
|
|
212
|
+
);
|
|
213
|
+
const { datasets: currDatasets } = config;
|
|
214
|
+
const datasets = cloneDeep(currDatasets);
|
|
215
|
+
currDatasets.forEach((dataset, i) => {
|
|
216
|
+
const { files = [] } = dataset;
|
|
217
|
+
let newFiles = [];
|
|
218
|
+
files.forEach((fileDef) => {
|
|
219
|
+
const { fileType } = fileDef;
|
|
220
|
+
const expansionFunc = convenienceFileTypes[fileType];
|
|
221
|
+
if (expansionFunc && typeof expansionFunc === 'function') {
|
|
222
|
+
// This was a convenience file type, so expand it.
|
|
223
|
+
const expandedFileDefs = expansionFunc(fileDef);
|
|
224
|
+
newFiles = newFiles.concat(expandedFileDefs);
|
|
225
|
+
} else {
|
|
226
|
+
// This was not a convenience file type,
|
|
227
|
+
// so keep it in the files array as-is.
|
|
228
|
+
newFiles.push(fileDef);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
datasets[i].files = newFiles;
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
...config,
|
|
235
|
+
datasets,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Initialize the view config:
|
|
241
|
+
* - Fill in missing coordination objects with default values.
|
|
242
|
+
* - Fill in missing component coordination scope mappings.
|
|
243
|
+
* based on the `initStrategy` specified in the view config.
|
|
244
|
+
* - Fill in missing view uid values.
|
|
245
|
+
* - Expand convenience file types.
|
|
246
|
+
* Should be "stable": if run on the same view config twice, the return value the second
|
|
247
|
+
* time should be identical to the return value the first time.
|
|
248
|
+
* @param {object} config The view config prop.
|
|
249
|
+
* @param {PluginJointFileType[]} jointFileTypes
|
|
250
|
+
* @param {PluginCoordinationType[]} coordinationTypes
|
|
251
|
+
* @param {PluginViewType[]} viewTypes
|
|
252
|
+
* @returns The initialized view config.
|
|
253
|
+
*/
|
|
254
|
+
export function initialize(config, jointFileTypes, coordinationTypes, viewTypes) {
|
|
255
|
+
let newConfig = cloneDeep(config);
|
|
256
|
+
if (newConfig.initStrategy === 'auto') {
|
|
257
|
+
// TODO: pass coordination types with defaults
|
|
258
|
+
// TODO: pass view types with per-view coordination type lists
|
|
259
|
+
newConfig = initializeAuto(config, coordinationTypes, viewTypes);
|
|
260
|
+
}
|
|
261
|
+
newConfig = expandConvenienceFileDefs(newConfig, jointFileTypes);
|
|
262
|
+
return assignViewUids(newConfig);
|
|
263
|
+
}
|