Compare commits

...

15 Commits

Author SHA1 Message Date
imbytecat 036afb8d20 chore: remove React Compiler and @rolldown/plugin-babel 2026-04-01 18:26:09 +08:00
imbytecat 688252fd49 chore(deps): bump @biomejs/biome to 2.4.9 and @orpc/* to 1.13.11 2026-03-26 01:14:09 +08:00
imbytecat 42c2fff7cd chore: update VS Code TypeScript SDK path 2026-03-25 09:58:50 +08:00
imbytecat 034f570794 chore(deps): update TanStack devtools packages 2026-03-25 09:51:21 +08:00
imbytecat ea5935e29b chore(deps): remove babel-plugin-react-compiler 2026-03-25 09:45:37 +08:00
imbytecat 3663f3d010 chore(deps): add @rolldown/plugin-babel and update dependencies
- Add @rolldown/plugin-babel for React compiler support
- Update TypeScript to 6.0.2
- Update TanStack packages (@tanstack/react-query, @tanstack/react-router, @tanstack/react-start)
- Update @vitejs/plugin-react to 6.0.1
- Update Vite to 8.0.2 and Nitro nightly
- Refactor vite.config.ts to use separate babel plugin with reactCompilerPreset
2026-03-25 09:44:13 +08:00
imbytecat 9d1beab2e1 chore: migrate to TypeScript 6.0.2
- Upgrade typescript from 5.9.3 to 6.0.2
- Add explicit types: ['node'] to base tsconfig (TS6 breaking change)
- Remove deprecated baseUrl from server tsconfig
- All typecheck passing
2026-03-25 09:23:07 +08:00
imbytecat 88326c4992 refactor(server): 改用 Vite 原生 tsconfig 路径解析 2026-03-22 01:27:47 +08:00
imbytecat 4e2bc5b8dc chore(deps): 更新 bun lock 2026-03-22 00:39:25 +08:00
imbytecat 9da3df6ad7 chore: 升级 monorepo 依赖版本 2026-03-22 00:02:55 +08:00
imbytecat 9d8a38a4c4 fix: 修正 ORPC handler 语义、加固 Electron 安全、优化构建与运行时配置
- todo.router: create 错误码 NOT_FOUND → INTERNAL_SERVER_ERROR,remove 增加存在性检查
- __root: devtools 仅在 DEV 环境渲染
- Electron: 添加 will-navigate 导航拦截、显式安全 webPreferences、deny-all 权限请求
- sidecar: 空 catch 块补充意图注释,新增 lastResolvedUrl getter
- todo.contract: 硬编码 omit 改用 generatedFieldKeys
- router: QueryClient 添加 staleTime/retry 默认值
- turbo: build 任务精细化 inputs 提升缓存命中率
- fields: id() 改为模块私有
2026-03-05 14:06:43 +08:00
imbytecat cd7448c3b3 docs: 统一使用 bun run <script> 避免与 Bun 内置子命令冲突
bun build 会调用 Bun 内置 bundler 而非 package.json script,
将所有文档中的 bun <script> 改为 bun run <script> 以避免歧义。
bun test 保留不变(直接使用 Bun 内置 test runner)。
2026-03-05 12:57:26 +08:00
imbytecat 58d7a453b6 style: 将 biome lineWidth 从默认 80 调整为 120 2026-03-05 12:28:18 +08:00
imbytecat afc3b66efa refactor: 移除根 package.json 中冗余的 --filter 参数
Turbo 会自动只在定义了对应 script 的包上执行任务,无需手动指定 filter。
2026-03-05 12:08:48 +08:00
imbytecat 3c97e9c3eb refactor: 移除根 turbo.json 中冗余的 compile/dist 任务定义
子包 turbo.json(extends root)已各自定义了完整配置,
根级重复注册无实际作用。
2026-03-05 12:06:11 +08:00
26 changed files with 486 additions and 596 deletions
+1
View File
@@ -43,6 +43,7 @@
"files.watcherExclude": {
"**/routeTree.gen.ts": true
},
"js/ts.tsdk.path": "node_modules/typescript/lib",
"search.exclude": {
"**/routeTree.gen.ts": true
}
+46 -47
View File
@@ -4,7 +4,7 @@ Guidelines for AI agents working in this Bun monorepo.
## Project Overview
> **This project uses [Bun](https://bun.sh) exclusively as both the JavaScript runtime and package manager. Do NOT use Node.js / npm / yarn / pnpm. All commands start with `bun` — use `bun install` for dependencies and `bun run` / `bun <script>` for scripts. Never use `npm`, `npx`, or `node`.**
> **This project uses [Bun](https://bun.sh) exclusively as both the JavaScript runtime and package manager. Do NOT use Node.js / npm / yarn / pnpm. All commands start with `bun` — use `bun install` for dependencies and `bun run <script>` for scripts. Always prefer `bun run <script>` over `bun <script>` to avoid conflicts with Bun built-in subcommands (e.g. `bun build` invokes Bun's bundler, NOT your package.json script). Never use `npm`, `npx`, or `node`.**
- **Monorepo**: Bun workspaces + Turborepo orchestration
- **Runtime**: Bun (see `mise.toml` for version) — **NOT Node.js**
@@ -18,57 +18,57 @@ Guidelines for AI agents working in this Bun monorepo.
### Root Commands (via Turbo)
```bash
bun dev # Start all apps in dev mode
bun build # Build all apps
bun compile # Compile server to standalone binary (current platform)
bun compile:darwin # Compile server for macOS (arm64 + x64)
bun compile:linux # Compile server for Linux (x64 + arm64)
bun compile:windows # Compile server for Windows x64
bun dist # Package desktop distributable (current platform)
bun dist:linux # Package desktop for Linux (x64 + arm64)
bun dist:mac # Package desktop for macOS (arm64 + x64)
bun dist:win # Package desktop for Windows x64
bun fix # Lint + format (Biome auto-fix)
bun typecheck # TypeScript check across monorepo
bun run dev # Start all apps in dev mode
bun run build # Build all apps
bun run compile # Compile server to standalone binary (current platform)
bun run compile:darwin # Compile server for macOS (arm64 + x64)
bun run compile:linux # Compile server for Linux (x64 + arm64)
bun run compile:windows # Compile server for Windows x64
bun run dist # Package desktop distributable (current platform)
bun run dist:linux # Package desktop for Linux (x64 + arm64)
bun run dist:mac # Package desktop for macOS (arm64 + x64)
bun run dist:win # Package desktop for Windows x64
bun run fix # Lint + format (Biome auto-fix)
bun run typecheck # TypeScript check across monorepo
```
### Server App (`apps/server`)
```bash
bun dev # Vite dev server (localhost:3000)
bun build # Production build -> .output/
bun compile # Compile to standalone binary (current platform)
bun compile:darwin # Compile for macOS (arm64 + x64)
bun compile:darwin:arm64 # Compile for macOS arm64
bun compile:darwin:x64 # Compile for macOS x64
bun compile:linux # Compile for Linux (x64 + arm64)
bun compile:linux:arm64 # Compile for Linux arm64
bun compile:linux:x64 # Compile for Linux x64
bun compile:windows # Compile for Windows (default: x64)
bun compile:windows:x64 # Compile for Windows x64
bun fix # Biome auto-fix
bun typecheck # TypeScript check
bun run dev # Vite dev server (localhost:3000)
bun run build # Production build -> .output/
bun run compile # Compile to standalone binary (current platform)
bun run compile:darwin # Compile for macOS (arm64 + x64)
bun run compile:darwin:arm64 # Compile for macOS arm64
bun run compile:darwin:x64 # Compile for macOS x64
bun run compile:linux # Compile for Linux (x64 + arm64)
bun run compile:linux:arm64 # Compile for Linux arm64
bun run compile:linux:x64 # Compile for Linux x64
bun run compile:windows # Compile for Windows (default: x64)
bun run compile:windows:x64 # Compile for Windows x64
bun run fix # Biome auto-fix
bun run typecheck # TypeScript check
# Database (Drizzle)
bun db:generate # Generate migrations from schema
bun db:migrate # Run migrations
bun db:push # Push schema (dev only)
bun db:studio # Open Drizzle Studio
bun run db:generate # Generate migrations from schema
bun run db:migrate # Run migrations
bun run db:push # Push schema (dev only)
bun run db:studio # Open Drizzle Studio
```
### Desktop App (`apps/desktop`)
```bash
bun dev # electron-vite dev mode (requires server dev running)
bun build # electron-vite build (main + preload)
bun dist # Build + package for current platform
bun dist:linux # Build + package for Linux (x64 + arm64)
bun dist:linux:x64 # Build + package for Linux x64
bun dist:linux:arm64 # Build + package for Linux arm64
bun dist:mac # Build + package for macOS (arm64 + x64)
bun dist:mac:arm64 # Build + package for macOS arm64
bun dist:mac:x64 # Build + package for macOS x64
bun dist:win # Build + package for Windows x64
bun fix # Biome auto-fix
bun typecheck # TypeScript check
bun run dev # electron-vite dev mode (requires server dev running)
bun run build # electron-vite build (main + preload)
bun run dist # Build + package for current platform
bun run dist:linux # Build + package for Linux (x64 + arm64)
bun run dist:linux:x64 # Build + package for Linux x64
bun run dist:linux:arm64 # Build + package for Linux arm64
bun run dist:mac # Build + package for macOS (arm64 + x64)
bun run dist:mac:arm64 # Build + package for macOS arm64
bun run dist:mac:x64 # Build + package for macOS x64
bun run dist:win # Build + package for Windows x64
bun run fix # Biome auto-fix
bun run typecheck # TypeScript check
```
### Testing
@@ -113,7 +113,6 @@ import type { ReactNode } from 'react'
- Components: arrow functions (enforced by Biome)
- Routes: TanStack Router file conventions (`export const Route = createFileRoute(...)`)
- Data fetching: `useSuspenseQuery(orpc.feature.list.queryOptions())`
- Let React Compiler handle memoization (no manual `useMemo`/`useCallback`)
### Error Handling
- Use `try-catch` for async operations; throw descriptive errors
@@ -160,7 +159,7 @@ export const myTable = pgTable('my_table', {
## Critical Rules
**DO:**
- Run `bun fix` before committing
- Run `bun run fix` before committing
- Use `@/*` path aliases (not relative imports)
- Include `createdAt`/`updatedAt` on all tables
- Use `catalog:` for dependency versions
@@ -178,9 +177,9 @@ export const myTable = pgTable('my_table', {
## Git Workflow
1. Make changes following style guide
2. `bun fix` - auto-format and lint
3. `bun typecheck` - verify types
4. `bun dev` - test locally
2. `bun run fix` - auto-format and lint
3. `bun run typecheck` - verify types
4. `bun run dev` - test locally
5. Commit with descriptive message
## Directory Structure
+18 -18
View File
@@ -4,7 +4,7 @@ Thin Electron shell hosting the fullstack server app.
## Tech Stack
> **⚠️ This project uses Bun as the package manager. Runtime is Electron (Node.js). Never use `npm`, `npx`, `yarn`, or `pnpm`.**
> **⚠️ This project uses Bun as the package manager. Runtime is Electron (Node.js). Always use `bun run <script>` (not `bun <script>`) to avoid conflicts with Bun built-in subcommands. Never use `npm`, `npx`, `yarn`, or `pnpm`.**
- **Type**: Electron desktop shell
- **Design**: Server-driven desktop (thin native window hosting web app)
@@ -22,18 +22,18 @@ Thin Electron shell hosting the fullstack server app.
## Commands
```bash
bun dev # electron-vite dev (requires server dev running)
bun build # electron-vite build (main + preload)
bun dist # Build + package for current platform
bun dist:linux # Build + package for Linux (x64 + arm64)
bun dist:linux:x64 # Build + package for Linux x64
bun dist:linux:arm64 # Build + package for Linux arm64
bun dist:mac # Build + package for macOS (arm64 + x64)
bun dist:mac:arm64 # Build + package for macOS arm64
bun dist:mac:x64 # Build + package for macOS x64
bun dist:win # Build + package for Windows x64
bun fix # Biome auto-fix
bun typecheck # TypeScript check
bun run dev # electron-vite dev (requires server dev running)
bun run build # electron-vite build (main + preload)
bun run dist # Build + package for current platform
bun run dist:linux # Build + package for Linux (x64 + arm64)
bun run dist:linux:x64 # Build + package for Linux x64
bun run dist:linux:arm64 # Build + package for Linux arm64
bun run dist:mac # Build + package for macOS (arm64 + x64)
bun run dist:mac:arm64 # Build + package for macOS arm64
bun run dist:mac:x64 # Build + package for macOS x64
bun run dist:win # Build + package for Windows x64
bun run fix # Biome auto-fix
bun run typecheck # TypeScript check
```
## Directory Structure
@@ -56,13 +56,13 @@ bun typecheck # TypeScript check
## Development Workflow
1. **Start server**: `bun dev` in `apps/server` (or use root `bun dev` via Turbo).
2. **Start desktop**: `bun dev` in `apps/desktop`.
1. **Start server**: `bun run dev` in `apps/server` (or use root `bun run dev` via Turbo).
2. **Start desktop**: `bun run dev` in `apps/desktop`.
3. **Connection**: Main process polls `localhost:3000` until responsive, then opens BrowserWindow.
## Production Build Workflow
From monorepo root, run `bun dist` to execute the full pipeline automatically (via Turbo task dependencies):
From monorepo root, run `bun run dist` to execute the full pipeline automatically (via Turbo task dependencies):
1. **Build server**: `apps/server``vite build``.output/`
2. **Compile server**: `apps/server``bun compile.ts --target ...``out/server-{os}-{arch}`
@@ -70,8 +70,8 @@ From monorepo root, run `bun dist` to execute the full pipeline automatically (v
The `electron-builder.yml` `extraResources` config reads binaries directly from `../server/out/`, no manual copy needed.
To build for a specific platform explicitly, use `bun dist:linux` / `bun dist:mac` / `bun dist:win` in `apps/desktop`.
For single-arch output, use `bun dist:linux:x64`, `bun dist:linux:arm64`, `bun dist:mac:x64`, or `bun dist:mac:arm64`.
To build for a specific platform explicitly, use `bun run dist:linux` / `bun run dist:mac` / `bun run dist:win` in `apps/desktop`.
For single-arch output, use `bun run dist:linux:x64`, `bun run dist:linux:arm64`, `bun run dist:mac:x64`, or `bun run dist:mac:arm64`.
## Development Principles
+26 -4
View File
@@ -1,5 +1,5 @@
import { join } from 'node:path'
import { app, BrowserWindow, dialog, shell } from 'electron'
import { app, BrowserWindow, dialog, session, shell } from 'electron'
import { createSidecarRuntime } from './sidecar'
const DEV_SERVER_URL = 'http://localhost:3000'
@@ -28,8 +28,7 @@ const sidecar = createSidecarRuntime({
},
})
const toErrorMessage = (error: unknown): string =>
error instanceof Error ? error.message : String(error)
const toErrorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error))
const canOpenExternally = (url: string): boolean => {
try {
@@ -62,6 +61,8 @@ const createWindow = async () => {
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: true,
contextIsolation: true,
nodeIntegration: false,
},
})
mainWindow = windowRef
@@ -79,6 +80,21 @@ const createWindow = async () => {
return { action: 'deny' }
})
windowRef.webContents.on('will-navigate', (event, url) => {
const allowed = [DEV_SERVER_URL, sidecar.lastResolvedUrl].filter((v): v is string => v != null)
const isAllowed = allowed.some((origin) => url.startsWith(origin))
if (!isAllowed) {
event.preventDefault()
if (canOpenExternally(url)) {
void shell.openExternal(url)
} else if (!app.isPackaged) {
console.warn(`Blocked navigation to: ${url}`)
}
}
})
windowRef.on('closed', () => {
if (mainWindow === windowRef) {
mainWindow = null
@@ -152,7 +168,13 @@ const handleWindowCreationError = (error: unknown, context: string) => {
app
.whenReady()
.then(() => ensureWindow())
.then(() => {
session.defaultSession.setPermissionRequestHandler((_webContents, _permission, callback) => {
callback(false)
})
return ensureWindow()
})
.catch((error) => {
handleWindowCreationError(error, 'Failed to create window')
})
+16 -28
View File
@@ -27,14 +27,12 @@ type SidecarRuntimeOptions = {
type SidecarRuntime = {
resolveUrl: () => Promise<string>
stop: () => void
lastResolvedUrl: string | null
}
const sleep = (ms: number): Promise<void> =>
new Promise((resolve) => setTimeout(resolve, ms))
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms))
const isProcessAlive = (
processToCheck: ChildProcess | null,
): processToCheck is ChildProcess => {
const isProcessAlive = (processToCheck: ChildProcess | null): processToCheck is ChildProcess => {
if (!processToCheck || !processToCheck.pid) {
return false
}
@@ -75,17 +73,15 @@ const isServerReady = async (url: string): Promise<boolean> => {
return true
}
} catch {}
} catch {
// Expected: probe request fails while server is still starting up
}
}
return false
}
const waitForServer = async (
url: string,
isQuitting: () => boolean,
processRef?: ChildProcess,
): Promise<boolean> => {
const waitForServer = async (url: string, isQuitting: () => boolean, processRef?: ChildProcess): Promise<boolean> => {
const start = Date.now()
while (Date.now() - start < SERVER_READY_TIMEOUT_MS && !isQuitting()) {
if (processRef && processRef.exitCode !== null) {
@@ -119,9 +115,7 @@ const formatUnexpectedStopMessage = (
return `Server process exited unexpectedly (code ${code ?? 'unknown'}, signal ${signal ?? 'none'}).`
}
export const createSidecarRuntime = (
options: SidecarRuntimeOptions,
): SidecarRuntime => {
export const createSidecarRuntime = (options: SidecarRuntimeOptions): SidecarRuntime => {
const state: SidecarState = {
process: null,
startup: null,
@@ -162,9 +156,7 @@ export const createSidecarRuntime = (
resetState(processRef)
if (!options.isQuitting() && hadReadyServer) {
options.onUnexpectedStop(
'The background service crashed unexpectedly. Please restart the app.',
)
options.onUnexpectedStop('The background service crashed unexpectedly. Please restart the app.')
return
}
@@ -180,9 +172,7 @@ export const createSidecarRuntime = (
resetState(processRef)
if (!options.isQuitting() && hadReadyServer) {
options.onUnexpectedStop(
formatUnexpectedStopMessage(options.isPackaged, code, signal),
)
options.onUnexpectedStop(formatUnexpectedStopMessage(options.isPackaged, code, signal))
}
})
}
@@ -222,11 +212,7 @@ export const createSidecarRuntime = (
state.process = processRef
attachLifecycleHandlers(processRef)
const ready = await waitForServer(
nextServerUrl,
options.isQuitting,
processRef,
)
const ready = await waitForServer(nextServerUrl, options.isQuitting, processRef)
if (ready && isProcessAlive(processRef)) {
state.url = nextServerUrl
return nextServerUrl
@@ -253,16 +239,18 @@ export const createSidecarRuntime = (
const ready = await waitForServer(options.devServerUrl, options.isQuitting)
if (!ready) {
throw new Error(
'Dev server not responding. Run `bun dev` in apps/server first.',
)
throw new Error('Dev server not responding. Run `bun dev` in apps/server first.')
}
state.url = options.devServerUrl
return options.devServerUrl
}
return {
resolveUrl,
stop,
get lastResolvedUrl() {
return state.url
},
}
}
@@ -13,12 +13,7 @@ export const SplashApp = () => {
ease: [0.16, 1, 0.3, 1],
}}
>
<img
alt="Logo"
className="h-20 w-auto object-contain"
draggable={false}
src={logoImage}
/>
<img alt="Logo" className="h-20 w-auto object-contain" draggable={false} src={logoImage} />
<div className="relative h-[4px] w-36 overflow-hidden rounded-full bg-zinc-100">
<motion.div
+2 -10
View File
@@ -10,11 +10,7 @@
"outputs": ["dist/**"]
},
"dist:linux": {
"dependsOn": [
"build",
"@furtherverse/server#compile:linux:arm64",
"@furtherverse/server#compile:linux:x64"
],
"dependsOn": ["build", "@furtherverse/server#compile:linux:arm64", "@furtherverse/server#compile:linux:x64"],
"outputs": ["dist/**"]
},
"dist:linux:arm64": {
@@ -26,11 +22,7 @@
"outputs": ["dist/**"]
},
"dist:mac": {
"dependsOn": [
"build",
"@furtherverse/server#compile:darwin:arm64",
"@furtherverse/server#compile:darwin:x64"
],
"dependsOn": ["build", "@furtherverse/server#compile:darwin:arm64", "@furtherverse/server#compile:darwin:x64"],
"outputs": ["dist/**"]
},
"dist:mac:arm64": {
+21 -22
View File
@@ -4,7 +4,7 @@ TanStack Start fullstack web app with ORPC (contract-first RPC).
## Tech Stack
> **⚠️ This project uses Bun — NOT Node.js / npm. All commands use `bun`. Never use `npm`, `npx`, or `node`.**
> **⚠️ This project uses Bun — NOT Node.js / npm. All commands use `bun`. Always use `bun run <script>` (not `bun <script>`) to avoid conflicts with Bun built-in subcommands. Never use `npm`, `npx`, or `node`.**
- **Framework**: TanStack Start (React 19 SSR, file-based routing)
- **Runtime**: Bun — **NOT Node.js**
@@ -20,33 +20,33 @@ TanStack Start fullstack web app with ORPC (contract-first RPC).
```bash
# Development
bun dev # Vite dev server (localhost:3000)
bun db:studio # Drizzle Studio GUI
bun run dev # Vite dev server (localhost:3000)
bun run db:studio # Drizzle Studio GUI
# Build
bun build # Production build → .output/
bun compile # Compile to standalone binary (current platform, depends on build)
bun compile:darwin # Compile for macOS (arm64 + x64)
bun compile:darwin:arm64 # Compile for macOS arm64
bun compile:darwin:x64 # Compile for macOS x64
bun compile:linux # Compile for Linux (x64 + arm64)
bun compile:linux:arm64 # Compile for Linux arm64
bun compile:linux:x64 # Compile for Linux x64
bun compile:windows # Compile for Windows (default: x64)
bun compile:windows:x64 # Compile for Windows x64
bun run build # Production build → .output/
bun run compile # Compile to standalone binary (current platform, depends on build)
bun run compile:darwin # Compile for macOS (arm64 + x64)
bun run compile:darwin:arm64 # Compile for macOS arm64
bun run compile:darwin:x64 # Compile for macOS x64
bun run compile:linux # Compile for Linux (x64 + arm64)
bun run compile:linux:arm64 # Compile for Linux arm64
bun run compile:linux:x64 # Compile for Linux x64
bun run compile:windows # Compile for Windows (default: x64)
bun run compile:windows:x64 # Compile for Windows x64
# Code Quality
bun fix # Biome auto-fix
bun typecheck # TypeScript check
bun run fix # Biome auto-fix
bun run typecheck # TypeScript check
# Database
bun db:generate # Generate migrations from schema
bun db:migrate # Run migrations
bun db:push # Push schema directly (dev only)
bun run db:generate # Generate migrations from schema
bun run db:migrate # Run migrations
bun run db:push # Push schema directly (dev only)
# Testing (not yet configured)
bun test path/to/test.ts # Run single test
bun test -t "pattern" # Run tests matching pattern
bun test path/to/test.ts # Run single test
bun test -t "pattern" # Run tests matching pattern
```
## Directory Structure
@@ -226,7 +226,6 @@ import type { ReactNode } from 'react'
### React
- Use arrow functions for components (Biome enforced)
- Use `useSuspenseQuery` for guaranteed data
- Let React Compiler handle memoization (no manual `useMemo`/`useCallback`)
## Environment Variables
@@ -257,7 +256,7 @@ export const env = createEnv({
## Critical Rules
**DO:**
- Run `bun fix` before committing
- Run `bun run fix` before committing
- Use `@/*` path aliases
- Include `createdAt`/`updatedAt` on all tables
- Use `ORPCError` with proper codes
+2 -7
View File
@@ -24,9 +24,7 @@ const { values } = parseArgs({
const resolveTarget = (): Bun.Build.CompileTarget => {
if (values.target !== undefined) {
if (!isSupportedTarget(values.target)) {
throw new Error(
`Invalid target: ${values.target}\nAllowed: ${SUPPORTED_TARGETS.join(', ')}`,
)
throw new Error(`Invalid target: ${values.target}\nAllowed: ${SUPPORTED_TARGETS.join(', ')}`)
}
return values.target
}
@@ -45,10 +43,7 @@ const main = async () => {
const outfile = `server-${suffix}`
await mkdir(OUTDIR, { recursive: true })
await Promise.all([
rm(`${OUTDIR}/${outfile}`, { force: true }),
rm(`${OUTDIR}/${outfile}.exe`, { force: true }),
])
await Promise.all([rm(`${OUTDIR}/${outfile}`, { force: true }), rm(`${OUTDIR}/${outfile}.exe`, { force: true })])
const result = await Bun.build({
entrypoints: [ENTRYPOINT],
+1 -3
View File
@@ -50,11 +50,9 @@
"@tanstack/react-router-devtools": "catalog:",
"@types/bun": "catalog:",
"@vitejs/plugin-react": "catalog:",
"babel-plugin-react-compiler": "catalog:",
"drizzle-kit": "catalog:",
"nitro": "catalog:",
"tailwindcss": "catalog:",
"vite": "catalog:",
"vite-tsconfig-paths": "catalog:"
"vite": "catalog:"
}
}
+8 -1
View File
@@ -5,7 +5,14 @@ import type { RouterContext } from './routes/__root'
import { routeTree } from './routeTree.gen'
export const getRouter = () => {
const queryClient = new QueryClient()
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 30 * 1000,
retry: 1,
},
},
})
const router = createRouter({
routeTree,
+18 -20
View File
@@ -1,11 +1,7 @@
import { TanStackDevtools } from '@tanstack/react-devtools'
import type { QueryClient } from '@tanstack/react-query'
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
import {
createRootRouteWithContext,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import { createRootRouteWithContext, HeadContent, Scripts } from '@tanstack/react-router'
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
import type { ReactNode } from 'react'
import { ErrorComponent } from '@/components/Error'
@@ -50,21 +46,23 @@ function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
</head>
<body>
{children}
<TanStackDevtools
config={{
position: 'bottom-right',
}}
plugins={[
{
name: 'TanStack Router',
render: <TanStackRouterDevtoolsPanel />,
},
{
name: 'TanStack Query',
render: <ReactQueryDevtoolsPanel />,
},
]}
/>
{import.meta.env.DEV && (
<TanStackDevtools
config={{
position: 'bottom-right',
}}
plugins={[
{
name: 'TanStack Router',
render: <TanStackRouterDevtoolsPanel />,
},
{
name: 'TanStack Query',
render: <ReactQueryDevtoolsPanel />,
},
]}
/>
)}
<Scripts />
</body>
</html>
+5 -20
View File
@@ -53,9 +53,7 @@ function Todos() {
{/* Header */}
<div className="flex items-end justify-between">
<div>
<h1 className="text-3xl font-bold text-slate-900 tracking-tight">
</h1>
<h1 className="text-3xl font-bold text-slate-900 tracking-tight"></h1>
<p className="text-slate-500 mt-1"></p>
</div>
<div className="text-right">
@@ -63,9 +61,7 @@ function Todos() {
{completedCount}
<span className="text-slate-400 text-lg">/{totalCount}</span>
</div>
<div className="text-xs font-medium text-slate-400 uppercase tracking-wider">
</div>
<div className="text-xs font-medium text-slate-400 uppercase tracking-wider"></div>
</div>
</div>
@@ -112,18 +108,11 @@ function Todos() {
stroke="currentColor"
aria-hidden="true"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
/>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg>
</div>
<p className="text-slate-500 text-lg font-medium"></p>
<p className="text-slate-400 text-sm mt-1">
</p>
<p className="text-slate-400 text-sm mt-1"></p>
</div>
) : (
todos.map((todo) => (
@@ -151,11 +140,7 @@ function Todos() {
strokeWidth={3}
aria-hidden="true"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M5 13l4 4L19 7"
/>
<path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
</svg>
)}
</button>
@@ -1,25 +1,14 @@
import { oc } from '@orpc/contract'
import {
createInsertSchema,
createSelectSchema,
createUpdateSchema,
} from 'drizzle-orm/zod'
import { createInsertSchema, createSelectSchema, createUpdateSchema } from 'drizzle-orm/zod'
import { z } from 'zod'
import { generatedFieldKeys } from '@/server/db/fields'
import { todoTable } from '@/server/db/schema'
const selectSchema = createSelectSchema(todoTable)
const insertSchema = createInsertSchema(todoTable).omit({
id: true,
createdAt: true,
updatedAt: true,
})
const insertSchema = createInsertSchema(todoTable).omit(generatedFieldKeys)
const updateSchema = createUpdateSchema(todoTable).omit({
id: true,
createdAt: true,
updatedAt: true,
})
const updateSchema = createUpdateSchema(todoTable).omit(generatedFieldKeys)
export const list = oc.input(z.void()).output(z.array(selectSchema))
+2 -10
View File
@@ -6,11 +6,7 @@ export const logError = (error: unknown) => {
}
export const handleValidationError = (error: unknown) => {
if (
error instanceof ORPCError &&
error.code === 'BAD_REQUEST' &&
error.cause instanceof ValidationError
) {
if (error instanceof ORPCError && error.code === 'BAD_REQUEST' && error.cause instanceof ValidationError) {
// If you only use Zod you can safely cast to ZodIssue[] (per ORPC official docs)
const zodError = new z.ZodError(error.cause.issues as z.core.$ZodIssue[])
@@ -22,11 +18,7 @@ export const handleValidationError = (error: unknown) => {
})
}
if (
error instanceof ORPCError &&
error.code === 'INTERNAL_SERVER_ERROR' &&
error.cause instanceof ValidationError
) {
if (error instanceof ORPCError && error.code === 'INTERNAL_SERVER_ERROR' && error.cause instanceof ValidationError) {
throw new ORPCError('OUTPUT_VALIDATION_FAILED', {
cause: error.cause,
})
@@ -11,39 +11,30 @@ export const list = os.todo.list.use(db).handler(async ({ context }) => {
return todos
})
export const create = os.todo.create
.use(db)
.handler(async ({ context, input }) => {
const [newTodo] = await context.db
.insert(todoTable)
.values(input)
.returning()
export const create = os.todo.create.use(db).handler(async ({ context, input }) => {
const [newTodo] = await context.db.insert(todoTable).values(input).returning()
if (!newTodo) {
throw new ORPCError('NOT_FOUND')
}
if (!newTodo) {
throw new ORPCError('INTERNAL_SERVER_ERROR', { message: 'Failed to create todo' })
}
return newTodo
})
return newTodo
})
export const update = os.todo.update
.use(db)
.handler(async ({ context, input }) => {
const [updatedTodo] = await context.db
.update(todoTable)
.set(input.data)
.where(eq(todoTable.id, input.id))
.returning()
export const update = os.todo.update.use(db).handler(async ({ context, input }) => {
const [updatedTodo] = await context.db.update(todoTable).set(input.data).where(eq(todoTable.id, input.id)).returning()
if (!updatedTodo) {
throw new ORPCError('NOT_FOUND')
}
if (!updatedTodo) {
throw new ORPCError('NOT_FOUND')
}
return updatedTodo
})
return updatedTodo
})
export const remove = os.todo.remove
.use(db)
.handler(async ({ context, input }) => {
await context.db.delete(todoTable).where(eq(todoTable.id, input.id))
})
export const remove = os.todo.remove.use(db).handler(async ({ context, input }) => {
const [deleted] = await context.db.delete(todoTable).where(eq(todoTable.id, input.id)).returning({ id: todoTable.id })
if (!deleted) {
throw new ORPCError('NOT_FOUND')
}
})
+1 -5
View File
@@ -1,8 +1,4 @@
import type {
ContractRouterClient,
InferContractRouterInputs,
InferContractRouterOutputs,
} from '@orpc/contract'
import type { ContractRouterClient, InferContractRouterInputs, InferContractRouterOutputs } from '@orpc/contract'
import type { Contract } from './contracts'
export type RouterClient = ContractRouterClient<Contract>
+3 -6
View File
@@ -4,7 +4,7 @@ import { v7 as uuidv7 } from 'uuid'
// id
export const id = (name: string) => uuid(name)
const id = (name: string) => uuid(name)
export const pk = (name: string, strategy?: 'native' | 'extension') => {
switch (strategy) {
// PG 18+
@@ -25,8 +25,7 @@ export const pk = (name: string, strategy?: 'native' | 'extension') => {
// timestamp
export const createdAt = (name = 'created_at') =>
timestamp(name, { withTimezone: true }).notNull().defaultNow()
export const createdAt = (name = 'created_at') => timestamp(name, { withTimezone: true }).notNull().defaultNow()
export const updatedAt = (name = 'updated_at') =>
timestamp(name, { withTimezone: true })
@@ -43,9 +42,7 @@ export const generatedFields = {
}
// Helper to create omit keys from generatedFields
const createGeneratedFieldKeys = <T extends Record<string, unknown>>(
fields: T,
): Record<keyof T, true> => {
const createGeneratedFieldKeys = <T extends Record<string, unknown>>(fields: T): Record<keyof T, true> => {
return Object.keys(fields).reduce(
(acc, key) => {
acc[key as keyof T] = true
-1
View File
@@ -1,7 +1,6 @@
{
"extends": "@furtherverse/tsconfig/react.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
+1
View File
@@ -4,6 +4,7 @@
"tasks": {
"build": {
"env": ["NODE_ENV", "VITE_*"],
"inputs": ["src/**", "public/**", "package.json", "tsconfig.json", "vite.config.ts"],
"outputs": [".output/**"]
},
"compile": {
+4 -7
View File
@@ -4,25 +4,22 @@ import { tanstackStart } from '@tanstack/react-start/plugin/vite'
import react from '@vitejs/plugin-react'
import { nitro } from 'nitro/vite'
import { defineConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
export default defineConfig({
clearScreen: false,
plugins: [
tanstackDevtools(),
tailwindcss(),
tsconfigPaths(),
tanstackStart(),
react({
babel: {
plugins: ['babel-plugin-react-compiler'],
},
}),
react(),
nitro({
preset: 'bun',
serveStatic: 'inline',
}),
],
resolve: {
tsconfigPaths: true,
},
server: {
port: 3000,
strictPort: true,
+2 -1
View File
@@ -11,7 +11,8 @@
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineEnding": "lf"
"lineEnding": "lf",
"lineWidth": 120
},
"linter": {
"enabled": true,
+245 -260
View File
File diff suppressed because it is too large Load Diff
+34 -36
View File
@@ -9,59 +9,57 @@
],
"scripts": {
"build": "turbo run build",
"compile": "turbo run compile --filter=@furtherverse/server",
"compile:darwin": "turbo run compile:darwin --filter=@furtherverse/server",
"compile:linux": "turbo run compile:linux --filter=@furtherverse/server",
"compile:windows": "turbo run compile:windows --filter=@furtherverse/server",
"compile": "turbo run compile",
"compile:darwin": "turbo run compile:darwin",
"compile:linux": "turbo run compile:linux",
"compile:windows": "turbo run compile:windows",
"dev": "turbo run dev",
"dist": "turbo run dist --filter=@furtherverse/desktop",
"dist:linux": "turbo run dist:linux --filter=@furtherverse/desktop",
"dist:mac": "turbo run dist:mac --filter=@furtherverse/desktop",
"dist:win": "turbo run dist:win --filter=@furtherverse/desktop",
"dist": "turbo run dist",
"dist:linux": "turbo run dist:linux",
"dist:mac": "turbo run dist:mac",
"dist:win": "turbo run dist:win",
"fix": "turbo run fix",
"typecheck": "turbo run typecheck"
},
"devDependencies": {
"@biomejs/biome": "^2.4.5",
"turbo": "^2.8.13",
"typescript": "^5.9.3"
"@biomejs/biome": "^2.4.9",
"turbo": "^2.8.20",
"typescript": "^6.0.2"
},
"catalog": {
"@orpc/client": "^1.13.6",
"@orpc/contract": "^1.13.6",
"@orpc/openapi": "^1.13.6",
"@orpc/server": "^1.13.6",
"@orpc/tanstack-query": "^1.13.6",
"@orpc/zod": "^1.13.6",
"@t3-oss/env-core": "^0.13.10",
"@tailwindcss/vite": "^4.2.1",
"@tanstack/devtools-vite": "^0.5.3",
"@tanstack/react-devtools": "^0.9.9",
"@tanstack/react-query": "^5.90.21",
"@tanstack/react-query-devtools": "^5.91.3",
"@tanstack/react-router": "^1.166.2",
"@tanstack/react-router-devtools": "^1.166.2",
"@tanstack/react-router-ssr-query": "^1.166.2",
"@tanstack/react-start": "^1.166.2",
"@types/bun": "^1.3.10",
"@types/node": "^24.11.0",
"@vitejs/plugin-react": "^5.1.4",
"babel-plugin-react-compiler": "^1.0.0",
"@orpc/client": "^1.13.11",
"@orpc/contract": "^1.13.11",
"@orpc/openapi": "^1.13.11",
"@orpc/server": "^1.13.11",
"@orpc/tanstack-query": "^1.13.11",
"@orpc/zod": "^1.13.11",
"@t3-oss/env-core": "^0.13.11",
"@tailwindcss/vite": "^4.2.2",
"@tanstack/devtools-vite": "^0.6.0",
"@tanstack/react-devtools": "^0.10.0",
"@tanstack/react-query": "^5.95.2",
"@tanstack/react-query-devtools": "^5.95.2",
"@tanstack/react-router": "^1.168.3",
"@tanstack/react-router-devtools": "^1.166.11",
"@tanstack/react-router-ssr-query": "^1.166.10",
"@tanstack/react-start": "^1.167.6",
"@types/bun": "^1.3.11",
"@types/node": "^24.12.0",
"@vitejs/plugin-react": "^6.0.1",
"drizzle-kit": "1.0.0-beta.15-859cf75",
"drizzle-orm": "1.0.0-beta.15-859cf75",
"electron": "^34.0.0",
"electron-builder": "^26.8.1",
"electron-vite": "^5.0.0",
"motion": "^12.35.0",
"nitro": "npm:nitro-nightly@3.0.1-20260227-181935-bfbb207c",
"motion": "^12.38.0",
"nitro": "npm:nitro-nightly@3.0.1-20260324-103046-9ce219ca",
"postgres": "^3.4.8",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"tailwindcss": "^4.2.1",
"tailwindcss": "^4.2.2",
"tree-kill": "^1.2.2",
"uuid": "^13.0.0",
"vite": "^8.0.0-beta.16",
"vite-tsconfig-paths": "^6.1.1",
"vite": "^8.0.2",
"zod": "^4.3.6"
},
"overrides": {
+3 -1
View File
@@ -20,7 +20,9 @@
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true
"noImplicitOverride": true,
"types": ["bun"]
},
"exclude": ["node_modules"]
}
+1 -38
View File
@@ -6,52 +6,15 @@
"build": {
"dependsOn": ["^build"]
},
"compile": {
"dependsOn": ["build"],
"cache": false
},
"compile:darwin": {
"dependsOn": ["build"],
"cache": false
},
"compile:linux": {
"dependsOn": ["build"],
"cache": false
},
"compile:windows": {
"dependsOn": ["build"],
"cache": false
},
"dev": {
"cache": false,
"persistent": true
},
"dist": {
"dependsOn": ["build"],
"cache": false
},
"dist:linux": {
"dependsOn": ["build"],
"cache": false
},
"dist:mac": {
"dependsOn": ["build"],
"cache": false
},
"dist:win": {
"dependsOn": ["build"],
"cache": false
},
"fix": {
"cache": false
},
"typecheck": {
"inputs": [
"package.json",
"tsconfig.json",
"tsconfig.*.json",
"**/*.{ts,tsx,d.ts}"
],
"inputs": ["package.json", "tsconfig.json", "tsconfig.*.json", "**/*.{ts,tsx,d.ts}"],
"outputs": []
}
},