diff --git a/src/blueapi/visit.ts b/src/blueapi/visit.ts index ff96356..d750a28 100644 --- a/src/blueapi/visit.ts +++ b/src/blueapi/visit.ts @@ -1,5 +1,5 @@ -import { RawValue } from "../pv/types"; -import { forceString, ReadPvRawValue } from "../pv/util"; +import { RawValue } from "pv/types"; +import { forceString, ReadPvRawValue } from "pv/util"; /** * Read the full visit path from the visit PV set by the beamline staff. diff --git a/src/components/Extruder/CollectionSetupEx.tsx b/src/components/Extruder/CollectionSetupEx.tsx index b8c3096..ec7bd9d 100644 --- a/src/components/Extruder/CollectionSetupEx.tsx +++ b/src/components/Extruder/CollectionSetupEx.tsx @@ -1,12 +1,12 @@ import { Box, Grid2, Stack } from "@mui/material"; import React from "react"; -import { ParameterInput } from "../ParameterInputs"; import { LaserCheckButtons, PumpProbeSelection, PumpProbeSetup, } from "./PumpProbeSelection"; -import { AbortButton, RunPlanButton } from "../../blueapi/BlueapiComponents"; +import { ParameterInput } from "components/ParameterInputs"; +import { AbortButton, RunPlanButton } from "blueapi/BlueapiComponents"; /**Main collection input window for the extruderpanel. */ export function CollectionSetupEx() { diff --git a/src/components/Extruder/PumpProbeSelection.tsx b/src/components/Extruder/PumpProbeSelection.tsx index ef505d3..f0d449d 100644 --- a/src/components/Extruder/PumpProbeSelection.tsx +++ b/src/components/Extruder/PumpProbeSelection.tsx @@ -5,9 +5,9 @@ import { Select, Tooltip, } from "@mui/material"; -import { ParameterInput } from "../ParameterInputs"; +import { RunPlanButton } from "blueapi/BlueapiComponents"; +import { ParameterInput } from "components/ParameterInputs"; import React from "react"; -import { RunPlanButton } from "../../blueapi/BlueapiComponents"; export function PumpProbeSelection({ pumpProbe, diff --git a/src/components/FixedTarget/CollectionSetupFt.tsx b/src/components/FixedTarget/CollectionSetupFt.tsx index 9f3c191..a09d984 100644 --- a/src/components/FixedTarget/CollectionSetupFt.tsx +++ b/src/components/FixedTarget/CollectionSetupFt.tsx @@ -11,9 +11,9 @@ import { import React from "react"; import { PumpProbeOptions } from "./PumpProbeComponents"; import { MapView } from "./FixedTargetMapComponents"; -import { chipTypes, MapTypes, pumpProbeMode } from "../params"; -import { AbortButton, RunPlanButton } from "../../blueapi/BlueapiComponents"; -import { ParameterInput } from "../ParameterInputs"; +import { RunPlanButton, AbortButton } from "blueapi/BlueapiComponents"; +import { ParameterInput } from "components/ParameterInputs"; +import { pumpProbeMode, chipTypes, MapTypes } from "components/params"; type ParametersProps = { subDir: string; diff --git a/src/components/FixedTarget/FixedTargetMapComponents.tsx b/src/components/FixedTarget/FixedTargetMapComponents.tsx index a12679d..90a8e89 100644 --- a/src/components/FixedTarget/FixedTargetMapComponents.tsx +++ b/src/components/FixedTarget/FixedTargetMapComponents.tsx @@ -13,8 +13,8 @@ import { ToggleButtonGroup, Tooltip, } from "@mui/material"; +import { MapTypes } from "components/params"; import React from "react"; -import { MapTypes } from "../params"; /** * Create list of numbered ToggleButtons to add to a ToggleButtonGroup diff --git a/src/components/FixedTarget/PumpProbeComponents.tsx b/src/components/FixedTarget/PumpProbeComponents.tsx index b943320..806be29 100644 --- a/src/components/FixedTarget/PumpProbeComponents.tsx +++ b/src/components/FixedTarget/PumpProbeComponents.tsx @@ -11,8 +11,8 @@ import { TextField, Tooltip, } from "@mui/material"; +import { EavaRequest, calculateEAVA } from "components/params"; import React from "react"; -import { calculateEAVA, EavaRequest } from "../params"; /** * Opens a dilog showing the calculated laser delay to set for each EAVA setting, given the laser diff --git a/src/components/OavVideoStream.tsx b/src/components/OavVideoStream.tsx index 4781cf7..da03780 100644 --- a/src/components/OavVideoStream.tsx +++ b/src/components/OavVideoStream.tsx @@ -1,13 +1,13 @@ import { Box } from "@mui/material"; -import { PvComponent } from "../pv/PvComponent"; -import { PvItem, PvDescription } from "../pv/types"; +import React from "react"; +import { useContainerDimensions } from "./OavVideoStreamHelper"; +import { PvComponent } from "pv/PvComponent"; +import { PvDescription, PvItem } from "pv/types"; import { + useParsedPvConnection, parseNumericPv, pvIntArrayToString, - useParsedPvConnection, -} from "../pv/util"; -import React from "react"; -import { useContainerDimensions } from "./OavVideoStreamHelper"; +} from "pv/util"; /* * A viewer which allows overlaying a crosshair (takes numbers which could be the values from a react useState hook) diff --git a/src/components/ReadOnlyInputs.tsx b/src/components/ReadOnlyInputs.tsx index 9a4e1f2..203e99e 100644 --- a/src/components/ReadOnlyInputs.tsx +++ b/src/components/ReadOnlyInputs.tsx @@ -1,5 +1,5 @@ import { Grid2 } from "@mui/material"; -import { RoPvBox } from "../pv/PvComponent"; +import { RoPvBox } from "pv/PvComponent"; type RoPvAddress = { visit: string; diff --git a/src/components/SelectionControl.tsx b/src/components/SelectionControl.tsx index f55fc4f..62c1c26 100644 --- a/src/components/SelectionControl.tsx +++ b/src/components/SelectionControl.tsx @@ -1,8 +1,8 @@ import React from "react"; -import { PvDescription } from "../pv/types"; -import { submitAndRunPlanImmediately } from "../blueapi/blueapi"; +import { PvDescription } from "pv/types"; +import { submitAndRunPlanImmediately } from "blueapi/blueapi"; import { FormControl, InputLabel, MenuItem, Select } from "@mui/material"; -import { forceString, useParsedPvConnection } from "../pv/util"; +import { forceString, useParsedPvConnection } from "pv/util"; type SelectionProps = PvDescription & { id: string; diff --git a/src/components/SerialNavBar.tsx b/src/components/SerialNavBar.tsx index 160cea1..584f8c7 100644 --- a/src/components/SerialNavBar.tsx +++ b/src/components/SerialNavBar.tsx @@ -5,7 +5,7 @@ import { type ImageColourSchemeSwitchType, } from "@diamondlightsource/sci-react-ui"; import { Link } from "react-router-dom"; -import i24ssx from "../assets/i24ssx.svg"; +import i24ssx from "assets/i24ssx.svg"; const ssxLogo: ImageColourSchemeSwitchType = { src: i24ssx, diff --git a/src/components/WorkerStatus.tsx b/src/components/WorkerStatus.tsx index 2a8ac76..edcfb7c 100644 --- a/src/components/WorkerStatus.tsx +++ b/src/components/WorkerStatus.tsx @@ -1,6 +1,6 @@ import { Grid2, Stack, Typography } from "@mui/material"; -import { processUseBlueApiCall, useBlueApiCall } from "../blueapi/blueapi"; +import { processUseBlueApiCall, useBlueApiCall } from "blueapi/blueapi"; import { useState } from "react"; export function WorkerStatus() { diff --git a/src/routes/BeamlineI24.tsx b/src/routes/BeamlineI24.tsx index 122e5a6..beade52 100644 --- a/src/routes/BeamlineI24.tsx +++ b/src/routes/BeamlineI24.tsx @@ -1,7 +1,7 @@ import { Box, Tab, Tabs, useTheme } from "@mui/material"; -import { BeamlineStatsTabPanel } from "../screens/BeamlineStats"; -import { DetectorMotionTabPanel } from "../screens/DetectorMotion"; -import { OavMover } from "../screens/OavMover"; +import { BeamlineStatsTabPanel } from "screens/BeamlineStats"; +import { DetectorMotionTabPanel } from "screens/DetectorMotion"; +import { OavMover } from "screens/OavMover"; import React from "react"; interface TabPanelProps { diff --git a/src/routes/Extruder.tsx b/src/routes/Extruder.tsx index 0ca6ce6..922ce92 100644 --- a/src/routes/Extruder.tsx +++ b/src/routes/Extruder.tsx @@ -1,6 +1,6 @@ import { Box, Typography, useTheme } from "@mui/material"; -import { ReadOnlyInputs } from "../components/ReadOnlyInputs"; -import { ParamsPanel } from "../screens/CollectionPanel"; +import { ReadOnlyInputs } from "components/ReadOnlyInputs"; +import { ParamsPanel } from "screens/CollectionPanel"; export function Extruder() { const theme = useTheme(); diff --git a/src/routes/FixedTarget.tsx b/src/routes/FixedTarget.tsx index 1d8fe4f..6226125 100644 --- a/src/routes/FixedTarget.tsx +++ b/src/routes/FixedTarget.tsx @@ -1,6 +1,6 @@ import { Box, Typography, useTheme } from "@mui/material"; -import { ParamsPanel } from "../screens/CollectionPanel"; -import { ReadOnlyInputs } from "../components/ReadOnlyInputs"; +import { ParamsPanel } from "screens/CollectionPanel"; +import { ReadOnlyInputs } from "components/ReadOnlyInputs"; export function FixedTarget() { const theme = useTheme(); diff --git a/src/screens/BeamlineStats.tsx b/src/screens/BeamlineStats.tsx index ae709b8..dc79c5d 100644 --- a/src/screens/BeamlineStats.tsx +++ b/src/screens/BeamlineStats.tsx @@ -7,10 +7,10 @@ import { Typography, useTheme, } from "@mui/material"; -import { PvItem } from "../pv/types"; -import { PvComponent } from "../pv/PvComponent"; -import { forceString, parseNumericPv } from "../pv/util"; -import { WorkerStatus } from "../components/WorkerStatus"; +import { PvItem } from "pv/types"; +import { PvComponent } from "pv/PvComponent"; +import { forceString, parseNumericPv } from "pv/util"; +import { WorkerStatus } from "components/WorkerStatus"; type StateBoxProps = { children: React.ReactNode; diff --git a/src/screens/CollectionPanel.tsx b/src/screens/CollectionPanel.tsx index 9629d9d..fcb17a4 100644 --- a/src/screens/CollectionPanel.tsx +++ b/src/screens/CollectionPanel.tsx @@ -1,6 +1,6 @@ import { Box, Typography } from "@mui/material"; -import { CollectionSetupFt } from "../components/FixedTarget/CollectionSetupFt"; -import { CollectionSetupEx } from "../components/Extruder/CollectionSetupEx"; +import { CollectionSetupFt } from "components/FixedTarget/CollectionSetupFt"; +import { CollectionSetupEx } from "components/Extruder/CollectionSetupEx"; type ExptType = { expt: "extruder" | "fixed-target"; diff --git a/src/screens/DetectorMotion.tsx b/src/screens/DetectorMotion.tsx index 8bc6ac8..b452bc8 100644 --- a/src/screens/DetectorMotion.tsx +++ b/src/screens/DetectorMotion.tsx @@ -1,6 +1,6 @@ import { Stack, Box, useTheme } from "@mui/material"; -import { RoPvBox } from "../pv/PvComponent"; -import { RunPlanButton } from "../blueapi/BlueapiComponents"; +import { RoPvBox } from "pv/PvComponent"; +import { RunPlanButton } from "blueapi/BlueapiComponents"; function DetectorState() { const theme = useTheme(); diff --git a/src/screens/OavMover.tsx b/src/screens/OavMover.tsx index 4ef3f6f..eab0917 100644 --- a/src/screens/OavMover.tsx +++ b/src/screens/OavMover.tsx @@ -12,7 +12,7 @@ import { useTheme, Drawer, } from "@mui/material"; -import { OavVideoStream } from "../components/OavVideoStream"; +import { OavVideoStream } from "components/OavVideoStream"; import { ArrowBackRounded, ArrowDownwardRounded, @@ -24,14 +24,14 @@ import { import { useState } from "react"; import React from "react"; -import { submitAndRunPlanImmediately } from "../blueapi/blueapi"; -import { CoordNumberInput } from "../components/CoordNumberInput"; -import { PvDescription } from "../pv/types"; -import { SelectionWithPlanRunner } from "../components/SelectionControl"; -import { BacklightPositions, ZoomLevels } from "../pv/enumPvValues"; -import oxfordChipDiagram from "../assets/Oxford Chip Diagram.excalidraw.svg"; -import { RunPlanButton } from "../blueapi/BlueapiComponents"; -import { parseInstrumentSession, readVisitFromPv } from "../blueapi/visit"; +import { submitAndRunPlanImmediately } from "blueapi/blueapi"; +import { CoordNumberInput } from "components/CoordNumberInput"; +import { PvDescription } from "pv/types"; +import { SelectionWithPlanRunner } from "components/SelectionControl"; +import { BacklightPositions, ZoomLevels } from "pv/enumPvValues"; +import oxfordChipDiagram from "assets/Oxford Chip Diagram.excalidraw.svg"; +import { RunPlanButton } from "blueapi/BlueapiComponents"; +import { parseInstrumentSession, readVisitFromPv } from "blueapi/visit"; const buttonStyle = { color: "white", diff --git a/tsconfig.app.json b/tsconfig.app.json index 5a2def4..dc8e950 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -6,6 +6,11 @@ "module": "ESNext", "skipLibCheck": true, + "baseUrl": "./", + "paths": { + "*": ["./src/*"] + }, + /* Bundler mode */ "moduleResolution": "Bundler", "allowImportingTsExtensions": true, diff --git a/vite.config.ts b/vite.config.ts index c1f7da1..d817bea 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,5 +1,6 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; +import path from "path"; // https://vite.dev/config/ export default defineConfig({ @@ -10,5 +11,15 @@ export default defineConfig({ VITE_PVWS_SSL: "true", }, }, + resolve: { + alias: { + assets: path.resolve(__dirname, "./src/assets"), + blueapi: path.resolve(__dirname, "./src/blueapi"), + components: path.resolve(__dirname, "./src/components"), + pv: path.resolve(__dirname, "./src/pv"), + routes: path.resolve(__dirname, "./src/routes"), + screens: path.resolve(__dirname, "./src/screens"), + }, + }, base: "/mx-daq-ui/", }); diff --git a/vitest.config.ts b/vitest.config.ts index 9f6250a..7803d6a 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,7 +1,18 @@ +import path from "path"; import { defineConfig } from "vitest/config"; export default defineConfig({ test: { environment: "jsdom", }, + resolve: { + alias: { + assets: path.resolve(__dirname, "./src/assets"), + blueapi: path.resolve(__dirname, "./src/blueapi"), + components: path.resolve(__dirname, "./src/components"), + pv: path.resolve(__dirname, "./src/pv"), + routes: path.resolve(__dirname, "./src/routes"), + screens: path.resolve(__dirname, "./src/screens"), + }, + }, });