From e0e13734683e303b539c3206e0b214ce3762357a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwena=C3=ABl=20Gallon?= Date: Tue, 2 Aug 2022 15:56:12 +0200 Subject: [PATCH] Chore: clean up sort imports with prettier (#870) * Update prettier to latest * Add format command * Create .prettierignore * Add prettier plugin sort imports * Update prettier config * Update prettier config * Update .prettierignore * Fix @babel/parser conflict https://github.com/trivago/prettier-plugin-sort-imports/issues/156 * Revert "Update .prettierignore" This reverts commit 282e5b838376f16b3df7f4c1f99f1106baaffea4. * Revert change for apps/www/pages/v/[id].tsx * Sort imports Moves the third party imports to the top, "~" imports in middle, and "./" at last * Sorting of the specifiers in an import declarations * [www] use path vs "../" * [core] use path "~" vs "../" * [tldraw] use path "~" vs "../.../" * [tldraw] use path "~" vs "../" * [tldraw] Cleanup * Update prettier config * Last use path "~" vs "../.../" * [www] Fix order of the third party imports * Clean prettier config --- .prettierignore | 17 ++ .prettierrc | 5 +- apps/electron/src/main/createMenu.ts | 2 +- apps/electron/src/main/createWindow.ts | 2 +- apps/electron/src/main/main.ts | 2 +- apps/electron/src/renderer/app.tsx | 2 +- apps/new-tab-extension/src/App.tsx | 2 +- apps/new-tab-extension/vite.config.ts | 2 +- apps/vscode/editor/scripts/build.mjs | 2 +- apps/vscode/editor/scripts/dev.mjs | 4 +- .../extension/src/TldrawWebviewManager.ts | 4 +- apps/www/components/Editor.tsx | 4 +- apps/www/components/IFrameWarning.tsx | 2 +- apps/www/components/MultiplayerEditor.tsx | 12 +- .../components/ReadOnlyMultiplayerEditor.tsx | 8 +- apps/www/hooks/useMultiplayerState.ts | 10 +- apps/www/hooks/useReadOnlyMultiplayerState.ts | 10 +- apps/www/pages/_app.tsx | 6 +- apps/www/pages/_document.tsx | 6 +- apps/www/pages/api/create.ts | 4 +- apps/www/pages/index.tsx | 2 +- apps/www/pages/r/[id].tsx | 6 +- apps/www/pages/r/index.tsx | 2 +- apps/www/pages/v/[id].tsx | 8 +- apps/www/tsconfig.json | 2 +- apps/www/utils/liveblocks.ts | 2 +- apps/www/utils/sentry.ts | 2 +- apps/www/utils/useGtag.ts | 3 +- .../core-example-advanced/scripts/build.mjs | 2 +- .../core-example-advanced/scripts/dev.mjs | 2 +- examples/core-example-advanced/src/app.tsx | 12 +- .../src/shapes/arrow/ArrowComponent.tsx | 6 +- .../src/shapes/arrow/ArrowIndicator.tsx | 4 +- .../src/shapes/arrow/ArrowUtil.ts | 2 +- .../src/shapes/box/BoxComponent.tsx | 2 +- .../src/shapes/box/BoxIndicator.tsx | 2 +- .../src/shapes/box/BoxUtil.ts | 2 +- .../src/shapes/pencil/PencilComponent.tsx | 2 +- .../src/shapes/pencil/PencilUtil.ts | 6 +- .../src/shapes/pencil/PenclIndicator.tsx | 2 +- .../actions/bindings/getBoundHandlePoint.ts | 2 +- .../src/state/actions/camera/panCamera.ts | 2 +- .../src/state/actions/camera/pinchCamera.ts | 2 +- .../src/state/actions/camera/zoomIn.ts | 2 +- .../src/state/actions/camera/zoomOut.ts | 2 +- .../src/state/actions/camera/zoomToFit.ts | 4 +- .../state/actions/camera/zoomToSelection.ts | 6 +- .../actions/data/restoreSavedDocument.ts | 2 +- .../src/state/actions/erase/eraseShapes.ts | 2 +- .../state/actions/erase/eraseShapesAtPoint.ts | 2 +- .../state/actions/handles/getBoundTarget.ts | 2 +- .../state/actions/handles/translateHandle.ts | 10 +- .../src/state/actions/history/addToHistory.ts | 2 +- .../src/state/actions/history/redo.ts | 2 +- .../src/state/actions/history/undo.ts | 2 +- .../state/actions/selection/updateBrush.ts | 4 +- .../state/actions/shapes/createArrowShape.ts | 8 +- .../state/actions/shapes/createPencilShape.ts | 2 +- .../src/state/actions/shapes/createShapes.ts | 2 +- .../src/state/constants.ts | 4 +- .../src/state/history.ts | 2 +- .../src/state/machine.ts | 2 +- examples/core-example/scripts/build.mjs | 2 +- examples/core-example/scripts/dev.mjs | 2 +- examples/core-example/src/app.tsx | 4 +- .../src/shapes/rect/RectComponent.tsx | 2 +- .../src/shapes/rect/RectIndicator.tsx | 2 +- examples/tldraw-example/scripts/build.mjs | 4 +- examples/tldraw-example/scripts/dev.mjs | 4 +- examples/tldraw-example/src/api-control.tsx | 3 +- examples/tldraw-example/src/api.tsx | 2 +- examples/tldraw-example/src/app.tsx | 36 ++-- examples/tldraw-example/src/basic.tsx | 2 +- examples/tldraw-example/src/changing-id.tsx | 2 +- examples/tldraw-example/src/dark-mode.tsx | 2 +- examples/tldraw-example/src/develop.tsx | 2 +- .../tldraw-example/src/export-to-server.tsx | 14 +- examples/tldraw-example/src/export.tsx | 2 +- examples/tldraw-example/src/file-system.tsx | 2 +- examples/tldraw-example/src/index.tsx | 3 +- examples/tldraw-example/src/loading-files.tsx | 2 +- .../src/multiplayer/liveblocks.config.ts | 2 +- .../src/multiplayer/multiplayer.tsx | 3 +- .../src/multiplayer/useMultiplayerState.ts | 11 +- examples/tldraw-example/src/persisted.tsx | 2 +- examples/tldraw-example/src/props-control.tsx | 4 +- examples/tldraw-example/src/readonly.tsx | 2 +- examples/tldraw-example/src/scroll.tsx | 2 +- guides/translation.md | 5 +- package.json | 7 +- packages/core/README.md | 6 +- .../core/src/TLShapeUtil/TLShapeUtil.spec.tsx | 8 +- packages/core/src/TLShapeUtil/TLShapeUtil.tsx | 6 +- packages/core/src/TLShapeUtil/index.ts | 2 +- .../core/src/components/Bounds/Bounds.tsx | 16 +- .../core/src/components/Bounds/BoundsBg.tsx | 4 +- .../src/components/Bounds/CornerHandle.tsx | 2 +- .../core/src/components/Bounds/EdgeHandle.tsx | 2 +- .../Bounds/__tests__/Bounds.test.tsx | 2 +- .../Bounds/__tests__/CloneButton.test.tsx | 2 +- .../Bounds/__tests__/CornerHandle.test.tsx | 4 +- .../Bounds/__tests__/EdgeHandle.test.tsx | 4 +- .../Bounds/__tests__/LinkHandle.test.tsx | 2 +- .../Bounds/__tests__/RotateHandle.test.tsx | 2 +- .../core/src/components/Brush/Brush.test.tsx | 2 +- packages/core/src/components/Brush/Brush.tsx | 2 +- .../core/src/components/Canvas/Canvas.tsx | 28 +-- .../src/components/Container/Container.tsx | 2 +- .../src/components/EraseLine/EraseLine.tsx | 2 +- .../src/components/Handles/Handle.test.tsx | 2 +- .../core/src/components/Handles/Handle.tsx | 10 +- .../src/components/Handles/Handles.test.tsx | 4 +- .../core/src/components/Handles/Handles.tsx | 2 +- packages/core/src/components/Page/Page.tsx | 6 +- .../src/components/Renderer/Renderer.test.tsx | 10 +- .../core/src/components/Renderer/Renderer.tsx | 26 +-- .../src/components/Shape/RenderedShape.tsx | 2 +- .../core/src/components/Shape/Shape.test.tsx | 6 +- packages/core/src/components/Shape/Shape.tsx | 6 +- .../core/src/components/Shape/ShapeNode.tsx | 2 +- .../ShapeIndicator/ShapeIndicator.test.tsx | 2 +- .../ShapeIndicator/ShapeIndicator.tsx | 2 +- .../UsersIndicators/UsersIndicators.tsx | 2 +- .../core/src/hooks/useBoundsHandleEvents.tsx | 2 +- packages/core/src/hooks/useCameraCss.tsx | 2 +- packages/core/src/hooks/useHandles.ts | 2 +- packages/core/src/hooks/useKeyEvents.ts | 2 +- packages/core/src/hooks/usePosition.ts | 2 +- packages/core/src/hooks/useResizeObserver.ts | 8 +- .../core/src/hooks/useSafariFocusOutFix.tsx | 2 +- packages/core/src/hooks/useSelection.tsx | 6 +- packages/core/src/hooks/useShapeEvents.tsx | 2 +- packages/core/src/hooks/useShapeTree.tsx | 10 +- packages/core/src/hooks/useTLContext.tsx | 4 +- packages/core/src/hooks/useZoomEvents.ts | 6 +- packages/core/src/inputs.ts | 2 +- packages/core/src/test/ContextWrapper.tsx | 8 +- packages/core/src/test/renderWithContext.tsx | 2 +- packages/core/src/test/renderWithSvg.tsx | 2 +- packages/core/src/types.ts | 1 - packages/core/src/utils/index.ts | 1 + packages/core/src/utils/utils.ts | 6 +- packages/curve/README.md | 6 +- packages/tldraw/src/Tldraw.spec.tsx | 2 +- packages/tldraw/src/Tldraw.tsx | 38 ++-- .../ContextMenu/ContextMenu.test.tsx | 2 +- .../components/ContextMenu/ContextMenu.tsx | 10 +- .../DropdownMenu/DMCheckboxItem.tsx | 2 +- .../Primitives/DropdownMenu/DMContent.tsx | 4 +- .../Primitives/DropdownMenu/DMItem.tsx | 2 +- .../Primitives/DropdownMenu/DMSubMenu.tsx | 4 +- .../Primitives/DropdownMenu/DMTriggerIcon.tsx | 2 +- .../src/components/Primitives/Kbd/Kbd.tsx | 2 +- .../Primitives/RowButton/RowButton.tsx | 4 +- .../Primitives/TextField/TextField.tsx | 2 +- .../Primitives/ToolButton/ToolButton.tsx | 2 +- .../components/ToolsPanel/ActionButton.tsx | 32 ++-- .../components/ToolsPanel/BackToContent.tsx | 6 +- .../components/ToolsPanel/DeleteButton.tsx | 8 +- .../src/components/ToolsPanel/HelpPanel.tsx | 20 +-- .../src/components/ToolsPanel/LockButton.tsx | 4 +- .../components/ToolsPanel/PrimaryTools.tsx | 14 +- .../src/components/ToolsPanel/ShapesMenu.tsx | 10 +- .../src/components/ToolsPanel/StatusBar.tsx | 6 +- .../components/ToolsPanel/ToolsPanel.test.tsx | 2 +- .../src/components/ToolsPanel/ToolsPanel.tsx | 10 +- .../ToolsPanel/keyboardShortcutDialog.tsx | 8 +- .../TopPanel/LanguageMenu/LanguageMenu.tsx | 4 +- .../src/components/TopPanel/Menu/Menu.tsx | 18 +- .../MultiplayerMenu/MultiplayerMenu.tsx | 16 +- .../components/TopPanel/PageMenu/PageMenu.tsx | 20 +-- .../PageOptionsDialog/PageOptionsDialog.tsx | 14 +- .../PreferencesMenu/PreferencesMenu.tsx | 4 +- .../TopPanel/StyleMenu/StyleMenu.tsx | 36 ++-- .../src/components/TopPanel/TopPanel.tsx | 10 +- .../components/TopPanel/ZoomMenu/ZoomMenu.tsx | 12 +- packages/tldraw/src/constants.ts | 3 +- packages/tldraw/src/hooks/index.ts | 10 +- .../tldraw/src/hooks/useKeyboardShortcuts.tsx | 2 +- packages/tldraw/src/hooks/useTranslation.ts | 2 +- packages/tldraw/src/state/IdbClipboard.ts | 2 +- .../src/state/StateManager/StateManager.ts | 10 +- packages/tldraw/src/state/TLDR.ts | 24 +-- packages/tldraw/src/state/TldrawApp.spec.ts | 2 +- packages/tldraw/src/state/TldrawApp.ts | 102 +++++------ .../commands/alignShapes/alignShapes.spec.ts | 2 +- .../state/commands/alignShapes/alignShapes.ts | 6 +- .../commands/changePage/changePage.spec.ts | 2 +- .../state/commands/changePage/changePage.ts | 2 +- .../commands/createPage/createPage.spec.ts | 2 +- .../state/commands/createPage/createPage.ts | 6 +- .../createShapes/createShapes.spec.ts | 2 +- .../commands/createShapes/createShapes.ts | 4 +- .../commands/deletePage/deletePage.spec.ts | 2 +- .../state/commands/deletePage/deletePage.ts | 2 +- .../deleteShapes/deleteShapes.spec.ts | 2 +- .../commands/deleteShapes/deleteShapes.ts | 4 +- .../distributeShapes/distributeShapes.spec.ts | 2 +- .../distributeShapes/distributeShapes.ts | 6 +- .../duplicatePage/duplicatePage.spec.ts | 2 +- .../commands/duplicatePage/duplicatePage.ts | 4 +- .../duplicateShapes/duplicateShapes.spec.ts | 2 +- .../duplicateShapes/duplicateShapes.ts | 4 +- .../commands/flipShapes/flipShapes.spec.ts | 2 +- .../state/commands/flipShapes/flipShapes.ts | 6 +- .../commands/groupShapes/groupShapes.spec.ts | 2 +- .../state/commands/groupShapes/groupShapes.ts | 6 +- .../insertContent/insertContent.spec.ts | 2 +- .../commands/insertContent/insertContent.ts | 4 +- .../src/state/commands/movePage/movePage.ts | 2 +- .../moveShapesToPage/moveShapesToPage.spec.ts | 2 +- .../moveShapesToPage/moveShapesToPage.ts | 8 +- .../commands/renamePage/renamePage.spec.ts | 2 +- .../state/commands/renamePage/renamePage.ts | 2 +- .../reorderShapes/reorderShapes.spec.ts | 2 +- .../commands/reorderShapes/reorderShapes.ts | 4 +- .../commands/resetBounds/resetBounds.spec.ts | 2 +- .../state/commands/resetBounds/resetBounds.ts | 4 +- .../rotateShapes/rotateShapes.spec.ts | 2 +- .../commands/rotateShapes/rotateShapes.ts | 4 +- .../commands/setShapesProps/setShapesProps.ts | 2 +- .../tldraw/src/state/commands/shared/index.ts | 2 + .../stretchShapes/stretchShapes.spec.ts | 4 +- .../commands/stretchShapes/stretchShapes.ts | 4 +- .../commands/styleShapes/styleShapes.spec.ts | 2 +- .../state/commands/styleShapes/styleShapes.ts | 6 +- .../toggleShapesDecoration.ts | 4 +- .../toggleShapesProp/toggleShapesProp.spec.ts | 2 +- .../toggleShapesProp/toggleShapesProp.ts | 2 +- .../translateShapes/translateShapes.spec.ts | 2 +- .../translateShapes/translateShapes.ts | 4 +- .../ungroupShapes/ungroupShapes.spec.ts | 2 +- .../commands/ungroupShapes/ungroupShapes.ts | 4 +- .../updateShapes/updateShapes.spec.ts | 2 +- .../commands/updateShapes/updateShapes.ts | 4 +- .../data/browser-fs-access/directory-open.js | 1 - .../state/data/browser-fs-access/file-open.js | 1 - .../state/data/browser-fs-access/file-save.js | 1 - packages/tldraw/src/state/data/filesystem.ts | 4 +- .../tldraw/src/state/data/migrate.spec.ts | 2 +- .../ArrowSession/ArrowSession.spec.ts | 2 +- .../sessions/ArrowSession/ArrowSession.ts | 22 +-- .../tldraw/src/state/sessions/BaseSession.ts | 2 +- .../BrushSession/BrushSession.spec.ts | 2 +- .../sessions/BrushSession/BrushSession.ts | 6 +- .../state/sessions/DrawSession/DrawSession.ts | 6 +- .../state/sessions/EditSession/EditSession.ts | 6 +- .../EraseSession/EraseSession.spec.ts | 2 +- .../sessions/EraseSession/EraseSession.ts | 12 +- .../sessions/GridSession/GridSession.spec.ts | 2 +- .../state/sessions/GridSession/GridSession.ts | 12 +- .../HandleSession/HandleSession.spec.ts | 2 +- .../sessions/HandleSession/HandleSession.ts | 6 +- .../RotateSession/RotateSession.spec.ts | 4 +- .../sessions/RotateSession/RotateSession.ts | 6 +- .../TransformSession/TransformSession.spec.ts | 2 +- .../TransformSession/TransformSession.ts | 10 +- .../TransformSingleSession.spec.ts | 4 +- .../TransformSingleSession.ts | 18 +- .../TranslateLabelSession.ts | 16 +- .../TranslateSession/TranslateSession.spec.ts | 2 +- .../TranslateSession/TranslateSession.ts | 32 ++-- packages/tldraw/src/state/sessions/index.ts | 6 +- .../src/state/shapes/ArrowUtil/ArrowUtil.tsx | 26 +-- .../state/shapes/ArrowUtil/arrowHelpers.ts | 4 +- .../src/state/shapes/DrawUtil/DrawUtil.tsx | 14 +- .../src/state/shapes/DrawUtil/drawHelpers.ts | 4 +- .../state/shapes/EllipseUtil/EllipseUtil.tsx | 21 ++- .../EllipseUtil/components/DashedEllipse.tsx | 4 +- .../shapes/EllipseUtil/ellipseHelpers.ts | 2 +- .../src/state/shapes/GroupUtil/GroupUtil.tsx | 11 +- .../src/state/shapes/ImageUtil/ImageUtil.tsx | 8 +- .../shapes/RectangleUtil/RectangleUtil.tsx | 20 +-- .../components/DashedRectangle.tsx | 4 +- .../shapes/RectangleUtil/rectangleHelpers.ts | 2 +- .../state/shapes/StickyUtil/StickyUtil.tsx | 23 ++- .../tldraw/src/state/shapes/TDShapeUtil.tsx | 10 +- .../src/state/shapes/TextUtil/TextUtil.tsx | 20 +-- .../shapes/TriangleUtil/TriangleUtil.tsx | 29 +-- .../components/DashedTriangle.tsx | 8 +- .../shapes/TriangleUtil/triangleHelpers.ts | 3 +- .../src/state/shapes/VideoUtil/VideoUtil.tsx | 8 +- packages/tldraw/src/state/shapes/index.ts | 14 +- .../src/state/shapes/shared/TextLabel.tsx | 2 +- .../state/shapes/shared/getTextSvgElement.ts | 6 +- .../tldraw/src/state/shapes/shared/index.ts | 13 +- .../src/state/shapes/shared/shape-styles.ts | 2 +- .../src/state/tools/ArrowTool/ArrowTool.ts | 4 +- packages/tldraw/src/state/tools/BaseTool.ts | 2 +- .../src/state/tools/DrawTool/DrawTool.ts | 4 +- .../state/tools/EllipseTool/EllipseTool.ts | 4 +- .../src/state/tools/EraseTool/EraseTool.ts | 6 +- .../src/state/tools/LineTool/LineTool.ts | 4 +- .../tools/RectangleTool/RectangleTool.ts | 4 +- .../state/tools/SelectTool/SelectTool.spec.ts | 2 +- .../src/state/tools/SelectTool/SelectTool.ts | 8 +- .../src/state/tools/StickyTool/StickyTool.ts | 4 +- .../src/state/tools/TextTool/TextTool.ts | 4 +- .../state/tools/TriangleTool/TriangleTool.ts | 4 +- packages/tldraw/src/state/tools/index.ts | 6 +- packages/tldraw/src/test/TldrawTestApp.tsx | 2 +- packages/tldraw/src/test/badDocument.spec.ts | 2 +- .../tldraw/src/test/documents/badDocument.ts | 2 +- packages/tldraw/src/test/mockDocument.tsx | 2 +- .../tldraw/src/test/renderWithContext.tsx | 8 +- .../src/test/renderWithIntlProvider.tsx | 2 +- packages/tldraw/src/types.ts | 24 +-- setupTests.ts | 1 + yarn.lock | 168 ++++++++++++++++-- 309 files changed, 1082 insertions(+), 910 deletions(-) create mode 100644 .prettierignore create mode 100644 packages/tldraw/src/state/commands/shared/index.ts diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..ed1de04f6 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,17 @@ +assets +**/assets +**/dist +**/extension/editor +**/out +**/public + +.DS_Store +.next +.tldr +.turbo +.vercel +.vsix + +*.lock +*.log +*.yaml diff --git a/.prettierrc b/.prettierrc index bf17a18ab..904e79276 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,5 +2,8 @@ "trailingComma": "es5", "singleQuote": true, "semi": false, - "printWidth": 100 + "printWidth": 100, + "importOrder": ["^[~]", "^[./]"], + "importOrderSortSpecifiers": true, + "importOrderParserPlugins": ["typescript", "jsx", "decorators-legacy"] } diff --git a/apps/electron/src/main/createMenu.ts b/apps/electron/src/main/createMenu.ts index c84b37203..64af2bad3 100644 --- a/apps/electron/src/main/createMenu.ts +++ b/apps/electron/src/main/createMenu.ts @@ -1,4 +1,4 @@ -import { shell, Menu, MenuItemConstructorOptions } from 'electron' +import { Menu, MenuItemConstructorOptions, shell } from 'electron' import type { Message } from 'src/types' export async function createMenu(send: (message: Message) => Promise) { diff --git a/apps/electron/src/main/createWindow.ts b/apps/electron/src/main/createWindow.ts index 44a771bfb..b19a24960 100644 --- a/apps/electron/src/main/createWindow.ts +++ b/apps/electron/src/main/createWindow.ts @@ -1,6 +1,6 @@ -import path from 'path' import { BrowserWindow } from 'electron' import { is } from 'electron-util' +import path from 'path' export async function createWindow() { let win: BrowserWindow | null = null diff --git a/apps/electron/src/main/main.ts b/apps/electron/src/main/main.ts index 265b6fbc8..f48d46e7b 100644 --- a/apps/electron/src/main/main.ts +++ b/apps/electron/src/main/main.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow } from 'electron' +import { BrowserWindow, app } from 'electron' import { is } from 'electron-util' import type { Message } from 'src/types' import { createMenu } from './createMenu' diff --git a/apps/electron/src/renderer/app.tsx b/apps/electron/src/renderer/app.tsx index f88cd6797..ad5e93ac2 100644 --- a/apps/electron/src/renderer/app.tsx +++ b/apps/electron/src/renderer/app.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Tldraw, TldrawApp } from '@tldraw/tldraw' +import * as React from 'react' import type { Message, TldrawBridgeApi } from 'src/types' declare const window: Window & { TldrawBridgeApi: TldrawBridgeApi } diff --git a/apps/new-tab-extension/src/App.tsx b/apps/new-tab-extension/src/App.tsx index d8222841a..d202df479 100644 --- a/apps/new-tab-extension/src/App.tsx +++ b/apps/new-tab-extension/src/App.tsx @@ -1,6 +1,6 @@ import { Tldraw, TldrawApp, TldrawProps, useFileSystem } from '@tldraw/tldraw' -import { useUploadAssets } from './hooks/useUploadAssets' import * as React from 'react' +import { useUploadAssets } from './hooks/useUploadAssets' declare const window: Window & { app: TldrawApp } diff --git a/apps/new-tab-extension/vite.config.ts b/apps/new-tab-extension/vite.config.ts index d6415f68c..3bb257f36 100644 --- a/apps/new-tab-extension/vite.config.ts +++ b/apps/new-tab-extension/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' +import { defineConfig } from 'vite' // https://vitejs.dev/config/ export default defineConfig({ diff --git a/apps/vscode/editor/scripts/build.mjs b/apps/vscode/editor/scripts/build.mjs index d08fb8296..6ca373ae9 100644 --- a/apps/vscode/editor/scripts/build.mjs +++ b/apps/vscode/editor/scripts/build.mjs @@ -1,6 +1,6 @@ /* eslint-disable */ -import fs from 'fs' import esbuild from 'esbuild' +import fs from 'fs' import { createRequire } from 'module' import path from 'path' diff --git a/apps/vscode/editor/scripts/dev.mjs b/apps/vscode/editor/scripts/dev.mjs index 56b7b23c2..392e5df0c 100644 --- a/apps/vscode/editor/scripts/dev.mjs +++ b/apps/vscode/editor/scripts/dev.mjs @@ -1,7 +1,7 @@ /* eslint-disable no-undef */ -import fs from 'fs' -import esbuildServe from 'esbuild-serve' import dotenv from 'dotenv' +import esbuildServe from 'esbuild-serve' +import fs from 'fs' import path from 'path' dotenv.config() diff --git a/apps/vscode/extension/src/TldrawWebviewManager.ts b/apps/vscode/extension/src/TldrawWebviewManager.ts index 8ad6cbdd8..bdc8bd463 100644 --- a/apps/vscode/extension/src/TldrawWebviewManager.ts +++ b/apps/vscode/extension/src/TldrawWebviewManager.ts @@ -1,6 +1,6 @@ -import * as vscode from 'vscode' import { TDFile } from '@tldraw/tldraw' -import { MessageFromWebview, MessageFromExtension } from './types' +import * as vscode from 'vscode' +import { MessageFromExtension, MessageFromWebview } from './types' /** * When a new editor is opened, an instance of this class will diff --git a/apps/www/components/Editor.tsx b/apps/www/components/Editor.tsx index 43d493d4d..26ffe5790 100644 --- a/apps/www/components/Editor.tsx +++ b/apps/www/components/Editor.tsx @@ -1,7 +1,7 @@ import { Tldraw, TldrawApp, TldrawProps, useFileSystem } from '@tldraw/tldraw' -import { useUploadAssets } from 'hooks/useUploadAssets' import * as React from 'react' -import * as gtag from 'utils/gtag' +import { useUploadAssets } from '~hooks/useUploadAssets' +import * as gtag from '~utils/gtag' declare const window: Window & { app: TldrawApp } diff --git a/apps/www/components/IFrameWarning.tsx b/apps/www/components/IFrameWarning.tsx index d8037fb1d..a2e2d0f5b 100644 --- a/apps/www/components/IFrameWarning.tsx +++ b/apps/www/components/IFrameWarning.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { styled } from 'styles' +import { styled } from '~styles' export default function IFrameWarning({ url = 'https://tldraw.com' }: { url?: string }) { const [copied, setCopied] = React.useState(false) diff --git a/apps/www/components/MultiplayerEditor.tsx b/apps/www/components/MultiplayerEditor.tsx index 9e60d3cbb..fe447386a 100644 --- a/apps/www/components/MultiplayerEditor.tsx +++ b/apps/www/components/MultiplayerEditor.tsx @@ -1,10 +1,10 @@ -import * as React from 'react' -import { RoomProvider } from '../utils/liveblocks' import { Tldraw, useFileSystem } from '@tldraw/tldraw' -import { useMultiplayerAssets } from 'hooks/useMultiplayerAssets' -import { useMultiplayerState } from 'hooks/useMultiplayerState' -import { useUploadAssets } from 'hooks/useUploadAssets' -import { styled } from 'styles' +import * as React from 'react' +import { useMultiplayerAssets } from '~hooks/useMultiplayerAssets' +import { useMultiplayerState } from '~hooks/useMultiplayerState' +import { useUploadAssets } from '~hooks/useUploadAssets' +import { styled } from '~styles' +import { RoomProvider } from '~utils/liveblocks' interface Props { roomId: string diff --git a/apps/www/components/ReadOnlyMultiplayerEditor.tsx b/apps/www/components/ReadOnlyMultiplayerEditor.tsx index 9fae93860..86f08b67b 100644 --- a/apps/www/components/ReadOnlyMultiplayerEditor.tsx +++ b/apps/www/components/ReadOnlyMultiplayerEditor.tsx @@ -1,8 +1,8 @@ -import * as React from 'react' -import { RoomProvider } from '../utils/liveblocks' import { Tldraw, useFileSystem } from '@tldraw/tldraw' -import { styled } from 'styles' -import { useReadOnlyMultiplayerState } from 'hooks/useReadOnlyMultiplayerState' +import * as React from 'react' +import { useReadOnlyMultiplayerState } from '~hooks/useReadOnlyMultiplayerState' +import { styled } from '~styles' +import { RoomProvider } from '~utils/liveblocks' interface Props { roomId: string diff --git a/apps/www/hooks/useMultiplayerState.ts b/apps/www/hooks/useMultiplayerState.ts index a5f07acc8..ec86d000b 100644 --- a/apps/www/hooks/useMultiplayerState.ts +++ b/apps/www/hooks/useMultiplayerState.ts @@ -1,10 +1,8 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ -import React, { useState, useRef, useCallback } from 'react' -import type { TldrawApp, TDUser, TDShape, TDBinding, TDAsset } from '@tldraw/tldraw' -import { Storage, useRedo, useUndo, useRoom, useUpdateMyPresence } from '../utils/liveblocks' -import { useHotkeys } from 'react-hotkeys-hook' import { LiveMap } from '@liveblocks/client' +import type { TDAsset, TDBinding, TDShape, TDUser, TldrawApp } from '@tldraw/tldraw' +import React, { useCallback, useRef, useState } from 'react' +import { useHotkeys } from 'react-hotkeys-hook' +import { Storage, useRedo, useRoom, useUndo, useUpdateMyPresence } from '~utils/liveblocks' declare const window: Window & { app: TldrawApp } diff --git a/apps/www/hooks/useReadOnlyMultiplayerState.ts b/apps/www/hooks/useReadOnlyMultiplayerState.ts index 328e75295..8e72ac401 100644 --- a/apps/www/hooks/useReadOnlyMultiplayerState.ts +++ b/apps/www/hooks/useReadOnlyMultiplayerState.ts @@ -1,10 +1,8 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ -import React, { useState, useRef, useCallback } from 'react' -import type { TldrawApp, TDUser, TDShape, TDBinding, TDAsset } from '@tldraw/tldraw' -import { Storage, useRedo, useUndo, useRoom, useUpdateMyPresence } from '../utils/liveblocks' -import { useHotkeys } from 'react-hotkeys-hook' import { LiveMap } from '@liveblocks/client' +import type { TDAsset, TDBinding, TDShape, TDUser, TldrawApp } from '@tldraw/tldraw' +import React, { useCallback, useRef, useState } from 'react' +import { useHotkeys } from 'react-hotkeys-hook' +import { Storage, useRedo, useRoom, useUndo, useUpdateMyPresence } from '~utils/liveblocks' declare const window: Window & { app: TldrawApp } diff --git a/apps/www/pages/_app.tsx b/apps/www/pages/_app.tsx index 4f131827f..da74882bf 100644 --- a/apps/www/pages/_app.tsx +++ b/apps/www/pages/_app.tsx @@ -1,8 +1,8 @@ -import '../styles/globals.css' import Head from 'next/head' -import useGtag from 'utils/useGtag' -import { init } from 'utils/sentry' import type React from 'react' +import '~styles/globals.css' +import { init } from '~utils/sentry' +import useGtag from '~utils/useGtag' init() diff --git a/apps/www/pages/_document.tsx b/apps/www/pages/_document.tsx index e5e1cfdf4..e66b09e30 100644 --- a/apps/www/pages/_document.tsx +++ b/apps/www/pages/_document.tsx @@ -1,6 +1,6 @@ -import NextDocument, { Html, Head, Main, NextScript, DocumentContext } from 'next/document' -import { getCssText } from 'styles' -import { GA_TRACKING_ID } from 'utils/gtag' +import NextDocument, { DocumentContext, Head, Html, Main, NextScript } from 'next/document' +import { getCssText } from '~styles' +import { GA_TRACKING_ID } from '~utils/gtag' class MyDocument extends NextDocument { static async getInitialProps(ctx: DocumentContext): Promise { diff --git a/apps/www/pages/api/create.ts b/apps/www/pages/api/create.ts index 5059035c0..981031828 100644 --- a/apps/www/pages/api/create.ts +++ b/apps/www/pages/api/create.ts @@ -1,6 +1,6 @@ -import { NextApiRequest, NextApiResponse } from 'next' -import { TDDocument } from '@tldraw/tldraw' import { Utils } from '@tldraw/core' +import { TDDocument } from '@tldraw/tldraw' +import { NextApiRequest, NextApiResponse } from 'next' type RequestBody = { pageId: string diff --git a/apps/www/pages/index.tsx b/apps/www/pages/index.tsx index 519841a93..0e57c2b0e 100644 --- a/apps/www/pages/index.tsx +++ b/apps/www/pages/index.tsx @@ -3,7 +3,7 @@ import Head from 'next/head' import { useRouter } from 'next/router' import { useMemo } from 'react' -const Editor = dynamic(() => import('components/Editor'), { ssr: false }) as any +const Editor = dynamic(() => import('~components/Editor'), { ssr: false }) as any const Home = () => { const { query } = useRouter() diff --git a/apps/www/pages/r/[id].tsx b/apps/www/pages/r/[id].tsx index fbe936c74..a7c94ec66 100644 --- a/apps/www/pages/r/[id].tsx +++ b/apps/www/pages/r/[id].tsx @@ -1,12 +1,12 @@ -import * as React from 'react' import type { GetServerSideProps } from 'next' import dynamic from 'next/dynamic' +import * as React from 'react' -const IFrameWarning = dynamic(() => import('components/IFrameWarning'), { +const IFrameWarning = dynamic(() => import('~components/IFrameWarning'), { ssr: false, }) as any -const MultiplayerEditor = dynamic(() => import('components/MultiplayerEditor'), { +const MultiplayerEditor = dynamic(() => import('~components/MultiplayerEditor'), { ssr: false, }) as any diff --git a/apps/www/pages/r/index.tsx b/apps/www/pages/r/index.tsx index 4818cecba..166821816 100644 --- a/apps/www/pages/r/index.tsx +++ b/apps/www/pages/r/index.tsx @@ -1,6 +1,6 @@ -import * as React from 'react' import type { GetServerSideProps } from 'next' import Head from 'next/head' +import * as React from 'react' export default function RandomRoomPage() { return ( diff --git a/apps/www/pages/v/[id].tsx b/apps/www/pages/v/[id].tsx index d369ee3fc..532d3fc0b 100644 --- a/apps/www/pages/v/[id].tsx +++ b/apps/www/pages/v/[id].tsx @@ -1,13 +1,13 @@ -import * as React from 'react' +import { Utils } from '@tldraw/core' import type { GetServerSideProps } from 'next' import dynamic from 'next/dynamic' -import { Utils } from '@tldraw/core' +import * as React from 'react' -const IFrameWarning = dynamic(() => import('components/IFrameWarning'), { +const IFrameWarning = dynamic(() => import('~components/IFrameWarning'), { ssr: false, }) as any -const ReadOnlyMultiplayerEditor = dynamic(() => import('components/ReadOnlyMultiplayerEditor'), { +const ReadOnlyMultiplayerEditor = dynamic(() => import('~components/ReadOnlyMultiplayerEditor'), { ssr: false, }) as any diff --git a/apps/www/tsconfig.json b/apps/www/tsconfig.json index 624f1d3c0..cd5703026 100644 --- a/apps/www/tsconfig.json +++ b/apps/www/tsconfig.json @@ -19,7 +19,7 @@ "rootDir": ".", "baseUrl": ".", "paths": { - "*": ["./*"], + "~*": ["./*"], "@tldraw/core": ["../../packages/core"], "@tldraw/tldraw": ["../../packages/tldraw"] } diff --git a/apps/www/utils/liveblocks.ts b/apps/www/utils/liveblocks.ts index 7bbd5d077..d3a864654 100644 --- a/apps/www/utils/liveblocks.ts +++ b/apps/www/utils/liveblocks.ts @@ -1,7 +1,7 @@ import { createClient } from '@liveblocks/client' import type { EnsureJson, LiveMap, LiveObject } from '@liveblocks/client' import { createRoomContext } from '@liveblocks/react' -import type { TDUser, TDShape, TDBinding, TDDocument, TDAsset } from '@tldraw/tldraw' +import type { TDAsset, TDBinding, TDDocument, TDShape, TDUser } from '@tldraw/tldraw' const client = createClient({ publicApiKey: process.env.NEXT_PUBLIC_LIVEBLOCKS_PUBLIC_API_KEY || '', diff --git a/apps/www/utils/sentry.ts b/apps/www/utils/sentry.ts index c5b83f009..5ccb9c539 100644 --- a/apps/www/utils/sentry.ts +++ b/apps/www/utils/sentry.ts @@ -1,5 +1,5 @@ -import * as Sentry from '@sentry/node' import { RewriteFrames } from '@sentry/integrations' +import * as Sentry from '@sentry/node' export function init(): void { if (!process.env.NEXT_PUBLIC_SENTRY_DSN) return diff --git a/apps/www/utils/useGtag.ts b/apps/www/utils/useGtag.ts index a31f220ab..9af16a1a8 100644 --- a/apps/www/utils/useGtag.ts +++ b/apps/www/utils/useGtag.ts @@ -1,7 +1,6 @@ -/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import router from 'next/router' import { useEffect } from 'react' -import * as gtag from 'utils/gtag' +import * as gtag from './gtag' function handleRouteChange(url: URL) { gtag.pageview(url) diff --git a/examples/core-example-advanced/scripts/build.mjs b/examples/core-example-advanced/scripts/build.mjs index 3820d35ce..85ad3dabe 100644 --- a/examples/core-example-advanced/scripts/build.mjs +++ b/examples/core-example-advanced/scripts/build.mjs @@ -1,6 +1,6 @@ /* eslint-disable */ -import fs from 'fs' import esbuild from 'esbuild' +import fs from 'fs' import { createRequire } from 'module' const pkg = createRequire(import.meta.url)('../package.json') diff --git a/examples/core-example-advanced/scripts/dev.mjs b/examples/core-example-advanced/scripts/dev.mjs index 1b4c2d71b..ce335b075 100644 --- a/examples/core-example-advanced/scripts/dev.mjs +++ b/examples/core-example-advanced/scripts/dev.mjs @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ -import fs from 'fs' import esbuildServe from 'esbuild-serve' +import fs from 'fs' const { log: jslog } = console diff --git a/examples/core-example-advanced/src/app.tsx b/examples/core-example-advanced/src/app.tsx index eae82bfdd..7d43e4af4 100644 --- a/examples/core-example-advanced/src/app.tsx +++ b/examples/core-example-advanced/src/app.tsx @@ -1,4 +1,4 @@ -import * as React from 'react' +import { useStateDesigner } from '@state-designer/react' import { Renderer, TLBounds, @@ -7,14 +7,14 @@ import { TLPointerEventHandler, TLWheelEventHandler, } from '@tldraw/core' -import { useStateDesigner } from '@state-designer/react' +import * as React from 'react' +import { Api } from 'state/api' +import styled from 'stitches.config' +import { TitleLinks } from './components/TitleLinks' +import { Toolbar } from './components/Toolbar' import { shapeUtils } from './shapes' import { machine } from './state/machine' -import { Toolbar } from './components/Toolbar' -import { TitleLinks } from './components/TitleLinks' import './styles.css' -import styled from 'stitches.config' -import { Api } from 'state/api' declare const window: Window & { api: Api } diff --git a/examples/core-example-advanced/src/shapes/arrow/ArrowComponent.tsx b/examples/core-example-advanced/src/shapes/arrow/ArrowComponent.tsx index 209f352ec..7d5116385 100644 --- a/examples/core-example-advanced/src/shapes/arrow/ArrowComponent.tsx +++ b/examples/core-example-advanced/src/shapes/arrow/ArrowComponent.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' -import { TLShapeUtil, SVGContainer } from '@tldraw/core' -import type { ArrowShape } from './ArrowShape' +import { SVGContainer, TLShapeUtil } from '@tldraw/core' import Vec from '@tldraw/vec' +import * as React from 'react' +import type { ArrowShape } from './ArrowShape' export const ArrowComponent = TLShapeUtil.Component( ({ shape, events, isGhost, meta }, ref) => { diff --git a/examples/core-example-advanced/src/shapes/arrow/ArrowIndicator.tsx b/examples/core-example-advanced/src/shapes/arrow/ArrowIndicator.tsx index 5e8110030..a6b2edafb 100644 --- a/examples/core-example-advanced/src/shapes/arrow/ArrowIndicator.tsx +++ b/examples/core-example-advanced/src/shapes/arrow/ArrowIndicator.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' import { TLShapeUtil } from '@tldraw/core' -import type { ArrowShape } from './ArrowShape' import Vec from '@tldraw/vec' +import * as React from 'react' +import type { ArrowShape } from './ArrowShape' export const ArrowIndicator = TLShapeUtil.Indicator(({ shape }) => { const { start, end } = shape.handles diff --git a/examples/core-example-advanced/src/shapes/arrow/ArrowUtil.ts b/examples/core-example-advanced/src/shapes/arrow/ArrowUtil.ts index 278bd52d4..3fce2d6a7 100644 --- a/examples/core-example-advanced/src/shapes/arrow/ArrowUtil.ts +++ b/examples/core-example-advanced/src/shapes/arrow/ArrowUtil.ts @@ -1,4 +1,4 @@ -import { Utils, TLBounds } from '@tldraw/core' +import { TLBounds, Utils } from '@tldraw/core' import { intersectBoundsLineSegment, intersectLineSegmentLineSegment } from '@tldraw/intersect' import Vec from '@tldraw/vec' import { nanoid } from 'nanoid' diff --git a/examples/core-example-advanced/src/shapes/box/BoxComponent.tsx b/examples/core-example-advanced/src/shapes/box/BoxComponent.tsx index 5aec2c9c7..2ec611b32 100644 --- a/examples/core-example-advanced/src/shapes/box/BoxComponent.tsx +++ b/examples/core-example-advanced/src/shapes/box/BoxComponent.tsx @@ -1,5 +1,5 @@ +import { SVGContainer, TLShapeUtil } from '@tldraw/core' import * as React from 'react' -import { TLShapeUtil, SVGContainer } from '@tldraw/core' import type { BoxShape } from './BoxShape' export const BoxComponent = TLShapeUtil.Component( diff --git a/examples/core-example-advanced/src/shapes/box/BoxIndicator.tsx b/examples/core-example-advanced/src/shapes/box/BoxIndicator.tsx index 831d395b1..9b7aaff8a 100644 --- a/examples/core-example-advanced/src/shapes/box/BoxIndicator.tsx +++ b/examples/core-example-advanced/src/shapes/box/BoxIndicator.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { TLShapeUtil } from '@tldraw/core' +import * as React from 'react' import type { BoxShape } from './BoxShape' export const BoxIndicator = TLShapeUtil.Indicator(({ shape }) => { diff --git a/examples/core-example-advanced/src/shapes/box/BoxUtil.ts b/examples/core-example-advanced/src/shapes/box/BoxUtil.ts index b8e12ca96..2d445bdc3 100644 --- a/examples/core-example-advanced/src/shapes/box/BoxUtil.ts +++ b/examples/core-example-advanced/src/shapes/box/BoxUtil.ts @@ -1,4 +1,4 @@ -import { Utils, TLBounds } from '@tldraw/core' +import { TLBounds, Utils } from '@tldraw/core' import { intersectLineSegmentBounds } from '@tldraw/intersect' import { nanoid } from 'nanoid' import { CustomShapeUtil } from 'shapes/CustomShapeUtil' diff --git a/examples/core-example-advanced/src/shapes/pencil/PencilComponent.tsx b/examples/core-example-advanced/src/shapes/pencil/PencilComponent.tsx index 2728412d7..837c925bd 100644 --- a/examples/core-example-advanced/src/shapes/pencil/PencilComponent.tsx +++ b/examples/core-example-advanced/src/shapes/pencil/PencilComponent.tsx @@ -1,5 +1,5 @@ +import { SVGContainer, TLShapeUtil } from '@tldraw/core' import * as React from 'react' -import { TLShapeUtil, SVGContainer } from '@tldraw/core' import type { PencilShape } from './PencilShape' import { getComponentSvgPath } from './pencil-helpers' diff --git a/examples/core-example-advanced/src/shapes/pencil/PencilUtil.ts b/examples/core-example-advanced/src/shapes/pencil/PencilUtil.ts index 7ee6673a9..cd15b66bd 100644 --- a/examples/core-example-advanced/src/shapes/pencil/PencilUtil.ts +++ b/examples/core-example-advanced/src/shapes/pencil/PencilUtil.ts @@ -1,15 +1,15 @@ -import { Utils, TLBounds } from '@tldraw/core' +import { TLBounds, Utils } from '@tldraw/core' import { intersectBoundsBounds, intersectBoundsPolyline, intersectLineSegmentPolyline, } from '@tldraw/intersect' +import Vec from '@tldraw/vec' import { nanoid } from 'nanoid' import { CustomShapeUtil } from 'shapes/CustomShapeUtil' import { PencilComponent } from './PencilComponent' -import { PencilIndicator } from './PenclIndicator' import type { PencilShape } from './PencilShape' -import Vec from '@tldraw/vec' +import { PencilIndicator } from './PenclIndicator' type T = PencilShape type E = SVGSVGElement diff --git a/examples/core-example-advanced/src/shapes/pencil/PenclIndicator.tsx b/examples/core-example-advanced/src/shapes/pencil/PenclIndicator.tsx index 079a705b8..0c952f9aa 100644 --- a/examples/core-example-advanced/src/shapes/pencil/PenclIndicator.tsx +++ b/examples/core-example-advanced/src/shapes/pencil/PenclIndicator.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { TLShapeUtil } from '@tldraw/core' +import * as React from 'react' import type { PencilShape } from './PencilShape' import { getIndicatorSvgPath } from './pencil-helpers' diff --git a/examples/core-example-advanced/src/state/actions/bindings/getBoundHandlePoint.ts b/examples/core-example-advanced/src/state/actions/bindings/getBoundHandlePoint.ts index 95c477004..72174e519 100644 --- a/examples/core-example-advanced/src/state/actions/bindings/getBoundHandlePoint.ts +++ b/examples/core-example-advanced/src/state/actions/bindings/getBoundHandlePoint.ts @@ -1,7 +1,7 @@ import { Utils } from '@tldraw/core' import { intersectLineSegmentBounds } from '@tldraw/intersect' import Vec from '@tldraw/vec' -import { getShapeUtils, Shape } from 'shapes' +import { Shape, getShapeUtils } from 'shapes' import type { ArrowShape } from 'shapes/arrow' import { AppData, BINDING_PADDING } from 'state/constants' diff --git a/examples/core-example-advanced/src/state/actions/camera/panCamera.ts b/examples/core-example-advanced/src/state/actions/camera/panCamera.ts index df41eae00..4d09184db 100644 --- a/examples/core-example-advanced/src/state/actions/camera/panCamera.ts +++ b/examples/core-example-advanced/src/state/actions/camera/panCamera.ts @@ -1,6 +1,6 @@ -import type { Action } from 'state/constants' import type { TLPointerInfo } from '@tldraw/core' import Vec from '@tldraw/vec' +import type { Action } from 'state/constants' export const panCamera: Action = (data, payload: TLPointerInfo) => { const { point, zoom } = data.pageState.camera diff --git a/examples/core-example-advanced/src/state/actions/camera/pinchCamera.ts b/examples/core-example-advanced/src/state/actions/camera/pinchCamera.ts index 7abcd1817..31b3225c4 100644 --- a/examples/core-example-advanced/src/state/actions/camera/pinchCamera.ts +++ b/examples/core-example-advanced/src/state/actions/camera/pinchCamera.ts @@ -1,6 +1,6 @@ -import type { Action } from 'state/constants' import type { TLPointerInfo } from '@tldraw/core' import Vec from '@tldraw/vec' +import type { Action } from 'state/constants' export const pinchCamera: Action = (data, payload: TLPointerInfo) => { const { camera } = data.pageState diff --git a/examples/core-example-advanced/src/state/actions/camera/zoomIn.ts b/examples/core-example-advanced/src/state/actions/camera/zoomIn.ts index 05b3d9c98..af3868efe 100644 --- a/examples/core-example-advanced/src/state/actions/camera/zoomIn.ts +++ b/examples/core-example-advanced/src/state/actions/camera/zoomIn.ts @@ -1,5 +1,5 @@ -import type { Action } from 'state/constants' import Vec from '@tldraw/vec' +import type { Action } from 'state/constants' import { mutables } from 'state/mutables' export const zoomIn: Action = (data) => { diff --git a/examples/core-example-advanced/src/state/actions/camera/zoomOut.ts b/examples/core-example-advanced/src/state/actions/camera/zoomOut.ts index e0d8d6732..57b2f9c56 100644 --- a/examples/core-example-advanced/src/state/actions/camera/zoomOut.ts +++ b/examples/core-example-advanced/src/state/actions/camera/zoomOut.ts @@ -1,5 +1,5 @@ -import type { Action } from 'state/constants' import Vec from '@tldraw/vec' +import type { Action } from 'state/constants' import { mutables } from 'state/mutables' export const zoomOut: Action = (data) => { diff --git a/examples/core-example-advanced/src/state/actions/camera/zoomToFit.ts b/examples/core-example-advanced/src/state/actions/camera/zoomToFit.ts index f725b00f3..3c872efa1 100644 --- a/examples/core-example-advanced/src/state/actions/camera/zoomToFit.ts +++ b/examples/core-example-advanced/src/state/actions/camera/zoomToFit.ts @@ -1,8 +1,8 @@ -import { Action, FIT_TO_SCREEN_PADDING } from 'state/constants' import { Utils } from '@tldraw/core' import Vec from '@tldraw/vec' -import { mutables } from 'state/mutables' import { getShapeUtils } from 'shapes' +import { Action, FIT_TO_SCREEN_PADDING } from 'state/constants' +import { mutables } from 'state/mutables' export const zoomToFit: Action = (data) => { const { camera } = data.pageState diff --git a/examples/core-example-advanced/src/state/actions/camera/zoomToSelection.ts b/examples/core-example-advanced/src/state/actions/camera/zoomToSelection.ts index e4c53052a..6d78ac6c9 100644 --- a/examples/core-example-advanced/src/state/actions/camera/zoomToSelection.ts +++ b/examples/core-example-advanced/src/state/actions/camera/zoomToSelection.ts @@ -1,8 +1,8 @@ -import { Action, FIT_TO_SCREEN_PADDING } from 'state/constants' import { Utils } from '@tldraw/core' -import { mutables } from 'state/mutables' -import { getShapeUtils } from 'shapes' import Vec from '@tldraw/vec' +import { getShapeUtils } from 'shapes' +import { Action, FIT_TO_SCREEN_PADDING } from 'state/constants' +import { mutables } from 'state/mutables' export const zoomToSelection: Action = (data) => { const { camera, selectedIds } = data.pageState diff --git a/examples/core-example-advanced/src/state/actions/data/restoreSavedDocument.ts b/examples/core-example-advanced/src/state/actions/data/restoreSavedDocument.ts index 8a6624a7e..a55a669ec 100644 --- a/examples/core-example-advanced/src/state/actions/data/restoreSavedDocument.ts +++ b/examples/core-example-advanced/src/state/actions/data/restoreSavedDocument.ts @@ -1,5 +1,5 @@ import type { Action } from 'state/constants' -import { mutables } from '../../mutables' +import { mutables } from 'state/mutables' export const restoreSavedDocument: Action = (data) => { const snapshot = mutables.history.restore() diff --git a/examples/core-example-advanced/src/state/actions/erase/eraseShapes.ts b/examples/core-example-advanced/src/state/actions/erase/eraseShapes.ts index 8aec3e8da..5b11a53f9 100644 --- a/examples/core-example-advanced/src/state/actions/erase/eraseShapes.ts +++ b/examples/core-example-advanced/src/state/actions/erase/eraseShapes.ts @@ -1,6 +1,6 @@ import type { TLPointerInfo } from '@tldraw/core' -import type { Action } from 'state/constants' import { getShapeUtils } from 'shapes' +import type { Action } from 'state/constants' import { mutables } from 'state/mutables' export const eraseShapes: Action = (data, payload: TLPointerInfo) => { diff --git a/examples/core-example-advanced/src/state/actions/erase/eraseShapesAtPoint.ts b/examples/core-example-advanced/src/state/actions/erase/eraseShapesAtPoint.ts index 91f9f6e58..46a44b0b3 100644 --- a/examples/core-example-advanced/src/state/actions/erase/eraseShapesAtPoint.ts +++ b/examples/core-example-advanced/src/state/actions/erase/eraseShapesAtPoint.ts @@ -1,5 +1,5 @@ -import type { Action } from 'state/constants' import { getShapeUtils } from 'shapes' +import type { Action } from 'state/constants' import { mutables } from 'state/mutables' export const eraseShapesAtPoint: Action = (data) => { diff --git a/examples/core-example-advanced/src/state/actions/handles/getBoundTarget.ts b/examples/core-example-advanced/src/state/actions/handles/getBoundTarget.ts index 9b3c2b7a2..7991ea5a2 100644 --- a/examples/core-example-advanced/src/state/actions/handles/getBoundTarget.ts +++ b/examples/core-example-advanced/src/state/actions/handles/getBoundTarget.ts @@ -1,6 +1,6 @@ import { Utils } from '@tldraw/core' import Vec from '@tldraw/vec' -import { getShapeUtils, Shape } from 'shapes' +import { Shape, getShapeUtils } from 'shapes' import type { ArrowShape } from 'shapes/arrow' import type { AppData } from 'state/constants' diff --git a/examples/core-example-advanced/src/state/actions/handles/translateHandle.ts b/examples/core-example-advanced/src/state/actions/handles/translateHandle.ts index 49420d7d4..c76c60397 100644 --- a/examples/core-example-advanced/src/state/actions/handles/translateHandle.ts +++ b/examples/core-example-advanced/src/state/actions/handles/translateHandle.ts @@ -1,10 +1,10 @@ -import type { Action, CustomBinding } from 'state/constants' -import { getShapeUtils, Shape } from 'shapes' -import { mutables } from 'state/mutables' -import { nanoid } from 'nanoid' import { TLPointerInfo, Utils } from '@tldraw/core' -import type { ArrowShape } from 'shapes/arrow' import Vec from '@tldraw/vec' +import { nanoid } from 'nanoid' +import { Shape, getShapeUtils } from 'shapes' +import type { ArrowShape } from 'shapes/arrow' +import type { Action, CustomBinding } from 'state/constants' +import { mutables } from 'state/mutables' export const translateHandle: Action = (data, payload: TLPointerInfo) => { const { initialPoint, snapshot, pointedHandleId } = mutables diff --git a/examples/core-example-advanced/src/state/actions/history/addToHistory.ts b/examples/core-example-advanced/src/state/actions/history/addToHistory.ts index e15b78430..cf140f82c 100644 --- a/examples/core-example-advanced/src/state/actions/history/addToHistory.ts +++ b/examples/core-example-advanced/src/state/actions/history/addToHistory.ts @@ -1,5 +1,5 @@ import type { Action } from 'state/constants' -import { mutables } from '../../mutables' +import { mutables } from 'state/mutables' export const addToHistory: Action = (data) => { mutables.history.push(data) diff --git a/examples/core-example-advanced/src/state/actions/history/redo.ts b/examples/core-example-advanced/src/state/actions/history/redo.ts index 4da590c54..bd3e85b09 100644 --- a/examples/core-example-advanced/src/state/actions/history/redo.ts +++ b/examples/core-example-advanced/src/state/actions/history/redo.ts @@ -1,5 +1,5 @@ import type { Action } from 'state/constants' -import { mutables } from '../../mutables' +import { mutables } from 'state/mutables' export const redo: Action = (data) => { const snapshot = mutables.history.redo() diff --git a/examples/core-example-advanced/src/state/actions/history/undo.ts b/examples/core-example-advanced/src/state/actions/history/undo.ts index 936042208..37f4e2923 100644 --- a/examples/core-example-advanced/src/state/actions/history/undo.ts +++ b/examples/core-example-advanced/src/state/actions/history/undo.ts @@ -1,5 +1,5 @@ import type { Action } from 'state/constants' -import { mutables } from '../../mutables' +import { mutables } from 'state/mutables' export const undo: Action = (data) => { const snapshot = mutables.history.undo() diff --git a/examples/core-example-advanced/src/state/actions/selection/updateBrush.ts b/examples/core-example-advanced/src/state/actions/selection/updateBrush.ts index 47ad79a36..03dddc62d 100644 --- a/examples/core-example-advanced/src/state/actions/selection/updateBrush.ts +++ b/examples/core-example-advanced/src/state/actions/selection/updateBrush.ts @@ -1,7 +1,7 @@ -import type { Action } from 'state/constants' import { TLPointerInfo, Utils } from '@tldraw/core' -import { mutables } from '../../mutables' import { getShapeUtils } from 'shapes' +import type { Action } from 'state/constants' +import { mutables } from 'state/mutables' export const updateBrush: Action = (data, payload: TLPointerInfo) => { const { initialPoint, snapshot } = mutables diff --git a/examples/core-example-advanced/src/state/actions/shapes/createArrowShape.ts b/examples/core-example-advanced/src/state/actions/shapes/createArrowShape.ts index b4c26b57d..86b634423 100644 --- a/examples/core-example-advanced/src/state/actions/shapes/createArrowShape.ts +++ b/examples/core-example-advanced/src/state/actions/shapes/createArrowShape.ts @@ -1,9 +1,9 @@ -import { nanoid } from 'nanoid' -import Vec from '@tldraw/vec' import { TLPointerInfo, Utils } from '@tldraw/core' -import { getShapeUtils, Shape, shapeUtils } from 'shapes' -import { mutables } from 'state/mutables' +import Vec from '@tldraw/vec' +import { nanoid } from 'nanoid' +import { Shape, getShapeUtils, shapeUtils } from 'shapes' import type { Action, CustomBinding } from 'state/constants' +import { mutables } from 'state/mutables' export const createArrowShape: Action = (data, payload: TLPointerInfo) => { const shape = shapeUtils.arrow.getShape({ diff --git a/examples/core-example-advanced/src/state/actions/shapes/createPencilShape.ts b/examples/core-example-advanced/src/state/actions/shapes/createPencilShape.ts index 0b022816c..e508984ab 100644 --- a/examples/core-example-advanced/src/state/actions/shapes/createPencilShape.ts +++ b/examples/core-example-advanced/src/state/actions/shapes/createPencilShape.ts @@ -1,6 +1,6 @@ import type { TLPointerInfo } from '@tldraw/core' -import type { Action } from 'state/constants' import { shapeUtils } from 'shapes' +import type { Action } from 'state/constants' import { mutables } from 'state/mutables' export const createPencilShape: Action = (data, payload: TLPointerInfo) => { diff --git a/examples/core-example-advanced/src/state/actions/shapes/createShapes.ts b/examples/core-example-advanced/src/state/actions/shapes/createShapes.ts index 21fa738ef..a4709abfd 100644 --- a/examples/core-example-advanced/src/state/actions/shapes/createShapes.ts +++ b/examples/core-example-advanced/src/state/actions/shapes/createShapes.ts @@ -1,5 +1,5 @@ import { nanoid } from 'nanoid' -import { getShapeUtils, Shape } from 'shapes' +import { Shape, getShapeUtils } from 'shapes' import type { Action } from 'state/constants' export const createShapes: Action = ( diff --git a/examples/core-example-advanced/src/state/constants.ts b/examples/core-example-advanced/src/state/constants.ts index 896bbdd85..17e965578 100644 --- a/examples/core-example-advanced/src/state/constants.ts +++ b/examples/core-example-advanced/src/state/constants.ts @@ -1,6 +1,6 @@ -import type { TLBinding, TLPage, TLPageState, TLPerformanceMode, TLSnapLine } from '@tldraw/core' -import type { Shape } from '../shapes' import type { S } from '@state-designer/react' +import type { TLBinding, TLPage, TLPageState, TLPerformanceMode, TLSnapLine } from '@tldraw/core' +import type { Shape } from 'shapes' export const VERSION = 1 export const PERSIST_DATA = true diff --git a/examples/core-example-advanced/src/state/history.ts b/examples/core-example-advanced/src/state/history.ts index 29b2babee..0730c1277 100644 --- a/examples/core-example-advanced/src/state/history.ts +++ b/examples/core-example-advanced/src/state/history.ts @@ -1,5 +1,5 @@ -import { AppData, INITIAL_DATA, PERSIST_DATA } from './constants' import { current } from 'immer' +import { AppData, INITIAL_DATA, PERSIST_DATA } from './constants' export function makeHistory(ID = '@tldraw/core_advanced_example') { let initialData = INITIAL_DATA diff --git a/examples/core-example-advanced/src/state/machine.ts b/examples/core-example-advanced/src/state/machine.ts index a03689d88..fdfab8a86 100644 --- a/examples/core-example-advanced/src/state/machine.ts +++ b/examples/core-example-advanced/src/state/machine.ts @@ -1,8 +1,8 @@ import { createState } from '@state-designer/react' import type { TLPointerInfo } from '@tldraw/core' -import { INITIAL_DATA } from './constants' import Vec from '@tldraw/vec' import * as actions from './actions' +import { INITIAL_DATA } from './constants' import { mutables } from './mutables' export const machine = createState({ diff --git a/examples/core-example/scripts/build.mjs b/examples/core-example/scripts/build.mjs index 3820d35ce..85ad3dabe 100644 --- a/examples/core-example/scripts/build.mjs +++ b/examples/core-example/scripts/build.mjs @@ -1,6 +1,6 @@ /* eslint-disable */ -import fs from 'fs' import esbuild from 'esbuild' +import fs from 'fs' import { createRequire } from 'module' const pkg = createRequire(import.meta.url)('../package.json') diff --git a/examples/core-example/scripts/dev.mjs b/examples/core-example/scripts/dev.mjs index b85dd8b52..8878260c4 100644 --- a/examples/core-example/scripts/dev.mjs +++ b/examples/core-example/scripts/dev.mjs @@ -1,6 +1,6 @@ /* eslint-disable no-undef */ -import fs from 'fs' import esbuildServe from 'esbuild-serve' +import fs from 'fs' const { log: jslog } = console diff --git a/examples/core-example/src/app.tsx b/examples/core-example/src/app.tsx index 21509bc20..5a056c325 100644 --- a/examples/core-example/src/app.tsx +++ b/examples/core-example/src/app.tsx @@ -1,8 +1,8 @@ -import * as React from 'react' import { Renderer, TLPointerEventHandler, TLShapeUtilsMap } from '@tldraw/core' +import { observer } from 'mobx-react-lite' +import * as React from 'react' import { RectUtil, Shape } from './shapes' import { Page, PageState } from './stores' -import { observer } from 'mobx-react-lite' const page = new Page({ id: 'page1', diff --git a/examples/core-example/src/shapes/rect/RectComponent.tsx b/examples/core-example/src/shapes/rect/RectComponent.tsx index 355717592..0ad51474c 100644 --- a/examples/core-example/src/shapes/rect/RectComponent.tsx +++ b/examples/core-example/src/shapes/rect/RectComponent.tsx @@ -1,5 +1,5 @@ +import { SVGContainer, TLShapeUtil } from '@tldraw/core' import * as React from 'react' -import { TLShapeUtil, SVGContainer } from '@tldraw/core' import type { RectShape } from './RectShape' export const RectComponent = TLShapeUtil.Component( diff --git a/examples/core-example/src/shapes/rect/RectIndicator.tsx b/examples/core-example/src/shapes/rect/RectIndicator.tsx index f7de85ea0..d6a11c134 100644 --- a/examples/core-example/src/shapes/rect/RectIndicator.tsx +++ b/examples/core-example/src/shapes/rect/RectIndicator.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { TLShapeUtil } from '@tldraw/core' +import * as React from 'react' import type { RectShape } from './RectShape' export const RectIndicator = TLShapeUtil.Indicator(({ shape }) => { diff --git a/examples/tldraw-example/scripts/build.mjs b/examples/tldraw-example/scripts/build.mjs index 4064a87df..2e19ee6ac 100644 --- a/examples/tldraw-example/scripts/build.mjs +++ b/examples/tldraw-example/scripts/build.mjs @@ -1,8 +1,8 @@ /* eslint-disable */ -import fs from 'fs' -import path from 'path' import esbuild from 'esbuild' +import fs from 'fs' import { createRequire } from 'module' +import path from 'path' const pkg = createRequire(import.meta.url)('../package.json') diff --git a/examples/tldraw-example/scripts/dev.mjs b/examples/tldraw-example/scripts/dev.mjs index fad15d56c..e5ccb5b80 100644 --- a/examples/tldraw-example/scripts/dev.mjs +++ b/examples/tldraw-example/scripts/dev.mjs @@ -1,8 +1,8 @@ /* eslint-disable no-undef */ +import dotenv from 'dotenv' +import esbuildServe from 'esbuild-serve' import fs from 'fs' import path from 'path' -import esbuildServe from 'esbuild-serve' -import dotenv from 'dotenv' dotenv.config() diff --git a/examples/tldraw-example/src/api-control.tsx b/examples/tldraw-example/src/api-control.tsx index a44f5232e..d631f572a 100644 --- a/examples/tldraw-example/src/api-control.tsx +++ b/examples/tldraw-example/src/api-control.tsx @@ -1,6 +1,5 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ +import { ColorStyle, TDShapeType, Tldraw, TldrawApp } from '@tldraw/tldraw' import * as React from 'react' -import { ColorStyle, Tldraw, TDShapeType, TldrawApp } from '@tldraw/tldraw' export default function Imperative() { const rTldrawApp = React.useRef() diff --git a/examples/tldraw-example/src/api.tsx b/examples/tldraw-example/src/api.tsx index 31e41b967..d4bcacde8 100644 --- a/examples/tldraw-example/src/api.tsx +++ b/examples/tldraw-example/src/api.tsx @@ -1,5 +1,5 @@ +import { ColorStyle, TDShapeType, Tldraw, TldrawApp } from '@tldraw/tldraw' import * as React from 'react' -import { Tldraw, TldrawApp, TDShapeType, ColorStyle } from '@tldraw/tldraw' declare const window: Window & { app: TldrawApp } diff --git a/examples/tldraw-example/src/app.tsx b/examples/tldraw-example/src/app.tsx index 03cce67a7..3680bd3f2 100644 --- a/examples/tldraw-example/src/app.tsx +++ b/examples/tldraw-example/src/app.tsx @@ -1,24 +1,24 @@ import * as React from 'react' -import { Routes, Route, Link } from 'react-router-dom' -import Basic from './basic' -import DarkMode from './dark-mode' -import ReadOnly from './readonly' -import PropsControl from './props-control' -import ApiControl from './api-control' -import LoadingFiles from './loading-files' -import Embedded from './embedded' -import NoSizeEmbedded from './no-size-embedded' -import ChangingId from './changing-id' -import Persisted from './persisted' -import Develop from './develop' -import Api from './api' -import Scroll from './scroll' -import FileSystem from './file-system' -import UIOptions from './ui-options' -import { Multiplayer } from './multiplayer' -import './styles.css' +import { Link, Route, Routes } from 'react-router-dom' import Export from '~export' import IFrame from '~iframe' +import Api from './api' +import ApiControl from './api-control' +import Basic from './basic' +import ChangingId from './changing-id' +import DarkMode from './dark-mode' +import Develop from './develop' +import Embedded from './embedded' +import FileSystem from './file-system' +import LoadingFiles from './loading-files' +import { Multiplayer } from './multiplayer' +import NoSizeEmbedded from './no-size-embedded' +import Persisted from './persisted' +import PropsControl from './props-control' +import ReadOnly from './readonly' +import Scroll from './scroll' +import './styles.css' +import UIOptions from './ui-options' const pages: ({ path: string; component: any; title: string } | '---')[] = [ { path: '/develop', component: Develop, title: 'Develop' }, diff --git a/examples/tldraw-example/src/basic.tsx b/examples/tldraw-example/src/basic.tsx index 95d1abaad..24e0c4d8f 100644 --- a/examples/tldraw-example/src/basic.tsx +++ b/examples/tldraw-example/src/basic.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Tldraw } from '@tldraw/tldraw' +import * as React from 'react' export default function Basic() { return ( diff --git a/examples/tldraw-example/src/changing-id.tsx b/examples/tldraw-example/src/changing-id.tsx index c202391a0..633885121 100644 --- a/examples/tldraw-example/src/changing-id.tsx +++ b/examples/tldraw-example/src/changing-id.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Tldraw } from '@tldraw/tldraw' +import * as React from 'react' export default function ChangingId() { const [id, setId] = React.useState('example') diff --git a/examples/tldraw-example/src/dark-mode.tsx b/examples/tldraw-example/src/dark-mode.tsx index 35e0da719..6f1ce0e5c 100644 --- a/examples/tldraw-example/src/dark-mode.tsx +++ b/examples/tldraw-example/src/dark-mode.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Tldraw } from '@tldraw/tldraw' +import * as React from 'react' export default function DarkMode() { return ( diff --git a/examples/tldraw-example/src/develop.tsx b/examples/tldraw-example/src/develop.tsx index 2db5c4e08..47dfa698f 100644 --- a/examples/tldraw-example/src/develop.tsx +++ b/examples/tldraw-example/src/develop.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import * as React from 'react' import { Tldraw, TldrawApp, useFileSystem } from '@tldraw/tldraw' +import * as React from 'react' declare const window: Window & { app: TldrawApp } diff --git a/examples/tldraw-example/src/export-to-server.tsx b/examples/tldraw-example/src/export-to-server.tsx index f14044d53..37219d78a 100644 --- a/examples/tldraw-example/src/export-to-server.tsx +++ b/examples/tldraw-example/src/export-to-server.tsx @@ -1,17 +1,17 @@ -import * as React from 'react' +import { Utils } from '@tldraw/core' import { - TldrawApp, ImageShape, - TDExportType, - TDAssets, TDAssetType, - TDShapeType, + TDAssets, + TDExportType, TDShape, - Tldraw, + TDShapeType, TLDR, + Tldraw, + TldrawApp, } from '@tldraw/tldraw' import Vec from '@tldraw/vec' -import { Utils } from '@tldraw/core' +import * as React from 'react' export default function Export() { const handleExport = React.useCallback(async (app: TldrawApp) => { diff --git a/examples/tldraw-example/src/export.tsx b/examples/tldraw-example/src/export.tsx index 1aa34ac70..00619942f 100644 --- a/examples/tldraw-example/src/export.tsx +++ b/examples/tldraw-example/src/export.tsx @@ -1,5 +1,5 @@ +import { TDExport, TDExportType, Tldraw, TldrawApp } from '@tldraw/tldraw' import * as React from 'react' -import { TldrawApp, TDExport, TDExportType, Tldraw } from '@tldraw/tldraw' const ACTION = 'download' as 'download' | 'open' diff --git a/examples/tldraw-example/src/file-system.tsx b/examples/tldraw-example/src/file-system.tsx index d9c0df8ca..5e3665c3a 100644 --- a/examples/tldraw-example/src/file-system.tsx +++ b/examples/tldraw-example/src/file-system.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Tldraw, useFileSystem } from '@tldraw/tldraw' +import * as React from 'react' export default function FileSystem() { const fileSystemEvents = useFileSystem() diff --git a/examples/tldraw-example/src/index.tsx b/examples/tldraw-example/src/index.tsx index ee8105ea8..bf1145acd 100644 --- a/examples/tldraw-example/src/index.tsx +++ b/examples/tldraw-example/src/index.tsx @@ -1,9 +1,8 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ - import React from 'react' import { createRoot } from 'react-dom/client' -import App from './app' import { HashRouter } from 'react-router-dom' +import App from './app' const container = document.getElementById('root')! const root = createRoot(container) diff --git a/examples/tldraw-example/src/loading-files.tsx b/examples/tldraw-example/src/loading-files.tsx index d1ac5e706..84339c35a 100644 --- a/examples/tldraw-example/src/loading-files.tsx +++ b/examples/tldraw-example/src/loading-files.tsx @@ -1,4 +1,4 @@ -import { Tldraw, TDFile } from '@tldraw/tldraw' +import { TDFile, Tldraw } from '@tldraw/tldraw' import * as React from 'react' export default function LoadingFiles() { diff --git a/examples/tldraw-example/src/multiplayer/liveblocks.config.ts b/examples/tldraw-example/src/multiplayer/liveblocks.config.ts index ac4f28965..028cf5d3b 100644 --- a/examples/tldraw-example/src/multiplayer/liveblocks.config.ts +++ b/examples/tldraw-example/src/multiplayer/liveblocks.config.ts @@ -1,7 +1,7 @@ import { createClient } from '@liveblocks/client' import type { EnsureJson, LiveMap, LiveObject } from '@liveblocks/client' import { createRoomContext } from '@liveblocks/react' -import type { TDUser, TDShape, TDBinding, TDDocument, TDAsset } from '@tldraw/tldraw' +import type { TDAsset, TDBinding, TDDocument, TDShape, TDUser } from '@tldraw/tldraw' const client = createClient({ publicApiKey: 'YOUR_PUBLIC_KEY' || '', diff --git a/examples/tldraw-example/src/multiplayer/multiplayer.tsx b/examples/tldraw-example/src/multiplayer/multiplayer.tsx index 6d3ad17b7..a2dc63047 100644 --- a/examples/tldraw-example/src/multiplayer/multiplayer.tsx +++ b/examples/tldraw-example/src/multiplayer/multiplayer.tsx @@ -1,8 +1,9 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import * as React from 'react' import { Tldraw } from '@tldraw/tldraw' +import * as React from 'react' import { RoomProvider } from './liveblocks.config' import { useMultiplayerState } from './useMultiplayerState' + const roomId = 'mp-test-8' /* diff --git a/examples/tldraw-example/src/multiplayer/useMultiplayerState.ts b/examples/tldraw-example/src/multiplayer/useMultiplayerState.ts index 0e5259bfb..ffd9e51ec 100644 --- a/examples/tldraw-example/src/multiplayer/useMultiplayerState.ts +++ b/examples/tldraw-example/src/multiplayer/useMultiplayerState.ts @@ -1,11 +1,8 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -/* eslint-disable @typescript-eslint/no-non-null-assertion */ -import React, { useState, useRef, useCallback } from 'react' -import type { TldrawApp, TDUser, TDShape, TDBinding, TDAsset } from '@tldraw/tldraw' -import { useHotkeys } from 'react-hotkeys-hook' import { LiveMap } from '@liveblocks/client' - -import { useRedo, useUndo, useRoom, useUpdateMyPresence } from './liveblocks.config' +import type { TDAsset, TDBinding, TDShape, TDUser, TldrawApp } from '@tldraw/tldraw' +import React, { useCallback, useRef, useState } from 'react' +import { useHotkeys } from 'react-hotkeys-hook' +import { useRedo, useRoom, useUndo, useUpdateMyPresence } from './liveblocks.config' import type { Storage } from './liveblocks.config' declare const window: Window & { app: TldrawApp } diff --git a/examples/tldraw-example/src/persisted.tsx b/examples/tldraw-example/src/persisted.tsx index c082e9e5d..b5ad122bf 100644 --- a/examples/tldraw-example/src/persisted.tsx +++ b/examples/tldraw-example/src/persisted.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Tldraw } from '@tldraw/tldraw' +import * as React from 'react' export default function Persisted() { return ( diff --git a/examples/tldraw-example/src/props-control.tsx b/examples/tldraw-example/src/props-control.tsx index fe92c60aa..661a49e90 100644 --- a/examples/tldraw-example/src/props-control.tsx +++ b/examples/tldraw-example/src/props-control.tsx @@ -1,13 +1,13 @@ -import * as React from 'react' import { - Tldraw, ColorStyle, DashStyle, SizeStyle, TDDocument, TDShapeType, + Tldraw, TldrawApp, } from '@tldraw/tldraw' +import * as React from 'react' export default function Controlled() { const rDocument = React.useRef({ diff --git a/examples/tldraw-example/src/readonly.tsx b/examples/tldraw-example/src/readonly.tsx index 10ffaddf4..d6f7f0e13 100644 --- a/examples/tldraw-example/src/readonly.tsx +++ b/examples/tldraw-example/src/readonly.tsx @@ -1,4 +1,4 @@ -import { Tldraw, TDFile } from '@tldraw/tldraw' +import { TDFile, Tldraw } from '@tldraw/tldraw' import * as React from 'react' export default function ReadOnly() { diff --git a/examples/tldraw-example/src/scroll.tsx b/examples/tldraw-example/src/scroll.tsx index e1ead608a..b6e654347 100644 --- a/examples/tldraw-example/src/scroll.tsx +++ b/examples/tldraw-example/src/scroll.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import * as React from 'react' import { Tldraw, TldrawApp } from '@tldraw/tldraw' +import * as React from 'react' declare const window: Window & { app: TldrawApp } diff --git a/guides/translation.md b/guides/translation.md index 278e15b7d..e86042c1c 100644 --- a/guides/translation.md +++ b/guides/translation.md @@ -27,9 +27,10 @@ Rename the new file to the [language code](https://gist.github.com/wpsmith/76048 In the `packages/tldraw/src/translations/translations.ts` file, import your file and create a new entry in to the `TRANSLATIONS` array like this: ```ts -import en from './en.json' import ar from './ar.json' -import eo from './eo.json' // <-- import here +import en from './en.json' +// import here ↲ +import eo from './eo.json' export const TRANSLATIONS: TDTranslations = [ // Default language: diff --git a/package.json b/package.json index 2c2337625..25f9d698b 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "test": "turbo run test --stream", "test:ci": "turbo run test:ci --stream", "test:watch": "turbo run test:watch --stream", + "format": "prettier --write .", "lint": "turbo run lint", "clean": "turbo run clean", "postinstall": "husky install", @@ -44,6 +45,7 @@ "@testing-library/jest-dom": "^5.16.2", "@testing-library/react": "^12.1.2", "@tldraw/lfg": "latest", + "@trivago/prettier-plugin-sort-imports": "^3.3.0", "@types/jest": "^27.4.0", "@types/node": "^17.0.14", "@types/vscode": "^1.63.2", @@ -57,7 +59,7 @@ "jest": "^27.4.7", "lint-staged": "^12.3.3", "mobx": "^6.3.8", - "prettier": "^2.5.1", + "prettier": "^2.7.1", "resize-observer-polyfill": "^1.5.1", "source-map-loader": "^3.0.1", "tslib": "^2.4.0", @@ -65,6 +67,9 @@ "typescript": "^4.7.3", "webpack": "^5.68.0" }, + "resolutions": { + "@trivago/prettier-plugin-sort-imports/**/@babel/parser": "^7.17.0" + }, "lint-staged": { "*": "prettier --ignore-unknown --write", "*.{ts,tsx}": "eslint --fix" diff --git a/packages/core/README.md b/packages/core/README.md index 28c42c8eb..75894c5e1 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -312,9 +312,8 @@ Next, use `TLShapeUtil.Component` to create a second component for your shape's ```tsx // BoxComponent.ts - +import { SVGContainer, shapeComponent } from '@tldraw/core' import * as React from 'react' -import { shapeComponent, SVGContainer } from '@tldraw/core' import type { BoxShape } from './BoxShape' export const BoxComponent = TLShapeUtil.Component( @@ -391,8 +390,7 @@ Next, create a "shape util" for your shape. This is a class that extends `TLShap ```ts // BoxUtil.ts - -import { Utils, TLBounds, TLShapeUtil } from '@tldraw/core' +import { TLBounds, TLShapeUtil, Utils } from '@tldraw/core' import { BoxComponent } from './BoxComponent' import { BoxIndicator } from './BoxIndicator' import type { BoxShape } from './BoxShape' diff --git a/packages/core/src/TLShapeUtil/TLShapeUtil.spec.tsx b/packages/core/src/TLShapeUtil/TLShapeUtil.spec.tsx index 9d44868ea..9816ebf2a 100644 --- a/packages/core/src/TLShapeUtil/TLShapeUtil.spec.tsx +++ b/packages/core/src/TLShapeUtil/TLShapeUtil.spec.tsx @@ -1,9 +1,9 @@ -import * as React from 'react' -import type { TLShape, TLBounds, TLComponentProps } from '../types' -import { TLShapeUtil } from './TLShapeUtil' import { render } from '@testing-library/react' +import * as React from 'react' import { SVGContainer } from '~components' -import Utils from '../utils' +import type { TLBounds, TLComponentProps, TLShape } from '~types' +import Utils from '~utils' +import { TLShapeUtil } from './TLShapeUtil' export interface BoxShape extends TLShape { type: 'box' diff --git a/packages/core/src/TLShapeUtil/TLShapeUtil.tsx b/packages/core/src/TLShapeUtil/TLShapeUtil.tsx index 454cf6dad..356ba23ce 100644 --- a/packages/core/src/TLShapeUtil/TLShapeUtil.tsx +++ b/packages/core/src/TLShapeUtil/TLShapeUtil.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' -import Utils from '../utils' -import type { TLBounds, TLComponentProps, TLForwardedRef, TLShape, TLUser } from '../types' import { intersectPolygonBounds } from '@tldraw/intersect' +import * as React from 'react' +import type { TLBounds, TLComponentProps, TLForwardedRef, TLShape, TLUser } from '~types' +import Utils from '~utils' export abstract class TLShapeUtil { refMap = new Map>() diff --git a/packages/core/src/TLShapeUtil/index.ts b/packages/core/src/TLShapeUtil/index.ts index 144a77466..3fd3629ca 100644 --- a/packages/core/src/TLShapeUtil/index.ts +++ b/packages/core/src/TLShapeUtil/index.ts @@ -1,4 +1,4 @@ -import type { TLShape } from '../types' +import type { TLShape } from '~types' import type { TLShapeUtil } from './TLShapeUtil' export type TLShapeUtilsMap = { diff --git a/packages/core/src/components/Bounds/Bounds.tsx b/packages/core/src/components/Bounds/Bounds.tsx index 7d0e5b180..a36821031 100644 --- a/packages/core/src/components/Bounds/Bounds.tsx +++ b/packages/core/src/components/Bounds/Bounds.tsx @@ -1,14 +1,14 @@ +import { observer } from 'mobx-react-lite' import * as React from 'react' -import { TLBoundsEdge, TLBoundsCorner, TLBounds } from '~types' -import { CenterHandle } from './CenterHandle' -import { RotateHandle } from './RotateHandle' -import { CornerHandle } from './CornerHandle' -import { LinkHandle } from './LinkHandle' -import { EdgeHandle } from './EdgeHandle' -import { CloneButtons } from './CloneButtons' import { Container } from '~components/Container' import { SVGContainer } from '~components/SVGContainer' -import { observer } from 'mobx-react-lite' +import { TLBounds, TLBoundsCorner, TLBoundsEdge } from '~types' +import { CenterHandle } from './CenterHandle' +import { CloneButtons } from './CloneButtons' +import { CornerHandle } from './CornerHandle' +import { EdgeHandle } from './EdgeHandle' +import { LinkHandle } from './LinkHandle' +import { RotateHandle } from './RotateHandle' interface BoundsProps { zoom: number diff --git a/packages/core/src/components/Bounds/BoundsBg.tsx b/packages/core/src/components/Bounds/BoundsBg.tsx index a53f8b670..4f50b83c0 100644 --- a/packages/core/src/components/Bounds/BoundsBg.tsx +++ b/packages/core/src/components/Bounds/BoundsBg.tsx @@ -1,9 +1,9 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' -import type { TLBounds } from '~types' -import { useBoundsEvents } from '~hooks' import { Container } from '~components/Container' import { SVGContainer } from '~components/SVGContainer' +import { useBoundsEvents } from '~hooks' +import type { TLBounds } from '~types' interface BoundsBgProps { bounds: TLBounds diff --git a/packages/core/src/components/Bounds/CornerHandle.tsx b/packages/core/src/components/Bounds/CornerHandle.tsx index bbb9dc9de..2a00487db 100644 --- a/packages/core/src/components/Bounds/CornerHandle.tsx +++ b/packages/core/src/components/Bounds/CornerHandle.tsx @@ -1,7 +1,7 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' import { useBoundsHandleEvents } from '~hooks' -import { TLBoundsCorner, TLBounds } from '~types' +import { TLBounds, TLBoundsCorner } from '~types' const cornerBgClassnames = { [TLBoundsCorner.TopLeft]: 'tl-cursor-nwse', diff --git a/packages/core/src/components/Bounds/EdgeHandle.tsx b/packages/core/src/components/Bounds/EdgeHandle.tsx index 1187271eb..73662748f 100644 --- a/packages/core/src/components/Bounds/EdgeHandle.tsx +++ b/packages/core/src/components/Bounds/EdgeHandle.tsx @@ -1,7 +1,7 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' import { useBoundsHandleEvents } from '~hooks' -import { TLBoundsEdge, TLBounds } from '~types' +import { TLBounds, TLBoundsEdge } from '~types' const edgeClassnames = { [TLBoundsEdge.Top]: 'tl-cursor-ns', diff --git a/packages/core/src/components/Bounds/__tests__/Bounds.test.tsx b/packages/core/src/components/Bounds/__tests__/Bounds.test.tsx index e3a9ab5cc..0b9f14225 100644 --- a/packages/core/src/components/Bounds/__tests__/Bounds.test.tsx +++ b/packages/core/src/components/Bounds/__tests__/Bounds.test.tsx @@ -1,6 +1,6 @@ -import { renderWithContext } from '~test' import { screen } from '@testing-library/react' import * as React from 'react' +import { renderWithContext } from '~test' import { Bounds } from '../Bounds' describe('bounds', () => { diff --git a/packages/core/src/components/Bounds/__tests__/CloneButton.test.tsx b/packages/core/src/components/Bounds/__tests__/CloneButton.test.tsx index 4b068e9b5..51bd4fadb 100644 --- a/packages/core/src/components/Bounds/__tests__/CloneButton.test.tsx +++ b/packages/core/src/components/Bounds/__tests__/CloneButton.test.tsx @@ -1,6 +1,6 @@ -import { renderWithContext } from '~test' import { screen } from '@testing-library/react' import * as React from 'react' +import { renderWithContext } from '~test' import { CloneButton } from '../CloneButton' jest.spyOn(console, 'error').mockImplementation(() => void null) diff --git a/packages/core/src/components/Bounds/__tests__/CornerHandle.test.tsx b/packages/core/src/components/Bounds/__tests__/CornerHandle.test.tsx index daa1f4fa5..7cced8820 100644 --- a/packages/core/src/components/Bounds/__tests__/CornerHandle.test.tsx +++ b/packages/core/src/components/Bounds/__tests__/CornerHandle.test.tsx @@ -1,8 +1,8 @@ -import { renderWithContext } from '~test' import { screen } from '@testing-library/react' import * as React from 'react' -import { CornerHandle } from '../CornerHandle' +import { renderWithContext } from '~test' import { TLBoundsCorner } from '~types' +import { CornerHandle } from '../CornerHandle' jest.spyOn(console, 'error').mockImplementation(() => void null) diff --git a/packages/core/src/components/Bounds/__tests__/EdgeHandle.test.tsx b/packages/core/src/components/Bounds/__tests__/EdgeHandle.test.tsx index 933b06b88..549c655e1 100644 --- a/packages/core/src/components/Bounds/__tests__/EdgeHandle.test.tsx +++ b/packages/core/src/components/Bounds/__tests__/EdgeHandle.test.tsx @@ -1,8 +1,8 @@ +import { screen } from '@testing-library/react' import * as React from 'react' import { renderWithContext } from '~test' -import { screen } from '@testing-library/react' -import { EdgeHandle } from '../EdgeHandle' import { TLBoundsEdge } from '~types' +import { EdgeHandle } from '../EdgeHandle' jest.spyOn(console, 'error').mockImplementation(() => void null) diff --git a/packages/core/src/components/Bounds/__tests__/LinkHandle.test.tsx b/packages/core/src/components/Bounds/__tests__/LinkHandle.test.tsx index c453e5312..242ec6550 100644 --- a/packages/core/src/components/Bounds/__tests__/LinkHandle.test.tsx +++ b/packages/core/src/components/Bounds/__tests__/LinkHandle.test.tsx @@ -1,6 +1,6 @@ -import { renderWithContext } from '~test' import { screen } from '@testing-library/react' import * as React from 'react' +import { renderWithContext } from '~test' import { LinkHandle } from '../LinkHandle' jest.spyOn(console, 'error').mockImplementation(() => void null) diff --git a/packages/core/src/components/Bounds/__tests__/RotateHandle.test.tsx b/packages/core/src/components/Bounds/__tests__/RotateHandle.test.tsx index 8518195e2..e89e523f1 100644 --- a/packages/core/src/components/Bounds/__tests__/RotateHandle.test.tsx +++ b/packages/core/src/components/Bounds/__tests__/RotateHandle.test.tsx @@ -1,6 +1,6 @@ -import { renderWithContext } from '~test' import { screen } from '@testing-library/react' import * as React from 'react' +import { renderWithContext } from '~test' import { RotateHandle } from '../RotateHandle' jest.spyOn(console, 'error').mockImplementation(() => void null) diff --git a/packages/core/src/components/Brush/Brush.test.tsx b/packages/core/src/components/Brush/Brush.test.tsx index bc28a0fc3..4708bc042 100644 --- a/packages/core/src/components/Brush/Brush.test.tsx +++ b/packages/core/src/components/Brush/Brush.test.tsx @@ -1,6 +1,6 @@ +import { screen } from '@testing-library/react' import * as React from 'react' import { renderWithSvg } from '~test' -import { screen } from '@testing-library/react' import { Brush } from './Brush' describe('brush', () => { diff --git a/packages/core/src/components/Brush/Brush.tsx b/packages/core/src/components/Brush/Brush.tsx index 625295112..eb9684b7d 100644 --- a/packages/core/src/components/Brush/Brush.tsx +++ b/packages/core/src/components/Brush/Brush.tsx @@ -1,8 +1,8 @@ import { observer } from 'mobx-react-lite' +import * as React from 'react' import { SVGContainer } from '~components' import { Container } from '~components/Container' import type { TLBounds } from '~types' -import * as React from 'react' import Utils from '~utils' export const Brush = observer<{ diff --git a/packages/core/src/components/Canvas/Canvas.tsx b/packages/core/src/components/Canvas/Canvas.tsx index d672e7686..900fe4eca 100644 --- a/packages/core/src/components/Canvas/Canvas.tsx +++ b/packages/core/src/components/Canvas/Canvas.tsx @@ -1,14 +1,23 @@ -import * as React from 'react' import { observer } from 'mobx-react-lite' +import * as React from 'react' +import { Brush } from '~components/Brush' +import { EraseLine } from '~components/EraseLine' +import { Grid } from '~components/Grid' +import { Overlay } from '~components/Overlay' +import { Page } from '~components/Page' +import { SnapLines } from '~components/SnapLines/SnapLines' +import { Users } from '~components/Users' +import { UsersIndicators } from '~components/UsersIndicators' import { - usePreventNavigationCss, - useZoomEvents, - useSafariFocusOutFix, - useCanvasEvents, useCameraCss, + useCanvasEvents, useKeyEvents, usePerformanceCss, + usePreventNavigationCss, + useSafariFocusOutFix, + useZoomEvents, } from '~hooks' +import { useResizeObserver } from '~hooks/useResizeObserver' import type { TLAssets, TLBinding, @@ -20,15 +29,6 @@ import type { TLSnapLine, TLUsers, } from '~types' -import { Brush } from '~components/Brush' -import { Page } from '~components/Page' -import { Users } from '~components/Users' -import { useResizeObserver } from '~hooks/useResizeObserver' -import { UsersIndicators } from '~components/UsersIndicators' -import { SnapLines } from '~components/SnapLines/SnapLines' -import { Grid } from '~components/Grid' -import { Overlay } from '~components/Overlay' -import { EraseLine } from '~components/EraseLine' interface CanvasProps> { page: TLPage diff --git a/packages/core/src/components/Container/Container.tsx b/packages/core/src/components/Container/Container.tsx index cc7a1f551..1663af65b 100644 --- a/packages/core/src/components/Container/Container.tsx +++ b/packages/core/src/components/Container/Container.tsx @@ -1,8 +1,8 @@ import { observer } from 'mobx-react-lite' import type { HTMLProps } from 'react' import * as React from 'react' -import type { TLBounds } from '~types' import { usePosition } from '~hooks' +import type { TLBounds } from '~types' interface ContainerProps extends HTMLProps { id?: string diff --git a/packages/core/src/components/EraseLine/EraseLine.tsx b/packages/core/src/components/EraseLine/EraseLine.tsx index 046241492..2f0af96e2 100644 --- a/packages/core/src/components/EraseLine/EraseLine.tsx +++ b/packages/core/src/components/EraseLine/EraseLine.tsx @@ -1,6 +1,6 @@ -import * as React from 'react' import { observer } from 'mobx-react-lite' import getStroke from 'perfect-freehand' +import * as React from 'react' import Utils from '~utils' export interface UiEraseLintProps { diff --git a/packages/core/src/components/Handles/Handle.test.tsx b/packages/core/src/components/Handles/Handle.test.tsx index 3c6f383a9..9004ec832 100644 --- a/packages/core/src/components/Handles/Handle.test.tsx +++ b/packages/core/src/components/Handles/Handle.test.tsx @@ -1,6 +1,6 @@ +import { screen } from '@testing-library/react' import * as React from 'react' import { renderWithContext } from '~test' -import { screen } from '@testing-library/react' import { Handle } from './Handle' describe('handle', () => { diff --git a/packages/core/src/components/Handles/Handle.tsx b/packages/core/src/components/Handles/Handle.tsx index 22302b1ce..b4c64fd30 100644 --- a/packages/core/src/components/Handles/Handle.tsx +++ b/packages/core/src/components/Handles/Handle.tsx @@ -1,9 +1,9 @@ -import * as React from 'react' -import { useHandleEvents } from '~hooks' -import { Container } from '~components/Container' -import Utils from '~utils' -import { SVGContainer } from '~components/SVGContainer' import { observer } from 'mobx-react-lite' +import * as React from 'react' +import { Container } from '~components/Container' +import { SVGContainer } from '~components/SVGContainer' +import { useHandleEvents } from '~hooks' +import Utils from '~utils' interface HandleProps { id: string diff --git a/packages/core/src/components/Handles/Handles.test.tsx b/packages/core/src/components/Handles/Handles.test.tsx index 4be42134c..d0843e2db 100644 --- a/packages/core/src/components/Handles/Handles.test.tsx +++ b/packages/core/src/components/Handles/Handles.test.tsx @@ -1,8 +1,8 @@ +import { screen } from '@testing-library/react' import * as React from 'react' +import { boxShape } from '~TLShapeUtil/TLShapeUtil.spec' import { renderWithContext } from '~test' import { Handles } from './Handles' -import { boxShape } from '~TLShapeUtil/TLShapeUtil.spec' -import { screen } from '@testing-library/react' describe('handles', () => { test('mounts component without crashing', () => { diff --git a/packages/core/src/components/Handles/Handles.tsx b/packages/core/src/components/Handles/Handles.tsx index 08d0ebd64..8c37374b8 100644 --- a/packages/core/src/components/Handles/Handles.tsx +++ b/packages/core/src/components/Handles/Handles.tsx @@ -1,6 +1,6 @@ +import { Vec } from '@tldraw/vec' import { observer } from 'mobx-react-lite' import * as React from 'react' -import { Vec } from '@tldraw/vec' import type { TLHandle, TLShape } from '~types' import { Handle } from './Handle' diff --git a/packages/core/src/components/Page/Page.tsx b/packages/core/src/components/Page/Page.tsx index 6e00c4699..061037618 100644 --- a/packages/core/src/components/Page/Page.tsx +++ b/packages/core/src/components/Page/Page.tsx @@ -1,13 +1,13 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' -import type { TLAssets, TLBinding, TLPage, TLPageState, TLShape } from '~types' -import { useSelection, useShapeTree, useTLContext } from '~hooks' +import type { TLShapeUtil } from '~TLShapeUtil' import { Bounds } from '~components/Bounds' import { BoundsBg } from '~components/Bounds/BoundsBg' import { Handles } from '~components/Handles' import { ShapeNode } from '~components/Shape' import { ShapeIndicator } from '~components/ShapeIndicator' -import type { TLShapeUtil } from '~TLShapeUtil' +import { useSelection, useShapeTree, useTLContext } from '~hooks' +import type { TLAssets, TLBinding, TLPage, TLPageState, TLShape } from '~types' interface PageProps> { page: TLPage diff --git a/packages/core/src/components/Renderer/Renderer.test.tsx b/packages/core/src/components/Renderer/Renderer.test.tsx index 489c18ee2..81f73a5d1 100644 --- a/packages/core/src/components/Renderer/Renderer.test.tsx +++ b/packages/core/src/components/Renderer/Renderer.test.tsx @@ -1,12 +1,12 @@ -import * as React from 'react' -import { mockDocument, mockUtils } from '~test' import { act, render } from '@testing-library/react' -import { Renderer } from './Renderer' +import Vec from '@tldraw/vec' import { action, makeAutoObservable } from 'mobx' +import * as React from 'react' +import type { BoxShape } from '~TLShapeUtil/TLShapeUtil.spec' +import { mockDocument, mockUtils } from '~test' import type { TLBounds, TLPage, TLPageState } from '~types' import Utils from '~utils' -import type { BoxShape } from '~TLShapeUtil/TLShapeUtil.spec' -import Vec from '@tldraw/vec' +import { Renderer } from './Renderer' describe('renderer', () => { test('mounts component without crashing', () => { diff --git a/packages/core/src/components/Renderer/Renderer.tsx b/packages/core/src/components/Renderer/Renderer.tsx index 8210e15ba..1552aad2b 100644 --- a/packages/core/src/components/Renderer/Renderer.tsx +++ b/packages/core/src/components/Renderer/Renderer.tsx @@ -1,22 +1,22 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' +import { Canvas } from '~/components/Canvas' +import type { TLShapeUtilsMap } from '~TLShapeUtil' +import { TLContext, TLContextType, useTLTheme } from '~hooks' +import { Inputs } from '~inputs' import type { - TLShape, + TLAssets, + TLBinding, + TLBounds, + TLCallbacks, TLPage, TLPageState, - TLCallbacks, - TLTheme, - TLBounds, - TLBinding, - TLSnapLine, - TLUsers, - TLAssets, TLPerformanceMode, -} from '../../types' -import { Canvas } from '../Canvas' -import { Inputs } from '../../inputs' -import { useTLTheme, TLContext, TLContextType } from '../../hooks' -import type { TLShapeUtilsMap } from '../../TLShapeUtil' + TLShape, + TLSnapLine, + TLTheme, + TLUsers, +} from '~types' export interface RendererProps extends Partial> { /** diff --git a/packages/core/src/components/Shape/RenderedShape.tsx b/packages/core/src/components/Shape/RenderedShape.tsx index 7d8667edf..0eabff710 100644 --- a/packages/core/src/components/Shape/RenderedShape.tsx +++ b/packages/core/src/components/Shape/RenderedShape.tsx @@ -1,7 +1,7 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' -import type { TLComponentProps, TLShape } from '~types' import type { TLShapeUtil } from '~TLShapeUtil' +import type { TLComponentProps, TLShape } from '~types' interface RenderedShapeProps extends TLComponentProps { diff --git a/packages/core/src/components/Shape/Shape.test.tsx b/packages/core/src/components/Shape/Shape.test.tsx index fb8772e12..a0cabf75e 100644 --- a/packages/core/src/components/Shape/Shape.test.tsx +++ b/packages/core/src/components/Shape/Shape.test.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { renderWithContext } from '~test' -import { Shape } from './Shape' -import { BoxUtil, boxShape } from '~TLShapeUtil/TLShapeUtil.spec' import type { TLShapeUtil } from '~TLShapeUtil' +import { BoxUtil, boxShape } from '~TLShapeUtil/TLShapeUtil.spec' +import { renderWithContext } from '~test' import type { TLShape } from '~types' +import { Shape } from './Shape' describe('shape', () => { test('mounts component without crashing', () => { diff --git a/packages/core/src/components/Shape/Shape.tsx b/packages/core/src/components/Shape/Shape.tsx index 9d05db206..1bfbec4ed 100644 --- a/packages/core/src/components/Shape/Shape.tsx +++ b/packages/core/src/components/Shape/Shape.tsx @@ -1,11 +1,11 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' +import type { TLShapeUtil } from '~TLShapeUtil' +import { Container } from '~components/Container' import { useShapeEvents } from '~hooks' +import { useTLContext } from '~hooks' import type { IShapeTreeNode, TLShape } from '~types' import { RenderedShape } from './RenderedShape' -import { Container } from '~components/Container' -import { useTLContext } from '~hooks' -import type { TLShapeUtil } from '~TLShapeUtil' interface ShapeProps extends IShapeTreeNode { utils: TLShapeUtil diff --git a/packages/core/src/components/Shape/ShapeNode.tsx b/packages/core/src/components/Shape/ShapeNode.tsx index f03c3ee7d..784667675 100644 --- a/packages/core/src/components/Shape/ShapeNode.tsx +++ b/packages/core/src/components/Shape/ShapeNode.tsx @@ -1,8 +1,8 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' +import type { TLShapeUtilsMap } from '~TLShapeUtil' import type { IShapeTreeNode, TLShape } from '~types' import { Shape } from './Shape' -import type { TLShapeUtilsMap } from '~TLShapeUtil' interface ShapeNodeProps extends IShapeTreeNode { utils: TLShapeUtilsMap diff --git a/packages/core/src/components/ShapeIndicator/ShapeIndicator.test.tsx b/packages/core/src/components/ShapeIndicator/ShapeIndicator.test.tsx index bd8fbf83f..0e72d598c 100644 --- a/packages/core/src/components/ShapeIndicator/ShapeIndicator.test.tsx +++ b/packages/core/src/components/ShapeIndicator/ShapeIndicator.test.tsx @@ -1,7 +1,7 @@ import * as React from 'react' +import { boxShape } from '~TLShapeUtil/TLShapeUtil.spec' import { renderWithSvg } from '~test' import { ShapeIndicator } from './ShapeIndicator' -import { boxShape } from '~TLShapeUtil/TLShapeUtil.spec' describe('shape indicator', () => { test('mounts component without crashing', () => { diff --git a/packages/core/src/components/ShapeIndicator/ShapeIndicator.tsx b/packages/core/src/components/ShapeIndicator/ShapeIndicator.tsx index 56b5833e4..7f9a53bac 100644 --- a/packages/core/src/components/ShapeIndicator/ShapeIndicator.tsx +++ b/packages/core/src/components/ShapeIndicator/ShapeIndicator.tsx @@ -1,7 +1,7 @@ import { observer } from 'mobx-react-lite' import * as React from 'react' -import type { TLShape, TLUser } from '~types' import { usePosition, useTLContext } from '~hooks' +import type { TLShape, TLUser } from '~types' interface IndicatorProps { shape: T diff --git a/packages/core/src/components/UsersIndicators/UsersIndicators.tsx b/packages/core/src/components/UsersIndicators/UsersIndicators.tsx index 69ab9a23d..5ff0d1f9e 100644 --- a/packages/core/src/components/UsersIndicators/UsersIndicators.tsx +++ b/packages/core/src/components/UsersIndicators/UsersIndicators.tsx @@ -1,8 +1,8 @@ import * as React from 'react' import { ShapeIndicator } from '~components/ShapeIndicator' +import { useTLContext } from '~hooks' import type { TLPage, TLShape, TLUsers } from '~types' import Utils from '~utils' -import { useTLContext } from '~hooks' interface UserIndicatorProps { page: TLPage diff --git a/packages/core/src/hooks/useBoundsHandleEvents.tsx b/packages/core/src/hooks/useBoundsHandleEvents.tsx index ab6b72415..fd4fe3ab7 100644 --- a/packages/core/src/hooks/useBoundsHandleEvents.tsx +++ b/packages/core/src/hooks/useBoundsHandleEvents.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import type { TLBoundsEdge, TLBoundsCorner } from '../types' +import type { TLBoundsCorner, TLBoundsEdge } from '~types' import { useTLContext } from './useTLContext' export function useBoundsHandleEvents( diff --git a/packages/core/src/hooks/useCameraCss.tsx b/packages/core/src/hooks/useCameraCss.tsx index b5316f379..9a23fdd20 100644 --- a/packages/core/src/hooks/useCameraCss.tsx +++ b/packages/core/src/hooks/useCameraCss.tsx @@ -1,6 +1,6 @@ import { autorun } from 'mobx' import * as React from 'react' -import type { TLPageState } from '../types' +import type { TLPageState } from '~types' export function useCameraCss( layerRef: React.RefObject, diff --git a/packages/core/src/hooks/useHandles.ts b/packages/core/src/hooks/useHandles.ts index e6123ed66..5a4ca7053 100644 --- a/packages/core/src/hooks/useHandles.ts +++ b/packages/core/src/hooks/useHandles.ts @@ -1,4 +1,4 @@ -import type { TLBinding, TLPage, TLPageState, TLShape } from '../types' +import type { TLBinding, TLPage, TLPageState, TLShape } from '~types' export function useHandles(page: TLPage, pageState: TLPageState) { const { selectedIds } = pageState diff --git a/packages/core/src/hooks/useKeyEvents.ts b/packages/core/src/hooks/useKeyEvents.ts index 54e3e2cdd..6f52358e7 100644 --- a/packages/core/src/hooks/useKeyEvents.ts +++ b/packages/core/src/hooks/useKeyEvents.ts @@ -1,5 +1,5 @@ -import { useTLContext } from '../hooks' import * as React from 'react' +import { useTLContext } from '~hooks' export function useKeyEvents() { const { inputs, callbacks } = useTLContext() diff --git a/packages/core/src/hooks/usePosition.ts b/packages/core/src/hooks/usePosition.ts index 0becd5396..315ab45d5 100644 --- a/packages/core/src/hooks/usePosition.ts +++ b/packages/core/src/hooks/usePosition.ts @@ -1,6 +1,6 @@ import { autorun } from 'mobx' import * as React from 'react' -import type { TLBounds } from '../types' +import type { TLBounds } from '~types' export function usePosition(bounds: TLBounds, rotation = 0) { const rBounds = React.useRef(null) diff --git a/packages/core/src/hooks/useResizeObserver.ts b/packages/core/src/hooks/useResizeObserver.ts index 8c010e2e2..dde4b8d2f 100644 --- a/packages/core/src/hooks/useResizeObserver.ts +++ b/packages/core/src/hooks/useResizeObserver.ts @@ -1,8 +1,8 @@ -import { useTLContext } from '../hooks' -import ResizeObserver from 'resize-observer-polyfill' import * as React from 'react' -import { Utils } from '../utils' -import type { TLBounds } from '../types' +import ResizeObserver from 'resize-observer-polyfill' +import { useTLContext } from '~hooks' +import type { TLBounds } from '~types' +import { Utils } from '~utils' // Credits: from excalidraw // https://github.com/excalidraw/excalidraw/blob/07ebd7c68ce6ff92ddbc22d1c3d215f2b21328d6/src/utils.ts#L542-L563 diff --git a/packages/core/src/hooks/useSafariFocusOutFix.tsx b/packages/core/src/hooks/useSafariFocusOutFix.tsx index 4aa8c4d02..370d77c1f 100644 --- a/packages/core/src/hooks/useSafariFocusOutFix.tsx +++ b/packages/core/src/hooks/useSafariFocusOutFix.tsx @@ -1,5 +1,5 @@ import { useEffect } from 'react' -import Utils from '../utils' +import Utils from '~utils' import { useTLContext } from './useTLContext' // Send event on iOS when a user presses the "Done" key while editing a text element. diff --git a/packages/core/src/hooks/useSelection.tsx b/packages/core/src/hooks/useSelection.tsx index 020d5846c..0c5dc4099 100644 --- a/packages/core/src/hooks/useSelection.tsx +++ b/packages/core/src/hooks/useSelection.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import type { TLPage, TLPageState, TLShape, TLBounds, TLBinding } from '../types' -import Utils from '../utils' +import type { TLShapeUtil, TLShapeUtilsMap } from '~TLShapeUtil' +import type { TLBinding, TLBounds, TLPage, TLPageState, TLShape } from '~types' +import Utils from '~utils' import { useTLContext } from './useTLContext' -import type { TLShapeUtil, TLShapeUtilsMap } from '../TLShapeUtil' function canvasToScreen(point: number[], camera: TLPageState['camera']): number[] { return [(point[0] + camera.point[0]) * camera.zoom, (point[1] + camera.point[1]) * camera.zoom] diff --git a/packages/core/src/hooks/useShapeEvents.tsx b/packages/core/src/hooks/useShapeEvents.tsx index 416004406..0f2b5b303 100644 --- a/packages/core/src/hooks/useShapeEvents.tsx +++ b/packages/core/src/hooks/useShapeEvents.tsx @@ -1,6 +1,6 @@ import * as React from 'react' -import { Utils } from '~utils' import { TLContext } from '~hooks' +import { Utils } from '~utils' export function useShapeEvents(id: string) { const { rPageState, rSelectionBounds, callbacks, inputs } = React.useContext(TLContext) diff --git a/packages/core/src/hooks/useShapeTree.tsx b/packages/core/src/hooks/useShapeTree.tsx index 42ea9e3bd..663128e08 100644 --- a/packages/core/src/hooks/useShapeTree.tsx +++ b/packages/core/src/hooks/useShapeTree.tsx @@ -1,16 +1,16 @@ +import { Vec } from '@tldraw/vec' import * as React from 'react' +import { useTLContext } from '~hooks' import type { IShapeTreeNode, + TLAssets, + TLBinding, + TLBounds, TLPage, TLPageState, TLShape, - TLBinding, - TLBounds, - TLAssets, } from '~types' import { Utils } from '~utils' -import { Vec } from '@tldraw/vec' -import { useTLContext } from '~hooks' function addToShapeTree>( shape: T, diff --git a/packages/core/src/hooks/useTLContext.tsx b/packages/core/src/hooks/useTLContext.tsx index 37f02b542..a908cf6d5 100644 --- a/packages/core/src/hooks/useTLContext.tsx +++ b/packages/core/src/hooks/useTLContext.tsx @@ -1,7 +1,7 @@ import * as React from 'react' -import type { Inputs } from '~inputs' -import type { TLCallbacks, TLShape, TLBounds, TLPageState } from '~types' import type { TLShapeUtilsMap } from '~TLShapeUtil' +import type { Inputs } from '~inputs' +import type { TLBounds, TLCallbacks, TLPageState, TLShape } from '~types' export interface TLContextType { id?: string diff --git a/packages/core/src/hooks/useZoomEvents.ts b/packages/core/src/hooks/useZoomEvents.ts index 39aa525bf..3e67b2b1e 100644 --- a/packages/core/src/hooks/useZoomEvents.ts +++ b/packages/core/src/hooks/useZoomEvents.ts @@ -1,8 +1,8 @@ -import * as React from 'react' -import { useTLContext } from './useTLContext' -import { Handler, useGesture, WebKitGestureEvent } from '@use-gesture/react' import { Vec } from '@tldraw/vec' +import { Handler, WebKitGestureEvent, useGesture } from '@use-gesture/react' +import * as React from 'react' import Utils from '~utils' +import { useTLContext } from './useTLContext' // Capture zoom gestures (pinches, wheels and pans) export function useZoomEvents( diff --git a/packages/core/src/inputs.ts b/packages/core/src/inputs.ts index e8ea47c79..07d7ac204 100644 --- a/packages/core/src/inputs.ts +++ b/packages/core/src/inputs.ts @@ -1,7 +1,7 @@ +import { Vec } from '@tldraw/vec' import type React from 'react' import type { TLBounds, TLKeyboardInfo, TLPointerInfo } from './types' import { Utils } from './utils' -import { Vec } from '@tldraw/vec' const DOUBLE_CLICK_DURATION = 250 diff --git a/packages/core/src/test/ContextWrapper.tsx b/packages/core/src/test/ContextWrapper.tsx index 72443e6df..b47b1a550 100644 --- a/packages/core/src/test/ContextWrapper.tsx +++ b/packages/core/src/test/ContextWrapper.tsx @@ -1,10 +1,10 @@ import * as React from 'react' -import type { TLPageState, TLBounds } from '../types' +import type { BoxShape } from '~TLShapeUtil/TLShapeUtil.spec' +import { TLContext, TLContextType, useTLTheme } from '~hooks' +import { Inputs } from '~inputs' +import type { TLBounds, TLPageState } from '~types' import { mockDocument } from './mockDocument' import { mockUtils } from './mockUtils' -import { useTLTheme, TLContext, TLContextType } from '../hooks' -import { Inputs } from '~inputs' -import type { BoxShape } from '~TLShapeUtil/TLShapeUtil.spec' export const ContextWrapper = ({ children }: { children: any }) => { useTLTheme() diff --git a/packages/core/src/test/renderWithContext.tsx b/packages/core/src/test/renderWithContext.tsx index 0afaa6d73..9137d951c 100644 --- a/packages/core/src/test/renderWithContext.tsx +++ b/packages/core/src/test/renderWithContext.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { render } from '@testing-library/react' +import * as React from 'react' import { ContextWrapper } from './ContextWrapper' export const renderWithContext = (children: React.ReactNode) => { diff --git a/packages/core/src/test/renderWithSvg.tsx b/packages/core/src/test/renderWithSvg.tsx index 652382046..bb854b721 100644 --- a/packages/core/src/test/renderWithSvg.tsx +++ b/packages/core/src/test/renderWithSvg.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { render } from '@testing-library/react' +import * as React from 'react' import { ContextWrapper } from './ContextWrapper' export const renderWithSvg = (children: React.ReactNode) => { diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 21391245f..97b44ff00 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -1,5 +1,4 @@ /* --------------------- Primary -------------------- */ - import type React from 'react' export enum TLPerformanceMode { diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index cdb565ef1..3b55be41a 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -1,4 +1,5 @@ import { Utils } from './utils' + export { Utils } from './utils' export default Utils diff --git a/packages/core/src/utils/utils.ts b/packages/core/src/utils/utils.ts index 590bcd8a2..cdcb31abe 100644 --- a/packages/core/src/utils/utils.ts +++ b/packages/core/src/utils/utils.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-extra-semi */ -import type React from 'react' -import { TLBounds, TLBoundsCorner, SnapPoints, Snap, TLBoundsEdge } from '../types' import { Vec } from '@tldraw/vec' -import './polyfills' +import type React from 'react' import type { Patch, TLBoundsWithCenter } from '~index' +import { Snap, SnapPoints, TLBounds, TLBoundsCorner, TLBoundsEdge } from '~types' +import './polyfills' const TAU = Math.PI * 2 diff --git a/packages/curve/README.md b/packages/curve/README.md index 4277b1238..7122b7a42 100644 --- a/packages/curve/README.md +++ b/packages/curve/README.md @@ -295,9 +295,8 @@ Next, use `TLShapeUtil.Component` to create a second component for your shape's ```tsx // BoxComponent.ts - +import { SVGContainer, shapeComponent } from '@tldraw/core' import * as React from 'react' -import { shapeComponent, SVGContainer } from '@tldraw/core' import type { BoxShape } from './BoxShape' export const BoxComponent = TLShapeUtil.Component( @@ -374,8 +373,7 @@ Next, create a "shape util" for your shape. This is a class that extends `TLShap ```ts // BoxUtil.ts - -import { Utils, TLBounds, TLShapeUtil } from '@tldraw/core' +import { TLBounds, TLShapeUtil, Utils } from '@tldraw/core' import { BoxComponent } from './BoxComponent' import { BoxIndicator } from './BoxIndicator' import type { BoxShape } from './BoxShape' diff --git a/packages/tldraw/src/Tldraw.spec.tsx b/packages/tldraw/src/Tldraw.spec.tsx index 1c4ea5390..193078d45 100644 --- a/packages/tldraw/src/Tldraw.spec.tsx +++ b/packages/tldraw/src/Tldraw.spec.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { render, waitFor } from '@testing-library/react' +import * as React from 'react' import { Tldraw } from './Tldraw' describe('Tldraw', () => { diff --git a/packages/tldraw/src/Tldraw.tsx b/packages/tldraw/src/Tldraw.tsx index 23d97f424..31125a536 100644 --- a/packages/tldraw/src/Tldraw.tsx +++ b/packages/tldraw/src/Tldraw.tsx @@ -1,27 +1,27 @@ -import * as React from 'react' import { Renderer } from '@tldraw/core' +import * as React from 'react' +import { ErrorBoundary as _Errorboundary } from 'react-error-boundary' import { IntlProvider } from 'react-intl' -import { styled, dark } from '~styles' -import { TDDocument, TDStatus } from '~types' -import { TldrawApp, TDCallbacks } from '~state' -import { - TldrawContext, - useStylesheet, - useTranslation, - useKeyboardShortcuts, - useTldrawApp, - ContainerContext, -} from '~hooks' -import { shapeUtils } from '~state/shapes' +import { ContextMenu } from '~components/ContextMenu' +import { ErrorFallback } from '~components/ErrorFallback' +import { FocusButton } from '~components/FocusButton' +import { Loading } from '~components/Loading' import { ToolsPanel } from '~components/ToolsPanel' import { TopPanel } from '~components/TopPanel' -import { ContextMenu } from '~components/ContextMenu' -import { FocusButton } from '~components/FocusButton' -import { TLDR } from '~state/TLDR' import { GRID_SIZE } from '~constants' -import { Loading } from '~components/Loading' -import { ErrorBoundary as _Errorboundary } from 'react-error-boundary' -import { ErrorFallback } from '~components/ErrorFallback' +import { + ContainerContext, + TldrawContext, + useKeyboardShortcuts, + useStylesheet, + useTldrawApp, + useTranslation, +} from '~hooks' +import { TDCallbacks, TldrawApp } from '~state' +import { TLDR } from '~state/TLDR' +import { shapeUtils } from '~state/shapes' +import { dark, styled } from '~styles' +import { TDDocument, TDStatus } from '~types' const ErrorBoundary = _Errorboundary as any diff --git a/packages/tldraw/src/components/ContextMenu/ContextMenu.test.tsx b/packages/tldraw/src/components/ContextMenu/ContextMenu.test.tsx index d690ca6e9..91a088039 100644 --- a/packages/tldraw/src/components/ContextMenu/ContextMenu.test.tsx +++ b/packages/tldraw/src/components/ContextMenu/ContextMenu.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react' -import { ContextMenu } from './ContextMenu' import { renderWithContext, renderWithIntlProvider } from '~test' +import { ContextMenu } from './ContextMenu' describe('context menu', () => { test('mounts component without crashing', () => { diff --git a/packages/tldraw/src/components/ContextMenu/ContextMenu.tsx b/packages/tldraw/src/components/ContextMenu/ContextMenu.tsx index fd9ef2cdc..a3997b567 100644 --- a/packages/tldraw/src/components/ContextMenu/ContextMenu.tsx +++ b/packages/tldraw/src/components/ContextMenu/ContextMenu.tsx @@ -1,8 +1,4 @@ -import * as React from 'react' -import { styled } from '~styles' import * as RadixContextMenu from '@radix-ui/react-context-menu' -import { useContainer, useTldrawApp } from '~hooks' -import { TDSnapshot, AlignType, DistributeType, StretchType, TDExportType } from '~types' import { AlignBottomIcon, AlignCenterHorizontallyIcon, @@ -15,11 +11,15 @@ import { StretchHorizontallyIcon, StretchVerticallyIcon, } from '@radix-ui/react-icons' +import * as React from 'react' +import { FormattedMessage, useIntl } from 'react-intl' import { Divider } from '~components/Primitives/Divider' import { MenuContent } from '~components/Primitives/MenuContent' import { RowButton, RowButtonProps } from '~components/Primitives/RowButton' import { ToolButton, ToolButtonProps } from '~components/Primitives/ToolButton' -import { FormattedMessage, useIntl } from 'react-intl' +import { useContainer, useTldrawApp } from '~hooks' +import { styled } from '~styles' +import { AlignType, DistributeType, StretchType, TDExportType, TDSnapshot } from '~types' const numberOfSelectedIdsSelector = (s: TDSnapshot) => { return s.document.pageStates[s.appState.currentPageId].selectedIds.length diff --git a/packages/tldraw/src/components/Primitives/DropdownMenu/DMCheckboxItem.tsx b/packages/tldraw/src/components/Primitives/DropdownMenu/DMCheckboxItem.tsx index 25e32b1d5..8276a65fa 100644 --- a/packages/tldraw/src/components/Primitives/DropdownMenu/DMCheckboxItem.tsx +++ b/packages/tldraw/src/components/Primitives/DropdownMenu/DMCheckboxItem.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { CheckboxItem } from '@radix-ui/react-dropdown-menu' +import * as React from 'react' import { RowButton, RowButtonProps } from '~components/Primitives/RowButton' import { preventEvent } from '~components/preventEvent' diff --git a/packages/tldraw/src/components/Primitives/DropdownMenu/DMContent.tsx b/packages/tldraw/src/components/Primitives/DropdownMenu/DMContent.tsx index 6ca7c75bd..1f785defe 100644 --- a/packages/tldraw/src/components/Primitives/DropdownMenu/DMContent.tsx +++ b/packages/tldraw/src/components/Primitives/DropdownMenu/DMContent.tsx @@ -1,9 +1,9 @@ -import * as React from 'react' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { styled } from '~styles/stitches.config' +import * as React from 'react' import { MenuContent } from '~components/Primitives/MenuContent' import { stopPropagation } from '~components/stopPropagation' import { useContainer } from '~hooks' +import { styled } from '~styles/stitches.config' export interface DMContentProps { variant?: 'menu' | 'horizontal' diff --git a/packages/tldraw/src/components/Primitives/DropdownMenu/DMItem.tsx b/packages/tldraw/src/components/Primitives/DropdownMenu/DMItem.tsx index 3475e805c..3ae40a5d0 100644 --- a/packages/tldraw/src/components/Primitives/DropdownMenu/DMItem.tsx +++ b/packages/tldraw/src/components/Primitives/DropdownMenu/DMItem.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Item } from '@radix-ui/react-dropdown-menu' +import * as React from 'react' import { RowButton, RowButtonProps } from '~components/Primitives/RowButton' export function DMItem({ diff --git a/packages/tldraw/src/components/Primitives/DropdownMenu/DMSubMenu.tsx b/packages/tldraw/src/components/Primitives/DropdownMenu/DMSubMenu.tsx index e3ba83d60..a3237357a 100644 --- a/packages/tldraw/src/components/Primitives/DropdownMenu/DMSubMenu.tsx +++ b/packages/tldraw/src/components/Primitives/DropdownMenu/DMSubMenu.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' import { Arrow, Sub, SubContent, SubTrigger } from '@radix-ui/react-dropdown-menu' -import { RowButton } from '~components/Primitives/RowButton' +import * as React from 'react' import { MenuContent } from '~components/Primitives/MenuContent' +import { RowButton } from '~components/Primitives/RowButton' export interface DMSubMenuProps { label: string diff --git a/packages/tldraw/src/components/Primitives/DropdownMenu/DMTriggerIcon.tsx b/packages/tldraw/src/components/Primitives/DropdownMenu/DMTriggerIcon.tsx index dafa62e70..fb4db4e7a 100644 --- a/packages/tldraw/src/components/Primitives/DropdownMenu/DMTriggerIcon.tsx +++ b/packages/tldraw/src/components/Primitives/DropdownMenu/DMTriggerIcon.tsx @@ -1,5 +1,5 @@ -import * as React from 'react' import { Trigger } from '@radix-ui/react-dropdown-menu' +import * as React from 'react' import { ToolButton, ToolButtonProps } from '~components/Primitives/ToolButton' interface DMTriggerIconProps extends ToolButtonProps { diff --git a/packages/tldraw/src/components/Primitives/Kbd/Kbd.tsx b/packages/tldraw/src/components/Primitives/Kbd/Kbd.tsx index 60e47f9dc..a7b87631d 100644 --- a/packages/tldraw/src/components/Primitives/Kbd/Kbd.tsx +++ b/packages/tldraw/src/components/Primitives/Kbd/Kbd.tsx @@ -1,6 +1,6 @@ +import { Utils } from '@tldraw/core' import * as React from 'react' import { styled } from '~styles' -import { Utils } from '@tldraw/core' /* -------------------------------------------------- */ /* Keyboard Shortcut */ diff --git a/packages/tldraw/src/components/Primitives/RowButton/RowButton.tsx b/packages/tldraw/src/components/Primitives/RowButton/RowButton.tsx index c1a32951f..71632351e 100644 --- a/packages/tldraw/src/components/Primitives/RowButton/RowButton.tsx +++ b/packages/tldraw/src/components/Primitives/RowButton/RowButton.tsx @@ -1,9 +1,9 @@ import { ItemIndicator } from '@radix-ui/react-dropdown-menu' -import { ChevronRightIcon, CheckIcon } from '@radix-ui/react-icons' +import { CheckIcon, ChevronRightIcon } from '@radix-ui/react-icons' import * as React from 'react' -import { breakpoints } from '~components/breakpoints' import { Kbd } from '~components/Primitives/Kbd' import { SmallIcon } from '~components/Primitives/SmallIcon' +import { breakpoints } from '~components/breakpoints' import { styled } from '~styles' export interface RowButtonProps { diff --git a/packages/tldraw/src/components/Primitives/TextField/TextField.tsx b/packages/tldraw/src/components/Primitives/TextField/TextField.tsx index 96cbd4e97..475665152 100644 --- a/packages/tldraw/src/components/Primitives/TextField/TextField.tsx +++ b/packages/tldraw/src/components/Primitives/TextField/TextField.tsx @@ -1,6 +1,6 @@ import * as React from 'react' +import { SmallIcon } from '~components/Primitives/SmallIcon' import { styled } from '~styles' -import { SmallIcon } from '../SmallIcon' export interface TextFieldProps extends React.HTMLProps { icon?: React.ReactElement diff --git a/packages/tldraw/src/components/Primitives/ToolButton/ToolButton.tsx b/packages/tldraw/src/components/Primitives/ToolButton/ToolButton.tsx index 90e7df7e7..1598afd41 100644 --- a/packages/tldraw/src/components/Primitives/ToolButton/ToolButton.tsx +++ b/packages/tldraw/src/components/Primitives/ToolButton/ToolButton.tsx @@ -1,6 +1,6 @@ import * as React from 'react' -import { breakpoints } from '~components/breakpoints' import { Tooltip } from '~components/Primitives/Tooltip' +import { breakpoints } from '~components/breakpoints' import { useTldrawApp } from '~hooks' import { styled } from '~styles' diff --git a/packages/tldraw/src/components/ToolsPanel/ActionButton.tsx b/packages/tldraw/src/components/ToolsPanel/ActionButton.tsx index e2318faec..9b8ee2031 100644 --- a/packages/tldraw/src/components/ToolsPanel/ActionButton.tsx +++ b/packages/tldraw/src/components/ToolsPanel/ActionButton.tsx @@ -1,13 +1,16 @@ -import * as React from 'react' -import { Tooltip } from '~components/Primitives/Tooltip/Tooltip' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { useTldrawApp } from '~hooks' -import { styled } from '~styles' -import { AlignType, TDSnapshot, DistributeType, StretchType } from '~types' import { + AlignBottomIcon, + AlignCenterHorizontallyIcon, + AlignCenterVerticallyIcon, + AlignLeftIcon, + AlignRightIcon, + AlignTopIcon, + AngleIcon, ArrowDownIcon, ArrowUpIcon, AspectRatioIcon, + BoxIcon, CopyIcon, DotsHorizontalIcon, GroupIcon, @@ -16,23 +19,20 @@ import { PinBottomIcon, PinTopIcon, RotateCounterClockwiseIcon, - AlignBottomIcon, - AlignCenterHorizontallyIcon, - AlignCenterVerticallyIcon, - AlignLeftIcon, - AlignRightIcon, - AlignTopIcon, SpaceEvenlyHorizontallyIcon, SpaceEvenlyVerticallyIcon, StretchHorizontallyIcon, StretchVerticallyIcon, - BoxIcon, - AngleIcon, } from '@radix-ui/react-icons' -import { DMContent } from '~components/Primitives/DropdownMenu' -import { Divider } from '~components/Primitives/Divider' -import { ToolButton } from '~components/Primitives/ToolButton' +import * as React from 'react' import { useIntl } from 'react-intl' +import { Divider } from '~components/Primitives/Divider' +import { DMContent } from '~components/Primitives/DropdownMenu' +import { ToolButton } from '~components/Primitives/ToolButton' +import { Tooltip } from '~components/Primitives/Tooltip/Tooltip' +import { useTldrawApp } from '~hooks' +import { styled } from '~styles' +import { AlignType, DistributeType, StretchType, TDSnapshot } from '~types' const dockPositionState = (s: TDSnapshot) => s.settings.dockPosition diff --git a/packages/tldraw/src/components/ToolsPanel/BackToContent.tsx b/packages/tldraw/src/components/ToolsPanel/BackToContent.tsx index eda5e491a..f63660044 100644 --- a/packages/tldraw/src/components/ToolsPanel/BackToContent.tsx +++ b/packages/tldraw/src/components/ToolsPanel/BackToContent.tsx @@ -1,10 +1,10 @@ import * as React from 'react' import { FormattedMessage } from 'react-intl' +import { MenuContent } from '~components/Primitives/MenuContent' +import { RowButton } from '~components/Primitives/RowButton' +import { useTldrawApp } from '~hooks' import { styled } from '~styles' import type { TDSnapshot } from '~types' -import { useTldrawApp } from '~hooks' -import { RowButton } from '~components/Primitives/RowButton' -import { MenuContent } from '~components/Primitives/MenuContent' const isEmptyCanvasSelector = (s: TDSnapshot) => { return ( diff --git a/packages/tldraw/src/components/ToolsPanel/DeleteButton.tsx b/packages/tldraw/src/components/ToolsPanel/DeleteButton.tsx index 51c2cad53..373f68ee5 100644 --- a/packages/tldraw/src/components/ToolsPanel/DeleteButton.tsx +++ b/packages/tldraw/src/components/ToolsPanel/DeleteButton.tsx @@ -1,9 +1,9 @@ import * as React from 'react' -import { Tooltip } from '~components/Primitives/Tooltip' -import { useTldrawApp } from '~hooks' -import { ToolButton } from '~components/Primitives/ToolButton' -import { TrashIcon } from '~components/Primitives/icons' import { useIntl } from 'react-intl' +import { ToolButton } from '~components/Primitives/ToolButton' +import { Tooltip } from '~components/Primitives/Tooltip' +import { TrashIcon } from '~components/Primitives/icons' +import { useTldrawApp } from '~hooks' export function DeleteButton() { const app = useTldrawApp() diff --git a/packages/tldraw/src/components/ToolsPanel/HelpPanel.tsx b/packages/tldraw/src/components/ToolsPanel/HelpPanel.tsx index 311ff21c6..c897105c5 100644 --- a/packages/tldraw/src/components/ToolsPanel/HelpPanel.tsx +++ b/packages/tldraw/src/components/ToolsPanel/HelpPanel.tsx @@ -1,24 +1,24 @@ -import * as React from 'react' -import * as Popover from '@radix-ui/react-popover' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { FormattedMessage } from 'react-intl' -import { styled } from '~styles' -import { useTldrawApp } from '~hooks' -import { TDSnapshot } from '~types' -import { breakpoints } from '~components/breakpoints' import { GitHubLogoIcon, - QuestionMarkIcon, HeartFilledIcon, + QuestionMarkIcon, TwitterLogoIcon, } from '@radix-ui/react-icons' -import { RowButton } from '~components/Primitives/RowButton' +import * as Popover from '@radix-ui/react-popover' +import * as React from 'react' +import { FormattedMessage } from 'react-intl' +import { Divider } from '~components/Primitives/Divider' import { MenuContent } from '~components/Primitives/MenuContent' +import { RowButton } from '~components/Primitives/RowButton' import { SmallIcon } from '~components/Primitives/SmallIcon' import { DiscordIcon } from '~components/Primitives/icons' import { LanguageMenu } from '~components/TopPanel/LanguageMenu/LanguageMenu' +import { breakpoints } from '~components/breakpoints' +import { useTldrawApp } from '~hooks' +import { styled } from '~styles' +import { TDSnapshot } from '~types' import { KeyboardShortcutDialog } from './keyboardShortcutDialog' -import { Divider } from '~components/Primitives/Divider' const isDebugModeSelector = (s: TDSnapshot) => s.settings.isDebugMode const dockPositionState = (s: TDSnapshot) => s.settings.dockPosition diff --git a/packages/tldraw/src/components/ToolsPanel/LockButton.tsx b/packages/tldraw/src/components/ToolsPanel/LockButton.tsx index 1123ed6fe..0d267f2e0 100644 --- a/packages/tldraw/src/components/ToolsPanel/LockButton.tsx +++ b/packages/tldraw/src/components/ToolsPanel/LockButton.tsx @@ -1,8 +1,8 @@ -import * as React from 'react' import { LockClosedIcon, LockOpen1Icon } from '@radix-ui/react-icons' +import * as React from 'react' +import { ToolButton } from '~components/Primitives/ToolButton' import { Tooltip } from '~components/Primitives/Tooltip' import { useTldrawApp } from '~hooks' -import { ToolButton } from '~components/Primitives/ToolButton' import type { TDSnapshot } from '~types' const isToolLockedSelector = (s: TDSnapshot) => s.appState.isToolLocked diff --git a/packages/tldraw/src/components/ToolsPanel/PrimaryTools.tsx b/packages/tldraw/src/components/ToolsPanel/PrimaryTools.tsx index 2df4c9436..1733407a7 100644 --- a/packages/tldraw/src/components/ToolsPanel/PrimaryTools.tsx +++ b/packages/tldraw/src/components/ToolsPanel/PrimaryTools.tsx @@ -1,5 +1,3 @@ -import * as React from 'react' -import { useIntl } from 'react-intl' import { ArrowTopRightIcon, CursorArrowIcon, @@ -8,14 +6,16 @@ import { Pencil2Icon, TextIcon, } from '@radix-ui/react-icons' -import { TDSnapshot, TDShapeType } from '~types' -import { useTldrawApp } from '~hooks' -import { ToolButtonWithTooltip } from '~components/Primitives/ToolButton' +import * as React from 'react' +import { useIntl } from 'react-intl' import { Panel } from '~components/Primitives/Panel' -import { ShapesMenu } from './ShapesMenu' +import { ToolButtonWithTooltip } from '~components/Primitives/ToolButton' import { EraserIcon } from '~components/Primitives/icons' -import { styled } from '~styles/stitches.config' import { breakpoints } from '~components/breakpoints' +import { useTldrawApp } from '~hooks' +import { styled } from '~styles/stitches.config' +import { TDShapeType, TDSnapshot } from '~types' +import { ShapesMenu } from './ShapesMenu' const activeToolSelector = (s: TDSnapshot) => s.appState.activeTool const toolLockedSelector = (s: TDSnapshot) => s.appState.isToolLocked diff --git a/packages/tldraw/src/components/ToolsPanel/ShapesMenu.tsx b/packages/tldraw/src/components/ToolsPanel/ShapesMenu.tsx index 07f335c36..9698bc6f5 100644 --- a/packages/tldraw/src/components/ToolsPanel/ShapesMenu.tsx +++ b/packages/tldraw/src/components/ToolsPanel/ShapesMenu.tsx @@ -1,13 +1,13 @@ -import * as React from 'react' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' +import { CircleIcon, SquareIcon, VercelLogoIcon } from '@radix-ui/react-icons' +import * as React from 'react' +import { useIntl } from 'react-intl' import { Panel } from '~components/Primitives/Panel' import { ToolButton } from '~components/Primitives/ToolButton' -import { TDShapeType, TDSnapshot, TDToolType } from '~types' -import { useTldrawApp } from '~hooks' -import { SquareIcon, CircleIcon, VercelLogoIcon } from '@radix-ui/react-icons' import { Tooltip } from '~components/Primitives/Tooltip' import { LineIcon } from '~components/Primitives/icons' -import { useIntl } from 'react-intl' +import { useTldrawApp } from '~hooks' +import { TDShapeType, TDSnapshot, TDToolType } from '~types' interface ShapesMenuProps { activeTool: TDToolType diff --git a/packages/tldraw/src/components/ToolsPanel/StatusBar.tsx b/packages/tldraw/src/components/ToolsPanel/StatusBar.tsx index 8618a50c5..48e972ce2 100644 --- a/packages/tldraw/src/components/ToolsPanel/StatusBar.tsx +++ b/packages/tldraw/src/components/ToolsPanel/StatusBar.tsx @@ -1,8 +1,8 @@ import * as React from 'react' -import { useTldrawApp } from '~hooks' -import type { TDSnapshot } from '~types' -import { styled } from '~styles' import { breakpoints } from '~components/breakpoints' +import { useTldrawApp } from '~hooks' +import { styled } from '~styles' +import type { TDSnapshot } from '~types' const statusSelector = (s: TDSnapshot) => s.appState.status const activeToolSelector = (s: TDSnapshot) => s.appState.activeTool diff --git a/packages/tldraw/src/components/ToolsPanel/ToolsPanel.test.tsx b/packages/tldraw/src/components/ToolsPanel/ToolsPanel.test.tsx index 056a23958..3e7adb2da 100644 --- a/packages/tldraw/src/components/ToolsPanel/ToolsPanel.test.tsx +++ b/packages/tldraw/src/components/ToolsPanel/ToolsPanel.test.tsx @@ -1,6 +1,6 @@ import * as React from 'react' -import { ToolsPanel } from './ToolsPanel' import { renderWithContext, renderWithIntlProvider } from '~test' +import { ToolsPanel } from './ToolsPanel' describe('tools panel', () => { test('mounts component without crashing', () => { diff --git a/packages/tldraw/src/components/ToolsPanel/ToolsPanel.tsx b/packages/tldraw/src/components/ToolsPanel/ToolsPanel.tsx index 48b093692..7bdc0ea9b 100644 --- a/packages/tldraw/src/components/ToolsPanel/ToolsPanel.tsx +++ b/packages/tldraw/src/components/ToolsPanel/ToolsPanel.tsx @@ -1,14 +1,14 @@ import * as React from 'react' +import { breakpoints } from '~components/breakpoints' +import { useTldrawApp } from '~hooks' import { styled } from '~styles' import type { TDSnapshot } from '~types' -import { useTldrawApp } from '~hooks' -import { StatusBar } from './StatusBar' -import { BackToContent } from './BackToContent' -import { PrimaryTools } from './PrimaryTools' import { ActionButton } from './ActionButton' +import { BackToContent } from './BackToContent' import { DeleteButton } from './DeleteButton' -import { breakpoints } from '~components/breakpoints' import { HelpPanel } from './HelpPanel' +import { PrimaryTools } from './PrimaryTools' +import { StatusBar } from './StatusBar' const isDebugModeSelector = (s: TDSnapshot) => s.settings.isDebugMode const dockPositionState = (s: TDSnapshot) => s.settings.dockPosition diff --git a/packages/tldraw/src/components/ToolsPanel/keyboardShortcutDialog.tsx b/packages/tldraw/src/components/ToolsPanel/keyboardShortcutDialog.tsx index 6ca766062..1b8bd64f6 100644 --- a/packages/tldraw/src/components/ToolsPanel/keyboardShortcutDialog.tsx +++ b/packages/tldraw/src/components/ToolsPanel/keyboardShortcutDialog.tsx @@ -1,12 +1,12 @@ -import * as React from 'react' import * as Dialog from '@radix-ui/react-dialog' import { Cross2Icon } from '@radix-ui/react-icons' +import * as React from 'react' import { FormattedMessage, useIntl } from 'react-intl' import { IconButton } from '~components/Primitives/IconButton' -import { RowButton } from '~components/Primitives/RowButton' -import { styled } from '~styles' -import { breakpoints } from '~components/breakpoints' import { Kbd } from '~components/Primitives/Kbd' +import { RowButton } from '~components/Primitives/RowButton' +import { breakpoints } from '~components/breakpoints' +import { styled } from '~styles' export function KeyboardShortcutDialog({ onOpenChange, diff --git a/packages/tldraw/src/components/TopPanel/LanguageMenu/LanguageMenu.tsx b/packages/tldraw/src/components/TopPanel/LanguageMenu/LanguageMenu.tsx index 2f99dc3a5..f3bafa7a5 100644 --- a/packages/tldraw/src/components/TopPanel/LanguageMenu/LanguageMenu.tsx +++ b/packages/tldraw/src/components/TopPanel/LanguageMenu/LanguageMenu.tsx @@ -1,12 +1,12 @@ -import * as React from 'react' import { ExternalLinkIcon } from '@radix-ui/react-icons' +import * as React from 'react' import { FormattedMessage } from 'react-intl' +import { Divider } from '~components/Primitives/Divider' import { DMCheckboxItem, DMContent, DMItem } from '~components/Primitives/DropdownMenu' import { SmallIcon } from '~components/Primitives/SmallIcon' import { useTldrawApp } from '~hooks' import { TDLanguage, TRANSLATIONS } from '~translations' import { TDSnapshot } from '~types' -import { Divider } from '~components/Primitives/Divider' const languageSelector = (s: TDSnapshot) => s.settings.language diff --git a/packages/tldraw/src/components/TopPanel/Menu/Menu.tsx b/packages/tldraw/src/components/TopPanel/Menu/Menu.tsx index 5e33eeec5..7f7bb7d23 100644 --- a/packages/tldraw/src/components/TopPanel/Menu/Menu.tsx +++ b/packages/tldraw/src/components/TopPanel/Menu/Menu.tsx @@ -1,14 +1,14 @@ -import * as React from 'react' -import { HamburgerMenuIcon } from '@radix-ui/react-icons' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { useTldrawApp } from '~hooks' -import { PreferencesMenu } from '../PreferencesMenu' -import { DMItem, DMContent, DMSubMenu, DMTriggerIcon } from '~components/Primitives/DropdownMenu' -import { useFileSystemHandlers } from '~hooks' -import { preventEvent } from '~components/preventEvent' -import { TDExportType, TDSnapshot } from '~types' -import { Divider } from '~components/Primitives/Divider' +import { HamburgerMenuIcon } from '@radix-ui/react-icons' +import * as React from 'react' import { FormattedMessage, useIntl } from 'react-intl' +import { Divider } from '~components/Primitives/Divider' +import { DMContent, DMItem, DMSubMenu, DMTriggerIcon } from '~components/Primitives/DropdownMenu' +import { preventEvent } from '~components/preventEvent' +import { useTldrawApp } from '~hooks' +import { useFileSystemHandlers } from '~hooks' +import { TDExportType, TDSnapshot } from '~types' +import { PreferencesMenu } from '../PreferencesMenu' interface MenuProps { readOnly: boolean diff --git a/packages/tldraw/src/components/TopPanel/MultiplayerMenu/MultiplayerMenu.tsx b/packages/tldraw/src/components/TopPanel/MultiplayerMenu/MultiplayerMenu.tsx index b6da9c189..8e4104f66 100644 --- a/packages/tldraw/src/components/TopPanel/MultiplayerMenu/MultiplayerMenu.tsx +++ b/packages/tldraw/src/components/TopPanel/MultiplayerMenu/MultiplayerMenu.tsx @@ -1,15 +1,15 @@ -import * as React from 'react' -import { CheckIcon, ClipboardIcon } from '@radix-ui/react-icons' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { useTldrawApp } from '~hooks' -import { DMItem, DMContent, DMTriggerIcon } from '~components/Primitives/DropdownMenu' -import { SmallIcon } from '~components/Primitives/SmallIcon' -import { TDAssetType, TDSnapshot } from '~types' -import { TLDR } from '~state/TLDR' +import { CheckIcon, ClipboardIcon } from '@radix-ui/react-icons' import { Utils } from '@tldraw/core' +import * as React from 'react' import { FormattedMessage } from 'react-intl' -import { MultiplayerIcon2 } from '~components/Primitives/icons/MultiplayerIcon2' import { Divider } from '~components/Primitives/Divider' +import { DMContent, DMItem, DMTriggerIcon } from '~components/Primitives/DropdownMenu' +import { SmallIcon } from '~components/Primitives/SmallIcon' +import { MultiplayerIcon2 } from '~components/Primitives/icons/MultiplayerIcon2' +import { useTldrawApp } from '~hooks' +import { TLDR } from '~state/TLDR' +import { TDAssetType, TDSnapshot } from '~types' const roomSelector = (state: TDSnapshot) => state.room diff --git a/packages/tldraw/src/components/TopPanel/PageMenu/PageMenu.tsx b/packages/tldraw/src/components/TopPanel/PageMenu/PageMenu.tsx index 4fa83e2ca..51344d16c 100644 --- a/packages/tldraw/src/components/TopPanel/PageMenu/PageMenu.tsx +++ b/packages/tldraw/src/components/TopPanel/PageMenu/PageMenu.tsx @@ -1,16 +1,16 @@ -import * as React from 'react' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { PlusIcon, CheckIcon } from '@radix-ui/react-icons' -import { PageOptionsDialog } from '../PageOptionsDialog' -import { styled } from '~styles' -import { useTldrawApp } from '~hooks' -import type { TDSnapshot } from '~types' -import { DMContent } from '~components/Primitives/DropdownMenu' -import { SmallIcon } from '~components/Primitives/SmallIcon' -import { RowButton } from '~components/Primitives/RowButton' -import { ToolButton } from '~components/Primitives/ToolButton' +import { CheckIcon, PlusIcon } from '@radix-ui/react-icons' +import * as React from 'react' import { FormattedMessage, useIntl } from 'react-intl' import { Divider } from '~components/Primitives/Divider' +import { DMContent } from '~components/Primitives/DropdownMenu' +import { RowButton } from '~components/Primitives/RowButton' +import { SmallIcon } from '~components/Primitives/SmallIcon' +import { ToolButton } from '~components/Primitives/ToolButton' +import { useTldrawApp } from '~hooks' +import { styled } from '~styles' +import type { TDSnapshot } from '~types' +import { PageOptionsDialog } from '../PageOptionsDialog' const sortedSelector = (s: TDSnapshot) => Object.values(s.document.pages).sort((a, b) => (a.childIndex || 0) - (b.childIndex || 0)) diff --git a/packages/tldraw/src/components/TopPanel/PageOptionsDialog/PageOptionsDialog.tsx b/packages/tldraw/src/components/TopPanel/PageOptionsDialog/PageOptionsDialog.tsx index f43bf96f9..fa332a56e 100644 --- a/packages/tldraw/src/components/TopPanel/PageOptionsDialog/PageOptionsDialog.tsx +++ b/packages/tldraw/src/components/TopPanel/PageOptionsDialog/PageOptionsDialog.tsx @@ -1,16 +1,16 @@ -import * as React from 'react' import * as Dialog from '@radix-ui/react-alert-dialog' import { MixerVerticalIcon, Pencil1Icon } from '@radix-ui/react-icons' -import type { TDSnapshot, TDPage } from '~types' -import { useContainer, useTldrawApp } from '~hooks' -import { RowButton, RowButtonProps } from '~components/Primitives/RowButton' -import { styled } from '~styles' +import * as React from 'react' +import { FormattedMessage, useIntl } from 'react-intl' import { Divider } from '~components/Primitives/Divider' import { IconButton } from '~components/Primitives/IconButton/IconButton' +import { RowButton, RowButtonProps } from '~components/Primitives/RowButton' import { SmallIcon } from '~components/Primitives/SmallIcon' -import { breakpoints } from '~components/breakpoints' import { TextField } from '~components/Primitives/TextField' -import { FormattedMessage, useIntl } from 'react-intl' +import { breakpoints } from '~components/breakpoints' +import { useContainer, useTldrawApp } from '~hooks' +import { styled } from '~styles' +import type { TDPage, TDSnapshot } from '~types' const canDeleteSelector = (s: TDSnapshot) => { return Object.keys(s.document.pages).length > 1 diff --git a/packages/tldraw/src/components/TopPanel/PreferencesMenu/PreferencesMenu.tsx b/packages/tldraw/src/components/TopPanel/PreferencesMenu/PreferencesMenu.tsx index 80dece76a..e82ec7744 100644 --- a/packages/tldraw/src/components/TopPanel/PreferencesMenu/PreferencesMenu.tsx +++ b/packages/tldraw/src/components/TopPanel/PreferencesMenu/PreferencesMenu.tsx @@ -1,10 +1,10 @@ import * as React from 'react' import { FormattedMessage, useIntl } from 'react-intl' +import { Divider } from '~components/Primitives/Divider' import { DMCheckboxItem, DMSubMenu } from '~components/Primitives/DropdownMenu' import { useTldrawApp } from '~hooks' -import { TDDockPosition, TDExportBackground, TDSnapshot } from '~types' import { styled } from '~styles' -import { Divider } from '~components/Primitives/Divider' +import { TDDockPosition, TDExportBackground, TDSnapshot } from '~types' const settingsSelector = (s: TDSnapshot) => s.settings diff --git a/packages/tldraw/src/components/TopPanel/StyleMenu/StyleMenu.tsx b/packages/tldraw/src/components/TopPanel/StyleMenu/StyleMenu.tsx index 295893fd1..f6605f521 100644 --- a/packages/tldraw/src/components/TopPanel/StyleMenu/StyleMenu.tsx +++ b/packages/tldraw/src/components/TopPanel/StyleMenu/StyleMenu.tsx @@ -1,9 +1,15 @@ -import * as React from 'react' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { strokes, fills, defaultTextStyle } from '~state/shapes/shared/shape-styles' +import { + TextAlignCenterIcon, + TextAlignJustifyIcon, + TextAlignLeftIcon, + TextAlignRightIcon, +} from '@radix-ui/react-icons' +import * as React from 'react' import { FormattedMessage } from 'react-intl' -import { useTldrawApp } from '~hooks' +import { Divider } from '~components/Primitives/Divider' import { DMCheckboxItem, DMContent, DMRadioItem } from '~components/Primitives/DropdownMenu' +import { ToolButton } from '~components/Primitives/ToolButton' import { CircleIcon, DashDashedIcon, @@ -14,27 +20,21 @@ import { SizeMediumIcon, SizeSmallIcon, } from '~components/Primitives/icons' -import { ToolButton } from '~components/Primitives/ToolButton' +import { breakpoints } from '~components/breakpoints' +import { preventEvent } from '~components/preventEvent' +import { useTldrawApp } from '~hooks' +import { defaultTextStyle, fills, strokes } from '~state/shapes/shared' +import { styled } from '~styles' import { - TDSnapshot, + AlignStyle, ColorStyle, DashStyle, - SizeStyle, - ShapeStyles, FontStyle, - AlignStyle, + ShapeStyles, + SizeStyle, TDShapeType, + TDSnapshot, } from '~types' -import { styled } from '~styles' -import { breakpoints } from '~components/breakpoints' -import { Divider } from '~components/Primitives/Divider' -import { preventEvent } from '~components/preventEvent' -import { - TextAlignCenterIcon, - TextAlignJustifyIcon, - TextAlignLeftIcon, - TextAlignRightIcon, -} from '@radix-ui/react-icons' const currentStyleSelector = (s: TDSnapshot) => s.appState.currentStyle const selectedIdsSelector = (s: TDSnapshot) => diff --git a/packages/tldraw/src/components/TopPanel/TopPanel.tsx b/packages/tldraw/src/components/TopPanel/TopPanel.tsx index 1eb57d687..c12b772f6 100644 --- a/packages/tldraw/src/components/TopPanel/TopPanel.tsx +++ b/packages/tldraw/src/components/TopPanel/TopPanel.tsx @@ -1,14 +1,14 @@ import * as React from 'react' -import { Menu } from './Menu/Menu' -import { styled } from '~styles' -import { PageMenu } from './PageMenu' -import { ZoomMenu } from './ZoomMenu' -import { StyleMenu } from './StyleMenu' import { Panel } from '~components/Primitives/Panel' import { ToolButton } from '~components/Primitives/ToolButton' import { UndoIcon } from '~components/Primitives/icons' import { useTldrawApp } from '~hooks' +import { styled } from '~styles' +import { Menu } from './Menu/Menu' import { MultiplayerMenu } from './MultiplayerMenu' +import { PageMenu } from './PageMenu' +import { StyleMenu } from './StyleMenu' +import { ZoomMenu } from './ZoomMenu' interface TopPanelProps { readOnly: boolean diff --git a/packages/tldraw/src/components/TopPanel/ZoomMenu/ZoomMenu.tsx b/packages/tldraw/src/components/TopPanel/ZoomMenu/ZoomMenu.tsx index b47c1fa15..bca53cb6f 100644 --- a/packages/tldraw/src/components/TopPanel/ZoomMenu/ZoomMenu.tsx +++ b/packages/tldraw/src/components/TopPanel/ZoomMenu/ZoomMenu.tsx @@ -1,12 +1,12 @@ -import * as React from 'react' -import { useTldrawApp } from '~hooks' -import type { TDSnapshot } from '~types' -import { styled } from '~styles' import * as DropdownMenu from '@radix-ui/react-dropdown-menu' -import { DMItem, DMContent } from '~components/Primitives/DropdownMenu' +import * as React from 'react' +import { FormattedMessage } from 'react-intl' +import { DMContent, DMItem } from '~components/Primitives/DropdownMenu' import { ToolButton } from '~components/Primitives/ToolButton' import { preventEvent } from '~components/preventEvent' -import { FormattedMessage } from 'react-intl' +import { useTldrawApp } from '~hooks' +import { styled } from '~styles' +import type { TDSnapshot } from '~types' const zoomSelector = (s: TDSnapshot) => s.document.pageStates[s.appState.currentPageId].camera.zoom diff --git a/packages/tldraw/src/constants.ts b/packages/tldraw/src/constants.ts index 348619435..e8c8ae4a5 100644 --- a/packages/tldraw/src/constants.ts +++ b/packages/tldraw/src/constants.ts @@ -1,3 +1,5 @@ +import type { Easing } from '~types' + export const LETTER_SPACING = '-0.03em' export const LINE_HEIGHT = 1 export const GRID_SIZE = 8 @@ -12,7 +14,6 @@ export const VERY_SLOW_SPEED = 2.5 export const GHOSTED_OPACITY = 0.3 export const DEAD_ZONE = 3 export const LABEL_POINT = [0.5, 0.5] -import type { Easing } from '~types' export const PI2 = Math.PI * 2 diff --git a/packages/tldraw/src/hooks/index.ts b/packages/tldraw/src/hooks/index.ts index b55955477..d112fac7b 100644 --- a/packages/tldraw/src/hooks/index.ts +++ b/packages/tldraw/src/hooks/index.ts @@ -1,7 +1,7 @@ -export * from './useKeyboardShortcuts' -export * from './useTldrawApp' -export * from './useTheme' -export * from './useStylesheet' -export * from './useFileSystemHandlers' export * from './useFileSystem' +export * from './useFileSystemHandlers' +export * from './useKeyboardShortcuts' +export * from './useStylesheet' +export * from './useTheme' +export * from './useTldrawApp' export * from './useTranslation' diff --git a/packages/tldraw/src/hooks/useKeyboardShortcuts.tsx b/packages/tldraw/src/hooks/useKeyboardShortcuts.tsx index 5a466c697..a3fe7890c 100644 --- a/packages/tldraw/src/hooks/useKeyboardShortcuts.tsx +++ b/packages/tldraw/src/hooks/useKeyboardShortcuts.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { useHotkeys } from 'react-hotkeys-hook' -import { AlignStyle, TDShapeType } from '~types' import { useFileSystemHandlers, useTldrawApp } from '~hooks' +import { AlignStyle, TDShapeType } from '~types' export function useKeyboardShortcuts(ref: React.RefObject) { const app = useTldrawApp() diff --git a/packages/tldraw/src/hooks/useTranslation.ts b/packages/tldraw/src/hooks/useTranslation.ts index fca19ff91..6851a864c 100644 --- a/packages/tldraw/src/hooks/useTranslation.ts +++ b/packages/tldraw/src/hooks/useTranslation.ts @@ -1,5 +1,5 @@ import * as React from 'react' -import { getTranslation, TDLanguage } from '../translations/translations' +import { TDLanguage, getTranslation } from '~translations' export function useTranslation(locale?: TDLanguage) { return React.useMemo(() => { diff --git a/packages/tldraw/src/state/IdbClipboard.ts b/packages/tldraw/src/state/IdbClipboard.ts index dd2b88a49..c827f785e 100644 --- a/packages/tldraw/src/state/IdbClipboard.ts +++ b/packages/tldraw/src/state/IdbClipboard.ts @@ -1,4 +1,4 @@ -import { get, set, del } from 'idb-keyval' +import { del, get, set } from 'idb-keyval' // Used for clipboard diff --git a/packages/tldraw/src/state/StateManager/StateManager.ts b/packages/tldraw/src/state/StateManager/StateManager.ts index abefd4f53..950ebdeb7 100644 --- a/packages/tldraw/src/state/StateManager/StateManager.ts +++ b/packages/tldraw/src/state/StateManager/StateManager.ts @@ -1,9 +1,9 @@ -import createVanilla, { StoreApi } from 'zustand/vanilla' -import create, { UseBoundStore } from 'zustand' -import * as idb from 'idb-keyval' -import { deepCopy } from './copy' -import type { Patch, Command } from '../../types' import { Utils } from '@tldraw/core' +import * as idb from 'idb-keyval' +import create, { UseBoundStore } from 'zustand' +import createVanilla, { StoreApi } from 'zustand/vanilla' +import type { Command, Patch } from '~types' +import { deepCopy } from './copy' export class StateManager> { /** diff --git a/packages/tldraw/src/state/TLDR.ts b/packages/tldraw/src/state/TLDR.ts index 397d58791..bfae71caa 100644 --- a/packages/tldraw/src/state/TLDR.ts +++ b/packages/tldraw/src/state/TLDR.ts @@ -1,24 +1,24 @@ -import { TLBounds, TLTransformInfo, Utils, TLPageState } from '@tldraw/core' +import { TLBounds, TLPageState, TLTransformInfo, Utils } from '@tldraw/core' +import { intersectRayBounds, intersectRayEllipse, intersectRayLineSegment } from '@tldraw/intersect' +import { Vec } from '@tldraw/vec' +import { BINDING_DISTANCE } from '~constants' import { - TDSnapshot, + ArrowShape, ShapesWithProp, - TDShape, TDBinding, + TDExportType, + TDHandle, TDPage, + TDShape, + TDShapeType, + TDSnapshot, TldrawCommand, TldrawPatch, - TDShapeType, - ArrowShape, - TDHandle, - TDExportType, } from '~types' -import { Vec } from '@tldraw/vec' -import type { TDShapeUtil } from './shapes/TDShapeUtil' -import { getShapeUtil } from './shapes' import { deepCopy } from './StateManager/copy' -import { intersectRayBounds, intersectRayEllipse, intersectRayLineSegment } from '@tldraw/intersect' +import { getShapeUtil } from './shapes' +import type { TDShapeUtil } from './shapes/TDShapeUtil' import { getTrianglePoints } from './shapes/TriangleUtil/triangleHelpers' -import { BINDING_DISTANCE } from '~constants' const isDev = process.env.NODE_ENV === 'development' export class TLDR { diff --git a/packages/tldraw/src/state/TldrawApp.spec.ts b/packages/tldraw/src/state/TldrawApp.spec.ts index 12d34e7aa..6c243127f 100644 --- a/packages/tldraw/src/state/TldrawApp.spec.ts +++ b/packages/tldraw/src/state/TldrawApp.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { ArrowShape, ColorStyle, SessionType, TDShapeType } from '~types' import { deepCopy } from './StateManager/copy' import type { SelectTool } from './tools/SelectTool' diff --git a/packages/tldraw/src/state/TldrawApp.ts b/packages/tldraw/src/state/TldrawApp.ts index 33612cdac..d124e7782 100644 --- a/packages/tldraw/src/state/TldrawApp.ts +++ b/packages/tldraw/src/state/TldrawApp.ts @@ -1,87 +1,87 @@ -import { Vec } from '@tldraw/vec' import { + TLBounds, TLBoundsEventHandler, TLBoundsHandleEventHandler, - TLKeyboardEventHandler, - TLShapeCloneHandler, TLCanvasEventHandler, + TLDropEventHandler, + TLKeyboardEventHandler, TLPageState, TLPinchEventHandler, TLPointerEventHandler, + TLShapeCloneHandler, TLWheelEventHandler, Utils, - TLBounds, - TLDropEventHandler, } from '@tldraw/core' +import { Vec } from '@tldraw/vec' import { - FlipType, - TDDocument, - MoveType, + FIT_TO_SCREEN_PADDING, + GRID_SIZE, + IMAGE_EXTENSIONS, + SVG_EXPORT_PADDING, + USER_COLORS, + VIDEO_EXTENSIONS, +} from '~constants' +import { shapeUtils } from '~state/shapes' +import { defaultStyle } from '~state/shapes/shared' +import { + AlignStyle, AlignType, - StretchType, + ArrowShape, DistributeType, + FlipType, + GroupShape, + MoveType, + SessionType, ShapeStyles, + StretchType, + TDAsset, + TDAssetType, + TDAssets, + TDBinding, + TDDocument, + TDExport, + TDExportBackground, + TDExportType, + TDPage, TDShape, TDShapeType, TDSnapshot, TDStatus, - TDPage, - TDBinding, - GroupShape, - TldrawCommand, - TDUser, - SessionType, TDToolType, - TDAssetType, - TDAsset, - TDAssets, - TDExport, - ArrowShape, - TDExportType, + TDUser, + TldrawCommand, TldrawPatch, - TDExportBackground, - AlignStyle, } from '~types' +import { getClipboard, setClipboard } from './IdbClipboard' +import { StateManager } from './StateManager' +import { deepCopy } from './StateManager/copy' +import { TLDR } from './TLDR' +import * as Commands from './commands' import { - migrate, FileSystemHandle, - loadFileHandle, - openFromFileSystem, - saveToFileSystem, - openAssetsFromFileSystem, fileToBase64, fileToText, getImageSizeFromSrc, getVideoSizeFromSrc, + loadFileHandle, + migrate, + openAssetsFromFileSystem, + openFromFileSystem, + saveToFileSystem, } from './data' -import { TLDR } from './TLDR' -import { shapeUtils } from '~state/shapes' -import { defaultStyle } from '~state/shapes/shared/shape-styles' -import * as Commands from './commands' -import { SessionArgsOfType, getSession, TldrawSession } from './sessions' -import { - USER_COLORS, - FIT_TO_SCREEN_PADDING, - GRID_SIZE, - IMAGE_EXTENSIONS, - VIDEO_EXTENSIONS, - SVG_EXPORT_PADDING, -} from '~constants' +import { SessionArgsOfType, TldrawSession, getSession } from './sessions' +import { clearPrevSize } from './shapes/shared/getTextSize' +import { ArrowTool } from './tools/ArrowTool' import type { BaseTool } from './tools/BaseTool' -import { SelectTool } from './tools/SelectTool' -import { EraseTool } from './tools/EraseTool' -import { TextTool } from './tools/TextTool' import { DrawTool } from './tools/DrawTool' import { EllipseTool } from './tools/EllipseTool' -import { RectangleTool } from './tools/RectangleTool' -import { TriangleTool } from './tools/TriangleTool' +import { EraseTool } from './tools/EraseTool' import { LineTool } from './tools/LineTool' -import { ArrowTool } from './tools/ArrowTool' +import { RectangleTool } from './tools/RectangleTool' +import { SelectTool } from './tools/SelectTool' import { StickyTool } from './tools/StickyTool' -import { StateManager } from './StateManager' -import { clearPrevSize } from './shapes/shared/getTextSize' -import { getClipboard, setClipboard } from './IdbClipboard' -import { deepCopy } from './StateManager/copy' +import { TextTool } from './tools/TextTool' +import { TriangleTool } from './tools/TriangleTool' const uuid = Utils.uniqueId() diff --git a/packages/tldraw/src/state/commands/alignShapes/alignShapes.spec.ts b/packages/tldraw/src/state/commands/alignShapes/alignShapes.spec.ts index 518a2943e..ef11c1534 100644 --- a/packages/tldraw/src/state/commands/alignShapes/alignShapes.spec.ts +++ b/packages/tldraw/src/state/commands/alignShapes/alignShapes.spec.ts @@ -1,5 +1,5 @@ import Vec from '@tldraw/vec' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { AlignType, TDShapeType } from '~types' describe('Align command', () => { diff --git a/packages/tldraw/src/state/commands/alignShapes/alignShapes.ts b/packages/tldraw/src/state/commands/alignShapes/alignShapes.ts index 9b9b75b94..4c1342c05 100644 --- a/packages/tldraw/src/state/commands/alignShapes/alignShapes.ts +++ b/packages/tldraw/src/state/commands/alignShapes/alignShapes.ts @@ -1,8 +1,8 @@ -import { Vec } from '@tldraw/vec' import { Utils } from '@tldraw/core' -import { AlignType, TldrawCommand, TDShapeType } from '~types' +import { Vec } from '@tldraw/vec' import { TLDR } from '~state/TLDR' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import { AlignType, TDShapeType, TldrawCommand } from '~types' export function alignShapes(app: TldrawApp, ids: string[], type: AlignType): TldrawCommand { const { currentPageId } = app diff --git a/packages/tldraw/src/state/commands/changePage/changePage.spec.ts b/packages/tldraw/src/state/commands/changePage/changePage.spec.ts index 5b5e28090..b7edcc386 100644 --- a/packages/tldraw/src/state/commands/changePage/changePage.spec.ts +++ b/packages/tldraw/src/state/commands/changePage/changePage.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' describe('Change page command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/changePage/changePage.ts b/packages/tldraw/src/state/commands/changePage/changePage.ts index c36ffe9da..95fe2e086 100644 --- a/packages/tldraw/src/state/commands/changePage/changePage.ts +++ b/packages/tldraw/src/state/commands/changePage/changePage.ts @@ -1,5 +1,5 @@ +import type { TldrawApp } from '~state/TldrawApp' import type { TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' export function changePage(app: TldrawApp, pageId: string): TldrawCommand { return { diff --git a/packages/tldraw/src/state/commands/createPage/createPage.spec.ts b/packages/tldraw/src/state/commands/createPage/createPage.spec.ts index c5d8127c1..c60e52e43 100644 --- a/packages/tldraw/src/state/commands/createPage/createPage.spec.ts +++ b/packages/tldraw/src/state/commands/createPage/createPage.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' let app: TldrawTestApp diff --git a/packages/tldraw/src/state/commands/createPage/createPage.ts b/packages/tldraw/src/state/commands/createPage/createPage.ts index d49169c8f..21ee56078 100644 --- a/packages/tldraw/src/state/commands/createPage/createPage.ts +++ b/packages/tldraw/src/state/commands/createPage/createPage.ts @@ -1,7 +1,7 @@ -import type { TldrawCommand, TDPage } from '~types' -import { Utils, TLPageState } from '@tldraw/core' +import { TLPageState, Utils } from '@tldraw/core' import type { TldrawApp } from '~state' -import { getIncrementedName } from '../shared/getIncrementedName' +import { getIncrementedName } from '~state/commands/shared' +import type { TDPage, TldrawCommand } from '~types' export function createPage( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/createShapes/createShapes.spec.ts b/packages/tldraw/src/state/commands/createShapes/createShapes.spec.ts index 7f4091df0..f126f9291 100644 --- a/packages/tldraw/src/state/commands/createShapes/createShapes.spec.ts +++ b/packages/tldraw/src/state/commands/createShapes/createShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' describe('Create command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/createShapes/createShapes.ts b/packages/tldraw/src/state/commands/createShapes/createShapes.ts index 41ea6baf8..0f57c99a6 100644 --- a/packages/tldraw/src/state/commands/createShapes/createShapes.ts +++ b/packages/tldraw/src/state/commands/createShapes/createShapes.ts @@ -1,5 +1,5 @@ -import type { Patch, TDShape, TldrawCommand, TDBinding } from '~types' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { Patch, TDBinding, TDShape, TldrawCommand } from '~types' export function createShapes( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/deletePage/deletePage.spec.ts b/packages/tldraw/src/state/commands/deletePage/deletePage.spec.ts index 65c281dc0..b2d642d9e 100644 --- a/packages/tldraw/src/state/commands/deletePage/deletePage.spec.ts +++ b/packages/tldraw/src/state/commands/deletePage/deletePage.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' describe('Delete page', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/deletePage/deletePage.ts b/packages/tldraw/src/state/commands/deletePage/deletePage.ts index b0eda1eea..b093b2d7f 100644 --- a/packages/tldraw/src/state/commands/deletePage/deletePage.ts +++ b/packages/tldraw/src/state/commands/deletePage/deletePage.ts @@ -1,5 +1,5 @@ +import type { TldrawApp } from '~state/TldrawApp' import type { TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' export function deletePage(app: TldrawApp, pageId: string): TldrawCommand { const { diff --git a/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.spec.ts b/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.spec.ts index bc1c6e9fa..56c7bd07f 100644 --- a/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.spec.ts +++ b/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { ColorStyle, DashStyle, diff --git a/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.ts b/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.ts index 2c79f5a68..d467d7c55 100644 --- a/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.ts +++ b/packages/tldraw/src/state/commands/deleteShapes/deleteShapes.ts @@ -1,6 +1,6 @@ +import type { TldrawApp } from '~state/TldrawApp' +import { removeShapesFromPage } from '~state/commands/shared' import type { TDAsset, TDAssets, TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' -import { removeShapesFromPage } from '../shared/removeShapesFromPage' const removeAssetsFromDocument = (assets: TDAssets, idsToRemove: string[]) => { const afterAssets: Record = { ...assets } diff --git a/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.spec.ts b/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.spec.ts index b0c559918..8d88cf205 100644 --- a/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.spec.ts +++ b/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.spec.ts @@ -1,5 +1,5 @@ import Vec from '@tldraw/vec' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { DistributeType, TDShapeType } from '~types' describe('Distribute command', () => { diff --git a/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.ts b/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.ts index 6eadc89a7..ba5f3e149 100644 --- a/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.ts +++ b/packages/tldraw/src/state/commands/distributeShapes/distributeShapes.ts @@ -1,8 +1,8 @@ import { Utils } from '@tldraw/core' -import { DistributeType, TDShape, TldrawCommand, TDShapeType } from '~types' -import { TLDR } from '~state/TLDR' import Vec from '@tldraw/vec' -import type { TldrawApp } from '../../internal' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { DistributeType, TDShape, TDShapeType, TldrawCommand } from '~types' export function distributeShapes( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.spec.ts b/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.spec.ts index 7192cb587..e61d179af 100644 --- a/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.spec.ts +++ b/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' describe('Duplicate page command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.ts b/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.ts index a45e72fc1..0a3b4257a 100644 --- a/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.ts +++ b/packages/tldraw/src/state/commands/duplicatePage/duplicatePage.ts @@ -1,6 +1,6 @@ -import type { TldrawCommand } from '~types' import { Utils } from '@tldraw/core' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { TldrawCommand } from '~types' export function duplicatePage(app: TldrawApp, pageId: string): TldrawCommand { const newId = Utils.uniqueId() diff --git a/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.spec.ts b/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.spec.ts index 6c050bbc2..8b7afe603 100644 --- a/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.spec.ts +++ b/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.spec.ts @@ -1,6 +1,6 @@ import { Utils } from '@tldraw/core' import { TLDR } from '~state/TLDR' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { ArrowShape, SessionType, TDShapeType } from '~types' describe('Duplicate command', () => { diff --git a/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.ts b/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.ts index 746662e69..6f0e4a24f 100644 --- a/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.ts +++ b/packages/tldraw/src/state/commands/duplicateShapes/duplicateShapes.ts @@ -1,8 +1,8 @@ import { Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' import { TLDR } from '~state/TLDR' -import type { PagePartial, TldrawCommand, TDShape } from '~types' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { PagePartial, TDShape, TldrawCommand } from '~types' export function duplicateShapes(app: TldrawApp, ids: string[], point?: number[]): TldrawCommand { const { selectedIds, currentPageId, page, shapes } = app diff --git a/packages/tldraw/src/state/commands/flipShapes/flipShapes.spec.ts b/packages/tldraw/src/state/commands/flipShapes/flipShapes.spec.ts index bf2d9aa2b..7e2725987 100644 --- a/packages/tldraw/src/state/commands/flipShapes/flipShapes.spec.ts +++ b/packages/tldraw/src/state/commands/flipShapes/flipShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import type { RectangleShape } from '~types' describe('Flip command', () => { diff --git a/packages/tldraw/src/state/commands/flipShapes/flipShapes.ts b/packages/tldraw/src/state/commands/flipShapes/flipShapes.ts index ee6e085d1..9e46f64b1 100644 --- a/packages/tldraw/src/state/commands/flipShapes/flipShapes.ts +++ b/packages/tldraw/src/state/commands/flipShapes/flipShapes.ts @@ -1,8 +1,8 @@ -import { FlipType } from '~types' import { TLBoundsCorner, Utils } from '@tldraw/core' -import type { TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { FlipType } from '~types' +import type { TldrawCommand } from '~types' export function flipShapes(app: TldrawApp, ids: string[], type: FlipType): TldrawCommand { const { diff --git a/packages/tldraw/src/state/commands/groupShapes/groupShapes.spec.ts b/packages/tldraw/src/state/commands/groupShapes/groupShapes.spec.ts index ffe3af481..294e4a09c 100644 --- a/packages/tldraw/src/state/commands/groupShapes/groupShapes.spec.ts +++ b/packages/tldraw/src/state/commands/groupShapes/groupShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { GroupShape, TDShape, TDShapeType } from '~types' describe('Group command', () => { diff --git a/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts b/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts index dc343720f..e9a850559 100644 --- a/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts +++ b/packages/tldraw/src/state/commands/groupShapes/groupShapes.ts @@ -1,8 +1,8 @@ -import { TDShape, TDShapeType } from '~types' import { Utils } from '@tldraw/core' -import type { Patch, TldrawCommand, TDBinding } from '~types' -import type { TldrawApp } from '../../internal' import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { TDShape, TDShapeType } from '~types' +import type { Patch, TDBinding, TldrawCommand } from '~types' export function groupShapes( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/insertContent/insertContent.spec.ts b/packages/tldraw/src/state/commands/insertContent/insertContent.spec.ts index 626a8da70..6d4fe28d9 100644 --- a/packages/tldraw/src/state/commands/insertContent/insertContent.spec.ts +++ b/packages/tldraw/src/state/commands/insertContent/insertContent.spec.ts @@ -1,6 +1,6 @@ import { Utils } from '@tldraw/core' import { TLDR } from '~state/TLDR' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { ColorStyle, DashStyle, SessionType, SizeStyle, TDShapeType } from '~types' let app: TldrawTestApp diff --git a/packages/tldraw/src/state/commands/insertContent/insertContent.ts b/packages/tldraw/src/state/commands/insertContent/insertContent.ts index a38162ced..2ca610719 100644 --- a/packages/tldraw/src/state/commands/insertContent/insertContent.ts +++ b/packages/tldraw/src/state/commands/insertContent/insertContent.ts @@ -1,8 +1,8 @@ import { Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' import { TLDR } from '~state/TLDR' -import type { PagePartial, TldrawCommand, TDShape, TDBinding, TDAsset } from '~types' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { PagePartial, TDAsset, TDBinding, TDShape, TldrawCommand } from '~types' export function insertContent( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/movePage/movePage.ts b/packages/tldraw/src/state/commands/movePage/movePage.ts index 79f546728..ed7a52929 100644 --- a/packages/tldraw/src/state/commands/movePage/movePage.ts +++ b/packages/tldraw/src/state/commands/movePage/movePage.ts @@ -1,5 +1,5 @@ +import type { TldrawApp } from '~state/TldrawApp' import type { TDPage, TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' export function movePage(app: TldrawApp, pageId: string, index: number): TldrawCommand { const { pages } = app.document diff --git a/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.spec.ts b/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.spec.ts index 178eb5787..a63c14a37 100644 --- a/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.spec.ts +++ b/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { ArrowShape, SessionType, TDShapeType } from '~types' describe('Move to page command', () => { diff --git a/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.ts b/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.ts index c2aabce6f..a42cf1509 100644 --- a/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.ts +++ b/packages/tldraw/src/state/commands/moveShapesToPage/moveShapesToPage.ts @@ -1,8 +1,8 @@ -import type { ArrowShape, PagePartial, TldrawCommand, TDShape } from '~types' -import type { TldrawApp } from '../../internal' -import { TLDR } from '~state/TLDR' -import { Utils, TLBounds } from '@tldraw/core' +import { TLBounds, Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import type { ArrowShape, PagePartial, TDShape, TldrawCommand } from '~types' export function moveShapesToPage( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/renamePage/renamePage.spec.ts b/packages/tldraw/src/state/commands/renamePage/renamePage.spec.ts index 9869ebedf..509af386d 100644 --- a/packages/tldraw/src/state/commands/renamePage/renamePage.spec.ts +++ b/packages/tldraw/src/state/commands/renamePage/renamePage.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' describe('Rename page command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/renamePage/renamePage.ts b/packages/tldraw/src/state/commands/renamePage/renamePage.ts index 3461f3c81..22ed95fd9 100644 --- a/packages/tldraw/src/state/commands/renamePage/renamePage.ts +++ b/packages/tldraw/src/state/commands/renamePage/renamePage.ts @@ -1,5 +1,5 @@ +import type { TldrawApp } from '~state/TldrawApp' import type { TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' export function renamePage(app: TldrawApp, pageId: string, name: string): TldrawCommand { const { page } = app diff --git a/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.spec.ts b/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.spec.ts index 3fb0225ab..500763385 100644 --- a/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.spec.ts +++ b/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.spec.ts @@ -1,6 +1,6 @@ -import { TDSnapshot, TDShapeType } from '~types' import { TLDR } from '~state/TLDR' import { TldrawTestApp } from '~test' +import { TDShapeType, TDSnapshot } from '~types' const app = new TldrawTestApp().createShapes( { diff --git a/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.ts b/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.ts index 2a5e61989..950562ff7 100644 --- a/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.ts +++ b/packages/tldraw/src/state/commands/reorderShapes/reorderShapes.ts @@ -1,6 +1,6 @@ -import { MoveType, TDShape, TldrawCommand } from '~types' import { TLDR } from '~state/TLDR' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import { MoveType, TDShape, TldrawCommand } from '~types' export function reorderShapes(app: TldrawApp, ids: string[], type: MoveType): TldrawCommand { const { currentPageId, page } = app diff --git a/packages/tldraw/src/state/commands/resetBounds/resetBounds.spec.ts b/packages/tldraw/src/state/commands/resetBounds/resetBounds.spec.ts index 1d80a6673..cab230e71 100644 --- a/packages/tldraw/src/state/commands/resetBounds/resetBounds.spec.ts +++ b/packages/tldraw/src/state/commands/resetBounds/resetBounds.spec.ts @@ -1,6 +1,6 @@ import { TLBoundsCorner, Utils } from '@tldraw/core' import { TLDR } from '~state/TLDR' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { SessionType, TDShapeType } from '~types' describe('Reset bounds command', () => { diff --git a/packages/tldraw/src/state/commands/resetBounds/resetBounds.ts b/packages/tldraw/src/state/commands/resetBounds/resetBounds.ts index 432d29b8c..58811b920 100644 --- a/packages/tldraw/src/state/commands/resetBounds/resetBounds.ts +++ b/packages/tldraw/src/state/commands/resetBounds/resetBounds.ts @@ -1,6 +1,6 @@ -import type { TldrawCommand } from '~types' import { TLDR } from '~state/TLDR' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { TldrawCommand } from '~types' export function resetBounds(app: TldrawApp, ids: string[], pageId: string): TldrawCommand { const { currentPageId } = app diff --git a/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.spec.ts b/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.spec.ts index 567a2543b..9fbfa0cd4 100644 --- a/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.spec.ts +++ b/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' describe('Rotate command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.ts b/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.ts index 1a0317b17..8a584c2dc 100644 --- a/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.ts +++ b/packages/tldraw/src/state/commands/rotateShapes/rotateShapes.ts @@ -1,7 +1,7 @@ import { Utils } from '@tldraw/core' -import type { TldrawCommand, TDShape } from '~types' import { TLDR } from '~state/TLDR' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { TDShape, TldrawCommand } from '~types' const PI2 = Math.PI * 2 diff --git a/packages/tldraw/src/state/commands/setShapesProps/setShapesProps.ts b/packages/tldraw/src/state/commands/setShapesProps/setShapesProps.ts index 12144c0a3..b316d0977 100644 --- a/packages/tldraw/src/state/commands/setShapesProps/setShapesProps.ts +++ b/packages/tldraw/src/state/commands/setShapesProps/setShapesProps.ts @@ -1,5 +1,5 @@ -import type { TDShape, TldrawCommand } from '~types' import type { TldrawApp } from '~state' +import type { TDShape, TldrawCommand } from '~types' export function setShapesProps( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/shared/index.ts b/packages/tldraw/src/state/commands/shared/index.ts new file mode 100644 index 000000000..1c01a2eaf --- /dev/null +++ b/packages/tldraw/src/state/commands/shared/index.ts @@ -0,0 +1,2 @@ +export * from './getIncrementedName' +export * from './removeShapesFromPage' diff --git a/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.spec.ts b/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.spec.ts index aa886e285..428433933 100644 --- a/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.spec.ts +++ b/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.spec.ts @@ -1,5 +1,5 @@ -import { StretchType, RectangleShape, TDShapeType } from '~types' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' +import { RectangleShape, StretchType, TDShapeType } from '~types' describe('Stretch command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.ts b/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.ts index 2f87a5e63..5c2927665 100644 --- a/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.ts +++ b/packages/tldraw/src/state/commands/stretchShapes/stretchShapes.ts @@ -1,8 +1,8 @@ import { TLBoundsCorner, Utils } from '@tldraw/core' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' import { StretchType, TDShapeType } from '~types' import type { TldrawCommand } from '~types' -import { TLDR } from '~state/TLDR' -import type { TldrawApp } from '../../internal' export function stretchShapes(app: TldrawApp, ids: string[], type: StretchType): TldrawCommand { const { currentPageId, selectedIds } = app diff --git a/packages/tldraw/src/state/commands/styleShapes/styleShapes.spec.ts b/packages/tldraw/src/state/commands/styleShapes/styleShapes.spec.ts index 566a63a02..a57936034 100644 --- a/packages/tldraw/src/state/commands/styleShapes/styleShapes.spec.ts +++ b/packages/tldraw/src/state/commands/styleShapes/styleShapes.spec.ts @@ -1,5 +1,5 @@ import { TLDR } from '~state/TLDR' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { SizeStyle, TDShapeType } from '~types' describe('Style command', () => { diff --git a/packages/tldraw/src/state/commands/styleShapes/styleShapes.ts b/packages/tldraw/src/state/commands/styleShapes/styleShapes.ts index 2600b9275..bd3d84121 100644 --- a/packages/tldraw/src/state/commands/styleShapes/styleShapes.ts +++ b/packages/tldraw/src/state/commands/styleShapes/styleShapes.ts @@ -1,7 +1,7 @@ -import { Patch, ShapeStyles, TldrawCommand, TDShape, TDShapeType, TextShape } from '~types' -import { TLDR } from '~state/TLDR' import { Vec } from '@tldraw/vec' -import type { TldrawApp } from '../../internal' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { Patch, ShapeStyles, TDShape, TDShapeType, TextShape, TldrawCommand } from '~types' export function styleShapes( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/toggleShapesDecoration/toggleShapesDecoration.ts b/packages/tldraw/src/state/commands/toggleShapesDecoration/toggleShapesDecoration.ts index 4ec27e796..58be4e7d4 100644 --- a/packages/tldraw/src/state/commands/toggleShapesDecoration/toggleShapesDecoration.ts +++ b/packages/tldraw/src/state/commands/toggleShapesDecoration/toggleShapesDecoration.ts @@ -1,6 +1,6 @@ +import type { TldrawApp } from '~state/internal' import { Decoration } from '~types' -import type { Patch, ArrowShape, TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' +import type { ArrowShape, Patch, TldrawCommand } from '~types' export function toggleShapesDecoration( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.spec.ts b/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.spec.ts index 6d3607e76..1c30dd96c 100644 --- a/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.spec.ts +++ b/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.spec.ts @@ -1,5 +1,5 @@ +import { TldrawTestApp, mockDocument } from '~test' import type { RectangleShape } from '~types' -import { mockDocument, TldrawTestApp } from '~test' describe('Toggle command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.ts b/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.ts index fc440cf2e..ac40219aa 100644 --- a/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.ts +++ b/packages/tldraw/src/state/commands/toggleShapesProp/toggleShapesProp.ts @@ -1,5 +1,5 @@ -import type { TDShape, TldrawCommand } from '~types' import type { TldrawApp } from '~state' +import type { TDShape, TldrawCommand } from '~types' export function toggleShapeProp(app: TldrawApp, ids: string[], prop: keyof TDShape): TldrawCommand { const { currentPageId } = app diff --git a/packages/tldraw/src/state/commands/translateShapes/translateShapes.spec.ts b/packages/tldraw/src/state/commands/translateShapes/translateShapes.spec.ts index f104a8a30..4420b5d85 100644 --- a/packages/tldraw/src/state/commands/translateShapes/translateShapes.spec.ts +++ b/packages/tldraw/src/state/commands/translateShapes/translateShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { ArrowShape, SessionType, TDShapeType } from '~types' describe('Translate command', () => { diff --git a/packages/tldraw/src/state/commands/translateShapes/translateShapes.ts b/packages/tldraw/src/state/commands/translateShapes/translateShapes.ts index 5393dc39c..23a1f12bc 100644 --- a/packages/tldraw/src/state/commands/translateShapes/translateShapes.ts +++ b/packages/tldraw/src/state/commands/translateShapes/translateShapes.ts @@ -1,7 +1,7 @@ import { Vec } from '@tldraw/vec' import { TLDR } from '~state/TLDR' -import type { TldrawCommand, PagePartial } from '~types' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { PagePartial, TldrawCommand } from '~types' export function translateShapes(app: TldrawApp, ids: string[], delta: number[]): TldrawCommand { const { currentPageId, selectedIds } = app diff --git a/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.spec.ts b/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.spec.ts index 4baa488fb..723a9cd89 100644 --- a/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.spec.ts +++ b/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { GroupShape, TDShapeType } from '~types' describe('Ungroup command', () => { diff --git a/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.ts b/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.ts index 0d369ab41..c9e749fb4 100644 --- a/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.ts +++ b/packages/tldraw/src/state/commands/ungroupShapes/ungroupShapes.ts @@ -1,7 +1,7 @@ import { TLDR } from '~state/TLDR' -import type { Patch, GroupShape, TDBinding, TDShape } from '~types' +import type { TldrawApp } from '~state/TldrawApp' +import type { GroupShape, Patch, TDBinding, TDShape } from '~types' import type { TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' export function ungroupShapes( app: TldrawApp, diff --git a/packages/tldraw/src/state/commands/updateShapes/updateShapes.spec.ts b/packages/tldraw/src/state/commands/updateShapes/updateShapes.spec.ts index 3258e9913..9d83f724c 100644 --- a/packages/tldraw/src/state/commands/updateShapes/updateShapes.spec.ts +++ b/packages/tldraw/src/state/commands/updateShapes/updateShapes.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' describe('Update command', () => { const app = new TldrawTestApp() diff --git a/packages/tldraw/src/state/commands/updateShapes/updateShapes.ts b/packages/tldraw/src/state/commands/updateShapes/updateShapes.ts index 4c71d4b23..0c1465e54 100644 --- a/packages/tldraw/src/state/commands/updateShapes/updateShapes.ts +++ b/packages/tldraw/src/state/commands/updateShapes/updateShapes.ts @@ -1,6 +1,6 @@ -import type { TldrawCommand, TDShape } from '~types' import { TLDR } from '~state/TLDR' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import type { TDShape, TldrawCommand } from '~types' export function updateShapes( app: TldrawApp, diff --git a/packages/tldraw/src/state/data/browser-fs-access/directory-open.js b/packages/tldraw/src/state/data/browser-fs-access/directory-open.js index 0bb0e0108..7114ef396 100644 --- a/packages/tldraw/src/state/data/browser-fs-access/directory-open.js +++ b/packages/tldraw/src/state/data/browser-fs-access/directory-open.js @@ -14,7 +14,6 @@ * limitations under the License. */ // @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0. - import supported from './supported.js' const implementation = !supported diff --git a/packages/tldraw/src/state/data/browser-fs-access/file-open.js b/packages/tldraw/src/state/data/browser-fs-access/file-open.js index 6c4c64773..81bc74450 100644 --- a/packages/tldraw/src/state/data/browser-fs-access/file-open.js +++ b/packages/tldraw/src/state/data/browser-fs-access/file-open.js @@ -14,7 +14,6 @@ * limitations under the License. */ // @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0. - import supported from './supported.js' const implementation = !supported diff --git a/packages/tldraw/src/state/data/browser-fs-access/file-save.js b/packages/tldraw/src/state/data/browser-fs-access/file-save.js index c0d1560e5..5a69443ba 100644 --- a/packages/tldraw/src/state/data/browser-fs-access/file-save.js +++ b/packages/tldraw/src/state/data/browser-fs-access/file-save.js @@ -14,7 +14,6 @@ * limitations under the License. */ // @license © 2020 Google LLC. Licensed under the Apache License, Version 2.0. - import supported from './supported.js' const implementation = !supported diff --git a/packages/tldraw/src/state/data/filesystem.ts b/packages/tldraw/src/state/data/filesystem.ts index cd9ffcd74..0aa54d9da 100644 --- a/packages/tldraw/src/state/data/filesystem.ts +++ b/packages/tldraw/src/state/data/filesystem.ts @@ -1,7 +1,7 @@ -import type { TDDocument, TDFile } from '~types' -import type { FileSystemHandle } from './browser-fs-access' import { get as getFromIdb, set as setToIdb } from 'idb-keyval' import { IMAGE_EXTENSIONS, VIDEO_EXTENSIONS } from '~constants' +import type { TDDocument, TDFile } from '~types' +import type { FileSystemHandle } from './browser-fs-access' const options = { mode: 'readwrite' as const } diff --git a/packages/tldraw/src/state/data/migrate.spec.ts b/packages/tldraw/src/state/data/migrate.spec.ts index 8773f503c..ec2c40e08 100644 --- a/packages/tldraw/src/state/data/migrate.spec.ts +++ b/packages/tldraw/src/state/data/migrate.spec.ts @@ -1,7 +1,7 @@ -import type { TDDocument } from '~types' import { TldrawApp } from '~state' import oldDoc from '~test/documents/old-doc' import oldDoc2 from '~test/documents/old-doc-2' +import type { TDDocument } from '~types' describe('When migrating bindings', () => { it('migrates a document without a version', () => { diff --git a/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.spec.ts b/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.spec.ts index 67d766458..3e4b7386b 100644 --- a/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.spec.ts +++ b/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { ArrowShape, SessionType, TDShapeType, TDStatus } from '~types' describe('Arrow session', () => { diff --git a/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.ts b/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.ts index b2656baa5..cacd192ac 100644 --- a/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.ts +++ b/packages/tldraw/src/state/sessions/ArrowSession/ArrowSession.ts @@ -1,21 +1,21 @@ +import { Utils } from '@tldraw/core' +import { Vec } from '@tldraw/vec' +import { deepCopy } from '~state/StateManager/copy' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { shapeUtils } from '~state/shapes' import { ArrowBinding, ArrowShape, - TDShape, - TDBinding, - TDStatus, SessionType, + TDBinding, + TDShape, TDShapeType, - TldrawPatch, + TDStatus, TldrawCommand, + TldrawPatch, } from '~types' -import { Vec } from '@tldraw/vec' -import { TLDR } from '~state/TLDR' -import { shapeUtils } from '~state/shapes' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' -import { Utils } from '@tldraw/core' -import { deepCopy } from '~state/StateManager/copy' export class ArrowSession extends BaseSession { type = SessionType.Arrow diff --git a/packages/tldraw/src/state/sessions/BaseSession.ts b/packages/tldraw/src/state/sessions/BaseSession.ts index 5db323c75..788df826f 100644 --- a/packages/tldraw/src/state/sessions/BaseSession.ts +++ b/packages/tldraw/src/state/sessions/BaseSession.ts @@ -1,6 +1,6 @@ import type { TLPerformanceMode } from '@tldraw/core' +import type { TldrawApp } from '~state/TldrawApp' import type { SessionType, TldrawCommand, TldrawPatch } from '~types' -import type { TldrawApp } from '../internal' export abstract class BaseSession { abstract type: SessionType diff --git a/packages/tldraw/src/state/sessions/BrushSession/BrushSession.spec.ts b/packages/tldraw/src/state/sessions/BrushSession/BrushSession.spec.ts index b966214aa..59a12604e 100644 --- a/packages/tldraw/src/state/sessions/BrushSession/BrushSession.spec.ts +++ b/packages/tldraw/src/state/sessions/BrushSession/BrushSession.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { SessionType, TDStatus } from '~types' describe('Brush session', () => { diff --git a/packages/tldraw/src/state/sessions/BrushSession/BrushSession.ts b/packages/tldraw/src/state/sessions/BrushSession/BrushSession.ts index c7cd7a3ea..0e38786f9 100644 --- a/packages/tldraw/src/state/sessions/BrushSession/BrushSession.ts +++ b/packages/tldraw/src/state/sessions/BrushSession/BrushSession.ts @@ -1,7 +1,7 @@ import { TLBounds, Utils } from '@tldraw/core' -import { SessionType, TldrawPatch, TDStatus, TldrawCommand } from '~types' -import type { TldrawApp } from '../../internal' -import { BaseSession } from '../BaseSession' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { SessionType, TDStatus, TldrawCommand, TldrawPatch } from '~types' export class BrushSession extends BaseSession { type = SessionType.Brush diff --git a/packages/tldraw/src/state/sessions/DrawSession/DrawSession.ts b/packages/tldraw/src/state/sessions/DrawSession/DrawSession.ts index bf06e9491..36e817d38 100644 --- a/packages/tldraw/src/state/sessions/DrawSession/DrawSession.ts +++ b/packages/tldraw/src/state/sessions/DrawSession/DrawSession.ts @@ -1,8 +1,8 @@ import { Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' -import { SessionType, TDStatus, TldrawPatch, TldrawCommand, DrawShape } from '~types' -import type { TldrawApp } from '../../internal' -import { BaseSession } from '../BaseSession' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { DrawShape, SessionType, TDStatus, TldrawCommand, TldrawPatch } from '~types' export class DrawSession extends BaseSession { type = SessionType.Draw diff --git a/packages/tldraw/src/state/sessions/EditSession/EditSession.ts b/packages/tldraw/src/state/sessions/EditSession/EditSession.ts index 3bff0bad7..cbba2f4d1 100644 --- a/packages/tldraw/src/state/sessions/EditSession/EditSession.ts +++ b/packages/tldraw/src/state/sessions/EditSession/EditSession.ts @@ -1,6 +1,6 @@ -import { TDShape, SessionType, TldrawPatch, TldrawCommand } from '~types' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { SessionType, TDShape, TldrawCommand, TldrawPatch } from '~types' export class EditSession extends BaseSession { type = SessionType.Edit diff --git a/packages/tldraw/src/state/sessions/EraseSession/EraseSession.spec.ts b/packages/tldraw/src/state/sessions/EraseSession/EraseSession.spec.ts index f3ac020a5..aa715d04b 100644 --- a/packages/tldraw/src/state/sessions/EraseSession/EraseSession.spec.ts +++ b/packages/tldraw/src/state/sessions/EraseSession/EraseSession.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { TDStatus } from '~types' describe('Draw session', () => { diff --git a/packages/tldraw/src/state/sessions/EraseSession/EraseSession.ts b/packages/tldraw/src/state/sessions/EraseSession/EraseSession.ts index d67a9b4be..414c82c96 100644 --- a/packages/tldraw/src/state/sessions/EraseSession/EraseSession.ts +++ b/packages/tldraw/src/state/sessions/EraseSession/EraseSession.ts @@ -1,15 +1,15 @@ import { Vec } from '@tldraw/vec' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' import { - SessionType, - TDStatus, - TDShape, PagePartial, + SessionType, TDBinding, - TldrawPatch, + TDShape, + TDStatus, TldrawCommand, + TldrawPatch, } from '~types' -import type { TldrawApp } from '../../internal' -import { BaseSession } from '../BaseSession' export class EraseSession extends BaseSession { type = SessionType.Draw diff --git a/packages/tldraw/src/state/sessions/GridSession/GridSession.spec.ts b/packages/tldraw/src/state/sessions/GridSession/GridSession.spec.ts index 7450a27c8..53c0c2c03 100644 --- a/packages/tldraw/src/state/sessions/GridSession/GridSession.spec.ts +++ b/packages/tldraw/src/state/sessions/GridSession/GridSession.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { TDStatus } from '~types' describe('Grid session', () => { diff --git a/packages/tldraw/src/state/sessions/GridSession/GridSession.ts b/packages/tldraw/src/state/sessions/GridSession/GridSession.ts index 0c1056cec..47e5d8319 100644 --- a/packages/tldraw/src/state/sessions/GridSession/GridSession.ts +++ b/packages/tldraw/src/state/sessions/GridSession/GridSession.ts @@ -1,16 +1,16 @@ -import { TLPageState, TLBounds, Utils } from '@tldraw/core' +import { TLBounds, TLPageState, Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' import { Patch, - TDShape, - TDStatus, SessionType, + TDShape, TDShapeType, - TldrawPatch, + TDStatus, TldrawCommand, + TldrawPatch, } from '~types' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' export class GridSession extends BaseSession { type = SessionType.Grid diff --git a/packages/tldraw/src/state/sessions/HandleSession/HandleSession.spec.ts b/packages/tldraw/src/state/sessions/HandleSession/HandleSession.spec.ts index 695f8eda7..d1f9e7610 100644 --- a/packages/tldraw/src/state/sessions/HandleSession/HandleSession.spec.ts +++ b/packages/tldraw/src/state/sessions/HandleSession/HandleSession.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { SessionType, TDShapeType, TDStatus } from '~types' describe('Handle session', () => { diff --git a/packages/tldraw/src/state/sessions/HandleSession/HandleSession.ts b/packages/tldraw/src/state/sessions/HandleSession/HandleSession.ts index 96add44b2..a2f23d9d1 100644 --- a/packages/tldraw/src/state/sessions/HandleSession/HandleSession.ts +++ b/packages/tldraw/src/state/sessions/HandleSession/HandleSession.ts @@ -1,8 +1,8 @@ import { Vec } from '@tldraw/vec' -import { SessionType, ShapesWithProp, TldrawCommand, TldrawPatch, TDStatus } from '~types' import { TLDR } from '~state/TLDR' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { SessionType, ShapesWithProp, TDStatus, TldrawCommand, TldrawPatch } from '~types' export class HandleSession extends BaseSession { type = SessionType.Handle diff --git a/packages/tldraw/src/state/sessions/RotateSession/RotateSession.spec.ts b/packages/tldraw/src/state/sessions/RotateSession/RotateSession.spec.ts index bd72f805b..e84b12e9d 100644 --- a/packages/tldraw/src/state/sessions/RotateSession/RotateSession.spec.ts +++ b/packages/tldraw/src/state/sessions/RotateSession/RotateSession.spec.ts @@ -1,6 +1,6 @@ -import Vec from '@tldraw/vec' import { Utils } from '@tldraw/core' -import { mockDocument, TldrawTestApp } from '~test' +import Vec from '@tldraw/vec' +import { TldrawTestApp, mockDocument } from '~test' import { TDStatus } from '~types' describe('Rotate session', () => { diff --git a/packages/tldraw/src/state/sessions/RotateSession/RotateSession.ts b/packages/tldraw/src/state/sessions/RotateSession/RotateSession.ts index e0b53ed01..c48f38f43 100644 --- a/packages/tldraw/src/state/sessions/RotateSession/RotateSession.ts +++ b/packages/tldraw/src/state/sessions/RotateSession/RotateSession.ts @@ -1,9 +1,9 @@ import { Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' -import { SessionType, TldrawCommand, TldrawPatch, TDShape, TDStatus } from '~types' import { TLDR } from '~state/TLDR' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { SessionType, TDShape, TDStatus, TldrawCommand, TldrawPatch } from '~types' export class RotateSession extends BaseSession { type = SessionType.Rotate diff --git a/packages/tldraw/src/state/sessions/TransformSession/TransformSession.spec.ts b/packages/tldraw/src/state/sessions/TransformSession/TransformSession.spec.ts index 6bda1407c..54d600062 100644 --- a/packages/tldraw/src/state/sessions/TransformSession/TransformSession.spec.ts +++ b/packages/tldraw/src/state/sessions/TransformSession/TransformSession.spec.ts @@ -1,6 +1,6 @@ -import { mockDocument, TldrawTestApp } from '~test' import { TLBoundsCorner, TLBoundsEdge, Utils } from '@tldraw/core' import { TLDR } from '~state/TLDR' +import { TldrawTestApp, mockDocument } from '~test' import { TDShapeType, TDStatus } from '~types' function getShapeBounds(app: TldrawTestApp, ...ids: string[]) { diff --git a/packages/tldraw/src/state/sessions/TransformSession/TransformSession.ts b/packages/tldraw/src/state/sessions/TransformSession/TransformSession.ts index 4cf16d714..6dd3a58e9 100644 --- a/packages/tldraw/src/state/sessions/TransformSession/TransformSession.ts +++ b/packages/tldraw/src/state/sessions/TransformSession/TransformSession.ts @@ -1,11 +1,11 @@ import { TLBounds, TLBoundsCorner, TLBoundsEdge, Utils } from '@tldraw/core' +import type { TLBoundsWithCenter, TLSnapLine } from '@tldraw/core' import { Vec } from '@tldraw/vec' -import type { TLSnapLine, TLBoundsWithCenter } from '@tldraw/core' -import { SessionType, TldrawCommand, TldrawPatch, TDShape, TDStatus } from '~types' -import { TLDR } from '~state/TLDR' import { SLOW_SPEED, SNAP_DISTANCE } from '~constants' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { SessionType, TDShape, TDStatus, TldrawCommand, TldrawPatch } from '~types' type SnapInfo = | { diff --git a/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.spec.ts b/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.spec.ts index 3fa2a45de..0dd40cba9 100644 --- a/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.spec.ts +++ b/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.spec.ts @@ -1,7 +1,7 @@ -import { mockDocument, TldrawTestApp } from '~test' import { TLBoundsCorner, TLBoundsEdge, Utils } from '@tldraw/core' -import { TDStatus } from '~types' import { TLDR } from '~state/TLDR' +import { TldrawTestApp, mockDocument } from '~test' +import { TDStatus } from '~types' describe('Transform single session', () => { it('begins, updateSession', () => { diff --git a/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts b/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts index e74e001af..811b5d8ae 100644 --- a/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts +++ b/packages/tldraw/src/state/sessions/TransformSingleSession/TransformSingleSession.ts @@ -1,17 +1,17 @@ import { - TLBoundsCorner, - TLSnapLine, - TLBoundsEdge, - Utils, - TLBoundsWithCenter, TLBounds, + TLBoundsCorner, + TLBoundsEdge, + TLBoundsWithCenter, + TLSnapLine, + Utils, } from '@tldraw/core' import { Vec } from '@tldraw/vec' -import { SessionType, TldrawCommand, TldrawPatch, TDShape, TDStatus } from '~types' -import { TLDR } from '~state/TLDR' import { SLOW_SPEED, SNAP_DISTANCE } from '~constants' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { SessionType, TDShape, TDStatus, TldrawCommand, TldrawPatch } from '~types' type SnapInfo = | { diff --git a/packages/tldraw/src/state/sessions/TranslateLabelSession/TranslateLabelSession.ts b/packages/tldraw/src/state/sessions/TranslateLabelSession/TranslateLabelSession.ts index de9a7d408..ae89f0c68 100644 --- a/packages/tldraw/src/state/sessions/TranslateLabelSession/TranslateLabelSession.ts +++ b/packages/tldraw/src/state/sessions/TranslateLabelSession/TranslateLabelSession.ts @@ -1,17 +1,17 @@ +import type { TLBounds } from '@tldraw/core' +import { TLDR } from '~state/TLDR' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' import { + ArrowShape, + EllipseShape, + RectangleShape, SessionType, + TDStatus, TldrawCommand, TldrawPatch, - TDStatus, - RectangleShape, TriangleShape, - EllipseShape, - ArrowShape, } from '~types' -import { TLDR } from '~state/TLDR' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' -import type { TLBounds } from '@tldraw/core' export class TranslateLabelSession extends BaseSession { type = SessionType.Handle diff --git a/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.spec.ts b/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.spec.ts index e826ee6dc..fb2904ea1 100644 --- a/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.spec.ts +++ b/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.spec.ts @@ -1,5 +1,5 @@ import { Vec } from '@tldraw/vec' -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { GroupShape, SessionType, TDShapeType, TDStatus } from '~types' describe('Translate session', () => { diff --git a/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.ts b/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.ts index ab8c1c8d0..c8bd2f02e 100644 --- a/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.ts +++ b/packages/tldraw/src/state/sessions/TranslateSession/TranslateSession.ts @@ -1,22 +1,22 @@ -import { TLPageState, Utils, TLBoundsWithCenter, TLSnapLine, TLBounds } from '@tldraw/core' +import { TLBounds, TLBoundsWithCenter, TLPageState, TLSnapLine, Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' -import { - TDShape, - TDBinding, - TldrawCommand, - TDStatus, - ArrowShape, - Patch, - GroupShape, - SessionType, - ArrowBinding, - TldrawPatch, - TDShapeType, -} from '~types' import { SLOW_SPEED, SNAP_DISTANCE } from '~constants' import { TLDR } from '~state/TLDR' -import { BaseSession } from '../BaseSession' -import type { TldrawApp } from '../../internal' +import type { TldrawApp } from '~state/TldrawApp' +import { BaseSession } from '~state/sessions/BaseSession' +import { + ArrowBinding, + ArrowShape, + GroupShape, + Patch, + SessionType, + TDBinding, + TDShape, + TDShapeType, + TDStatus, + TldrawCommand, + TldrawPatch, +} from '~types' type CloneInfo = | { diff --git a/packages/tldraw/src/state/sessions/index.ts b/packages/tldraw/src/state/sessions/index.ts index 6adf75016..481506768 100644 --- a/packages/tldraw/src/state/sessions/index.ts +++ b/packages/tldraw/src/state/sessions/index.ts @@ -2,14 +2,14 @@ import { ExceptFirst, SessionType } from '~types' import { ArrowSession } from './ArrowSession' import { BrushSession } from './BrushSession' import { DrawSession } from './DrawSession' +import { EditSession } from './EditSession' +import { EraseSession } from './EraseSession' +import { GridSession } from './GridSession' import { HandleSession } from './HandleSession' import { RotateSession } from './RotateSession' import { TransformSession } from './TransformSession' import { TransformSingleSession } from './TransformSingleSession' import { TranslateSession } from './TranslateSession' -import { EraseSession } from './EraseSession' -import { GridSession } from './GridSession' -import { EditSession } from './EditSession' export type TldrawSession = | ArrowSession diff --git a/packages/tldraw/src/state/shapes/ArrowUtil/ArrowUtil.tsx b/packages/tldraw/src/state/shapes/ArrowUtil/ArrowUtil.tsx index 08513b473..0442e0a05 100644 --- a/packages/tldraw/src/state/shapes/ArrowUtil/ArrowUtil.tsx +++ b/packages/tldraw/src/state/shapes/ArrowUtil/ArrowUtil.tsx @@ -1,15 +1,23 @@ -import * as React from 'react' -import { Utils, TLBounds, SVGContainer } from '@tldraw/core' -import { Vec } from '@tldraw/vec' -import { defaultStyle } from '../shared/shape-styles' -import { ArrowShape, TransformInfo, Decoration, TDShapeType, DashStyle, TDMeta } from '~types' -import { TDShapeUtil } from '../TDShapeUtil' +import { SVGContainer, TLBounds, Utils } from '@tldraw/core' import { intersectArcBounds, intersectLineSegmentBounds, intersectLineSegmentLineSegment, } from '@tldraw/intersect' +import { Vec } from '@tldraw/vec' +import * as React from 'react' import { GHOSTED_OPACITY } from '~constants' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' +import { + LabelMask, + TextLabel, + defaultStyle, + getFontStyle, + getShapeStyle, + getTextLabelSize, +} from '~state/shapes/shared' +import { styled } from '~styles' +import { ArrowShape, DashStyle, Decoration, TDMeta, TDShapeType, TransformInfo } from '~types' import { getArcLength, getArcPoints, @@ -18,12 +26,8 @@ import { getCtp, isAngleBetween, } from './arrowHelpers' -import { styled } from '~styles' -import { TextLabel, getFontStyle, getShapeStyle } from '../shared' -import { getTextLabelSize } from '../shared/getTextSize' -import { StraightArrow } from './components/StraightArrow' import { CurvedArrow } from './components/CurvedArrow.tsx' -import { LabelMask } from '../shared/LabelMask' +import { StraightArrow } from './components/StraightArrow' type T = ArrowShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/ArrowUtil/arrowHelpers.ts b/packages/tldraw/src/state/shapes/ArrowUtil/arrowHelpers.ts index b76e7653a..8ffa5e6b4 100644 --- a/packages/tldraw/src/state/shapes/ArrowUtil/arrowHelpers.ts +++ b/packages/tldraw/src/state/shapes/ArrowUtil/arrowHelpers.ts @@ -3,9 +3,9 @@ import { intersectCircleCircle, intersectCircleLineSegment } from '@tldraw/inter import Vec from '@tldraw/vec' import getStroke from 'perfect-freehand' import { EASINGS } from '~constants' -import { getShapeStyle } from '../shared/shape-styles' +import { TLDR } from '~state/TLDR' +import { getShapeStyle } from '~state/shapes/shared' import type { ArrowShape, Decoration, ShapeStyles } from '~types' -import { TLDR } from '../../TLDR' export function getArrowArcPath(start: number[], end: number[], circle: number[], bend: number) { return [ diff --git a/packages/tldraw/src/state/shapes/DrawUtil/DrawUtil.tsx b/packages/tldraw/src/state/shapes/DrawUtil/DrawUtil.tsx index 955996655..85d00b260 100644 --- a/packages/tldraw/src/state/shapes/DrawUtil/DrawUtil.tsx +++ b/packages/tldraw/src/state/shapes/DrawUtil/DrawUtil.tsx @@ -1,21 +1,21 @@ -import * as React from 'react' -import { Utils, SVGContainer, TLBounds } from '@tldraw/core' -import { Vec } from '@tldraw/vec' -import { defaultStyle, getShapeStyle } from '../shared/shape-styles' -import { DrawShape, DashStyle, TDShapeType, TransformInfo, TDMeta } from '~types' -import { TDShapeUtil } from '../TDShapeUtil' +import { SVGContainer, TLBounds, Utils } from '@tldraw/core' import { intersectBoundsBounds, intersectBoundsPolyline, intersectLineSegmentBounds, intersectLineSegmentLineSegment, } from '@tldraw/intersect' +import { Vec } from '@tldraw/vec' +import * as React from 'react' +import { GHOSTED_OPACITY } from '~constants' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' +import { defaultStyle, getShapeStyle } from '~state/shapes/shared' +import { DashStyle, DrawShape, TDMeta, TDShapeType, TransformInfo } from '~types' import { getDrawStrokePathTDSnapshot, getFillPath, getSolidStrokePathTDSnapshot, } from './drawHelpers' -import { GHOSTED_OPACITY } from '~constants' type T = DrawShape type E = SVGSVGElement diff --git a/packages/tldraw/src/state/shapes/DrawUtil/drawHelpers.ts b/packages/tldraw/src/state/shapes/DrawUtil/drawHelpers.ts index a542c3f69..2e3ffc34e 100644 --- a/packages/tldraw/src/state/shapes/DrawUtil/drawHelpers.ts +++ b/packages/tldraw/src/state/shapes/DrawUtil/drawHelpers.ts @@ -1,8 +1,8 @@ import { Utils } from '@tldraw/core' import Vec from '@tldraw/vec' -import { getStrokeOutlinePoints, getStrokePoints, StrokeOptions } from 'perfect-freehand' +import { StrokeOptions, getStrokeOutlinePoints, getStrokePoints } from 'perfect-freehand' +import { getShapeStyle } from '~state/shapes/shared' import type { DrawShape } from '~types' -import { getShapeStyle } from '../shared/shape-styles' const simulatePressureSettings: StrokeOptions = { easing: (t) => Math.sin((t * Math.PI) / 2), diff --git a/packages/tldraw/src/state/shapes/EllipseUtil/EllipseUtil.tsx b/packages/tldraw/src/state/shapes/EllipseUtil/EllipseUtil.tsx index 9463a74ac..888665455 100644 --- a/packages/tldraw/src/state/shapes/EllipseUtil/EllipseUtil.tsx +++ b/packages/tldraw/src/state/shapes/EllipseUtil/EllipseUtil.tsx @@ -1,20 +1,19 @@ -import * as React from 'react' -import { Utils, SVGContainer, TLBounds } from '@tldraw/core' -import { Vec } from '@tldraw/vec' -import { defaultStyle, getShapeStyle, getFontStyle } from '~state/shapes/shared' -import { EllipseShape, DashStyle, TDShapeType, TDShape, TransformInfo, TDMeta } from '~types' -import { GHOSTED_OPACITY, LABEL_POINT } from '~constants' -import { TDShapeUtil } from '../TDShapeUtil' +import { SVGContainer, TLBounds, Utils } from '@tldraw/core' import { intersectEllipseBounds, intersectLineSegmentEllipse, intersectRayEllipse, } from '@tldraw/intersect' -import { getEllipseIndicatorPath } from './ellipseHelpers' -import { DrawEllipse } from './components/DrawEllipse' -import { DashedEllipse } from './components/DashedEllipse' -import { TextLabel } from '../shared/TextLabel' +import { Vec } from '@tldraw/vec' +import * as React from 'react' +import { GHOSTED_OPACITY, LABEL_POINT } from '~constants' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' +import { TextLabel, defaultStyle, getFontStyle, getShapeStyle } from '~state/shapes/shared' import { styled } from '~styles' +import { DashStyle, EllipseShape, TDMeta, TDShape, TDShapeType, TransformInfo } from '~types' +import { DashedEllipse } from './components/DashedEllipse' +import { DrawEllipse } from './components/DrawEllipse' +import { getEllipseIndicatorPath } from './ellipseHelpers' type T = EllipseShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/EllipseUtil/components/DashedEllipse.tsx b/packages/tldraw/src/state/shapes/EllipseUtil/components/DashedEllipse.tsx index 1b63e95aa..d6ebb167a 100644 --- a/packages/tldraw/src/state/shapes/EllipseUtil/components/DashedEllipse.tsx +++ b/packages/tldraw/src/state/shapes/EllipseUtil/components/DashedEllipse.tsx @@ -1,7 +1,7 @@ -import * as React from 'react' import { Utils } from '@tldraw/core' -import type { ShapeStyles } from '~types' +import * as React from 'react' import { getShapeStyle } from '~state/shapes/shared' +import type { ShapeStyles } from '~types' interface EllipseSvgProps { radius: number[] diff --git a/packages/tldraw/src/state/shapes/EllipseUtil/ellipseHelpers.ts b/packages/tldraw/src/state/shapes/EllipseUtil/ellipseHelpers.ts index bcf09d5f5..089515d56 100644 --- a/packages/tldraw/src/state/shapes/EllipseUtil/ellipseHelpers.ts +++ b/packages/tldraw/src/state/shapes/EllipseUtil/ellipseHelpers.ts @@ -1,8 +1,8 @@ import { Utils } from '@tldraw/core' import { getStrokeOutlinePoints, getStrokePoints } from 'perfect-freehand' import { EASINGS } from '~constants' +import { getShapeStyle } from '~state/shapes/shared' import type { ShapeStyles } from '~types' -import { getShapeStyle } from '../shared/shape-styles' export function getEllipseStrokePoints(id: string, radius: number[], style: ShapeStyles) { const { strokeWidth } = getShapeStyle(style) diff --git a/packages/tldraw/src/state/shapes/GroupUtil/GroupUtil.tsx b/packages/tldraw/src/state/shapes/GroupUtil/GroupUtil.tsx index 78fd6c5a5..cb5bd714a 100644 --- a/packages/tldraw/src/state/shapes/GroupUtil/GroupUtil.tsx +++ b/packages/tldraw/src/state/shapes/GroupUtil/GroupUtil.tsx @@ -1,11 +1,10 @@ +import { SVGContainer, Utils } from '@tldraw/core' import * as React from 'react' -import { styled } from '~styles' -import { Utils, SVGContainer } from '@tldraw/core' -import { defaultStyle } from '../shared/shape-styles' -import { TDShapeType, GroupShape, ColorStyle, TDMeta } from '~types' import { GHOSTED_OPACITY } from '~constants' -import { TDShapeUtil } from '../TDShapeUtil' -import { getBoundsRectangle } from '../shared' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' +import { defaultStyle, getBoundsRectangle } from '~state/shapes/shared' +import { styled } from '~styles' +import { ColorStyle, GroupShape, TDMeta, TDShapeType } from '~types' type T = GroupShape type E = SVGSVGElement diff --git a/packages/tldraw/src/state/shapes/ImageUtil/ImageUtil.tsx b/packages/tldraw/src/state/shapes/ImageUtil/ImageUtil.tsx index 8263471df..f7d0e1a81 100644 --- a/packages/tldraw/src/state/shapes/ImageUtil/ImageUtil.tsx +++ b/packages/tldraw/src/state/shapes/ImageUtil/ImageUtil.tsx @@ -1,15 +1,15 @@ +import { styled } from '@stitches/react' +import { HTMLContainer, Utils } from '@tldraw/core' import * as React from 'react' -import { Utils, HTMLContainer } from '@tldraw/core' -import { TDShapeType, TDMeta, ImageShape, TDImageAsset } from '~types' import { GHOSTED_OPACITY } from '~constants' -import { TDShapeUtil } from '../TDShapeUtil' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' import { defaultStyle, getBoundsRectangle, transformRectangle, transformSingleRectangle, } from '~state/shapes/shared' -import { styled } from '@stitches/react' +import { ImageShape, TDImageAsset, TDMeta, TDShapeType } from '~types' type T = ImageShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/RectangleUtil/RectangleUtil.tsx b/packages/tldraw/src/state/shapes/RectangleUtil/RectangleUtil.tsx index 670805f70..2c2fca4bc 100644 --- a/packages/tldraw/src/state/shapes/RectangleUtil/RectangleUtil.tsx +++ b/packages/tldraw/src/state/shapes/RectangleUtil/RectangleUtil.tsx @@ -1,22 +1,22 @@ +import { SVGContainer, Utils } from '@tldraw/core' import * as React from 'react' -import { Utils, SVGContainer } from '@tldraw/core' -import { RectangleShape, DashStyle, TDShapeType, TDMeta } from '~types' import { GHOSTED_OPACITY, LABEL_POINT } from '~constants' -import { TDShapeUtil } from '../TDShapeUtil' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' import { + TextLabel, defaultStyle, - getShapeStyle, getBoundsRectangle, - transformRectangle, getFontStyle, + getShapeStyle, + transformRectangle, transformSingleRectangle, } from '~state/shapes/shared' -import { TextLabel } from '../shared/TextLabel' -import { getRectangleIndicatorPathTDSnapshot } from './rectangleHelpers' -import { DrawRectangle } from './components/DrawRectangle' -import { DashedRectangle } from './components/DashedRectangle' -import { BindingIndicator } from './components/BindingIndicator' import { styled } from '~styles' +import { DashStyle, RectangleShape, TDMeta, TDShapeType } from '~types' +import { BindingIndicator } from './components/BindingIndicator' +import { DashedRectangle } from './components/DashedRectangle' +import { DrawRectangle } from './components/DrawRectangle' +import { getRectangleIndicatorPathTDSnapshot } from './rectangleHelpers' type T = RectangleShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/RectangleUtil/components/DashedRectangle.tsx b/packages/tldraw/src/state/shapes/RectangleUtil/components/DashedRectangle.tsx index d199f30c3..df30b1726 100644 --- a/packages/tldraw/src/state/shapes/RectangleUtil/components/DashedRectangle.tsx +++ b/packages/tldraw/src/state/shapes/RectangleUtil/components/DashedRectangle.tsx @@ -1,8 +1,8 @@ -import * as React from 'react' import { Utils } from '@tldraw/core' +import * as React from 'react' import { BINDING_DISTANCE } from '~constants' -import type { ShapeStyles } from '~types' import { getShapeStyle } from '~state/shapes/shared' +import type { ShapeStyles } from '~types' interface RectangleSvgProps { id: string diff --git a/packages/tldraw/src/state/shapes/RectangleUtil/rectangleHelpers.ts b/packages/tldraw/src/state/shapes/RectangleUtil/rectangleHelpers.ts index fa7707459..f88354c3e 100644 --- a/packages/tldraw/src/state/shapes/RectangleUtil/rectangleHelpers.ts +++ b/packages/tldraw/src/state/shapes/RectangleUtil/rectangleHelpers.ts @@ -1,8 +1,8 @@ import { Utils } from '@tldraw/core' import Vec from '@tldraw/vec' import getStroke, { getStrokePoints } from 'perfect-freehand' +import { getShapeStyle } from '~state/shapes/shared' import type { ShapeStyles } from '~types' -import { getShapeStyle } from '../shared' function getRectangleDrawPoints(id: string, style: ShapeStyles, size: number[]) { const styles = getShapeStyle(style) diff --git a/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx b/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx index 5b6a42851..70a4d59f7 100644 --- a/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx +++ b/packages/tldraw/src/state/shapes/StickyUtil/StickyUtil.tsx @@ -1,15 +1,20 @@ -import * as React from 'react' -import { Utils, HTMLContainer, TLBounds } from '@tldraw/core' -import { AlignStyle, StickyShape, TDMeta, TDShapeType, TransformInfo } from '~types' -import { defaultTextStyle, getBoundsRectangle, TextAreaUtils } from '../shared' -import { TDShapeUtil } from '../TDShapeUtil' -import { getStickyFontStyle, getStickyShapeStyle } from '../shared/shape-styles' -import { styled } from '~styles' +import { HTMLContainer, TLBounds, Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' +import * as React from 'react' +import { stopPropagation } from '~components/stopPropagation' import { GHOSTED_OPACITY } from '~constants' import { TLDR } from '~state/TLDR' -import { getTextSvgElement } from '../shared/getTextSvgElement' -import { stopPropagation } from '~components/stopPropagation' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' +import { + TextAreaUtils, + defaultTextStyle, + getBoundsRectangle, + getStickyFontStyle, + getStickyShapeStyle, + getTextSvgElement, +} from '~state/shapes/shared' +import { styled } from '~styles' +import { AlignStyle, StickyShape, TDMeta, TDShapeType, TransformInfo } from '~types' type T = StickyShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/TDShapeUtil.tsx b/packages/tldraw/src/state/shapes/TDShapeUtil.tsx index c400f067a..5601b4952 100644 --- a/packages/tldraw/src/state/shapes/TDShapeUtil.tsx +++ b/packages/tldraw/src/state/shapes/TDShapeUtil.tsx @@ -1,17 +1,17 @@ -import { Utils, TLShapeUtil } from '@tldraw/core' -import type { TLPointerInfo, TLBounds } from '@tldraw/core' +import { TLShapeUtil, Utils } from '@tldraw/core' +import type { TLBounds, TLPointerInfo } from '@tldraw/core' import { intersectLineSegmentBounds, intersectLineSegmentPolyline, intersectRayBounds, } from '@tldraw/intersect' import { Vec } from '@tldraw/vec' -import type { ShapesWithProp, TDBinding, TDMeta, TDShape, TransformInfo } from '~types' import * as React from 'react' import { BINDING_DISTANCE } from '~constants' -import { getTextSvgElement } from './shared/getTextSvgElement' -import { getTextLabelSize } from './shared/getTextSize' +import type { ShapesWithProp, TDBinding, TDMeta, TDShape, TransformInfo } from '~types' import { getFontStyle, getShapeStyle } from './shared' +import { getTextLabelSize } from './shared/getTextSize' +import { getTextSvgElement } from './shared/getTextSvgElement' export abstract class TDShapeUtil extends TLShapeUtil< T, diff --git a/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx b/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx index 8ad5befb2..fff6fd555 100644 --- a/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx +++ b/packages/tldraw/src/state/shapes/TextUtil/TextUtil.tsx @@ -1,20 +1,20 @@ -import * as React from 'react' -import { Utils, HTMLContainer, TLBounds } from '@tldraw/core' -import { TextShape, TDMeta, TDShapeType, TransformInfo, AlignStyle } from '~types' -import { BINDING_DISTANCE, GHOSTED_OPACITY, LETTER_SPACING } from '~constants' -import { TDShapeUtil } from '../TDShapeUtil' -import { styled } from '~styles' +import { HTMLContainer, TLBounds, Utils } from '@tldraw/core' import { Vec } from '@tldraw/vec' -import { TLDR } from '~state/TLDR' +import * as React from 'react' import { stopPropagation } from '~components/stopPropagation' +import { BINDING_DISTANCE, GHOSTED_OPACITY, LETTER_SPACING } from '~constants' +import { TLDR } from '~state/TLDR' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' import { - getTextSvgElement, TextAreaUtils, defaultTextStyle, - getShapeStyle, getFontStyle, + getShapeStyle, getTextAlign, -} from '../shared' + getTextSvgElement, +} from '~state/shapes/shared' +import { styled } from '~styles' +import { AlignStyle, TDMeta, TDShapeType, TextShape, TransformInfo } from '~types' type T = TextShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/TriangleUtil/TriangleUtil.tsx b/packages/tldraw/src/state/shapes/TriangleUtil/TriangleUtil.tsx index 09265afa8..21609e816 100644 --- a/packages/tldraw/src/state/shapes/TriangleUtil/TriangleUtil.tsx +++ b/packages/tldraw/src/state/shapes/TriangleUtil/TriangleUtil.tsx @@ -1,27 +1,28 @@ -import * as React from 'react' -import { Utils, SVGContainer, TLBounds } from '@tldraw/core' -import { TriangleShape, TDShapeType, TDMeta, TDShape, DashStyle } from '~types' -import { TDShapeUtil } from '../TDShapeUtil' -import { - defaultStyle, - getBoundsRectangle, - transformRectangle, - transformSingleRectangle, - getFontStyle, -} from '~state/shapes/shared' +import { SVGContainer, TLBounds, Utils } from '@tldraw/core' import { intersectBoundsPolygon, intersectLineSegmentPolyline, intersectRayLineSegment, } from '@tldraw/intersect' import Vec from '@tldraw/vec' +import * as React from 'react' import { BINDING_DISTANCE, GHOSTED_OPACITY, LABEL_POINT } from '~constants' -import { getTriangleCentroid, getTrianglePoints } from './triangleHelpers' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' +import { + TextLabel, + defaultStyle, + getBoundsRectangle, + getFontStyle, + getShapeStyle, + transformRectangle, + transformSingleRectangle, +} from '~state/shapes/shared' import { styled } from '~styles' -import { DrawTriangle } from './components/DrawTriangle' +import { DashStyle, TDMeta, TDShape, TDShapeType, TriangleShape } from '~types' import { DashedTriangle } from './components/DashedTriangle' -import { TextLabel, getShapeStyle } from '../shared' +import { DrawTriangle } from './components/DrawTriangle' import { TriangleBindingIndicator } from './components/TriangleBindingIndicator' +import { getTriangleCentroid, getTrianglePoints } from './triangleHelpers' type T = TriangleShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/TriangleUtil/components/DashedTriangle.tsx b/packages/tldraw/src/state/shapes/TriangleUtil/components/DashedTriangle.tsx index 08360f54d..01cd30886 100644 --- a/packages/tldraw/src/state/shapes/TriangleUtil/components/DashedTriangle.tsx +++ b/packages/tldraw/src/state/shapes/TriangleUtil/components/DashedTriangle.tsx @@ -1,9 +1,9 @@ -import * as React from 'react' import { Utils } from '@tldraw/core' -import type { ShapeStyles } from '~types' -import { getShapeStyle } from '~state/shapes/shared' -import { getTrianglePoints } from '../triangleHelpers' import Vec from '@tldraw/vec' +import * as React from 'react' +import { getShapeStyle } from '~state/shapes/shared' +import type { ShapeStyles } from '~types' +import { getTrianglePoints } from '../triangleHelpers' interface TriangleSvgProps { id: string diff --git a/packages/tldraw/src/state/shapes/TriangleUtil/triangleHelpers.ts b/packages/tldraw/src/state/shapes/TriangleUtil/triangleHelpers.ts index 6b889b860..4e63f5382 100644 --- a/packages/tldraw/src/state/shapes/TriangleUtil/triangleHelpers.ts +++ b/packages/tldraw/src/state/shapes/TriangleUtil/triangleHelpers.ts @@ -1,9 +1,8 @@ import { Utils } from '@tldraw/core' import Vec from '@tldraw/vec' import getStroke, { getStrokePoints } from 'perfect-freehand' +import { getOffsetPolygon, getShapeStyle } from '~state/shapes/shared' import type { ShapeStyles } from '~types' -import { getShapeStyle } from '../shared' -import { getOffsetPolygon } from '../shared/PolygonUtils' export function getTrianglePoints(size: number[], offset = 0, rotation = 0) { const [w, h] = size diff --git a/packages/tldraw/src/state/shapes/VideoUtil/VideoUtil.tsx b/packages/tldraw/src/state/shapes/VideoUtil/VideoUtil.tsx index 1d96e210b..e68e8dd32 100644 --- a/packages/tldraw/src/state/shapes/VideoUtil/VideoUtil.tsx +++ b/packages/tldraw/src/state/shapes/VideoUtil/VideoUtil.tsx @@ -1,15 +1,15 @@ +import { styled } from '@stitches/react' +import { HTMLContainer, Utils } from '@tldraw/core' import * as React from 'react' -import { Utils, HTMLContainer } from '@tldraw/core' -import { TDShapeType, TDMeta, VideoShape, TDVideoAsset } from '~types' import { GHOSTED_OPACITY } from '~constants' -import { TDShapeUtil } from '../TDShapeUtil' +import { TDShapeUtil } from '~state/shapes/TDShapeUtil' import { defaultStyle, getBoundsRectangle, transformRectangle, transformSingleRectangle, } from '~state/shapes/shared' -import { styled } from '@stitches/react' +import { TDMeta, TDShapeType, TDVideoAsset, VideoShape } from '~types' type T = VideoShape type E = HTMLDivElement diff --git a/packages/tldraw/src/state/shapes/index.ts b/packages/tldraw/src/state/shapes/index.ts index ce3a79d9d..3a0126ad9 100644 --- a/packages/tldraw/src/state/shapes/index.ts +++ b/packages/tldraw/src/state/shapes/index.ts @@ -1,14 +1,14 @@ -import type { TDShapeUtil } from './TDShapeUtil' -import { RectangleUtil } from './RectangleUtil' -import { TriangleUtil } from './TriangleUtil' -import { EllipseUtil } from './EllipseUtil' +import type { TDShapeUtil } from '~state/shapes/TDShapeUtil' +import { TDShape, TDShapeType } from '~types' import { ArrowUtil } from './ArrowUtil' +import { DrawUtil } from './DrawUtil' +import { EllipseUtil } from './EllipseUtil' import { GroupUtil } from './GroupUtil' +import { ImageUtil } from './ImageUtil' +import { RectangleUtil } from './RectangleUtil' import { StickyUtil } from './StickyUtil' import { TextUtil } from './TextUtil' -import { DrawUtil } from './DrawUtil' -import { ImageUtil } from './ImageUtil' -import { TDShape, TDShapeType } from '~types' +import { TriangleUtil } from './TriangleUtil' import { VideoUtil } from './VideoUtil' export const Rectangle = new RectangleUtil() diff --git a/packages/tldraw/src/state/shapes/shared/TextLabel.tsx b/packages/tldraw/src/state/shapes/shared/TextLabel.tsx index 974060d04..ef949af6b 100644 --- a/packages/tldraw/src/state/shapes/shared/TextLabel.tsx +++ b/packages/tldraw/src/state/shapes/shared/TextLabel.tsx @@ -3,8 +3,8 @@ import { stopPropagation } from '~components/stopPropagation' import { GHOSTED_OPACITY, LETTER_SPACING } from '~constants' import { TLDR } from '~state/TLDR' import { styled } from '~styles' -import { getTextLabelSize } from './getTextSize' import { TextAreaUtils } from './TextAreaUtils' +import { getTextLabelSize } from './getTextSize' export interface TextLabelProps { font: string diff --git a/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts b/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts index ea69408e6..fbeaa6bb1 100644 --- a/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts +++ b/packages/tldraw/src/state/shapes/shared/getTextSvgElement.ts @@ -1,8 +1,8 @@ import type { TLBounds } from '@tldraw/core' -import { AlignStyle, ShapeStyles } from '~types' -import { getFontFace, getFontSize } from './shape-styles' -import { getTextAlign } from './getTextAlign' import { LINE_HEIGHT } from '~constants' +import { AlignStyle, ShapeStyles } from '~types' +import { getTextAlign } from './getTextAlign' +import { getFontFace, getFontSize } from './shape-styles' export function getTextSvgElement(text: string, style: ShapeStyles, bounds: TLBounds) { const fontSize = getFontSize(style.size, style.font) diff --git a/packages/tldraw/src/state/shapes/shared/index.ts b/packages/tldraw/src/state/shapes/shared/index.ts index 0e45426a5..7100eb44c 100644 --- a/packages/tldraw/src/state/shapes/shared/index.ts +++ b/packages/tldraw/src/state/shapes/shared/index.ts @@ -1,8 +1,11 @@ export * from './getBoundsRectangle' +export * from './getTextAlign' +export * from './getTextSize' +export * from './getTextSvgElement' +export * from './LabelMask' +export * from './PolygonUtils' +export * from './shape-styles' +export * from './TextAreaUtils' +export * from './TextLabel' export * from './transformRectangle' export * from './transformSingleRectangle' -export * from './TextAreaUtils' -export * from './shape-styles' -export * from './getTextAlign' -export * from './TextLabel' -export * from './getTextSvgElement' diff --git a/packages/tldraw/src/state/shapes/shared/shape-styles.ts b/packages/tldraw/src/state/shapes/shared/shape-styles.ts index 9f238ba99..729a37d27 100644 --- a/packages/tldraw/src/state/shapes/shared/shape-styles.ts +++ b/packages/tldraw/src/state/shapes/shared/shape-styles.ts @@ -1,5 +1,5 @@ import { Utils } from '@tldraw/core' -import { Theme, ColorStyle, DashStyle, ShapeStyles, SizeStyle, FontStyle, AlignStyle } from '~types' +import { AlignStyle, ColorStyle, DashStyle, FontStyle, ShapeStyles, SizeStyle, Theme } from '~types' const canvasLight = '#fafafa' diff --git a/packages/tldraw/src/state/tools/ArrowTool/ArrowTool.ts b/packages/tldraw/src/state/tools/ArrowTool/ArrowTool.ts index a15f3c2b3..845e8ee20 100644 --- a/packages/tldraw/src/state/tools/ArrowTool/ArrowTool.ts +++ b/packages/tldraw/src/state/tools/ArrowTool/ArrowTool.ts @@ -1,8 +1,8 @@ -import { Utils, TLPointerEventHandler } from '@tldraw/core' +import { TLPointerEventHandler, Utils } from '@tldraw/core' import Vec from '@tldraw/vec' import { Arrow } from '~state/shapes' +import { BaseTool, Status } from '~state/tools/BaseTool' import { SessionType, TDShapeType } from '~types' -import { BaseTool, Status } from '../BaseTool' export class ArrowTool extends BaseTool { type = TDShapeType.Arrow as const diff --git a/packages/tldraw/src/state/tools/BaseTool.ts b/packages/tldraw/src/state/tools/BaseTool.ts index 8b990f64a..9a73cc85a 100644 --- a/packages/tldraw/src/state/tools/BaseTool.ts +++ b/packages/tldraw/src/state/tools/BaseTool.ts @@ -4,7 +4,7 @@ import { TLPointerEventHandler, Utils, } from '@tldraw/core' -import type { TldrawApp } from '../internal' +import type { TldrawApp } from '~state/TldrawApp' import { TDEventHandler, TDToolType } from '~types' export enum Status { diff --git a/packages/tldraw/src/state/tools/DrawTool/DrawTool.ts b/packages/tldraw/src/state/tools/DrawTool/DrawTool.ts index cc236285b..f52dba9a3 100644 --- a/packages/tldraw/src/state/tools/DrawTool/DrawTool.ts +++ b/packages/tldraw/src/state/tools/DrawTool/DrawTool.ts @@ -1,7 +1,7 @@ -import { Utils, TLPointerEventHandler } from '@tldraw/core' +import { TLPointerEventHandler, Utils } from '@tldraw/core' import { Draw } from '~state/shapes' +import { BaseTool } from '~state/tools/BaseTool' import { SessionType, TDShapeType } from '~types' -import { BaseTool } from '../BaseTool' enum Status { Idle = 'idle', diff --git a/packages/tldraw/src/state/tools/EllipseTool/EllipseTool.ts b/packages/tldraw/src/state/tools/EllipseTool/EllipseTool.ts index 8a8f2a8bd..34af65dfd 100644 --- a/packages/tldraw/src/state/tools/EllipseTool/EllipseTool.ts +++ b/packages/tldraw/src/state/tools/EllipseTool/EllipseTool.ts @@ -1,8 +1,8 @@ -import { Utils, TLPointerEventHandler, TLBoundsCorner } from '@tldraw/core' +import { TLBoundsCorner, TLPointerEventHandler, Utils } from '@tldraw/core' import Vec from '@tldraw/vec' import { Ellipse } from '~state/shapes' +import { BaseTool, Status } from '~state/tools/BaseTool' import { SessionType, TDShapeType } from '~types' -import { BaseTool, Status } from '../BaseTool' export class EllipseTool extends BaseTool { type = TDShapeType.Ellipse as const diff --git a/packages/tldraw/src/state/tools/EraseTool/EraseTool.ts b/packages/tldraw/src/state/tools/EraseTool/EraseTool.ts index e5d710420..a446e3e7f 100644 --- a/packages/tldraw/src/state/tools/EraseTool/EraseTool.ts +++ b/packages/tldraw/src/state/tools/EraseTool/EraseTool.ts @@ -1,8 +1,8 @@ -import Vec from '@tldraw/vec' import type { TLPointerEventHandler } from '@tldraw/core' -import { SessionType } from '~types' -import { BaseTool } from '../BaseTool' +import Vec from '@tldraw/vec' import { DEAD_ZONE } from '~constants' +import { BaseTool } from '~state/tools/BaseTool' +import { SessionType } from '~types' enum Status { Idle = 'idle', diff --git a/packages/tldraw/src/state/tools/LineTool/LineTool.ts b/packages/tldraw/src/state/tools/LineTool/LineTool.ts index a7c8087dd..91009c506 100644 --- a/packages/tldraw/src/state/tools/LineTool/LineTool.ts +++ b/packages/tldraw/src/state/tools/LineTool/LineTool.ts @@ -1,8 +1,8 @@ -import { Utils, TLPointerEventHandler } from '@tldraw/core' +import { TLPointerEventHandler, Utils } from '@tldraw/core' import Vec from '@tldraw/vec' import { Arrow } from '~state/shapes' +import { BaseTool, Status } from '~state/tools/BaseTool' import { SessionType, TDShapeType } from '~types' -import { BaseTool, Status } from '../BaseTool' export class LineTool extends BaseTool { type = TDShapeType.Line as const diff --git a/packages/tldraw/src/state/tools/RectangleTool/RectangleTool.ts b/packages/tldraw/src/state/tools/RectangleTool/RectangleTool.ts index c366d56f0..bb7ed1042 100644 --- a/packages/tldraw/src/state/tools/RectangleTool/RectangleTool.ts +++ b/packages/tldraw/src/state/tools/RectangleTool/RectangleTool.ts @@ -1,8 +1,8 @@ -import { Utils, TLPointerEventHandler, TLBoundsCorner } from '@tldraw/core' +import { TLBoundsCorner, TLPointerEventHandler, Utils } from '@tldraw/core' import Vec from '@tldraw/vec' import { Rectangle } from '~state/shapes' +import { BaseTool, Status } from '~state/tools/BaseTool' import { SessionType, TDShapeType } from '~types' -import { BaseTool, Status } from '../BaseTool' export class RectangleTool extends BaseTool { type = TDShapeType.Rectangle as const diff --git a/packages/tldraw/src/state/tools/SelectTool/SelectTool.spec.ts b/packages/tldraw/src/state/tools/SelectTool/SelectTool.spec.ts index 81bd79654..c03586db4 100644 --- a/packages/tldraw/src/state/tools/SelectTool/SelectTool.spec.ts +++ b/packages/tldraw/src/state/tools/SelectTool/SelectTool.spec.ts @@ -1,4 +1,4 @@ -import { mockDocument, TldrawTestApp } from '~test' +import { TldrawTestApp, mockDocument } from '~test' import { SessionType, TDShapeType } from '~types' import { SelectTool } from '.' diff --git a/packages/tldraw/src/state/tools/SelectTool/SelectTool.ts b/packages/tldraw/src/state/tools/SelectTool/SelectTool.ts index 4675bfb1b..503714517 100644 --- a/packages/tldraw/src/state/tools/SelectTool/SelectTool.ts +++ b/packages/tldraw/src/state/tools/SelectTool/SelectTool.ts @@ -4,16 +4,16 @@ import { TLBoundsEventHandler, TLBoundsHandleEventHandler, TLCanvasEventHandler, - TLPointerEventHandler, TLKeyboardEventHandler, + TLPointerEventHandler, TLShapeCloneHandler, Utils, } from '@tldraw/core' -import { SessionType, TDShapeType } from '~types' -import { BaseTool } from '../BaseTool' import Vec from '@tldraw/vec' -import { TLDR } from '~state/TLDR' import { CLONING_DISTANCE, DEAD_ZONE } from '~constants' +import { TLDR } from '~state/TLDR' +import { BaseTool } from '~state/tools/BaseTool' +import { SessionType, TDShapeType } from '~types' enum Status { Idle = 'idle', diff --git a/packages/tldraw/src/state/tools/StickyTool/StickyTool.ts b/packages/tldraw/src/state/tools/StickyTool/StickyTool.ts index 471950925..ed85f31c7 100644 --- a/packages/tldraw/src/state/tools/StickyTool/StickyTool.ts +++ b/packages/tldraw/src/state/tools/StickyTool/StickyTool.ts @@ -1,9 +1,9 @@ -import Vec from '@tldraw/vec' import type { TLPointerEventHandler } from '@tldraw/core' import { Utils } from '@tldraw/core' +import Vec from '@tldraw/vec' import { Sticky } from '~state/shapes' +import { BaseTool, Status } from '~state/tools/BaseTool' import { SessionType, TDShapeType } from '~types' -import { BaseTool, Status } from '../BaseTool' export class StickyTool extends BaseTool { type = TDShapeType.Sticky as const diff --git a/packages/tldraw/src/state/tools/TextTool/TextTool.ts b/packages/tldraw/src/state/tools/TextTool/TextTool.ts index 6d18f9c78..cce4ac086 100644 --- a/packages/tldraw/src/state/tools/TextTool/TextTool.ts +++ b/packages/tldraw/src/state/tools/TextTool/TextTool.ts @@ -1,7 +1,7 @@ -import type { TLPointerEventHandler, TLKeyboardEventHandler } from '@tldraw/core' +import type { TLKeyboardEventHandler, TLPointerEventHandler } from '@tldraw/core' import Vec from '@tldraw/vec' +import { BaseTool, Status } from '~state/tools/BaseTool' import { TDShapeType } from '~types' -import { BaseTool, Status } from '../BaseTool' export class TextTool extends BaseTool { type = TDShapeType.Text as const diff --git a/packages/tldraw/src/state/tools/TriangleTool/TriangleTool.ts b/packages/tldraw/src/state/tools/TriangleTool/TriangleTool.ts index 53794df02..11554c0b0 100644 --- a/packages/tldraw/src/state/tools/TriangleTool/TriangleTool.ts +++ b/packages/tldraw/src/state/tools/TriangleTool/TriangleTool.ts @@ -1,8 +1,8 @@ -import { Utils, TLPointerEventHandler, TLBoundsCorner } from '@tldraw/core' +import { TLBoundsCorner, TLPointerEventHandler, Utils } from '@tldraw/core' import Vec from '@tldraw/vec' import { Triangle } from '~state/shapes' +import { BaseTool, Status } from '~state/tools/BaseTool' import { SessionType, TDShapeType } from '~types' -import { BaseTool, Status } from '../BaseTool' export class TriangleTool extends BaseTool { type = TDShapeType.Triangle as const diff --git a/packages/tldraw/src/state/tools/index.ts b/packages/tldraw/src/state/tools/index.ts index bc4090b62..71060e736 100644 --- a/packages/tldraw/src/state/tools/index.ts +++ b/packages/tldraw/src/state/tools/index.ts @@ -1,14 +1,14 @@ import { TDShapeType, TDToolType } from '~types' import { ArrowTool } from './ArrowTool' -import { LineTool } from './LineTool' import { DrawTool } from './DrawTool' import { EllipseTool } from './EllipseTool' +import { EraseTool } from './EraseTool' +import { LineTool } from './LineTool' import { RectangleTool } from './RectangleTool' -import { TriangleTool } from './TriangleTool' import { SelectTool } from './SelectTool' import { StickyTool } from './StickyTool' import { TextTool } from './TextTool' -import { EraseTool } from './EraseTool' +import { TriangleTool } from './TriangleTool' export interface ToolsMap { select: typeof SelectTool diff --git a/packages/tldraw/src/test/TldrawTestApp.tsx b/packages/tldraw/src/test/TldrawTestApp.tsx index aac7c28e7..b35c89baa 100644 --- a/packages/tldraw/src/test/TldrawTestApp.tsx +++ b/packages/tldraw/src/test/TldrawTestApp.tsx @@ -1,4 +1,4 @@ -import { inputs, TLBoundsEdge, TLBoundsCorner, TLBoundsHandle } from '@tldraw/core' +import { TLBoundsCorner, TLBoundsEdge, TLBoundsHandle, inputs } from '@tldraw/core' import { TldrawApp } from '~state' import type { TDShape } from '~types' diff --git a/packages/tldraw/src/test/badDocument.spec.ts b/packages/tldraw/src/test/badDocument.spec.ts index ba65fef21..ff32e40cd 100644 --- a/packages/tldraw/src/test/badDocument.spec.ts +++ b/packages/tldraw/src/test/badDocument.spec.ts @@ -1,5 +1,5 @@ -import { badDocument } from './documents/badDocument' import { TldrawTestApp } from './TldrawTestApp' +import { badDocument } from './documents/badDocument' describe('When loading a bad document', () => { it('Fixes the document', () => { diff --git a/packages/tldraw/src/test/documents/badDocument.ts b/packages/tldraw/src/test/documents/badDocument.ts index 1003abc00..e8fc06e99 100644 --- a/packages/tldraw/src/test/documents/badDocument.ts +++ b/packages/tldraw/src/test/documents/badDocument.ts @@ -1,4 +1,4 @@ -import { TDDocument, ColorStyle, DashStyle, SizeStyle, TDShapeType } from '~types' +import { ColorStyle, DashStyle, SizeStyle, TDDocument, TDShapeType } from '~types' export const badDocument: TDDocument = { version: 0, diff --git a/packages/tldraw/src/test/mockDocument.tsx b/packages/tldraw/src/test/mockDocument.tsx index a2281a128..2d10de0d7 100644 --- a/packages/tldraw/src/test/mockDocument.tsx +++ b/packages/tldraw/src/test/mockDocument.tsx @@ -1,4 +1,4 @@ -import { TDDocument, ColorStyle, DashStyle, SizeStyle, TDShapeType } from '~types' +import { ColorStyle, DashStyle, SizeStyle, TDDocument, TDShapeType } from '~types' export const mockDocument: TDDocument = { version: 0, diff --git a/packages/tldraw/src/test/renderWithContext.tsx b/packages/tldraw/src/test/renderWithContext.tsx index 9f211e277..7708f442d 100644 --- a/packages/tldraw/src/test/renderWithContext.tsx +++ b/packages/tldraw/src/test/renderWithContext.tsx @@ -1,8 +1,8 @@ -import * as React from 'react' -import { TldrawApp } from '~state' -import { useKeyboardShortcuts, TldrawContext } from '~hooks' -import { mockDocument } from './mockDocument' import { render } from '@testing-library/react' +import * as React from 'react' +import { TldrawContext, useKeyboardShortcuts } from '~hooks' +import { TldrawApp } from '~state' +import { mockDocument } from './mockDocument' export const Wrapper = ({ children }: { children: any }) => { const [app] = React.useState(() => new TldrawApp()) diff --git a/packages/tldraw/src/test/renderWithIntlProvider.tsx b/packages/tldraw/src/test/renderWithIntlProvider.tsx index 0781ed788..cce46fc6b 100644 --- a/packages/tldraw/src/test/renderWithIntlProvider.tsx +++ b/packages/tldraw/src/test/renderWithIntlProvider.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import { IntlProvider } from 'react-intl' -import messages_en from '~translations/main.json' import messages_fr from '~translations/fr.json' +import messages_en from '~translations/main.json' export const renderWithIntlProvider = (children: React.ReactNode) => { const messages = { diff --git a/packages/tldraw/src/types.ts b/packages/tldraw/src/types.ts index ce82969ff..146e62ef2 100644 --- a/packages/tldraw/src/types.ts +++ b/packages/tldraw/src/types.ts @@ -1,23 +1,23 @@ import type { - TLPage, - TLUser, - TLPageState, + TLAsset, TLBinding, TLBoundsCorner, TLBoundsEdge, - TLShape, - TLHandle, - TLSnapLine, - TLPinchEventHandler, - TLKeyboardEventHandler, - TLPointerEventHandler, - TLWheelEventHandler, - TLCanvasEventHandler, TLBoundsEventHandler, TLBoundsHandleEventHandler, + TLCanvasEventHandler, + TLHandle, + TLKeyboardEventHandler, + TLPage, + TLPageState, + TLPinchEventHandler, + TLPointerEventHandler, + TLShape, TLShapeBlurHandler, TLShapeCloneHandler, - TLAsset, + TLSnapLine, + TLUser, + TLWheelEventHandler, } from '@tldraw/core' import { TDLanguage } from '~translations' diff --git a/setupTests.ts b/setupTests.ts index df68d0744..6d73517bc 100644 --- a/setupTests.ts +++ b/setupTests.ts @@ -1,5 +1,6 @@ import '@testing-library/jest-dom/extend-expect' import 'fake-indexeddb/auto' + global.ResizeObserver = require('resize-observer-polyfill') Object.defineProperty(window, 'matchMedia', { diff --git a/yarn.lock b/yarn.lock index 5b06968cc..c827066f4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -55,6 +55,32 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.18.6.tgz#8b37d24e88e8e21c499d4328db80577d8882fa53" integrity sha512-tzulrgDT0QD6U7BJ4TKVk2SDDg7wlP39P9yAx1RfLy7vP/7rsDRlWVfbWxElslu56+r7QOhB2NSDsabYYruoZQ== +"@babel/compat-data@^7.18.8": + version "7.18.8" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.18.8.tgz#2483f565faca607b8535590e84e7de323f27764d" + integrity sha512-HSmX4WZPPK3FUxYp7g2T6EyO8j96HlZJlxmKPSh6KAcqwyDrfx7hKjXpAW/0FhFfTJsR0Yt4lAjLI2coMptIHQ== + +"@babel/core@7.17.8": + version "7.17.8" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.8.tgz#3dac27c190ebc3a4381110d46c80e77efe172e1a" + integrity sha512-OdQDV/7cRBtJHLSOBqqbYNkOcydOgnX59TZx4puf41fzcVtN3e/4yqY8lMQsK+5X2lJtAdmA+6OHqsj1hBJ4IQ== + dependencies: + "@ampproject/remapping" "^2.1.0" + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.17.7" + "@babel/helper-compilation-targets" "^7.17.7" + "@babel/helper-module-transforms" "^7.17.7" + "@babel/helpers" "^7.17.8" + "@babel/parser" "^7.17.8" + "@babel/template" "^7.16.7" + "@babel/traverse" "^7.17.3" + "@babel/types" "^7.17.0" + convert-source-map "^1.7.0" + debug "^4.1.0" + gensync "^1.0.0-beta.2" + json5 "^2.1.2" + semver "^6.3.0" + "@babel/core@^7.1.0", "@babel/core@^7.11.1", "@babel/core@^7.12.3", "@babel/core@^7.7.2", "@babel/core@^7.8.0": version "7.17.2" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.17.2.tgz#2c77fc430e95139d816d39b113b31bf40fb22337" @@ -97,6 +123,15 @@ json5 "^2.2.1" semver "^6.3.0" +"@babel/generator@7.17.7": + version "7.17.7" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.7.tgz#8da2599beb4a86194a3b24df6c085931d9ee45ad" + integrity sha512-oLcVCTeIFadUoArDTwpluncplrYBmTCCZZgXCbgNGvOBBiSDDK3eWO4b/+eOTli5tKv1lg+a5/NAXg+nTcei1w== + dependencies: + "@babel/types" "^7.17.0" + jsesc "^2.5.1" + source-map "^0.5.0" + "@babel/generator@^7.17.0", "@babel/generator@^7.7.2": version "7.17.0" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.17.0.tgz#7bd890ba706cd86d3e2f727322346ffdbf98f65e" @@ -106,6 +141,15 @@ jsesc "^2.5.1" source-map "^0.5.0" +"@babel/generator@^7.17.3", "@babel/generator@^7.17.7", "@babel/generator@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.18.9.tgz#68337e9ea8044d6ddc690fb29acae39359cca0a5" + integrity sha512-wt5Naw6lJrL1/SGkipMiFxJjtyczUWTP38deiP1PO60HsBjDeKk08CGC3S8iVuvf0FmTdgKwU1KIXzSKL1G0Ug== + dependencies: + "@babel/types" "^7.18.9" + "@jridgewell/gen-mapping" "^0.3.2" + jsesc "^2.5.1" + "@babel/generator@^7.18.6": version "7.18.7" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.18.7.tgz#2aa78da3c05aadfc82dbac16c99552fc802284bd" @@ -147,6 +191,16 @@ browserslist "^4.17.5" semver "^6.3.0" +"@babel/helper-compilation-targets@^7.17.7": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.9.tgz#69e64f57b524cde3e5ff6cc5a9f4a387ee5563bf" + integrity sha512-tzLCyVmqUiFlcFoAPLA/gL9TeYrF61VLNtb+hvkuVaB5SUjW7jcfrglBIX1vUIoT7CLP3bBlIMeyEsIl2eFQNg== + dependencies: + "@babel/compat-data" "^7.18.8" + "@babel/helper-validator-option" "^7.18.6" + browserslist "^4.20.2" + semver "^6.3.0" + "@babel/helper-compilation-targets@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.18.6.tgz#18d35bfb9f83b1293c22c55b3d576c1315b6ed96" @@ -204,6 +258,11 @@ resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.6.tgz#b7eee2b5b9d70602e59d1a6cad7dd24de7ca6cd7" integrity sha512-8n6gSfn2baOY+qlp+VSzsosjCVGFqWKmDF0cCWOybh52Dw3SEyoWR1KrhMJASjLwIEkkAufZ0xvr+SxLHSpy2Q== +"@babel/helper-environment-visitor@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz#0c0cee9b35d2ca190478756865bb3528422f51be" + integrity sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg== + "@babel/helper-explode-assignable-expression@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.16.7.tgz#12a6d8522fdd834f194e868af6354e8650242b7a" @@ -228,6 +287,14 @@ "@babel/template" "^7.18.6" "@babel/types" "^7.18.6" +"@babel/helper-function-name@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.18.9.tgz#940e6084a55dee867d33b4e487da2676365e86b0" + integrity sha512-fJgWlZt7nxGksJS9a0XdSaI4XvpExnNIgRP+rVefWh5U7BL8pPuir6SJUmFKRfjWQ51OtWSzwOxhaH/EBWWc0A== + dependencies: + "@babel/template" "^7.18.6" + "@babel/types" "^7.18.9" + "@babel/helper-get-function-arity@^7.16.7": version "7.16.7" resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.7.tgz#ea08ac753117a669f1508ba06ebcc49156387419" @@ -284,6 +351,20 @@ "@babel/traverse" "^7.16.7" "@babel/types" "^7.16.7" +"@babel/helper-module-transforms@^7.17.7": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.18.9.tgz#5a1079c005135ed627442df31a42887e80fcb712" + integrity sha512-KYNqY0ICwfv19b31XzvmI/mfcylOzbLtowkw+mfvGPAQ3kfCnMLYbED3YecL5tPd8nAYFQFAd6JHp2LxZk/J1g== + dependencies: + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-module-imports" "^7.18.6" + "@babel/helper-simple-access" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/helper-validator-identifier" "^7.18.6" + "@babel/template" "^7.18.6" + "@babel/traverse" "^7.18.9" + "@babel/types" "^7.18.9" + "@babel/helper-module-transforms@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.18.6.tgz#57e3ca669e273d55c3cda55e6ebf552f37f483c8" @@ -409,6 +490,15 @@ "@babel/traverse" "^7.17.0" "@babel/types" "^7.17.0" +"@babel/helpers@^7.17.8": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.18.9.tgz#4bef3b893f253a1eced04516824ede94dcfe7ff9" + integrity sha512-Jf5a+rbrLoR4eNdUmnFu8cN5eNJT6qdTdOg5IHIzq87WwyRw9PwguLFOWYgktN/60IP4fgDUawJvs7PjQIzELQ== + dependencies: + "@babel/template" "^7.18.6" + "@babel/traverse" "^7.18.9" + "@babel/types" "^7.18.9" + "@babel/helpers@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.18.6.tgz#4c966140eaa1fcaa3d5a8c09d7db61077d4debfd" @@ -436,15 +526,15 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.7", "@babel/parser@^7.17.0": +"@babel/parser@7.17.8", "@babel/parser@^7.0.0", "@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.7", "@babel/parser@^7.17.0", "@babel/parser@^7.17.3", "@babel/parser@^7.17.8", "@babel/parser@^7.18.9": version "7.17.0" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.17.0.tgz#f0ac33eddbe214e4105363bb17c3341c5ffcc43c" integrity sha512-VKXSCQx5D8S04ej+Dqsr1CzYvvWgf20jIw2D+YhQCrIlr2UZGaDds23Y0xg75/skOxpLCRpUZvk/1EAVkGoDOw== "@babel/parser@^7.18.6": - version "7.18.6" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.6.tgz#845338edecad65ebffef058d3be851f1d28a63bc" - integrity sha512-uQVSa9jJUe/G/304lXspfWVpKpK4euFLgGiMQFOCpM/bgcAdeoHwi/OQz23O9GK2osz26ZiXRRV9aV+Yl1O8tw== + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.18.9.tgz#f2dde0c682ccc264a9a8595efd030a5cc8fd2539" + integrity sha512-9uJveS9eY9DJ0t64YbIBZICtJy8a5QrDEVdiLCG97fVLpDTpGX7t8mMSb6OWw6Lrnjqj4O8zwjELX3dhoMgiBg== "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7": version "7.16.7" @@ -1122,6 +1212,22 @@ "@babel/parser" "^7.18.6" "@babel/types" "^7.18.6" +"@babel/traverse@7.17.3": + version "7.17.3" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.3.tgz#0ae0f15b27d9a92ba1f2263358ea7c4e7db47b57" + integrity sha512-5irClVky7TxRWIRtxlh2WPUUOLhcPN06AGgaQSB8AEwuyEBgJVuJ5imdHm5zxk8w0QS5T+tDfnDxAlhWjpb7cw== + dependencies: + "@babel/code-frame" "^7.16.7" + "@babel/generator" "^7.17.3" + "@babel/helper-environment-visitor" "^7.16.7" + "@babel/helper-function-name" "^7.16.7" + "@babel/helper-hoist-variables" "^7.16.7" + "@babel/helper-split-export-declaration" "^7.16.7" + "@babel/parser" "^7.17.3" + "@babel/types" "^7.17.0" + debug "^4.1.0" + globals "^11.1.0" + "@babel/traverse@^7.13.0", "@babel/traverse@^7.16.7", "@babel/traverse@^7.16.8", "@babel/traverse@^7.17.0", "@babel/traverse@^7.7.2": version "7.17.0" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.17.0.tgz#3143e5066796408ccc880a33ecd3184f3e75cd30" @@ -1138,6 +1244,22 @@ debug "^4.1.0" globals "^11.1.0" +"@babel/traverse@^7.17.3", "@babel/traverse@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.18.9.tgz#deeff3e8f1bad9786874cb2feda7a2d77a904f98" + integrity sha512-LcPAnujXGwBgv3/WHv01pHtb2tihcyW1XuL9wd7jqh1Z8AQkTd+QVjMrMijrln0T7ED3UXLIy36P9Ao7W75rYg== + dependencies: + "@babel/code-frame" "^7.18.6" + "@babel/generator" "^7.18.9" + "@babel/helper-environment-visitor" "^7.18.9" + "@babel/helper-function-name" "^7.18.9" + "@babel/helper-hoist-variables" "^7.18.6" + "@babel/helper-split-export-declaration" "^7.18.6" + "@babel/parser" "^7.18.9" + "@babel/types" "^7.18.9" + debug "^4.1.0" + globals "^11.1.0" + "@babel/traverse@^7.18.6": version "7.18.6" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.18.6.tgz#a228562d2f46e89258efa4ddd0416942e2fd671d" @@ -1154,7 +1276,7 @@ debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.16.8", "@babel/types@^7.17.0", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": +"@babel/types@7.17.0", "@babel/types@^7.0.0", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.16.8", "@babel/types@^7.17.0", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": version "7.17.0" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.17.0.tgz#a826e368bccb6b3d84acd76acad5c0d87342390b" integrity sha512-TmKSNO4D5rzhL5bjWFcVHHLETzfQ/AmbKpKPOSjlP0WoHZ6L911fgoOKY4Alp/emzG4cHJdyN49zpgkbXFEHHw== @@ -1170,6 +1292,14 @@ "@babel/helper-validator-identifier" "^7.18.6" to-fast-properties "^2.0.0" +"@babel/types@^7.18.9": + version "7.18.9" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.18.9.tgz#7148d64ba133d8d73a41b3172ac4b83a1452205f" + integrity sha512-WwMLAg2MvJmt/rKEVQBBhIVffMmnilX4oe0sRe7iPOHIGsqpruFHHdrfj4O1CMMtgMtCU4oPafZjDPCRgO57Wg== + dependencies: + "@babel/helper-validator-identifier" "^7.18.6" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -3224,6 +3354,19 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== +"@trivago/prettier-plugin-sort-imports@^3.3.0": + version "3.3.0" + resolved "https://registry.yarnpkg.com/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-3.3.0.tgz#ee4e9ec1d8e3076b95fcb94311f42f7a61eecd37" + integrity sha512-1y44bVZuIN0RsS3oIiGd5k8Vm3IZXYZnp4VsP2Z/S5L9WAOw43HE2clso66M2S/dDeJ+8sKPqnHsEfh39Vjs3w== + dependencies: + "@babel/core" "7.17.8" + "@babel/generator" "7.17.7" + "@babel/parser" "7.17.8" + "@babel/traverse" "7.17.3" + "@babel/types" "7.17.0" + javascript-natural-sort "0.7.1" + lodash "4.17.21" + "@types/aria-query@^4.2.0": version "4.2.2" resolved "https://registry.yarnpkg.com/@types/aria-query/-/aria-query-4.2.2.tgz#ed4e0ad92306a704f9fb132a0cfcf77486dbe2bc" @@ -8015,6 +8158,11 @@ jake@^10.8.5: filelist "^1.0.1" minimatch "^3.0.4" +javascript-natural-sort@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz#f9e2303d4507f6d74355a73664d1440fb5a0ef59" + integrity sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw== + jest-changed-files@^27.5.1: version "27.5.1" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-27.5.1.tgz#a348aed00ec9bf671cc58a66fcbe7c3dfd6a68f5" @@ -8833,7 +8981,7 @@ lodash.startcase@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.startcase/-/lodash.startcase-4.4.0.tgz#9436e34ed26093ed7ffae1936144350915d9add8" integrity sha1-lDbjTtJgk+1/+uGTYUQ1CRXZrdg= -lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.7.0: +lodash@4.17.21, lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -9901,10 +10049,10 @@ prettier@^1.19.1: resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== -prettier@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a" - integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg== +prettier@^2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" + integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== pretty-bytes@^5.3.0, pretty-bytes@^5.4.1: version "5.6.0"