feat: move utils to utils package and make @excalidraw/utils a workspace (#7432)

* feat: move utils to utils package and make @excalidraw/utils a workspace

* remove esm and update types path

* remove esm script

* fix package.json and yarn.lock

* update path

* fix

* fix lint and test
This commit is contained in:
Aakansha Doshi 2023-12-13 21:51:27 +05:30 committed by GitHub
parent b635b10b59
commit 88a2b286c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 261 additions and 56 deletions

View file

@ -5,7 +5,6 @@ import { RoughCanvas } from "roughjs/bin/canvas";
import rough from "roughjs/bin/rough";
import clsx from "clsx";
import { nanoid } from "nanoid";
import {
actionAddToLibrary,
actionBringForward,
@ -392,7 +391,7 @@ import {
import { Emitter } from "../emitter";
import { ElementCanvasButtons } from "../element/ElementCanvasButtons";
import { MagicCacheData, diagramToHTML } from "../data/magic";
import { elementsOverlappingBBox, exportToBlob } from "../../utils";
import { elementsOverlappingBBox, exportToBlob } from "../../utils/export";
import { COLOR_PALETTE } from "../colors";
import { ElementCanvasButton } from "./MagicButton";
import { MagicIcon, copyIcon, fullscreenIcon } from "./icons";

View file

@ -23,7 +23,7 @@ import { nativeFileSystemSupported } from "../data/filesystem";
import { NonDeletedExcalidrawElement } from "../element/types";
import { t } from "../i18n";
import { isSomeElementSelected } from "../scene";
import { exportToCanvas } from "../../utils";
import { exportToCanvas } from "../../utils/export";
import { copyIcon, downloadIcon, helpIcon } from "./icons";
import { Dialog } from "./Dialog";

View file

@ -6,7 +6,7 @@ import { t } from "../i18n";
import Trans from "./Trans";
import { LibraryItems, LibraryItem, UIAppState } from "../types";
import { exportToCanvas, exportToSvg } from "../../utils";
import { exportToCanvas, exportToSvg } from "../../utils/export";
import {
EDITOR_LS_KEYS,
EXPORT_DATA_TYPES,

View file

@ -11,7 +11,7 @@ import {
NonDeletedExcalidrawElement,
} from "../element/types";
import { t } from "../i18n";
import { elementsOverlappingBBox } from "../../withinBounds";
import { elementsOverlappingBBox } from "../../utils/export";
import { isSomeElementSelected, getSelectedElements } from "../scene";
import { exportToCanvas, exportToSvg } from "../scene/export";
import { ExportType } from "../scene/types";

View file

@ -21,7 +21,7 @@ import { getElementsWithinSelection, getSelectedElements } from "./scene";
import { getElementsInGroup, selectGroupsFromGivenElements } from "./groups";
import Scene, { ExcalidrawElementsIncludingDeleted } from "./scene/Scene";
import { getElementLineSegments } from "./element/bounds";
import { doLineSegmentsIntersect } from "../utils";
import { doLineSegmentsIntersect } from "../utils/export";
import { isFrameElement, isFrameLikeElement } from "./element/typeChecks";
// --------------------------- Frame State ------------------------------------

View file

@ -2,7 +2,7 @@ import { atom, useAtom } from "jotai";
import { useEffect, useState } from "react";
import { COLOR_PALETTE } from "../colors";
import { jotaiScope } from "../jotai";
import { exportToSvg } from "../../utils";
import { exportToSvg } from "../../utils/export";
import { LibraryItem } from "../types";
export type SvgCache = Map<LibraryItem["id"], SVGSVGElement>;

View file

@ -216,7 +216,7 @@ export {
getFreeDrawSvgPath,
exportToClipboard,
mergeLibraryItems,
} from "../utils";
} from "../utils/export";
export { isLinearElement } from "./element/typeChecks";
export { FONT_FAMILY, THEME, MIME_TYPES } from "./constants";
@ -254,4 +254,4 @@ export {
elementsOverlappingBBox,
isElementInsideBBox,
elementPartiallyOverlapsWithOrContainsBBox,
} from "../withinBounds";
} from "../utils/export";

View file

@ -2,7 +2,7 @@
"name": "@excalidraw/excalidraw",
"version": "0.17.1",
"main": "main.js",
"types": "types/packages/excalidraw/index.d.ts",
"types": "types/excalidraw/index.d.ts",
"files": [
"dist/*",
"types/*"
@ -77,9 +77,6 @@
"tunnel-rat": "0.1.2"
},
"devDependencies": {
"@types/pako": "1.0.3",
"@types/pica": "5.1.3",
"@types/resize-observer-browser": "0.1.7",
"@babel/core": "7.18.9",
"@babel/plugin-transform-arrow-functions": "7.18.6",
"@babel/plugin-transform-async-to-generator": "7.18.6",
@ -89,6 +86,9 @@
"@babel/preset-react": "7.18.6",
"@babel/preset-typescript": "7.18.6",
"@size-limit/preset-big-lib": "9.0.0",
"@types/pako": "1.0.3",
"@types/pica": "5.1.3",
"@types/resize-observer-browser": "0.1.7",
"autoprefixer": "10.4.7",
"babel-loader": "8.2.5",
"babel-plugin-transform-class-properties": "6.24.1",

View file

@ -26,7 +26,7 @@ import {
getInitializedImageElements,
updateImageCache,
} from "../element/image";
import { elementsOverlappingBBox } from "../../withinBounds";
import { elementsOverlappingBBox } from "../../utils/export";
import {
getFrameLikeElements,
getFrameLikeTitle,