mirror of
https://github.com/ReVanced/revanced-bots.git
synced 2026-01-11 13:56:15 +00:00
chore: format and remove unneccessary code
This commit is contained in:
@@ -1,40 +1,40 @@
|
||||
{
|
||||
"name": "@revanced/bot-api",
|
||||
"type": "module",
|
||||
"version": "0.1.0",
|
||||
"description": "🙌🏻 Programmatic API for bots assisting ReVanced to communicate to its API server",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "bun bundle && bun types",
|
||||
"watch": "conc --raw \"bun bundle:watch\" \"bun types:watch\"",
|
||||
"bundle": "bun build src/index.ts --outdir=dist --sourcemap=external --target=node --minify",
|
||||
"bundle:watch": "bun run bundle --watch",
|
||||
"types": "tsc --declaration --emitDeclarationOnly",
|
||||
"types:watch": "bun types --watch --preserveWatchOutput",
|
||||
"types:clean": "bun types --build --clean"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/revanced/revanced-helper.git",
|
||||
"directory": "packages/api"
|
||||
},
|
||||
"author": "Palm <palmpasuthorn@gmail.com> (https://github.com/PalmDevs)",
|
||||
"contributors": [
|
||||
"Palm <palmpasuthorn@gmail.com> (https://github.com/PalmDevs)",
|
||||
"ReVanced <nosupport@revanced.app> (https://github.com/revanced)"
|
||||
],
|
||||
"license": "GPL-3.0-or-later",
|
||||
"bugs": {
|
||||
"url": "https://github.com/revanced/revanced-helper/issues"
|
||||
},
|
||||
"homepage": "https://github.com/revanced/revanced-helper#readme",
|
||||
"dependencies": {
|
||||
"@revanced/bot-shared": "workspace:*",
|
||||
"ws": "^8.14.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ws": "^8.5.10",
|
||||
"typed-emitter": "^2.1.0"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "@revanced/bot-api",
|
||||
"type": "module",
|
||||
"version": "0.1.0",
|
||||
"description": "🙌🏻 Programmatic API for bots assisting ReVanced to communicate to its API server",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "bun bundle && bun types",
|
||||
"watch": "conc --raw \"bun bundle:watch\" \"bun types:watch\"",
|
||||
"bundle": "bun build src/index.ts --outdir=dist --sourcemap=external --target=node --minify",
|
||||
"bundle:watch": "bun run bundle --watch",
|
||||
"types": "tsc --declaration --emitDeclarationOnly",
|
||||
"types:watch": "bun types --watch --preserveWatchOutput",
|
||||
"types:clean": "bun types --build --clean"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/revanced/revanced-helper.git",
|
||||
"directory": "packages/api"
|
||||
},
|
||||
"author": "Palm <palmpasuthorn@gmail.com> (https://github.com/PalmDevs)",
|
||||
"contributors": [
|
||||
"Palm <palmpasuthorn@gmail.com> (https://github.com/PalmDevs)",
|
||||
"ReVanced <nosupport@revanced.app> (https://github.com/revanced)"
|
||||
],
|
||||
"license": "GPL-3.0-or-later",
|
||||
"bugs": {
|
||||
"url": "https://github.com/revanced/revanced-helper/issues"
|
||||
},
|
||||
"homepage": "https://github.com/revanced/revanced-helper#readme",
|
||||
"dependencies": {
|
||||
"@revanced/bot-shared": "workspace:*",
|
||||
"ws": "^8.14.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/ws": "^8.5.10",
|
||||
"typed-emitter": "^2.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,9 @@ export default class Client {
|
||||
rs(packet)
|
||||
}
|
||||
|
||||
const parseTextFailedListener = (packet: Packet<ServerOperation.ParseTextFailed>) => {
|
||||
const parseTextFailedListener = (
|
||||
packet: Packet<ServerOperation.ParseTextFailed>
|
||||
) => {
|
||||
if (packet.d.id !== currentId) return
|
||||
this.gateway.off('parseTextFailed', parseTextFailedListener)
|
||||
rj(packet)
|
||||
@@ -84,7 +86,9 @@ export default class Client {
|
||||
rs(packet)
|
||||
}
|
||||
|
||||
const parseImageFailedListener = (packet: Packet<ServerOperation.ParseImageFailed>) => {
|
||||
const parseImageFailedListener = (
|
||||
packet: Packet<ServerOperation.ParseImageFailed>
|
||||
) => {
|
||||
if (packet.d.id !== currentId) return
|
||||
this.gateway.off('parseImageFailed', parseImageFailedListener)
|
||||
rj(packet)
|
||||
|
||||
@@ -24,8 +24,7 @@ export default class ClientGateway {
|
||||
|
||||
#hbTimeout: NodeJS.Timeout = null!
|
||||
#socket: WebSocket = null!
|
||||
#emitter =
|
||||
new EventEmitter() as TypedEmitter<ClientGatewayEventHandlers>
|
||||
#emitter = new EventEmitter() as TypedEmitter<ClientGatewayEventHandlers>
|
||||
|
||||
constructor(options: ClientGatewayOptions) {
|
||||
this.url = options.url
|
||||
@@ -110,6 +109,7 @@ export default class ClientGateway {
|
||||
|
||||
switch (packet.op) {
|
||||
case ServerOperation.Hello:
|
||||
// eslint-disable-next-line no-case-declarations
|
||||
const data = Object.freeze(
|
||||
(packet as Packet<ServerOperation.Hello>).d
|
||||
)
|
||||
@@ -124,9 +124,11 @@ export default class ClientGateway {
|
||||
default:
|
||||
return this.#emitter.emit(
|
||||
uncapitalize(
|
||||
ServerOperation[packet.op] as ClientGatewayServerEventName
|
||||
ServerOperation[
|
||||
packet.op
|
||||
] as ClientGatewayServerEventName
|
||||
),
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error TypeScript doesn't know that the lines above negate the type enough
|
||||
packet
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export { default as Client } from './Client.js'
|
||||
export * from './Client.js'
|
||||
export { default as ClientGateway } from './ClientGateway.js'
|
||||
export * from './ClientGateway.js'
|
||||
export * from './ClientGateway.js'
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"rootDir": "./src",
|
||||
"outDir": "dist",
|
||||
"module": "ESNext",
|
||||
"composite": true,
|
||||
"composite": true
|
||||
},
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
}
|
||||
|
||||
2
packages/api/utility-types.d.ts
vendored
2
packages/api/utility-types.d.ts
vendored
@@ -1 +1 @@
|
||||
type RequiredProperty<T> = { [P in keyof T]: Required<NonNullable<T[P]>>; };
|
||||
type RequiredProperty<T> = { [P in keyof T]: Required<NonNullable<T[P]>> }
|
||||
|
||||
Reference in New Issue
Block a user