Skip to content

Commit

Permalink
fixed re-export types
Browse files Browse the repository at this point in the history
  • Loading branch information
yasenytskyoleh committed Apr 17, 2024
1 parent da6d3ca commit 794c36d
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 61 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Annotator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/Annotator/reducers/fix-twisted.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 2 additions & 6 deletions src/Annotator/reducers/general-reducer.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -986,7 +982,7 @@ export default <T extends ImmutableObject<MainLayoutState>>(
case "help": {
return state;
}
case "full-screen": {
case "fullscreen": {
return Immutable(state).setIn(["fullScreen"], true) as T;
}
case "exit fullscreen":
Expand Down
2 changes: 1 addition & 1 deletion src/Annotator/reducers/get-implied-video-regions.ts
Original file line number Diff line number Diff line change
@@ -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[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/HighlightBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/ImageCanvas/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/ImageCanvas/use-project-box.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/ImageMask/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/MainLayout/icon-dictionary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const iconDictionary: Record<
"create-keypoints": () => (
<FontAwesomeIcon style={faStyle} size="xs" fixedWidth icon={faExpand} />
),
"full-screen": () => (
fullscreen: () => (
<FontAwesomeIcon style={faStyle} size="xs" fixedWidth icon={faExpand} />
),
window: () => (
Expand Down
14 changes: 9 additions & 5 deletions src/MainLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/MainLayout/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion src/MainLayout/use-implied-video-regions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];

Expand Down
2 changes: 1 addition & 1 deletion src/PointDistances/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")(() => ({
Expand Down
2 changes: 1 addition & 1 deletion src/RegionLabel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/RegionSelectAndTransformBoxes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/RegionSelectorSidebarBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 1 addition & 5 deletions src/RegionShapes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/RegionTags/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
14 changes: 14 additions & 0 deletions src/lib.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/get-landmarks-with-transform.ts
Original file line number Diff line number Diff line change
@@ -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 };
Expand Down
18 changes: 0 additions & 18 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,17 +24,13 @@ export default defineConfig(() => {
},
define: {
global: "globalThis",
"process.env": process.env,
NODE_ENV: '"development"',
"process.versions.node": JSON.stringify(process.versions.node),
},
optimizeDeps: {
esbuildOptions: {
define: {
global: "globalThis",
},
},
exclude: ["react", "react-dom"],
},
build: {
lib: {
Expand Down
11 changes: 3 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 794c36d

Please sign in to comment.