mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Move utils source into src/
This commit is contained in:
parent
ba0a9e0cb4
commit
4a182f985b
31 changed files with 47 additions and 49 deletions
|
@ -47,14 +47,6 @@ export default defineConfig(({ mode }) => {
|
|||
find: /^@excalidraw\/excalidraw\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "../packages/excalidraw/$1"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils$/,
|
||||
replacement: path.resolve(__dirname, "../packages/utils/index.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "../packages/utils/$1"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/math$/,
|
||||
replacement: path.resolve(__dirname, "../packages/math/src/index.ts"),
|
||||
|
@ -63,6 +55,14 @@ export default defineConfig(({ mode }) => {
|
|||
find: /^@excalidraw\/math\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "../packages/math/src/$1"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils$/,
|
||||
replacement: path.resolve(__dirname, "../packages/utils/src/index.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "../packages/utils/src/$1"),
|
||||
},
|
||||
],
|
||||
},
|
||||
build: {
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
pointRotateRads,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import { getCurvePathOps } from "@excalidraw/utils/geometry/shape";
|
||||
import { getCurvePathOps } from "@excalidraw/utils/shape";
|
||||
|
||||
import type {
|
||||
Degrees,
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
} from "@excalidraw/math/ellipse";
|
||||
|
||||
import { isPointInShape, isPointOnShape } from "@excalidraw/utils/collision";
|
||||
import { getPolygonShape } from "@excalidraw/utils/geometry/shape";
|
||||
import { getPolygonShape } from "@excalidraw/utils/shape";
|
||||
|
||||
import type {
|
||||
GlobalPoint,
|
||||
|
@ -26,7 +26,7 @@ import type {
|
|||
Radians,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import type { GeometricShape } from "@excalidraw/utils/geometry/shape";
|
||||
import type { GeometricShape } from "@excalidraw/utils/shape";
|
||||
|
||||
import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
vectorFromPoint,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import { getCurvePathOps } from "@excalidraw/utils/geometry/shape";
|
||||
import { getCurvePathOps } from "@excalidraw/utils/shape";
|
||||
|
||||
import {
|
||||
DRAGGING_THRESHOLD,
|
||||
|
@ -20,7 +20,7 @@ import {
|
|||
tupleToCoors,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
// TODO: remove the dependency on the scene
|
||||
// TODO: remove direct dependency on the scene, should be passed in or injected instead
|
||||
import Scene from "@excalidraw/excalidraw/scene/Scene";
|
||||
|
||||
import type { Store } from "@excalidraw/excalidraw/store";
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
toBrandedType,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
// TODO_SEP: should be passed in or injected instead
|
||||
// TODO: remove direct dependency on the scene, should be passed in or injected instead
|
||||
import Scene from "@excalidraw/excalidraw/scene/Scene";
|
||||
|
||||
import type { Radians } from "@excalidraw/math";
|
||||
|
|
|
@ -23,7 +23,7 @@ import {
|
|||
getFreedrawShape,
|
||||
getPolygonShape,
|
||||
type GeometricShape,
|
||||
} from "@excalidraw/utils/geometry/shape";
|
||||
} from "@excalidraw/utils/shape";
|
||||
|
||||
import type { NormalizedZoomValue, Zoom } from "@excalidraw/excalidraw/types";
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@ import {
|
|||
render,
|
||||
} from "@excalidraw/excalidraw/tests/test-utils";
|
||||
|
||||
import "@excalidraw/utils/test-utils";
|
||||
|
||||
import type { LocalPoint } from "@excalidraw/math";
|
||||
|
||||
import { bindLinearElement } from "../src/binding";
|
||||
|
||||
import "../../utils/test-utils";
|
||||
|
||||
import type {
|
||||
ExcalidrawArrowElement,
|
||||
ExcalidrawBindableElement,
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
vectorNormalize,
|
||||
} from "@excalidraw/math";
|
||||
import { isPointInShape } from "@excalidraw/utils/collision";
|
||||
import { getSelectionBoxShape } from "@excalidraw/utils/geometry/shape";
|
||||
import { getSelectionBoxShape } from "@excalidraw/utils/shape";
|
||||
|
||||
import {
|
||||
COLOR_PALETTE,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@import "../css/variables.module";
|
||||
@import "../css/variables.module.scss";
|
||||
|
||||
.excalidraw {
|
||||
--avatar-size: 1.75rem;
|
||||
|
|
|
@ -21,6 +21,8 @@ import {
|
|||
DEFAULT_ELEMENT_STROKE_COLOR_INDEX,
|
||||
} from "@excalidraw/common";
|
||||
|
||||
import "@excalidraw/utils/test-utils";
|
||||
|
||||
import type { LocalPoint, Radians } from "@excalidraw/math";
|
||||
|
||||
import type {
|
||||
|
@ -35,7 +37,6 @@ import type {
|
|||
} from "@excalidraw/element/types";
|
||||
|
||||
import "../global.d.ts";
|
||||
import "../../utils/test-utils";
|
||||
|
||||
import {
|
||||
actionSendBackward,
|
||||
|
|
|
@ -5,6 +5,8 @@ import { bindOrUnbindLinearElement } from "@excalidraw/element/binding";
|
|||
|
||||
import { KEYS, reseed } from "@excalidraw/common";
|
||||
|
||||
import "@excalidraw/utils/test-utils";
|
||||
|
||||
import type {
|
||||
ExcalidrawLinearElement,
|
||||
NonDeleted,
|
||||
|
@ -17,7 +19,6 @@ import { Excalidraw } from "../index";
|
|||
import * as InteractiveCanvas from "../renderer/interactiveScene";
|
||||
import * as StaticScene from "../renderer/staticScene";
|
||||
|
||||
import "../../utils/test-utils";
|
||||
|
||||
import { UI, Pointer, Keyboard } from "./helpers/ui";
|
||||
import { render, fireEvent, act, unmountComponent } from "./test-utils";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import "../../utils/test-utils";
|
||||
import "@excalidraw/utils/test-utils";
|
||||
|
||||
import {
|
||||
curve,
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
"@excalidraw/excalidraw/*": ["./excalidraw/*"],
|
||||
"@excalidraw/math": ["./math/src/index.ts"],
|
||||
"@excalidraw/math/*": ["./math/src/*"],
|
||||
"@excalidraw/utils": ["./utils/index.ts"],
|
||||
"@excalidraw/utils/*": ["./utils/*"]
|
||||
"@excalidraw/utils": ["./utils/src/index.ts"],
|
||||
"@excalidraw/utils/*": ["./utils/src/*"]
|
||||
}
|
||||
},
|
||||
"exclude": ["**/*.test.*", "tests", "types", "examples", "dist"]
|
||||
|
|
|
@ -12,13 +12,9 @@ import {
|
|||
|
||||
import type { Curve } from "@excalidraw/math";
|
||||
|
||||
import {
|
||||
pointInEllipse,
|
||||
pointOnEllipse,
|
||||
type GeometricShape,
|
||||
} from "./geometry/shape";
|
||||
import { pointInEllipse, pointOnEllipse, type GeometricShape } from "./shape";
|
||||
|
||||
import type { Polycurve, Polyline } from "./geometry/shape";
|
||||
import type { Polycurve, Polyline } from "./shape";
|
||||
|
||||
// check if the given point is considered on the given shape's border
|
||||
export const isPointOnShape = <Point extends GlobalPoint | LocalPoint>(
|
|
@ -9,9 +9,9 @@ import {
|
|||
|
||||
import type { Curve, Degrees, GlobalPoint } from "@excalidraw/math";
|
||||
|
||||
import { pointOnCurve, pointOnPolyline } from "./collision";
|
||||
import { pointOnCurve, pointOnPolyline } from "../src/collision";
|
||||
|
||||
import type { Polyline } from "./geometry/shape";
|
||||
import type { Polyline } from "../src/shape";
|
||||
|
||||
describe("point and curve", () => {
|
||||
const c: Curve<GlobalPoint> = curve(
|
|
@ -3,7 +3,7 @@ import * as mockedSceneExportUtils from "@excalidraw/excalidraw/scene/export";
|
|||
import { diagramFactory } from "@excalidraw/excalidraw/tests/fixtures/diagramFixture";
|
||||
import { vi } from "vitest";
|
||||
|
||||
import * as utils from ".";
|
||||
import * as utils from "../src";
|
||||
|
||||
const exportToSvgSpy = vi.spyOn(mockedSceneExportUtils, "exportToSvg");
|
||||
|
|
@ -15,7 +15,7 @@ import type {
|
|||
Radians,
|
||||
} from "@excalidraw/math";
|
||||
|
||||
import { pointInEllipse, pointOnEllipse, type Ellipse } from "./shape";
|
||||
import { pointInEllipse, pointOnEllipse, type Ellipse } from "../src/shape";
|
||||
|
||||
describe("point and line", () => {
|
||||
// const l: Line<GlobalPoint> = line(point(1, 0), point(1, 2));
|
|
@ -4,7 +4,7 @@ import { API } from "@excalidraw/excalidraw/tests/helpers/api";
|
|||
|
||||
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
|
||||
|
||||
import * as utils from "./index";
|
||||
import * as utils from "../src";
|
||||
|
||||
// NOTE this test file is using the actual API, unmocked. Hence splitting it
|
||||
// from the other test file, because I couldn't figure out how to test
|
|
@ -6,7 +6,7 @@ import {
|
|||
elementPartiallyOverlapsWithOrContainsBBox,
|
||||
elementsOverlappingBBox,
|
||||
isElementInsideBBox,
|
||||
} from "./withinBounds";
|
||||
} from "../src/withinBounds";
|
||||
|
||||
const makeElement = (x: number, y: number, width: number, height: number) =>
|
||||
API.createElement({
|
|
@ -32,7 +32,7 @@ const getConfig = (outdir) => ({
|
|||
"@excalidraw/element": path.resolve(__dirname, "../packages/element/src"),
|
||||
"@excalidraw/excalidraw": path.resolve(__dirname, "../packages/excalidraw"),
|
||||
"@excalidraw/math": path.resolve(__dirname, "../packages/math/src"),
|
||||
"@excalidraw/utils": path.resolve(__dirname, "../packages/utils"),
|
||||
"@excalidraw/utils": path.resolve(__dirname, "../packages/utils/src"),
|
||||
},
|
||||
loader: {
|
||||
".woff2": "file",
|
||||
|
|
|
@ -10,7 +10,7 @@ const getConfig = (outdir) => ({
|
|||
outdir,
|
||||
bundle: true,
|
||||
format: "esm",
|
||||
entryPoints: ["index.ts"],
|
||||
entryPoints: ["src/index.ts"],
|
||||
entryNames: "[name]",
|
||||
assetNames: "[dir]/[name]",
|
||||
alias: {
|
||||
|
@ -18,7 +18,7 @@ const getConfig = (outdir) => ({
|
|||
"@excalidraw/element": path.resolve(__dirname, "../packages/element/src"),
|
||||
"@excalidraw/excalidraw": path.resolve(__dirname, "../packages/excalidraw"),
|
||||
"@excalidraw/math": path.resolve(__dirname, "../packages/math/src"),
|
||||
"@excalidraw/utils": path.resolve(__dirname, "../packages/utils"),
|
||||
"@excalidraw/utils": path.resolve(__dirname, "../packages/utils/src"),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
"@excalidraw/element/*": ["./packages/element/src/*"],
|
||||
"@excalidraw/math": ["./packages/math/src/index.ts"],
|
||||
"@excalidraw/math/*": ["./packages/math/src/*"],
|
||||
"@excalidraw/utils": ["./packages/utils/index.ts"],
|
||||
"@excalidraw/utils/*": ["./packages/utils/*"]
|
||||
"@excalidraw/utils": ["./packages/utils/src/index.ts"],
|
||||
"@excalidraw/utils/*": ["./packages/utils/src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["packages", "excalidraw-app"],
|
||||
|
|
|
@ -29,14 +29,6 @@ export default defineConfig({
|
|||
find: /^@excalidraw\/excalidraw\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "./packages/excalidraw/$1"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils$/,
|
||||
replacement: path.resolve(__dirname, "./packages/utils/index.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "./packages/utils/$1"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/math$/,
|
||||
replacement: path.resolve(__dirname, "./packages/math/src/index.ts"),
|
||||
|
@ -45,6 +37,14 @@ export default defineConfig({
|
|||
find: /^@excalidraw\/math\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "./packages/math/src/$1"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils$/,
|
||||
replacement: path.resolve(__dirname, "./packages/utils/src/index.ts"),
|
||||
},
|
||||
{
|
||||
find: /^@excalidraw\/utils\/(.*?)/,
|
||||
replacement: path.resolve(__dirname, "./packages/utils/src/$1"),
|
||||
},
|
||||
],
|
||||
},
|
||||
//@ts-ignore
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue