-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Clean up client types #225 * Fix linter * Cleaned up TS in the client package * Add file with shared types * Add missing empty lines at the end and remove excluding needed files from tsconfigs
- Loading branch information
Showing
11 changed files
with
155 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
packages/**/refactor.ts | ||
packages/client/**/scene/*.ts | ||
packages/server/**/scene/*.ts | ||
packages/server/**/utils/*.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { RoomList, UsersList } from './shared'; | ||
|
||
type ActionTypes = "accelerate" | "brake" | "left" | "right"; | ||
|
||
type Class = { new(...args: any[]): any }; | ||
|
||
type PlayerFromServer = { | ||
color: string; | ||
userID: string; | ||
username: string; | ||
vehicle: { | ||
body: { position: any; rotationQuaternion: any; quaternion: any }; | ||
wheels: Array<{ position: any; rotationQuaternion: any; quaternion: any }>; | ||
}; | ||
}; | ||
|
||
type PlayersFromServer = Array<PlayerFromServer>; | ||
|
||
type UI = { | ||
createPlayersList: (list: UsersList) => void; | ||
createRoomList: (list: RoomList) => void; | ||
hideElement: (element: HTMLElement) => void; | ||
setCurrentPlayer: (id: string) => void; | ||
showElement: (element: HTMLElement) => void; | ||
DialogWrapper: Class; | ||
}; | ||
|
||
interface ClientEvents { | ||
"client-dev:stop the race": () => void; | ||
"client:action": (data: { playerActions: Array<ActionTypes>, id: string }) => void; | ||
"client:join race room": () => void; | ||
"client:leave race room": () => void; | ||
"client:set name": (data: { userID: string; username: string }) => void; | ||
"client:start the race": () => void; | ||
} | ||
|
||
export type { ActionTypes, ClientEvents, PlayerFromServer, PlayersFromServer, UI }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { RoomList, User, UsersList } from './shared'; | ||
|
||
type SessionInfo = { | ||
sessionID: string; | ||
userID: string; | ||
}; | ||
|
||
interface ServerEvents { | ||
"server:action": (data: Object) => void; | ||
"server:close dialog": () => void; | ||
"server:send users": (data: UsersList) => void; | ||
"server:send room users": (data: RoomList) => void; | ||
"server:session": (data: SessionInfo) => void; | ||
"server:show error": (data: { message: string }) => void; | ||
"server:start-race": (data: Object) => void; | ||
"server:user can join the room": () => void; | ||
"server:user can leave the room": () => void; | ||
"server:user can start the race": () => void; | ||
"server:user cannot start the race": () => void; | ||
"server:user connected": (data: User) => void; | ||
"server:user disconnected": (data: { userID: string }) => void; | ||
} | ||
|
||
export type { ServerEvents }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
type RoomUser = { | ||
username: string; | ||
}; | ||
|
||
type RoomList = Array<RoomUser>; | ||
|
||
type User = { | ||
connected: boolean; | ||
userID: string; | ||
username: string; | ||
}; | ||
|
||
type UsersList = Array<User>; | ||
|
||
export type { RoomList, User, UsersList }; |