@aics/vole-app 2.13.7 → 2.14.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/es/aics-image-viewer/components/App/index.js +8 -2
- package/es/aics-image-viewer/components/ViewerStateProvider/ResetStateProvider.js +4 -1
- package/es/aics-image-viewer/shared/utils/datatypes.js +29 -0
- package/es/aics-image-viewer/shared/utils/firebase/index.js +109 -0
- package/es/aics-image-viewer/shared/utils/math.js +3 -0
- package/es/aics-image-viewer/shared/utils/test/urlParsing.test.js +1112 -0
- package/es/aics-image-viewer/shared/utils/urlParsing.js +1255 -0
- package/es/index.js +2 -1
- package/package.json +1 -1
- package/type-declarations/aics-image-viewer/components/App/types.d.ts +1 -0
- package/type-declarations/aics-image-viewer/components/Toolbar/index.d.ts +1 -1
- package/type-declarations/aics-image-viewer/components/ViewerStateProvider/index.d.ts +1 -1
- package/type-declarations/aics-image-viewer/shared/utils/datatypes.d.ts +10 -0
- package/type-declarations/aics-image-viewer/shared/utils/firebase/index.d.ts +69 -0
- package/type-declarations/aics-image-viewer/shared/utils/math.d.ts +1 -0
- package/type-declarations/aics-image-viewer/shared/utils/urlParsing.d.ts +344 -0
- package/type-declarations/index.d.ts +3 -1
package/es/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { parseViewerUrlParams } from "./aics-image-viewer/shared/utils/urlParsing";
|
|
1
2
|
import ImageViewerApp from "./aics-image-viewer/components/App";
|
|
2
3
|
import ViewerStateProvider from "./aics-image-viewer/components/ViewerStateProvider";
|
|
3
4
|
export { ViewMode, RenderMode, ImageType } from "./aics-image-viewer/shared/enums";
|
|
4
|
-
export { ImageViewerApp, ViewerStateProvider };
|
|
5
|
+
export { ImageViewerApp, ViewerStateProvider, parseViewerUrlParams };
|
package/package.json
CHANGED
|
@@ -42,5 +42,6 @@ export interface AppProps {
|
|
|
42
42
|
metadataFormatter?: (metadata: MetadataRecord) => MetadataRecord;
|
|
43
43
|
onControlPanelToggle?: (collapsed: boolean) => void;
|
|
44
44
|
showError?: (error: any) => void;
|
|
45
|
+
onImageTitleChange?: (title: string | undefined) => void;
|
|
45
46
|
}
|
|
46
47
|
export {};
|
|
@@ -27,5 +27,5 @@ type ToolbarProps = {
|
|
|
27
27
|
changeViewerSetting: ViewerSettingUpdater;
|
|
28
28
|
resetToSavedViewerState: () => void;
|
|
29
29
|
};
|
|
30
|
-
declare const _default: React.FC<Omit<ToolbarProps, "viewMode" | "renderMode" | "imageType" | "showAxes" | "showBoundingBox" | "autorotate" | "
|
|
30
|
+
declare const _default: React.FC<Omit<ToolbarProps, "viewMode" | "renderMode" | "imageType" | "showAxes" | "showBoundingBox" | "autorotate" | "resetToSavedViewerState" | "changeViewerSetting">>;
|
|
31
31
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ViewerState, ViewerStateContextType } from "./types";
|
|
3
|
-
export declare const ALL_VIEWER_STATE_KEYS: (keyof ViewerState | "
|
|
3
|
+
export declare const ALL_VIEWER_STATE_KEYS: (keyof ViewerState | keyof import("./types").ResetState | "channelSettings" | "changeViewerSetting" | "changeChannelSetting" | "setChannelSettings" | "applyColorPresets")[];
|
|
4
4
|
type NoNull<T> = {
|
|
5
5
|
[K in keyof T]: NonNullable<T[K]>;
|
|
6
6
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a (shallow) copy of an object with all properties that are
|
|
3
|
+
* `undefined` removed.
|
|
4
|
+
*/
|
|
5
|
+
export declare function removeUndefinedProperties<T>(obj: T): Partial<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Returns a copy of `obj` where all properties with values that match the properties of `match`
|
|
8
|
+
* are removed. Matching is determined by deep equality (see `isDeepEqual()`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function removeMatchingProperties<T extends Object>(obj: Partial<T>, match: T): Partial<T>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { DocumentData, FirebaseFirestore } from "@firebase/firestore-types";
|
|
2
|
+
export interface DatasetMetaData {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
datasets?: {
|
|
6
|
+
[key: string]: DatasetMetaData;
|
|
7
|
+
};
|
|
8
|
+
id: string;
|
|
9
|
+
description: string;
|
|
10
|
+
image: string;
|
|
11
|
+
link?: string;
|
|
12
|
+
manifest?: string;
|
|
13
|
+
production?: boolean;
|
|
14
|
+
userData: {
|
|
15
|
+
isNew: boolean;
|
|
16
|
+
inReview: boolean;
|
|
17
|
+
totalTaggedStructures: number;
|
|
18
|
+
totalCells: number;
|
|
19
|
+
totalFOVs: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface FileInfo {
|
|
23
|
+
CellId: string;
|
|
24
|
+
CellLineName: string;
|
|
25
|
+
FOVId: string;
|
|
26
|
+
structureProteinName: string;
|
|
27
|
+
fovThumbnailPath: string;
|
|
28
|
+
fovVolumeviewerPath: string;
|
|
29
|
+
thumbnailPath: string;
|
|
30
|
+
volumeviewerPath: string;
|
|
31
|
+
}
|
|
32
|
+
interface ManifestDocumentData extends DocumentData {
|
|
33
|
+
featuresDataPath: string;
|
|
34
|
+
cellLineDataPath: string;
|
|
35
|
+
thumbnailRoot: string;
|
|
36
|
+
downloadRoot: string;
|
|
37
|
+
volumeViewerDataRoot: string;
|
|
38
|
+
featuresDisplayOrder: string[];
|
|
39
|
+
defaultXAxis: string;
|
|
40
|
+
defaultYAxis: string;
|
|
41
|
+
fileInfoPath: string;
|
|
42
|
+
featuresDataOrder: string[];
|
|
43
|
+
albumPath: string;
|
|
44
|
+
featureDefsPath: string;
|
|
45
|
+
}
|
|
46
|
+
declare class FirebaseRequest {
|
|
47
|
+
private firestore;
|
|
48
|
+
private fileInfoPath;
|
|
49
|
+
private collectionRef;
|
|
50
|
+
private featuresDataPath;
|
|
51
|
+
private cellLineDataPath;
|
|
52
|
+
private thumbnailRoot;
|
|
53
|
+
private downloadRoot;
|
|
54
|
+
private volumeViewerDataRoot;
|
|
55
|
+
private featuresDisplayOrder;
|
|
56
|
+
private datasetId;
|
|
57
|
+
private featuresDataOrder;
|
|
58
|
+
private albumPath;
|
|
59
|
+
private featureDefsPath;
|
|
60
|
+
constructor(firestore: FirebaseFirestore);
|
|
61
|
+
private getDoc;
|
|
62
|
+
getAvailableDatasets: () => Promise<DatasetMetaData[]>;
|
|
63
|
+
setCollectionRef: (id: string) => void;
|
|
64
|
+
private getManifest;
|
|
65
|
+
selectDataset: (ref: string) => Promise<ManifestDocumentData>;
|
|
66
|
+
getFileInfoByCellId: (cellId: string) => Promise<FileInfo | undefined>;
|
|
67
|
+
getFileInfoByArrayOfCellIds: (cellIds: string[]) => Promise<(FileInfo | undefined)[]>;
|
|
68
|
+
}
|
|
69
|
+
export default FirebaseRequest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
import { CameraState } from "@aics/vole-core";
|
|
2
|
+
import { FirebaseFirestore } from "@firebase/firestore-types";
|
|
3
|
+
import type { AppProps } from "../../components/App/types";
|
|
4
|
+
import type { ChannelState, ViewerState, ViewerStateContextType } from "../../components/ViewerStateProvider/types";
|
|
5
|
+
import { ViewMode } from "../enums";
|
|
6
|
+
import type { MetadataRecord } from "../types";
|
|
7
|
+
import { ColorArray } from "./colorRepresentations";
|
|
8
|
+
import type { ViewerChannelSetting } from "./viewerChannelSettings";
|
|
9
|
+
export declare const ENCODED_COMMA_REGEX: RegExp;
|
|
10
|
+
export declare const ENCODED_COLON_REGEX: RegExp;
|
|
11
|
+
/**
|
|
12
|
+
* LEGACY: Matches a COMMA-separated list of control points, where each control point is represented
|
|
13
|
+
* by a triplet of `{x}:{opacity}:{hex color}`.
|
|
14
|
+
* The hex color can be replaced with `w` to represent white (`ffffff`).
|
|
15
|
+
*/
|
|
16
|
+
export declare const LEGACY_CONTROL_POINTS_REGEX: RegExp;
|
|
17
|
+
/**
|
|
18
|
+
* Matches a COLON-separated list of control points, where each control point is represented
|
|
19
|
+
* by a triplet of `{x}:{opacity}:{hex color}`.
|
|
20
|
+
* The hex color can be replaced with `w` to represent white (`ffffff`).
|
|
21
|
+
*/
|
|
22
|
+
export declare const CONTROL_POINTS_REGEX: RegExp;
|
|
23
|
+
/**
|
|
24
|
+
* Enum keys for URL parameters. These are stored as enums for better readability,
|
|
25
|
+
* and are mapped to types in `ViewerStateParams`.
|
|
26
|
+
*/
|
|
27
|
+
export declare enum ViewerStateKeys {
|
|
28
|
+
View = "view",
|
|
29
|
+
Mode = "mode",
|
|
30
|
+
Mask = "mask",
|
|
31
|
+
Image = "image",
|
|
32
|
+
Axes = "axes",
|
|
33
|
+
BoundingBox = "bb",
|
|
34
|
+
BoundingBoxColor = "bbcol",
|
|
35
|
+
BackgroundColor = "bgcol",
|
|
36
|
+
Autorotate = "rot",
|
|
37
|
+
Brightness = "bright",
|
|
38
|
+
Density = "dens",
|
|
39
|
+
Levels = "lvl",
|
|
40
|
+
Interpolation = "interp",
|
|
41
|
+
Region = "reg",
|
|
42
|
+
Slice = "slice",
|
|
43
|
+
Time = "t",
|
|
44
|
+
Scene = "scene",
|
|
45
|
+
CameraState = "cam"
|
|
46
|
+
}
|
|
47
|
+
export declare enum CameraTransformKeys {
|
|
48
|
+
/** Camera position in 3D coordinates. */
|
|
49
|
+
Position = "pos",
|
|
50
|
+
/** Target position of the trackball controls in 3D coordinates. */
|
|
51
|
+
Target = "tar",
|
|
52
|
+
/** The up vector of the camera. Will be normalized to magnitude of 1. */
|
|
53
|
+
Up = "up",
|
|
54
|
+
/** Scale factor for orthographic cameras. */
|
|
55
|
+
OrthoScale = "ort",
|
|
56
|
+
/** Vertical FOV of the camera view frustum, from top to bottom, in degrees. */
|
|
57
|
+
Fov = "fov"
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Mapped to types in `ViewerChannelSettingParams`
|
|
61
|
+
*/
|
|
62
|
+
export declare enum ViewerChannelSettingKeys {
|
|
63
|
+
Color = "col",
|
|
64
|
+
Colorize = "clz",
|
|
65
|
+
ColorizeAlpha = "cza",
|
|
66
|
+
IsosurfaceAlpha = "isa",
|
|
67
|
+
Lut = "lut",
|
|
68
|
+
Ramp = "rmp",
|
|
69
|
+
ControlPoints = "cps",
|
|
70
|
+
ControlPointsEnabled = "cpe",
|
|
71
|
+
VolumeEnabled = "ven",
|
|
72
|
+
SurfaceEnabled = "sen",
|
|
73
|
+
IsosurfaceValue = "isv"
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The serialized form of a ViewerChannelSetting, as a dictionary object.
|
|
77
|
+
*/
|
|
78
|
+
export declare class ViewerChannelSettingParams {
|
|
79
|
+
/** Color, as a 6-digit hex color. */
|
|
80
|
+
[ViewerChannelSettingKeys.Color]?: string;
|
|
81
|
+
/** Colorize. "1" is enabled. Disabled by default. */
|
|
82
|
+
[ViewerChannelSettingKeys.Colorize]?: "1" | "0";
|
|
83
|
+
/** Colorize alpha, in the [0, 1] range. Set to `1.0` by default. */
|
|
84
|
+
[ViewerChannelSettingKeys.ColorizeAlpha]?: string;
|
|
85
|
+
/** Isosurface alpha, in the [0, 1 range]. Set to `1.0` by default.*/
|
|
86
|
+
[ViewerChannelSettingKeys.IsosurfaceAlpha]?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Lookup table (LUT) to map from volume intensity to opacity. Should be two
|
|
89
|
+
* alphanumeric values separated by a colon, where the first value is the
|
|
90
|
+
* minimum and the second is the maximum. Defaults to [0, 255].
|
|
91
|
+
*
|
|
92
|
+
* Min and max values are determined as following:
|
|
93
|
+
* - Plain numbers are indices of histogram bins, typically in the range [0,
|
|
94
|
+
* 255].
|
|
95
|
+
* - `v{n}` represents a raw intensity value, where `n` is a number.
|
|
96
|
+
* - `p{n}` represents a percentile, where `n` is a percentile in the [0, 100]
|
|
97
|
+
* range.
|
|
98
|
+
* - `m{n}` represents the median multiplied by `n / 100`.
|
|
99
|
+
* - `autoij` in either the min or max fields will use the "auto" algorithm
|
|
100
|
+
* from ImageJ to select the min and max.
|
|
101
|
+
*
|
|
102
|
+
* Values will be used to determine the initial control points and ramp if
|
|
103
|
+
* those fields are not provided.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```
|
|
107
|
+
* "0:255" // min: intensity 0, max: intensity 255.
|
|
108
|
+
* "p50:p90" // min: 50th percentile, max: 90th percentile.
|
|
109
|
+
* "m1:p75" // min: median, max: 75th percentile.
|
|
110
|
+
* "autoij:0" // use Auto-IJ to calculate min and max.
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
[ViewerChannelSettingKeys.Lut]?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Control points for the transfer function. If provided, overrides the
|
|
116
|
+
* `lut` field when calculating the control points. Should be a list
|
|
117
|
+
* of `x:opacity:color` triplets, separated by colon.
|
|
118
|
+
* - `x` is a numeric intensity value.
|
|
119
|
+
* - `opacity` is a float in the [0, 1] range.
|
|
120
|
+
* - `color` is a 6-digit hex color, e.g. `ff0000`.
|
|
121
|
+
*/
|
|
122
|
+
[ViewerChannelSettingKeys.ControlPoints]?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Whether to show advanced mode, which will show control points instead of
|
|
125
|
+
* ramp values defined by the LUT. "1" is enabled, disabled by default.
|
|
126
|
+
*/
|
|
127
|
+
[ViewerChannelSettingKeys.ControlPointsEnabled]?: "1" | "0";
|
|
128
|
+
/**
|
|
129
|
+
* Raw ramp values, which should be two numeric values separated by a colon.
|
|
130
|
+
* If provided, overrides the `lut` field when calculating the ramp values.
|
|
131
|
+
*/
|
|
132
|
+
[ViewerChannelSettingKeys.Ramp]?: string;
|
|
133
|
+
/** Volume enabled. "1" is enabled. Disabled by default. */
|
|
134
|
+
[ViewerChannelSettingKeys.VolumeEnabled]?: "1" | "0";
|
|
135
|
+
/** Isosurface enabled. "1" is enabled. Disabled by default. */
|
|
136
|
+
[ViewerChannelSettingKeys.SurfaceEnabled]?: "1" | "0";
|
|
137
|
+
/** Isosurface value, in the [0, 255] range. Set to `128` by default. */
|
|
138
|
+
[ViewerChannelSettingKeys.IsosurfaceValue]?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Channels, matching the pattern `c0`, `c1`, etc. corresponding to the index of the channel being configured.
|
|
142
|
+
* The channel parameter should have a value that is a comma-separated list of `key:value` pairs, with keys
|
|
143
|
+
* defined in `ViewerChannelSettingJson`.
|
|
144
|
+
*/
|
|
145
|
+
type ChannelParams = {
|
|
146
|
+
[_ in `c${number}`]?: string;
|
|
147
|
+
};
|
|
148
|
+
/** Serialized version of `ViewerState`. */
|
|
149
|
+
export declare class ViewerStateParams {
|
|
150
|
+
/** Axis to view. Valid values are "3D", "X", "Y", and "Z". Defaults to "3D". */
|
|
151
|
+
[ViewerStateKeys.View]?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Render mode. Valid values are "volumetric", "maxproject", and "pathtrace".
|
|
154
|
+
* Defaults to "volumetric".
|
|
155
|
+
*/
|
|
156
|
+
[ViewerStateKeys.Mode]?: string;
|
|
157
|
+
/** The opacity of the mask channel, an integer in the range [0, 100]. Defaults to 50. */
|
|
158
|
+
[ViewerStateKeys.Mask]?: string;
|
|
159
|
+
/** The type of image to display. Valid values are "cell" and "fov". Defaults to "cell". */
|
|
160
|
+
[ViewerStateKeys.Image]?: string;
|
|
161
|
+
/** Whether to show the axes helper. "1" is enabled. Disabled by default. */
|
|
162
|
+
[ViewerStateKeys.Axes]?: string;
|
|
163
|
+
/** Whether to show the bounding box. "1" is enabled. Disabled by default. */
|
|
164
|
+
[ViewerStateKeys.BoundingBox]?: string;
|
|
165
|
+
/** The color of the bounding box, as a 6-digit hex color. */
|
|
166
|
+
[ViewerStateKeys.BoundingBoxColor]?: string;
|
|
167
|
+
/** The background color, as a 6-digit hex color. */
|
|
168
|
+
[ViewerStateKeys.BackgroundColor]?: string;
|
|
169
|
+
/** Whether to autorotate the view. "1" is enabled. Disabled by default. */
|
|
170
|
+
[ViewerStateKeys.Autorotate]?: string;
|
|
171
|
+
/** The brightness of the image, an float in the range [0, 100]. Defaults to 70. */
|
|
172
|
+
[ViewerStateKeys.Brightness]?: string;
|
|
173
|
+
/** Density, a float in the range [0, 100]. Defaults to 50. */
|
|
174
|
+
[ViewerStateKeys.Density]?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Levels for image intensity adjustment. Should be three numeric values separated
|
|
177
|
+
* by commas, representing the low, middle, and high values in a [0, 255] range.
|
|
178
|
+
* Values will be sorted in ascending order; empty values will be parsed as 0.
|
|
179
|
+
*/
|
|
180
|
+
[ViewerStateKeys.Levels]?: string;
|
|
181
|
+
/** Whether to enable interpolation. "1" is enabled. Enabled by default. */
|
|
182
|
+
[ViewerStateKeys.Interpolation]?: string;
|
|
183
|
+
/** Subregions per axis, as min:max pairs separated by commas.
|
|
184
|
+
* Defaults to full range (`0:1`) for each axis.
|
|
185
|
+
*/
|
|
186
|
+
[ViewerStateKeys.Region]?: string;
|
|
187
|
+
/** Slice position per X, Y, and Z axes, as a list of comma-separated floats.
|
|
188
|
+
* 0.5 for all axes by default (e.g. `0.5,0.5,0.5`)
|
|
189
|
+
*/
|
|
190
|
+
[ViewerStateKeys.Slice]?: string;
|
|
191
|
+
/** Frame number, for time-series volumes. 0 by default. */
|
|
192
|
+
[ViewerStateKeys.Time]?: string;
|
|
193
|
+
/** Scene number, for multiscene images. 0 by default. */
|
|
194
|
+
[ViewerStateKeys.Scene]?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Camera transform settings, as a list of `key:value` pairs separated by commas.
|
|
197
|
+
* Valid keys are defined in `CameraTransformKeys`:
|
|
198
|
+
* - `pos`: position
|
|
199
|
+
* - `tar`: target
|
|
200
|
+
* - `up`: up
|
|
201
|
+
* - `rot`: rotation
|
|
202
|
+
* - `ort`: orthographic scales
|
|
203
|
+
*
|
|
204
|
+
* All values are an array of three floats, separated by commas and
|
|
205
|
+
* encoded using `encodeURIComponent`.
|
|
206
|
+
*/
|
|
207
|
+
[ViewerStateKeys.CameraState]?: string;
|
|
208
|
+
}
|
|
209
|
+
/** URL parameters that define data sources when loading volumes. */
|
|
210
|
+
declare class DataParams {
|
|
211
|
+
/**
|
|
212
|
+
* One or more volume URLs to load. If multiple URLs are provided, they should
|
|
213
|
+
* be separated by commas.
|
|
214
|
+
*/
|
|
215
|
+
url?: string;
|
|
216
|
+
/**
|
|
217
|
+
* The URL of a JSON manifest. The JSON should contain two properties:
|
|
218
|
+
* - "scenes": A string array of volume URLs.
|
|
219
|
+
* - "meta": An array of metadata dictionary objects.
|
|
220
|
+
*
|
|
221
|
+
* See `ManifestJson` for the type definition.
|
|
222
|
+
*/
|
|
223
|
+
manifest?: string;
|
|
224
|
+
/**
|
|
225
|
+
* The name of a dataset in the Cell Feature Explorer database. Used with `id`.
|
|
226
|
+
*/
|
|
227
|
+
dataset?: string;
|
|
228
|
+
/**
|
|
229
|
+
* The ID of a cell within the loaded dataset. Used with `dataset`.
|
|
230
|
+
*/
|
|
231
|
+
id?: string;
|
|
232
|
+
}
|
|
233
|
+
declare class DeprecatedParams {
|
|
234
|
+
/** Deprecated query parameter for channel settings. */
|
|
235
|
+
ch?: string;
|
|
236
|
+
/** Deprecated query parameter for LUT settings. */
|
|
237
|
+
luts?: string;
|
|
238
|
+
/** Deprecated query parameter for channel colors. */
|
|
239
|
+
colors?: string;
|
|
240
|
+
}
|
|
241
|
+
type AppParams = Partial<ViewerStateParams & DataParams & DeprecatedParams & ChannelParams>;
|
|
242
|
+
/**
|
|
243
|
+
* Filters a set of URLSearchParams for only the keys that are valid parameters for the viewer.
|
|
244
|
+
* Non-matching keys are discarded.
|
|
245
|
+
* @param searchParams Input URL search parameters.
|
|
246
|
+
* @returns a dictionary object matching the type of `Params`.
|
|
247
|
+
*/
|
|
248
|
+
export declare function getAllowedParams(searchParams: URLSearchParams): AppParams;
|
|
249
|
+
/**
|
|
250
|
+
* Parse a string list of comma-separated key:value pairs into
|
|
251
|
+
* a key-value object.
|
|
252
|
+
*
|
|
253
|
+
* @param data The string to parse. Expected to be in the format
|
|
254
|
+
* "key1:value1,key2:value2,...". Commas in keys or values
|
|
255
|
+
* must be encoded using `encodeURIComponent`.
|
|
256
|
+
* @returns An object with the parsed key-value pairs. Key and value strings
|
|
257
|
+
* will be decoded using `decodeURIComponent`.
|
|
258
|
+
*/
|
|
259
|
+
export declare function parseKeyValueList(data: string): Record<string, string>;
|
|
260
|
+
export declare function objectToKeyValueList(obj: Record<string, string | undefined>): string;
|
|
261
|
+
/**
|
|
262
|
+
* Parses a string to a float and clamps the result to the [min, max] range.
|
|
263
|
+
* Returns `undefined` if the string is undefined or NaN.
|
|
264
|
+
* @param value String to parse as a float. Will be parsed with `Number.parseFloat`.
|
|
265
|
+
* @param min Minimum value, inclusive.
|
|
266
|
+
* @param max Maximum value, inclusive.
|
|
267
|
+
* @returns
|
|
268
|
+
* - The parsed number, clamped to the [min, max] range.
|
|
269
|
+
* - `undefined` if the string is undefined or NaN.
|
|
270
|
+
*/
|
|
271
|
+
export declare function parseStringFloat(value: string | undefined, min: number, max: number): number | undefined;
|
|
272
|
+
/**
|
|
273
|
+
* Parses a string to an integer and clamps the result to the [min, max] range.
|
|
274
|
+
* @param value String to parse as a float. Assumes base 10, parses with `Number.parseInt(value, 10)`.
|
|
275
|
+
* @param min Minimum value, inclusive.
|
|
276
|
+
* @param max Maximum value, inclusive.
|
|
277
|
+
* @returns
|
|
278
|
+
* - The parsed number, clamped to the [min, max] range.
|
|
279
|
+
* - `undefined` if the string is undefined or NaN.
|
|
280
|
+
*/
|
|
281
|
+
export declare function parseStringInt(value: string | undefined, min: number, max: number): number | undefined;
|
|
282
|
+
/**
|
|
283
|
+
* Parses a string to an enum value; if the string is not in the enum, returns the default value.
|
|
284
|
+
* @param value String to parse.
|
|
285
|
+
* @param enumValues Enum. Cannot be a `const enum`, as these are removed at compile time.
|
|
286
|
+
* @param defaultValue Default value to return if the string is not in the enum.
|
|
287
|
+
* @returns A value from the enum or the default value. Note that the return type includes `undefined`
|
|
288
|
+
* if the `defaultValue` is `undefined`.
|
|
289
|
+
*/
|
|
290
|
+
export declare function parseStringEnum<E extends string, T extends E | undefined>(value: string | undefined, enumValues: Record<string | number | symbol, E>, defaultValue?: T): T;
|
|
291
|
+
export declare function parseHexColorAsColorArray(hexColor: string | undefined): ColorArray | undefined;
|
|
292
|
+
export declare function serializeCameraState(cameraState: Partial<CameraState>, removeDefaults: boolean, viewMode?: ViewMode): string | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* Parses a ViewerChannelSetting from a JSON object.
|
|
295
|
+
* @param channelIndex Index of the channel, to be turned into a `match` value.
|
|
296
|
+
* @param jsonState The serialized ViewerChannelSetting to parse, as an object.
|
|
297
|
+
* @returns A ViewerChannelSetting object.
|
|
298
|
+
*/
|
|
299
|
+
export declare function deserializeViewerChannelSetting(channelIndex: number, jsonState: ViewerChannelSettingParams): ViewerChannelSetting;
|
|
300
|
+
/**
|
|
301
|
+
* Serializes a single viewer channel setting into a dictionary of URL parameters
|
|
302
|
+
* (`ViewerChannelSettingParams`).
|
|
303
|
+
* @param channelSetting The channel state object to serialize.
|
|
304
|
+
* @param removeDefaults Whether to remove properties that match the output of `GET_DEFAULT_CHANNEL_STATE`.
|
|
305
|
+
* @returns A `ViewerChannelSettingParams` object with the serialized parameters. Undefined values are removed.
|
|
306
|
+
*/
|
|
307
|
+
export declare function serializeViewerChannelSetting(channelSetting: Partial<ChannelState>, removeDefaults: boolean): Partial<ViewerChannelSettingParams>;
|
|
308
|
+
export declare function deserializeViewerState(params: ViewerStateParams): Partial<ViewerState>;
|
|
309
|
+
/**
|
|
310
|
+
* Serializes a ViewerState object into a dictionary of URL parameters.
|
|
311
|
+
* @param state The ViewerState to serialize.
|
|
312
|
+
* @param removeDefaults If true, remove properties that match the output of `GET_DEFAULT_VIEWER_STATE`.
|
|
313
|
+
* @returns A `ViewerStateParams` object with the serialized parameters. Undefined values are removed.
|
|
314
|
+
*/
|
|
315
|
+
export declare function serializeViewerState(state: Partial<ViewerState>, removeDefaults: boolean): ViewerStateParams;
|
|
316
|
+
export declare function loadFromManifest(manifestUrl: string): Promise<{
|
|
317
|
+
scenes: (string | string[])[];
|
|
318
|
+
metadata?: MetadataRecord[];
|
|
319
|
+
}>;
|
|
320
|
+
/**
|
|
321
|
+
* Parses a set of URL search parameters into props for the viewer.
|
|
322
|
+
* @param urlSearchParams The URLSearchParams object to parse.
|
|
323
|
+
* @param firestore Optional Firestore instance. If provided, the function can
|
|
324
|
+
* load data from a Firestore dataset if the `dataset` and `id` parameters are
|
|
325
|
+
* provided.
|
|
326
|
+
* @returns An object containing:
|
|
327
|
+
* - `args`: Partial AppProps object.
|
|
328
|
+
* - `viewerSettings`: Partial ViewerState object.
|
|
329
|
+
*
|
|
330
|
+
* `args` can be passed as props to the `ImageViewerApp`, and `viewerSettings`
|
|
331
|
+
* can be passed to `ViewerStateProvider`.
|
|
332
|
+
*/
|
|
333
|
+
export declare function parseViewerUrlParams(urlSearchParams: URLSearchParams, firestore?: FirebaseFirestore): Promise<{
|
|
334
|
+
args: Partial<AppProps>;
|
|
335
|
+
viewerSettings: Partial<ViewerState>;
|
|
336
|
+
}>;
|
|
337
|
+
/**
|
|
338
|
+
* Serializes the ViewerState and ChannelState of a ViewerStateContext into a URLSearchParams object.
|
|
339
|
+
* @param state ViewerStateContext to serialize.
|
|
340
|
+
* @param removeDefaults If true, shortens parameters by removing any properties that match the default state.
|
|
341
|
+
* This includes the output of GET_DEFAULT_VIEWER_STATE and GET_DEFAULT_CHANNEL_STATE.
|
|
342
|
+
*/
|
|
343
|
+
export declare function serializeViewerUrlParams(state: Partial<ViewerStateContextType>, removeDefaults?: boolean): AppParams;
|
|
344
|
+
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { parseViewerUrlParams } from "./aics-image-viewer/shared/utils/urlParsing";
|
|
1
2
|
import ImageViewerApp from "./aics-image-viewer/components/App";
|
|
2
3
|
import ViewerStateProvider from "./aics-image-viewer/components/ViewerStateProvider";
|
|
3
4
|
export type { ViewerChannelSettings, ViewerChannelGroup, ViewerChannelSetting, } from "./aics-image-viewer/shared/utils/viewerChannelSettings";
|
|
5
|
+
export type { ViewerState } from "./aics-image-viewer/components/ViewerStateProvider/types";
|
|
4
6
|
export { ViewMode, RenderMode, ImageType } from "./aics-image-viewer/shared/enums";
|
|
5
7
|
export type { AppProps } from "./aics-image-viewer/components/App/types";
|
|
6
8
|
export type { RawArrayData, RawArrayInfo } from "@aics/vole-core";
|
|
7
|
-
export { ImageViewerApp, ViewerStateProvider };
|
|
9
|
+
export { ImageViewerApp, ViewerStateProvider, parseViewerUrlParams };
|