Fix es & ts build

This commit is contained in:
Marcel Mraz 2025-03-18 12:44:13 +01:00
parent 931d03d514
commit fc225c5353
18 changed files with 73 additions and 54 deletions

View file

@ -13,6 +13,8 @@ import {
isLinearElement, isLinearElement,
} from "@excalidraw/element/typeChecks"; } from "@excalidraw/element/typeChecks";
import type { Mutable } from "@excalidraw/excalidraw/utility-types";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
@ -512,7 +514,10 @@ export const _generateElementShape = (
if (isPathALoop(element.points)) { if (isPathALoop(element.points)) {
// generate rough polygon to fill freedraw shape // generate rough polygon to fill freedraw shape
const simplifiedPoints = simplify(element.points, 0.75); const simplifiedPoints = simplify(
element.points as Mutable<LocalPoint[]>,
0.75,
);
shape = generator.curve(simplifiedPoints as [number, number][], { shape = generator.curve(simplifiedPoints as [number, number][], {
...generateRoughOptions(element), ...generateRoughOptions(element),
stroke: "none", stroke: "none",

View file

@ -13,6 +13,7 @@ import {
import { getCurvePathOps } from "@excalidraw/utils/geometry/shape"; import { getCurvePathOps } from "@excalidraw/utils/geometry/shape";
import { generateRoughOptions } from "@excalidraw/element/Shape"; import { generateRoughOptions } from "@excalidraw/element/Shape";
import { ShapeCache } from "@excalidraw/element/ShapeCache";
import type { import type {
Degrees, Degrees,

View file

@ -5,6 +5,8 @@ import {
import { KEYS, invariant, toBrandedType } from "@excalidraw/common"; import { KEYS, invariant, toBrandedType } from "@excalidraw/common";
import { aabbForElement } from "@excalidraw/element"; import { aabbForElement } from "@excalidraw/element";
import { pointFrom, type LocalPoint } from "@excalidraw/math";
import type { import type {
AppState, AppState,
PendingExcalidrawElements, PendingExcalidrawElements,

View file

@ -5,12 +5,13 @@ import {
toBrandedType, toBrandedType,
} from "@excalidraw/common"; } 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 { Radians } from "@excalidraw/math";
import type { Mutable } from "@excalidraw/excalidraw/utility-types"; import type { Mutable } from "@excalidraw/excalidraw/utility-types";
import Scene from "../scene/Scene";
import { ShapeCache } from "./ShapeCache"; import { ShapeCache } from "./ShapeCache";
import { updateElbowArrowPoints } from "./elbowArrow"; import { updateElbowArrowPoints } from "./elbowArrow";

View file

@ -38,7 +38,7 @@ import {
import { getContainingFrame } from "@excalidraw/element/frame"; import { getContainingFrame } from "@excalidraw/element/frame";
import { getCornerRadius } from "@excalidraw/element/shapes"; import { getCornerRadius } from "@excalidraw/element/shapes";
// TODO: consider separating // TODO_SEP: consider separating
import { getVerticalOffset } from "@excalidraw/excalidraw/fonts/FontMetadata"; import { getVerticalOffset } from "@excalidraw/excalidraw/fonts/FontMetadata";
import type { import type {

View file

@ -1,6 +1,8 @@
import clsx from "clsx"; import clsx from "clsx";
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";
import type { ColorPaletteCustom } from "@excalidraw/common";
import { useAtom } from "../../editor-jotai"; import { useAtom } from "../../editor-jotai";
import { t } from "../../i18n"; import { t } from "../../i18n";
@ -11,7 +13,6 @@ import {
getColorNameAndShadeFromColor, getColorNameAndShadeFromColor,
} from "./colorPickerUtils"; } from "./colorPickerUtils";
import type { ColorPaletteCustom } from "../../colors";
import type { TranslationKeys } from "../../i18n"; import type { TranslationKeys } from "../../i18n";
interface PickerColorListProps { interface PickerColorListProps {

View file

@ -1,6 +1,8 @@
import clsx from "clsx"; import clsx from "clsx";
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";
import type { ColorPaletteCustom } from "@excalidraw/common";
import { useAtom } from "../../editor-jotai"; import { useAtom } from "../../editor-jotai";
import { t } from "../../i18n"; import { t } from "../../i18n";
@ -10,8 +12,6 @@ import {
getColorNameAndShadeFromColor, getColorNameAndShadeFromColor,
} from "./colorPickerUtils"; } from "./colorPickerUtils";
import type { ColorPaletteCustom } from "../../colors";
interface ShadeListProps { interface ShadeListProps {
hex: string; hex: string;
onChange: (color: string) => void; onChange: (color: string) => void;

View file

@ -1,3 +1,5 @@
import { isInGroup } from "@excalidraw/common";
import { isTextElement, redrawTextBoundingBox } from "@excalidraw/element"; import { isTextElement, redrawTextBoundingBox } from "@excalidraw/element";
import { mutateElement } from "@excalidraw/element/mutateElement"; import { mutateElement } from "@excalidraw/element/mutateElement";
import { getBoundTextElement } from "@excalidraw/element/textElement"; import { getBoundTextElement } from "@excalidraw/element/textElement";
@ -9,7 +11,6 @@ import type {
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
} from "@excalidraw/element/types"; } from "@excalidraw/element/types";
import { isInGroup } from "../../groups";
import { fontSizeIcon } from "../icons"; import { fontSizeIcon } from "../icons";
import StatsDragInput from "./DragInput"; import StatsDragInput from "./DragInput";

View file

@ -1,3 +1,4 @@
import { isInGroup } from "@excalidraw/common";
import { pointFrom, pointRotateRads } from "@excalidraw/math"; import { pointFrom, pointRotateRads } from "@excalidraw/math";
import { import {
@ -21,11 +22,7 @@ import type {
NonDeletedSceneElementsMap, NonDeletedSceneElementsMap,
} from "@excalidraw/element/types"; } from "@excalidraw/element/types";
import { import { getSelectedGroupIds, getElementsInGroup } from "../../groups";
getSelectedGroupIds,
getElementsInGroup,
isInGroup,
} from "../../groups";
import type Scene from "../../scene/Scene"; import type Scene from "../../scene/Scene";
import type { AppState } from "../../types"; import type { AppState } from "../../types";

View file

@ -8,7 +8,7 @@ import {
useState, useState,
} from "react"; } 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"; import { getElementAbsoluteCoords } from "@excalidraw/element/bounds";

View file

@ -4,6 +4,7 @@ interface Window {
EXCALIDRAW_ASSET_PATH: string | string[] | undefined; EXCALIDRAW_ASSET_PATH: string | string[] | undefined;
EXCALIDRAW_THROTTLE_RENDER: boolean | undefined; EXCALIDRAW_THROTTLE_RENDER: boolean | undefined;
DEBUG_FRACTIONAL_INDICES: boolean | undefined; DEBUG_FRACTIONAL_INDICES: boolean | undefined;
EXCALIDRAW_EXPORT_SOURCE: string;
gtag: Function; gtag: Function;
sa_event: Function; sa_event: Function;
fathom: { trackEvent: Function }; fathom: { trackEvent: Function };

View file

@ -1,4 +1,4 @@
import { VERSIONS } from "../../constants"; import { VERSIONS } from "@excalidraw/common";
import { import {
diamondFixture, diamondFixture,

View file

@ -1,8 +1,8 @@
import { DEFAULT_FONT_FAMILY } from "@excalidraw/common";
import type { Radians } from "@excalidraw/math"; import type { Radians } from "@excalidraw/math";
import { DEFAULT_FONT_FAMILY } from "../../constants"; import type { ExcalidrawElement } from "@excalidraw/element/types";
import type { ExcalidrawElement } from "../../element/types";
const elementBase: Omit<ExcalidrawElement, "type"> = { const elementBase: Omit<ExcalidrawElement, "type"> = {
id: "vWrqOAfkind2qcm7LDAGZ", id: "vWrqOAfkind2qcm7LDAGZ",

View file

@ -4,12 +4,10 @@ import util from "util";
import { pointFrom, type LocalPoint, type Radians } from "@excalidraw/math"; import { pointFrom, type LocalPoint, type Radians } from "@excalidraw/math";
import { getDefaultAppState } from "../../appState"; import { DEFAULT_VERTICAL_ALIGN, ROUNDNESS } from "@excalidraw/common";
import { createTestHook } from "../../components/App";
import { DEFAULT_VERTICAL_ALIGN, ROUNDNESS } from "../../constants"; import { newElement, newTextElement, newLinearElement } from "@excalidraw/element";
import { getMimeType } from "../../data/blob"; import { mutateElement } from "@excalidraw/element/mutateElement";
import { newElement, newTextElement, newLinearElement } from "../../element";
import { mutateElement } from "../../element/mutateElement";
import { import {
newArrowElement, newArrowElement,
newEmbeddableElement, newEmbeddableElement,
@ -18,15 +16,12 @@ import {
newIframeElement, newIframeElement,
newImageElement, newImageElement,
newMagicFrameElement, newMagicFrameElement,
} from "../../element/newElement"; } from "@excalidraw/element/newElement";
import { isLinearElementType } from "../../element/typeChecks"; import { isLinearElementType } from "@excalidraw/element/typeChecks";
import { selectGroupsForSelectedElements } from "../../groups";
import { getSelectedElements } from "../../scene/selection"; import { getSelectedElements } from "@excalidraw/excalidraw/scene/selection";
import { assertNever } from "../../utils"; import { assertNever } from "@excalidraw/common";
import { GlobalTestState, createEvent, fireEvent, act } from "../test-utils";
import type { Action } from "../../actions/types";
import type App from "../../components/App";
import type { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawGenericElement, ExcalidrawGenericElement,
@ -41,7 +36,16 @@ import type {
ExcalidrawElbowArrowElement, ExcalidrawElbowArrowElement,
ExcalidrawArrowElement, ExcalidrawArrowElement,
FixedSegment, 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 { AppState } from "../../types";
import type { Mutable } from "../../utility-types"; import type { Mutable } from "../../utility-types";

View file

@ -1,11 +1,11 @@
import { pointFrom, pointRotateRads } from "@excalidraw/math"; import { pointFrom, pointRotateRads } from "@excalidraw/math";
import type { GlobalPoint, LocalPoint, Radians } from "@excalidraw/math"; import {
getCommonBounds,
import { createTestHook } from "../../components/App"; getElementPointsCoords,
import { getCommonBounds, getElementPointsCoords } from "../../element/bounds"; } from "@excalidraw/element/bounds";
import { cropElement } from "../../element/cropElement"; import { cropElement } from "@excalidraw/element/cropElement";
import { mutateElement } from "../../element/mutateElement"; import { mutateElement } from "@excalidraw/element/mutateElement";
import { import {
getTransformHandles, getTransformHandles,
getTransformHandlesFromCoords, getTransformHandlesFromCoords,
@ -13,21 +13,18 @@ import {
OMIT_SIDES_FOR_MULTIPLE_ELEMENTS, OMIT_SIDES_FOR_MULTIPLE_ELEMENTS,
type TransformHandle, type TransformHandle,
type TransformHandleDirection, type TransformHandleDirection,
} from "../../element/transformHandles"; } from "@excalidraw/element/transformHandles";
import { import {
isLinearElement, isLinearElement,
isFreeDrawElement, isFreeDrawElement,
isTextElement, isTextElement,
isFrameLikeElement, isFrameLikeElement,
} from "../../element/typeChecks"; } from "@excalidraw/element/typeChecks";
import { KEYS } from "../../keys"; import { KEYS, arrayToMap } from "@excalidraw/common";
import { arrayToMap } from "../../utils";
import { getTextEditor } from "../queries/dom";
import { act, fireEvent, GlobalTestState, screen } from "../test-utils";
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 { import type {
ExcalidrawElement, ExcalidrawElement,
ExcalidrawLinearElement, ExcalidrawLinearElement,
@ -39,7 +36,14 @@ import type {
ExcalidrawTextContainer, ExcalidrawTextContainer,
ExcalidrawTextElementWithContainer, ExcalidrawTextElementWithContainer,
ExcalidrawImageElement, 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"; import type { ToolType } from "../../types";
// so that window.h is available when App.tsx is not imported as well. // so that window.h is available when App.tsx is not imported as well.

View file

@ -1,8 +1,8 @@
import { queries, buildQueries } from "@testing-library/react"; 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 _getAllByToolName = (container: HTMLElement, tool: ToolType | "lock") => {
const toolTitle = tool === "lock" ? "lock" : TOOL_TYPE[tool]; const toolTitle = tool === "lock" ? "lock" : TOOL_TYPE[tool];

View file

@ -9,10 +9,12 @@ import {
} from "@testing-library/react"; } from "@testing-library/react";
import ansi from "ansicolor"; 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 { STORAGE_KEYS } from "../../../excalidraw-app/app_constants";
import { ORIG_ID } from "../constants";
import { getSelectedElements } from "../scene/selection"; import { getSelectedElements } from "../scene/selection";
import { arrayToMap } from "../utils";
import { UI } from "./helpers/ui"; import { UI } from "./helpers/ui";
import * as toolQueries from "./queries/toolQueries"; 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 { RenderResult, RenderOptions } from "@testing-library/react";
import type { ImportedDataState } from "../data/types"; import type { ImportedDataState } from "../data/types";
import type { ExcalidrawElement } from "../element/types";
import type { AllPossibleKeys } from "../utility-types"; import type { AllPossibleKeys } from "../utility-types";
export { cleanup as unmountComponent }; export { cleanup as unmountComponent };

View file

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