move the files to src and tests folders under utils
This commit is contained in:
parent
a76999e9a2
commit
58567dd2b6
@ -6,7 +6,7 @@ import {
|
||||
rectangleWithLinkFixture,
|
||||
} from "../fixtures/elementFixture";
|
||||
import { API } from "../helpers/api";
|
||||
import { exportToCanvas, exportToSvg } from "../../../utils/export";
|
||||
import { exportToCanvas, exportToSvg } from "../../../utils/src/export";
|
||||
import { FRAME_STYLE } from "../../constants";
|
||||
import { prepareElementsForExport } from "../../data";
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
export * from "./export";
|
||||
export * from "./withinBounds";
|
||||
export * from "./bbox";
|
||||
export * from "./collision";
|
||||
export * from "./geometry/shape";
|
||||
export * from "./geometry/geometry";
|
||||
export * from "./src/export";
|
||||
export * from "./src/withinBounds";
|
||||
export * from "./src/bbox";
|
||||
export * from "./src/collision";
|
||||
export * from "./src/geometry/shape";
|
||||
export * from "./src/geometry/geometry";
|
||||
|
@ -64,6 +64,7 @@
|
||||
"@babel/preset-typescript": "7.18.6",
|
||||
"babel-loader": "8.2.5",
|
||||
"babel-plugin-transform-class-properties": "6.24.1",
|
||||
"chokidar": "3.6.0",
|
||||
"cross-env": "7.0.3",
|
||||
"css-loader": "6.7.1",
|
||||
"file-loader": "6.2.0",
|
||||
@ -79,6 +80,7 @@
|
||||
"scripts": {
|
||||
"gen:types": "rm -rf types && tsc",
|
||||
"build:umd": "cross-env NODE_ENV=production webpack --config webpack.prod.config.js",
|
||||
"build:src": "rm -rf dist && node ../../scripts/buildUtils.js",
|
||||
"build:esm": "rm -rf dist && node ../../scripts/buildUtils.js && yarn gen:types",
|
||||
"build:umd:withAnalyzer": "cross-env NODE_ENV=production ANALYZER=true webpack --config webpack.prod.config.js",
|
||||
"clear": "rm -rf dist",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { Bounds } from "../excalidraw/element/bounds";
|
||||
import type { Point } from "../excalidraw/types";
|
||||
import type { Bounds } from "../../excalidraw/element/bounds";
|
||||
import type { Point } from "../../excalidraw/types";
|
||||
|
||||
export type LineSegment = [Point, Point];
|
||||
|
||||
@ -17,6 +17,7 @@ export function crossProduct(a: Point, b: Point) {
|
||||
}
|
||||
|
||||
export function doBBoxesIntersect(a: Bounds, b: Bounds) {
|
||||
console.log("HI");
|
||||
return a[0] <= b[2] && a[2] >= b[0] && a[1] <= b[3] && a[3] >= b[1];
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
import {
|
||||
exportToCanvas as _exportToCanvas,
|
||||
exportToSvg as _exportToSvg,
|
||||
} from "../excalidraw/scene/export";
|
||||
import { getDefaultAppState } from "../excalidraw/appState";
|
||||
import type { AppState, BinaryFiles } from "../excalidraw/types";
|
||||
} from "../../excalidraw/scene/export";
|
||||
import { getDefaultAppState } from "../../excalidraw/appState";
|
||||
import type { AppState, BinaryFiles } from "../../excalidraw/types";
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
ExcalidrawFrameLikeElement,
|
||||
NonDeleted,
|
||||
} from "../excalidraw/element/types";
|
||||
import { restore } from "../excalidraw/data/restore";
|
||||
import { MIME_TYPES } from "../excalidraw/constants";
|
||||
import { encodePngMetadata } from "../excalidraw/data/image";
|
||||
import { serializeAsJSON } from "../excalidraw/data/json";
|
||||
} from "../../excalidraw/element/types";
|
||||
import { restore } from "../../excalidraw/data/restore";
|
||||
import { MIME_TYPES } from "../../excalidraw/constants";
|
||||
import { encodePngMetadata } from "../../excalidraw/data/image";
|
||||
import { serializeAsJSON } from "../../excalidraw/data/json";
|
||||
import {
|
||||
copyBlobToClipboardAsPng,
|
||||
copyTextToSystemClipboard,
|
||||
copyToClipboard,
|
||||
} from "../excalidraw/clipboard";
|
||||
} from "../../excalidraw/clipboard";
|
||||
|
||||
export { MIME_TYPES };
|
||||
|
||||
@ -170,7 +170,7 @@ export const exportToSvg = async ({
|
||||
exportPadding?: number;
|
||||
renderEmbeddables?: boolean;
|
||||
}): Promise<SVGSVGElement> => {
|
||||
console.info("HIIII FROM UTILS WORKSPACE");
|
||||
console.info("Watching exportToSVG :)");
|
||||
|
||||
const { elements: restoredElements, appState: restoredAppState } = restore(
|
||||
{ elements, appState },
|
@ -1,4 +1,4 @@
|
||||
import { distance2d } from "../../excalidraw/math";
|
||||
import { distance2d } from "../../../excalidraw/math";
|
||||
import type {
|
||||
Point,
|
||||
Line,
|
@ -12,7 +12,7 @@
|
||||
* to pure shapes
|
||||
*/
|
||||
|
||||
import { getElementAbsoluteCoords } from "../../excalidraw/element";
|
||||
import { getElementAbsoluteCoords } from "../../../excalidraw/element";
|
||||
import type {
|
||||
ElementsMap,
|
||||
ExcalidrawDiamondElement,
|
||||
@ -27,7 +27,7 @@ import type {
|
||||
ExcalidrawRectangleElement,
|
||||
ExcalidrawSelectionElement,
|
||||
ExcalidrawTextElement,
|
||||
} from "../../excalidraw/element/types";
|
||||
} from "../../../excalidraw/element/types";
|
||||
import { angleToDegrees, close, pointAdd, pointRotate } from "./geometry";
|
||||
import { pointsOnBezierCurves } from "points-on-curve";
|
||||
import type { Drawable, Op } from "roughjs/bin/core";
|
@ -3,19 +3,19 @@ import type {
|
||||
ExcalidrawFreeDrawElement,
|
||||
ExcalidrawLinearElement,
|
||||
NonDeletedExcalidrawElement,
|
||||
} from "../excalidraw/element/types";
|
||||
} from "../../excalidraw/element/types";
|
||||
import {
|
||||
isArrowElement,
|
||||
isExcalidrawElement,
|
||||
isFreeDrawElement,
|
||||
isLinearElement,
|
||||
isTextElement,
|
||||
} from "../excalidraw/element/typeChecks";
|
||||
import { isValueInRange, rotatePoint } from "../excalidraw/math";
|
||||
import type { Point } from "../excalidraw/types";
|
||||
import type { Bounds } from "../excalidraw/element/bounds";
|
||||
import { getElementBounds } from "../excalidraw/element/bounds";
|
||||
import { arrayToMap } from "../excalidraw/utils";
|
||||
} from "../../excalidraw/element/typeChecks";
|
||||
import { isValueInRange, rotatePoint } from "../../excalidraw/math";
|
||||
import type { Point } from "../../excalidraw/types";
|
||||
import type { Bounds } from "../../excalidraw/element/bounds";
|
||||
import { getElementBounds } from "../../excalidraw/element/bounds";
|
||||
import { arrayToMap } from "../../excalidraw/utils";
|
||||
|
||||
type Element = NonDeletedExcalidrawElement;
|
||||
type Elements = readonly NonDeletedExcalidrawElement[];
|
@ -1,9 +1,9 @@
|
||||
import * as utils from "./export";
|
||||
import { diagramFactory } from "../excalidraw/tests/fixtures/diagramFixture";
|
||||
import * as utils from "../src/export";
|
||||
import { diagramFactory } from "../../excalidraw/tests/fixtures/diagramFixture";
|
||||
import { vi } from "vitest";
|
||||
import * as mockedSceneExportUtils from "../excalidraw/scene/export";
|
||||
import * as mockedSceneExportUtils from "../../excalidraw/scene/export";
|
||||
|
||||
import { MIME_TYPES } from "../excalidraw/constants";
|
||||
import { MIME_TYPES } from "../../excalidraw/constants";
|
||||
|
||||
const exportToSvgSpy = vi.spyOn(mockedSceneExportUtils, "exportToSvg");
|
||||
|
@ -11,8 +11,15 @@ import {
|
||||
pointOnPolyline,
|
||||
pointRightofLine,
|
||||
pointRotate,
|
||||
} from "./geometry";
|
||||
import type { Curve, Ellipse, Line, Point, Polygon, Polyline } from "./shape";
|
||||
} from "../src/geometry/geometry";
|
||||
import type {
|
||||
Curve,
|
||||
Ellipse,
|
||||
Line,
|
||||
Point,
|
||||
Polygon,
|
||||
Polyline,
|
||||
} from "../src/geometry/shape";
|
||||
|
||||
describe("point and line", () => {
|
||||
const line: Line = [
|
@ -1,7 +1,10 @@
|
||||
import { decodePngMetadata, decodeSvgMetadata } from "../excalidraw/data/image";
|
||||
import type { ImportedDataState } from "../excalidraw/data/types";
|
||||
import * as utils from "../utils";
|
||||
import { API } from "../excalidraw/tests/helpers/api";
|
||||
import {
|
||||
decodePngMetadata,
|
||||
decodeSvgMetadata,
|
||||
} from "../../excalidraw/data/image";
|
||||
import type { ImportedDataState } from "../../excalidraw/data/types";
|
||||
import * as utils from "../dist/prod";
|
||||
import { API } from "../../excalidraw/tests/helpers/api";
|
||||
|
||||
// NOTE this test file is using the actual API, unmocked. Hence splitting it
|
||||
// from the other test file, because I couldn't figure out how to test
|
@ -1,10 +1,10 @@
|
||||
import type { Bounds } from "../excalidraw/element/bounds";
|
||||
import { API } from "../excalidraw/tests/helpers/api";
|
||||
import type { Bounds } from "../../excalidraw/element/bounds";
|
||||
import { API } from "../../excalidraw/tests/helpers/api";
|
||||
import {
|
||||
elementPartiallyOverlapsWithOrContainsBBox,
|
||||
elementsOverlappingBBox,
|
||||
isElementInsideBBox,
|
||||
} from "./withinBounds";
|
||||
} from "../src/withinBounds";
|
||||
|
||||
const makeElement = (x: number, y: number, width: number, height: number) =>
|
||||
API.createElement({
|
Loading…
x
Reference in New Issue
Block a user