From 99180e63ce12af7ddcd2edbcfa0ba22059e9e91e Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Sat, 25 Oct 2025 23:46:35 +0200 Subject: [PATCH] move some more stuff around --- src/App/App.tsx | 2 +- src/App/RTHistory.tsx | 3 ++- src/App/ShowAST.tsx | 1 - src/App/TopPanel/ZoomButtons.tsx | 2 +- src/App/VisualEditor/ArrowSVG.tsx | 4 ++-- src/App/VisualEditor/DiamondSVG.tsx | 2 +- src/App/VisualEditor/HistorySVG.tsx | 4 ++-- src/App/VisualEditor/RectHelpers.tsx | 4 ++-- src/App/VisualEditor/RountangleSVG.tsx | 2 +- src/App/VisualEditor/VisualEditor.tsx | 14 +++----------- src/App/VisualEditor/editor_types.ts | 0 src/App/{ => VisualEditor}/shortcut_handler.ts | 2 +- src/App/{VisualEditor => }/parameters.ts | 0 src/statecharts/concrete_syntax.ts | 7 ++++--- src/statecharts/environment.ts | 2 +- src/statecharts/parser.ts | 4 ++-- src/{App/VisualEditor => util}/geometry.ts | 11 +++++++++-- src/{App/VisualEditor => util}/svg_helper.ts | 0 18 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 src/App/VisualEditor/editor_types.ts rename src/App/{ => VisualEditor}/shortcut_handler.ts (92%) rename src/App/{VisualEditor => }/parameters.ts (100%) rename src/{App/VisualEditor => util}/geometry.ts (95%) rename src/{App/VisualEditor => util}/svg_helper.ts (100%) diff --git a/src/App/App.tsx b/src/App/App.tsx index b4bd334..c2ecc69 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -11,7 +11,7 @@ import "./App.css"; import { TopPanel } from "./TopPanel/TopPanel"; import { ShowAST, ShowInputEvents, ShowInternalEvents, ShowOutputEvents } from "./ShowAST"; import { parseStatechart } from "../statecharts/parser"; -import { getKeyHandler } from "./shortcut_handler"; +import { getKeyHandler } from "./VisualEditor/shortcut_handler"; import { BottomPanel } from "./BottomPanel"; import { emptyState } from "@/statecharts/concrete_syntax"; import { PersistentDetails } from "./PersistentDetails"; diff --git a/src/App/RTHistory.tsx b/src/App/RTHistory.tsx index 295905f..f89b592 100644 --- a/src/App/RTHistory.tsx +++ b/src/App/RTHistory.tsx @@ -1,9 +1,10 @@ import { Dispatch, memo, Ref, SetStateAction, useCallback } from "react"; import { Statechart, stateDescription } from "../statecharts/abstract_syntax"; -import { BigStep, Environment, Mode, RaisedEvent, RT_Event } from "../statecharts/runtime_types"; +import { BigStep, Mode, RaisedEvent, RT_Event } from "../statecharts/runtime_types"; import { formatTime } from "../util/util"; import { TimeMode } from "../statecharts/time"; import { TraceItem, TraceState } from "./App"; +import { Environment } from "@/statecharts/environment"; type RTHistoryProps = { trace: TraceState|null, diff --git a/src/App/ShowAST.tsx b/src/App/ShowAST.tsx index a7f86dd..8a63081 100644 --- a/src/App/ShowAST.tsx +++ b/src/App/ShowAST.tsx @@ -1,6 +1,5 @@ import { ConcreteState, UnstableState, stateDescription, Transition } from "../statecharts/abstract_syntax"; import { Action, EventTrigger, Expression } from "../statecharts/label_ast"; -import { RT_Statechart } from "../statecharts/runtime_types"; import "./AST.css"; diff --git a/src/App/TopPanel/ZoomButtons.tsx b/src/App/TopPanel/ZoomButtons.tsx index 91a80c9..cd8ea09 100644 --- a/src/App/TopPanel/ZoomButtons.tsx +++ b/src/App/TopPanel/ZoomButtons.tsx @@ -1,4 +1,4 @@ -import { ZOOM_MAX, ZOOM_MIN, ZOOM_STEP } from "@/App/VisualEditor/parameters"; +import { ZOOM_MAX, ZOOM_MIN, ZOOM_STEP } from "@/App/parameters"; import { Dispatch, memo, SetStateAction, useEffect } from "react"; import { KeyInfoHidden, KeyInfoVisible } from "./KeyInfo"; diff --git a/src/App/VisualEditor/ArrowSVG.tsx b/src/App/VisualEditor/ArrowSVG.tsx index 3f01d47..9b12a3a 100644 --- a/src/App/VisualEditor/ArrowSVG.tsx +++ b/src/App/VisualEditor/ArrowSVG.tsx @@ -1,7 +1,7 @@ import { memo } from "react"; import { Arrow, ArrowPart } from "../../statecharts/concrete_syntax"; -import { ArcDirection, euclideanDistance } from "./geometry"; -import { CORNER_HELPER_RADIUS } from "./parameters"; +import { ArcDirection, euclideanDistance } from "../../util/geometry"; +import { CORNER_HELPER_RADIUS } from "../parameters"; import { arraysEqual } from "@/util/util"; diff --git a/src/App/VisualEditor/DiamondSVG.tsx b/src/App/VisualEditor/DiamondSVG.tsx index 77a86f8..df35101 100644 --- a/src/App/VisualEditor/DiamondSVG.tsx +++ b/src/App/VisualEditor/DiamondSVG.tsx @@ -1,6 +1,6 @@ import { Diamond, RectSide } from "@/statecharts/concrete_syntax"; import { rountangleMinSize } from "./VisualEditor"; -import { Vec2D } from "./geometry"; +import { Vec2D } from "../../util/geometry"; import { RectHelper } from "./RectHelpers"; import { memo } from "react"; import { arraysEqual } from "@/util/util"; diff --git a/src/App/VisualEditor/HistorySVG.tsx b/src/App/VisualEditor/HistorySVG.tsx index b6b3d7b..f0fccb4 100644 --- a/src/App/VisualEditor/HistorySVG.tsx +++ b/src/App/VisualEditor/HistorySVG.tsx @@ -1,6 +1,6 @@ import { memo } from "react"; -import { Vec2D } from "./geometry"; -import { HISTORY_RADIUS } from "./parameters"; +import { Vec2D } from "../../util/geometry"; +import { HISTORY_RADIUS } from "../parameters"; export const HistorySVG = memo(function HistorySVG(props: {uid: string, topLeft: Vec2D, kind: "shallow"|"deep", selected: boolean, highlight: boolean}) { const text = props.kind === "shallow" ? "H" : "H*"; diff --git a/src/App/VisualEditor/RectHelpers.tsx b/src/App/VisualEditor/RectHelpers.tsx index 8668789..15f6cbb 100644 --- a/src/App/VisualEditor/RectHelpers.tsx +++ b/src/App/VisualEditor/RectHelpers.tsx @@ -1,7 +1,7 @@ import { memo } from "react"; import { RectSide } from "../../statecharts/concrete_syntax"; -import { Vec2D } from "./geometry"; -import { CORNER_HELPER_OFFSET, CORNER_HELPER_RADIUS } from "./parameters"; +import { Vec2D } from "../../util/geometry"; +import { CORNER_HELPER_OFFSET, CORNER_HELPER_RADIUS } from "../parameters"; function lineGeometryProps(size: Vec2D): [RectSide, object][] { return [ diff --git a/src/App/VisualEditor/RountangleSVG.tsx b/src/App/VisualEditor/RountangleSVG.tsx index 4eae8db..62b0d10 100644 --- a/src/App/VisualEditor/RountangleSVG.tsx +++ b/src/App/VisualEditor/RountangleSVG.tsx @@ -1,6 +1,6 @@ import { memo } from "react"; import { Rountangle, RectSide } from "../../statecharts/concrete_syntax"; -import { ROUNTANGLE_RADIUS } from "./parameters"; +import { ROUNTANGLE_RADIUS } from "../parameters"; import { RectHelper } from "./RectHelpers"; import { rountangleMinSize } from "./VisualEditor"; import { arraysEqual } from "@/util/util"; diff --git a/src/App/VisualEditor/VisualEditor.tsx b/src/App/VisualEditor/VisualEditor.tsx index 72be33c..160da43 100644 --- a/src/App/VisualEditor/VisualEditor.tsx +++ b/src/App/VisualEditor/VisualEditor.tsx @@ -3,9 +3,9 @@ import { ClipboardEvent, Dispatch, memo, ReactElement, SetStateAction, useCallba import { Statechart } from "../../statecharts/abstract_syntax"; import { Arrow, ArrowPart, Diamond, History, Rountangle, RectSide, Text } from "../../statecharts/concrete_syntax"; import { parseStatechart, TraceableError } from "../../statecharts/parser"; -import { ArcDirection, Line2D, Rect2D, Vec2D, addV2D, arcDirection, area, getBottomSide, getLeftSide, getRightSide, getTopSide, isEntirelyWithin, normalizeRect, scaleV2D, subtractV2D, transformLine, transformRect } from "./geometry"; -import { MIN_ROUNTANGLE_SIZE } from "./parameters"; -import { getBBoxInSvgCoords } from "./svg_helper"; +import { ArcDirection, Rect2D, Vec2D, addV2D, arcDirection, area, isEntirelyWithin, normalizeRect, scaleV2D, subtractV2D, transformLine, transformRect } from "../../util/geometry"; +import { MIN_ROUNTANGLE_SIZE } from "../parameters"; +import { getBBoxInSvgCoords } from "../../util/svg_helper"; import { ArrowSVG } from "./ArrowSVG"; import { RountangleSVG } from "./RountangleSVG"; import { TextSVG } from "./TextSVG"; @@ -52,14 +52,6 @@ type Selectable = RountangleSelectable | ArrowSelectable | TextSelectable | Hist type Selection = Selectable[]; - -export const sides: [RectSide, (r:Rect2D)=>Line2D][] = [ - ["left", getLeftSide], - ["top", getTopSide], - ["right", getRightSide], - ["bottom", getBottomSide], -]; - export type InsertMode = "and"|"or"|"pseudo"|"shallow"|"deep"|"transition"|"text"; type VisualEditorProps = { diff --git a/src/App/VisualEditor/editor_types.ts b/src/App/VisualEditor/editor_types.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/App/shortcut_handler.ts b/src/App/VisualEditor/shortcut_handler.ts similarity index 92% rename from src/App/shortcut_handler.ts rename to src/App/VisualEditor/shortcut_handler.ts index 834f874..d7792f7 100644 --- a/src/App/shortcut_handler.ts +++ b/src/App/VisualEditor/shortcut_handler.ts @@ -1,5 +1,5 @@ import { Dispatch, SetStateAction } from "react"; -import { InsertMode } from "./VisualEditor/VisualEditor"; +import { InsertMode } from "./VisualEditor"; export function getKeyHandler(setMode: Dispatch>) { return function onKeyDown(e: KeyboardEvent) { diff --git a/src/App/VisualEditor/parameters.ts b/src/App/parameters.ts similarity index 100% rename from src/App/VisualEditor/parameters.ts rename to src/App/parameters.ts diff --git a/src/statecharts/concrete_syntax.ts b/src/statecharts/concrete_syntax.ts index 372ef98..3fb9a72 100644 --- a/src/statecharts/concrete_syntax.ts +++ b/src/statecharts/concrete_syntax.ts @@ -1,6 +1,7 @@ -import { Rect2D, Vec2D, Line2D, euclideanDistance, intersectLines, isWithin, lineBBox, subtractV2D } from "../App/VisualEditor/geometry"; -import { ARROW_SNAP_THRESHOLD, HISTORY_RADIUS, TEXT_SNAP_THRESHOLD } from "../App/VisualEditor/parameters"; -import { sides, VisualEditorState } from "../App/VisualEditor/VisualEditor"; +import { Rect2D, Vec2D, Line2D, euclideanDistance, intersectLines, isWithin, lineBBox, subtractV2D } from "../util/geometry"; +import { ARROW_SNAP_THRESHOLD, HISTORY_RADIUS, TEXT_SNAP_THRESHOLD } from "../App/parameters"; +import { VisualEditorState } from "../App/VisualEditor/VisualEditor"; +import { sides } from "@/util/geometry"; export type Rountangle = { uid: string; diff --git a/src/statecharts/environment.ts b/src/statecharts/environment.ts index d53dfa2..bc1e35f 100644 --- a/src/statecharts/environment.ts +++ b/src/statecharts/environment.ts @@ -13,7 +13,7 @@ export type Environment = { // read variable get(key: string): any; - entries(): Iterator<[string, any]>; + entries(): IterableIterator<[string, any]>; } diff --git a/src/statecharts/parser.ts b/src/statecharts/parser.ts index 2b631a7..d20ea61 100644 --- a/src/statecharts/parser.ts +++ b/src/statecharts/parser.ts @@ -1,10 +1,10 @@ import { ConcreteState, HistoryState, OrState, UnstableState, Statechart, stateDescription, Transition } from "./abstract_syntax"; import { Rountangle } from "./concrete_syntax"; -import { isEntirelyWithin, Rect2D } from "../App/VisualEditor/geometry"; +import { isEntirelyWithin, Rect2D } from "../util/geometry"; import { Action, EventTrigger, Expression, ParsedText } from "./label_ast"; import { parse as parseLabel, SyntaxError } from "./label_parser"; import { Connections } from "./detect_connections"; -import { HISTORY_RADIUS } from "../App/VisualEditor/parameters"; +import { HISTORY_RADIUS } from "../App/parameters"; import { VisualEditorState } from "@/App/VisualEditor/VisualEditor"; import { memoize } from "@/util/util"; diff --git a/src/App/VisualEditor/geometry.ts b/src/util/geometry.ts similarity index 95% rename from src/App/VisualEditor/geometry.ts rename to src/util/geometry.ts index f183193..7d92b23 100644 --- a/src/App/VisualEditor/geometry.ts +++ b/src/util/geometry.ts @@ -1,4 +1,4 @@ -import { RectSide } from "../../statecharts/concrete_syntax"; +import { RectSide } from "../statecharts/concrete_syntax"; export type Vec2D = { x: number; @@ -195,4 +195,11 @@ export function arcDirection(start: RectSide, end: RectSide): ArcDirection { return "ccw"; } return "cw"; -} \ No newline at end of file +} + +export const sides: [RectSide, (r: Rect2D) => Line2D][] = [ + ["left", getLeftSide], + ["top", getTopSide], + ["right", getRightSide], + ["bottom", getBottomSide], +]; diff --git a/src/App/VisualEditor/svg_helper.ts b/src/util/svg_helper.ts similarity index 100% rename from src/App/VisualEditor/svg_helper.ts rename to src/util/svg_helper.ts