diff --git a/packages/element/src/Shape.ts b/packages/element/src/Shape.ts index 33ee4c545..dc82d6586 100644 --- a/packages/element/src/Shape.ts +++ b/packages/element/src/Shape.ts @@ -13,6 +13,8 @@ import { isLinearElement, } from "@excalidraw/element/typeChecks"; +import type { Mutable } from "@excalidraw/excalidraw/utility-types"; + import type { ExcalidrawElement, NonDeletedExcalidrawElement, @@ -512,7 +514,10 @@ export const _generateElementShape = ( if (isPathALoop(element.points)) { // generate rough polygon to fill freedraw shape - const simplifiedPoints = simplify(element.points, 0.75); + const simplifiedPoints = simplify( + element.points as Mutable, + 0.75, + ); shape = generator.curve(simplifiedPoints as [number, number][], { ...generateRoughOptions(element), stroke: "none", diff --git a/packages/element/src/bounds.ts b/packages/element/src/bounds.ts index 225a78ba6..ff967ddbe 100644 --- a/packages/element/src/bounds.ts +++ b/packages/element/src/bounds.ts @@ -13,6 +13,7 @@ import { import { getCurvePathOps } from "@excalidraw/utils/geometry/shape"; import { generateRoughOptions } from "@excalidraw/element/Shape"; +import { ShapeCache } from "@excalidraw/element/ShapeCache"; import type { Degrees, diff --git a/packages/element/src/flowchart.ts b/packages/element/src/flowchart.ts index 664b25a1c..cc642d383 100644 --- a/packages/element/src/flowchart.ts +++ b/packages/element/src/flowchart.ts @@ -5,6 +5,8 @@ import { import { KEYS, invariant, toBrandedType } from "@excalidraw/common"; import { aabbForElement } from "@excalidraw/element"; +import { pointFrom, type LocalPoint } from "@excalidraw/math"; + import type { AppState, PendingExcalidrawElements, diff --git a/packages/element/src/mutateElement.ts b/packages/element/src/mutateElement.ts index 236eb62ce..35fda4fbc 100644 --- a/packages/element/src/mutateElement.ts +++ b/packages/element/src/mutateElement.ts @@ -5,12 +5,13 @@ import { toBrandedType, } from "@excalidraw/common"; +// TODO_SEP: should be passed in or injected instead +import Scene from "@excalidraw/excalidraw/scene/Scene"; + import type { Radians } from "@excalidraw/math"; import type { Mutable } from "@excalidraw/excalidraw/utility-types"; -import Scene from "../scene/Scene"; - import { ShapeCache } from "./ShapeCache"; import { updateElbowArrowPoints } from "./elbowArrow"; diff --git a/packages/element/src/renderElement.ts b/packages/element/src/renderElement.ts index fbe3c0d52..53f9be5bf 100644 --- a/packages/element/src/renderElement.ts +++ b/packages/element/src/renderElement.ts @@ -38,7 +38,7 @@ import { import { getContainingFrame } from "@excalidraw/element/frame"; import { getCornerRadius } from "@excalidraw/element/shapes"; -// TODO: consider separating +// TODO_SEP: consider separating import { getVerticalOffset } from "@excalidraw/excalidraw/fonts/FontMetadata"; import type { diff --git a/packages/excalidraw/components/ColorPicker/PickerColorList.tsx b/packages/excalidraw/components/ColorPicker/PickerColorList.tsx index b355228f1..50594a59e 100644 --- a/packages/excalidraw/components/ColorPicker/PickerColorList.tsx +++ b/packages/excalidraw/components/ColorPicker/PickerColorList.tsx @@ -1,6 +1,8 @@ import clsx from "clsx"; import { useEffect, useRef } from "react"; +import type { ColorPaletteCustom } from "@excalidraw/common"; + import { useAtom } from "../../editor-jotai"; import { t } from "../../i18n"; @@ -11,7 +13,6 @@ import { getColorNameAndShadeFromColor, } from "./colorPickerUtils"; -import type { ColorPaletteCustom } from "../../colors"; import type { TranslationKeys } from "../../i18n"; interface PickerColorListProps { diff --git a/packages/excalidraw/components/ColorPicker/ShadeList.tsx b/packages/excalidraw/components/ColorPicker/ShadeList.tsx index 35d89ea80..aa2c25ea0 100644 --- a/packages/excalidraw/components/ColorPicker/ShadeList.tsx +++ b/packages/excalidraw/components/ColorPicker/ShadeList.tsx @@ -1,6 +1,8 @@ import clsx from "clsx"; import { useEffect, useRef } from "react"; +import type { ColorPaletteCustom } from "@excalidraw/common"; + import { useAtom } from "../../editor-jotai"; import { t } from "../../i18n"; @@ -10,8 +12,6 @@ import { getColorNameAndShadeFromColor, } from "./colorPickerUtils"; -import type { ColorPaletteCustom } from "../../colors"; - interface ShadeListProps { hex: string; onChange: (color: string) => void; diff --git a/packages/excalidraw/components/Stats/MultiFontSize.tsx b/packages/excalidraw/components/Stats/MultiFontSize.tsx index 5391aadfd..e5a541fb7 100644 --- a/packages/excalidraw/components/Stats/MultiFontSize.tsx +++ b/packages/excalidraw/components/Stats/MultiFontSize.tsx @@ -1,3 +1,5 @@ +import { isInGroup } from "@excalidraw/common"; + import { isTextElement, redrawTextBoundingBox } from "@excalidraw/element"; import { mutateElement } from "@excalidraw/element/mutateElement"; import { getBoundTextElement } from "@excalidraw/element/textElement"; @@ -9,7 +11,6 @@ import type { NonDeletedSceneElementsMap, } from "@excalidraw/element/types"; -import { isInGroup } from "../../groups"; import { fontSizeIcon } from "../icons"; import StatsDragInput from "./DragInput"; diff --git a/packages/excalidraw/components/Stats/utils.ts b/packages/excalidraw/components/Stats/utils.ts index 6c5ecd097..fd6d4e532 100644 --- a/packages/excalidraw/components/Stats/utils.ts +++ b/packages/excalidraw/components/Stats/utils.ts @@ -1,3 +1,4 @@ +import { isInGroup } from "@excalidraw/common"; import { pointFrom, pointRotateRads } from "@excalidraw/math"; import { @@ -21,11 +22,7 @@ import type { NonDeletedSceneElementsMap, } from "@excalidraw/element/types"; -import { - getSelectedGroupIds, - getElementsInGroup, - isInGroup, -} from "../../groups"; +import { getSelectedGroupIds, getElementsInGroup } from "../../groups"; import type Scene from "../../scene/Scene"; import type { AppState } from "../../types"; diff --git a/packages/excalidraw/components/hyperlink/Hyperlink.tsx b/packages/excalidraw/components/hyperlink/Hyperlink.tsx index 6200a039c..9a386a163 100644 --- a/packages/excalidraw/components/hyperlink/Hyperlink.tsx +++ b/packages/excalidraw/components/hyperlink/Hyperlink.tsx @@ -8,7 +8,7 @@ import { useState, } from "react"; -import { EVENT, HYPERLINK_TOOLTIP_DELAY } from "@excalidraw/common"; +import { EVENT, HYPERLINK_TOOLTIP_DELAY, KEYS } from "@excalidraw/common"; import { getElementAbsoluteCoords } from "@excalidraw/element/bounds"; diff --git a/packages/excalidraw/global.d.ts b/packages/excalidraw/global.d.ts index 23626bd52..e9b6c3f96 100644 --- a/packages/excalidraw/global.d.ts +++ b/packages/excalidraw/global.d.ts @@ -4,6 +4,7 @@ interface Window { EXCALIDRAW_ASSET_PATH: string | string[] | undefined; EXCALIDRAW_THROTTLE_RENDER: boolean | undefined; DEBUG_FRACTIONAL_INDICES: boolean | undefined; + EXCALIDRAW_EXPORT_SOURCE: string; gtag: Function; sa_event: Function; fathom: { trackEvent: Function }; diff --git a/packages/excalidraw/tests/fixtures/diagramFixture.ts b/packages/excalidraw/tests/fixtures/diagramFixture.ts index a4fdc1560..8512fed36 100644 --- a/packages/excalidraw/tests/fixtures/diagramFixture.ts +++ b/packages/excalidraw/tests/fixtures/diagramFixture.ts @@ -1,4 +1,4 @@ -import { VERSIONS } from "../../constants"; +import { VERSIONS } from "@excalidraw/common"; import { diamondFixture, diff --git a/packages/excalidraw/tests/fixtures/elementFixture.ts b/packages/excalidraw/tests/fixtures/elementFixture.ts index a7d8c5080..35aabd55f 100644 --- a/packages/excalidraw/tests/fixtures/elementFixture.ts +++ b/packages/excalidraw/tests/fixtures/elementFixture.ts @@ -1,8 +1,8 @@ +import { DEFAULT_FONT_FAMILY } from "@excalidraw/common"; + import type { Radians } from "@excalidraw/math"; -import { DEFAULT_FONT_FAMILY } from "../../constants"; - -import type { ExcalidrawElement } from "../../element/types"; +import type { ExcalidrawElement } from "@excalidraw/element/types"; const elementBase: Omit = { id: "vWrqOAfkind2qcm7LDAGZ", diff --git a/packages/excalidraw/tests/helpers/api.ts b/packages/excalidraw/tests/helpers/api.ts index 2aa9ee999..fc2c581ba 100644 --- a/packages/excalidraw/tests/helpers/api.ts +++ b/packages/excalidraw/tests/helpers/api.ts @@ -4,12 +4,10 @@ import util from "util"; import { pointFrom, type LocalPoint, type Radians } from "@excalidraw/math"; -import { getDefaultAppState } from "../../appState"; -import { createTestHook } from "../../components/App"; -import { DEFAULT_VERTICAL_ALIGN, ROUNDNESS } from "../../constants"; -import { getMimeType } from "../../data/blob"; -import { newElement, newTextElement, newLinearElement } from "../../element"; -import { mutateElement } from "../../element/mutateElement"; +import { DEFAULT_VERTICAL_ALIGN, ROUNDNESS } from "@excalidraw/common"; + +import { newElement, newTextElement, newLinearElement } from "@excalidraw/element"; +import { mutateElement } from "@excalidraw/element/mutateElement"; import { newArrowElement, newEmbeddableElement, @@ -18,15 +16,12 @@ import { newIframeElement, newImageElement, newMagicFrameElement, -} from "../../element/newElement"; -import { isLinearElementType } from "../../element/typeChecks"; -import { selectGroupsForSelectedElements } from "../../groups"; -import { getSelectedElements } from "../../scene/selection"; -import { assertNever } from "../../utils"; -import { GlobalTestState, createEvent, fireEvent, act } from "../test-utils"; +} from "@excalidraw/element/newElement"; +import { isLinearElementType } from "@excalidraw/element/typeChecks"; + +import { getSelectedElements } from "@excalidraw/excalidraw/scene/selection"; +import { assertNever } from "@excalidraw/common"; -import type { Action } from "../../actions/types"; -import type App from "../../components/App"; import type { ExcalidrawElement, ExcalidrawGenericElement, @@ -41,7 +36,16 @@ import type { ExcalidrawElbowArrowElement, ExcalidrawArrowElement, FixedSegment, -} from "../../element/types"; +} from "@excalidraw/element/types"; + +import { selectGroupsForSelectedElements } from "../../groups"; +import { getMimeType } from "../../data/blob"; +import { createTestHook } from "../../components/App"; +import { getDefaultAppState } from "../../appState"; +import { GlobalTestState, createEvent, fireEvent, act } from "../test-utils"; + +import type { Action } from "../../actions/types"; +import type App from "../../components/App"; import type { AppState } from "../../types"; import type { Mutable } from "../../utility-types"; diff --git a/packages/excalidraw/tests/helpers/ui.ts b/packages/excalidraw/tests/helpers/ui.ts index a72e3fa74..c328ae105 100644 --- a/packages/excalidraw/tests/helpers/ui.ts +++ b/packages/excalidraw/tests/helpers/ui.ts @@ -1,11 +1,11 @@ import { pointFrom, pointRotateRads } from "@excalidraw/math"; -import type { GlobalPoint, LocalPoint, Radians } from "@excalidraw/math"; - -import { createTestHook } from "../../components/App"; -import { getCommonBounds, getElementPointsCoords } from "../../element/bounds"; -import { cropElement } from "../../element/cropElement"; -import { mutateElement } from "../../element/mutateElement"; +import { + getCommonBounds, + getElementPointsCoords, +} from "@excalidraw/element/bounds"; +import { cropElement } from "@excalidraw/element/cropElement"; +import { mutateElement } from "@excalidraw/element/mutateElement"; import { getTransformHandles, getTransformHandlesFromCoords, @@ -13,21 +13,18 @@ import { OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, type TransformHandle, type TransformHandleDirection, -} from "../../element/transformHandles"; +} from "@excalidraw/element/transformHandles"; import { isLinearElement, isFreeDrawElement, isTextElement, isFrameLikeElement, -} from "../../element/typeChecks"; -import { KEYS } from "../../keys"; -import { arrayToMap } from "../../utils"; -import { getTextEditor } from "../queries/dom"; -import { act, fireEvent, GlobalTestState, screen } from "../test-utils"; +} from "@excalidraw/element/typeChecks"; +import { KEYS, arrayToMap } from "@excalidraw/common"; -import { API } from "./api"; +import type { GlobalPoint, LocalPoint, Radians } from "@excalidraw/math"; -import type { TransformHandleType } from "../../element/transformHandles"; +import type { TransformHandleType } from "@excalidraw/element/transformHandles"; import type { ExcalidrawElement, ExcalidrawLinearElement, @@ -39,7 +36,14 @@ import type { ExcalidrawTextContainer, ExcalidrawTextElementWithContainer, ExcalidrawImageElement, -} from "../../element/types"; +} from "@excalidraw/element/types"; + +import { createTestHook } from "../../components/App"; +import { getTextEditor } from "../queries/dom"; +import { act, fireEvent, GlobalTestState, screen } from "../test-utils"; + +import { API } from "./api"; + import type { ToolType } from "../../types"; // so that window.h is available when App.tsx is not imported as well. diff --git a/packages/excalidraw/tests/queries/toolQueries.ts b/packages/excalidraw/tests/queries/toolQueries.ts index ed168735d..8413bf5fb 100644 --- a/packages/excalidraw/tests/queries/toolQueries.ts +++ b/packages/excalidraw/tests/queries/toolQueries.ts @@ -1,8 +1,8 @@ import { queries, buildQueries } from "@testing-library/react"; -import { TOOL_TYPE } from "../../constants"; +import { TOOL_TYPE } from "@excalidraw/common"; -import type { ToolType } from "../../types"; +import type { ToolType } from "@excalidraw/excalidraw/types"; const _getAllByToolName = (container: HTMLElement, tool: ToolType | "lock") => { const toolTitle = tool === "lock" ? "lock" : TOOL_TYPE[tool]; diff --git a/packages/excalidraw/tests/test-utils.ts b/packages/excalidraw/tests/test-utils.ts index 73b340982..40d03ff67 100644 --- a/packages/excalidraw/tests/test-utils.ts +++ b/packages/excalidraw/tests/test-utils.ts @@ -9,10 +9,12 @@ import { } from "@testing-library/react"; import ansi from "ansicolor"; +import { ORIG_ID, arrayToMap } from "@excalidraw/common"; + +import type { ExcalidrawElement } from "@excalidraw/element/types"; + import { STORAGE_KEYS } from "../../../excalidraw-app/app_constants"; -import { ORIG_ID } from "../constants"; import { getSelectedElements } from "../scene/selection"; -import { arrayToMap } from "../utils"; import { UI } from "./helpers/ui"; import * as toolQueries from "./queries/toolQueries"; @@ -20,7 +22,7 @@ import * as toolQueries from "./queries/toolQueries"; import type { RenderResult, RenderOptions } from "@testing-library/react"; import type { ImportedDataState } from "../data/types"; -import type { ExcalidrawElement } from "../element/types"; + import type { AllPossibleKeys } from "../utility-types"; export { cleanup as unmountComponent }; diff --git a/packages/utils/bbox.ts b/packages/utils/bbox.ts index 61c75a668..a56128156 100644 --- a/packages/utils/bbox.ts +++ b/packages/utils/bbox.ts @@ -5,7 +5,7 @@ import { type LocalPoint, } from "@excalidraw/math"; -import type { Bounds } from "@excalidraw/excalidraw/element/bounds"; +import type { Bounds } from "@excalidraw/element/bounds"; export type LineSegment

= [P, P];