bonktools 1.0.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +536 -10
- package/dist/connection/BonkConnection.d.ts +173 -0
- package/dist/connection/BonkConnection.js +482 -0
- package/dist/connection/PacketBuilder.d.ts +13 -0
- package/dist/connection/PacketBuilder.js +25 -0
- package/dist/connection/PacketParser.d.ts +14 -0
- package/dist/connection/PacketParser.js +26 -0
- package/dist/connection/types.d.ts +0 -0
- package/dist/connection/types.js +1 -0
- package/dist/game/GameLoop.d.ts +0 -0
- package/dist/game/GameLoop.js +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +73 -0
- package/dist/simulator/GameState.d.ts +0 -0
- package/dist/simulator/GameState.js +1 -0
- package/dist/simulator/PhysicsWorld.d.ts +0 -0
- package/dist/simulator/PhysicsWorld.js +1 -0
- package/dist/types/events.d.ts +0 -0
- package/dist/types/events.js +1 -0
- package/dist/types/index.d.ts +0 -0
- package/dist/types/index.js +1 -0
- package/dist/utils/constants.d.ts +175 -0
- package/dist/utils/constants.js +187 -0
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logger.js +133 -0
- package/dist/utils/validation.d.ts +5 -0
- package/dist/utils/validation.js +28 -0
- package/package.json +48 -18
- package/index.ts +0 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logger utility for BonkTools
|
|
4
|
+
* Provides colored console logging with different levels
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.defaultLogger = exports.LOG_LEVELS = exports.LogLevel = void 0;
|
|
8
|
+
exports.createLogger = createLogger;
|
|
9
|
+
var LogLevel;
|
|
10
|
+
(function (LogLevel) {
|
|
11
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
12
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
13
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
14
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
15
|
+
LogLevel[LogLevel["NONE"] = 4] = "NONE";
|
|
16
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
17
|
+
// ANSI color codes for terminal
|
|
18
|
+
const colors = {
|
|
19
|
+
reset: '\x1b[0m',
|
|
20
|
+
bright: '\x1b[1m',
|
|
21
|
+
dim: '\x1b[2m',
|
|
22
|
+
// Foreground colors
|
|
23
|
+
black: '\x1b[30m',
|
|
24
|
+
red: '\x1b[31m',
|
|
25
|
+
green: '\x1b[32m',
|
|
26
|
+
yellow: '\x1b[33m',
|
|
27
|
+
blue: '\x1b[34m',
|
|
28
|
+
magenta: '\x1b[35m',
|
|
29
|
+
cyan: '\x1b[36m',
|
|
30
|
+
white: '\x1b[37m',
|
|
31
|
+
gray: '\x1b[90m'
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Format timestamp for logs
|
|
35
|
+
*/
|
|
36
|
+
function getTimestamp() {
|
|
37
|
+
const now = new Date();
|
|
38
|
+
const hours = String(now.getHours()).padStart(2, '0');
|
|
39
|
+
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
40
|
+
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
41
|
+
const ms = String(now.getMilliseconds()).padStart(3, '0');
|
|
42
|
+
return `${hours}:${minutes}:${seconds}.${ms}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Format log message with color and timestamp
|
|
46
|
+
*/
|
|
47
|
+
function formatMessage(level, color, namespace, args) {
|
|
48
|
+
const timestamp = `${colors.gray}[${getTimestamp()}]${colors.reset}`;
|
|
49
|
+
const levelStr = `${color}${level.padEnd(5)}${colors.reset}`;
|
|
50
|
+
const namespaceStr = `${colors.cyan}[${namespace}]${colors.reset}`;
|
|
51
|
+
return `${timestamp} ${levelStr} ${namespaceStr}`;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Serialize arguments for logging
|
|
55
|
+
*/
|
|
56
|
+
function serializeArgs(args) {
|
|
57
|
+
return args.map(arg => {
|
|
58
|
+
if (typeof arg === 'string') {
|
|
59
|
+
return arg;
|
|
60
|
+
}
|
|
61
|
+
if (arg instanceof Error) {
|
|
62
|
+
return `${arg.message}\n${arg.stack}`;
|
|
63
|
+
}
|
|
64
|
+
if (typeof arg === 'object') {
|
|
65
|
+
try {
|
|
66
|
+
return JSON.stringify(arg, null, 2);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return String(arg);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return String(arg);
|
|
73
|
+
}).join(' ');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create a logger instance
|
|
77
|
+
*/
|
|
78
|
+
function createLogger(namespace, initialLevel = LogLevel.INFO) {
|
|
79
|
+
let currentLevel;
|
|
80
|
+
// Parse initial level
|
|
81
|
+
if (typeof initialLevel === 'string') {
|
|
82
|
+
currentLevel = LogLevel[initialLevel];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
currentLevel = initialLevel;
|
|
86
|
+
}
|
|
87
|
+
const logger = {
|
|
88
|
+
debug(...args) {
|
|
89
|
+
if (currentLevel <= LogLevel.DEBUG) {
|
|
90
|
+
const prefix = formatMessage('DEBUG', colors.gray, namespace, args);
|
|
91
|
+
console.log(prefix, serializeArgs(args));
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
info(...args) {
|
|
95
|
+
if (currentLevel <= LogLevel.INFO) {
|
|
96
|
+
const prefix = formatMessage('INFO', colors.blue, namespace, args);
|
|
97
|
+
console.log(prefix, serializeArgs(args));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
warn(...args) {
|
|
101
|
+
if (currentLevel <= LogLevel.WARN) {
|
|
102
|
+
const prefix = formatMessage('WARN', colors.yellow, namespace, args);
|
|
103
|
+
console.warn(prefix, serializeArgs(args));
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
error(...args) {
|
|
107
|
+
if (currentLevel <= LogLevel.ERROR) {
|
|
108
|
+
const prefix = formatMessage('ERROR', colors.red, namespace, args);
|
|
109
|
+
console.error(prefix, serializeArgs(args));
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
setLevel(level) {
|
|
113
|
+
if (typeof level === 'string') {
|
|
114
|
+
currentLevel = LogLevel[level];
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
currentLevel = level;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
getLevel() {
|
|
121
|
+
return currentLevel;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
return logger;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Export LogLevel for convenience
|
|
128
|
+
*/
|
|
129
|
+
exports.LOG_LEVELS = LogLevel;
|
|
130
|
+
/**
|
|
131
|
+
* Default logger instance
|
|
132
|
+
*/
|
|
133
|
+
exports.defaultLogger = createLogger('BonkTools');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CreateRoomOptions, JoinOptions } from '../connection/BonkConnection';
|
|
2
|
+
export declare function validateAccount(account: any): any;
|
|
3
|
+
export declare function validateRoomOptions(options: CreateRoomOptions): CreateRoomOptions;
|
|
4
|
+
export declare function validateJoinOptions(options: JoinOptions): JoinOptions;
|
|
5
|
+
export declare function validateString(value: any, name: string): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Funções de validação mockadas para permitir a compilação inicial
|
|
3
|
+
// Devem ser implementadas com a lógica do bonkbot original
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.validateAccount = validateAccount;
|
|
6
|
+
exports.validateRoomOptions = validateRoomOptions;
|
|
7
|
+
exports.validateJoinOptions = validateJoinOptions;
|
|
8
|
+
exports.validateString = validateString;
|
|
9
|
+
function validateAccount(account) {
|
|
10
|
+
if (!account || !account.username) {
|
|
11
|
+
throw new Error('Account must have a username.');
|
|
12
|
+
}
|
|
13
|
+
account.guest = account.guest ?? true;
|
|
14
|
+
return account;
|
|
15
|
+
}
|
|
16
|
+
function validateRoomOptions(options) {
|
|
17
|
+
// Implementação de validação de opções de sala
|
|
18
|
+
return options;
|
|
19
|
+
}
|
|
20
|
+
function validateJoinOptions(options) {
|
|
21
|
+
// Implementação de validação de opções de entrada
|
|
22
|
+
return options;
|
|
23
|
+
}
|
|
24
|
+
function validateString(value, name) {
|
|
25
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
26
|
+
throw new Error(`Invalid value for ${name}: must be a non-empty string.`);
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,34 +1,64 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bonktools",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Advanced Bonk.io bot library with physics simulation and game state management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"dev": "
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"local": "ts-node examples/local-testing.ts",
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"test:watch": "jest --watch",
|
|
13
|
+
"lint": "eslint src/**/*.ts",
|
|
14
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"example:simple": "ts-node examples/simple-bot.ts",
|
|
17
|
+
"example:host": "ts-node examples/host-bot.ts"
|
|
10
18
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"url": "https://github.com/brenoluizdev/bonktools.git"
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
21
|
},
|
|
15
22
|
"keywords": [
|
|
16
23
|
"bonk.io",
|
|
17
24
|
"bot",
|
|
18
25
|
"game",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
26
|
+
"automation",
|
|
27
|
+
"physics",
|
|
28
|
+
"box2d",
|
|
29
|
+
"typescript"
|
|
22
30
|
],
|
|
23
|
-
"author": "
|
|
31
|
+
"author": "OBL",
|
|
24
32
|
"license": "MIT",
|
|
25
|
-
"
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/brenoluizdev/bonktools.git"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"axios": "^1.6.0",
|
|
44
|
+
"box2d-wasm": "^6.0.1",
|
|
45
|
+
"eventemitter3": "^5.0.1",
|
|
46
|
+
"socket.io-client": "^2.3.1"
|
|
47
|
+
},
|
|
26
48
|
"devDependencies": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
49
|
+
"@types/jest": "^29.5.0",
|
|
50
|
+
"@types/node": "^20.10.0",
|
|
51
|
+
"@types/socket.io-client": "^1.4.36",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
53
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
54
|
+
"eslint": "^8.50.0",
|
|
55
|
+
"jest": "^29.7.0",
|
|
56
|
+
"prettier": "^3.0.0",
|
|
57
|
+
"ts-jest": "^29.1.0",
|
|
58
|
+
"ts-node": "^10.9.0",
|
|
59
|
+
"typescript": "^5.3.0"
|
|
29
60
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=16.0.0"
|
|
63
|
+
}
|
|
34
64
|
}
|
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const label = 'click aqui'
|