Give types to all functions in OsuPacketWriter

This commit is contained in:
Holly Stubbs 2023-10-06 09:48:31 +01:00
parent 39f6669f94
commit 5e1106e488
8 changed files with 84 additions and 25 deletions

View file

@ -0,0 +1,5 @@
export default interface ChannelData {
channelName: string,
channelTopic: string,
channelUserCount: number
}

View file

@ -1,7 +1,11 @@
import ChannelData from "./ChannelData"
import MatchData from "./MatchData" import MatchData from "./MatchData"
import MatchScoreData from "./MatchScoreData" import MatchScoreData from "./MatchScoreData"
import MessageData from "./MessageData" import MessageData from "./MessageData"
import SpectateFramesData from "./SpectateFramesData"
import StatusUpdateData from "./StatusUpdateData" import StatusUpdateData from "./StatusUpdateData"
import UserPresenceData from "./UserPresenceData"
import UserQuitData from "./UserQuitData"
export default interface OsuPacketWriter { export default interface OsuPacketWriter {
// Functions // Functions
@ -9,36 +13,36 @@ export default interface OsuPacketWriter {
CommandError() : OsuPacketWriter, CommandError() : OsuPacketWriter,
SendMessage(data:MessageData) : OsuPacketWriter, SendMessage(data:MessageData) : OsuPacketWriter,
Ping() : OsuPacketWriter, Ping() : OsuPacketWriter,
HandleIrcChangeUsername(data:any) : OsuPacketWriter, HandleIrcChangeUsername(data:string) : OsuPacketWriter,
HandleIrcQuit() : OsuPacketWriter, HandleIrcQuit() : OsuPacketWriter,
HandleOsuUpdate(data:StatusUpdateData) : OsuPacketWriter, HandleOsuUpdate(data:StatusUpdateData) : OsuPacketWriter,
HandleUserQuit(data:any) : OsuPacketWriter, HandleUserQuit(data:UserQuitData) : OsuPacketWriter,
SpectatorJoined(data:any) : OsuPacketWriter, SpectatorJoined(data:number) : OsuPacketWriter,
SpectatorLeft(data:any) : OsuPacketWriter, SpectatorLeft(data:number) : OsuPacketWriter,
SpectateFrames(data:any) : OsuPacketWriter, SpectateFrames(data:SpectateFramesData) : OsuPacketWriter,
VersionUpdate() : OsuPacketWriter, VersionUpdate() : OsuPacketWriter,
SpectatorCantSpectate(data:any) : OsuPacketWriter, SpectatorCantSpectate(data:number) : OsuPacketWriter,
GetAttention() : OsuPacketWriter, GetAttention() : OsuPacketWriter,
Announce(data:string) : OsuPacketWriter, Announce(data:string) : OsuPacketWriter,
MatchUpdate(data:MatchData) : OsuPacketWriter, MatchUpdate(data:MatchData) : OsuPacketWriter,
MatchNew(data:MatchData) : OsuPacketWriter, MatchNew(data:MatchData) : OsuPacketWriter,
MatchDisband(data:any) : OsuPacketWriter, MatchDisband(data:number) : OsuPacketWriter,
MatchJoinSuccess(data:MatchData) : OsuPacketWriter, MatchJoinSuccess(data:MatchData) : OsuPacketWriter,
MatchJoinFail() : OsuPacketWriter, MatchJoinFail() : OsuPacketWriter,
FellowSpectatorJoined(data:number) : OsuPacketWriter, FellowSpectatorJoined(data:number) : OsuPacketWriter,
FellowSpectatorLeft(data:number) : OsuPacketWriter, FellowSpectatorLeft(data:number) : OsuPacketWriter,
MatchStart(data:MatchData) : OsuPacketWriter, MatchStart(data:MatchData) : OsuPacketWriter,
MatchScoreUpdate(data:MatchScoreData) : OsuPacketWriter, MatchScoreUpdate(data:MatchScoreData) : OsuPacketWriter,
MatchTransferHost(data:any) : OsuPacketWriter, MatchTransferHost() : OsuPacketWriter,
MatchAllPlayersLoaded() : OsuPacketWriter, MatchAllPlayersLoaded() : OsuPacketWriter,
MatchPlayerFailed(data:any) : OsuPacketWriter, MatchPlayerFailed(data:number) : OsuPacketWriter,
MatchComplete() : OsuPacketWriter, MatchComplete() : OsuPacketWriter,
MatchSkip() : OsuPacketWriter, MatchSkip() : OsuPacketWriter,
Unauthorised() : OsuPacketWriter, Unauthorised() : OsuPacketWriter,
ChannelJoinSuccess(data:any) : OsuPacketWriter, ChannelJoinSuccess(data:string) : OsuPacketWriter,
ChannelAvailable(data:any) : OsuPacketWriter, ChannelAvailable(data:ChannelData) : OsuPacketWriter,
ChannelRevoked(data:any) : OsuPacketWriter, ChannelRevoked(data:string) : OsuPacketWriter,
ChannelAvailableAutojoin(data:any) : OsuPacketWriter, ChannelAvailableAutojoin(data:ChannelData) : OsuPacketWriter,
BeatmapInfoReply() : OsuPacketWriter, BeatmapInfoReply() : OsuPacketWriter,
LoginPermissions(data:number) : OsuPacketWriter, LoginPermissions(data:number) : OsuPacketWriter,
FriendsList(data:Array<number>) : OsuPacketWriter, FriendsList(data:Array<number>) : OsuPacketWriter,
@ -46,22 +50,22 @@ export default interface OsuPacketWriter {
TitleUpdate(data:string) : OsuPacketWriter, TitleUpdate(data:string) : OsuPacketWriter,
Monitor() : OsuPacketWriter, Monitor() : OsuPacketWriter,
MatchPlayerSkipped(data:number) : OsuPacketWriter, MatchPlayerSkipped(data:number) : OsuPacketWriter,
UserPresence(data:any) : OsuPacketWriter, UserPresence(data:UserPresenceData) : OsuPacketWriter,
Restart(data:number) : OsuPacketWriter, Restart(data:number) : OsuPacketWriter,
Invite(data:any) : OsuPacketWriter, Invite(data:MessageData) : OsuPacketWriter,
ChannelListingComplete() : OsuPacketWriter, ChannelListingComplete() : OsuPacketWriter,
MatchChangePassword(data:any) : OsuPacketWriter, MatchChangePassword(data:string) : OsuPacketWriter,
BanInfo(data:any) : OsuPacketWriter, BanInfo(data:number) : OsuPacketWriter,
UserSilenced(data:any) : OsuPacketWriter, UserSilenced(data:number) : OsuPacketWriter,
UserPresenceSingle(data:any) : OsuPacketWriter, UserPresenceSingle(data:number) : OsuPacketWriter,
UserPresenceBundle(data:any) : OsuPacketWriter, UserPresenceBundle(data:Array<number>) : OsuPacketWriter,
UserPMBlocked(data:any) : OsuPacketWriter, UserPMBlocked(data:MessageData) : OsuPacketWriter,
TargetIsSilenced(data:any) : OsuPacketWriter, TargetIsSilenced(data:MessageData) : OsuPacketWriter,
VersionUpdateForced() : OsuPacketWriter, VersionUpdateForced() : OsuPacketWriter,
SwitchServer(data:any) : OsuPacketWriter, SwitchServer(data:number) : OsuPacketWriter,
AccountRestricted() : OsuPacketWriter, AccountRestricted() : OsuPacketWriter,
RTX(data:string) : OsuPacketWriter, RTX(data:string) : OsuPacketWriter,
SwitchTourneyServer(data:any) : OsuPacketWriter SwitchTourneyServer(data:string) : OsuPacketWriter
toBuffer : Buffer toBuffer : Buffer
} }

View file

@ -0,0 +1,7 @@
export default interface ReplayFrameData {
buttonState: number,
bt: number,
mouseX: number,
mouseY: number,
time: number
}

View file

@ -0,0 +1,17 @@
export default interface ScoreFrameData {
time: number,
id: number,
count300: number,
count100: number,
count50: number,
countGeki: number,
countKatu: number,
countMiss: number,
totalScore: number,
maxCombo: number,
currentCombo: number,
perfect: boolean,
currentHp: number,
tagByte: number,
usingScoreV2: boolean,
}

View file

@ -0,0 +1,10 @@
import MatchScoreData from "./MatchScoreData";
import ReplayFrameData from "./ReplayFrameData";
import ScoreFrameData from "./ScoreFrameData";
export default interface SpectateFramesData {
extra: number,
replayFrames: Array<ReplayFrameData>,
action: number,
scoreFrame: ScoreFrameData
}

View file

@ -0,0 +1,12 @@
import { Permissions } from "../enums/Permissions";
export default interface UserPresenceData {
userId: number,
username: string,
timezone: number,
countryId: number,
permissions: Permissions,
longitude: number,
latitude: number,
rank: number
}

View file

@ -0,0 +1,4 @@
export default interface UserQuitData {
userId: number,
state: number
}

View file

@ -1,7 +1,7 @@
import { readFileSync, writeFileSync } from "fs"; import { readFileSync, writeFileSync } from "fs";
import { minify } from "terser"; import { minify } from "terser";
const DISABLE = true; const DISABLE = false;
writeFileSync("./build/.MANGLED", `${DISABLE}`); writeFileSync("./build/.MANGLED", `${DISABLE}`);
if (DISABLE) { if (DISABLE) {