Commit c3b781a6 authored by Sophia's avatar Sophia

declare `ygopro` global variable

parent e2965161
Pipeline #6258 canceled with stages
......@@ -7,12 +7,14 @@
"author": "Sophia <beyondthesophia@gmail.com>",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1",
"type-fest": "^2.5.0",
"typescript": "^4.4.4"
}
}
export * from "./ygopro";
export * from "./message-helper";
import * as net from "net";
declare class Handler {
private readonly handler: (buffer: Buffer, info: any, datas: Buffer[], params: any) => Promise<boolean>;
public readonly synchronous: boolean;
constructor(handler: (buffer: Buffer, info: any, datas: Buffer[], params: any) => Promise<boolean>, synchronous: boolean);
handle(buffer: Buffer, info: any, datas: Buffer[], params: any): Promise<boolean> | boolean;
}
interface HandlerList {
STOC: Map<number, Handler[]>[];
CTOS: Map<number, Handler[]>[];
}
interface DirectionAndProto {
direction: string;
proto: string;
}
export interface Feedback {
type: string;
message: string;
}
export interface HandleResult {
datas: Buffer[];
feedback: Feedback;
}
export interface Constants {
TYPES: Record<string, number>;
RACES: Record<string, number>;
ATTRIBUTES: Record<string, number>;
LINK_MARKERS: Record<string, number>;
DUEL_STAGE: Record<string, number>;
COLORS: Record<string, number>;
TIMING: Record<string, string>;
NETWORK: Record<string, string>;
NETPLAYER: Record<string, string>;
CTOS: Record<string, string>;
STOC: Record<string, string>;
PLAYERCHANGE: Record<string, string>;
ERRMSG: Record<string, string>;
MODE: Record<string, string>;
MSG: Record<string, string>;
}
export interface YGOProMessagesHelperInstance {
handlers: HandlerList;
structs: Map<string, any>;
structs_declaration: Record<string, any>;
typedefs: Record<string, string>;
proto_structs: Record<"CTOS" | "STOC", Record<string, string>>;
constants: Constants;
singleHandleLimit: number;
constructor(singleHandleLimit?: number);
initDatas(): void;
initStructs(): void;
getDirectionAndProto(protoStr: string): DirectionAndProto;
translateProto(proto: string | number, direction: string): number;
prepareMessage(protostr: string, info?: string | Buffer | any): Buffer;
sendMessage(socket: net.Socket, protostr: string, info?: string | Buffer | any): void;
sendMessageAsync(socket: net.Socket, protostr: string, info?: string | Buffer | any): Promise<Error>;
addHandler(
protostr: string,
handler: (buffer: Buffer, info: any, datas: Buffer[], params: any) => Promise<boolean>,
synchronous: boolean,
priority: number,
): void;
handleBuffer(messageBuffer: Buffer, direction: string, protoFilter?: string[], params?: any): Promise<HandleResult>;
}
import type { ReadonlyDeep } from "type-fest";
import type { Socket } from "net";
import type { YGOProMessagesHelperInstance } from "./message-helper";
type Dictionary<T> = { [key: string]: T };
type ReloadI18NResult = { regex: RegExp; text: string };
type FollowHandler = (buffer: Buffer, info: Dictionary<any>, client: Socket, server: Socket, data: Dictionary<any>) => Promise<boolean>;
export interface YGOPro {
i18ns: Dictionary<Dictionary<string>>;
i18nR: Dictionary<Dictionary<string>>;
reloadI18nR(): Array<ReloadI18NResult>;
helper: YGOProMessagesHelperInstance;
structs: YGOProMessagesHelperInstance["structs"];
structs_declaration: YGOProMessagesHelperInstance["structs_declaration"];
typedefs: YGOProMessagesHelperInstance["typedefs"];
proto_structs: YGOProMessagesHelperInstance["proto_structs"];
constants: YGOProMessagesHelperInstance["constants"];
stoc_follow(proto: string, synchronous: boolean, callback: FollowHandler): void;
stoc_follow_before(proto: string, synchronous: boolean, callback: FollowHandler): void;
stoc_follow_after(proto: string, synchronous: boolean, callback: FollowHandler): void;
ctos_follow(proto: string, synchronous: boolean, callback: FollowHandler): void;
ctos_follow_before(proto: string, synchronous: boolean, callback: FollowHandler): void;
ctos_follow_after(proto: string, synchronous: boolean, callback: FollowHandler): void;
stoc_send(socket: any, proto: string, info: Dictionary<any>): any;
ctos_send(socket: any, proto: string, info: Dictionary<any>): any;
stoc_send_chat(): void;
stoc_send_chat_to_room(): void;
stoc_send_hint_card_to_room(): void;
stoc_die(): void;
}
declare var ygopro: ReadonlyDeep<YGOPro>;
......@@ -62,6 +62,11 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
"@types/node@^16.11.0":
version "16.11.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.0.tgz#4b95f2327bacd1ef8f08d8ceda193039c5d7f52e"
integrity sha512-8MLkBIYQMuhRBQzGN9875bYsOhPnf/0rgXGo66S2FemHkhbn9qtsz9ywV1iCG+vbjigE4WUNVvw37Dx+L0qsPg==
"@typescript-eslint/eslint-plugin@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.0.0.tgz#ecc7cc69d1e6f342beb6ea9cf9fbc02c97a212ac"
......@@ -1271,6 +1276,11 @@ type-fest@^0.20.2:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
integrity sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==
type-fest@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.5.0.tgz#e5d0ef818d565e8fc442414194a4ac3afc4c42a7"
integrity sha512-wB5vE+XXZ2g2mDRo18yZMae1joUhquomLTm+BkxeuRHnwmrNWzVPNrFah9z7pjsKNiVAaJL33+uQbgbPSARyqw==
typescript@^4.4.4:
version "4.4.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment