diff --git a/package.json b/package.json index a0d44741..92c90241 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@idapgroup/react-image-annotate", - "version": "2.0.6", + "version": "2.0.8", "type": "module", "main": "dist/react-image-annotate.js", "types": "dist/lib.d.ts", @@ -56,7 +56,6 @@ "vite": "^5.2.7", "vite-plugin-dts": "^3.8.1", "vite-plugin-node-polyfills": "^0.21.0", - "vite-raw-plugin": "^1.0.2", "vite-tsconfig-paths": "^4.3.2" }, "peerDependencies": { diff --git a/src/Annotator/index.tsx b/src/Annotator/index.tsx index 5450b68b..3531cc3b 100644 --- a/src/Annotator/index.tsx +++ b/src/Annotator/index.tsx @@ -9,7 +9,7 @@ import { import { ComponentType, FunctionComponent, useEffect, useReducer } from "react"; import Immutable, { ImmutableObject } from "seamless-immutable"; -import type { KeypointsDefinition } from "../ImageCanvas/region-tools"; +import type { KeypointsDefinition } from "../types/region-tools.ts"; import MainLayout from "../MainLayout"; import SettingsProvider from "../SettingsProvider"; import combineReducers from "./reducers/combine-reducers"; diff --git a/src/Annotator/reducers/convert-expanding-line-to-polygon.ts b/src/Annotator/reducers/convert-expanding-line-to-polygon.ts index 0079ce5a..47a795b3 100644 --- a/src/Annotator/reducers/convert-expanding-line-to-polygon.ts +++ b/src/Annotator/reducers/convert-expanding-line-to-polygon.ts @@ -1,7 +1,7 @@ // @flow import { clamp } from "../../utils/clamp"; -import { ExpandingLine } from "../../ImageCanvas/region-tools.tsx"; +import { ExpandingLine } from "../../types/region-tools.ts"; import Immutable from "seamless-immutable"; export default (expandingLine: ExpandingLine) => { diff --git a/src/Annotator/reducers/fix-twisted.ts b/src/Annotator/reducers/fix-twisted.ts index 0a822a2f..ba2ddbef 100644 --- a/src/Annotator/reducers/fix-twisted.ts +++ b/src/Annotator/reducers/fix-twisted.ts @@ -1,6 +1,6 @@ // @flow -import { ExpandingLine } from "../../ImageCanvas/region-tools.tsx"; +import { ExpandingLine } from "../../types/region-tools.ts"; export default (pointsWithAngles: ExpandingLine["points"]) => { // Adjacent angles should not have an angular distance of more than Math.PI diff --git a/src/Annotator/reducers/general-reducer.ts b/src/Annotator/reducers/general-reducer.ts index eaac0795..4a619112 100644 --- a/src/Annotator/reducers/general-reducer.ts +++ b/src/Annotator/reducers/general-reducer.ts @@ -1,10 +1,6 @@ // @flow import { Action, Image, MainLayoutState } from "../../MainLayout/types"; -import { - ExpandingLine, - moveRegion, - Region, -} from "../../ImageCanvas/region-tools"; +import { ExpandingLine, moveRegion, Region } from "../../types/region-tools.ts"; import Immutable, { ImmutableObject } from "seamless-immutable"; import isEqual from "lodash/isEqual"; import getActiveImage from "./get-active-image"; @@ -986,7 +982,7 @@ export default >( case "help": { return state; } - case "full-screen": { + case "fullscreen": { return Immutable(state).setIn(["fullScreen"], true) as T; } case "exit fullscreen": diff --git a/src/Annotator/reducers/get-implied-video-regions.ts b/src/Annotator/reducers/get-implied-video-regions.ts index 989b3cd9..0e862ccf 100644 --- a/src/Annotator/reducers/get-implied-video-regions.ts +++ b/src/Annotator/reducers/get-implied-video-regions.ts @@ -1,6 +1,6 @@ // @flow -import type { Region } from "../../ImageCanvas/region-tools"; +import type { Region } from "../../types/region-tools.ts"; import { MainLayoutVideoAnnotationState } from "../../MainLayout/types.ts"; const emptyArr: Region[] = []; diff --git a/src/HighlightBox/index.tsx b/src/HighlightBox/index.tsx index 51d9d85b..408545e1 100644 --- a/src/HighlightBox/index.tsx +++ b/src/HighlightBox/index.tsx @@ -2,7 +2,7 @@ import classnames from "classnames"; import { createTheme, ThemeProvider } from "@mui/material/styles"; -import type { Point, Region } from "../ImageCanvas/region-tools.tsx"; +import type { Point, Region } from "../types/region-tools.ts"; import { MouseEvents } from "../ImageCanvas/use-mouse.ts"; import { tss } from "tss-react/mui"; diff --git a/src/ImageCanvas/index.tsx b/src/ImageCanvas/index.tsx index 9df587dc..3c11a47d 100644 --- a/src/ImageCanvas/index.tsx +++ b/src/ImageCanvas/index.tsx @@ -18,7 +18,7 @@ import type { Point, Polygon, Region, -} from "./region-tools"; +} from "../types/region-tools.ts"; import { createTheme, ThemeProvider } from "@mui/material/styles"; import PreventScrollToParents from "../PreventScrollToParents"; import useWindowSize from "../hooks/use-window-size.tsx"; diff --git a/src/ImageCanvas/use-project-box.ts b/src/ImageCanvas/use-project-box.ts index b1f1c9b3..5ac6877c 100644 --- a/src/ImageCanvas/use-project-box.ts +++ b/src/ImageCanvas/use-project-box.ts @@ -1,6 +1,6 @@ // @flow weak import useEventCallback from "use-event-callback"; -import { getEnclosingBox, Region } from "./region-tools.tsx"; +import { getEnclosingBox, Region } from "../types/region-tools.ts"; import { CanvasLayoutParams } from "./index.tsx"; import { IMatrix } from "transformation-matrix-js"; import { MutableRefObject } from "react"; diff --git a/src/ImageMask/index.tsx b/src/ImageMask/index.tsx index 19fb79b5..58d44b86 100644 --- a/src/ImageMask/index.tsx +++ b/src/ImageMask/index.tsx @@ -4,7 +4,7 @@ import { CSSProperties, useEffect, useMemo, useState } from "react"; import { useDebounce } from "react-use"; import loadImage from "./load-image"; import autoseg, { AutosegConfig } from "autoseg/webworker"; -import { Region } from "../ImageCanvas/region-tools.tsx"; +import { Region } from "../types/region-tools.ts"; import { ImagePosition } from "../types/common.ts"; function convertToUDTRegions(regions: Region[]) { diff --git a/src/MainLayout/icon-dictionary.tsx b/src/MainLayout/icon-dictionary.tsx index 68eac303..2bac49d7 100644 --- a/src/MainLayout/icon-dictionary.tsx +++ b/src/MainLayout/icon-dictionary.tsx @@ -76,7 +76,7 @@ export const iconDictionary: Record< "create-keypoints": () => ( ), - "full-screen": () => ( + fullscreen: () => ( ), window: () => ( diff --git a/src/MainLayout/index.tsx b/src/MainLayout/index.tsx index 21f97265..a58e8045 100644 --- a/src/MainLayout/index.tsx +++ b/src/MainLayout/index.tsx @@ -250,13 +250,17 @@ export const MainLayout = ({ dispatch({ type: "SELECT_TOOL", selectedTool: item.name }); }); - const onClickHeaderItem = useEventCallback((item) => { - if (item.name === "full-screen") { + const onClickHeaderItem = useEventCallback((item: { name: string }) => { + const btnName = item.name.toLowerCase(); + if (btnName === "fullscreen") { fullScreenHandle.enter(); - } else if (item.name === "window") { + } else if (btnName === "window") { fullScreenHandle.exit(); } - dispatch({ type: "HEADER_BUTTON_CLICKED", buttonName: item.name }); + dispatch({ + type: "HEADER_BUTTON_CLICKED", + buttonName: btnName, + }); }); const debugModeOn = Boolean( @@ -280,7 +284,7 @@ export const MainLayout = ({ activeImage?.regions && { name: "Clone" }, !hideSettings && { name: "Settings" }, !hideFullScreen && - (state.fullScreen ? { name: "window" } : { name: "full-screen" }), + (state.fullScreen ? { name: "Window" } : { name: "Fullscreen" }), !hideSave && { name: "Save" }, ].reduce((acc: { name: string }[], curr) => { if (curr) { diff --git a/src/MainLayout/types.ts b/src/MainLayout/types.ts index 3df343a1..7ff2c6c5 100644 --- a/src/MainLayout/types.ts +++ b/src/MainLayout/types.ts @@ -8,7 +8,7 @@ import type { Point, Polygon, Region, -} from "../ImageCanvas/region-tools.tsx"; +} from "../types/region-tools.ts"; import { AutosegOptions } from "autoseg/webworker"; export type AnnotatorToolEnum = diff --git a/src/MainLayout/use-implied-video-regions.ts b/src/MainLayout/use-implied-video-regions.ts index 9074493b..5d2420b6 100644 --- a/src/MainLayout/use-implied-video-regions.ts +++ b/src/MainLayout/use-implied-video-regions.ts @@ -3,7 +3,7 @@ import { useMemo } from "react"; import getImpliedVideoRegions from "../Annotator/reducers/get-implied-video-regions"; import { MainLayoutState } from "./types"; -import { Region } from "../ImageCanvas/region-tools.tsx"; +import { Region } from "../types/region-tools.ts"; const emptyArr: Region[] = []; diff --git a/src/PointDistances/index.tsx b/src/PointDistances/index.tsx index e3248f62..627513cc 100644 --- a/src/PointDistances/index.tsx +++ b/src/PointDistances/index.tsx @@ -3,7 +3,7 @@ import { Fragment } from "react"; import { createTheme, styled, ThemeProvider } from "@mui/material/styles"; import { ProjectBoxFn } from "../ImageCanvas/use-project-box.ts"; -import { Point, Region } from "../ImageCanvas/region-tools.tsx"; +import { Point, Region } from "../types/region-tools.ts"; const theme = createTheme(); const Svg = styled("svg")(() => ({ diff --git a/src/RegionLabel/index.tsx b/src/RegionLabel/index.tsx index d715993e..68fc8c6c 100644 --- a/src/RegionLabel/index.tsx +++ b/src/RegionLabel/index.tsx @@ -4,7 +4,7 @@ import { memo, useRef } from "react"; import Paper from "@mui/material/Paper"; import { createTheme, ThemeProvider } from "@mui/material/styles"; import classnames from "classnames"; -import type { Region } from "../ImageCanvas/region-tools"; +import type { Region } from "../types/region-tools.ts"; import IconButton from "@mui/material/IconButton"; import Button from "@mui/material/Button"; import TrashIcon from "@mui/icons-material/Delete"; diff --git a/src/RegionSelectAndTransformBoxes/index.tsx b/src/RegionSelectAndTransformBoxes/index.tsx index ca1ec377..f462a194 100644 --- a/src/RegionSelectAndTransformBoxes/index.tsx +++ b/src/RegionSelectAndTransformBoxes/index.tsx @@ -9,7 +9,7 @@ import { type Point, type Polygon, Region, -} from "../ImageCanvas/region-tools.tsx"; +} from "../types/region-tools.ts"; import { MouseEvents } from "../ImageCanvas/use-mouse.ts"; import { ProjectBox, ProjectBoxFn } from "../ImageCanvas/use-project-box.ts"; import { CanvasLayoutParams } from "../ImageCanvas"; diff --git a/src/RegionSelectorSidebarBox/index.tsx b/src/RegionSelectorSidebarBox/index.tsx index 3378f8f6..5e7346c6 100644 --- a/src/RegionSelectorSidebarBox/index.tsx +++ b/src/RegionSelectorSidebarBox/index.tsx @@ -15,7 +15,7 @@ import VisibleIcon from "@mui/icons-material/Visibility"; import VisibleOffIcon from "@mui/icons-material/VisibilityOff"; import classnames from "classnames"; import isEqual from "lodash/isEqual"; -import { Region } from "../ImageCanvas/region-tools.tsx"; +import { Region } from "../types/region-tools.ts"; import { tss } from "tss-react/mui"; const theme = createTheme(); diff --git a/src/RegionShapes/index.tsx b/src/RegionShapes/index.tsx index 84b0be8d..2b21cee1 100644 --- a/src/RegionShapes/index.tsx +++ b/src/RegionShapes/index.tsx @@ -3,11 +3,7 @@ import { memo } from "react"; import colorAlpha from "color-alpha"; import { clamp } from "../utils/clamp.ts"; -import { - KeypointsDefinition, - Line, - Region, -} from "../ImageCanvas/region-tools.tsx"; +import { KeypointsDefinition, Line, Region } from "../types/region-tools.ts"; import Immutable from "seamless-immutable"; import { ImagePosition } from "../types/common.ts"; diff --git a/src/RegionTags/index.tsx b/src/RegionTags/index.tsx index 345f7e3a..f9380d7a 100644 --- a/src/RegionTags/index.tsx +++ b/src/RegionTags/index.tsx @@ -3,7 +3,7 @@ import Paper from "@mui/material/Paper"; import DefaultRegionLabel, { RegionLabelProps } from "../RegionLabel"; import LockIcon from "@mui/icons-material/Lock"; -import { Region } from "../ImageCanvas/region-tools.tsx"; +import { Region } from "../types/region-tools.ts"; import { ProjectBox, ProjectBoxFn } from "../ImageCanvas/use-project-box.ts"; import { MouseEvents } from "../ImageCanvas/use-mouse.ts"; import { ComponentType, FunctionComponent } from "react"; diff --git a/src/lib.tsx b/src/lib.tsx index ba8397dd..118a1b26 100644 --- a/src/lib.tsx +++ b/src/lib.tsx @@ -12,6 +12,20 @@ export type { AnnotatorToolEnum, } from "./MainLayout/types"; +export type { + Region, + BaseRegion, + Box, + PixelRegion, + ExpandingLine, + KeypointDefinition, + Keypoints, + Line, + Polygon, + Point, + KeypointsDefinition, +} from "./types/region-tools"; + export { Annotator }; export default Annotator; diff --git a/src/ImageCanvas/region-tools.tsx b/src/types/region-tools.ts similarity index 100% rename from src/ImageCanvas/region-tools.tsx rename to src/types/region-tools.ts diff --git a/src/utils/get-landmarks-with-transform.ts b/src/utils/get-landmarks-with-transform.ts index 8360cd0b..99b97ccd 100644 --- a/src/utils/get-landmarks-with-transform.ts +++ b/src/utils/get-landmarks-with-transform.ts @@ -1,5 +1,5 @@ // @flow -import type { KeypointDefinition } from "../ImageCanvas/region-tools"; +import type { KeypointDefinition } from "../types/region-tools.ts"; type Parameters = { center: { x: number; y: number }; diff --git a/vite.config.ts b/vite.config.ts index c26c70df..8422a283 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,33 +2,19 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import viteTsconfigPaths from "vite-tsconfig-paths"; import { nodePolyfills } from "vite-plugin-node-polyfills"; -import markdownRawPlugin from "vite-raw-plugin"; import { resolve } from "path"; import dts from "vite-plugin-dts"; import peerDepsExternal from "rollup-plugin-peer-deps-external"; -const process = { - env: {}, - versions: { - node: "14.15.1", // replace with your Node.js version - }, -}; - export default defineConfig(() => { - // process.env = { ...process.env, ...loadEnv(mode, process.cwd()) } return { - // depending on your application, base can also be "/" base: "./", - // @ts-ignore plugins: [ react(), dts(), viteTsconfigPaths(), nodePolyfills(), peerDepsExternal(), - markdownRawPlugin({ - fileRegex: /\.md$/, - }), ], server: { // this ensures that the browser opens upon server start @@ -38,9 +24,6 @@ export default defineConfig(() => { }, define: { global: "globalThis", - "process.env": process.env, - NODE_ENV: '"development"', - "process.versions.node": JSON.stringify(process.versions.node), }, optimizeDeps: { esbuildOptions: { @@ -48,7 +31,6 @@ export default defineConfig(() => { global: "globalThis", }, }, - exclude: ["react", "react-dom"], }, build: { lib: { diff --git a/yarn.lock b/yarn.lock index 46d78375..0b7d9ef3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1744,9 +1744,9 @@ domain-browser@^4.22.0: integrity sha512-ArzcM/II1wCCujdCNyQjXrAFwS4mrLh4C7DZWlaI8mdh7h3BfKdNd3bKXITfl2PT9FtfQqaGvhi1vPRQPimjGA== electron-to-chromium@^1.4.668: - version "1.4.737" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.737.tgz#3a774a58e04980741f65d440f5fdf57af18b6dde" - integrity sha512-QvLTxaLHKdy5YxvixAw/FfHq2eWLUL9KvsPjp0aHK1gI5d3EDuDgITkvj0nFO2c6zUY3ZqVAJQiBYyQP9tQpfw== + version "1.4.738" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.738.tgz#9a7fca98abaee61e20c9c25013d5ce60bb533436" + integrity sha512-lwKft2CLFztD+vEIpesrOtCrko/TFnEJlHFdRhazU7Y/jx5qc4cqsocfVrBg4So4gGe9lvxnbLIoev47WMpg+A== elliptic@^6.5.3, elliptic@^6.5.5: version "6.5.5" @@ -4251,11 +4251,6 @@ vite-plugin-node-polyfills@^0.21.0: "@rollup/plugin-inject" "^5.0.5" node-stdlib-browser "^1.2.0" -vite-raw-plugin@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/vite-raw-plugin/-/vite-raw-plugin-1.0.2.tgz#7be8a6e1275b7a0eb6753d066337957c15f438cd" - integrity sha512-gdp/OFVXBiVq1UwPujVb7+4mmgYHTGrzslMbQvxmgzTN4/HC+3j4GNrumsIKSWfA/y3hktII7XqY38muRaGjhw== - vite-tsconfig-paths@^4.3.2: version "4.3.2" resolved "https://registry.yarnpkg.com/vite-tsconfig-paths/-/vite-tsconfig-paths-4.3.2.tgz#321f02e4b736a90ff62f9086467faf4e2da857a9"