@diamondlightsource/davidia 1.0.5 → 1.3.0-rc.1
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/README.md +27 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +75 -26
- package/dist/index.js +3369 -3913
- package/package.json +44 -41
- package/dist/style.css +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
## Frontend documentation
|
|
2
|
+
|
|
3
|
+
View the frontend Typescript documentation [here](https://diamondlightsource.github.io/davidia/typedocs/index.html).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Currently, only React 18 is supported.
|
|
8
|
+
|
|
9
|
+
### `pnpm add @diamondlightsource/davidia`
|
|
10
|
+
|
|
11
|
+
## Vite configuration
|
|
12
|
+
|
|
13
|
+
Use `vite < 8` in your devDependencies.
|
|
14
|
+
|
|
15
|
+
Some davidia dependencies require a global object to be defined when used in Vite applications. Add the following to your vite.config.ts:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { defineConfig } from 'vite';
|
|
19
|
+
import react from '@vitejs/plugin-react';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
plugins: [react()],
|
|
23
|
+
define: {
|
|
24
|
+
global: {},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
```
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
._top_cq7uz_1{grid-template-columns:70px 50px 100px 70px;display:grid}._error_cq7uz_6{color:red;flex-direction:row;align-items:center;padding-right:10px;display:flex}._label_cq7uz_14{flex-direction:row;align-items:center;display:flex}._modal_ftojl_1{z-index:1000;position:fixed;left:45%}._modal_content_ftojl_7{background-color:#fff;border:2px solid #ffffffe6;display:grid;box-shadow:0 0 0 1px #0000001a,0 4px 11px #0000001a}._modal_header_ftojl_16,._modal_footer_ftojl_17{padding:10px;position:relative}._modal_title_ftojl_22{margin:0}._modal_body_ftojl_26{border-top:1px solid gray;padding:10px;position:relative}._close_button_ftojl_32{position:absolute;top:1ex;right:1ex}._aspect_ftojl_38{justify-content:left;padding-top:10px;position:relative}._btn_ftojl_44{background-color:var(--h5w-toolbar--bgColor,aliceblue);cursor:pointer;box-shadow:-1px -1px 2px inset var(--h5w-btnRaised--shadowColor,gray);border-radius:.8rem;justify-content:center;padding:0 .5rem}._btn_ftojl_44:hover{background-color:var(--h5w-btn-hover--bgColor,whitesmoke)}._root_h18us_1{flex-direction:column;align-items:center;display:flex;position:relative}._sliderContainer_h18us_8{flex:1;margin-right:-.375rem;padding:0 .375rem;display:flex}._slider_h18us_8{cursor:pointer;--track-width:var(--h5w-domainSlider-track--width,8rem);--track-height:var(--h5w-domainSlider-track--height,.625rem);--thumb-size:calc(var(--track-height) * 2.5);--thumb-size-auto:calc(var(--thumb-size) * .9);margin-right:-.25rem;font-size:.75rem;display:flex}._tools_h18us_27{padding-bottom:2rem;padding-left:2rem;padding-right:2rem}._toolsInner_h18us_37{align-items:center;padding:1rem .375rem 1rem .75rem;display:flex}._modeless_1im3t_1{z-index:1000;position:fixed;left:45%}._modeless_content_1im3t_7{background-color:#fff;border:2px solid #ffffffe6;display:grid;box-shadow:0 0 0 1px #0000001a,0 4px 11px #0000001a}._modeless_header_1im3t_16,._modeless_footer_1im3t_17{padding:10px;position:relative}._modeless_title_1im3t_22{margin:0}._modeless_body_1im3t_26{border-top:1px solid gray;row-gap:4px;padding:10px;display:grid;position:relative}._close_button_1im3t_34{position:absolute;top:1ex;right:1ex}._aspect_1im3t_40{justify-content:left;padding-top:10px;position:relative}._btn_1im3t_46{background-color:var(--h5w-toolbar--bgColor,aliceblue);cursor:pointer;box-shadow:-1px -1px 2px inset var(--h5w-btnRaised--shadowColor,gray);border-radius:.8rem;justify-content:center;padding:0 .5rem}._btn_1im3t_46:hover{background-color:var(--h5w-btn-hover--bgColor,whitesmoke)}._colourLabel_1evqd_1{border-left:24px solid #000;margin-top:20px;padding-left:10px}._option_1qhtz_1{align-items:center;display:flex}._icon_1qhtz_6{padding-top:1px;font-size:1.5em}._scrollContainer_a4950_1{max-height:24ex;overflow-y:scroll}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Dispatch } from 'react';
|
|
|
7
7
|
import { Domain } from '@h5web/lib';
|
|
8
8
|
import { GlyphType } from '@h5web/lib';
|
|
9
9
|
import { HistogramParams } from '@h5web/lib';
|
|
10
|
-
import { JSX as JSX_2 } from 'react
|
|
10
|
+
import { JSX as JSX_2 } from 'react';
|
|
11
11
|
import { Matrix3 } from 'three';
|
|
12
12
|
import { MutableRefObject } from 'react';
|
|
13
13
|
import { NdArray } from 'ndarray';
|
|
@@ -37,7 +37,7 @@ export declare type AnyPlotVisProps = LinePlotProps | ImagePlotProps | HeatmapPl
|
|
|
37
37
|
export declare function AnyToolbar(props: PropsWithChildren<AnyToolbarProps>): false | JSX_2.Element;
|
|
38
38
|
|
|
39
39
|
export declare interface AnyToolbarProps {
|
|
40
|
-
/** Inner
|
|
40
|
+
/** Inner children to add to plot toolbar */
|
|
41
41
|
extraChildren?: React.ReactNode;
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ export { Aspect }
|
|
|
45
45
|
|
|
46
46
|
/** Class to select part of an axis */
|
|
47
47
|
export declare class AxialSelection extends BaseSelection {
|
|
48
|
-
readonly
|
|
48
|
+
readonly _defaultColour = "#882255";
|
|
49
49
|
/** length in dimension */
|
|
50
50
|
length: number;
|
|
51
51
|
/** dimension (x=0, y=1) */
|
|
@@ -68,14 +68,14 @@ export { AxisScaleType }
|
|
|
68
68
|
export declare class BaseSelection implements SelectionBase {
|
|
69
69
|
id: string;
|
|
70
70
|
name: string;
|
|
71
|
-
|
|
71
|
+
_defaultColour: string;
|
|
72
72
|
colour?: string;
|
|
73
73
|
alpha: number;
|
|
74
74
|
fixed: boolean;
|
|
75
75
|
start: [number, number];
|
|
76
|
-
|
|
76
|
+
_asDashed?: boolean;
|
|
77
77
|
/** Vector3 copy of start coordinate */
|
|
78
|
-
|
|
78
|
+
_vStart: Vector3;
|
|
79
79
|
constructor(start: [number, number]);
|
|
80
80
|
toString(): string;
|
|
81
81
|
setStart(i: number, v: number): void;
|
|
@@ -106,7 +106,7 @@ export declare interface BatonProps {
|
|
|
106
106
|
|
|
107
107
|
/** Class to select a circular sector */
|
|
108
108
|
export declare class CircularSectorialSelection extends BaseSelection {
|
|
109
|
-
readonly
|
|
109
|
+
readonly _defaultColour = "#117733";
|
|
110
110
|
/** inner and outer radii */
|
|
111
111
|
radii: [number, number];
|
|
112
112
|
/** start and end angles (radians) */
|
|
@@ -120,7 +120,7 @@ export declare class CircularSectorialSelection extends BaseSelection {
|
|
|
120
120
|
|
|
121
121
|
/** Class to select a circle */
|
|
122
122
|
export declare class CircularSelection extends BaseSelection {
|
|
123
|
-
readonly
|
|
123
|
+
readonly _defaultColour = "#332288";
|
|
124
124
|
/** radius of circle */
|
|
125
125
|
radius: number;
|
|
126
126
|
constructor(start: [number, number], radius: number);
|
|
@@ -140,7 +140,7 @@ export { ColorScaleType }
|
|
|
140
140
|
* @param {ConnectedPlotProps} props - component props
|
|
141
141
|
* @returns {JSX.Element} The rendered component
|
|
142
142
|
*/
|
|
143
|
-
export declare function ConnectedPlot({ plotId, hostname, port, uuid, }: ConnectedPlotProps): JSX_2.Element;
|
|
143
|
+
export declare function ConnectedPlot({ plotId, hostname, port, source, events, uuid, tightAxes, customToolbarChildren, depends_on, }: ConnectedPlotProps): JSX_2.Element | undefined;
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Props for the `ConnectedPlot` component
|
|
@@ -152,15 +152,31 @@ export declare interface ConnectedPlotProps {
|
|
|
152
152
|
hostname?: string;
|
|
153
153
|
/** The port */
|
|
154
154
|
port?: string;
|
|
155
|
+
/** Possible source configuration */
|
|
156
|
+
source?: SourceConfig;
|
|
157
|
+
/** Any event configuration */
|
|
158
|
+
events?: EventConfig[];
|
|
155
159
|
/** The universally unique identifier */
|
|
156
160
|
uuid: string;
|
|
161
|
+
/**
|
|
162
|
+
* If enabled, forces the plot to shrink or expand to keep the image flush with the axes.
|
|
163
|
+
* Has no effect if the aspect is not equal.
|
|
164
|
+
*/
|
|
165
|
+
tightAxes?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Children to customize the toolbar. If undefined then use default toolbar, if null, disable toolbar,
|
|
168
|
+
* otherwise use given children
|
|
169
|
+
*/
|
|
170
|
+
customToolbarChildren?: React.ReactNode;
|
|
171
|
+
/** The plot ID that this plot depends on */
|
|
172
|
+
depends_on?: string;
|
|
157
173
|
}
|
|
158
174
|
|
|
159
175
|
export { Domain }
|
|
160
176
|
|
|
161
177
|
/** Class to select an ellipse */
|
|
162
178
|
export declare class EllipticalSelection extends OrientableSelection {
|
|
163
|
-
readonly
|
|
179
|
+
readonly _defaultColour = "#999933";
|
|
164
180
|
/** lengths of major and minor semi-axes */
|
|
165
181
|
semiAxes: [number, number];
|
|
166
182
|
constructor(start: [number, number], semiAxes: [number, number], angle?: number);
|
|
@@ -170,6 +186,11 @@ export declare class EllipticalSelection extends OrientableSelection {
|
|
|
170
186
|
static createFromSelection(s: EllipticalSelection): EllipticalSelection;
|
|
171
187
|
}
|
|
172
188
|
|
|
189
|
+
export declare interface EventConfig {
|
|
190
|
+
plugin: string;
|
|
191
|
+
[propName: string]: unknown;
|
|
192
|
+
}
|
|
193
|
+
|
|
173
194
|
export { GlyphType }
|
|
174
195
|
|
|
175
196
|
/**
|
|
@@ -234,6 +255,11 @@ declare type ImagePlotCustomizationProps = Omit<ImagePlotProps, 'values'>;
|
|
|
234
255
|
* Props for the `ImagePlot` component
|
|
235
256
|
*/
|
|
236
257
|
export declare interface ImagePlotProps extends PlotBaseProps, ImageData_2 {
|
|
258
|
+
/**
|
|
259
|
+
* If enabled, forces the plot to shrink or expand to keep the image flush with the axes.
|
|
260
|
+
* Has no effect if the aspect is not equal.
|
|
261
|
+
*/
|
|
262
|
+
tightAxes?: boolean;
|
|
237
263
|
}
|
|
238
264
|
|
|
239
265
|
export declare enum InteractionModeType {
|
|
@@ -244,7 +270,7 @@ export declare enum InteractionModeType {
|
|
|
244
270
|
|
|
245
271
|
/** Class to select a line */
|
|
246
272
|
export declare class LinearSelection extends OrientableSelection {
|
|
247
|
-
readonly
|
|
273
|
+
readonly _defaultColour = "#44aa99";
|
|
248
274
|
/** length of line */
|
|
249
275
|
length: number;
|
|
250
276
|
constructor(start?: [number, number], length?: number, angle?: number);
|
|
@@ -292,7 +318,9 @@ export declare interface LineParams {
|
|
|
292
318
|
/** The size of the data points (optional) */
|
|
293
319
|
pointSize?: number;
|
|
294
320
|
/** The type of glyph */
|
|
295
|
-
glyphType
|
|
321
|
+
glyphType?: GlyphType;
|
|
322
|
+
/** The line width */
|
|
323
|
+
width?: number;
|
|
296
324
|
}
|
|
297
325
|
|
|
298
326
|
/**
|
|
@@ -325,8 +353,8 @@ export declare type NDT = NdArray<TypedArray>;
|
|
|
325
353
|
export declare class OrientableSelection extends BaseSelection {
|
|
326
354
|
/** angle of selection (radians) */
|
|
327
355
|
angle: number;
|
|
328
|
-
protected
|
|
329
|
-
protected
|
|
356
|
+
protected _transform: Matrix3;
|
|
357
|
+
protected _invTransform: Matrix3;
|
|
330
358
|
constructor(start: [number, number], angle?: number);
|
|
331
359
|
setAngle(angle: number): void;
|
|
332
360
|
static isShape(s: OrientableSelection | SelectionBase): s is OrientableSelection;
|
|
@@ -498,7 +526,7 @@ export declare interface PlotSelectionProps {
|
|
|
498
526
|
* @param {Props} props - inner children
|
|
499
527
|
* @returns {JSX.Element} The rendered component.
|
|
500
528
|
*/
|
|
501
|
-
export declare function PlotToolbar(props: PropsWithChildren): JSX.Element;
|
|
529
|
+
export declare function PlotToolbar(props: PropsWithChildren): React.JSX.Element;
|
|
502
530
|
|
|
503
531
|
/**
|
|
504
532
|
* Plot type available
|
|
@@ -507,9 +535,9 @@ export declare type PlotType = 'Line' | 'Heatmap' | 'Image' | 'Scatter' | 'Surfa
|
|
|
507
535
|
|
|
508
536
|
/** Class to select a polygon */
|
|
509
537
|
export declare class PolygonalSelection extends BaseSelection {
|
|
510
|
-
readonly
|
|
511
|
-
readonly
|
|
512
|
-
readonly
|
|
538
|
+
readonly _defaultOpenColour = "#88ccee";
|
|
539
|
+
readonly _defaultClosedColour = "#ffa07a";
|
|
540
|
+
readonly _defaultColour = "#88ccee";
|
|
513
541
|
/** array of point coordinates */
|
|
514
542
|
points: [number, number][];
|
|
515
543
|
/** if true, polygon is closed by joining last and first point */
|
|
@@ -526,7 +554,7 @@ export declare class PolygonalSelection extends BaseSelection {
|
|
|
526
554
|
|
|
527
555
|
/** Class to select a rectangle */
|
|
528
556
|
export declare class RectangularSelection extends OrientableSelection {
|
|
529
|
-
readonly
|
|
557
|
+
readonly _defaultColour = "#ddcc77";
|
|
530
558
|
/** lengths of major and minor sides */
|
|
531
559
|
lengths: [number, number];
|
|
532
560
|
constructor(start: [number, number], lengths: [number, number], angle?: number);
|
|
@@ -586,7 +614,7 @@ export declare interface SelectionBase {
|
|
|
586
614
|
/** name */
|
|
587
615
|
name: string;
|
|
588
616
|
/** default colour */
|
|
589
|
-
|
|
617
|
+
_defaultColour: string;
|
|
590
618
|
/** outline colour */
|
|
591
619
|
colour?: string;
|
|
592
620
|
/** opacity [0,1] */
|
|
@@ -596,7 +624,7 @@ export declare interface SelectionBase {
|
|
|
596
624
|
/** start (or centre) point coordinate */
|
|
597
625
|
start: [number, number];
|
|
598
626
|
/** if true, outline is dashed */
|
|
599
|
-
|
|
627
|
+
_asDashed?: boolean;
|
|
600
628
|
/** set start */
|
|
601
629
|
setStart: (i: number, v: number) => void;
|
|
602
630
|
/** retrieve points */
|
|
@@ -617,10 +645,7 @@ dragging?: boolean,
|
|
|
617
645
|
/** if true, remove selection */
|
|
618
646
|
clear?: boolean) => string | null;
|
|
619
647
|
|
|
620
|
-
|
|
621
|
-
* Object of possible options for a SelectionType and its maximum occurrences
|
|
622
|
-
*/
|
|
623
|
-
export declare type SelectionOptions = {
|
|
648
|
+
declare type SelectionOptions = {
|
|
624
649
|
[K in SelectionType]?: number;
|
|
625
650
|
};
|
|
626
651
|
|
|
@@ -658,6 +683,14 @@ export declare enum SelectionType {
|
|
|
658
683
|
unknown = "unknown"
|
|
659
684
|
}
|
|
660
685
|
|
|
686
|
+
export declare interface SourceConfig {
|
|
687
|
+
/** name of plugin class*/
|
|
688
|
+
plugin: string;
|
|
689
|
+
/** if true, allow new updates from source - optionally true */
|
|
690
|
+
activate?: boolean;
|
|
691
|
+
[propName: string]: unknown;
|
|
692
|
+
}
|
|
693
|
+
|
|
661
694
|
/**
|
|
662
695
|
* Represent surface data
|
|
663
696
|
*/
|
|
@@ -756,10 +789,26 @@ export declare function useSelections(initSelections?: SelectionBase[], listener
|
|
|
756
789
|
enableSelect: Dispatch<SetStateAction<boolean>>;
|
|
757
790
|
};
|
|
758
791
|
|
|
792
|
+
/**
|
|
793
|
+
* Render a video plot.
|
|
794
|
+
* @param {VideoPlotProps} props - The component props.
|
|
795
|
+
* @returns {JSX.Element} The rendered component.
|
|
796
|
+
*/
|
|
797
|
+
export declare function VideoPlot(props: VideoPlotProps): JSX_2.Element;
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Props for the `VideoPlot` component.
|
|
801
|
+
*/
|
|
802
|
+
export declare interface VideoPlotProps extends PlotBaseProps {
|
|
803
|
+
/** video source url */
|
|
804
|
+
sourceURL: string;
|
|
805
|
+
/** if true, source is an animated image (MJPEG, animated GIF, etc) */
|
|
806
|
+
isImage?: boolean;
|
|
807
|
+
}
|
|
808
|
+
|
|
759
809
|
export { }
|
|
760
810
|
|
|
761
811
|
|
|
762
812
|
declare namespace DomainConfig {
|
|
763
813
|
var displayName: string;
|
|
764
814
|
}
|
|
765
|
-
|