@vitessce/vit-s 2.0.2 → 2.0.3

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.
Files changed (172) hide show
  1. package/dist/index.mjs +84801 -0
  2. package/{dist → dist-tsc}/index.js +2 -2
  3. package/package.json +7 -7
  4. package/src/CallbackPublisher.js +81 -0
  5. package/src/LoadingIndicator.js +34 -0
  6. package/src/TitleInfo.js +240 -0
  7. package/src/VitS.js +180 -0
  8. package/src/VitessceGrid.js +110 -0
  9. package/src/VitessceGrid.test.jsx +48 -0
  10. package/src/Warning.js +62 -0
  11. package/{dist → src}/classNames.js +0 -0
  12. package/src/component-registry.js +21 -0
  13. package/src/data/AbstractLoader.js +46 -0
  14. package/{dist → src}/data/AbstractTwoStepLoader.js +5 -4
  15. package/src/data/LoaderResult.js +8 -0
  16. package/{dist → src}/data/index.js +0 -0
  17. package/src/data/loader-registry.js +19 -0
  18. package/src/data-hook-utils.js +197 -0
  19. package/src/data-hooks.js +354 -0
  20. package/src/errors/AbstractLoaderError.js +14 -0
  21. package/src/errors/DataSourceFetchError.js +15 -0
  22. package/src/errors/DatasetNotFoundError.js +23 -0
  23. package/src/errors/LoaderNotFoundError.js +24 -0
  24. package/src/errors/LoaderValidationError.js +23 -0
  25. package/src/errors/OptionsValidationError.js +25 -0
  26. package/{dist → src}/errors/index.js +0 -0
  27. package/src/file-options-schemas-legacy.js +139 -0
  28. package/src/file-options-schemas-legacy.test.js +138 -0
  29. package/src/file-options-schemas.js +327 -0
  30. package/src/file-options-schemas.test.js +26 -0
  31. package/src/hooks.js +252 -0
  32. package/src/index.js +101 -0
  33. package/src/joint-file-types-legacy.js +298 -0
  34. package/src/joint-file-types-legacy.test.js +412 -0
  35. package/src/joint-file-types.js +171 -0
  36. package/src/joint-file-types.test.js +144 -0
  37. package/{dist/schemas.js → src/json-schemas.js} +6 -1
  38. package/{dist → src}/plugins.js +102 -70
  39. package/src/plugins.test.fixtures.js +78 -0
  40. package/src/plugins.test.js +42 -0
  41. package/src/schemas/config-0.1.0.schema.json +85 -0
  42. package/src/schemas/config-1.0.0.schema.json +733 -0
  43. package/src/schemas/config-1.0.1.schema.json +909 -0
  44. package/src/schemas/config-1.0.10.schema.json +969 -0
  45. package/src/schemas/config-1.0.11.schema.json +990 -0
  46. package/src/schemas/config-1.0.12.schema.json +997 -0
  47. package/src/schemas/config-1.0.13.schema.json +1013 -0
  48. package/src/schemas/config-1.0.14.schema.json +1048 -0
  49. package/src/schemas/config-1.0.15.schema.json +1048 -0
  50. package/src/schemas/config-1.0.16.schema.json +1069 -0
  51. package/src/schemas/config-1.0.16.schema.test.js +32 -0
  52. package/src/schemas/config-1.0.2.schema.json +911 -0
  53. package/src/schemas/config-1.0.3.schema.json +911 -0
  54. package/src/schemas/config-1.0.4.schema.json +949 -0
  55. package/src/schemas/config-1.0.5.schema.json +949 -0
  56. package/src/schemas/config-1.0.6.schema.json +950 -0
  57. package/src/schemas/config-1.0.7.schema.json +950 -0
  58. package/src/schemas/config-1.0.8.schema.json +966 -0
  59. package/src/schemas/config-1.0.9.schema.json +965 -0
  60. package/src/schemas/fixtures/cellSets.good.json +16 -0
  61. package/src/schemas/fixtures/config-1.0.1.bad.json +1 -0
  62. package/src/schemas/fixtures/config-1.0.1.bad.message.json +11 -0
  63. package/src/schemas/fixtures/config-1.0.1.good.json +37 -0
  64. package/src/schemas/fixtures/config-1.0.2.bad.json +1 -0
  65. package/src/schemas/fixtures/config-1.0.2.bad.message.json +11 -0
  66. package/src/schemas/fixtures/config-1.0.2.good.json +38 -0
  67. package/src/schemas/fixtures/config-1.0.3.bad.json +1 -0
  68. package/src/schemas/fixtures/config-1.0.3.bad.message.json +11 -0
  69. package/src/schemas/fixtures/config-1.0.3.good.json +38 -0
  70. package/src/schemas/fixtures/obsSets.bad.json +1 -0
  71. package/src/schemas/fixtures/obsSets.bad.message.json +11 -0
  72. package/src/schemas/fixtures/obsSets.good.json +16 -0
  73. package/src/schemas/fixtures/obsSetsTabular.bad.json +1 -0
  74. package/src/schemas/fixtures/obsSetsTabular.bad.message.json +11 -0
  75. package/src/schemas/fixtures/obsSetsTabular.good.json +26 -0
  76. package/src/schemas/fixtures/raster.bad.json +1 -0
  77. package/src/schemas/fixtures/raster.bad.message.json +11 -0
  78. package/src/schemas/fixtures/raster.good.json +39 -0
  79. package/src/schemas/obsSets.schema.js +195 -0
  80. package/src/schemas/obsSetsTabular.schema.js +39 -0
  81. package/src/schemas/raster.schema.js +121 -0
  82. package/src/schemas/schema-schema.sh +34 -0
  83. package/{dist → src}/schemas/schema.test-old.js +0 -1
  84. package/src/shared-mui/components.js +79 -0
  85. package/src/shared-mui/container.js +212 -0
  86. package/src/shared-mui/styles.js +110 -0
  87. package/src/shared-plot-options/CellColorEncodingOption.js +43 -0
  88. package/src/shared-plot-options/OptionSelect.js +19 -0
  89. package/src/shared-plot-options/OptionsContainer.js +26 -0
  90. package/{dist → src}/shared-plot-options/index.js +0 -0
  91. package/src/shared-plot-options/styles.js +49 -0
  92. package/src/state/hooks.js +633 -0
  93. package/src/view-config-upgraders.js +628 -0
  94. package/src/view-config-utils.js +315 -0
  95. package/src/view-config-utils.test.fixtures.js +893 -0
  96. package/src/view-config-utils.test.js +95 -0
  97. package/src/view-config-versions.js +68 -0
  98. package/src/vitessce-grid-layout/VitessceGridLayout.js +158 -0
  99. package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +56 -0
  100. package/{dist → src}/vitessce-grid-layout/index.js +0 -0
  101. package/src/vitessce-grid-layout/layout-utils.js +76 -0
  102. package/src/vitessce-grid-layout/layout-utils.test.js +167 -0
  103. package/src/vitessce-grid-utils.js +160 -0
  104. package/dist/CallbackPublisher.js +0 -68
  105. package/dist/LoadingIndicator.js +0 -27
  106. package/dist/TitleInfo.js +0 -151
  107. package/dist/VitS.js +0 -112
  108. package/dist/VitessceGrid.js +0 -59
  109. package/dist/VitessceGrid.test.js +0 -36
  110. package/dist/Warning.js +0 -45
  111. package/dist/component-registry.js +0 -16
  112. package/dist/data/AbstractLoader.js +0 -35
  113. package/dist/data/LoaderResult.js +0 -7
  114. package/dist/data/loader-registry.js +0 -15
  115. package/dist/data-hook-utils.js +0 -175
  116. package/dist/data-hooks.js +0 -241
  117. package/dist/errors/AbstractLoaderError.js +0 -13
  118. package/dist/errors/DataSourceFetchError.js +0 -13
  119. package/dist/errors/DatasetNotFoundError.js +0 -17
  120. package/dist/errors/LoaderNotFoundError.js +0 -17
  121. package/dist/errors/LoaderValidationError.js +0 -15
  122. package/dist/errors/OptionsValidationError.js +0 -15
  123. package/dist/file-options-schemas-legacy.js +0 -136
  124. package/dist/file-options-schemas-legacy.test.js +0 -126
  125. package/dist/file-options-schemas.js +0 -322
  126. package/dist/file-options-schemas.test.js +0 -23
  127. package/dist/hooks.js +0 -215
  128. package/dist/joint-file-types-legacy.js +0 -278
  129. package/dist/joint-file-types-legacy.test.js +0 -400
  130. package/dist/joint-file-types.js +0 -148
  131. package/dist/joint-file-types.test.js +0 -139
  132. package/dist/plugins.test.fixtures.js +0 -76
  133. package/dist/plugins.test.js +0 -30
  134. package/dist/schemas/config-0.1.0.schema.json +0 -84
  135. package/dist/schemas/config-1.0.0.schema.json +0 -733
  136. package/dist/schemas/config-1.0.1.schema.json +0 -909
  137. package/dist/schemas/config-1.0.10.schema.json +0 -969
  138. package/dist/schemas/config-1.0.11.schema.json +0 -990
  139. package/dist/schemas/config-1.0.12.schema.json +0 -997
  140. package/dist/schemas/config-1.0.13.schema.json +0 -1013
  141. package/dist/schemas/config-1.0.14.schema.json +0 -1048
  142. package/dist/schemas/config-1.0.15.schema.json +0 -1048
  143. package/dist/schemas/config-1.0.15.schema.test.js +0 -22
  144. package/dist/schemas/config-1.0.2.schema.json +0 -910
  145. package/dist/schemas/config-1.0.3.schema.json +0 -910
  146. package/dist/schemas/config-1.0.4.schema.json +0 -949
  147. package/dist/schemas/config-1.0.5.schema.json +0 -949
  148. package/dist/schemas/config-1.0.6.schema.json +0 -949
  149. package/dist/schemas/config-1.0.7.schema.json +0 -949
  150. package/dist/schemas/config-1.0.8.schema.json +0 -965
  151. package/dist/schemas/config-1.0.9.schema.json +0 -965
  152. package/dist/schemas/obsSets.schema.js +0 -195
  153. package/dist/schemas/obsSetsTabular.schema.js +0 -38
  154. package/dist/schemas/raster.schema.js +0 -120
  155. package/dist/shared-mui/components.js +0 -35
  156. package/dist/shared-mui/container.js +0 -211
  157. package/dist/shared-mui/styles.js +0 -73
  158. package/dist/shared-plot-options/CellColorEncodingOption.js +0 -18
  159. package/dist/shared-plot-options/OptionSelect.js +0 -12
  160. package/dist/shared-plot-options/OptionsContainer.js +0 -12
  161. package/dist/shared-plot-options/styles.js +0 -48
  162. package/dist/state/hooks.js +0 -549
  163. package/dist/view-config-upgraders.js +0 -525
  164. package/dist/view-config-utils.js +0 -286
  165. package/dist/view-config-utils.test.fixtures.js +0 -765
  166. package/dist/view-config-utils.test.js +0 -66
  167. package/dist/view-config-versions.js +0 -47
  168. package/dist/vitessce-grid-layout/VitessceGridLayout.js +0 -95
  169. package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +0 -40
  170. package/dist/vitessce-grid-layout/layout-utils.js +0 -60
  171. package/dist/vitessce-grid-layout/layout-utils.test.js +0 -146
  172. package/dist/vitessce-grid-utils.js +0 -140
@@ -0,0 +1,144 @@
1
+ import { FileType, FILE_TYPE_DATA_TYPE_MAPPING } from '@vitessce/constants-internal';
2
+ import {
3
+ JOINT_FILE_TYPES,
4
+ expandAnndataZarr,
5
+ } from './joint-file-types';
6
+
7
+
8
+ describe('src/app/joint-file-types.js', () => {
9
+ describe('FileType-to-DataType mappings', () => {
10
+ it('every file type is mapped to either a data type or a joint file type expansion function', () => {
11
+ const fileTypes = Object.values(FileType).sort();
12
+ const mappedFileTypes = [
13
+ ...Object.keys(FILE_TYPE_DATA_TYPE_MAPPING),
14
+ ...Object.keys(JOINT_FILE_TYPES),
15
+ ].sort();
16
+ expect(fileTypes.length).toEqual(mappedFileTypes.length);
17
+ expect(fileTypes).toEqual(mappedFileTypes);
18
+ });
19
+ });
20
+ describe('expandAnndataZarr', () => {
21
+ it('fails to expand when there are no options', () => {
22
+ expect(() => expandAnndataZarr({
23
+ fileType: 'anndata.zarr',
24
+ url: 'http://localhost:8000/anndata.zarr',
25
+ })).toThrow();
26
+ });
27
+ it('expands when there is an obsEmbedding object', () => {
28
+ expect(expandAnndataZarr({
29
+ fileType: 'anndata.zarr',
30
+ url: 'http://localhost:8000/anndata.zarr',
31
+ options: {
32
+ obsLabels: {
33
+ path: 'obs/spot_name',
34
+ },
35
+ featureLabels: {
36
+ path: 'var/gene_symbol',
37
+ },
38
+ obsEmbedding: {
39
+ path: 'obsm/pca',
40
+ dims: [2, 4],
41
+ },
42
+ },
43
+ coordinationValues: {
44
+ obsType: 'spot',
45
+ featureType: 'transcript',
46
+ obsLabelsType: 'spotName',
47
+ featureLabelsType: 'geneSymbol',
48
+ embeddingType: 'PCA',
49
+ },
50
+ })).toEqual([
51
+ {
52
+ fileType: 'obsEmbedding.anndata.zarr',
53
+ url: 'http://localhost:8000/anndata.zarr',
54
+ options: {
55
+ path: 'obsm/pca',
56
+ dims: [2, 4],
57
+ },
58
+ coordinationValues: {
59
+ obsType: 'spot',
60
+ embeddingType: 'PCA',
61
+ },
62
+ },
63
+ {
64
+ fileType: 'obsLabels.anndata.zarr',
65
+ url: 'http://localhost:8000/anndata.zarr',
66
+ options: {
67
+ path: 'obs/spot_name',
68
+ },
69
+ coordinationValues: {
70
+ obsType: 'spot',
71
+ obsLabelsType: 'spotName',
72
+ },
73
+ },
74
+ {
75
+ fileType: 'featureLabels.anndata.zarr',
76
+ url: 'http://localhost:8000/anndata.zarr',
77
+ options: {
78
+ path: 'var/gene_symbol',
79
+ },
80
+ coordinationValues: {
81
+ featureType: 'transcript',
82
+ featureLabelsType: 'geneSymbol',
83
+ },
84
+ },
85
+ ]);
86
+ });
87
+ it('expands when there is an obsEmbedding array of objects', () => {
88
+ expect(expandAnndataZarr({
89
+ fileType: 'anndata.zarr',
90
+ url: 'http://localhost:8000/anndata.zarr',
91
+ options: {
92
+ obsLocations: {
93
+ path: 'obsm/xy',
94
+ },
95
+ obsEmbedding: [
96
+ {
97
+ path: 'obsm/pca',
98
+ dims: [2, 4],
99
+ embeddingType: 'PCA',
100
+ },
101
+ {
102
+ path: 'obsm/umap',
103
+ embeddingType: 'UMAP',
104
+ },
105
+ ],
106
+ },
107
+ })).toEqual([
108
+ {
109
+ fileType: 'obsLocations.anndata.zarr',
110
+ url: 'http://localhost:8000/anndata.zarr',
111
+ options: {
112
+ path: 'obsm/xy',
113
+ },
114
+ coordinationValues: {
115
+ obsType: 'cell',
116
+ },
117
+ },
118
+ {
119
+ fileType: 'obsEmbedding.anndata.zarr',
120
+ url: 'http://localhost:8000/anndata.zarr',
121
+ options: {
122
+ path: 'obsm/pca',
123
+ dims: [2, 4],
124
+ },
125
+ coordinationValues: {
126
+ obsType: 'cell',
127
+ embeddingType: 'PCA',
128
+ },
129
+ },
130
+ {
131
+ fileType: 'obsEmbedding.anndata.zarr',
132
+ url: 'http://localhost:8000/anndata.zarr',
133
+ options: {
134
+ path: 'obsm/umap',
135
+ },
136
+ coordinationValues: {
137
+ obsType: 'cell',
138
+ embeddingType: 'UMAP',
139
+ },
140
+ },
141
+ ]);
142
+ });
143
+ });
144
+ });
@@ -1,4 +1,9 @@
1
1
  import rasterSchema from './schemas/raster.schema';
2
2
  import obsSetsSchema from './schemas/obsSets.schema';
3
3
  import obsSetsTabularSchema from './schemas/obsSetsTabular.schema';
4
- export { rasterSchema, obsSetsSchema, obsSetsTabularSchema, };
4
+
5
+ export {
6
+ rasterSchema,
7
+ obsSetsSchema,
8
+ obsSetsTabularSchema,
9
+ };
@@ -1,6 +1,12 @@
1
1
  import { fromEntries } from '@vitessce/utils';
2
- import { FileType, CoordinationType, FILE_TYPE_DATA_TYPE_MAPPING, COMPONENT_COORDINATION_TYPES, DEFAULT_COORDINATION_VALUES, } from '@vitessce/constants-internal';
2
+ import {
3
+ FileType, CoordinationType,
4
+ FILE_TYPE_DATA_TYPE_MAPPING,
5
+ COMPONENT_COORDINATION_TYPES,
6
+ DEFAULT_COORDINATION_VALUES,
7
+ } from '@vitessce/constants-internal';
3
8
  import { JOINT_FILE_TYPES } from './joint-file-types';
9
+
4
10
  const PLUGINS_KEY = '__VITESSCE_PLUGINS__';
5
11
  const PLUGIN_VIEW_TYPES_KEY = 'viewTypes';
6
12
  const PLUGIN_COORDINATION_TYPES_KEY = 'coordinationTypes';
@@ -8,23 +14,31 @@ const PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY = 'coordinationTypesPerView';
8
14
  const PLUGIN_FILE_TYPES_KEY = 'fileTypes';
9
15
  const PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY = 'fileTypeDataTypeMapping';
10
16
  const PLUGIN_JOINT_FILE_TYPES_KEY = 'jointFileTypes';
17
+
11
18
  window[PLUGINS_KEY] = {};
12
19
  const PLUGINS = window[PLUGINS_KEY];
20
+
13
21
  // Reference: https://github.com/higlass/higlass-register/blob/master/src/index.js
14
22
  PLUGINS[PLUGIN_VIEW_TYPES_KEY] = PLUGINS[PLUGIN_VIEW_TYPES_KEY] || {};
15
23
  PLUGINS[PLUGIN_COORDINATION_TYPES_KEY] = PLUGINS[PLUGIN_COORDINATION_TYPES_KEY] || {};
16
- PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY] = (PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY] || {});
24
+ PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY] = (
25
+ PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY] || {}
26
+ );
17
27
  PLUGINS[PLUGIN_FILE_TYPES_KEY] = PLUGINS[PLUGIN_FILE_TYPES_KEY] || {};
18
- PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY] = (PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY] || {});
28
+ PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY] = (
29
+ PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY] || {}
30
+ );
19
31
  PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY] = PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY] || {};
32
+
20
33
  /**
21
34
  * Register a new coordination type.
22
35
  * @param {string} typeName Name for the new coordination type.
23
36
  * @param {*} defaultValue A default value for the coordination type.
24
37
  */
25
38
  export function registerPluginCoordinationType(typeName, defaultValue) {
26
- PLUGINS[PLUGIN_COORDINATION_TYPES_KEY][typeName] = defaultValue;
39
+ PLUGINS[PLUGIN_COORDINATION_TYPES_KEY][typeName] = defaultValue;
27
40
  }
41
+
28
42
  /**
29
43
  * Register a new view type.
30
44
  * @param {string} viewType A name
@@ -32,20 +46,20 @@ export function registerPluginCoordinationType(typeName, defaultValue) {
32
46
  * @param {string[]} coordinationTypes A list of coordination types that this view supports.
33
47
  */
34
48
  export function registerPluginViewType(viewType, viewSubscriberReactComponent, coordinationTypes) {
35
- PLUGINS[PLUGIN_VIEW_TYPES_KEY][viewType] = viewSubscriberReactComponent;
36
- // Register the supported coordination types.
37
- const pluginTypesPerView = PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY];
38
- if (Array.isArray(pluginTypesPerView[viewType])) {
39
- coordinationTypes.forEach((coordinationType) => {
40
- if (!pluginTypesPerView[viewType].includes(coordinationType)) {
41
- pluginTypesPerView[viewType].push(coordinationType);
42
- }
43
- });
44
- }
45
- else {
46
- pluginTypesPerView[viewType] = coordinationTypes;
47
- }
48
- }
49
+ PLUGINS[PLUGIN_VIEW_TYPES_KEY][viewType] = viewSubscriberReactComponent;
50
+ // Register the supported coordination types.
51
+ const pluginTypesPerView = PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY];
52
+ if (Array.isArray(pluginTypesPerView[viewType])) {
53
+ coordinationTypes.forEach((coordinationType) => {
54
+ if (!pluginTypesPerView[viewType].includes(coordinationType)) {
55
+ pluginTypesPerView[viewType].push(coordinationType);
56
+ }
57
+ });
58
+ } else {
59
+ pluginTypesPerView[viewType] = coordinationTypes;
60
+ }
61
+ }
62
+
49
63
  /**
50
64
  * Register a new file type.
51
65
  * @param {string} fileTypeName Name for the new file type.
@@ -54,11 +68,13 @@ export function registerPluginViewType(viewType, viewSubscriberReactComponent, c
54
68
  * @param {class} dataLoaderClass Data loader class definition.
55
69
  */
56
70
  export function registerPluginFileType(
57
- // eslint-disable-next-line no-unused-vars
58
- fileTypeName, dataTypeName, dataLoaderClass, dataSourceClass) {
59
- PLUGINS[PLUGIN_FILE_TYPES_KEY][fileTypeName] = [dataSourceClass, dataLoaderClass];
60
- PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY][fileTypeName] = dataTypeName;
71
+ // eslint-disable-next-line no-unused-vars
72
+ fileTypeName, dataTypeName, dataLoaderClass, dataSourceClass,
73
+ ) {
74
+ PLUGINS[PLUGIN_FILE_TYPES_KEY][fileTypeName] = [dataSourceClass, dataLoaderClass];
75
+ PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY][fileTypeName] = dataTypeName;
61
76
  }
77
+
62
78
  /**
63
79
  * Register a new joint file type.
64
80
  * @param {string} fileTypeName Name for the new file type.
@@ -67,88 +83,104 @@ fileTypeName, dataTypeName, dataLoaderClass, dataSourceClass) {
67
83
  * file definitions with valid atomic fileType values.
68
84
  */
69
85
  export function registerPluginJointFileType(
70
- // eslint-disable-next-line no-unused-vars
71
- fileTypeName, expansionFunction) {
72
- PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY][fileTypeName] = expansionFunction;
86
+ // eslint-disable-next-line no-unused-vars
87
+ fileTypeName, expansionFunction,
88
+ ) {
89
+ PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY][fileTypeName] = expansionFunction;
73
90
  }
91
+
92
+
74
93
  // Plugin getter functions.
94
+
75
95
  export function getPluginViewTypes() {
76
- return Object.keys(PLUGINS[PLUGIN_VIEW_TYPES_KEY]);
96
+ return Object.keys(PLUGINS[PLUGIN_VIEW_TYPES_KEY]);
77
97
  }
98
+
78
99
  export function getPluginViewType(viewType) {
79
- return PLUGINS[PLUGIN_VIEW_TYPES_KEY][viewType];
100
+ return PLUGINS[PLUGIN_VIEW_TYPES_KEY][viewType];
80
101
  }
102
+
81
103
  export function getPluginCoordinationTypes() {
82
- return Object.keys(PLUGINS[PLUGIN_COORDINATION_TYPES_KEY]);
104
+ return Object.keys(PLUGINS[PLUGIN_COORDINATION_TYPES_KEY]);
83
105
  }
106
+
84
107
  export function getPluginCoordinationTypeDefaults() {
85
- return PLUGINS[PLUGIN_COORDINATION_TYPES_KEY];
108
+ return PLUGINS[PLUGIN_COORDINATION_TYPES_KEY];
86
109
  }
110
+
87
111
  export function getPluginCoordinationTypesForViewType(viewType) {
88
- if (Array.isArray(PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY][viewType])) {
89
- return PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY][viewType];
90
- }
91
- return [];
112
+ if (Array.isArray(PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY][viewType])) {
113
+ return PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY][viewType];
114
+ }
115
+ return [];
92
116
  }
117
+
93
118
  export function getPluginFileTypes() {
94
- return Object.keys(PLUGINS[PLUGIN_FILE_TYPES_KEY]);
119
+ return Object.keys(PLUGINS[PLUGIN_FILE_TYPES_KEY]);
95
120
  }
96
121
  export function getPluginConvenienceFileTypes() {
97
- return Object.keys(PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY]);
122
+ return Object.keys(PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY]);
98
123
  }
124
+
99
125
  export function getDataTypeForPluginFileType(fileType) {
100
- return PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY][fileType];
126
+ return PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY][fileType];
101
127
  }
102
128
  export function getLoaderClassesForPluginFileType(fileType) {
103
- return PLUGINS[PLUGIN_FILE_TYPES_KEY][fileType];
129
+ return PLUGINS[PLUGIN_FILE_TYPES_KEY][fileType];
104
130
  }
105
131
  export function getExpansionFunctionForPluginConvenienceFileType(fileType) {
106
- return PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY][fileType];
132
+ return PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY][fileType];
107
133
  }
134
+
108
135
  // Getters that depend on plugins.
109
136
  export function getFileTypes() {
110
- return [
111
- ...Object.values(FileType),
112
- ...getPluginFileTypes(),
113
- ];
137
+ return [
138
+ ...Object.values(FileType),
139
+ ...getPluginFileTypes(),
140
+ ];
114
141
  }
142
+
115
143
  export function getCoordinationTypes() {
116
- return [
117
- ...Object.values(CoordinationType),
118
- ...getPluginCoordinationTypes(),
119
- ];
144
+ return [
145
+ ...Object.values(CoordinationType),
146
+ ...getPluginCoordinationTypes(),
147
+ ];
120
148
  }
149
+
121
150
  // Need to do this in a function since the plugin coordination
122
151
  // types are dynamic.
123
152
  export function getDefaultCoordinationValues() {
124
- return {
125
- ...DEFAULT_COORDINATION_VALUES,
126
- ...getPluginCoordinationTypeDefaults(),
127
- };
153
+ return {
154
+ ...DEFAULT_COORDINATION_VALUES,
155
+ ...getPluginCoordinationTypeDefaults(),
156
+ };
128
157
  }
158
+
129
159
  // Need to do this in a function since the plugin coordination
130
160
  // types are dynamic.
131
161
  export function getComponentCoordinationTypes() {
132
- return {
133
- ...COMPONENT_COORDINATION_TYPES,
134
- ...fromEntries(getPluginViewTypes().map(viewType => ([
135
- viewType,
136
- getPluginCoordinationTypesForViewType(viewType),
137
- ]))),
138
- };
139
- }
162
+ return {
163
+ ...COMPONENT_COORDINATION_TYPES,
164
+ ...fromEntries(getPluginViewTypes().map(viewType => ([
165
+ viewType,
166
+ getPluginCoordinationTypesForViewType(viewType),
167
+ ]))),
168
+ };
169
+ }
170
+
140
171
  export function getFileTypeDataTypeMapping() {
141
- return {
142
- ...FILE_TYPE_DATA_TYPE_MAPPING,
143
- ...fromEntries(getPluginFileTypes().map(fileType => ([
144
- fileType,
145
- getDataTypeForPluginFileType(fileType),
146
- ]))),
147
- };
148
- }
172
+ return {
173
+ ...FILE_TYPE_DATA_TYPE_MAPPING,
174
+ ...fromEntries(getPluginFileTypes().map(fileType => ([
175
+ fileType,
176
+ getDataTypeForPluginFileType(fileType),
177
+ ]))),
178
+ };
179
+ }
180
+
149
181
  export function getJointFileTypes() {
150
- return {
151
- ...JOINT_FILE_TYPES,
152
- ...PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY],
153
- };
182
+ return {
183
+ ...JOINT_FILE_TYPES,
184
+ ...PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY],
185
+ };
154
186
  }
@@ -0,0 +1,78 @@
1
+ export const convenienceFileDefsCollapsed = {
2
+ version: '1.0.15',
3
+ name: 'My config name',
4
+ description: 'My config description',
5
+ initStrategy: 'auto',
6
+ datasets: [
7
+ {
8
+ files: [
9
+ {
10
+ fileType: 'anndata.convenience.zarr',
11
+ url: 'http://localhost:8000/my_anndata.zarr',
12
+ options: {
13
+ cells: {
14
+ xy: 'obsm/centroids',
15
+ },
16
+ cellSets: [
17
+ {
18
+ groupName: 'Leiden',
19
+ setName: 'obs/leiden',
20
+ },
21
+ ],
22
+ },
23
+ },
24
+ ],
25
+ name: 'A',
26
+ uid: 'A',
27
+ },
28
+ ],
29
+ layout: [],
30
+ };
31
+
32
+ export function pluginExpandAnnDataConvenience(fileDef) {
33
+ return [
34
+ {
35
+ fileType: 'anndata-cells.zarr',
36
+ url: fileDef.url,
37
+ options: fileDef.options.cells,
38
+ },
39
+ {
40
+ fileType: 'anndata-cell-sets.zarr',
41
+ url: fileDef.url,
42
+ options: fileDef.options.cellSets,
43
+ },
44
+ ];
45
+ }
46
+
47
+ export const convenienceFileDefsExpanded = {
48
+ version: '1.0.15',
49
+ name: 'My config name',
50
+ description: 'My config description',
51
+ initStrategy: 'auto',
52
+ datasets: [
53
+ {
54
+ files: [
55
+ {
56
+ fileType: 'anndata-cells.zarr',
57
+ url: 'http://localhost:8000/my_anndata.zarr',
58
+ options: {
59
+ xy: 'obsm/centroids',
60
+ },
61
+ },
62
+ {
63
+ fileType: 'anndata-cell-sets.zarr',
64
+ url: 'http://localhost:8000/my_anndata.zarr',
65
+ options: [
66
+ {
67
+ groupName: 'Leiden',
68
+ setName: 'obs/leiden',
69
+ },
70
+ ],
71
+ },
72
+ ],
73
+ name: 'A',
74
+ uid: 'A',
75
+ },
76
+ ],
77
+ layout: [],
78
+ };
@@ -0,0 +1,42 @@
1
+ /* eslint-disable camelcase */
2
+ import {
3
+ registerPluginFileType,
4
+ registerPluginJointFileType,
5
+ getFileTypeDataTypeMapping,
6
+ getJointFileTypes,
7
+ } from './plugins';
8
+ import {
9
+ convenienceFileDefsCollapsed,
10
+ convenienceFileDefsExpanded,
11
+ pluginExpandAnnDataConvenience,
12
+ } from './plugins.test.fixtures';
13
+ import {
14
+ initialize,
15
+ } from './view-config-utils';
16
+
17
+ describe('src/app/plugins.js', () => {
18
+ describe('getFileTypeDataTypeMapping', () => {
19
+ it('returns the correct data type for built-in file types', () => {
20
+ const dataType = getFileTypeDataTypeMapping()['image.raster.json'];
21
+ expect(dataType).toEqual('image');
22
+ });
23
+ it('returns the correct data type for plugin file types', () => {
24
+ registerPluginFileType('plugin-cells.json', 'cells', null, null);
25
+ const dataType = getFileTypeDataTypeMapping()['plugin-cells.json'];
26
+ expect(dataType).toEqual('cells');
27
+ });
28
+ });
29
+ describe('convenience file types', () => {
30
+ it('registers plugin convenience file types', () => {
31
+ registerPluginJointFileType('anndata.convenience.zarr', pluginExpandAnnDataConvenience);
32
+ const expansionFuncs = getJointFileTypes();
33
+ expect(Object.keys(expansionFuncs).includes('anndata.convenience.zarr')).toBeTruthy();
34
+ expect(typeof expansionFuncs['anndata.convenience.zarr']).toEqual('function');
35
+ });
36
+ it('uses plugin convenience file types in view config initialization', () => {
37
+ registerPluginJointFileType('anndata.convenience.zarr', pluginExpandAnnDataConvenience);
38
+ expect(initialize(convenienceFileDefsCollapsed).datasets)
39
+ .toEqual(convenienceFileDefsExpanded.datasets);
40
+ });
41
+ });
42
+ });
@@ -0,0 +1,85 @@
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
+ }
85
+