Skip to content

Commit

Permalink
fix: type didnt exported
Browse files Browse the repository at this point in the history
  • Loading branch information
JadlionHD committed Oct 11, 2024
1 parent f67be87 commit 16f1afb
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 40 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 1 addition & 3 deletions src/packets/TankPacket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -83,5 +83,3 @@ class TankPacket {
return buf;
}
}

export { TankPacket };
4 changes: 1 addition & 3 deletions src/packets/TextPacket.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -43,5 +43,3 @@ class TextPacket {
return buffer;
}
}

export { TextPacket };
9 changes: 2 additions & 7 deletions src/packets/Variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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);
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -177,5 +174,3 @@ class Variant {
});
}
}

export { Variant };
15 changes: 5 additions & 10 deletions src/structures/Client.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -148,5 +145,3 @@ class Client extends EventEmitter {
});
}
}

export { Client };
4 changes: 1 addition & 3 deletions src/structures/ItemsDat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ExtendString, ItemDefinition, ItemsDatMeta, StringOptions } from "../../types";

class ItemsDat {
export class ItemsDat {
private mempos = 0;

private key: string = "PBG892FXX982ABC*";
Expand Down Expand Up @@ -362,5 +362,3 @@ class ItemsDat {
});
}
}

export { ItemsDat };
4 changes: 1 addition & 3 deletions src/structures/Peer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ClientType, PeerData, Sendable } from "../../types";
import { Variant } from "../packets/Variant.js";
import { Client } from "./Client.js";

class Peer<T extends PeerData> {
export class Peer<T extends PeerData> {
public data: T;

constructor(private client: Client, netID: number) {
Expand Down Expand Up @@ -73,5 +73,3 @@ class Peer<T extends PeerData> {
}
}
}

export { Peer };
9 changes: 2 additions & 7 deletions src/util/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Types for each Argument.
*/
enum VariantTypes {
export enum VariantTypes {
NONE,
FLOAT_1,
STRING,
Expand All @@ -14,7 +14,7 @@ enum VariantTypes {
/**
* Growtopia Packet Types
*/
enum PacketTypes {
export enum PacketTypes {
UNK,
HELLO,
STR,
Expand All @@ -25,8 +25,3 @@ enum PacketTypes {
CLIENT_LOG_REQ,
CLIENT_LOG_RES
}

export default {
VariantTypes,
PacketTypes
};
4 changes: 1 addition & 3 deletions src/util/Utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function parseText(chunk: Buffer) {
export function parseText(chunk: Buffer) {
let data: Record<string, string | number> = {};
chunk[chunk.length - 1] = 0;

Expand All @@ -20,5 +20,3 @@ function parseText(chunk: Buffer) {

return data;
}

export default { parseText };

0 comments on commit 16f1afb

Please sign in to comment.