refactor: auto ordered imports (#9163)
All checks were successful
Tests / test (push) Successful in 4m38s

This commit is contained in:
Marcel Mraz 2025-03-12 15:23:31 +01:00 committed by GitHub
parent 82b9a6b464
commit 21ffaf4d76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
421 changed files with 3532 additions and 2763 deletions

View file

@ -4,6 +4,7 @@ import {
type GlobalPoint,
type LocalPoint,
} from "@excalidraw/math";
import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
export type LineSegment<P extends LocalPoint | GlobalPoint> = [P, P];

View file

@ -1,4 +1,3 @@
import type { Curve, Degrees, GlobalPoint } from "@excalidraw/math";
import {
curve,
degreesToRadians,
@ -7,7 +6,11 @@ import {
pointFrom,
pointRotateDegs,
} from "@excalidraw/math";
import type { Curve, Degrees, GlobalPoint } from "@excalidraw/math";
import { pointOnCurve, pointOnPolyline } from "./collision";
import type { Polyline } from "./geometry/shape";
describe("point and curve", () => {

View file

@ -1,10 +1,3 @@
import type { Polycurve, Polyline } from "./geometry/shape";
import {
pointInEllipse,
pointOnEllipse,
type GeometricShape,
} from "./geometry/shape";
import type { Curve } from "@excalidraw/math";
import {
lineSegment,
pointFrom,
@ -17,6 +10,16 @@ import {
type Polygon,
} from "@excalidraw/math";
import type { Curve } from "@excalidraw/math";
import {
pointInEllipse,
pointOnEllipse,
type GeometricShape,
} from "./geometry/shape";
import type { Polycurve, Polyline } from "./geometry/shape";
// check if the given point is considered on the given shape's border
export const isPointOnShape = <Point extends GlobalPoint | LocalPoint>(
point: Point,

View file

@ -1,9 +1,9 @@
import * as utils from ".";
import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
import * as mockedSceneExportUtils from "@excalidraw/excalidraw/scene/export";
import { diagramFactory } from "@excalidraw/excalidraw/tests/fixtures/diagramFixture";
import { vi } from "vitest";
import * as mockedSceneExportUtils from "@excalidraw/excalidraw/scene/export";
import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
import * as utils from ".";
const exportToSvgSpy = vi.spyOn(mockedSceneExportUtils, "exportToSvg");

View file

@ -1,23 +1,24 @@
import {
exportToCanvas as _exportToCanvas,
exportToSvg as _exportToSvg,
} from "@excalidraw/excalidraw/scene/export";
import { getDefaultAppState } from "@excalidraw/excalidraw/appState";
import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeleted,
} from "@excalidraw/excalidraw/element/types";
import { restore } from "@excalidraw/excalidraw/data/restore";
import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
import { encodePngMetadata } from "@excalidraw/excalidraw/data/image";
import { serializeAsJSON } from "@excalidraw/excalidraw/data/json";
import {
copyBlobToClipboardAsPng,
copyTextToSystemClipboard,
copyToClipboard,
} from "@excalidraw/excalidraw/clipboard";
import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
import { encodePngMetadata } from "@excalidraw/excalidraw/data/image";
import { serializeAsJSON } from "@excalidraw/excalidraw/data/json";
import { restore } from "@excalidraw/excalidraw/data/restore";
import {
exportToCanvas as _exportToCanvas,
exportToSvg as _exportToSvg,
} from "@excalidraw/excalidraw/scene/export";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeleted,
} from "@excalidraw/excalidraw/element/types";
import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
export { MIME_TYPES };

View file

@ -1,9 +1,3 @@
import type {
GlobalPoint,
LineSegment,
Polygon,
Radians,
} from "@excalidraw/math";
import {
pointFrom,
lineSegment,
@ -13,6 +7,14 @@ import {
polygonIncludesPoint,
segmentsIntersectAt,
} from "@excalidraw/math";
import type {
GlobalPoint,
LineSegment,
Polygon,
Radians,
} from "@excalidraw/math";
import { pointInEllipse, pointOnEllipse, type Ellipse } from "./shape";
describe("point and line", () => {

View file

@ -12,7 +12,8 @@
* to pure shapes
*/
import type { Curve, LineSegment, Polygon, Radians } from "@excalidraw/math";
import { getElementAbsoluteCoords } from "@excalidraw/excalidraw/element";
import { invariant } from "@excalidraw/excalidraw/utils";
import {
curve,
lineSegment,
@ -32,7 +33,8 @@ import {
type GlobalPoint,
type LocalPoint,
} from "@excalidraw/math";
import { getElementAbsoluteCoords } from "@excalidraw/excalidraw/element";
import { pointsOnBezierCurves } from "points-on-curve";
import type {
ElementsMap,
ExcalidrawBindableElement,
@ -49,9 +51,9 @@ import type {
ExcalidrawSelectionElement,
ExcalidrawTextElement,
} from "@excalidraw/excalidraw/element/types";
import { pointsOnBezierCurves } from "points-on-curve";
import type { Curve, LineSegment, Polygon, Radians } from "@excalidraw/math";
import type { Drawable, Op } from "roughjs/bin/core";
import { invariant } from "@excalidraw/excalidraw/utils";
// a polyline (made up term here) is a line consisting of other line segments
// this corresponds to a straight line element in the editor but it could also

View file

@ -1,8 +1,10 @@
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
import * as utils from "./index";
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
import { decodeSvgBase64Payload } from "@excalidraw/excalidraw/scene/export";
import { decodePngMetadata } from "@excalidraw/excalidraw/data/image";
import { decodeSvgBase64Payload } from "@excalidraw/excalidraw/scene/export";
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
import * as utils from "./index";
// 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

View file

@ -1,5 +1,7 @@
import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
import {
elementPartiallyOverlapsWithOrContainsBBox,
elementsOverlappingBBox,

View file

@ -1,9 +1,4 @@
import type {
ExcalidrawElement,
ExcalidrawFreeDrawElement,
ExcalidrawLinearElement,
NonDeletedExcalidrawElement,
} from "@excalidraw/excalidraw/element/types";
import { getElementBounds } from "@excalidraw/excalidraw/element/bounds";
import {
isArrowElement,
isExcalidrawElement,
@ -11,10 +6,7 @@ import {
isLinearElement,
isTextElement,
} from "@excalidraw/excalidraw/element/typeChecks";
import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
import { getElementBounds } from "@excalidraw/excalidraw/element/bounds";
import { arrayToMap } from "@excalidraw/excalidraw/utils";
import type { LocalPoint } from "@excalidraw/math";
import {
rangeIncludesValue,
pointFrom,
@ -22,6 +14,15 @@ import {
rangeInclusive,
} from "@excalidraw/math";
import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
import type {
ExcalidrawElement,
ExcalidrawFreeDrawElement,
ExcalidrawLinearElement,
NonDeletedExcalidrawElement,
} from "@excalidraw/excalidraw/element/types";
import type { LocalPoint } from "@excalidraw/math";
type Element = NonDeletedExcalidrawElement;
type Elements = readonly NonDeletedExcalidrawElement[];