refactor: reorganize src structure
This commit is contained in:
+4
-4
@@ -3,11 +3,11 @@
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "bun --hot src/dev-server.tsx",
|
||||
"dev": "bun --hot src/server/dev-server.tsx",
|
||||
"build": "rm -rf dist && bun run build:client && bun run build:server && bun run build:mcp",
|
||||
"build:client": "bun build --target=browser --production --outdir ./dist/public ./src/index.html",
|
||||
"build:server": "mkdir -p ./dist/server && bun build --target=bun --production --outfile ./dist/server/server.js ./src/server.tsx",
|
||||
"build:mcp": "mkdir -p ./dist/mcp && bun build --target=bun --production --outfile ./dist/mcp/mcp-server.js ./src/mcp-server.ts",
|
||||
"build:client": "bun build --target=browser --production --outdir ./dist/public ./src/client/index.html",
|
||||
"build:server": "mkdir -p ./dist/server && bun build --target=bun --production --outfile ./dist/server/server.js ./src/server/http-server.tsx",
|
||||
"build:mcp": "mkdir -p ./dist/mcp && bun build --target=bun --production --outfile ./dist/mcp/mcp-server.js ./src/mcp/server.ts",
|
||||
"start": "DATABASE_PATH=./data/excalidraw.sqlite bun ./dist/server/server.js",
|
||||
"test": "bun test",
|
||||
"typecheck": "tsc --noEmit"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { DrawingSidebar, DrawingsToggle } from "./DrawingSidebar";
|
||||
import { EditorCanvas } from "./EditorCanvas";
|
||||
import { useDrawingSession } from "./useDrawingSession";
|
||||
import { useThemeTokenSync } from "./useThemeTokenSync";
|
||||
import { DrawingSidebar, DrawingsToggle } from "./components/DrawingSidebar";
|
||||
import { EditorCanvas } from "./components/EditorCanvas";
|
||||
import { useDrawingSession } from "./hooks/useDrawingSession";
|
||||
import { useThemeTokenSync } from "./hooks/useThemeTokenSync";
|
||||
|
||||
export function App() {
|
||||
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type DrawingMeta } from "./shared";
|
||||
import { type DrawingMeta } from "../../core/shared";
|
||||
|
||||
type DrawingSidebarProps = {
|
||||
open: boolean;
|
||||
@@ -1,11 +1,11 @@
|
||||
import "../node_modules/@excalidraw/excalidraw/dist/prod/index.css";
|
||||
import "../../../node_modules/@excalidraw/excalidraw/dist/prod/index.css";
|
||||
import { Excalidraw } from "@excalidraw/excalidraw";
|
||||
import type {
|
||||
AppState,
|
||||
BinaryFiles,
|
||||
ExcalidrawInitialDataState,
|
||||
} from "@excalidraw/excalidraw/types";
|
||||
import { type ScenePayload } from "./shared";
|
||||
import { type ScenePayload } from "../../core/shared";
|
||||
|
||||
type EditorCanvasProps = {
|
||||
activeId: string | null;
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "./shared";
|
||||
import { DEFAULT_TITLE, type DrawingMeta, type ScenePayload } from "../../core/shared";
|
||||
|
||||
type DrawingResponse = DrawingMeta & ScenePayload;
|
||||
type ApiErrorBody = { ok: false; error?: string; drawing?: DrawingMeta };
|
||||
@@ -6,7 +6,7 @@
|
||||
<!-- to resolve the hs and css from root -->
|
||||
<base href="/" />
|
||||
<title>excali-box</title>
|
||||
<script type="module" src="./client.tsx"></script>
|
||||
<script type="module" src="./main.tsx"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
@@ -2,9 +2,9 @@ import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { createDrawingStore, type DrawingStore } from "./db";
|
||||
import { createMcpToolHandlers, resolvePublicBaseUrl } from "./mcp-server";
|
||||
import { type ScenePayload } from "./shared";
|
||||
import { type ScenePayload } from "../core/shared";
|
||||
import { createDrawingStore, type DrawingStore } from "../server/db";
|
||||
import { createMcpToolHandlers, resolvePublicBaseUrl } from "./server";
|
||||
|
||||
const cleanup: Array<{ dir: string; store: DrawingStore }> = [];
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { applyPatch, type Operation } from "fast-json-patch";
|
||||
import { createMcpHandler } from "mcp-handler";
|
||||
import { z } from "zod";
|
||||
import { createDrawingStore, type DrawingStore } from "./db";
|
||||
import { normalizeScene, normalizeTitle } from "./scene";
|
||||
import { type ScenePayload } from "./shared";
|
||||
import { normalizeScene, normalizeTitle } from "../core/scene";
|
||||
import { type ScenePayload } from "../core/shared";
|
||||
import { createDrawingStore, type DrawingStore } from "../server/db";
|
||||
|
||||
const sceneSchema = z.object({
|
||||
elements: z.array(z.unknown()),
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type DrawingStore } from "./db";
|
||||
import { type DrawingMeta } from "./shared";
|
||||
import { HttpError, normalizeTitle, parseJsonBody, parseSceneText } from "./scene";
|
||||
import { type DrawingMeta } from "../core/shared";
|
||||
import { HttpError, normalizeTitle, parseJsonBody, parseSceneText } from "../core/scene";
|
||||
|
||||
type RouteRequest = Request & {
|
||||
params?: Record<string, string>;
|
||||
@@ -2,8 +2,8 @@ import { Database } from "bun:sqlite";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { dirname } from "node:path";
|
||||
import { DEFAULT_TITLE, type DrawingMeta, type DrawingRecord, type ScenePayload } from "./shared";
|
||||
import { emptyScene, normalizeScene, normalizeTitle } from "./scene";
|
||||
import { DEFAULT_TITLE, type DrawingMeta, type DrawingRecord, type ScenePayload } from "../core/shared";
|
||||
import { emptyScene, normalizeScene, normalizeTitle } from "../core/scene";
|
||||
|
||||
type DrawingRow = {
|
||||
id: string;
|
||||
@@ -1,5 +1,5 @@
|
||||
import index from "./index.html";
|
||||
import { createServer } from "./server";
|
||||
import index from "../client/index.html";
|
||||
import { createServer } from "./http-server";
|
||||
|
||||
export function createDevServer() {
|
||||
const server = createServer();
|
||||
@@ -3,7 +3,7 @@ import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { createDrawingStore, type DrawingStore } from "./db";
|
||||
import { createServer } from "./server";
|
||||
import { createServer } from "./http-server";
|
||||
|
||||
const cleanup: string[] = [];
|
||||
const stores: DrawingStore[] = [];
|
||||
Reference in New Issue
Block a user