@vitessce/vit-s 2.0.0-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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/dist/CallbackPublisher.js +68 -0
  3. package/dist/LoadingIndicator.js +27 -0
  4. package/dist/TitleInfo.js +151 -0
  5. package/dist/VitS.js +113 -0
  6. package/dist/Vitessce.integration.test.js +36 -0
  7. package/dist/Vitessce.js +101 -0
  8. package/dist/VitessceGrid.js +55 -0
  9. package/dist/VitessceGrid.test.js +36 -0
  10. package/dist/Warning.js +45 -0
  11. package/dist/classNames.js +8 -0
  12. package/dist/component-registry.js +16 -0
  13. package/dist/data/AbstractLoader.js +35 -0
  14. package/dist/data/AbstractTwoStepLoader.js +7 -0
  15. package/dist/data/LoaderResult.js +7 -0
  16. package/dist/data/index.js +3 -0
  17. package/dist/data/loader-registry.js +15 -0
  18. package/dist/data-hook-utils.js +175 -0
  19. package/dist/data-hooks.js +241 -0
  20. package/dist/errors/AbstractLoaderError.js +13 -0
  21. package/dist/errors/DataSourceFetchError.js +13 -0
  22. package/dist/errors/DatasetNotFoundError.js +17 -0
  23. package/dist/errors/LoaderNotFoundError.js +17 -0
  24. package/dist/errors/LoaderValidationError.js +15 -0
  25. package/dist/errors/OptionsValidationError.js +15 -0
  26. package/dist/errors/index.js +6 -0
  27. package/dist/export-utils.js +70 -0
  28. package/dist/export-utils.test.js +66 -0
  29. package/dist/file-options-schemas-legacy.js +136 -0
  30. package/dist/file-options-schemas-legacy.test.js +126 -0
  31. package/dist/file-options-schemas.js +322 -0
  32. package/dist/file-options-schemas.test.js +23 -0
  33. package/dist/hooks.js +215 -0
  34. package/dist/index.js +18 -0
  35. package/dist/joint-file-types-legacy.js +278 -0
  36. package/dist/joint-file-types-legacy.test.js +400 -0
  37. package/dist/joint-file-types.js +148 -0
  38. package/dist/joint-file-types.test.js +139 -0
  39. package/dist/loader-registry.js +98 -0
  40. package/dist/plugins.js +154 -0
  41. package/dist/plugins.test.fixtures.js +76 -0
  42. package/dist/plugins.test.js +30 -0
  43. package/dist/schemas/PrettyJsonSchema.js +34 -0
  44. package/dist/schemas/config-0.1.0.schema.json +84 -0
  45. package/dist/schemas/config-1.0.0.schema.json +733 -0
  46. package/dist/schemas/config-1.0.1.schema.json +909 -0
  47. package/dist/schemas/config-1.0.10.schema.json +969 -0
  48. package/dist/schemas/config-1.0.11.schema.json +990 -0
  49. package/dist/schemas/config-1.0.12.schema.json +997 -0
  50. package/dist/schemas/config-1.0.13.schema.json +1013 -0
  51. package/dist/schemas/config-1.0.14.schema.json +1048 -0
  52. package/dist/schemas/config-1.0.15.schema.json +1048 -0
  53. package/dist/schemas/config-1.0.15.schema.test.js +22 -0
  54. package/dist/schemas/config-1.0.2.schema.json +910 -0
  55. package/dist/schemas/config-1.0.3.schema.json +910 -0
  56. package/dist/schemas/config-1.0.4.schema.json +949 -0
  57. package/dist/schemas/config-1.0.5.schema.json +949 -0
  58. package/dist/schemas/config-1.0.6.schema.json +949 -0
  59. package/dist/schemas/config-1.0.7.schema.json +949 -0
  60. package/dist/schemas/config-1.0.8.schema.json +965 -0
  61. package/dist/schemas/config-1.0.9.schema.json +965 -0
  62. package/dist/schemas/obsSets.schema.js +195 -0
  63. package/dist/schemas/obsSets.schema.json +194 -0
  64. package/dist/schemas/obsSetsTabular.schema.js +38 -0
  65. package/dist/schemas/obsSetsTabular.schema.json +37 -0
  66. package/dist/schemas/raster.schema.js +120 -0
  67. package/dist/schemas/raster.schema.json +119 -0
  68. package/dist/schemas/schema.test-old.js +50 -0
  69. package/dist/schemas/schema.test.js +46 -0
  70. package/dist/schemas.js +4 -0
  71. package/dist/shared-mui/components.js +35 -0
  72. package/dist/shared-mui/container.js +211 -0
  73. package/dist/shared-mui/styles.js +63 -0
  74. package/dist/shared-plot-options/CellColorEncodingOption.js +18 -0
  75. package/dist/shared-plot-options/OptionSelect.js +12 -0
  76. package/dist/shared-plot-options/OptionsContainer.js +12 -0
  77. package/dist/shared-plot-options/index.js +4 -0
  78. package/dist/shared-plot-options/styles.js +48 -0
  79. package/dist/state/hooks.js +550 -0
  80. package/dist/view-config-upgraders.js +525 -0
  81. package/dist/view-config-utils.js +286 -0
  82. package/dist/view-config-utils.test.fixtures.js +765 -0
  83. package/dist/view-config-utils.test.js +66 -0
  84. package/dist/view-config-versions.js +47 -0
  85. package/dist/vitessce-grid-layout/VitessceGridLayout.js +96 -0
  86. package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +40 -0
  87. package/dist/vitessce-grid-layout/index.js +1 -0
  88. package/dist/vitessce-grid-layout/layout-utils.js +61 -0
  89. package/dist/vitessce-grid-layout/layout-utils.test.js +146 -0
  90. package/dist/vitessce-grid-utils.js +140 -0
  91. package/package.json +43 -0
@@ -0,0 +1,550 @@
1
+ import { useRef, useCallback, useMemo } from 'react';
2
+ import create from 'zustand';
3
+ import createContext from 'zustand/context';
4
+ import shallow from 'zustand/shallow';
5
+ import isMatch from 'lodash/isMatch';
6
+ import { CoordinationType } from '@vitessce/constants-internal';
7
+ import { fromEntries, capitalize } from '@vitessce/utils';
8
+ // Reference: https://github.com/pmndrs/zustand#react-context
9
+ // Reference: https://github.com/pmndrs/zustand/blob/e47ea03/tests/context.test.tsx#L60
10
+ const { Provider: ViewConfigProviderLocal, useStore: useViewConfigStoreLocal, useStoreApi: useViewConfigStoreApiLocal, } = createContext();
11
+ export const ViewConfigProvider = ViewConfigProviderLocal;
12
+ export const useViewConfigStore = useViewConfigStoreLocal;
13
+ export const useViewConfigStoreApi = useViewConfigStoreApiLocal;
14
+ const { Provider: AuxiliaryProviderLocal, useStore: useAuxiliaryStoreLocal, } = createContext();
15
+ export const AuxiliaryProvider = AuxiliaryProviderLocal;
16
+ export const useAuxiliaryStore = useAuxiliaryStoreLocal;
17
+ /**
18
+ * The useViewConfigStore hook is initialized via the zustand
19
+ * create() function, which sets up both the state variables
20
+ * and the reducer-type functions.
21
+ * Reference: https://github.com/react-spring/zustand
22
+ * @returns {function} The useStore hook.
23
+ */
24
+ export const createViewConfigStore = () => create(set => ({
25
+ // State:
26
+ // The viewConfig is an object which must conform to the schema
27
+ // found in src/schemas/config.schema.json.
28
+ viewConfig: null,
29
+ // The loaders object is a mapping from dataset ID to
30
+ // data type to loader object instance.
31
+ loaders: null,
32
+ // Reducer functions which update the state
33
+ // (although technically also part of state):
34
+ setViewConfig: viewConfig => set({ viewConfig }),
35
+ setLoaders: loaders => set({ loaders }),
36
+ setCoordinationValue: ({ parameter, scope, value }) => set(state => ({
37
+ viewConfig: {
38
+ ...state.viewConfig,
39
+ coordinationSpace: {
40
+ ...state.viewConfig.coordinationSpace,
41
+ [parameter]: {
42
+ ...state.viewConfig.coordinationSpace[parameter],
43
+ [scope]: value,
44
+ },
45
+ },
46
+ },
47
+ })),
48
+ removeComponent: uid => set((state) => {
49
+ const newLayout = state.viewConfig.layout.filter(c => c.uid !== uid);
50
+ return {
51
+ viewConfig: {
52
+ ...state.viewConfig,
53
+ layout: newLayout,
54
+ },
55
+ };
56
+ }),
57
+ changeLayout: newComponentProps => set((state) => {
58
+ const newLayout = state.viewConfig.layout.slice();
59
+ newComponentProps.forEach(([i, newProps]) => {
60
+ newLayout[i] = {
61
+ ...newLayout[i],
62
+ ...newProps,
63
+ };
64
+ });
65
+ return {
66
+ viewConfig: {
67
+ ...state.viewConfig,
68
+ layout: newLayout,
69
+ },
70
+ };
71
+ }),
72
+ }));
73
+ /**
74
+ * Hook for getting components' layout from the view config based on
75
+ * matching all coordination scopes.
76
+ * @returns {Object} The components' layout.
77
+ */
78
+ export const useComponentLayout = (component, scopes, coordinationScopes) => useViewConfigStore(state => state.viewConfig.layout.filter(l => l.component === component).filter(l => scopes.every(scope => l.coordinationScopes[scope]
79
+ === coordinationScopes[scope])));
80
+ /**
81
+ * The useAuxiliaryStore hook is initialized via the zustand
82
+ * create() function, which sets up both the state variables
83
+ * and the reducer-type functions.
84
+ * Reference: https://github.com/react-spring/zustand
85
+ * It is meant to be used for non-viewconfig-based coordination between components.
86
+ * For example, as currently happens, the layer controller can coordinate
87
+ * on-load callbacks with spatial view based on whether or not they are
88
+ * coordinated via `spatialImageLayer` - the callbacks are not part of the view config
89
+ * though so they live here.
90
+ * @returns {function} The useStore hook.
91
+ */
92
+ export const createAuxiliaryStore = () => create(set => ({
93
+ auxiliaryStore: null,
94
+ setCoordinationValue: ({ parameter, scope, value }) => set(state => ({
95
+ auxiliaryStore: {
96
+ ...state.auxiliaryStore,
97
+ [parameter]: {
98
+ [scope]: value,
99
+ },
100
+ },
101
+ })),
102
+ }));
103
+ /**
104
+ * The hover store can be used to store global state
105
+ * related to which component is currently hovered,
106
+ * which is required for tooltip / crossover elements.
107
+ * @returns {function} The useStore hook.
108
+ */
109
+ const useHoverStore = create(set => ({
110
+ // Components may need to know if they are the "hover source"
111
+ // for tooltip interactions. This value should be a unique
112
+ // component ID, such as its index in the view config layout.
113
+ componentHover: null,
114
+ setComponentHover: componentHover => set({ componentHover }),
115
+ }));
116
+ /**
117
+ * The warning store can be used to store global state
118
+ * related to app warning messages.
119
+ * @returns {function} The useStore hook.
120
+ */
121
+ const useWarnStore = create(set => ({
122
+ // Want a global state to collect warning messages
123
+ // that occur anywhere in the app.
124
+ warning: null,
125
+ setWarning: warning => set({ warning }),
126
+ }));
127
+ /**
128
+ * The view info store can be used to store component-level
129
+ * viewInfo objects,
130
+ * which are required for tooltip / crossover elements.
131
+ * @returns {function} The useStore hook.
132
+ */
133
+ const useViewInfoStore = create(set => ({
134
+ // The viewInfo object is a mapping from
135
+ // component IDs to component view info objects.
136
+ // Each view info object must have a project() function.
137
+ viewInfo: {},
138
+ setComponentViewInfo: (uuid, viewInfo) => set(state => ({
139
+ viewInfo: {
140
+ ...state.viewInfo,
141
+ [uuid]: viewInfo,
142
+ },
143
+ })),
144
+ }));
145
+ /**
146
+ * The grid size store can be used to store a
147
+ * counter which updates on each window or react-grid-layout
148
+ * resize event.
149
+ * @returns {function} The useStore hook.
150
+ */
151
+ const useGridSizeStore = create(set => ({
152
+ resizeCount: {},
153
+ incrementResizeCount: () => set(state => ({
154
+ resizeCount: state.resizeCount + 1,
155
+ })),
156
+ }));
157
+ /**
158
+ * The useCoordination hook returns both the
159
+ * values and setter functions for the coordination objects
160
+ * in a particular coordination scope mapping.
161
+ * This hook is intended to be used within the ___Subscriber
162
+ * components to allow them to "hook into" only those coordination
163
+ * objects and setter functions of relevance.
164
+ * @param {string[]} parameters Array of coordination types.
165
+ * @param {object} coordinationScopes Mapping of coordination types
166
+ * to scope names.
167
+ * @returns {array} Returns a tuple [values, setters]
168
+ * where values is an object containing all coordination values,
169
+ * and setters is an object containing all coordination setter
170
+ * functions for the values in `values`, named with a "set"
171
+ * prefix.
172
+ */
173
+ export function useCoordination(parameters, coordinationScopes) {
174
+ const setCoordinationValue = useViewConfigStore(state => state.setCoordinationValue);
175
+ const values = useViewConfigStore((state) => {
176
+ const { coordinationSpace } = state.viewConfig;
177
+ return fromEntries(parameters.map((parameter) => {
178
+ if (coordinationSpace && coordinationSpace[parameter]) {
179
+ const value = coordinationSpace[parameter][coordinationScopes[parameter]];
180
+ return [parameter, value];
181
+ }
182
+ return [parameter, undefined];
183
+ }));
184
+ }, shallow);
185
+ const setters = useMemo(() => fromEntries(parameters.map((parameter) => {
186
+ const setterName = `set${capitalize(parameter)}`;
187
+ const setterFunc = value => setCoordinationValue({
188
+ parameter,
189
+ scope: coordinationScopes[parameter],
190
+ value,
191
+ });
192
+ return [setterName, setterFunc];
193
+ // eslint-disable-next-line react-hooks/exhaustive-deps
194
+ })), [parameters, coordinationScopes]);
195
+ return [values, setters];
196
+ }
197
+ export function useMultiCoordinationValues(parameter, coordinationScopes) {
198
+ const scopes = coordinationScopes[parameter];
199
+ // Mapping from dataset coordination scope name to dataset uid
200
+ const vals = useViewConfigStore((state) => {
201
+ const { coordinationSpace } = state.viewConfig;
202
+ // Convert a single scope to an array of scopes to be consistent.
203
+ const scopesArr = Array.isArray(scopes) ? scopes : [scopes];
204
+ return fromEntries(scopesArr.map((scope) => {
205
+ if (coordinationSpace && coordinationSpace[parameter]) {
206
+ const value = coordinationSpace[parameter][scope];
207
+ return [scope, value];
208
+ }
209
+ return [scope, undefined];
210
+ // eslint-disable-next-line no-unused-vars
211
+ }).filter(([k, v]) => v !== undefined));
212
+ }, shallow);
213
+ return vals;
214
+ }
215
+ /**
216
+ * Get a mapping from dataset coordination scopes to dataset UIDs.
217
+ * @param {object} coordinationScopes The coordination scope mapping object for a view.
218
+ * @returns {object} Mapping from dataset coordination scope names to dataset UIDs.
219
+ */
220
+ export function useDatasetUids(coordinationScopes) {
221
+ return useMultiCoordinationValues(CoordinationType.DATASET, coordinationScopes);
222
+ }
223
+ /**
224
+ * Use coordination values and coordination setter functions corresponding to
225
+ * dataset-specific coordination scopes for each coordination type.
226
+ * @param {string[]} parameters An array of coordination types supported by a view.
227
+ * @param {object} coordinationScopes The coordination scope mapping object for a view.
228
+ * @returns {array} [cValues, cSetters] where
229
+ * cValues is a mapping from coordination scope name to { coordinationType: coordinationValue },
230
+ * and cSetters is a mapping from coordination scope name to { setCoordinationType }
231
+ * setter functions.
232
+ */
233
+ export function useMultiDatasetCoordination(parameters, coordinationScopes) {
234
+ const setCoordinationValue = useViewConfigStore(state => state.setCoordinationValue);
235
+ const datasetScopes = coordinationScopes[CoordinationType.DATASET];
236
+ // Convert a single scope to an array of scopes to be consistent.
237
+ const datasetScopesArr = Array.isArray(datasetScopes) ? datasetScopes : [datasetScopes];
238
+ const values = useViewConfigStore((state) => {
239
+ const { coordinationSpace } = state.viewConfig;
240
+ return fromEntries(datasetScopesArr.map((datasetScope) => {
241
+ const datasetValues = fromEntries(parameters.map((parameter) => {
242
+ if (coordinationSpace && coordinationSpace[parameter]) {
243
+ let value;
244
+ const parameterSpace = coordinationSpace[parameter];
245
+ const parameterScope = coordinationScopes[parameter];
246
+ if (typeof parameterScope === 'object') {
247
+ value = parameterSpace[parameterScope[datasetScope]];
248
+ }
249
+ else if (typeof parameterScope === 'string') {
250
+ value = parameterSpace[parameterScope];
251
+ }
252
+ else {
253
+ console.error(`coordination scope for ${parameter} must be of type string or object.`);
254
+ }
255
+ return [parameter, value];
256
+ }
257
+ return [parameter, undefined];
258
+ }));
259
+ return [datasetScope, datasetValues];
260
+ }));
261
+ }, shallow);
262
+ const setters = useMemo(() => fromEntries(datasetScopesArr.map((datasetScope) => {
263
+ const datasetSetters = fromEntries(parameters.map((parameter) => {
264
+ const setterName = `set${capitalize(parameter)}`;
265
+ let setterFunc;
266
+ const parameterScope = coordinationScopes[parameter];
267
+ if (typeof parameterScope === 'object') {
268
+ setterFunc = value => setCoordinationValue({
269
+ parameter,
270
+ scope: parameterScope[datasetScope],
271
+ value,
272
+ });
273
+ }
274
+ else if (typeof parameterScope === 'string') {
275
+ setterFunc = value => setCoordinationValue({
276
+ parameter,
277
+ scope: parameterScope,
278
+ value,
279
+ });
280
+ }
281
+ else {
282
+ console.error(`coordination scope for ${parameter} must be of type string or object.`);
283
+ }
284
+ return [setterName, setterFunc];
285
+ }));
286
+ return [datasetScope, datasetSetters];
287
+ // eslint-disable-next-line react-hooks/exhaustive-deps
288
+ })), [parameters, coordinationScopes]);
289
+ return [values, setters];
290
+ }
291
+ const AUXILIARY_COORDINATION_TYPES_MAP = {
292
+ spatialImageLayer: ['imageLayerCallbacks', 'areLoadingImageChannels'],
293
+ spatialSegmentationLayer: ['segmentationLayerCallbacks', 'areLoadingSegmentationChannels'],
294
+ };
295
+ /**
296
+ * The maps the coordination types of incoming scopes to new types
297
+ * for the auxiliary store.
298
+ * @param {object} coordinationScopes Mapping of coordination types
299
+ * to scope names.
300
+ * @returns {object} Mapping of coordination types
301
+ * to new scope names for the auxiliary store.
302
+ */
303
+ const mapCoordinationScopes = (coordinationScopes) => {
304
+ const newCoordinationScopes = {};
305
+ Object.keys(coordinationScopes).forEach((key) => {
306
+ const newCoordinationTypes = AUXILIARY_COORDINATION_TYPES_MAP[key] || [];
307
+ newCoordinationTypes.forEach((coordinationType) => {
308
+ newCoordinationScopes[coordinationType || key] = coordinationScopes[key];
309
+ });
310
+ });
311
+ return newCoordinationScopes;
312
+ };
313
+ const mapParameters = parameters => parameters
314
+ .map(parameter => AUXILIARY_COORDINATION_TYPES_MAP[parameter]).filter(Boolean).flat();
315
+ /**
316
+ * The useAuxiliaryCoordination hook returns both the
317
+ * values and setter functions for the auxiliary coordination objects
318
+ * in a particular coordination scope mapping.
319
+ * This hook is intended to be used within the ___Subscriber
320
+ * components to allow them to "hook into" only those auxiliary coordination
321
+ * objects and setter functions of relevance, for example "on load" callbacks.
322
+ * @param {string[]} parameters Array of coordination types.
323
+ * @param {object} coordinationScopes Mapping of coordination types
324
+ * to scope names.
325
+ * @returns {array} Returns a tuple [values, setters]
326
+ * where values is an object containing all coordination values,
327
+ * and setters is an object containing all coordination setter
328
+ * functions for the values in `values`, named with a "set"
329
+ * prefix.
330
+ */
331
+ export function useAuxiliaryCoordination(parameters, coordinationScopes) {
332
+ const setCoordinationValue = useAuxiliaryStore(state => state.setCoordinationValue);
333
+ const mappedCoordinationScopes = mapCoordinationScopes(coordinationScopes);
334
+ const mappedParameters = mapParameters(parameters);
335
+ const values = useAuxiliaryStore((state) => {
336
+ const { auxiliaryStore } = state;
337
+ return fromEntries(mappedParameters.map((parameter) => {
338
+ if (auxiliaryStore && auxiliaryStore[parameter]) {
339
+ const value = auxiliaryStore[parameter][mappedCoordinationScopes[parameter]];
340
+ return [parameter, value];
341
+ }
342
+ return [parameter, undefined];
343
+ }));
344
+ }, shallow);
345
+ const setters = useMemo(() => fromEntries(mappedParameters.map((parameter) => {
346
+ const setterName = `set${capitalize(parameter)}`;
347
+ const setterFunc = value => setCoordinationValue({
348
+ parameter,
349
+ scope: mappedCoordinationScopes[parameter],
350
+ value,
351
+ });
352
+ return [setterName, setterFunc];
353
+ // eslint-disable-next-line react-hooks/exhaustive-deps
354
+ })), [parameters, coordinationScopes]);
355
+ return [values, setters];
356
+ }
357
+ /**
358
+ * Obtain the loaders object from
359
+ * the global app state.
360
+ * @returns {object} The loaders object
361
+ * in the `useViewConfigStore` store.
362
+ */
363
+ export function useLoaders() {
364
+ return useViewConfigStore(state => state.loaders);
365
+ }
366
+ /**
367
+ * Find a specific loader instance for a particular dataset, data type, and view
368
+ * coordination values (mapping from coordination types to coordination values).
369
+ * Uses lodash/isMatch to perform matching against the file definition's
370
+ * coordination value mapping.
371
+ * @param {object} loaders The value returned by useLoaders.
372
+ * @param {string} dataset The dataset UID.
373
+ * @param {string} dataType The data type for the matching file.
374
+ * @param {object} viewCoordinationValues Current coordination values
375
+ * from the view. Match these against a subset of file definition coordination
376
+ * values.
377
+ * @returns The matching loader instance or `null`.
378
+ */
379
+ export function useMatchingLoader(loaders, dataset, dataType, viewCoordinationValues) {
380
+ return useMemo(() => {
381
+ if (!loaders[dataset]) {
382
+ return null;
383
+ }
384
+ const loaderInternMap = loaders[dataset].loaders[dataType];
385
+ if (!loaderInternMap) {
386
+ return null;
387
+ }
388
+ const loaderKeys = Array.from(loaderInternMap.keys());
389
+ const matchingKey = loaderKeys
390
+ .find(fileCoordinationValues => isMatch(fileCoordinationValues, viewCoordinationValues));
391
+ if (!matchingKey) {
392
+ return null;
393
+ }
394
+ return loaderInternMap.get(matchingKey);
395
+ }, [loaders, dataset, dataType, viewCoordinationValues]);
396
+ }
397
+ /**
398
+ * Find a specific loader instance for a particular dataset, data type, and view
399
+ * coordination values (mapping from coordination types to coordination values).
400
+ * Uses lodash/isMatch to perform matching against the file definition's
401
+ * coordination value mapping.
402
+ * @param {object} loaders The value returned by useLoaders.
403
+ * @param {string} dataset The dataset UID.
404
+ * @param {string} dataType The data type for the matching file.
405
+ * @param {object} viewCoordinationValues Current coordination values
406
+ * from the view. Match these against a subset of file definition coordination
407
+ * values.
408
+ * @returns The matching loader instance or `null`.
409
+ */
410
+ export function useMatchingLoaders(loaders, dataset, dataType, viewCoordinationValuesObj) {
411
+ return useMemo(() => {
412
+ if (!loaders[dataset]) {
413
+ return null;
414
+ }
415
+ const loaderInternMap = loaders[dataset].loaders[dataType];
416
+ if (!loaderInternMap) {
417
+ return null;
418
+ }
419
+ const loaderKeys = Array.from(loaderInternMap.keys());
420
+ function getLoader(viewCoordinationValues) {
421
+ const matchingKey = loaderKeys
422
+ .find(fileCoordinationValues => isMatch(fileCoordinationValues, viewCoordinationValues));
423
+ return loaderInternMap.get(matchingKey);
424
+ }
425
+ return fromEntries(Object.entries(viewCoordinationValuesObj).map(([key, viewCoordinationValues]) => ([
426
+ key,
427
+ getLoader(viewCoordinationValues),
428
+ ])));
429
+ }, [loaders, dataset, dataType, viewCoordinationValuesObj]);
430
+ }
431
+ /**
432
+ * Obtain the view config layout array from
433
+ * the global app state.
434
+ * @returns {object[]} The layout array
435
+ * in the `useViewConfigStore` store.
436
+ */
437
+ export function useLayout() {
438
+ return useViewConfigStore(state => state.viewConfig?.layout);
439
+ }
440
+ /**
441
+ * Obtain the component removal function from
442
+ * the global app state.
443
+ * @returns {function} The remove component function
444
+ * in the `useViewInfoStore` store.
445
+ */
446
+ export function useRemoveComponent() {
447
+ return useViewConfigStore(state => state.removeComponent);
448
+ }
449
+ /**
450
+ * Obtain the component prop setter function from
451
+ * the global app state.
452
+ * @returns {function} The set component props function
453
+ * in the `useViewInfoStore` store.
454
+ */
455
+ export function useChangeLayout() {
456
+ return useViewConfigStore(state => state.changeLayout);
457
+ }
458
+ /**
459
+ * Obtain the loaders setter function from
460
+ * the global app state.
461
+ * @returns {function} The loaders setter function
462
+ * in the `useViewConfigStore` store.
463
+ */
464
+ export function useSetLoaders() {
465
+ return useViewConfigStore(state => state.setLoaders);
466
+ }
467
+ /**
468
+ * Obtain the view config setter function from
469
+ * the global app state.
470
+ * @returns {function} The view config setter function
471
+ * in the `useViewConfigStore` store.
472
+ */
473
+ export function useSetViewConfig(viewConfigStoreApi) {
474
+ const setViewConfigRef = useRef(viewConfigStoreApi.getState().setViewConfig);
475
+ const setViewConfig = setViewConfigRef.current;
476
+ return setViewConfig;
477
+ }
478
+ /**
479
+ * Obtain the component hover value from
480
+ * the global app state.
481
+ * @returns {number} The hovered component ID
482
+ * in the `useHoverStore` store.
483
+ */
484
+ export function useComponentHover() {
485
+ return useHoverStore(state => state.componentHover);
486
+ }
487
+ /**
488
+ * Obtain the component hover setter function from
489
+ * the global app state.
490
+ * @returns {function} The component hover setter function
491
+ * in the `useHoverStore` store.
492
+ */
493
+ export function useSetComponentHover() {
494
+ return useHoverStore(state => state.setComponentHover);
495
+ }
496
+ /**
497
+ * Obtain the warning message from
498
+ * the global app state.
499
+ * @returns {string} The warning message
500
+ * in the `useWarnStore` store.
501
+ */
502
+ export function useWarning() {
503
+ return useWarnStore(state => state.warning);
504
+ }
505
+ /**
506
+ * Obtain the warning setter function from
507
+ * the global app state.
508
+ * @returns {function} The warning setter function
509
+ * in the `useWarnStore` store.
510
+ */
511
+ export function useSetWarning() {
512
+ return useWarnStore(state => state.setWarning);
513
+ }
514
+ /**
515
+ * Obtain the component view info value from
516
+ * the global app state.
517
+ * @returns {object} The view info object for the component
518
+ * in the `useViewInfoStore` store.
519
+ */
520
+ export function useComponentViewInfo(uuid) {
521
+ return useViewInfoStore(useCallback(state => state.viewInfo[uuid], [uuid]));
522
+ }
523
+ /**
524
+ * Obtain the component view info setter function from
525
+ * the global app state.
526
+ * @returns {function} The component view info setter function
527
+ * in the `useViewInfoStore` store.
528
+ */
529
+ export function useSetComponentViewInfo(uuid) {
530
+ const setViewInfoRef = useRef(useViewInfoStore.getState().setComponentViewInfo);
531
+ const setComponentViewInfo = viewInfo => setViewInfoRef.current(uuid, viewInfo);
532
+ return setComponentViewInfo;
533
+ }
534
+ /**
535
+ * Obtain the grid resize count value
536
+ * from the global app state.
537
+ * @returns {number} The grid resize increment value.
538
+ */
539
+ export function useGridResize() {
540
+ return useGridSizeStore(state => state.resizeCount);
541
+ }
542
+ /**
543
+ * Obtain the grid resize count increment function
544
+ * from the global app state.
545
+ * @returns {function} The grid resize count increment
546
+ * function.
547
+ */
548
+ export function useEmitGridResize() {
549
+ return useGridSizeStore(state => state.incrementResizeCount);
550
+ }