From 31f2eed11898ec66332cf42f88d1bceb0ea7fc2a Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Sat, 15 Nov 2025 17:31:54 -0800 Subject: [PATCH] chore: move various files --- .../draw => }/components/colors/colors.module.css | 0 .../{views/draw => }/components/colors/colors.tsx | 0 client-src/components/colors/index.ts | 1 + .../components/controls/controls.module.css | 0 .../draw => }/components/controls/controls.tsx | 2 +- client-src/components/controls/index.ts | 1 + .../draw => }/components/controls/use-controls.tsx | 2 +- .../draw => }/components/editor/editor.module.css | 0 .../{views/draw => }/components/editor/editor.tsx | 0 client-src/components/editor/index.ts | 1 + client-src/components/slider/index.ts | 1 + .../draw => }/components/slider/slider.module.css | 0 .../{views/draw => }/components/slider/slider.tsx | 0 .../user-message/user-message.tsx} | 0 .../user-toolbar/user-toolbar.tsx} | 12 ++++++------ .../{views/room/state => constants}/frogs.ts | 4 ++-- client-src/{views/room/state => constants}/hats.ts | 4 ++-- .../constants/constants.ts => constants/socket.ts} | 0 client-src/hooks/index.ts | 1 + .../{views/draw => }/hooks/useKeyboardShortcuts.ts | 0 client-src/routes/index.tsx | 14 +++++++------- client-src/services/socket.ts | 6 ++++++ client-src/state/index.ts | 1 + client-src/{views/draw => }/state/shapes/draw.tsx | 2 +- client-src/state/shapes/index.ts | 1 + client-src/{views/draw => }/state/state.ts | 4 ++-- client-src/{views/draw => }/state/types.ts | 0 client-src/{views/draw => utils}/utils.ts | 0 client-src/views/draw/components/colors/index.ts | 1 - client-src/views/draw/components/controls/index.ts | 1 - client-src/views/draw/components/editor/index.ts | 1 - client-src/views/draw/components/slider/index.ts | 1 - client-src/views/draw/hooks/index.ts | 1 - client-src/views/draw/services/socket.ts | 6 ------ client-src/views/draw/state/index.ts | 1 - client-src/views/draw/state/shapes/index.ts | 1 - 36 files changed, 35 insertions(+), 35 deletions(-) rename client-src/{views/draw => }/components/colors/colors.module.css (100%) rename client-src/{views/draw => }/components/colors/colors.tsx (100%) create mode 100644 client-src/components/colors/index.ts rename client-src/{views/draw => }/components/controls/controls.module.css (100%) rename client-src/{views/draw => }/components/controls/controls.tsx (97%) create mode 100644 client-src/components/controls/index.ts rename client-src/{views/draw => }/components/controls/use-controls.tsx (96%) rename client-src/{views/draw => }/components/editor/editor.module.css (100%) rename client-src/{views/draw => }/components/editor/editor.tsx (100%) create mode 100644 client-src/components/editor/index.ts create mode 100644 client-src/components/slider/index.ts rename client-src/{views/draw => }/components/slider/slider.module.css (100%) rename client-src/{views/draw => }/components/slider/slider.tsx (100%) rename client-src/{views/room/UserMessage.tsx => components/user-message/user-message.tsx} (100%) rename client-src/{views/room/UserToolbar.tsx => components/user-toolbar/user-toolbar.tsx} (95%) rename client-src/{views/room/state => constants}/frogs.ts (81%) rename client-src/{views/room/state => constants}/hats.ts (81%) rename client-src/{views/draw/constants/constants.ts => constants/socket.ts} (100%) create mode 100644 client-src/hooks/index.ts rename client-src/{views/draw => }/hooks/useKeyboardShortcuts.ts (100%) create mode 100644 client-src/services/socket.ts create mode 100644 client-src/state/index.ts rename client-src/{views/draw => }/state/shapes/draw.tsx (99%) create mode 100644 client-src/state/shapes/index.ts rename client-src/{views/draw => }/state/state.ts (98%) rename client-src/{views/draw => }/state/types.ts (100%) rename client-src/{views/draw => utils}/utils.ts (100%) delete mode 100644 client-src/views/draw/components/colors/index.ts delete mode 100644 client-src/views/draw/components/controls/index.ts delete mode 100644 client-src/views/draw/components/editor/index.ts delete mode 100644 client-src/views/draw/components/slider/index.ts delete mode 100644 client-src/views/draw/hooks/index.ts delete mode 100644 client-src/views/draw/services/socket.ts delete mode 100644 client-src/views/draw/state/index.ts delete mode 100644 client-src/views/draw/state/shapes/index.ts diff --git a/client-src/views/draw/components/colors/colors.module.css b/client-src/components/colors/colors.module.css similarity index 100% rename from client-src/views/draw/components/colors/colors.module.css rename to client-src/components/colors/colors.module.css diff --git a/client-src/views/draw/components/colors/colors.tsx b/client-src/components/colors/colors.tsx similarity index 100% rename from client-src/views/draw/components/colors/colors.tsx rename to client-src/components/colors/colors.tsx diff --git a/client-src/components/colors/index.ts b/client-src/components/colors/index.ts new file mode 100644 index 0000000..3583214 --- /dev/null +++ b/client-src/components/colors/index.ts @@ -0,0 +1 @@ +export * from "./colors.tsx"; diff --git a/client-src/views/draw/components/controls/controls.module.css b/client-src/components/controls/controls.module.css similarity index 100% rename from client-src/views/draw/components/controls/controls.module.css rename to client-src/components/controls/controls.module.css diff --git a/client-src/views/draw/components/controls/controls.tsx b/client-src/components/controls/controls.tsx similarity index 97% rename from client-src/views/draw/components/controls/controls.tsx rename to client-src/components/controls/controls.tsx index 0cf5427..e1c332f 100644 --- a/client-src/views/draw/components/controls/controls.tsx +++ b/client-src/components/controls/controls.tsx @@ -1,7 +1,7 @@ import { Colors } from "../colors"; import { Slider } from "../slider"; import { app } from "../../state"; -import { useControls, COLORS } from "./use-controls"; +import { useControls, COLORS } from "./use-controls.tsx"; export function Controls() { const { diff --git a/client-src/components/controls/index.ts b/client-src/components/controls/index.ts new file mode 100644 index 0000000..bf11059 --- /dev/null +++ b/client-src/components/controls/index.ts @@ -0,0 +1 @@ +export * from "./controls.tsx"; diff --git a/client-src/views/draw/components/controls/use-controls.tsx b/client-src/components/controls/use-controls.tsx similarity index 96% rename from client-src/views/draw/components/controls/use-controls.tsx rename to client-src/components/controls/use-controls.tsx index e13dc43..d9d233c 100644 --- a/client-src/views/draw/components/controls/use-controls.tsx +++ b/client-src/components/controls/use-controls.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { app, useAppState } from "../../state"; -import type { State } from "../../state/types"; +import type { State } from "../../state/types.ts"; export const COLORS = [ "#000000", diff --git a/client-src/views/draw/components/editor/editor.module.css b/client-src/components/editor/editor.module.css similarity index 100% rename from client-src/views/draw/components/editor/editor.module.css rename to client-src/components/editor/editor.module.css diff --git a/client-src/views/draw/components/editor/editor.tsx b/client-src/components/editor/editor.tsx similarity index 100% rename from client-src/views/draw/components/editor/editor.tsx rename to client-src/components/editor/editor.tsx diff --git a/client-src/components/editor/index.ts b/client-src/components/editor/index.ts new file mode 100644 index 0000000..ba9b6cc --- /dev/null +++ b/client-src/components/editor/index.ts @@ -0,0 +1 @@ +export * from "./editor.tsx"; diff --git a/client-src/components/slider/index.ts b/client-src/components/slider/index.ts new file mode 100644 index 0000000..2dcdf3a --- /dev/null +++ b/client-src/components/slider/index.ts @@ -0,0 +1 @@ +export * from "./slider.tsx"; diff --git a/client-src/views/draw/components/slider/slider.module.css b/client-src/components/slider/slider.module.css similarity index 100% rename from client-src/views/draw/components/slider/slider.module.css rename to client-src/components/slider/slider.module.css diff --git a/client-src/views/draw/components/slider/slider.tsx b/client-src/components/slider/slider.tsx similarity index 100% rename from client-src/views/draw/components/slider/slider.tsx rename to client-src/components/slider/slider.tsx diff --git a/client-src/views/room/UserMessage.tsx b/client-src/components/user-message/user-message.tsx similarity index 100% rename from client-src/views/room/UserMessage.tsx rename to client-src/components/user-message/user-message.tsx diff --git a/client-src/views/room/UserToolbar.tsx b/client-src/components/user-toolbar/user-toolbar.tsx similarity index 95% rename from client-src/views/room/UserToolbar.tsx rename to client-src/components/user-toolbar/user-toolbar.tsx index 082b1b5..677d347 100644 --- a/client-src/views/room/UserToolbar.tsx +++ b/client-src/components/user-toolbar/user-toolbar.tsx @@ -1,10 +1,10 @@ import { RefObject, useMemo, useRef, useState, useEffect } from "react"; -import { Controls } from "../draw/components/controls"; -import { Editor } from "../draw/components/editor"; -import { HATS, REVERSE_HAT_MAP } from "./state/hats"; -import { FROGS, REVERSE_FROG_MAP } from "./state/frogs"; -import { socketSend } from "../draw/services/socket"; -import { app } from "../draw/state"; +import { Controls } from "../controls"; +import { Editor } from "../editor"; +import { HATS, REVERSE_HAT_MAP } from "../../constants/hats.ts"; +import { FROGS, REVERSE_FROG_MAP } from "../../constants/frogs.ts"; +import { socketSend } from "../../services/socket.ts"; +import { app } from "../../state"; const EditPencil = `/StreamlineFreehand-EditPencil.svg`; diff --git a/client-src/views/room/state/frogs.ts b/client-src/constants/frogs.ts similarity index 81% rename from client-src/views/room/state/frogs.ts rename to client-src/constants/frogs.ts index 9594fff..03d685a 100644 --- a/client-src/views/room/state/frogs.ts +++ b/client-src/constants/frogs.ts @@ -1,4 +1,4 @@ -import {FrogSchema} from "../../../../isomophic-src/isomorphic" +import {FrogSchema} from "../../isomophic-src/isomorphic.ts" export const FROG_MAP: Record = FrogSchema.options.reduce((acc, frog) => { const val = frog.value; @@ -16,4 +16,4 @@ export const REVERSE_FROG_MAP: Record = Object.entries(FR return acc; }, {} as Record); -export const FROGS = Object.values(FROG_MAP); \ No newline at end of file +export const FROGS = Object.values(FROG_MAP); diff --git a/client-src/views/room/state/hats.ts b/client-src/constants/hats.ts similarity index 81% rename from client-src/views/room/state/hats.ts rename to client-src/constants/hats.ts index 1bd7f34..04430eb 100644 --- a/client-src/views/room/state/hats.ts +++ b/client-src/constants/hats.ts @@ -1,4 +1,4 @@ -import {HatSchema} from "../../../../isomophic-src/isomorphic" +import {HatSchema} from "../../isomophic-src/isomorphic.ts" export const HAT_MAP: Record = HatSchema.options.reduce((acc, hat) => { const val = hat.value; @@ -16,4 +16,4 @@ export const REVERSE_HAT_MAP: Record = Object.entries(HAT return acc; }, {} as Record); -export const HATS = Object.values(HAT_MAP); \ No newline at end of file +export const HATS = Object.values(HAT_MAP); diff --git a/client-src/views/draw/constants/constants.ts b/client-src/constants/socket.ts similarity index 100% rename from client-src/views/draw/constants/constants.ts rename to client-src/constants/socket.ts diff --git a/client-src/hooks/index.ts b/client-src/hooks/index.ts new file mode 100644 index 0000000..eb2980b --- /dev/null +++ b/client-src/hooks/index.ts @@ -0,0 +1 @@ +export * from "./useKeyboardShortcuts.ts"; diff --git a/client-src/views/draw/hooks/useKeyboardShortcuts.ts b/client-src/hooks/useKeyboardShortcuts.ts similarity index 100% rename from client-src/views/draw/hooks/useKeyboardShortcuts.ts rename to client-src/hooks/useKeyboardShortcuts.ts diff --git a/client-src/routes/index.tsx b/client-src/routes/index.tsx index 3b08387..638082b 100644 --- a/client-src/routes/index.tsx +++ b/client-src/routes/index.tsx @@ -1,5 +1,5 @@ import { createFileRoute } from "@tanstack/react-router"; -import UserToolbar from "../views/room/UserToolbar"; +import UserToolbar from "../components/user-toolbar/user-toolbar.tsx"; import { useEffect, useState } from "react"; import { Frog, @@ -10,12 +10,12 @@ import { DEFAULT_HAT, DEFAULT_FROG, } from "../../isomophic-src/isomorphic"; -import UserMessage from "../views/room/UserMessage"; -import { HAT_MAP } from "../views/room/state/hats"; -import { FROG_MAP } from "../views/room/state/frogs"; -import { socketSend } from "../views/draw/services/socket"; -import { socket } from "../views/draw/constants/constants"; -import { useKeyboardShortcuts } from "../views/draw/hooks"; +import UserMessage from "../components/user-message/user-message.tsx"; +import { HAT_MAP } from "../constants/hats.ts"; +import { FROG_MAP } from "../constants/frogs.ts"; +import { socketSend } from "../services/socket"; +import { socket } from "../constants/socket.ts"; +import { useKeyboardShortcuts } from "../hooks"; export const Route = createFileRoute("/")({ component: Index, diff --git a/client-src/services/socket.ts b/client-src/services/socket.ts new file mode 100644 index 0000000..29e46a6 --- /dev/null +++ b/client-src/services/socket.ts @@ -0,0 +1,6 @@ +import { FromClientSocketMessage } from "../../isomophic-src/isomorphic.ts"; +import { socket } from "../constants/socket.ts"; + +export function socketSend(type: FromClientSocketMessage) { + socket.send(JSON.stringify(type)); +} diff --git a/client-src/state/index.ts b/client-src/state/index.ts new file mode 100644 index 0000000..d2fcb56 --- /dev/null +++ b/client-src/state/index.ts @@ -0,0 +1 @@ +export * from "./state.ts"; diff --git a/client-src/views/draw/state/shapes/draw.tsx b/client-src/state/shapes/draw.tsx similarity index 99% rename from client-src/views/draw/state/shapes/draw.tsx rename to client-src/state/shapes/draw.tsx index 9e1c6db..5f2667a 100644 --- a/client-src/views/draw/state/shapes/draw.tsx +++ b/client-src/state/shapes/draw.tsx @@ -12,7 +12,7 @@ import { } from "@tldraw/intersect"; import { Vec } from "@tldraw/vec"; import { getStroke } from "perfect-freehand"; -import type { DrawShape } from "../types"; +import type { DrawShape } from "../types.ts"; type T = DrawShape; type E = SVGSVGElement; diff --git a/client-src/state/shapes/index.ts b/client-src/state/shapes/index.ts new file mode 100644 index 0000000..e49faed --- /dev/null +++ b/client-src/state/shapes/index.ts @@ -0,0 +1 @@ +export * from "./draw.tsx"; diff --git a/client-src/views/draw/state/state.ts b/client-src/state/state.ts similarity index 98% rename from client-src/views/draw/state/state.ts rename to client-src/state/state.ts index 6672727..4ba6ea6 100644 --- a/client-src/views/draw/state/state.ts +++ b/client-src/state/state.ts @@ -1,11 +1,11 @@ import * as React from "react"; -import type { Doc, DrawShape, DrawStyles, State } from "./types"; +import type { Doc, DrawShape, DrawStyles, State } from "./types.ts"; import { TLPointerEventHandler, TLShapeUtilsMap, Utils } from "@tldraw/core"; import { Vec } from "@tldraw/vec"; import { StateManager } from "rko"; import { draw, DrawUtil } from "./shapes"; import type { StateSelector } from "zustand"; -import { VecRound } from "../utils.ts"; +import { VecRound } from "../utils/utils.ts"; export const shapeUtils: TLShapeUtilsMap = { draw: new DrawUtil(), diff --git a/client-src/views/draw/state/types.ts b/client-src/state/types.ts similarity index 100% rename from client-src/views/draw/state/types.ts rename to client-src/state/types.ts diff --git a/client-src/views/draw/utils.ts b/client-src/utils/utils.ts similarity index 100% rename from client-src/views/draw/utils.ts rename to client-src/utils/utils.ts diff --git a/client-src/views/draw/components/colors/index.ts b/client-src/views/draw/components/colors/index.ts deleted file mode 100644 index bbdc171..0000000 --- a/client-src/views/draw/components/colors/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./colors"; diff --git a/client-src/views/draw/components/controls/index.ts b/client-src/views/draw/components/controls/index.ts deleted file mode 100644 index 06fd433..0000000 --- a/client-src/views/draw/components/controls/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./controls"; diff --git a/client-src/views/draw/components/editor/index.ts b/client-src/views/draw/components/editor/index.ts deleted file mode 100644 index 8b1fd90..0000000 --- a/client-src/views/draw/components/editor/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./editor"; diff --git a/client-src/views/draw/components/slider/index.ts b/client-src/views/draw/components/slider/index.ts deleted file mode 100644 index 67c45bb..0000000 --- a/client-src/views/draw/components/slider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./slider"; diff --git a/client-src/views/draw/hooks/index.ts b/client-src/views/draw/hooks/index.ts deleted file mode 100644 index ef52385..0000000 --- a/client-src/views/draw/hooks/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./useKeyboardShortcuts"; diff --git a/client-src/views/draw/services/socket.ts b/client-src/views/draw/services/socket.ts deleted file mode 100644 index c39d919..0000000 --- a/client-src/views/draw/services/socket.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { FromClientSocketMessage } from "../../../../isomophic-src/isomorphic"; -import { socket } from "../constants/constants"; - -export function socketSend(type: FromClientSocketMessage) { - socket.send(JSON.stringify(type)); -} diff --git a/client-src/views/draw/state/index.ts b/client-src/views/draw/state/index.ts deleted file mode 100644 index be6f715..0000000 --- a/client-src/views/draw/state/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./state"; diff --git a/client-src/views/draw/state/shapes/index.ts b/client-src/views/draw/state/shapes/index.ts deleted file mode 100644 index 1528a45..0000000 --- a/client-src/views/draw/state/shapes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./draw"; -- 2.51.2