mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
refactor: auto ordered imports (#9163)
All checks were successful
Tests / test (push) Successful in 4m38s
All checks were successful
Tests / test (push) Successful in 4m38s
This commit is contained in:
parent
82b9a6b464
commit
21ffaf4d76
421 changed files with 3532 additions and 2763 deletions
|
@ -1,19 +1,22 @@
|
|||
import { nanoid } from "nanoid";
|
||||
|
||||
import { cleanAppStateForExport } from "../appState";
|
||||
import { IMAGE_MIME_TYPES, MIME_TYPES } from "../constants";
|
||||
import { clearElementsForExport } from "../element";
|
||||
import type { ExcalidrawElement, FileId } from "../element/types";
|
||||
import { CanvasError, ImageSceneDataError } from "../errors";
|
||||
import { calculateScrollCenter } from "../scene";
|
||||
import { decodeSvgBase64Payload } from "../scene/export";
|
||||
import type { AppState, DataURL, LibraryItem } from "../types";
|
||||
import type { ValueOf } from "../utility-types";
|
||||
import { bytesToHexString, isPromiseLike } from "../utils";
|
||||
|
||||
import { base64ToString, stringToBase64, toByteString } from "./encode";
|
||||
import type { FileSystemHandle } from "./filesystem";
|
||||
import { nativeFileSystemSupported } from "./filesystem";
|
||||
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";
|
||||
|
||||
const parseFileContents = async (blob: Blob | File): Promise<string> => {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { deflate, inflate } from "pako";
|
||||
|
||||
import { encryptData, decryptData } from "./encryption";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ENCRYPTION_KEY_BITS } from "../constants";
|
||||
|
||||
import { blobToArrayBuffer } from "./blob";
|
||||
|
||||
export const IV_LENGTH_BYTES = 12;
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import type { FileSystemHandle } from "browser-fs-access";
|
||||
import {
|
||||
fileOpen as _fileOpen,
|
||||
fileSave as _fileSave,
|
||||
supported as nativeFileSystemSupported,
|
||||
} from "browser-fs-access";
|
||||
|
||||
import { EVENT, MIME_TYPES } from "../constants";
|
||||
import { AbortError } from "../errors";
|
||||
import { debounce } from "../utils";
|
||||
|
||||
import type { FileSystemHandle } from "browser-fs-access";
|
||||
|
||||
type FILE_EXTENSION = Exclude<keyof typeof MIME_TYPES, "binary">;
|
||||
|
||||
const INPUT_CHANGE_INTERVAL_MS = 500;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import decodePng from "png-chunks-extract";
|
||||
import tEXt from "png-chunk-text";
|
||||
import encodePng from "png-chunks-encode";
|
||||
import { encode, decode } from "./encode";
|
||||
import decodePng from "png-chunks-extract";
|
||||
|
||||
import { EXPORT_DATA_TYPES, MIME_TYPES } from "../constants";
|
||||
|
||||
import { blobToArrayBuffer } from "./blob";
|
||||
import { encode, decode } from "./encode";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// PNG
|
||||
|
|
|
@ -11,22 +11,24 @@ import {
|
|||
} from "../constants";
|
||||
import { getNonDeletedElements } from "../element";
|
||||
import { isFrameLikeElement } from "../element/typeChecks";
|
||||
import { getElementsOverlappingFrame } from "../frame";
|
||||
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 { getElementsOverlappingFrame } from "../frame";
|
||||
import { t } from "../i18n";
|
||||
import { getSelectedElements, isSomeElementSelected } from "../scene";
|
||||
import { exportToCanvas, exportToSvg } from "../scene/export";
|
||||
import type { ExportType } from "../scene/types";
|
||||
import type { AppState, BinaryFiles } from "../types";
|
||||
import { cloneJSON } from "../utils";
|
||||
import { canvasToBlob } from "./blob";
|
||||
import type { FileSystemHandle } from "./filesystem";
|
||||
import { fileSave } from "./filesystem";
|
||||
import { serializeAsJSON } from "./json";
|
||||
|
||||
export { loadFromBlob } from "./blob";
|
||||
export { loadFromJSON, saveAsJSON } from "./json";
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { fileOpen, fileSave } from "./filesystem";
|
||||
import { cleanAppStateForExport, clearAppStateForDatabase } from "../appState";
|
||||
import {
|
||||
DEFAULT_FILENAME,
|
||||
|
@ -8,10 +7,12 @@ import {
|
|||
VERSIONS,
|
||||
} from "../constants";
|
||||
import { clearElementsForDatabase, clearElementsForExport } from "../element";
|
||||
|
||||
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 { isImageFileHandle, loadFromBlob, normalizeFile } from "./blob";
|
||||
|
||||
import type {
|
||||
ExportedDataState,
|
||||
ImportedDataState,
|
||||
|
|
|
@ -1,19 +1,5 @@
|
|||
import { loadLibraryFromBlob } from "./blob";
|
||||
import type {
|
||||
LibraryItems,
|
||||
LibraryItem,
|
||||
ExcalidrawImperativeAPI,
|
||||
LibraryItemsSource,
|
||||
LibraryItems_anyVersion,
|
||||
} from "../types";
|
||||
import { restoreLibraryItems } from "./restore";
|
||||
import type App from "../components/App";
|
||||
import { atom, editorJotaiStore } from "../editor-jotai";
|
||||
import type { ExcalidrawElement } from "../element/types";
|
||||
import { getCommonBoundingBox } from "../element/bounds";
|
||||
import { AbortError } from "../errors";
|
||||
import { t } from "../i18n";
|
||||
import { useEffect, useRef } from "react";
|
||||
|
||||
import {
|
||||
URL_HASH_KEYS,
|
||||
URL_QUERY_KEYS,
|
||||
|
@ -22,7 +8,14 @@ import {
|
|||
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,
|
||||
|
@ -30,12 +23,22 @@ import {
|
|||
promiseTry,
|
||||
resolvablePromise,
|
||||
} from "../utils";
|
||||
import type { MaybePromise } from "../utility-types";
|
||||
import { Emitter } from "../emitter";
|
||||
import { Queue } from "../queue";
|
||||
import { hashElementsVersion, hashString } from "../element";
|
||||
|
||||
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,
|
||||
ExcalidrawImperativeAPI,
|
||||
LibraryItemsSource,
|
||||
LibraryItems_anyVersion,
|
||||
} from "../types";
|
||||
import type { MaybePromise } from "../utility-types";
|
||||
|
||||
/**
|
||||
* format: hostname or hostname/pathname
|
||||
*
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
import throttle from "lodash.throttle";
|
||||
|
||||
import { ENV } from "../constants";
|
||||
import type { OrderedExcalidrawElement } from "../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";
|
||||
import { arrayToMap } from "../utils";
|
||||
|
||||
export type ReconciledExcalidrawElement = OrderedExcalidrawElement &
|
||||
MakeBrand<"ReconciledElement">;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import { getFileHandleType, isImageFileHandleType } from "./blob";
|
||||
|
||||
import { exportCanvas, prepareElementsForExport } from ".";
|
||||
|
||||
import type { ExcalidrawElement } from "../element/types";
|
||||
import type { AppState, BinaryFiles } from "../types";
|
||||
import { exportCanvas, prepareElementsForExport } from ".";
|
||||
import { getFileHandleType, isImageFileHandleType } from "./blob";
|
||||
|
||||
export const resaveAsImageWithScene = async (
|
||||
elements: readonly ExcalidrawElement[],
|
||||
|
|
|
@ -1,3 +1,56 @@
|
|||
import { isFiniteNumber, pointFrom } from "@excalidraw/math";
|
||||
|
||||
import type { LocalPoint, Radians } from "@excalidraw/math";
|
||||
|
||||
import { getDefaultAppState } from "../appState";
|
||||
import {
|
||||
DEFAULT_FONT_FAMILY,
|
||||
DEFAULT_TEXT_ALIGN,
|
||||
DEFAULT_VERTICAL_ALIGN,
|
||||
FONT_FAMILY,
|
||||
ROUNDNESS,
|
||||
DEFAULT_SIDEBAR,
|
||||
DEFAULT_ELEMENT_PROPS,
|
||||
DEFAULT_GRID_SIZE,
|
||||
DEFAULT_GRID_STEP,
|
||||
} from "../constants";
|
||||
import {
|
||||
getNonDeletedElements,
|
||||
getNormalizedDimensions,
|
||||
isInvisiblySmallElement,
|
||||
refreshTextDimensions,
|
||||
} from "../element";
|
||||
import { normalizeFixedPoint } from "../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";
|
||||
import {
|
||||
isArrowElement,
|
||||
isElbowArrow,
|
||||
isFixedPointBinding,
|
||||
isLinearElement,
|
||||
isTextElement,
|
||||
isUsingAdaptiveRadius,
|
||||
} from "../element/typeChecks";
|
||||
import { getLineHeight } from "../fonts";
|
||||
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";
|
||||
|
||||
import { normalizeLink } from "./url";
|
||||
|
||||
import type {
|
||||
ExcalidrawArrowElement,
|
||||
ExcalidrawElbowArrowElement,
|
||||
|
@ -14,57 +67,8 @@ import type {
|
|||
StrokeRoundness,
|
||||
} from "../element/types";
|
||||
import type { AppState, BinaryFiles, LibraryItem } from "../types";
|
||||
import type { ImportedDataState, LegacyAppState } from "./types";
|
||||
import {
|
||||
getNonDeletedElements,
|
||||
getNormalizedDimensions,
|
||||
isInvisiblySmallElement,
|
||||
refreshTextDimensions,
|
||||
} from "../element";
|
||||
import {
|
||||
isArrowElement,
|
||||
isElbowArrow,
|
||||
isFixedPointBinding,
|
||||
isLinearElement,
|
||||
isTextElement,
|
||||
isUsingAdaptiveRadius,
|
||||
} from "../element/typeChecks";
|
||||
import { randomId } from "../random";
|
||||
import {
|
||||
DEFAULT_FONT_FAMILY,
|
||||
DEFAULT_TEXT_ALIGN,
|
||||
DEFAULT_VERTICAL_ALIGN,
|
||||
FONT_FAMILY,
|
||||
ROUNDNESS,
|
||||
DEFAULT_SIDEBAR,
|
||||
DEFAULT_ELEMENT_PROPS,
|
||||
DEFAULT_GRID_SIZE,
|
||||
DEFAULT_GRID_STEP,
|
||||
} from "../constants";
|
||||
import { getDefaultAppState } from "../appState";
|
||||
import { LinearElementEditor } from "../element/linearElementEditor";
|
||||
import { bumpVersion } from "../element/mutateElement";
|
||||
import { getUpdatedTimestamp, updateActiveTool } from "../utils";
|
||||
import { arrayToMap } from "../utils";
|
||||
import type { MarkOptional, Mutable } from "../utility-types";
|
||||
import { getContainerElement } from "../element/textElement";
|
||||
import { normalizeLink } from "./url";
|
||||
import { syncInvalidIndices } from "../fractionalIndex";
|
||||
import { getSizeFromPoints } from "../points";
|
||||
import { getLineHeight } from "../fonts";
|
||||
import { normalizeFixedPoint } from "../element/binding";
|
||||
import {
|
||||
getNormalizedGridSize,
|
||||
getNormalizedGridStep,
|
||||
getNormalizedZoom,
|
||||
} from "../scene";
|
||||
import type { LocalPoint, Radians } from "@excalidraw/math";
|
||||
import { isFiniteNumber, pointFrom } from "@excalidraw/math";
|
||||
import { detectLineHeight } from "../element/textMeasurements";
|
||||
import {
|
||||
updateElbowArrowPoints,
|
||||
validateElbowPoints,
|
||||
} from "../element/elbowArrow";
|
||||
import type { ImportedDataState, LegacyAppState } from "./types";
|
||||
|
||||
type RestoredAppState = Omit<
|
||||
AppState,
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { vi } from "vitest";
|
||||
import type { ExcalidrawElementSkeleton } from "./transform";
|
||||
import { convertToExcalidrawElements } from "./transform";
|
||||
import type { ExcalidrawArrowElement } from "../element/types";
|
||||
import { pointFrom } from "@excalidraw/math";
|
||||
import { vi } from "vitest";
|
||||
|
||||
import { convertToExcalidrawElements } from "./transform";
|
||||
|
||||
import type { ExcalidrawElementSkeleton } from "./transform";
|
||||
import type { ExcalidrawArrowElement } from "../element/types";
|
||||
|
||||
const opts = { regenerateIds: false };
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { pointFrom, type LocalPoint } from "@excalidraw/math";
|
||||
|
||||
import {
|
||||
DEFAULT_FONT_FAMILY,
|
||||
DEFAULT_FONT_SIZE,
|
||||
|
@ -11,7 +13,6 @@ import {
|
|||
redrawTextBoundingBox,
|
||||
} from "../element";
|
||||
import { bindLinearElement } from "../element/binding";
|
||||
import type { ElementConstructorOpts } from "../element/newElement";
|
||||
import {
|
||||
newArrowElement,
|
||||
newFrameElement,
|
||||
|
@ -19,6 +20,22 @@ import {
|
|||
newMagicFrameElement,
|
||||
newTextElement,
|
||||
} from "../element/newElement";
|
||||
import { measureText, normalizeText } from "../element/textMeasurements";
|
||||
import { isArrowElement } from "../element/typeChecks";
|
||||
import { getLineHeight } from "../fonts";
|
||||
import { syncInvalidIndices } from "../fractionalIndex";
|
||||
import { getSizeFromPoints } from "../points";
|
||||
import { randomId } from "../random";
|
||||
import {
|
||||
arrayToMap,
|
||||
assertNever,
|
||||
cloneJSON,
|
||||
getFontString,
|
||||
isDevEnv,
|
||||
toBrandedType,
|
||||
} from "../utils";
|
||||
|
||||
import type { ElementConstructorOpts } from "../element/newElement";
|
||||
import type {
|
||||
ElementsMap,
|
||||
ExcalidrawArrowElement,
|
||||
|
@ -40,21 +57,6 @@ import type {
|
|||
VerticalAlign,
|
||||
} from "../element/types";
|
||||
import type { MarkOptional } from "../utility-types";
|
||||
import {
|
||||
arrayToMap,
|
||||
assertNever,
|
||||
cloneJSON,
|
||||
getFontString,
|
||||
isDevEnv,
|
||||
toBrandedType,
|
||||
} from "../utils";
|
||||
import { getSizeFromPoints } from "../points";
|
||||
import { randomId } from "../random";
|
||||
import { syncInvalidIndices } from "../fractionalIndex";
|
||||
import { getLineHeight } from "../fonts";
|
||||
import { isArrowElement } from "../element/typeChecks";
|
||||
import { pointFrom, type LocalPoint } from "@excalidraw/math";
|
||||
import { measureText, normalizeText } from "../element/textMeasurements";
|
||||
|
||||
export type ValidLinearElement = {
|
||||
type: "arrow" | "line";
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import type { cleanAppStateForExport } from "../appState";
|
||||
import type { VERSIONS } from "../constants";
|
||||
import type { ExcalidrawElement } from "../element/types";
|
||||
import type {
|
||||
AppState,
|
||||
|
@ -5,8 +7,6 @@ import type {
|
|||
LibraryItems,
|
||||
LibraryItems_anyVersion,
|
||||
} from "../types";
|
||||
import type { cleanAppStateForExport } from "../appState";
|
||||
import type { VERSIONS } from "../constants";
|
||||
|
||||
export interface ExportedDataState {
|
||||
type: string;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { sanitizeUrl } from "@braintree/sanitize-url";
|
||||
|
||||
import { escapeDoubleQuotes } from "../utils";
|
||||
|
||||
export const normalizeLink = (link: string) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue