From 0027f08cad80f8ef958da65f187cd713ef24063f Mon Sep 17 00:00:00 2001 From: Marcel Mraz Date: Tue, 18 Mar 2025 12:53:51 +0100 Subject: [PATCH] Fix vite app --- excalidraw-app/App.tsx | 14 +++++++------- excalidraw-app/CustomStats.tsx | 6 +++--- excalidraw-app/ExcalidrawPlusIframeExport.tsx | 2 +- excalidraw-app/collab/Collab.tsx | 14 +++++++------- excalidraw-app/collab/Portal.tsx | 6 +++--- excalidraw-app/components/AI.tsx | 2 +- excalidraw-app/components/AppMainMenu.tsx | 2 +- excalidraw-app/components/AppWelcomeScreen.tsx | 2 +- excalidraw-app/components/DebugCanvas.tsx | 15 ++++++++------- .../components/ExportToExcalidrawPlus.tsx | 8 ++++---- excalidraw-app/components/GitHubCorner.tsx | 4 ++-- excalidraw-app/data/FileManager.ts | 6 +++--- excalidraw-app/data/LocalData.ts | 14 ++++---------- excalidraw-app/data/firebase.ts | 6 +++--- excalidraw-app/data/index.ts | 12 ++++++------ excalidraw-app/data/localStorage.ts | 4 ++-- excalidraw-app/share/ShareDialog.tsx | 4 ++-- excalidraw-app/useHandleAppTheme.ts | 6 +++--- excalidraw-app/vite.config.mts | 12 ++++++------ 19 files changed, 67 insertions(+), 72 deletions(-) diff --git a/excalidraw-app/App.tsx b/excalidraw-app/App.tsx index dc399a7d0..cd1f4cb5b 100644 --- a/excalidraw-app/App.tsx +++ b/excalidraw-app/App.tsx @@ -22,7 +22,7 @@ import { THEME, TITLE_TIMEOUT, VERSION_TIMEOUT, -} from "@excalidraw/excalidraw/constants"; +} from "@excalidraw/common"; import polyfill from "@excalidraw/excalidraw/polyfill"; import { useCallback, useEffect, useRef, useState } from "react"; import { loadFromBlob } from "@excalidraw/excalidraw/data/blob"; @@ -36,7 +36,7 @@ import { preventUnload, resolvablePromise, isRunningInIframe, -} from "@excalidraw/excalidraw/utils"; +} from "@excalidraw/common"; import { GithubIcon, XBrandIcon, @@ -47,10 +47,10 @@ import { share, youtubeIcon, } from "@excalidraw/excalidraw/components/icons"; -import { isElementLink } from "@excalidraw/excalidraw/element/elementLink"; +import { isElementLink } from "@excalidraw/element/elementLink"; import { restore, restoreAppState } from "@excalidraw/excalidraw/data/restore"; -import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement"; -import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks"; +import { newElementWith } from "@excalidraw/element/mutateElement"; +import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; import clsx from "clsx"; import { parseLibraryTokensFromUrl, @@ -63,7 +63,7 @@ import type { FileId, NonDeletedExcalidrawElement, OrderedExcalidrawElement, -} from "@excalidraw/excalidraw/element/types"; +} from "@excalidraw/element/types"; import type { AppState, ExcalidrawImperativeAPI, @@ -72,7 +72,7 @@ import type { UIAppState, } from "@excalidraw/excalidraw/types"; import type { ResolutionType } from "@excalidraw/excalidraw/utility-types"; -import type { ResolvablePromise } from "@excalidraw/excalidraw/utils"; +import type { ResolvablePromise } from "@excalidraw/common"; import CustomStats from "./CustomStats"; import { diff --git a/excalidraw-app/CustomStats.tsx b/excalidraw-app/CustomStats.tsx index c57f297fe..978aa17a1 100644 --- a/excalidraw-app/CustomStats.tsx +++ b/excalidraw-app/CustomStats.tsx @@ -1,11 +1,11 @@ import { Stats } from "@excalidraw/excalidraw"; import { copyTextToSystemClipboard } from "@excalidraw/excalidraw/clipboard"; -import { DEFAULT_VERSION } from "@excalidraw/excalidraw/constants"; +import { DEFAULT_VERSION } from "@excalidraw/common"; import { t } from "@excalidraw/excalidraw/i18n"; -import { debounce, getVersion, nFormatter } from "@excalidraw/excalidraw/utils"; +import { debounce, getVersion, nFormatter } from "@excalidraw/common"; import { useEffect, useState } from "react"; -import type { NonDeletedExcalidrawElement } from "@excalidraw/excalidraw/element/types"; +import type { NonDeletedExcalidrawElement } from "@excalidraw/element/types"; import type { UIAppState } from "@excalidraw/excalidraw/types"; import { diff --git a/excalidraw-app/ExcalidrawPlusIframeExport.tsx b/excalidraw-app/ExcalidrawPlusIframeExport.tsx index be046f795..0ad27cafb 100644 --- a/excalidraw-app/ExcalidrawPlusIframeExport.tsx +++ b/excalidraw-app/ExcalidrawPlusIframeExport.tsx @@ -5,7 +5,7 @@ import { useLayoutEffect, useRef } from "react"; import type { FileId, OrderedExcalidrawElement, -} from "@excalidraw/excalidraw/element/types"; +} from "@excalidraw/element/types"; import type { AppState, BinaryFileData } from "@excalidraw/excalidraw/types"; import { STORAGE_KEYS } from "./app_constants"; diff --git a/excalidraw-app/collab/Collab.tsx b/excalidraw-app/collab/Collab.tsx index 0964a7365..c23a0f474 100644 --- a/excalidraw-app/collab/Collab.tsx +++ b/excalidraw-app/collab/Collab.tsx @@ -6,19 +6,19 @@ import { reconcileElements, } from "@excalidraw/excalidraw"; import { ErrorDialog } from "@excalidraw/excalidraw/components/ErrorDialog"; -import { APP_NAME, ENV, EVENT } from "@excalidraw/excalidraw/constants"; +import { APP_NAME, ENV, EVENT } from "@excalidraw/common"; import { IDLE_THRESHOLD, ACTIVE_THRESHOLD, UserIdleState, -} from "@excalidraw/excalidraw/constants"; +} from "@excalidraw/common"; import { decryptData } from "@excalidraw/excalidraw/data/encryption"; -import { getVisibleSceneBounds } from "@excalidraw/excalidraw/element/bounds"; -import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement"; +import { getVisibleSceneBounds } from "@excalidraw/element/bounds"; +import { newElementWith } from "@excalidraw/element/mutateElement"; import { isImageElement, isInitializedImageElement, -} from "@excalidraw/excalidraw/element/typeChecks"; +} from "@excalidraw/element/typeChecks"; import { AbortError } from "@excalidraw/excalidraw/errors"; import { t } from "@excalidraw/excalidraw/i18n"; import { withBatchedUpdates } from "@excalidraw/excalidraw/reactUtils"; @@ -27,7 +27,7 @@ import { preventUnload, resolvablePromise, throttleRAF, -} from "@excalidraw/excalidraw/utils"; +} from "@excalidraw/common"; import throttle from "lodash.throttle"; import { PureComponent } from "react"; @@ -41,7 +41,7 @@ import type { FileId, InitializedExcalidrawImageElement, OrderedExcalidrawElement, -} from "@excalidraw/excalidraw/element/types"; +} from "@excalidraw/element/types"; import type { BinaryFileData, ExcalidrawImperativeAPI, diff --git a/excalidraw-app/collab/Portal.tsx b/excalidraw-app/collab/Portal.tsx index 037bca314..26a7d0d9e 100644 --- a/excalidraw-app/collab/Portal.tsx +++ b/excalidraw-app/collab/Portal.tsx @@ -1,11 +1,11 @@ import { CaptureUpdateAction } from "@excalidraw/excalidraw"; import { trackEvent } from "@excalidraw/excalidraw/analytics"; import { encryptData } from "@excalidraw/excalidraw/data/encryption"; -import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement"; +import { newElementWith } from "@excalidraw/element/mutateElement"; import throttle from "lodash.throttle"; -import type { UserIdleState } from "@excalidraw/excalidraw/constants"; -import type { OrderedExcalidrawElement } from "@excalidraw/excalidraw/element/types"; +import type { UserIdleState } from "@excalidraw/common"; +import type { OrderedExcalidrawElement } from "@excalidraw/element/types"; import type { OnUserFollowedPayload, SocketId, diff --git a/excalidraw-app/components/AI.tsx b/excalidraw-app/components/AI.tsx index c9b6684b3..4469d74f6 100644 --- a/excalidraw-app/components/AI.tsx +++ b/excalidraw-app/components/AI.tsx @@ -6,7 +6,7 @@ import { TTDDialog, } from "@excalidraw/excalidraw"; import { getDataURL } from "@excalidraw/excalidraw/data/blob"; -import { safelyParseJSON } from "@excalidraw/excalidraw/utils"; +import { safelyParseJSON } from "@excalidraw/common"; import type { ExcalidrawImperativeAPI } from "@excalidraw/excalidraw/types"; diff --git a/excalidraw-app/components/AppMainMenu.tsx b/excalidraw-app/components/AppMainMenu.tsx index 996d6912d..c90d4e325 100644 --- a/excalidraw-app/components/AppMainMenu.tsx +++ b/excalidraw-app/components/AppMainMenu.tsx @@ -6,7 +6,7 @@ import { import { MainMenu } from "@excalidraw/excalidraw/index"; import React from "react"; -import type { Theme } from "@excalidraw/excalidraw/element/types"; +import type { Theme } from "@excalidraw/element/types"; import { LanguageList } from "../app-language/LanguageList"; import { isExcalidrawPlusSignedUser } from "../app_constants"; diff --git a/excalidraw-app/components/AppWelcomeScreen.tsx b/excalidraw-app/components/AppWelcomeScreen.tsx index c33de092a..5bb5073e9 100644 --- a/excalidraw-app/components/AppWelcomeScreen.tsx +++ b/excalidraw-app/components/AppWelcomeScreen.tsx @@ -1,5 +1,5 @@ import { loginIcon } from "@excalidraw/excalidraw/components/icons"; -import { POINTER_EVENTS } from "@excalidraw/excalidraw/constants"; +import { POINTER_EVENTS } from "@excalidraw/common"; import { useI18n } from "@excalidraw/excalidraw/i18n"; import { WelcomeScreen } from "@excalidraw/excalidraw/index"; import React from "react"; diff --git a/excalidraw-app/components/DebugCanvas.tsx b/excalidraw-app/components/DebugCanvas.tsx index af1a2b140..e83a62647 100644 --- a/excalidraw-app/components/DebugCanvas.tsx +++ b/excalidraw-app/components/DebugCanvas.tsx @@ -8,20 +8,21 @@ import { getNormalizedCanvasDimensions, } from "@excalidraw/excalidraw/renderer/helpers"; import { type AppState } from "@excalidraw/excalidraw/types"; -import { throttleRAF } from "@excalidraw/excalidraw/utils"; +import { throttleRAF } from "@excalidraw/common"; import { useCallback, useImperativeHandle, useRef } from "react"; -import type { DebugElement } from "@excalidraw/excalidraw/visualdebug"; - import { isLineSegment, type GlobalPoint, type LineSegment, -} from "../../packages/math"; -import { isCurve } from "../../packages/math/curve"; -import { STORAGE_KEYS } from "../app_constants"; +} from "@excalidraw/math"; +import { isCurve } from "@excalidraw/math/curve"; -import type { Curve } from "../../packages/math"; +import type { DebugElement } from "@excalidraw/excalidraw/visualdebug"; + +import type { Curve } from "@excalidraw/math"; + +import { STORAGE_KEYS } from "../app_constants"; const renderLine = ( context: CanvasRenderingContext2D, diff --git a/excalidraw-app/components/ExportToExcalidrawPlus.tsx b/excalidraw-app/components/ExportToExcalidrawPlus.tsx index a630f804f..785e23a1e 100644 --- a/excalidraw-app/components/ExportToExcalidrawPlus.tsx +++ b/excalidraw-app/components/ExportToExcalidrawPlus.tsx @@ -2,15 +2,15 @@ import { trackEvent } from "@excalidraw/excalidraw/analytics"; import { Card } from "@excalidraw/excalidraw/components/Card"; import { ExcalidrawLogo } from "@excalidraw/excalidraw/components/ExcalidrawLogo"; import { ToolButton } from "@excalidraw/excalidraw/components/ToolButton"; -import { MIME_TYPES } from "@excalidraw/excalidraw/constants"; +import { MIME_TYPES } from "@excalidraw/common"; import { encryptData, generateEncryptionKey, } from "@excalidraw/excalidraw/data/encryption"; import { serializeAsJSON } from "@excalidraw/excalidraw/data/json"; -import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks"; +import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; import { useI18n } from "@excalidraw/excalidraw/i18n"; -import { getFrame } from "@excalidraw/excalidraw/utils"; +import { getFrame } from "@excalidraw/common"; import { uploadBytes, ref } from "firebase/storage"; import { nanoid } from "nanoid"; import React from "react"; @@ -18,7 +18,7 @@ import React from "react"; import type { FileId, NonDeletedExcalidrawElement, -} from "@excalidraw/excalidraw/element/types"; +} from "@excalidraw/element/types"; import type { AppState, BinaryFileData, diff --git a/excalidraw-app/components/GitHubCorner.tsx b/excalidraw-app/components/GitHubCorner.tsx index b1c17f29e..6a4108813 100644 --- a/excalidraw-app/components/GitHubCorner.tsx +++ b/excalidraw-app/components/GitHubCorner.tsx @@ -1,8 +1,8 @@ -import { THEME } from "@excalidraw/excalidraw/constants"; +import { THEME } from "@excalidraw/common"; import oc from "open-color"; import React from "react"; -import type { Theme } from "@excalidraw/excalidraw/element/types"; +import type { Theme } from "@excalidraw/element/types"; // https://github.com/tholman/github-corners export const GitHubCorner = React.memo( diff --git a/excalidraw-app/data/FileManager.ts b/excalidraw-app/data/FileManager.ts index 93d7ddec8..5d134144f 100644 --- a/excalidraw-app/data/FileManager.ts +++ b/excalidraw-app/data/FileManager.ts @@ -1,7 +1,7 @@ import { CaptureUpdateAction } from "@excalidraw/excalidraw"; import { compressData } from "@excalidraw/excalidraw/data/encode"; -import { newElementWith } from "@excalidraw/excalidraw/element/mutateElement"; -import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks"; +import { newElementWith } from "@excalidraw/element/mutateElement"; +import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; import { t } from "@excalidraw/excalidraw/i18n"; import type { @@ -9,7 +9,7 @@ import type { ExcalidrawImageElement, FileId, InitializedExcalidrawImageElement, -} from "@excalidraw/excalidraw/element/types"; +} from "@excalidraw/element/types"; import type { BinaryFileData, BinaryFileMetadata, diff --git a/excalidraw-app/data/LocalData.ts b/excalidraw-app/data/LocalData.ts index 6b53cc482..3ff2692d9 100644 --- a/excalidraw-app/data/LocalData.ts +++ b/excalidraw-app/data/LocalData.ts @@ -11,12 +11,9 @@ */ import { clearAppStateForLocalStorage } from "@excalidraw/excalidraw/appState"; -import { - CANVAS_SEARCH_TAB, - DEFAULT_SIDEBAR, -} from "@excalidraw/excalidraw/constants"; -import { clearElementsForLocalStorage } from "@excalidraw/excalidraw/element"; -import { debounce } from "@excalidraw/excalidraw/utils"; +import { CANVAS_SEARCH_TAB, DEFAULT_SIDEBAR } from "@excalidraw/common"; +import { clearElementsForLocalStorage } from "@excalidraw/element"; +import { debounce } from "@excalidraw/common"; import { createStore, entries, @@ -29,10 +26,7 @@ import { import type { LibraryPersistedData } from "@excalidraw/excalidraw/data/library"; import type { ImportedDataState } from "@excalidraw/excalidraw/data/types"; -import type { - ExcalidrawElement, - FileId, -} from "@excalidraw/excalidraw/element/types"; +import type { ExcalidrawElement, FileId } from "@excalidraw/element/types"; import type { AppState, BinaryFileData, diff --git a/excalidraw-app/data/firebase.ts b/excalidraw-app/data/firebase.ts index 66893b513..568054f7e 100644 --- a/excalidraw-app/data/firebase.ts +++ b/excalidraw-app/data/firebase.ts @@ -1,12 +1,12 @@ import { reconcileElements } from "@excalidraw/excalidraw"; -import { MIME_TYPES } from "@excalidraw/excalidraw/constants"; +import { MIME_TYPES } from "@excalidraw/common"; import { decompressData } from "@excalidraw/excalidraw/data/encode"; import { encryptData, decryptData, } from "@excalidraw/excalidraw/data/encryption"; import { restoreElements } from "@excalidraw/excalidraw/data/restore"; -import { getSceneVersion } from "@excalidraw/excalidraw/element"; +import { getSceneVersion } from "@excalidraw/element"; import { initializeApp } from "firebase/app"; import { getFirestore, @@ -22,7 +22,7 @@ import type { ExcalidrawElement, FileId, OrderedExcalidrawElement, -} from "@excalidraw/excalidraw/element/types"; +} from "@excalidraw/element/types"; import type { AppState, BinaryFileData, diff --git a/excalidraw-app/data/index.ts b/excalidraw-app/data/index.ts index e8fbc1f4d..3964b27d2 100644 --- a/excalidraw-app/data/index.ts +++ b/excalidraw-app/data/index.ts @@ -9,19 +9,19 @@ import { } from "@excalidraw/excalidraw/data/encryption"; import { serializeAsJSON } from "@excalidraw/excalidraw/data/json"; import { restore } from "@excalidraw/excalidraw/data/restore"; -import { isInvisiblySmallElement } from "@excalidraw/excalidraw/element/sizeHelpers"; -import { isInitializedImageElement } from "@excalidraw/excalidraw/element/typeChecks"; +import { isInvisiblySmallElement } from "@excalidraw/element/sizeHelpers"; +import { isInitializedImageElement } from "@excalidraw/element/typeChecks"; import { t } from "@excalidraw/excalidraw/i18n"; -import { bytesToHexString } from "@excalidraw/excalidraw/utils"; +import { bytesToHexString } from "@excalidraw/common"; -import type { UserIdleState } from "@excalidraw/excalidraw/constants"; +import type { UserIdleState } from "@excalidraw/common"; import type { ImportedDataState } from "@excalidraw/excalidraw/data/types"; -import type { SceneBounds } from "@excalidraw/excalidraw/element/bounds"; +import type { SceneBounds } from "@excalidraw/element/bounds"; import type { ExcalidrawElement, FileId, OrderedExcalidrawElement, -} from "@excalidraw/excalidraw/element/types"; +} from "@excalidraw/element/types"; import type { AppState, BinaryFileData, diff --git a/excalidraw-app/data/localStorage.ts b/excalidraw-app/data/localStorage.ts index ac1206498..bc0df4a67 100644 --- a/excalidraw-app/data/localStorage.ts +++ b/excalidraw-app/data/localStorage.ts @@ -2,9 +2,9 @@ import { clearAppStateForLocalStorage, getDefaultAppState, } from "@excalidraw/excalidraw/appState"; -import { clearElementsForLocalStorage } from "@excalidraw/excalidraw/element"; +import { clearElementsForLocalStorage } from "@excalidraw/element"; -import type { ExcalidrawElement } from "@excalidraw/excalidraw/element/types"; +import type { ExcalidrawElement } from "@excalidraw/element/types"; import type { AppState } from "@excalidraw/excalidraw/types"; import { STORAGE_KEYS } from "../app_constants"; diff --git a/excalidraw-app/share/ShareDialog.tsx b/excalidraw-app/share/ShareDialog.tsx index de77c6079..2dcce1409 100644 --- a/excalidraw-app/share/ShareDialog.tsx +++ b/excalidraw-app/share/ShareDialog.tsx @@ -15,8 +15,8 @@ import { import { useUIAppState } from "@excalidraw/excalidraw/context/ui-appState"; import { useCopyStatus } from "@excalidraw/excalidraw/hooks/useCopiedIndicator"; import { useI18n } from "@excalidraw/excalidraw/i18n"; -import { KEYS } from "@excalidraw/excalidraw/keys"; -import { getFrame } from "@excalidraw/excalidraw/utils"; +import { KEYS } from "@excalidraw/common"; +import { getFrame } from "@excalidraw/common"; import { useEffect, useRef, useState } from "react"; import { atom, useAtom, useAtomValue } from "../app-jotai"; diff --git a/excalidraw-app/useHandleAppTheme.ts b/excalidraw-app/useHandleAppTheme.ts index 6fc2ff54f..5ae60f0b7 100644 --- a/excalidraw-app/useHandleAppTheme.ts +++ b/excalidraw-app/useHandleAppTheme.ts @@ -1,9 +1,9 @@ import { THEME } from "@excalidraw/excalidraw"; -import { EVENT } from "@excalidraw/excalidraw/constants"; -import { CODES, KEYS } from "@excalidraw/excalidraw/keys"; +import { EVENT } from "@excalidraw/common"; +import { CODES, KEYS } from "@excalidraw/common"; import { useEffect, useLayoutEffect, useState } from "react"; -import type { Theme } from "@excalidraw/excalidraw/element/types"; +import type { Theme } from "@excalidraw/element/types"; import { STORAGE_KEYS } from "./app_constants"; diff --git a/excalidraw-app/vite.config.mts b/excalidraw-app/vite.config.mts index 90771a335..627b75710 100644 --- a/excalidraw-app/vite.config.mts +++ b/excalidraw-app/vite.config.mts @@ -25,19 +25,19 @@ export default defineConfig(({ mode }) => { alias: [ { find: /^@excalidraw\/common$/, - replacement: path.resolve(__dirname, "../packages/common/index.ts"), + replacement: path.resolve(__dirname, "../packages/common/src/index.ts"), }, { find: /^@excalidraw\/common\/(.*?)/, - replacement: path.resolve(__dirname, "../packages/common/$1"), + replacement: path.resolve(__dirname, "../packages/common/src/$1"), }, { find: /^@excalidraw\/element$/, - replacement: path.resolve(__dirname, "../packages/element/index.ts"), + replacement: path.resolve(__dirname, "../packages/element/src/index.ts"), }, { find: /^@excalidraw\/element\/(.*?)/, - replacement: path.resolve(__dirname, "../packages/element/$1"), + replacement: path.resolve(__dirname, "../packages/element/src/$1"), }, { find: /^@excalidraw\/excalidraw$/, @@ -57,11 +57,11 @@ export default defineConfig(({ mode }) => { }, { find: /^@excalidraw\/math$/, - replacement: path.resolve(__dirname, "../packages/math/index.ts"), + replacement: path.resolve(__dirname, "../packages/math/src/index.ts"), }, { find: /^@excalidraw\/math\/(.*?)/, - replacement: path.resolve(__dirname, "../packages/math/$1"), + replacement: path.resolve(__dirname, "../packages/math/src/$1"), }, ], },