From 5e6889570981dae9113336a7dd4ac786abc35ac3 Mon Sep 17 00:00:00 2001 From: Marcel Mraz Date: Mon, 17 Mar 2025 14:05:13 +0100 Subject: [PATCH] Fixing math package --- packages/element/bounds.ts | 8 ++++---- packages/math/CHANGELOG.md | 0 packages/math/index.ts | 24 +++++++++++------------ packages/math/{ => src}/angle.ts | 0 packages/math/{ => src}/curve.ts | 0 packages/math/{ => src}/ellipse.ts | 0 packages/math/{ => src}/line.ts | 0 packages/math/{ => src}/point.ts | 0 packages/math/{ => src}/polygon.ts | 0 packages/math/{ => src}/range.ts | 2 +- packages/math/{ => src}/rectangle.ts | 0 packages/math/{ => src}/segment.ts | 0 packages/math/{ => src}/triangle.ts | 0 packages/math/{ => src}/types.ts | 0 packages/math/{ => src}/utils.ts | 0 packages/math/{ => src}/vector.ts | 0 packages/math/{ => tests}/curve.test.ts | 8 ++++---- packages/math/{ => tests}/ellipse.test.ts | 10 +++++----- packages/math/{ => tests}/line.test.ts | 4 ++-- packages/math/{ => tests}/point.test.ts | 4 ++-- packages/math/{ => tests}/range.test.ts | 2 +- packages/math/{ => tests}/segment.test.ts | 4 ++-- packages/math/{ => tests}/vector.test.ts | 2 +- packages/tsconfig.base.json | 2 +- scripts/buildShared.js | 2 +- tsconfig.json | 2 +- 26 files changed, 37 insertions(+), 37 deletions(-) delete mode 100644 packages/math/CHANGELOG.md rename packages/math/{ => src}/angle.ts (100%) rename packages/math/{ => src}/curve.ts (100%) rename packages/math/{ => src}/ellipse.ts (100%) rename packages/math/{ => src}/line.ts (100%) rename packages/math/{ => src}/point.ts (100%) rename packages/math/{ => src}/polygon.ts (100%) rename packages/math/{ => src}/range.ts (97%) rename packages/math/{ => src}/rectangle.ts (100%) rename packages/math/{ => src}/segment.ts (100%) rename packages/math/{ => src}/triangle.ts (100%) rename packages/math/{ => src}/types.ts (100%) rename packages/math/{ => src}/utils.ts (100%) rename packages/math/{ => src}/vector.ts (100%) rename packages/math/{ => tests}/curve.test.ts (94%) rename packages/math/{ => tests}/ellipse.test.ts (94%) rename packages/math/{ => tests}/line.test.ts (88%) rename packages/math/{ => tests}/point.test.ts (84%) rename packages/math/{ => tests}/range.test.ts (99%) rename packages/math/{ => tests}/segment.test.ts (82%) rename packages/math/{ => tests}/vector.test.ts (88%) diff --git a/packages/element/bounds.ts b/packages/element/bounds.ts index 9d8fd22d3..bb1cf7a0a 100644 --- a/packages/element/bounds.ts +++ b/packages/element/bounds.ts @@ -17,10 +17,10 @@ import type { Radians, } from "@excalidraw/math"; -import { rescalePoints } from "../points"; -import { generateRoughOptions } from "../scene/Shape"; -import { ShapeCache } from "../scene/ShapeCache"; -import { arrayToMap, invariant } from "../utils"; +import { rescalePoints } from "@excalidraw/excalidraw/points"; +import { generateRoughOptions } from "@excalidraw/excalidraw/scene/Shape"; +import { ShapeCache } from "@excalidraw/excalidraw/scene/ShapeCache"; +import { arrayToMap, invariant } from "@excalidraw/excalidraw/utils"; import { LinearElementEditor } from "./linearElementEditor"; import { getBoundTextElement, getContainerElement } from "./textElement"; diff --git a/packages/math/CHANGELOG.md b/packages/math/CHANGELOG.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/math/index.ts b/packages/math/index.ts index d00ab469d..955fbd348 100644 --- a/packages/math/index.ts +++ b/packages/math/index.ts @@ -1,12 +1,12 @@ -export * from "./angle"; -export * from "./curve"; -export * from "./line"; -export * from "./point"; -export * from "./polygon"; -export * from "./range"; -export * from "./rectangle"; -export * from "./segment"; -export * from "./triangle"; -export * from "./types"; -export * from "./vector"; -export * from "./utils"; +export * from "./src/angle"; +export * from "./src/curve"; +export * from "./src/line"; +export * from "./src/point"; +export * from "./src/polygon"; +export * from "./src/range"; +export * from "./src/rectangle"; +export * from "./src/segment"; +export * from "./src/triangle"; +export * from "./src/types"; +export * from "./src/vector"; +export * from "./src/utils"; diff --git a/packages/math/angle.ts b/packages/math/src/angle.ts similarity index 100% rename from packages/math/angle.ts rename to packages/math/src/angle.ts diff --git a/packages/math/curve.ts b/packages/math/src/curve.ts similarity index 100% rename from packages/math/curve.ts rename to packages/math/src/curve.ts diff --git a/packages/math/ellipse.ts b/packages/math/src/ellipse.ts similarity index 100% rename from packages/math/ellipse.ts rename to packages/math/src/ellipse.ts diff --git a/packages/math/line.ts b/packages/math/src/line.ts similarity index 100% rename from packages/math/line.ts rename to packages/math/src/line.ts diff --git a/packages/math/point.ts b/packages/math/src/point.ts similarity index 100% rename from packages/math/point.ts rename to packages/math/src/point.ts diff --git a/packages/math/polygon.ts b/packages/math/src/polygon.ts similarity index 100% rename from packages/math/polygon.ts rename to packages/math/src/polygon.ts diff --git a/packages/math/range.ts b/packages/math/src/range.ts similarity index 97% rename from packages/math/range.ts rename to packages/math/src/range.ts index 8417f8f38..1b292344e 100644 --- a/packages/math/range.ts +++ b/packages/math/src/range.ts @@ -1,4 +1,4 @@ -import { toBrandedType } from "@excalidraw/common/utils"; +import { toBrandedType } from "@excalidraw/common"; import type { InclusiveRange } from "./types"; diff --git a/packages/math/rectangle.ts b/packages/math/src/rectangle.ts similarity index 100% rename from packages/math/rectangle.ts rename to packages/math/src/rectangle.ts diff --git a/packages/math/segment.ts b/packages/math/src/segment.ts similarity index 100% rename from packages/math/segment.ts rename to packages/math/src/segment.ts diff --git a/packages/math/triangle.ts b/packages/math/src/triangle.ts similarity index 100% rename from packages/math/triangle.ts rename to packages/math/src/triangle.ts diff --git a/packages/math/types.ts b/packages/math/src/types.ts similarity index 100% rename from packages/math/types.ts rename to packages/math/src/types.ts diff --git a/packages/math/utils.ts b/packages/math/src/utils.ts similarity index 100% rename from packages/math/utils.ts rename to packages/math/src/utils.ts diff --git a/packages/math/vector.ts b/packages/math/src/vector.ts similarity index 100% rename from packages/math/vector.ts rename to packages/math/src/vector.ts diff --git a/packages/math/curve.test.ts b/packages/math/tests/curve.test.ts similarity index 94% rename from packages/math/curve.test.ts rename to packages/math/tests/curve.test.ts index 8d60a7346..753ab5bef 100644 --- a/packages/math/curve.test.ts +++ b/packages/math/tests/curve.test.ts @@ -1,13 +1,13 @@ -import "../utils/test-utils"; +import "../../utils/test-utils"; import { curve, curveClosestPoint, curveIntersectLineSegment, curvePointDistance, -} from "./curve"; -import { pointFrom } from "./point"; -import { lineSegment } from "./segment"; +} from "../src/curve"; +import { pointFrom } from "../src/point"; +import { lineSegment } from "../src/segment"; describe("Math curve", () => { describe("line segment intersection", () => { diff --git a/packages/math/ellipse.test.ts b/packages/math/tests/ellipse.test.ts similarity index 94% rename from packages/math/ellipse.test.ts rename to packages/math/tests/ellipse.test.ts index bcaab2a5d..4fa0d4e59 100644 --- a/packages/math/ellipse.test.ts +++ b/packages/math/tests/ellipse.test.ts @@ -4,12 +4,12 @@ import { ellipseIncludesPoint, ellipseTouchesPoint, ellipseLineIntersectionPoints, -} from "./ellipse"; -import { line } from "./line"; -import { pointFrom } from "./point"; -import { lineSegment } from "./segment"; +} from "../src/ellipse"; +import { line } from "../src/line"; +import { pointFrom } from "../src/point"; +import { lineSegment } from "../src/segment"; -import type { Ellipse, GlobalPoint } from "./types"; +import type { Ellipse, GlobalPoint } from "../src/types"; describe("point and ellipse", () => { it("point on ellipse", () => { diff --git a/packages/math/line.test.ts b/packages/math/tests/line.test.ts similarity index 88% rename from packages/math/line.test.ts rename to packages/math/tests/line.test.ts index 0e6bb1cc8..c8915a466 100644 --- a/packages/math/line.test.ts +++ b/packages/math/tests/line.test.ts @@ -1,5 +1,5 @@ -import { line, linesIntersectAt } from "./line"; -import { pointFrom } from "./point"; +import { line, linesIntersectAt } from "../src/line"; +import { pointFrom } from "../src/point"; describe("line-line intersections", () => { it("should correctly detect intersection at origin", () => { diff --git a/packages/math/point.test.ts b/packages/math/tests/point.test.ts similarity index 84% rename from packages/math/point.test.ts rename to packages/math/tests/point.test.ts index 0ed59ee9a..3f3ee15cd 100644 --- a/packages/math/point.test.ts +++ b/packages/math/tests/point.test.ts @@ -1,6 +1,6 @@ -import { pointFrom, pointRotateRads } from "./point"; +import { pointFrom, pointRotateRads } from "../src/point"; -import type { Radians } from "./types"; +import type { Radians } from "../src/types"; describe("rotate", () => { it("should rotate over (x2, y2) and return the rotated coordinates for (x1, y1)", () => { diff --git a/packages/math/range.test.ts b/packages/math/tests/range.test.ts similarity index 99% rename from packages/math/range.test.ts rename to packages/math/tests/range.test.ts index fb4b6a38d..9808f77f4 100644 --- a/packages/math/range.test.ts +++ b/packages/math/tests/range.test.ts @@ -1,4 +1,4 @@ -import { rangeInclusive, rangeIntersection, rangesOverlap } from "./range"; +import { rangeInclusive, rangeIntersection, rangesOverlap } from "../src/range"; describe("range overlap", () => { const range1_4 = rangeInclusive(1, 4); diff --git a/packages/math/segment.test.ts b/packages/math/tests/segment.test.ts similarity index 82% rename from packages/math/segment.test.ts rename to packages/math/tests/segment.test.ts index 4237a3c85..6b29bba59 100644 --- a/packages/math/segment.test.ts +++ b/packages/math/tests/segment.test.ts @@ -1,5 +1,5 @@ -import { pointFrom } from "./point"; -import { lineSegment, lineSegmentIntersectionPoints } from "./segment"; +import { pointFrom } from "../src/point"; +import { lineSegment, lineSegmentIntersectionPoints } from "../src/segment"; describe("line-segment intersections", () => { it("should correctly detect intersection", () => { diff --git a/packages/math/vector.test.ts b/packages/math/tests/vector.test.ts similarity index 88% rename from packages/math/vector.test.ts rename to packages/math/tests/vector.test.ts index 145c90953..820f60400 100644 --- a/packages/math/vector.test.ts +++ b/packages/math/tests/vector.test.ts @@ -1,4 +1,4 @@ -import { isVector } from "."; +import { isVector } from "../src/vector"; describe("Vector", () => { test("isVector", () => { diff --git a/packages/tsconfig.base.json b/packages/tsconfig.base.json index c6b6d3c72..643fe7bc0 100644 --- a/packages/tsconfig.base.json +++ b/packages/tsconfig.base.json @@ -19,7 +19,7 @@ "@excalidraw/excalidraw": ["./excalidraw/index.tsx"], "@excalidraw/excalidraw/*": ["./excalidraw/*"], "@excalidraw/math": ["./math/index.ts"], - "@excalidraw/math/*": ["./math/*"], + "@excalidraw/math/*": ["./math/src/*"], "@excalidraw/utils": ["./utils/index.ts"], "@excalidraw/utils/*": ["./utils/*"], } diff --git a/scripts/buildShared.js b/scripts/buildShared.js index 256655745..ef31a4876 100644 --- a/scripts/buildShared.js +++ b/scripts/buildShared.js @@ -14,7 +14,7 @@ const getConfig = (outdir) => ({ entryNames: "[name]", assetNames: "[dir]/[name]", alias: { - "@excalidraw/common": path.resolve(__dirname, "../packages/common/src"), + "@excalidraw/common": path.resolve(__dirname, "../packages/common"), "@excalidraw/element": path.resolve(__dirname, "../packages/element"), "@excalidraw/excalidraw": path.resolve(__dirname, "../packages/excalidraw"), "@excalidraw/utils": path.resolve(__dirname, "../packages/utils"), diff --git a/tsconfig.json b/tsconfig.json index da21fe801..d5d6cecad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -26,7 +26,7 @@ "@excalidraw/element": ["./packages/element/index.ts"], "@excalidraw/element/*": ["./packages/element/*"], "@excalidraw/math": ["./packages/math/index.ts"], - "@excalidraw/math/*": ["./packages/math/*"], + "@excalidraw/math/*": ["./packages/math/src/*"], "@excalidraw/utils": ["./packages/utils/index.ts"], "@excalidraw/utils/*": ["./packages/utils/*"], }