@vitessce/vit-s 2.0.2 → 2.0.3-beta.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/LoadingIndicator.js +1 -1
- package/dist/TitleInfo.js +5 -5
- package/dist/VitS.js +10 -5
- package/dist/Vitessce.integration.test.js +36 -0
- package/dist/Vitessce.js +101 -0
- package/dist/Warning.js +4 -4
- package/dist/export-utils.js +70 -0
- package/dist/export-utils.test.js +66 -0
- package/dist/loader-registry.js +98 -0
- package/dist/schemas/PrettyJsonSchema.js +34 -0
- package/dist/schemas/config-1.0.16.schema.json +1109 -0
- package/dist/schemas/config-1.0.16.schema.test.js +22 -0
- package/dist/schemas/obs-sets-tabular.schema.js +37 -0
- package/dist/schemas/obs-sets.schema.js +194 -0
- package/dist/schemas/schema.test.js +46 -0
- package/dist/schemas-extra.js +3 -0
- package/dist/shared-mui/container.js +2 -2
- package/dist/shared-mui/styles.js +44 -10
- package/dist/shared-plot-options/styles.js +1 -1
- package/package.json +3 -3
package/dist/LoadingIndicator.js
CHANGED
package/dist/TitleInfo.js
CHANGED
|
@@ -85,7 +85,7 @@ export const useTitleStyles = makeStyles(theme => ({
|
|
|
85
85
|
overflow: 'hidden',
|
|
86
86
|
fontSize: '80% !important',
|
|
87
87
|
opacity: '.8',
|
|
88
|
-
padding: '0
|
|
88
|
+
padding: '0 4px',
|
|
89
89
|
justifyContent: 'center',
|
|
90
90
|
lineHeight: '25px !important',
|
|
91
91
|
flexShrink: '1',
|
|
@@ -105,16 +105,16 @@ export const useTitleStyles = makeStyles(theme => ({
|
|
|
105
105
|
border: `1px solid ${theme.palette.cardBorder}`,
|
|
106
106
|
flex: '1 1 auto',
|
|
107
107
|
minHeight: '1px',
|
|
108
|
-
padding: '
|
|
109
|
-
marginTop: '
|
|
110
|
-
marginBottom: '
|
|
108
|
+
padding: '12px',
|
|
109
|
+
marginTop: '8px',
|
|
110
|
+
marginBottom: '8px',
|
|
111
111
|
position: 'relative',
|
|
112
112
|
display: 'flex',
|
|
113
113
|
flexDirection: 'column',
|
|
114
114
|
minWidth: '0',
|
|
115
115
|
wordWrap: 'break-word',
|
|
116
116
|
backgroundClip: 'border-box',
|
|
117
|
-
borderRadius: '
|
|
117
|
+
borderRadius: '4px',
|
|
118
118
|
},
|
|
119
119
|
noScrollCard: {
|
|
120
120
|
backgroundColor: theme.palette.secondaryBackground,
|
package/dist/VitS.js
CHANGED
|
@@ -11,10 +11,6 @@ import { Warning } from './Warning';
|
|
|
11
11
|
import CallbackPublisher from './CallbackPublisher';
|
|
12
12
|
import { getComponent } from './component-registry';
|
|
13
13
|
import { checkTypes, initialize, upgradeAndValidate, } from './view-config-utils';
|
|
14
|
-
const generateClassName = createGenerateClassName({
|
|
15
|
-
disableGlobal: false,
|
|
16
|
-
productionPrefix: 'vit', // Avoid conflicts with portal-ui MUI class names
|
|
17
|
-
});
|
|
18
14
|
function logConfig(config, name) {
|
|
19
15
|
console.groupCollapsed(`🚄 Vitessce (${META_VERSION.version}) ${name}`);
|
|
20
16
|
console.info(`data:,${JSON.stringify(config)}`);
|
|
@@ -39,9 +35,18 @@ function logConfig(config, name) {
|
|
|
39
35
|
* @param {boolean} props.validateOnConfigChange Whether to validate
|
|
40
36
|
* against the view config schema when publishing changes. Use for debugging
|
|
41
37
|
* purposes, as this may have a performance impact. By default, false.
|
|
38
|
+
* @param {undefined|string} props.uid A unique identifier for this Vitessce instance,
|
|
39
|
+
* for the purpose of avoiding CSS autogenerated class name conflicts. Must be valid as part
|
|
40
|
+
* of a CSS class name string.
|
|
42
41
|
*/
|
|
43
42
|
export function VitS(props) {
|
|
44
|
-
const { config, rowHeight, height, theme, onWarn, onConfigChange, onLoaderChange, validateOnConfigChange = false, onConfigUpgrade, isBounded = false, } = props;
|
|
43
|
+
const { config, rowHeight, height, theme, onWarn, onConfigChange, onLoaderChange, validateOnConfigChange = false, onConfigUpgrade, isBounded = false, uid, } = props;
|
|
44
|
+
const generateClassName = useMemo(() => createGenerateClassName({
|
|
45
|
+
disableGlobal: false,
|
|
46
|
+
// Avoid conflicts with portal-ui MUI class names,
|
|
47
|
+
// and allow setting a UID.
|
|
48
|
+
productionPrefix: (uid ? `vit${uid}` : 'vit'),
|
|
49
|
+
}), [uid]);
|
|
45
50
|
// Process the view config and memoize the result:
|
|
46
51
|
// - Validate.
|
|
47
52
|
// - Upgrade, if legacy schema.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
// import React from 'react';
|
|
4
|
+
// import Adapter from 'enzyme-adapter-react-16';
|
|
5
|
+
// import { mount, configure } from 'enzyme';
|
|
6
|
+
// import Ajv from 'ajv';
|
|
7
|
+
// import expect from 'expect';
|
|
8
|
+
// import Vitessce from './Vitessce';
|
|
9
|
+
// import { configs } from './api';
|
|
10
|
+
// import configSchema from '../schemas/config.schema.json';
|
|
11
|
+
// configure({ adapter: new Adapter() });
|
|
12
|
+
// describe('Vitessce.js', () => {
|
|
13
|
+
// describe('<Vitessce />', () => {
|
|
14
|
+
// it('Produces valid view config', (done) => {
|
|
15
|
+
// const config = configs['linnarsson-2018'];
|
|
16
|
+
// let updatedConfig = {};
|
|
17
|
+
// // eslint-disable-next-line no-return-assign
|
|
18
|
+
// const wrapper = mount(<Vitessce config={config} onConfigChange={c => updatedConfig = c} />);
|
|
19
|
+
// setTimeout(() => {
|
|
20
|
+
// // Simulate usage of some of the app
|
|
21
|
+
// wrapper.find('[id^="deckgl-overlay-"]').at(0).simulate('wheel', { deltaY: 1000, deltaX: 1000 });
|
|
22
|
+
// wrapper.find('[id^="deckgl-overlay-"]').at(1).simulate('wheel', { deltaY: 1000, deltaX: 1000 });
|
|
23
|
+
// wrapper.find('[id^="deckgl-overlay-"]').at(2).simulate('wheel', { deltaY: 1000, deltaX: 1000 });
|
|
24
|
+
// const validate = new Ajv().compile(configSchema);
|
|
25
|
+
// const valid = validate(updatedConfig);
|
|
26
|
+
// if (!valid) {
|
|
27
|
+
// const failureReason = JSON.stringify(validate.errors, null, 2);
|
|
28
|
+
// console.error(failureReason);
|
|
29
|
+
// }
|
|
30
|
+
// expect(valid).toEqual(true);
|
|
31
|
+
// wrapper.unmount();
|
|
32
|
+
// done();
|
|
33
|
+
// }, 20000);
|
|
34
|
+
// }).timeout(30000);
|
|
35
|
+
// });
|
|
36
|
+
// });
|
package/dist/Vitessce.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable camelcase */
|
|
3
|
+
import React, { useEffect, useMemo } from 'react';
|
|
4
|
+
import { ThemeProvider, StylesProvider, createGenerateClassName, } from '@material-ui/core/styles';
|
|
5
|
+
import isEqual from 'lodash/isEqual';
|
|
6
|
+
import { muiTheme } from './shared-mui/styles';
|
|
7
|
+
import { ViewConfigProvider, createViewConfigStore, AuxiliaryProvider, createAuxiliaryStore, } from './state/hooks';
|
|
8
|
+
import VitessceGrid from './VitessceGrid';
|
|
9
|
+
import { Warning } from './Warning';
|
|
10
|
+
import CallbackPublisher from './CallbackPublisher';
|
|
11
|
+
import { getComponent } from './component-registry';
|
|
12
|
+
import { checkTypes, initialize, upgradeAndValidate } from './view-config-utils';
|
|
13
|
+
// TODO(monorepo): figure out how to get the current package version from package.json
|
|
14
|
+
// import packageJson from '../package.json';
|
|
15
|
+
const packageJson = { version: 'unk' };
|
|
16
|
+
const generateClassName = createGenerateClassName({
|
|
17
|
+
disableGlobal: true,
|
|
18
|
+
});
|
|
19
|
+
function logConfig(config, name) {
|
|
20
|
+
console.groupCollapsed(`🚄 Vitessce (${packageJson.version}) ${name}`);
|
|
21
|
+
console.info(`data:,${JSON.stringify(config)}`);
|
|
22
|
+
console.info(JSON.stringify(config, null, 2));
|
|
23
|
+
console.groupEnd();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The Vitessce component.
|
|
27
|
+
* @param {object} props
|
|
28
|
+
* @param {object} props.config A Vitessce view config.
|
|
29
|
+
* If the config is valid, the VitessceGrid will be rendered as a child.
|
|
30
|
+
* If the config is invalid, a Warning will be rendered instead.
|
|
31
|
+
* @param {number} props.rowHeight Row height for grid layout. Optional.
|
|
32
|
+
* @param {number} props.height Total height for grid layout. Optional.
|
|
33
|
+
* @param {string} props.theme The theme, used for styling as
|
|
34
|
+
* light or dark. Optional. By default, "dark"
|
|
35
|
+
* @param {function} props.onWarn A callback for warning messages. Optional.
|
|
36
|
+
* @param {function} props.onConfigChange A callback for view config
|
|
37
|
+
* updates. Optional.
|
|
38
|
+
* @param {function} props.onLoaderChange A callback for loader
|
|
39
|
+
* updates. Optional.
|
|
40
|
+
* @param {boolean} props.validateOnConfigChange Whether to validate
|
|
41
|
+
* against the view config schema when publishing changes. Use for debugging
|
|
42
|
+
* purposes, as this may have a performance impact. By default, false.
|
|
43
|
+
*/
|
|
44
|
+
export function Vitessce(props) {
|
|
45
|
+
const { config, rowHeight, height, theme, onWarn, onConfigChange, onLoaderChange, validateOnConfigChange = false, onConfigUpgrade, isBounded = false, } = props;
|
|
46
|
+
// Process the view config and memoize the result:
|
|
47
|
+
// - Validate.
|
|
48
|
+
// - Upgrade, if legacy schema.
|
|
49
|
+
// - Validate after upgrade, if legacy schema.
|
|
50
|
+
// - Initialize (based on initStrategy).
|
|
51
|
+
const [configOrWarning, success] = useMemo(() => {
|
|
52
|
+
// If the config value is undefined, show a warning message.
|
|
53
|
+
if (!config) {
|
|
54
|
+
return [{
|
|
55
|
+
title: 'No such dataset',
|
|
56
|
+
unformatted: 'The dataset configuration could not be found.',
|
|
57
|
+
}, false];
|
|
58
|
+
}
|
|
59
|
+
// If the view config is missing a version, show a warning message.
|
|
60
|
+
if (!config.version) {
|
|
61
|
+
return [{
|
|
62
|
+
title: 'Missing version',
|
|
63
|
+
unformatted: 'The dataset configuration is missing a version, preventing validation.',
|
|
64
|
+
}, false];
|
|
65
|
+
}
|
|
66
|
+
logConfig(config, 'input view config');
|
|
67
|
+
// Check if this is a "legacy" view config.
|
|
68
|
+
const [upgradedConfig, upgradeSuccess] = upgradeAndValidate(config, onConfigUpgrade);
|
|
69
|
+
if (upgradeSuccess) {
|
|
70
|
+
logConfig(upgradedConfig, 'upgraded view config');
|
|
71
|
+
// Initialize the view config according to the initStrategy.
|
|
72
|
+
const [typeCheckSuccess, typeCheckMessage] = checkTypes(upgradedConfig);
|
|
73
|
+
if (typeCheckSuccess) {
|
|
74
|
+
try {
|
|
75
|
+
const initializedConfig = initialize(upgradedConfig);
|
|
76
|
+
logConfig(initializedConfig, 'initialized view config');
|
|
77
|
+
return [initializedConfig, true];
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
return [{
|
|
81
|
+
title: 'View config initialization failed.',
|
|
82
|
+
unformatted: e.message,
|
|
83
|
+
}, false];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return [{
|
|
87
|
+
title: 'View config checks failed.',
|
|
88
|
+
unformatted: typeCheckMessage,
|
|
89
|
+
}, false];
|
|
90
|
+
}
|
|
91
|
+
return [upgradedConfig, false];
|
|
92
|
+
}, [config, onConfigUpgrade]);
|
|
93
|
+
// Emit the upgraded/initialized view config
|
|
94
|
+
// to onConfigChange if necessary.
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (success && !isEqual(configOrWarning, config) && onConfigChange) {
|
|
97
|
+
onConfigChange(configOrWarning);
|
|
98
|
+
}
|
|
99
|
+
}, [success, config, configOrWarning, onConfigChange]);
|
|
100
|
+
return success ? (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(ViewConfigProvider, { createStore: createViewConfigStore, children: _jsxs(AuxiliaryProvider, { createStore: createAuxiliaryStore, children: [_jsx(VitessceGrid, { config: configOrWarning, getComponent: getComponent, rowHeight: rowHeight, height: height, theme: theme, isBounded: isBounded }), _jsx(CallbackPublisher, { onWarn: onWarn, onConfigChange: onConfigChange, onLoaderChange: onLoaderChange, validateOnConfigChange: validateOnConfigChange })] }) }) }) })) : (_jsx(StylesProvider, { generateClassName: generateClassName, children: _jsx(ThemeProvider, { theme: muiTheme[theme], children: _jsx(Warning, { ...configOrWarning }) }) }));
|
|
101
|
+
}
|
package/dist/Warning.js
CHANGED
|
@@ -24,16 +24,16 @@ const useStyles = makeStyles(theme => ({
|
|
|
24
24
|
border: `1px solid ${theme.palette.cardBorder}`,
|
|
25
25
|
flex: '1 1 auto',
|
|
26
26
|
minHeight: '1px',
|
|
27
|
-
padding: '
|
|
28
|
-
marginTop: '
|
|
29
|
-
marginBottom: '
|
|
27
|
+
padding: '12px',
|
|
28
|
+
marginTop: '8px',
|
|
29
|
+
marginBottom: '8px',
|
|
30
30
|
position: 'relative',
|
|
31
31
|
display: 'flex',
|
|
32
32
|
flexDirection: 'column',
|
|
33
33
|
minWidth: '0',
|
|
34
34
|
wordWrap: 'break-word',
|
|
35
35
|
backgroundClip: 'border-box',
|
|
36
|
-
borderRadius: '
|
|
36
|
+
borderRadius: '4px',
|
|
37
37
|
backgroundColor: theme.palette.primaryBackground,
|
|
38
38
|
color: theme.palette.primaryForeground,
|
|
39
39
|
},
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Bowser from 'bowser';
|
|
2
|
+
import { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string';
|
|
3
|
+
const CURRENT_VERSION = '0.0.1';
|
|
4
|
+
const VITESSCE_CONF_QUERY_STRING = 'vitessce_conf';
|
|
5
|
+
const VERSION_QUERY_STRING = 'vitessce_conf_version';
|
|
6
|
+
const LENGTH_QUERY_STRING = 'vitessce_conf_length';
|
|
7
|
+
function sniffBrowser() {
|
|
8
|
+
const { browser } = Bowser.parse(window.navigator.userAgent);
|
|
9
|
+
return browser.name;
|
|
10
|
+
}
|
|
11
|
+
// https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
|
|
12
|
+
const MAX_BROWSER_URL_LENGTHS = {
|
|
13
|
+
Chrome: 32779,
|
|
14
|
+
'Internet Explorer': 2047,
|
|
15
|
+
Edge: 2047,
|
|
16
|
+
Safari: 65000,
|
|
17
|
+
Firefox: 65000,
|
|
18
|
+
};
|
|
19
|
+
export default class CompressedConfLengthError {
|
|
20
|
+
constructor(message) {
|
|
21
|
+
this.message = message;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Encode a configuration as url params with a version and an lz-compressed conf.
|
|
26
|
+
* @param {Object} params
|
|
27
|
+
* @param {Object} params.conf Previous scope names.
|
|
28
|
+
* @param {function} params.onOverMaximumUrlLength Callback for when new url
|
|
29
|
+
* is over max length for your browser - takes two arguments: { message, willWorkOn }
|
|
30
|
+
* for the error message and the browsers for which the url will work (optional).
|
|
31
|
+
* @returns {string} The new params like
|
|
32
|
+
* vitessce_conf_length=10&vitessce_conf_version=0.0.1&vitessce_conf=fksdfasdfjkl
|
|
33
|
+
*/
|
|
34
|
+
export function encodeConfInUrl({ conf, onOverMaximumUrlLength = () => { }, }) {
|
|
35
|
+
const compressedConf = compressToEncodedURIComponent(JSON.stringify(conf));
|
|
36
|
+
const newParams = `${LENGTH_QUERY_STRING}=${compressedConf.length}&${VERSION_QUERY_STRING}=${CURRENT_VERSION}&${VITESSCE_CONF_QUERY_STRING}=${compressedConf}`;
|
|
37
|
+
const browser = sniffBrowser();
|
|
38
|
+
const maxLength = MAX_BROWSER_URL_LENGTHS[browser];
|
|
39
|
+
if (newParams.length > maxLength) {
|
|
40
|
+
const willWorkOn = Object.entries(MAX_BROWSER_URL_LENGTHS)
|
|
41
|
+
.filter(entry => entry[1] > newParams.length)
|
|
42
|
+
.map(entry => entry[0]);
|
|
43
|
+
const message = `Configuration is ${compressedConf.length} characters; max URL for ${browser} is ${maxLength}: it will work on ${willWorkOn.join(', ') || 'no browser'}.`;
|
|
44
|
+
console.error(message);
|
|
45
|
+
onOverMaximumUrlLength({ message, willWorkOn });
|
|
46
|
+
}
|
|
47
|
+
return newParams;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Decode URL params to a Vitessce configuration.
|
|
51
|
+
* The URL params must have version and vitessce_conf params,
|
|
52
|
+
* like vitessce_conf_length=10&vitessce_conf_version=0.0.1&vitessce_conf=fksdfasdfjkl.
|
|
53
|
+
* @param {Object} queryString The URL params,
|
|
54
|
+
* like vitessce_conf_length=10&vitessce_conf_version=0.0.1&vitessce_conf=fksdfasdfjkl.
|
|
55
|
+
* @returns {string} A vitessce configuration.
|
|
56
|
+
*/
|
|
57
|
+
export function decodeURLParamsToConf(queryString) {
|
|
58
|
+
const params = new URLSearchParams(queryString.replace('#', '&'));
|
|
59
|
+
const compressedConfString = params.get(VITESSCE_CONF_QUERY_STRING);
|
|
60
|
+
const expectedConfLength = Number(params.get(LENGTH_QUERY_STRING));
|
|
61
|
+
if (expectedConfLength !== compressedConfString.length) {
|
|
62
|
+
throw new CompressedConfLengthError(`Compressed conf length (${compressedConfString.length}) != expected (${expectedConfLength}). URL truncated?`);
|
|
63
|
+
}
|
|
64
|
+
const version = params.get(VERSION_QUERY_STRING);
|
|
65
|
+
if (version === CURRENT_VERSION) {
|
|
66
|
+
const conf = JSON.parse(decompressFromEncodedURIComponent(compressedConfString));
|
|
67
|
+
return conf;
|
|
68
|
+
}
|
|
69
|
+
throw new Error('Unrecognized URL Param Version');
|
|
70
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import expect from 'expect';
|
|
2
|
+
import { encodeConfInUrl, decodeURLParamsToConf, } from './export-utils';
|
|
3
|
+
const fakeConfig = {
|
|
4
|
+
version: '0.1.0',
|
|
5
|
+
public: false,
|
|
6
|
+
layers: [
|
|
7
|
+
{
|
|
8
|
+
name: 'cells',
|
|
9
|
+
type: 'CELLS',
|
|
10
|
+
fileType: 'cells.json',
|
|
11
|
+
url: 'http://example.com/cells.json',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
name: 'Just scatterplot',
|
|
15
|
+
staticLayout: [
|
|
16
|
+
{
|
|
17
|
+
component: 'scatterplot',
|
|
18
|
+
props: {
|
|
19
|
+
mapping: 't-SNE',
|
|
20
|
+
view: {
|
|
21
|
+
zoom: 0.75,
|
|
22
|
+
target: [0, 0, 0],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
x: 0,
|
|
26
|
+
y: 0,
|
|
27
|
+
w: 12,
|
|
28
|
+
h: 2,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
function makeLongString(length) {
|
|
33
|
+
let result = '';
|
|
34
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
35
|
+
const charactersLength = characters.length;
|
|
36
|
+
// eslint-disable-next-line no-plusplus
|
|
37
|
+
for (let i = 0; i < length; i++) {
|
|
38
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
describe('src/app/export-utils.js', () => {
|
|
43
|
+
describe('encodeConfInUrl', () => {
|
|
44
|
+
it('encodes a view config for a URL', () => {
|
|
45
|
+
const urlParams1 = encodeConfInUrl({ conf: {} });
|
|
46
|
+
expect(urlParams1).toEqual('vitessce_conf_length=5&vitessce_conf_version=0.0.1&vitessce_conf=N4XyA');
|
|
47
|
+
const urlParams2 = encodeConfInUrl({ conf: fakeConfig });
|
|
48
|
+
expect(urlParams2).toEqual('vitessce_conf_length=327&vitessce_conf_version=0.0.1&vitessce_conf=N4IgbgpgTgzglgewHYgFwgAwDoCMWMgA0IADgK4BGANnAMZoBmAhlTBMVUwJ7QxoDaoJEwC2ENCFoQqrIiAAuXEuPQBhAKIAZTQGU5DOFQgAVJSsnTWWAFYxkcslCoSAFvPklUAei8QAHqIkRli0CCJeUjIwNnYoAL4AusTCYhIAUmQw8gAEMLRM7tBBCPJyWQV0mtwIZKWogpJhJMgQSHUgeQXyRVQlciRQCCR8qKAiTCQkcEgA5hLyALQ6AHLqcmBwEADuaKAAXghhaNgA7ACsxPJMUDMQdfwYhI8YCXFxxH7HxFxfIDuoOAATMQXGhAYk4kA');
|
|
49
|
+
});
|
|
50
|
+
it('Calls onOverMaximumUrlLength for conf too long', () => {
|
|
51
|
+
let browsers;
|
|
52
|
+
// eslint-disable-next-line no-return-assign
|
|
53
|
+
const onOverMaximumUrlLength = ({ willWorkOn }) => browsers = willWorkOn;
|
|
54
|
+
encodeConfInUrl({ conf: { foo: makeLongString(69000) }, onOverMaximumUrlLength });
|
|
55
|
+
expect(browsers).toEqual([]);
|
|
56
|
+
encodeConfInUrl({ conf: { foo: makeLongString(37000) }, onOverMaximumUrlLength });
|
|
57
|
+
expect(browsers).toEqual(['Safari', 'Firefox']);
|
|
58
|
+
});
|
|
59
|
+
it('decodes a view config for a URL', () => {
|
|
60
|
+
const viewConfig1 = decodeURLParamsToConf('vitessce_conf_length=5&vitessce_conf_version=0.0.1&vitessce_conf=N4XyA');
|
|
61
|
+
expect(viewConfig1).toEqual({});
|
|
62
|
+
const viewConfig2 = decodeURLParamsToConf('vitessce_conf_length=327&vitessce_conf_version=0.0.1&vitessce_conf=N4IgbgpgTgzglgewHYgFwgAwDoCMWMgA0IADgK4BGANnAMZoBmAhlTBMVUwJ7QxoDaoJEwC2ENCFoQqrIiAAuXEuPQBhAKIAZTQGU5DOFQgAVJSsnTWWAFYxkcslCoSAFvPklUAei8QAHqIkRli0CCJeUjIwNnYoAL4AusTCYhIAUmQw8gAEMLRM7tBBCPJyWQV0mtwIZKWogpJhJMgQSHUgeQXyRVQlciRQCCR8qKAiTCQkcEgA5hLyALQ6AHLqcmBwEADuaKAAXghhaNgA7ACsxPJMUDMQdfwYhI8YCXFxxH7HxFxfIDuoOAATMQXGhAYk4kA');
|
|
63
|
+
expect(viewConfig2).toEqual(fakeConfig);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { getLoaderClassesForPluginFileType, } from './plugins';
|
|
2
|
+
// TODO(monorepo)
|
|
3
|
+
/*
|
|
4
|
+
import {
|
|
5
|
+
AnnDataSource,
|
|
6
|
+
ZarrDataSource,
|
|
7
|
+
JsonSource,
|
|
8
|
+
CsvSource,
|
|
9
|
+
} from './data-sources';
|
|
10
|
+
import JsonLoader from './json-loaders/JsonLoader';
|
|
11
|
+
import ObsSetsJsonLoader from './json-loaders/ObsSetsJson';
|
|
12
|
+
import ObsSegmentationsJsonLoader from './json-loaders/ObsSegmentationsJson';
|
|
13
|
+
import OmeZarrLoader from './OmeZarrLoader';
|
|
14
|
+
import AnnDataLoaders from './anndata-loaders';
|
|
15
|
+
import GenomicProfilesZarrLoader from './GenomicProfilesZarrLoader';
|
|
16
|
+
import CellsJsonAsObsLabelsLoader from './legacy-loaders/CellsJsonAsObsLabels';
|
|
17
|
+
import CellsJsonAsObsEmbeddingLoader from './legacy-loaders/CellsJsonAsObsEmbedding';
|
|
18
|
+
import CellsJsonAsObsSegmentationsLoader from './legacy-loaders/CellsJsonAsObsSegmentations';
|
|
19
|
+
import ClustersJsonAsObsFeatureMatrixLoader from './legacy-loaders/ClustersJsonAsObsFeatureMatrix';
|
|
20
|
+
import GenesJsonAsObsFeatureMatrixLoader from './legacy-loaders/GenesJsonAsObsFeatureMatrix';
|
|
21
|
+
import RasterJsonAsImageLoader from './raster-json-loaders/RasterJsonAsImageLoader';
|
|
22
|
+
import RasterJsonAsObsSegmentationsLoader from './raster-json-loaders/RasterJsonAsObsSegmentationsLoader';
|
|
23
|
+
import MatrixZarrAsObsFeatureMatrixLoader from './matrix-loaders/MatrixZarrAsObsFeatureMatrix';
|
|
24
|
+
import MoleculesJsonAsObsLocationsLoader from './legacy-loaders/MoleculesJsonAsObsLocations';
|
|
25
|
+
import MoleculesJsonAsObsLabelsLoader from './legacy-loaders/MoleculesJsonAsObsLabels';
|
|
26
|
+
import CellsJsonAsObsLocationsLoader from './legacy-loaders/CellsJsonAsObsLocations';
|
|
27
|
+
import ObsEmbeddingCsvLoader from './csv-loaders/ObsEmbeddingCsv';
|
|
28
|
+
import ObsLocationsCsvLoader from './csv-loaders/ObsLocationsCsv';
|
|
29
|
+
import ObsLabelsCsvLoader from './csv-loaders/ObsLabelsCsv';
|
|
30
|
+
import FeatureLabelsCsvLoader from './csv-loaders/FeatureLabelsCsv';
|
|
31
|
+
import ObsFeatureMatrixCsvLoader from './csv-loaders/ObsFeatureMatrixCsv';
|
|
32
|
+
import ObsSetsCsvLoader from './csv-loaders/ObsSetsCsv';
|
|
33
|
+
*/
|
|
34
|
+
export const fileTypeToLoaderAndSource = {
|
|
35
|
+
// TODO(monorepo)
|
|
36
|
+
/*
|
|
37
|
+
[FileType.OBS_EMBEDDING_CSV]: [CsvSource, ObsEmbeddingCsvLoader],
|
|
38
|
+
[FileType.OBS_LOCATIONS_CSV]: [CsvSource, ObsLocationsCsvLoader],
|
|
39
|
+
[FileType.OBS_LABELS_CSV]: [CsvSource, ObsLabelsCsvLoader],
|
|
40
|
+
[FileType.FEATURE_LABELS_CSV]: [CsvSource, FeatureLabelsCsvLoader],
|
|
41
|
+
[FileType.OBS_FEATURE_MATRIX_CSV]: [CsvSource, ObsFeatureMatrixCsvLoader],
|
|
42
|
+
[FileType.OBS_SEGMENTATIONS_JSON]: [JsonSource, ObsSegmentationsJsonLoader],
|
|
43
|
+
[FileType.OBS_SETS_CSV]: [CsvSource, ObsSetsCsvLoader],
|
|
44
|
+
[FileType.OBS_FEATURE_MATRIX_ANNDATA_ZARR]: [
|
|
45
|
+
AnnDataSource, AnnDataLoaders.ObsFeatureMatrixAnndataLoader,
|
|
46
|
+
],
|
|
47
|
+
[FileType.OBS_SETS_ANNDATA_ZARR]: [
|
|
48
|
+
AnnDataSource, AnnDataLoaders.ObsSetsAnndataLoader,
|
|
49
|
+
],
|
|
50
|
+
[FileType.OBS_EMBEDDING_ANNDATA_ZARR]: [
|
|
51
|
+
AnnDataSource, AnnDataLoaders.ObsEmbeddingAnndataLoader,
|
|
52
|
+
],
|
|
53
|
+
[FileType.OBS_LOCATIONS_ANNDATA_ZARR]: [
|
|
54
|
+
AnnDataSource, AnnDataLoaders.ObsLocationsAnndataLoader,
|
|
55
|
+
],
|
|
56
|
+
[FileType.OBS_SEGMENTATIONS_ANNDATA_ZARR]: [
|
|
57
|
+
AnnDataSource, AnnDataLoaders.ObsSegmentationsAnndataLoader,
|
|
58
|
+
],
|
|
59
|
+
[FileType.OBS_LABELS_ANNDATA_ZARR]: [
|
|
60
|
+
AnnDataSource, AnnDataLoaders.ObsLabelsAnndataLoader,
|
|
61
|
+
],
|
|
62
|
+
[FileType.OBS_FEATURE_MATRIX_EXPRESSION_MATRIX_ZARR]: [
|
|
63
|
+
ZarrDataSource, MatrixZarrAsObsFeatureMatrixLoader,
|
|
64
|
+
],
|
|
65
|
+
[FileType.FEATURE_LABELS_ANNDATA_ZARR]: [
|
|
66
|
+
AnnDataSource, AnnDataLoaders.FeatureLabelsAnndataLoader,
|
|
67
|
+
],
|
|
68
|
+
[FileType.IMAGE_OME_ZARR]: [ZarrDataSource, OmeZarrLoader],
|
|
69
|
+
[FileType.IMAGE_RASTER_JSON]: [JsonSource, RasterJsonAsImageLoader],
|
|
70
|
+
[FileType.OBS_SEGMENTATIONS_RASTER_JSON]: [JsonSource, RasterJsonAsObsSegmentationsLoader],
|
|
71
|
+
[FileType.OBS_SETS_JSON]: [JsonSource, ObsSetsJsonLoader],
|
|
72
|
+
[FileType.OBS_SETS_CELL_SETS_JSON]: [JsonSource, ObsSetsJsonLoader],
|
|
73
|
+
[FileType.OBS_FEATURE_MATRIX_CLUSTERS_JSON]: [JsonSource, ClustersJsonAsObsFeatureMatrixLoader],
|
|
74
|
+
[FileType.OBS_FEATURE_MATRIX_GENES_JSON]: [JsonSource, GenesJsonAsObsFeatureMatrixLoader],
|
|
75
|
+
[FileType.OBS_LABELS_CELLS_JSON]: [JsonSource, CellsJsonAsObsLabelsLoader],
|
|
76
|
+
[FileType.OBS_EMBEDDING_CELLS_JSON]: [JsonSource, CellsJsonAsObsEmbeddingLoader],
|
|
77
|
+
[FileType.OBS_LOCATIONS_CELLS_JSON]: [JsonSource, CellsJsonAsObsLocationsLoader],
|
|
78
|
+
[FileType.OBS_SEGMENTATIONS_CELLS_JSON]: [JsonSource, CellsJsonAsObsSegmentationsLoader],
|
|
79
|
+
[FileType.OBS_LOCATIONS_MOLECULES_JSON]: [JsonSource, MoleculesJsonAsObsLocationsLoader],
|
|
80
|
+
[FileType.OBS_LABELS_MOLECULES_JSON]: [JsonSource, MoleculesJsonAsObsLabelsLoader],
|
|
81
|
+
// Old mappings:
|
|
82
|
+
[FileType.NEIGHBORHOODS_JSON]: [JsonSource, JsonLoader],
|
|
83
|
+
[FileType.GENOMIC_PROFILES_ZARR]: [ZarrDataSource, GenomicProfilesZarrLoader],
|
|
84
|
+
*/
|
|
85
|
+
};
|
|
86
|
+
export function getSourceAndLoaderFromFileType(type) {
|
|
87
|
+
if (fileTypeToLoaderAndSource[type]) {
|
|
88
|
+
return fileTypeToLoaderAndSource[type];
|
|
89
|
+
}
|
|
90
|
+
const pluginFileType = getLoaderClassesForPluginFileType(type);
|
|
91
|
+
if (pluginFileType) {
|
|
92
|
+
return pluginFileType;
|
|
93
|
+
}
|
|
94
|
+
// Fallback to JSON.
|
|
95
|
+
// TODO(monorepo)
|
|
96
|
+
// return [JsonSource, JsonLoader];
|
|
97
|
+
return [null, null];
|
|
98
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import yaml from 'js-yaml'; // eslint-disable-line import/no-extraneous-dependencies
|
|
4
|
+
// This should only be used by docz, and should not be part of the app build.
|
|
5
|
+
function abbreviateType(yamlString) {
|
|
6
|
+
return yamlString.replace(/:\s+type: (\w+)/g, ' ($1):');
|
|
7
|
+
}
|
|
8
|
+
function abbreviateRef(yamlString) {
|
|
9
|
+
return yamlString.replace(/:\s+\$ref: '#\/definitions\/(\w+)'/g, ' ($1)');
|
|
10
|
+
}
|
|
11
|
+
function stripAddProps(yamlString) {
|
|
12
|
+
// This should be the default in our schemas, but we don't need it in the docs.
|
|
13
|
+
return yamlString.replace(/\s+additionalProperties: false/g, '');
|
|
14
|
+
}
|
|
15
|
+
function valuesAre(yamlString) {
|
|
16
|
+
return yamlString.replace(/patternProperties:\s+\./g, 'Object values are');
|
|
17
|
+
}
|
|
18
|
+
function hasProperties(yamlString) {
|
|
19
|
+
return yamlString.replace(/\.:\s+properties:/g, 'Each value has these properties:');
|
|
20
|
+
}
|
|
21
|
+
function pretty(title, obj) {
|
|
22
|
+
// This is entirely ad-hoc:
|
|
23
|
+
// It woks well for our schema, but no assertion that it should work for anyone else.
|
|
24
|
+
if (!obj)
|
|
25
|
+
return '';
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsx("h3", { children: title }), _jsx("pre", { children: hasProperties(valuesAre(stripAddProps(abbreviateRef(abbreviateType(yaml.safeDump(obj)))))) })] }));
|
|
27
|
+
}
|
|
28
|
+
export default function PrettyJsonSchema(props) {
|
|
29
|
+
const { children } = props;
|
|
30
|
+
const { definitions, patternProperties, properties } = children;
|
|
31
|
+
// We could grab the title as well, but when we output an <h2> it is not anchored;
|
|
32
|
+
// better to put the section headers in MD.
|
|
33
|
+
return (_jsxs("blockquote", { children: [pretty('Definitions', definitions), pretty('Properties', patternProperties), pretty('Properties', properties)] }));
|
|
34
|
+
}
|