From 16f1afbdaa23a0073e646218977db228b48c2fd0 Mon Sep 17 00:00:00 2001 From: Hendra Gunawan <48410066+JadlionHD@users.noreply.github.com> Date: Sat, 12 Oct 2024 00:24:39 +0700 Subject: [PATCH] fix: type didnt exported --- package.json | 2 +- src/packets/TankPacket.ts | 4 +--- src/packets/TextPacket.ts | 4 +--- src/packets/Variant.ts | 9 ++------- src/structures/Client.ts | 15 +++++---------- src/structures/ItemsDat.ts | 4 +--- src/structures/Peer.ts | 4 +--- src/util/Constants.ts | 9 ++------- src/util/Utils.ts | 4 +--- 9 files changed, 15 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 2dbd453..2077ceb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "growtopia.js", - "version": "1.6.0", + "version": "1.6.1", "description": "A package to create a growtopia private servers.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/packets/TankPacket.ts b/src/packets/TankPacket.ts index 4fa2cff..10ec903 100644 --- a/src/packets/TankPacket.ts +++ b/src/packets/TankPacket.ts @@ -5,7 +5,7 @@ const TANK_HEADER_SIZE = 60; /** * Represent a TankPacket. */ -class TankPacket { +export class TankPacket { /** * Creates a new instance of the TankPacket class. * @param data The tankpacket header and data. @@ -83,5 +83,3 @@ class TankPacket { return buf; } } - -export { TankPacket }; diff --git a/src/packets/TextPacket.ts b/src/packets/TextPacket.ts index 1d6b40d..b481a6c 100644 --- a/src/packets/TextPacket.ts +++ b/src/packets/TextPacket.ts @@ -1,7 +1,7 @@ /** * TextPacket class to create text packets such as for actions or other uses. */ -class TextPacket { +export class TextPacket { /** * Creates a new TextPacket class * @param type The type of the packet. @@ -43,5 +43,3 @@ class TextPacket { return buffer; } } - -export { TextPacket }; diff --git a/src/packets/Variant.ts b/src/packets/Variant.ts index e67c7f3..24cda91 100644 --- a/src/packets/Variant.ts +++ b/src/packets/Variant.ts @@ -2,12 +2,12 @@ import { TankPacket } from "./TankPacket.js"; // Types import type { VariantArg, VariantArray, VariantOptions } from "../../types/packets"; -import Constants from "../util/Constants.js"; +import { VariantTypes } from "../util/Constants.js"; /** * Represents the Variant class. */ -class Variant { +export class Variant { public index: number = 0; /** @@ -33,7 +33,6 @@ class Variant { public static toArray(data: Buffer): VariantArray[] { let arr: VariantArray[] = []; - const VariantTypes = Constants.VariantTypes; let pos = 60; const count = data.readUint8(60); @@ -110,8 +109,6 @@ class Variant { * Parses the data of the Variant and returns a TankPacket from it. */ public parse() { - const VariantTypes = Constants.VariantTypes; - let buf = [this.args.length]; this.args.forEach((arg) => { @@ -177,5 +174,3 @@ class Variant { }); } } - -export { Variant }; diff --git a/src/structures/Client.ts b/src/structures/Client.ts index a4dc77d..a1e59bd 100644 --- a/src/structures/Client.ts +++ b/src/structures/Client.ts @@ -1,7 +1,7 @@ import EventEmitter from "eventemitter3"; import type { Caching, ClientOptions, ClientType } from "../../types"; -import Constants from "../util/Constants.js"; -import Utils from "../util/Utils.js"; +import { PacketTypes } from "../util/Constants.js"; +import { parseText } from "../util/Utils.js"; import { Peer } from "./Peer.js"; import type { ActionEvent, LoginInfo, PeerData } from "../../types"; import { TankPacket } from "../packets/TankPacket.js"; @@ -12,10 +12,9 @@ import { fileURLToPath } from "url"; import nodegyp from "node-gyp-build"; const __dirname = dirname(fileURLToPath(import.meta.url)); -console.log(__dirname); const Native = nodegyp(join(__dirname, "..", "..")).Client; -class Client extends EventEmitter { +export class Client extends EventEmitter { public _client: ClientType; public config: ClientOptions; public cache: Caching; @@ -112,18 +111,16 @@ class Client extends EventEmitter { const type = data.readInt32LE(); const peer = new Peer(this, netID); - const PacketTypes = Constants.PacketTypes; - switch (type) { case PacketTypes.STR: { - const parsed = Utils.parseText(data); + const parsed = parseText(data); this.emit("text", peer, parsed); break; } case PacketTypes.ACTION: { - const parsed = Utils.parseText(data); + const parsed = parseText(data); this.emit("action", peer, parsed); break; } @@ -148,5 +145,3 @@ class Client extends EventEmitter { }); } } - -export { Client }; diff --git a/src/structures/ItemsDat.ts b/src/structures/ItemsDat.ts index 0d5565b..18581cf 100644 --- a/src/structures/ItemsDat.ts +++ b/src/structures/ItemsDat.ts @@ -1,6 +1,6 @@ import type { ExtendString, ItemDefinition, ItemsDatMeta, StringOptions } from "../../types"; -class ItemsDat { +export class ItemsDat { private mempos = 0; private key: string = "PBG892FXX982ABC*"; @@ -362,5 +362,3 @@ class ItemsDat { }); } } - -export { ItemsDat }; diff --git a/src/structures/Peer.ts b/src/structures/Peer.ts index 8757127..c11e9c0 100644 --- a/src/structures/Peer.ts +++ b/src/structures/Peer.ts @@ -2,7 +2,7 @@ import type { ClientType, PeerData, Sendable } from "../../types"; import { Variant } from "../packets/Variant.js"; import { Client } from "./Client.js"; -class Peer { +export class Peer { public data: T; constructor(private client: Client, netID: number) { @@ -73,5 +73,3 @@ class Peer { } } } - -export { Peer }; diff --git a/src/util/Constants.ts b/src/util/Constants.ts index c072c64..bc077e8 100644 --- a/src/util/Constants.ts +++ b/src/util/Constants.ts @@ -1,7 +1,7 @@ /** * Types for each Argument. */ -enum VariantTypes { +export enum VariantTypes { NONE, FLOAT_1, STRING, @@ -14,7 +14,7 @@ enum VariantTypes { /** * Growtopia Packet Types */ -enum PacketTypes { +export enum PacketTypes { UNK, HELLO, STR, @@ -25,8 +25,3 @@ enum PacketTypes { CLIENT_LOG_REQ, CLIENT_LOG_RES } - -export default { - VariantTypes, - PacketTypes -}; diff --git a/src/util/Utils.ts b/src/util/Utils.ts index 4379246..cb2fd28 100644 --- a/src/util/Utils.ts +++ b/src/util/Utils.ts @@ -1,4 +1,4 @@ -function parseText(chunk: Buffer) { +export function parseText(chunk: Buffer) { let data: Record = {}; chunk[chunk.length - 1] = 0; @@ -20,5 +20,3 @@ function parseText(chunk: Buffer) { return data; } - -export default { parseText };