fix: Circular reference (#10544)

* fix: Circular reference

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* fix: Lint

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>

* Trigger CI

---------

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Márk Tolmács
2025-12-21 22:14:21 +01:00
committed by GitHub
parent 7cc31ac64a
commit d87620b239
22 changed files with 44 additions and 45 deletions
+17
View File
@@ -0,0 +1,17 @@
/**
* x and y position of top left corner, x and y position of bottom right corner
*/
export type Bounds = readonly [
minX: number,
minY: number,
maxX: number,
maxY: number,
];
export const isBounds = (box: unknown): box is Bounds =>
Array.isArray(box) &&
box.length === 4 &&
typeof box[0] === "number" &&
typeof box[1] === "number" &&
typeof box[2] === "number" &&
typeof box[3] === "number";
+1
View File
@@ -1,4 +1,5 @@
export * from "./binary-heap"; export * from "./binary-heap";
export * from "./bounds";
export * from "./colors"; export * from "./colors";
export * from "./constants"; export * from "./constants";
export * from "./font-metadata"; export * from "./font-metadata";
+1 -3
View File
@@ -6,12 +6,10 @@ import {
type LocalPoint, type LocalPoint,
} from "@excalidraw/math"; } from "@excalidraw/math";
import { isBounds } from "@excalidraw/element";
import type { Curve } from "@excalidraw/math"; import type { Curve } from "@excalidraw/math";
import type { LineSegment } from "@excalidraw/utils"; import type { LineSegment } from "@excalidraw/utils";
import type { Bounds } from "@excalidraw/element"; import { type Bounds, isBounds } from "./bounds";
// The global data holder to collect the debug operations // The global data holder to collect the debug operations
declare global { declare global {
+1 -3
View File
@@ -22,10 +22,9 @@ import {
} from "@excalidraw/math"; } from "@excalidraw/math";
import type { LineSegment, LocalPoint, Radians } from "@excalidraw/math"; import type { LineSegment, LocalPoint, Radians } from "@excalidraw/math";
import type { AppState } from "@excalidraw/excalidraw/types"; import type { AppState } from "@excalidraw/excalidraw/types";
import type { MapEntry, Mutable } from "@excalidraw/common/utility-types"; import type { MapEntry, Mutable } from "@excalidraw/common/utility-types";
import type { Bounds } from "@excalidraw/common";
import { import {
doBoundsIntersect, doBoundsIntersect,
@@ -64,7 +63,6 @@ import { projectFixedPointOntoDiagonal } from "./utils";
import type { Scene } from "./Scene"; import type { Scene } from "./Scene";
import type { Bounds } from "./bounds";
import type { ElementUpdate } from "./mutateElement"; import type { ElementUpdate } from "./mutateElement";
import type { import type {
BindMode, BindMode,
+1 -10
View File
@@ -2,6 +2,7 @@ import rough from "roughjs/bin/rough";
import { import {
arrayToMap, arrayToMap,
type Bounds,
invariant, invariant,
rescalePoints, rescalePoints,
sizeOf, sizeOf,
@@ -78,16 +79,6 @@ export type RectangleBox = {
type MaybeQuadraticSolution = [number | null, number | null] | false; type MaybeQuadraticSolution = [number | null, number | null] | false;
/**
* x and y position of top left corner, x and y position of bottom right corner
*/
export type Bounds = readonly [
minX: number,
minY: number,
maxX: number,
maxY: number,
];
export type SceneBounds = readonly [ export type SceneBounds = readonly [
sceneX: number, sceneX: number,
sceneY: number, sceneY: number,
+1 -2
View File
@@ -1,4 +1,4 @@
import { invariant, isTransparent } from "@excalidraw/common"; import { invariant, isTransparent, type Bounds } from "@excalidraw/common";
import { import {
curveIntersectLineSegment, curveIntersectLineSegment,
isPointWithinBounds, isPointWithinBounds,
@@ -29,7 +29,6 @@ import type { FrameNameBounds } from "@excalidraw/excalidraw/types";
import { isPathALoop } from "./utils"; import { isPathALoop } from "./utils";
import { import {
type Bounds,
doBoundsIntersect, doBoundsIntersect,
elementCenterPoint, elementCenterPoint,
getCenterForBounds, getCenterForBounds,
+1 -1
View File
@@ -1,4 +1,5 @@
import { import {
type Bounds,
TEXT_AUTOWRAP_THRESHOLD, TEXT_AUTOWRAP_THRESHOLD,
getGridPoint, getGridPoint,
getFontString, getFontString,
@@ -29,7 +30,6 @@ import {
import type { Scene } from "./Scene"; import type { Scene } from "./Scene";
import type { Bounds } from "./bounds";
import type { ExcalidrawElement } from "./types"; import type { ExcalidrawElement } from "./types";
export const dragSelectedElements = ( export const dragSelectedElements = (
+1 -1
View File
@@ -14,6 +14,7 @@ import {
} from "@excalidraw/math"; } from "@excalidraw/math";
import { import {
type Bounds,
BinaryHeap, BinaryHeap,
invariant, invariant,
isAnyTrue, isAnyTrue,
@@ -54,7 +55,6 @@ import {
import { aabbForElement, pointInsideBounds } from "./bounds"; import { aabbForElement, pointInsideBounds } from "./bounds";
import { getHoveredElementForBinding } from "./collision"; import { getHoveredElementForBinding } from "./collision";
import type { Bounds } from "./bounds";
import type { Heading } from "./heading"; import type { Heading } from "./heading";
import type { import type {
Arrowhead, Arrowhead,
+7 -2
View File
@@ -1,4 +1,9 @@
import { invariant, isDevEnv, isTestEnv } from "@excalidraw/common"; import {
invariant,
isDevEnv,
isTestEnv,
type Bounds,
} from "@excalidraw/common";
import { import {
pointFrom, pointFrom,
@@ -19,7 +24,7 @@ import type {
Vector, Vector,
} from "@excalidraw/math"; } from "@excalidraw/math";
import { getCenterForBounds, type Bounds } from "./bounds"; import { getCenterForBounds } from "./bounds";
import type { ExcalidrawBindableElement } from "./types"; import type { ExcalidrawBindableElement } from "./types";
+1 -1
View File
@@ -42,6 +42,7 @@ import type {
NullableGridSize, NullableGridSize,
Zoom, Zoom,
} from "@excalidraw/excalidraw/types"; } from "@excalidraw/excalidraw/types";
import type { Bounds } from "@excalidraw/common";
import { import {
calculateFixedPointForNonElbowArrowBinding, calculateFixedPointForNonElbowArrowBinding,
@@ -68,7 +69,6 @@ import { isLineElement } from "./typeChecks";
import type { Scene } from "./Scene"; import type { Scene } from "./Scene";
import type { Bounds } from "./bounds";
import type { import type {
NonDeleted, NonDeleted,
ExcalidrawLinearElement, ExcalidrawLinearElement,
+1 -1
View File
@@ -13,6 +13,7 @@ import {
import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math"; import type { GlobalPoint, LineSegment, LocalPoint } from "@excalidraw/math";
import type { AppState, Zoom } from "@excalidraw/excalidraw/types"; import type { AppState, Zoom } from "@excalidraw/excalidraw/types";
import type { Bounds } from "@excalidraw/common";
import { getElementAbsoluteCoords } from "./bounds"; import { getElementAbsoluteCoords } from "./bounds";
import { import {
@@ -23,7 +24,6 @@ import {
} from "./transformHandles"; } from "./transformHandles";
import { isImageElement, isLinearElement } from "./typeChecks"; import { isImageElement, isLinearElement } from "./typeChecks";
import type { Bounds } from "./bounds";
import type { import type {
TransformHandleType, TransformHandleType,
TransformHandle, TransformHandle,
+1 -1
View File
@@ -11,6 +11,7 @@ import type {
InteractiveCanvasAppState, InteractiveCanvasAppState,
Zoom, Zoom,
} from "@excalidraw/excalidraw/types"; } from "@excalidraw/excalidraw/types";
import type { Bounds } from "@excalidraw/common";
import { getElementAbsoluteCoords } from "./bounds"; import { getElementAbsoluteCoords } from "./bounds";
import { import {
@@ -20,7 +21,6 @@ import {
isLinearElement, isLinearElement,
} from "./typeChecks"; } from "./typeChecks";
import type { Bounds } from "./bounds";
import type { import type {
ElementsMap, ElementsMap,
ExcalidrawElement, ExcalidrawElement,
-10
View File
@@ -6,7 +6,6 @@ import type { ElementOrToolType } from "@excalidraw/excalidraw/types";
import type { MarkNonNullable } from "@excalidraw/common/utility-types"; import type { MarkNonNullable } from "@excalidraw/common/utility-types";
import type { Bounds } from "./bounds";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawTextElement, ExcalidrawTextElement,
@@ -356,15 +355,6 @@ export const getDefaultRoundnessTypeForElement = (
return null; return null;
}; };
// TODO: Move this to @excalidraw/math
export const isBounds = (box: unknown): box is Bounds =>
Array.isArray(box) &&
box.length === 4 &&
typeof box[0] === "number" &&
typeof box[1] === "number" &&
typeof box[2] === "number" &&
typeof box[3] === "number";
export const getLinearElementSubType = ( export const getLinearElementSubType = (
element: ExcalidrawLinearElement, element: ExcalidrawLinearElement,
): ExcalidrawLinearElementSubType => { ): ExcalidrawLinearElementSubType => {
+1 -1
View File
@@ -2,6 +2,7 @@ import { pointFrom } from "@excalidraw/math";
import { Excalidraw } from "@excalidraw/excalidraw"; import { Excalidraw } from "@excalidraw/excalidraw";
import { import {
type Bounds,
KEYS, KEYS,
getSizeFromPoints, getSizeFromPoints,
reseed, reseed,
@@ -22,7 +23,6 @@ import { resizeSingleElement } from "../src/resizeElements";
import { LinearElementEditor } from "../src/linearElementEditor"; import { LinearElementEditor } from "../src/linearElementEditor";
import { getElementPointsCoords } from "../src/bounds"; import { getElementPointsCoords } from "../src/bounds";
import type { Bounds } from "../src/bounds";
import type { import type {
ExcalidrawElbowArrowElement, ExcalidrawElbowArrowElement,
ExcalidrawFreeDrawElement, ExcalidrawFreeDrawElement,
@@ -6,7 +6,7 @@ import { hitElementBoundingBox } from "@excalidraw/element";
import type { GlobalPoint, Radians } from "@excalidraw/math"; import type { GlobalPoint, Radians } from "@excalidraw/math";
import type { Bounds } from "@excalidraw/element"; import type { Bounds } from "@excalidraw/common";
import type { import type {
ElementsMap, ElementsMap,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
+1 -1
View File
@@ -28,7 +28,7 @@ import { shouldTestInside } from "@excalidraw/element";
import { hasBoundTextElement, isBoundToContainer } from "@excalidraw/element"; import { hasBoundTextElement, isBoundToContainer } from "@excalidraw/element";
import { getBoundTextElementId } from "@excalidraw/element"; import { getBoundTextElementId } from "@excalidraw/element";
import type { Bounds } from "@excalidraw/element"; import type { Bounds } from "@excalidraw/common";
import type { GlobalPoint, LineSegment } from "@excalidraw/math/types"; import type { GlobalPoint, LineSegment } from "@excalidraw/math/types";
import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types"; import type { ElementsMap, ExcalidrawElement } from "@excalidraw/element/types";
+2 -1
View File
@@ -6,8 +6,9 @@ import {
polygonIncludesPointNonZero, polygonIncludesPointNonZero,
} from "@excalidraw/math"; } from "@excalidraw/math";
import { type Bounds } from "@excalidraw/common";
import { import {
type Bounds,
computeBoundTextPosition, computeBoundTextPosition,
doBoundsIntersect, doBoundsIntersect,
getBoundTextElement, getBoundTextElement,
+1 -1
View File
@@ -39,7 +39,7 @@ import { type Mutable } from "@excalidraw/common/utility-types";
import { newTextElement } from "@excalidraw/element"; import { newTextElement } from "@excalidraw/element";
import type { Bounds } from "@excalidraw/element"; import type { Bounds } from "@excalidraw/common";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
+1 -1
View File
@@ -24,7 +24,7 @@ import {
import type { InclusiveRange } from "@excalidraw/math"; import type { InclusiveRange } from "@excalidraw/math";
import type { Bounds } from "@excalidraw/element"; import type { Bounds } from "@excalidraw/common";
import type { MaybeTransformHandleType } from "@excalidraw/element"; import type { MaybeTransformHandleType } from "@excalidraw/element";
import type { import type {
ElementsMap, ElementsMap,
+1 -1
View File
@@ -5,7 +5,7 @@ import {
type LocalPoint, type LocalPoint,
} from "@excalidraw/math"; } from "@excalidraw/math";
import type { Bounds } from "@excalidraw/element"; import type { Bounds } from "@excalidraw/common";
export type LineSegment<P extends LocalPoint | GlobalPoint> = [P, P]; export type LineSegment<P extends LocalPoint | GlobalPoint> = [P, P];
+1 -2
View File
@@ -1,4 +1,4 @@
import { arrayToMap } from "@excalidraw/common"; import { arrayToMap, type Bounds } from "@excalidraw/common";
import { getElementBounds } from "@excalidraw/element"; import { getElementBounds } from "@excalidraw/element";
import { import {
isArrowElement, isArrowElement,
@@ -14,7 +14,6 @@ import {
rangeInclusive, rangeInclusive,
} from "@excalidraw/math"; } from "@excalidraw/math";
import type { Bounds } from "@excalidraw/element";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawFreeDrawElement, ExcalidrawFreeDrawElement,
+1 -1
View File
@@ -1,6 +1,6 @@
import { API } from "@excalidraw/excalidraw/tests/helpers/api"; import { API } from "@excalidraw/excalidraw/tests/helpers/api";
import type { Bounds } from "@excalidraw/element"; import type { Bounds } from "@excalidraw/common";
import { import {
elementPartiallyOverlapsWithOrContainsBBox, elementPartiallyOverlapsWithOrContainsBBox,