Fix all but components & tests

This commit is contained in:
Marcel Mraz 2025-03-17 19:42:10 +01:00
parent e2c2218f62
commit 44837c9bde
No known key found for this signature in database
GPG key ID: 4EBD6E62DC830CD2
103 changed files with 1284 additions and 1003 deletions

View file

@ -1,4 +1,5 @@
import type { EDITOR_LS_KEYS } from "../constants";
import type { EDITOR_LS_KEYS } from "@excalidraw/common";
import type { JSONValue } from "../types";
export class EditorLocalStorage {

View file

@ -1,12 +1,21 @@
import { nanoid } from "nanoid";
import {
IMAGE_MIME_TYPES,
MIME_TYPES,
bytesToHexString,
isPromiseLike,
} from "@excalidraw/common";
import { clearElementsForExport } from "@excalidraw/element";
import type { ExcalidrawElement, FileId } from "@excalidraw/element/types";
import { cleanAppStateForExport } from "../appState";
import { IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
import { clearElementsForExport } from "../element";
import { CanvasError, ImageSceneDataError } from "../errors";
import { calculateScrollCenter } from "../scene";
import { decodeSvgBase64Payload } from "../scene/export";
import { bytesToHexString, isPromiseLike } from "../utils";
import { base64ToString, stringToBase64, toByteString } from "./encode";
import { nativeFileSystemSupported } from "./filesystem";
@ -14,7 +23,7 @@ import { isValidExcalidrawData, isValidLibrary } from "./json";
import { restore, restoreLibraryItems } from "./restore";
import type { FileSystemHandle } from "./filesystem";
import type { ExcalidrawElement, FileId } from "../element/types";
import type { AppState, DataURL, LibraryItem } from "../types";
import type { ValueOf } from "../utility-types";
import type { ImportedLibraryData } from "./types";

View file

@ -1,4 +1,4 @@
import { ENCRYPTION_KEY_BITS } from "../constants";
import { ENCRYPTION_KEY_BITS } from "@excalidraw/common";
import { blobToArrayBuffer } from "./blob";

View file

@ -4,9 +4,9 @@ import {
supported as nativeFileSystemSupported,
} from "browser-fs-access";
import { EVENT, MIME_TYPES } from "../constants";
import { EVENT, MIME_TYPES, debounce } from "@excalidraw/common";
import { AbortError } from "../errors";
import { debounce } from "../utils";
import type { FileSystemHandle } from "browser-fs-access";

View file

@ -2,7 +2,7 @@ import tEXt from "png-chunk-text";
import encodePng from "png-chunks-encode";
import decodePng from "png-chunks-extract";
import { EXPORT_DATA_TYPES, MIME_TYPES } from "../constants";
import { EXPORT_DATA_TYPES, MIME_TYPES } from "@excalidraw/common";
import { blobToArrayBuffer } from "./blob";
import { encode, decode } from "./encode";

View file

@ -1,32 +1,39 @@
import {
copyBlobToClipboardAsPng,
copyTextToSystemClipboard,
} from "../clipboard";
import {
DEFAULT_EXPORT_PADDING,
DEFAULT_FILENAME,
IMAGE_MIME_TYPES,
isFirefox,
MIME_TYPES,
} from "../constants";
import { getNonDeletedElements } from "../element";
import { isFrameLikeElement } from "../element/typeChecks";
import { getElementsOverlappingFrame } from "../frame";
cloneJSON,
} from "@excalidraw/common";
import { getNonDeletedElements } from "@excalidraw/element";
import { isFrameLikeElement } from "@excalidraw/element/typeChecks";
import { getElementsOverlappingFrame } from "@excalidraw/element/frame";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeletedExcalidrawElement,
} from "@excalidraw/element/types";
import {
copyBlobToClipboardAsPng,
copyTextToSystemClipboard,
} from "../clipboard";
import { t } from "../i18n";
import { getSelectedElements, isSomeElementSelected } from "../scene";
import { exportToCanvas, exportToSvg } from "../scene/export";
import { cloneJSON } from "../utils";
import { canvasToBlob } from "./blob";
import { fileSave } from "./filesystem";
import { serializeAsJSON } from "./json";
import type { FileSystemHandle } from "./filesystem";
import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeletedExcalidrawElement,
} from "../element/types";
import type { ExportType } from "../scene/types";
import type { AppState, BinaryFiles } from "../types";

View file

@ -1,17 +1,23 @@
import { cleanAppStateForExport, clearAppStateForDatabase } from "../appState";
import {
DEFAULT_FILENAME,
EXPORT_DATA_TYPES,
EXPORT_SOURCE,
MIME_TYPES,
VERSIONS,
} from "../constants";
import { clearElementsForDatabase, clearElementsForExport } from "../element";
} from "@excalidraw/common";
import {
clearElementsForDatabase,
clearElementsForExport,
} from "@excalidraw/element";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { cleanAppStateForExport, clearAppStateForDatabase } from "../appState";
import { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob";
import { fileOpen, fileSave } from "./filesystem";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, BinaryFiles, LibraryItems } from "../types";
import type {
ExportedDataState,

View file

@ -7,29 +7,33 @@ import {
EVENT,
DEFAULT_SIDEBAR,
LIBRARY_SIDEBAR_TAB,
} from "../constants";
import { atom, editorJotaiStore } from "../editor-jotai";
import { hashElementsVersion, hashString } from "../element";
import { getCommonBoundingBox } from "../element/bounds";
import { Emitter } from "../emitter";
import { AbortError } from "../errors";
import { libraryItemSvgsCache } from "../hooks/useLibraryItemSvg";
import { t } from "../i18n";
import { Queue } from "../queue";
import {
arrayToMap,
cloneJSON,
preventUnload,
promiseTry,
resolvablePromise,
} from "../utils";
toValidURL,
} from "@excalidraw/common";
import { hashElementsVersion, hashString } from "@excalidraw/element";
import { getCommonBoundingBox } from "@excalidraw/element/bounds";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { atom, editorJotaiStore } from "../editor-jotai";
import { Emitter } from "../emitter";
import { AbortError } from "../errors";
import { libraryItemSvgsCache } from "../hooks/useLibraryItemSvg";
import { t } from "../i18n";
import { Queue } from "../queue";
import { loadLibraryFromBlob } from "./blob";
import { restoreLibraryItems } from "./restore";
import { toValidURL } from "./url";
import type App from "../components/App";
import type { ExcalidrawElement } from "../element/types";
import type {
LibraryItems,
LibraryItem,

View file

@ -1,14 +1,15 @@
import throttle from "lodash.throttle";
import { ENV } from "../constants";
import { ENV, arrayToMap } from "@excalidraw/common";
import type { OrderedExcalidrawElement } from "@excalidraw/element/types";
import {
orderByFractionalIndex,
syncInvalidIndices,
validateFractionalIndices,
} from "../fractionalIndex";
import { arrayToMap } from "../utils";
import type { OrderedExcalidrawElement } from "../element/types";
import type { AppState } from "../types";
import type { MakeBrand } from "../utility-types";

View file

@ -1,8 +1,9 @@
import type { ExcalidrawElement } from "@excalidraw/element/types";
import { getFileHandleType, isImageFileHandleType } from "./blob";
import { exportCanvas, prepareElementsForExport } from ".";
import type { ExcalidrawElement } from "../element/types";
import type { AppState, BinaryFiles } from "../types";
export const resaveAsImageWithScene = async (

View file

@ -1,8 +1,5 @@
import { isFiniteNumber, pointFrom } from "@excalidraw/math";
import type { LocalPoint, Radians } from "@excalidraw/math";
import { getDefaultAppState } from "../appState";
import {
DEFAULT_FONT_FAMILY,
DEFAULT_TEXT_ALIGN,
@ -13,22 +10,28 @@ import {
DEFAULT_ELEMENT_PROPS,
DEFAULT_GRID_SIZE,
DEFAULT_GRID_STEP,
} from "../constants";
randomId,
getUpdatedTimestamp,
updateActiveTool,
arrayToMap,
getSizeFromPoints,
normalizeLink,
} from "@excalidraw/common";
import {
getNonDeletedElements,
getNormalizedDimensions,
isInvisiblySmallElement,
refreshTextDimensions,
} from "../element";
import { normalizeFixedPoint } from "../element/binding";
} from "@excalidraw/element";
import { normalizeFixedPoint } from "@excalidraw/element/binding";
import {
updateElbowArrowPoints,
validateElbowPoints,
} from "../element/elbowArrow";
import { LinearElementEditor } from "../element/linearElementEditor";
import { bumpVersion } from "../element/mutateElement";
import { getContainerElement } from "../element/textElement";
import { detectLineHeight } from "../element/textMeasurements";
} from "@excalidraw/element/elbowArrow";
import { LinearElementEditor } from "@excalidraw/element/linearElementEditor";
import { bumpVersion } from "@excalidraw/element/mutateElement";
import { getContainerElement } from "@excalidraw/element/textElement";
import { detectLineHeight } from "@excalidraw/element/textMeasurements";
import {
isArrowElement,
isElbowArrow,
@ -36,20 +39,9 @@ import {
isLinearElement,
isTextElement,
isUsingAdaptiveRadius,
} from "../element/typeChecks";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import { randomId } from "../random";
import {
getNormalizedGridSize,
getNormalizedGridStep,
getNormalizedZoom,
} from "../scene";
import { getUpdatedTimestamp, updateActiveTool } from "../utils";
import { arrayToMap } from "../utils";
import { getSizeFromPoints } from "../points";
} from "@excalidraw/element/typeChecks";
import { normalizeLink } from "./url";
import type { LocalPoint, Radians } from "@excalidraw/math";
import type {
ExcalidrawArrowElement,
@ -65,7 +57,18 @@ import type {
OrderedExcalidrawElement,
PointBinding,
StrokeRoundness,
} from "../element/types";
} from "@excalidraw/element/types";
import { getDefaultAppState } from "../appState";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import {
getNormalizedGridSize,
getNormalizedGridStep,
getNormalizedZoom,
} from "../scene";
import type { AppState, BinaryFiles, LibraryItem } from "../types";
import type { MarkOptional, Mutable } from "../utility-types";
import type { ImportedDataState, LegacyAppState } from "./types";

View file

@ -1,10 +1,11 @@
import { pointFrom } from "@excalidraw/math";
import { vi } from "vitest";
import type { ExcalidrawArrowElement } from "@excalidraw/element/types";
import { convertToExcalidrawElements } from "./transform";
import type { ExcalidrawElementSkeleton } from "./transform";
import type { ExcalidrawArrowElement } from "../element/types";
const opts = { regenerateIds: false };

View file

@ -5,37 +5,37 @@ import {
DEFAULT_FONT_SIZE,
TEXT_ALIGN,
VERTICAL_ALIGN,
} from "../constants";
import {
getCommonBounds,
newElement,
newLinearElement,
redrawTextBoundingBox,
} from "../element";
import { bindLinearElement } from "../element/binding";
import {
newArrowElement,
newFrameElement,
newImageElement,
newMagicFrameElement,
newTextElement,
} from "../element/newElement";
import { measureText, normalizeText } from "../element/textMeasurements";
import { isArrowElement } from "../element/typeChecks";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import { getSizeFromPoints } from "../points";
import { randomId } from "../random";
import {
getSizeFromPoints,
randomId,
arrayToMap,
assertNever,
cloneJSON,
getFontString,
isDevEnv,
toBrandedType,
} from "../utils";
} from "@excalidraw/common";
import {
getCommonBounds,
newElement,
newLinearElement,
redrawTextBoundingBox,
} from "@excalidraw/element";
import { bindLinearElement } from "@excalidraw/element/binding";
import {
newArrowElement,
newFrameElement,
newImageElement,
newMagicFrameElement,
newTextElement,
} from "@excalidraw/element/newElement";
import {
measureText,
normalizeText,
} from "@excalidraw/element/textMeasurements";
import { isArrowElement } from "@excalidraw/element/typeChecks";
import type { ElementConstructorOpts } from "@excalidraw/element/newElement";
import type { ElementConstructorOpts } from "../element/newElement";
import type {
ElementsMap,
ExcalidrawArrowElement,
@ -55,7 +55,11 @@ import type {
NonDeletedSceneElementsMap,
TextAlign,
VerticalAlign,
} from "../element/types";
} from "@excalidraw/element/types";
import { getLineHeight } from "../fonts/FontMetadata";
import { syncInvalidIndices } from "../fractionalIndex";
import type { MarkOptional } from "../utility-types";
export type ValidLinearElement = {

View file

@ -1,6 +1,8 @@
import type { VERSIONS } from "@excalidraw/common";
import type { ExcalidrawElement } from "@excalidraw/element/types";
import type { cleanAppStateForExport } from "../appState";
import type { VERSIONS } from "../constants";
import type { ExcalidrawElement } from "../element/types";
import type {
AppState,
BinaryFiles,