@vitessce/vit-s 3.0.0 → 3.1.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 +28430 -25685
- package/dist-tsc/VitS.d.ts +7 -2
- package/dist-tsc/VitS.d.ts.map +1 -1
- package/dist-tsc/VitS.js +43 -23
- package/dist-tsc/VitessceGrid.d.ts.map +1 -1
- package/dist-tsc/VitessceGrid.js +14 -11
- package/dist-tsc/VitessceGrid.test.js +5 -2
- package/dist-tsc/Warning.js +2 -2
- package/dist-tsc/data/LoaderResult.d.ts +8 -3
- package/dist-tsc/data/LoaderResult.d.ts.map +1 -1
- package/dist-tsc/data/LoaderResult.js +5 -0
- package/dist-tsc/data-hook-utils.d.ts +3 -7
- package/dist-tsc/data-hook-utils.d.ts.map +1 -1
- package/dist-tsc/data-hook-utils.js +97 -79
- package/dist-tsc/data-hooks.d.ts +12 -16
- package/dist-tsc/data-hooks.d.ts.map +1 -1
- package/dist-tsc/data-hooks.js +140 -127
- package/dist-tsc/errors/DataSourceFetchError.js +1 -1
- package/dist-tsc/hooks.d.ts +3 -7
- package/dist-tsc/hooks.d.ts.map +1 -1
- package/dist-tsc/hooks.js +12 -18
- package/dist-tsc/index.d.ts +2 -1
- package/dist-tsc/index.js +2 -1
- 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/shared-plot-options/OptionSelect.js +1 -1
- package/dist-tsc/shared-plot-options/styles.js +1 -1
- package/dist-tsc/state/hooks.d.ts +27 -1
- package/dist-tsc/state/hooks.d.ts.map +1 -1
- package/dist-tsc/state/hooks.js +61 -21
- package/dist-tsc/view-config-utils.d.ts +1 -0
- package/dist-tsc/view-config-utils.d.ts.map +1 -1
- package/dist-tsc/view-config-utils.js +7 -1
- package/dist-tsc/view-config-utils.test.js +1 -0
- package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.js +1 -1
- package/dist-tsc/vitessce-grid-layout/layout-utils.test.js +1 -0
- package/package.json +10 -9
- package/src/VitS.js +79 -43
- package/src/VitessceGrid.js +16 -10
- package/src/VitessceGrid.test.jsx +8 -2
- package/src/Warning.js +2 -2
- package/src/data/LoaderResult.js +5 -0
- package/src/data-hook-utils.js +116 -81
- package/src/data-hooks.js +148 -129
- package/src/errors/DataSourceFetchError.js +1 -1
- package/src/hooks.js +14 -21
- package/src/index.js +2 -0
- package/src/mui-utils.js +52 -0
- package/src/shared-plot-options/OptionSelect.js +1 -1
- package/src/shared-plot-options/styles.js +1 -1
- package/src/state/hooks.js +66 -21
- package/src/view-config-utils.js +8 -0
- package/src/view-config-utils.test.jsx +1 -0
- package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +1 -1
- package/src/vitessce-grid-layout/layout-utils.test.js +1 -0
- package/dist-tsc/schemas/config-0.1.0.schema.json +0 -84
- package/dist-tsc/schemas/config-1.0.0.schema.json +0 -733
- package/dist-tsc/schemas/config-1.0.1.schema.json +0 -909
- package/dist-tsc/schemas/config-1.0.10.schema.json +0 -969
- package/dist-tsc/schemas/config-1.0.11.schema.json +0 -990
- package/dist-tsc/schemas/config-1.0.12.schema.json +0 -997
- package/dist-tsc/schemas/config-1.0.13.schema.json +0 -1013
- package/dist-tsc/schemas/config-1.0.14.schema.json +0 -1048
- package/dist-tsc/schemas/config-1.0.15.schema.json +0 -1048
- package/dist-tsc/schemas/config-1.0.16.schema.json +0 -1089
- package/dist-tsc/schemas/config-1.0.2.schema.json +0 -910
- package/dist-tsc/schemas/config-1.0.3.schema.json +0 -910
- package/dist-tsc/schemas/config-1.0.4.schema.json +0 -949
- package/dist-tsc/schemas/config-1.0.5.schema.json +0 -949
- package/dist-tsc/schemas/config-1.0.6.schema.json +0 -949
- package/dist-tsc/schemas/config-1.0.7.schema.json +0 -949
- package/dist-tsc/schemas/config-1.0.8.schema.json +0 -965
- package/dist-tsc/schemas/config-1.0.9.schema.json +0 -965
- package/dist-tsc/schemas/obsSets.schema.d.ts +0 -179
- package/dist-tsc/schemas/obsSets.schema.d.ts.map +0 -1
- package/dist-tsc/schemas/obsSets.schema.js +0 -195
- package/dist-tsc/schemas/obsSetsTabular.schema.d.ts +0 -57
- package/dist-tsc/schemas/obsSetsTabular.schema.d.ts.map +0 -1
- package/dist-tsc/schemas/obsSetsTabular.schema.js +0 -38
- package/dist-tsc/schemas/raster.schema.d.ts +0 -239
- package/dist-tsc/schemas/raster.schema.d.ts.map +0 -1
- package/dist-tsc/schemas/raster.schema.js +0 -120
- 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 -1089
- 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/state/hooks.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useRef, useCallback, useMemo } from 'react';
|
|
|
3
3
|
import create from 'zustand';
|
|
4
4
|
import createContext from 'zustand/context';
|
|
5
5
|
import shallow from 'zustand/shallow';
|
|
6
|
-
import { isMatch } from 'lodash-es';
|
|
6
|
+
import { isMatch, cloneDeep } from 'lodash-es';
|
|
7
7
|
import { CoordinationType } from '@vitessce/constants-internal';
|
|
8
8
|
import { fromEntries, capitalize } from '@vitessce/utils';
|
|
9
9
|
|
|
@@ -38,17 +38,19 @@ export const useAuxiliaryStore = useAuxiliaryStoreLocal;
|
|
|
38
38
|
* - https://github.com/pmndrs/zustand#using-subscribe-with-selector
|
|
39
39
|
* @returns {function} The useStore hook.
|
|
40
40
|
*/
|
|
41
|
-
export const createViewConfigStore = () => create(set => ({
|
|
41
|
+
export const createViewConfigStore = (initialLoaders, initialConfig) => create(set => ({
|
|
42
42
|
// State:
|
|
43
43
|
// The viewConfig is an object which must conform to the schema
|
|
44
44
|
// found in src/schemas/config.schema.json.
|
|
45
|
-
viewConfig:
|
|
45
|
+
viewConfig: initialConfig,
|
|
46
|
+
// Store the initial config so that its values can be used for resetting.
|
|
47
|
+
initialViewConfig: cloneDeep(initialConfig),
|
|
46
48
|
// The loaders object is a mapping from dataset ID to
|
|
47
49
|
// data type to loader object instance.
|
|
48
|
-
loaders:
|
|
50
|
+
loaders: initialLoaders,
|
|
49
51
|
// Reducer functions which update the state
|
|
50
52
|
// (although technically also part of state):
|
|
51
|
-
setViewConfig: viewConfig => set({ viewConfig }),
|
|
53
|
+
setViewConfig: viewConfig => set({ viewConfig, initialViewConfig: viewConfig }),
|
|
52
54
|
setLoaders: loaders => set({ loaders }),
|
|
53
55
|
setCoordinationValue: ({ parameter, scope, value }) => set(state => ({
|
|
54
56
|
viewConfig: {
|
|
@@ -181,6 +183,30 @@ const useGridSizeStore = create(set => ({
|
|
|
181
183
|
})),
|
|
182
184
|
}));
|
|
183
185
|
|
|
186
|
+
/**
|
|
187
|
+
* This hook uses the same logic as for the `values` part of
|
|
188
|
+
* the useCoordination hook, with the difference that it
|
|
189
|
+
* gets its values from the _initial_ view config rather
|
|
190
|
+
* than the current view config.
|
|
191
|
+
* @param {string[]} parameters Array of coordination types.
|
|
192
|
+
* @param {object} coordinationScopes Mapping of coordination types
|
|
193
|
+
* to scope names.
|
|
194
|
+
* @returns {object} Object containing all coordination values.
|
|
195
|
+
*/
|
|
196
|
+
export function useInitialCoordination(parameters, coordinationScopes) {
|
|
197
|
+
const values = useViewConfigStore((state) => {
|
|
198
|
+
const { coordinationSpace } = state.initialViewConfig;
|
|
199
|
+
return fromEntries(parameters.map((parameter) => {
|
|
200
|
+
if (coordinationSpace && coordinationSpace[parameter]) {
|
|
201
|
+
const value = coordinationSpace[parameter][coordinationScopes[parameter]];
|
|
202
|
+
return [parameter, value];
|
|
203
|
+
}
|
|
204
|
+
return [parameter, undefined];
|
|
205
|
+
}));
|
|
206
|
+
}, shallow);
|
|
207
|
+
return values;
|
|
208
|
+
}
|
|
209
|
+
|
|
184
210
|
/**
|
|
185
211
|
* The useCoordination hook returns both the
|
|
186
212
|
* values and setter functions for the coordination objects
|
|
@@ -434,6 +460,37 @@ export function useLoaders() {
|
|
|
434
460
|
return useViewConfigStore(state => state.loaders);
|
|
435
461
|
}
|
|
436
462
|
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Find a specific loader instance for a particular dataset, data type, and view
|
|
466
|
+
* coordination values (mapping from coordination types to coordination values).
|
|
467
|
+
* Uses lodash/isMatch to perform matching against the file definition's
|
|
468
|
+
* coordination value mapping.
|
|
469
|
+
* @param {object} loaders The value returned by useLoaders.
|
|
470
|
+
* @param {string} dataset The dataset UID.
|
|
471
|
+
* @param {string} dataType The data type for the matching file.
|
|
472
|
+
* @param {object} viewCoordinationValues Current coordination values
|
|
473
|
+
* from the view. Match these against a subset of file definition coordination
|
|
474
|
+
* values.
|
|
475
|
+
* @returns The matching loader instance or `null`.
|
|
476
|
+
*/
|
|
477
|
+
export function getMatchingLoader(loaders, dataset, dataType, viewCoordinationValues) {
|
|
478
|
+
if (!loaders[dataset]) {
|
|
479
|
+
return null;
|
|
480
|
+
}
|
|
481
|
+
const loaderInternMap = loaders[dataset].loaders[dataType];
|
|
482
|
+
if (!loaderInternMap) {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
const loaderKeys = Array.from(loaderInternMap.keys());
|
|
486
|
+
const matchingKey = loaderKeys
|
|
487
|
+
.find(fileCoordinationValues => isMatch(fileCoordinationValues, viewCoordinationValues));
|
|
488
|
+
if (!matchingKey) {
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
return loaderInternMap.get(matchingKey);
|
|
492
|
+
}
|
|
493
|
+
|
|
437
494
|
/**
|
|
438
495
|
* Find a specific loader instance for a particular dataset, data type, and view
|
|
439
496
|
* coordination values (mapping from coordination types to coordination values).
|
|
@@ -448,22 +505,9 @@ export function useLoaders() {
|
|
|
448
505
|
* @returns The matching loader instance or `null`.
|
|
449
506
|
*/
|
|
450
507
|
export function useMatchingLoader(loaders, dataset, dataType, viewCoordinationValues) {
|
|
451
|
-
return useMemo(() =>
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
const loaderInternMap = loaders[dataset].loaders[dataType];
|
|
456
|
-
if (!loaderInternMap) {
|
|
457
|
-
return null;
|
|
458
|
-
}
|
|
459
|
-
const loaderKeys = Array.from(loaderInternMap.keys());
|
|
460
|
-
const matchingKey = loaderKeys
|
|
461
|
-
.find(fileCoordinationValues => isMatch(fileCoordinationValues, viewCoordinationValues));
|
|
462
|
-
if (!matchingKey) {
|
|
463
|
-
return null;
|
|
464
|
-
}
|
|
465
|
-
return loaderInternMap.get(matchingKey);
|
|
466
|
-
}, [loaders, dataset, dataType, viewCoordinationValues]);
|
|
508
|
+
return useMemo(() => getMatchingLoader(
|
|
509
|
+
loaders, dataset, dataType, viewCoordinationValues,
|
|
510
|
+
), [loaders, dataset, dataType, viewCoordinationValues]);
|
|
467
511
|
}
|
|
468
512
|
|
|
469
513
|
/**
|
|
@@ -471,6 +515,7 @@ export function useMatchingLoader(loaders, dataset, dataType, viewCoordinationVa
|
|
|
471
515
|
* coordination values (mapping from coordination types to coordination values).
|
|
472
516
|
* Uses lodash/isMatch to perform matching against the file definition's
|
|
473
517
|
* coordination value mapping.
|
|
518
|
+
* TODO: can this function be removed?
|
|
474
519
|
* @param {object} loaders The value returned by useLoaders.
|
|
475
520
|
* @param {string} dataset The dataset UID.
|
|
476
521
|
* @param {string} dataType The data type for the matching file.
|
package/src/view-config-utils.js
CHANGED
|
@@ -4,8 +4,16 @@ import { cloneDeep } from 'lodash-es';
|
|
|
4
4
|
import { fromEntries, getNextScope } from '@vitessce/utils';
|
|
5
5
|
import {
|
|
6
6
|
AUTO_INDEPENDENT_COORDINATION_TYPES,
|
|
7
|
+
META_VERSION,
|
|
7
8
|
} from '@vitessce/constants-internal';
|
|
8
9
|
|
|
10
|
+
export function logConfig(config, name) {
|
|
11
|
+
console.groupCollapsed(`🚄 VitS (${META_VERSION.version}) ${name}`);
|
|
12
|
+
console.info(`data:,${JSON.stringify(config)}`);
|
|
13
|
+
console.info(JSON.stringify(config, null, 2));
|
|
14
|
+
console.groupEnd();
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* Get a list of all unique scope names for a
|
|
11
19
|
* particular coordination type, which exist in
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
1
2
|
import '@testing-library/jest-dom';
|
|
2
3
|
import { cleanup, render, screen } from '@testing-library/react';
|
|
3
|
-
import { afterEach } from 'vitest';
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { PluginViewType } from '@vitessce/plugins';
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://github.com/vitessce/vitessce/#dataset",
|
|
4
|
-
"title": "Vitessce data set",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"definitions": {
|
|
7
|
-
"components": {
|
|
8
|
-
"type": "array",
|
|
9
|
-
"items": {
|
|
10
|
-
"type": "object",
|
|
11
|
-
"additionalProperties": false,
|
|
12
|
-
"required": ["component", "x", "y"],
|
|
13
|
-
"properties": {
|
|
14
|
-
"component": { "type": "string" },
|
|
15
|
-
"props": { "type": "object" },
|
|
16
|
-
"x": { "type": "integer" },
|
|
17
|
-
"y": { "type": "integer" },
|
|
18
|
-
"w": { "type": "integer" },
|
|
19
|
-
"h": { "type": "integer" }
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"requestInit": {
|
|
24
|
-
"type": "object",
|
|
25
|
-
"additionalProperties": false,
|
|
26
|
-
"required": [],
|
|
27
|
-
"properties": {
|
|
28
|
-
"method": {
|
|
29
|
-
"type": "string"
|
|
30
|
-
},
|
|
31
|
-
"headers": {
|
|
32
|
-
"type": "object"
|
|
33
|
-
},
|
|
34
|
-
"body": {
|
|
35
|
-
"type": "string"
|
|
36
|
-
},
|
|
37
|
-
"mode": {
|
|
38
|
-
"type": "string"
|
|
39
|
-
},
|
|
40
|
-
"credentials": {
|
|
41
|
-
"type": "string"
|
|
42
|
-
},
|
|
43
|
-
"cache": {
|
|
44
|
-
"type": "string"
|
|
45
|
-
},
|
|
46
|
-
"redirect": {
|
|
47
|
-
"type": "string"
|
|
48
|
-
},
|
|
49
|
-
"referrer": {
|
|
50
|
-
"type": "string"
|
|
51
|
-
},
|
|
52
|
-
"integrity": {
|
|
53
|
-
"type": "string"
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"additionalProperties": false,
|
|
59
|
-
"required": ["version", "name", "layers"],
|
|
60
|
-
"properties": {
|
|
61
|
-
"name": { "type": "string" },
|
|
62
|
-
"public": { "type": "boolean" },
|
|
63
|
-
"description": { "type": "string" },
|
|
64
|
-
"layers": {
|
|
65
|
-
"type": "array",
|
|
66
|
-
"items": {
|
|
67
|
-
"type": "object",
|
|
68
|
-
"additionalProperties": false,
|
|
69
|
-
"required": ["name", "type", "fileType", "url"],
|
|
70
|
-
"properties": {
|
|
71
|
-
"name": { "type": "string" },
|
|
72
|
-
"type": { "type": "string" },
|
|
73
|
-
"fileType": { "type": "string" },
|
|
74
|
-
"url": { "type": "string" },
|
|
75
|
-
"requestInit": { "$ref": "#/definitions/requestInit" }
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"staticLayout": { "$ref": "#/definitions/components" },
|
|
80
|
-
"version": {
|
|
81
|
-
"type": "string", "enum": ["0.1.0"]
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|