Compare commits

..

2 Commits

Author SHA1 Message Date
semantic-release-bot
caa2bea7a8 chore(release): 2.4.3 [skip ci]
## [2.4.3](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.4.2...v2.4.3) (2025-10-08)

### Bug Fixes

* resolve socket-server import path for Next.js build ([12c3c37](12c3c37ff8))
2025-10-08 13:56:18 +00:00
Thomas Hallock
12c3c37ff8 fix: resolve socket-server import path for Next.js build
Create a wrapper module in src/lib/socket-io.ts that provides access
to the socket.io server instance for API routes, avoiding the build
error caused by importing from outside the src directory.

The wrapper uses dynamic imports to lazy-load the socket server module
only on the server-side, making it safe for Next.js to bundle.

Changes:
- Add src/lib/socket-io.ts with async getSocketIO() function
- Update join route to use @/lib/socket-io import
- Update leave route to use @/lib/socket-io import
- Both routes now await getSocketIO() since it's async

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-08 08:55:28 -05:00
5 changed files with 51 additions and 5 deletions

View File

@@ -1,3 +1,10 @@
## [2.4.3](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.4.2...v2.4.3) (2025-10-08)
### Bug Fixes
* resolve socket-server import path for Next.js build ([12c3c37](https://github.com/antialias/soroban-abacus-flashcards/commit/12c3c37ff8e1d3df71d72e527c08fa975043c504))
## [2.4.2](https://github.com/antialias/soroban-abacus-flashcards/compare/v2.4.1...v2.4.2) (2025-10-08)

View File

@@ -3,7 +3,7 @@ import { getRoomById, touchRoom } from '@/lib/arcade/room-manager'
import { addRoomMember, getOnlineRoomMembers } from '@/lib/arcade/room-membership'
import { getActivePlayers, getRoomActivePlayers } from '@/lib/arcade/player-manager'
import { getViewerId } from '@/lib/viewer'
import { getSocketIO } from '../../../../../../socket-server'
import { getSocketIO } from '@/lib/socket-io'
type RouteContext = {
params: Promise<{ roomId: string }>
@@ -58,7 +58,7 @@ export async function POST(req: NextRequest, context: RouteContext) {
await touchRoom(roomId)
// Broadcast to all users in the room via socket
const io = getSocketIO()
const io = await getSocketIO()
if (io) {
try {
const onlineMembers = await getOnlineRoomMembers(roomId)

View File

@@ -3,7 +3,7 @@ import { getRoomById } from '@/lib/arcade/room-manager'
import { getOnlineRoomMembers, isMember, removeMember } from '@/lib/arcade/room-membership'
import { getRoomActivePlayers } from '@/lib/arcade/player-manager'
import { getViewerId } from '@/lib/viewer'
import { getSocketIO } from '../../../../../../socket-server'
import { getSocketIO } from '@/lib/socket-io'
type RouteContext = {
params: Promise<{ roomId: string }>
@@ -34,7 +34,7 @@ export async function POST(_req: NextRequest, context: RouteContext) {
await removeMember(roomId, viewerId)
// Broadcast to all remaining users in the room via socket
const io = getSocketIO()
const io = await getSocketIO()
if (io) {
try {
const onlineMembers = await getOnlineRoomMembers(roomId)

View File

@@ -0,0 +1,39 @@
/**
* Socket.IO server instance accessor for API routes
* This module provides a way for API routes to access the socket.io server
* to broadcast real-time updates.
*/
import type { Server as SocketIOServerType } from 'socket.io'
// Import the socket server module (this is safe because it's only used in Node.js context)
let socketServer: { getSocketIO: () => SocketIOServerType | null } | null = null
// Lazy-load the socket server module (only works on server-side)
async function loadSocketServer() {
if (typeof window !== 'undefined') {
// Client-side: return null
return null
}
if (!socketServer) {
try {
// Dynamic import to avoid bundling issues
socketServer = await import('../../socket-server')
} catch (error) {
console.error('[Socket IO] Failed to load socket server:', error)
return null
}
}
return socketServer
}
/**
* Get the socket.io server instance
* Returns null if not initialized or if called on client-side
*/
export async function getSocketIO(): Promise<SocketIOServerType | null> {
const server = await loadSocketServer()
return server ? server.getSocketIO() : null
}

View File

@@ -1,6 +1,6 @@
{
"name": "soroban-monorepo",
"version": "2.4.2",
"version": "2.4.3",
"private": true,
"description": "Beautiful Soroban Flashcard Generator - Monorepo",
"workspaces": [