mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-18 06:50:31 +02:00
refactor: separate elements logic into a standalone package (#9285)
This commit is contained in:
@@ -17,5 +17,3 @@ With PNPM, similarly install the package with this command:
|
||||
```bash
|
||||
pnpm add @excalidraw/math
|
||||
```
|
||||
|
||||
## API
|
||||
|
@@ -54,6 +54,6 @@
|
||||
"repository": "https://github.com/excalidraw/excalidraw",
|
||||
"scripts": {
|
||||
"gen:types": "rm -rf types && tsc",
|
||||
"build:esm": "rm -rf dist && node ../../scripts/buildMath.js && yarn gen:types"
|
||||
"build:esm": "rm -rf dist && node ../../scripts/buildBase.js && yarn gen:types"
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import type { Bounds } from "@excalidraw/element/bounds";
|
||||
|
||||
import { isPoint, pointDistance, pointFrom } from "./point";
|
||||
import { rectangle, rectangleIntersectLineSegment } from "./rectangle";
|
||||
|
||||
import type { Curve, GlobalPoint, LineSegment, LocalPoint } from "./types";
|
||||
import type { Bounds } from "../excalidraw/element/bounds";
|
||||
|
||||
/**
|
||||
*
|
@@ -1,4 +1,4 @@
|
||||
import { toBrandedType } from "@excalidraw/excalidraw/utils";
|
||||
import { toBrandedType } from "@excalidraw/common";
|
||||
|
||||
import type { InclusiveRange } from "./types";
|
||||
|
@@ -1,13 +1,13 @@
|
||||
import "../utils/test-utils";
|
||||
import "@excalidraw/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", () => {
|
@@ -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", () => {
|
@@ -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", () => {
|
@@ -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)", () => {
|
@@ -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);
|
@@ -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", () => {
|
@@ -1,4 +1,4 @@
|
||||
import { isVector } from ".";
|
||||
import { isVector } from "../src/vector";
|
||||
|
||||
describe("Vector", () => {
|
||||
test("isVector", () => {
|
@@ -1,24 +1,6 @@
|
||||
{
|
||||
"extends": "../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/types",
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"resolveJsonModule": true,
|
||||
"jsx": "react-jsx",
|
||||
"emitDeclarationOnly": true,
|
||||
"paths": {
|
||||
"@excalidraw/excalidraw": ["../excalidraw/index.tsx"],
|
||||
"@excalidraw/utils": ["../utils/index.ts"],
|
||||
"@excalidraw/math": ["../math/index.ts"],
|
||||
"@excalidraw/excalidraw/*": ["../excalidraw/*"],
|
||||
"@excalidraw/utils/*": ["../utils/*"],
|
||||
"@excalidraw/math/*": ["../math/*"]
|
||||
}
|
||||
},
|
||||
"exclude": ["**/*.test.*", "tests", "types", "examples", "dist"]
|
||||
"outDir": "./dist/types"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user