chore: adding protobuf ts as dev dependency

This commit is contained in:
Chubby Granny Chaser
2025-05-10 17:46:17 +01:00
parent 216f813771
commit 74d93da9b3
3 changed files with 291 additions and 201 deletions

View File

@@ -38,7 +38,6 @@
"@hookform/resolvers": "^3.9.1", "@hookform/resolvers": "^3.9.1",
"@monaco-editor/react": "^4.6.0", "@monaco-editor/react": "^4.6.0",
"@primer/octicons-react": "^19.9.0", "@primer/octicons-react": "^19.9.0",
"@protobuf-ts/plugin": "^2.10.0",
"@radix-ui/react-dropdown-menu": "^2.1.2", "@radix-ui/react-dropdown-menu": "^2.1.2",
"@reduxjs/toolkit": "^2.2.3", "@reduxjs/toolkit": "^2.2.3",
"@sentry/react": "^8.47.0", "@sentry/react": "^8.47.0",
@@ -88,6 +87,7 @@
"@electron-toolkit/eslint-config-prettier": "^2.0.0", "@electron-toolkit/eslint-config-prettier": "^2.0.0",
"@electron-toolkit/eslint-config-ts": "^2.0.0", "@electron-toolkit/eslint-config-ts": "^2.0.0",
"@electron-toolkit/tsconfig": "^1.0.1", "@electron-toolkit/tsconfig": "^1.0.1",
"@protobuf-ts/plugin": "^2.10.0",
"@swc/core": "^1.4.16", "@swc/core": "^1.4.16",
"@types/auto-launch": "^5.0.5", "@types/auto-launch": "^5.0.5",
"@types/color": "^3.0.6", "@types/color": "^3.0.6",

View File

@@ -1,31 +1,11 @@
import { registerEvent } from "../register-event"; import { registerEvent } from "../register-event";
import { HydraApi, WindowManager } from "@main/services"; import { HydraApi, WindowManager } from "@main/services";
import { publishNewFriendRequestNotification } from "@main/services/notifications";
import { UserNotLoggedInError } from "@shared"; import { UserNotLoggedInError } from "@shared";
import type { FriendRequestSync } from "@types"; import type { FriendRequestSync } from "@types";
interface SyncState {
friendRequestCount: number | null;
tick: number;
}
const syncState: SyncState = {
friendRequestCount: null,
tick: 0,
};
export const syncFriendRequests = async () => { export const syncFriendRequests = async () => {
return HydraApi.get<FriendRequestSync>(`/profile/friend-requests/sync`) return HydraApi.get<FriendRequestSync>(`/profile/friend-requests/sync`)
.then((res) => { .then((res) => {
if (
syncState.friendRequestCount != null &&
syncState.friendRequestCount < res.friendRequestCount
) {
publishNewFriendRequestNotification();
}
syncState.friendRequestCount = res.friendRequestCount;
WindowManager.mainWindow?.webContents.send( WindowManager.mainWindow?.webContents.send(
"on-sync-friend-requests", "on-sync-friend-requests",
res res

View File

@@ -14,104 +14,140 @@ import { MessageType } from "@protobuf-ts/runtime";
* @generated from protobuf message FriendRequest * @generated from protobuf message FriendRequest
*/ */
export interface FriendRequest { export interface FriendRequest {
/** /**
* @generated from protobuf field: int32 friend_request_count = 1; * @generated from protobuf field: int32 friend_request_count = 1;
*/ */
friendRequestCount: number; friendRequestCount: number;
/** /**
* @generated from protobuf field: optional string sender_id = 2; * @generated from protobuf field: optional string sender_id = 2;
*/ */
senderId?: string; senderId?: string;
} }
/** /**
* @generated from protobuf message FriendGameSession * @generated from protobuf message FriendGameSession
*/ */
export interface FriendGameSession { export interface FriendGameSession {
/** /**
* @generated from protobuf field: string object_id = 1; * @generated from protobuf field: string object_id = 1;
*/ */
objectId: string; objectId: string;
/** /**
* @generated from protobuf field: string shop = 2; * @generated from protobuf field: string shop = 2;
*/ */
shop: string; shop: string;
/** /**
* @generated from protobuf field: string friend_id = 3; * @generated from protobuf field: string friend_id = 3;
*/ */
friendId: string; friendId: string;
} }
/** /**
* @generated from protobuf message Envelope * @generated from protobuf message Envelope
*/ */
export interface Envelope { export interface Envelope {
/** /**
* @generated from protobuf oneof: payload * @generated from protobuf oneof: payload
*/ */
payload: { payload:
| {
oneofKind: "friendRequest"; oneofKind: "friendRequest";
/** /**
* @generated from protobuf field: FriendRequest friend_request = 1; * @generated from protobuf field: FriendRequest friend_request = 1;
*/ */
friendRequest: FriendRequest; friendRequest: FriendRequest;
} | { }
| {
oneofKind: "friendGameSession"; oneofKind: "friendGameSession";
/** /**
* @generated from protobuf field: FriendGameSession friend_game_session = 2; * @generated from protobuf field: FriendGameSession friend_game_session = 2;
*/ */
friendGameSession: FriendGameSession; friendGameSession: FriendGameSession;
} | { }
| {
oneofKind: undefined; oneofKind: undefined;
}; };
} }
// @generated message type with reflection information, may provide speed optimized methods // @generated message type with reflection information, may provide speed optimized methods
class FriendRequest$Type extends MessageType<FriendRequest> { class FriendRequest$Type extends MessageType<FriendRequest> {
constructor() { constructor() {
super("FriendRequest", [ super("FriendRequest", [
{ no: 1, name: "friend_request_count", kind: "scalar", T: 5 /*ScalarType.INT32*/ }, {
{ no: 2, name: "sender_id", kind: "scalar", opt: true, T: 9 /*ScalarType.STRING*/ } no: 1,
]); name: "friend_request_count",
} kind: "scalar",
create(value?: PartialMessage<FriendRequest>): FriendRequest { T: 5 /*ScalarType.INT32*/,
const message = globalThis.Object.create((this.messagePrototype!)); },
message.friendRequestCount = 0; {
if (value !== undefined) no: 2,
reflectionMergePartial<FriendRequest>(this, message, value); name: "sender_id",
return message; kind: "scalar",
} opt: true,
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: FriendRequest): FriendRequest { T: 9 /*ScalarType.STRING*/,
let message = target ?? this.create(), end = reader.pos + length; },
while (reader.pos < end) { ]);
let [fieldNo, wireType] = reader.tag(); }
switch (fieldNo) { create(value?: PartialMessage<FriendRequest>): FriendRequest {
case /* int32 friend_request_count */ 1: const message = globalThis.Object.create(this.messagePrototype!);
message.friendRequestCount = reader.int32(); message.friendRequestCount = 0;
break; if (value !== undefined)
case /* optional string sender_id */ 2: reflectionMergePartial<FriendRequest>(this, message, value);
message.senderId = reader.string(); return message;
break; }
default: internalBinaryRead(
let u = options.readUnknownField; reader: IBinaryReader,
if (u === "throw") length: number,
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); options: BinaryReadOptions,
let d = reader.skip(wireType); target?: FriendRequest
if (u !== false) ): FriendRequest {
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); let message = target ?? this.create(),
} end = reader.pos + length;
} while (reader.pos < end) {
return message; let [fieldNo, wireType] = reader.tag();
} switch (fieldNo) {
internalBinaryWrite(message: FriendRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { case /* int32 friend_request_count */ 1:
/* int32 friend_request_count = 1; */ message.friendRequestCount = reader.int32();
if (message.friendRequestCount !== 0) break;
writer.tag(1, WireType.Varint).int32(message.friendRequestCount); case /* optional string sender_id */ 2:
/* optional string sender_id = 2; */ message.senderId = reader.string();
if (message.senderId !== undefined) break;
writer.tag(2, WireType.LengthDelimited).string(message.senderId); default:
let u = options.writeUnknownFields; let u = options.readUnknownField;
if (u !== false) if (u === "throw")
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); throw new globalThis.Error(
return writer; `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
} }
return message;
}
internalBinaryWrite(
message: FriendRequest,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* int32 friend_request_count = 1; */
if (message.friendRequestCount !== 0)
writer.tag(1, WireType.Varint).int32(message.friendRequestCount);
/* optional string sender_id = 2; */
if (message.senderId !== undefined)
writer.tag(2, WireType.LengthDelimited).string(message.senderId);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(
this.typeName,
message,
writer
);
return writer;
}
} }
/** /**
* @generated MessageType for protobuf message FriendRequest * @generated MessageType for protobuf message FriendRequest
@@ -119,62 +155,84 @@ class FriendRequest$Type extends MessageType<FriendRequest> {
export const FriendRequest = new FriendRequest$Type(); export const FriendRequest = new FriendRequest$Type();
// @generated message type with reflection information, may provide speed optimized methods // @generated message type with reflection information, may provide speed optimized methods
class FriendGameSession$Type extends MessageType<FriendGameSession> { class FriendGameSession$Type extends MessageType<FriendGameSession> {
constructor() { constructor() {
super("FriendGameSession", [ super("FriendGameSession", [
{ no: 1, name: "object_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 1, name: "object_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 2, name: "shop", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "shop", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
{ no: 3, name: "friend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ } { no: 3, name: "friend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
]); ]);
} }
create(value?: PartialMessage<FriendGameSession>): FriendGameSession { create(value?: PartialMessage<FriendGameSession>): FriendGameSession {
const message = globalThis.Object.create((this.messagePrototype!)); const message = globalThis.Object.create(this.messagePrototype!);
message.objectId = ""; message.objectId = "";
message.shop = ""; message.shop = "";
message.friendId = ""; message.friendId = "";
if (value !== undefined) if (value !== undefined)
reflectionMergePartial<FriendGameSession>(this, message, value); reflectionMergePartial<FriendGameSession>(this, message, value);
return message; return message;
} }
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: FriendGameSession): FriendGameSession { internalBinaryRead(
let message = target ?? this.create(), end = reader.pos + length; reader: IBinaryReader,
while (reader.pos < end) { length: number,
let [fieldNo, wireType] = reader.tag(); options: BinaryReadOptions,
switch (fieldNo) { target?: FriendGameSession
case /* string object_id */ 1: ): FriendGameSession {
message.objectId = reader.string(); let message = target ?? this.create(),
break; end = reader.pos + length;
case /* string shop */ 2: while (reader.pos < end) {
message.shop = reader.string(); let [fieldNo, wireType] = reader.tag();
break; switch (fieldNo) {
case /* string friend_id */ 3: case /* string object_id */ 1:
message.friendId = reader.string(); message.objectId = reader.string();
break; break;
default: case /* string shop */ 2:
let u = options.readUnknownField; message.shop = reader.string();
if (u === "throw") break;
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); case /* string friend_id */ 3:
let d = reader.skip(wireType); message.friendId = reader.string();
if (u !== false) break;
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); default:
} let u = options.readUnknownField;
} if (u === "throw")
return message; throw new globalThis.Error(
} `Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
internalBinaryWrite(message: FriendGameSession, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { );
/* string object_id = 1; */ let d = reader.skip(wireType);
if (message.objectId !== "") if (u !== false)
writer.tag(1, WireType.LengthDelimited).string(message.objectId); (u === true ? UnknownFieldHandler.onRead : u)(
/* string shop = 2; */ this.typeName,
if (message.shop !== "") message,
writer.tag(2, WireType.LengthDelimited).string(message.shop); fieldNo,
/* string friend_id = 3; */ wireType,
if (message.friendId !== "") d
writer.tag(3, WireType.LengthDelimited).string(message.friendId); );
let u = options.writeUnknownFields; }
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
return writer;
} }
return message;
}
internalBinaryWrite(
message: FriendGameSession,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* string object_id = 1; */
if (message.objectId !== "")
writer.tag(1, WireType.LengthDelimited).string(message.objectId);
/* string shop = 2; */
if (message.shop !== "")
writer.tag(2, WireType.LengthDelimited).string(message.shop);
/* string friend_id = 3; */
if (message.friendId !== "")
writer.tag(3, WireType.LengthDelimited).string(message.friendId);
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(
this.typeName,
message,
writer
);
return writer;
}
} }
/** /**
* @generated MessageType for protobuf message FriendGameSession * @generated MessageType for protobuf message FriendGameSession
@@ -182,59 +240,111 @@ class FriendGameSession$Type extends MessageType<FriendGameSession> {
export const FriendGameSession = new FriendGameSession$Type(); export const FriendGameSession = new FriendGameSession$Type();
// @generated message type with reflection information, may provide speed optimized methods // @generated message type with reflection information, may provide speed optimized methods
class Envelope$Type extends MessageType<Envelope> { class Envelope$Type extends MessageType<Envelope> {
constructor() { constructor() {
super("Envelope", [ super("Envelope", [
{ no: 1, name: "friend_request", kind: "message", oneof: "payload", T: () => FriendRequest }, {
{ no: 2, name: "friend_game_session", kind: "message", oneof: "payload", T: () => FriendGameSession } no: 1,
]); name: "friend_request",
} kind: "message",
create(value?: PartialMessage<Envelope>): Envelope { oneof: "payload",
const message = globalThis.Object.create((this.messagePrototype!)); T: () => FriendRequest,
message.payload = { oneofKind: undefined }; },
if (value !== undefined) {
reflectionMergePartial<Envelope>(this, message, value); no: 2,
return message; name: "friend_game_session",
} kind: "message",
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Envelope): Envelope { oneof: "payload",
let message = target ?? this.create(), end = reader.pos + length; T: () => FriendGameSession,
while (reader.pos < end) { },
let [fieldNo, wireType] = reader.tag(); ]);
switch (fieldNo) { }
case /* FriendRequest friend_request */ 1: create(value?: PartialMessage<Envelope>): Envelope {
message.payload = { const message = globalThis.Object.create(this.messagePrototype!);
oneofKind: "friendRequest", message.payload = { oneofKind: undefined };
friendRequest: FriendRequest.internalBinaryRead(reader, reader.uint32(), options, (message.payload as any).friendRequest) if (value !== undefined)
}; reflectionMergePartial<Envelope>(this, message, value);
break; return message;
case /* FriendGameSession friend_game_session */ 2: }
message.payload = { internalBinaryRead(
oneofKind: "friendGameSession", reader: IBinaryReader,
friendGameSession: FriendGameSession.internalBinaryRead(reader, reader.uint32(), options, (message.payload as any).friendGameSession) length: number,
}; options: BinaryReadOptions,
break; target?: Envelope
default: ): Envelope {
let u = options.readUnknownField; let message = target ?? this.create(),
if (u === "throw") end = reader.pos + length;
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); while (reader.pos < end) {
let d = reader.skip(wireType); let [fieldNo, wireType] = reader.tag();
if (u !== false) switch (fieldNo) {
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); case /* FriendRequest friend_request */ 1:
} message.payload = {
} oneofKind: "friendRequest",
return message; friendRequest: FriendRequest.internalBinaryRead(
} reader,
internalBinaryWrite(message: Envelope, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { reader.uint32(),
/* FriendRequest friend_request = 1; */ options,
if (message.payload.oneofKind === "friendRequest") (message.payload as any).friendRequest
FriendRequest.internalBinaryWrite(message.payload.friendRequest, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); ),
/* FriendGameSession friend_game_session = 2; */ };
if (message.payload.oneofKind === "friendGameSession") break;
FriendGameSession.internalBinaryWrite(message.payload.friendGameSession, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); case /* FriendGameSession friend_game_session */ 2:
let u = options.writeUnknownFields; message.payload = {
if (u !== false) oneofKind: "friendGameSession",
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); friendGameSession: FriendGameSession.internalBinaryRead(
return writer; reader,
reader.uint32(),
options,
(message.payload as any).friendGameSession
),
};
break;
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(
`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`
);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(
this.typeName,
message,
fieldNo,
wireType,
d
);
}
} }
return message;
}
internalBinaryWrite(
message: Envelope,
writer: IBinaryWriter,
options: BinaryWriteOptions
): IBinaryWriter {
/* FriendRequest friend_request = 1; */
if (message.payload.oneofKind === "friendRequest")
FriendRequest.internalBinaryWrite(
message.payload.friendRequest,
writer.tag(1, WireType.LengthDelimited).fork(),
options
).join();
/* FriendGameSession friend_game_session = 2; */
if (message.payload.oneofKind === "friendGameSession")
FriendGameSession.internalBinaryWrite(
message.payload.friendGameSession,
writer.tag(2, WireType.LengthDelimited).fork(),
options
).join();
let u = options.writeUnknownFields;
if (u !== false)
(u == true ? UnknownFieldHandler.onWrite : u)(
this.typeName,
message,
writer
);
return writer;
}
} }
/** /**
* @generated MessageType for protobuf message Envelope * @generated MessageType for protobuf message Envelope