Commit Graph

10 Commits

Author SHA1 Message Date
Thomas Hallock 9fa95eca89 chore: update tsconfig, plans, lockfile, and templates
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-13 10:49:34 -06:00
Thomas Hallock ab94fd350f fix: use dynamic ES module imports for @svg-maps packages in know-your-world
Fixes production errors where Socket.IO server failed with "Unexpected token 'export'"
when loading map data from @svg-maps/world and @svg-maps/usa packages.

**Changes:**

- **maps.ts**: Use dynamic `import()` for ES modules instead of JSON workaround
  - Async loading via `ensureMapSourcesLoaded()` works in both browser and Node.js
  - Sync Proxy exports (`WORLD_MAP`, `USA_MAP`) for client components
  - Async functions (`getMapData()`, `getFilteredMapData()`) for server-side use
  - Remove JSON data files (world.json, usa.json) - now load directly from npm packages

- **Client components**: Use sync map exports instead of async functions
  - MapRenderer, PlayingPhase, ResultsPhase, SetupPhase, StudyPhase, MapRenderer.stories
  - Import `WORLD_MAP`/`USA_MAP` or use `getFilteredMapDataSync()`
  - No more Promise handling needed in React components

- **Page component**: Disable SSR to prevent build-time errors
  - Use Next.js `dynamic()` import with `ssr: false`
  - Prevents race condition during static generation

- **tsconfig.server.json**: Include maps.ts and related files for server compilation

**Testing:**
-  Docker build succeeds
-  Socket.IO server loads: "Socket server module loaded successfully"
-  Zero ES module errors in production build
-  Maps load correctly from @svg-maps packages via dynamic imports

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 12:16:54 -06:00
Thomas Hallock a51e539d02 fix(nav): update types for registry games with nullable gameName
Fixes TypeScript errors introduced by registry game system:
- Allow gameName to be string | null in nav component types
- Update RecentRoom, AddPlayerButton, GameContextNav, ArcadeRoomInfo interfaces
- Convert null to undefined where needed for legacy function calls
- Fix GameTitleMenu showMenu prop
- Update JoinRoomModal to use separate useGetRoomByCode and useJoinRoom hooks

These changes allow rooms to exist without a selected game (gameName = null).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 19:15:32 -05:00
Thomas Hallock 7d1a351ed6 fix(arcade): add Number Guesser to game config helpers
Fixes server-side session creation for Number Guesser:
- Import DEFAULT_NUMBER_GUESSER_CONFIG
- Add case for 'number-guesser' in getDefaultGameConfig()
- Add validation for number-guesser config
- Include arcade-games validators in server TypeScript build

This resolves the "Unknown game: number-guesser" error when creating sessions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 19:15:32 -05:00
Thomas Hallock b7f1d5a569 fix: exclude dist from TypeScript compilation and add missing type import
- Add "dist" to tsconfig.server.json exclude to prevent TypeScript from
  seeing compiled .js files as input files (was causing TS5055 errors)
- Fix schema path glob: "src/db/schema.ts" -> "src/db/schema/**/*.ts"
  to properly include all schema files in the directory
- Add missing PlayerOwnershipMap type import in player-ownership.ts
  to fix TS2304 compilation error

These fixes resolve the dev server compilation issues and ensure clean
builds without dist/ pollution.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 12:39:54 -05:00
Thomas Hallock bda5bc6c0e fix: prevent database imports from being bundled into client code
**Problem:**
- player-ownership.ts imported drizzle-orm and @/db at top level
- When RoomMemoryPairsProvider imported client-safe utilities, Webpack bundled ALL imports including database code
- This caused hydration error: "The 'original' argument must be of type Function"
- Node.js util.promisify was being called in browser context

**Solution:**
1. Created player-ownership.client.ts with ONLY client-safe utilities
   - No database imports
   - Safe to import from 'use client' components
   - Contains: buildPlayerOwnershipFromRoomData(), buildPlayerMetadata(), helper functions

2. Updated player-ownership.ts to re-export client utilities and add server-only functions
   - Re-exports everything from .client.ts
   - Adds buildPlayerOwnershipMap() (async, database-backed)
   - Safe to import from server components/API routes

3. Updated RoomMemoryPairsProvider to import from .client.ts

**Result:**
- No more hydration errors on /arcade/room
- Client bundle doesn't include database code
- Server code can still use both client and server utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 11:40:46 -05:00
Thomas Hallock 2b7ff237cc fix: correct TypeScript build configuration to prevent .js pollution in src/
**Problem:**
- TypeScript was compiling .js files directly into src/ alongside .ts files
- This broke the app and polluted source control with build artifacts

**Solution:**
1. Moved socket-server.ts from root to src/socket-server.ts
   - Updated imports to remove './src/' prefix (now './lib/...')
2. Updated tsconfig.server.json:
   - Added rootDir: "./src" to ensure clean dist/ structure
   - Updated include path from "socket-server.ts" to "src/socket-server.ts"
3. server.js already correctly requires from ./dist/*

**Result:**
- TypeScript now compiles to dist/ with clean structure:
  - src/socket-server.ts → dist/socket-server.js ✓
  - src/db/index.ts → dist/db/index.js ✓
  - No dist/src/ subdirectory ✓
  - No .js files created in src/ ✓
- Dev server starts successfully
- Build artifacts properly separated from source code

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 11:18:02 -05:00
Thomas Hallock 431e4a61de fix: remove rootDir from tsconfig.server.json
Allow socket-server.ts in root while outputting to dist/
2025-10-10 10:55:41 -05:00
Thomas Hallock 29f5adcfbc fix: remove build artifacts from source control
BREAKING: This fixes a critical issue where compiled .js files were
being committed directly into src/ alongside .ts files, breaking the
app and polluting source control.

Changes:
- Fix tsconfig.server.json: outDir "." → "./dist", rootDir "." → "./src"
- Remove 23 tracked .js files from src/ directory
- Update .gitignore to block src/**/*.js and /dist
- Clean working directory of all .js artifacts

This ensures TypeScript compilation outputs to dist/ folder, not src/.

Fixes player ownership implementation and all future builds.
2025-10-10 10:53:59 -05:00
Thomas Hallock 83b9a4d976 fix: compile TypeScript server files to JavaScript for production
- Add tsconfig.server.json to compile server-side TypeScript
- Install tsc-alias to resolve path aliases (@/*) in compiled JS
- Update build script to run tsc + tsc-alias before Next.js build
- Update dev script to compile server files before starting
- Remove tsx runtime dependencies from server.js
- Add compiled JS files for socket-server, db, and arcade modules

This enables production builds to run with pure Node.js without
requiring tsx or ts-node at runtime, as required for Docker deployment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 07:55:18 -05:00