summary refs log tree commit diff
path: root/gateway
diff options
context:
space:
mode:
Diffstat (limited to 'gateway')
-rw-r--r--gateway/.swcrc5
-rw-r--r--gateway/package-lock.json2
-rw-r--r--gateway/src/Server.ts6
-rw-r--r--gateway/src/events/Connection.ts11
-rw-r--r--gateway/src/events/Message.ts3
-rw-r--r--gateway/src/listener/listener.ts6
-rw-r--r--gateway/src/opcodes/Heartbeat.ts4
-rw-r--r--gateway/src/opcodes/Identify.ts17
-rw-r--r--gateway/src/opcodes/LazyRequest.ts4
-rw-r--r--gateway/tsconfig.json4
10 files changed, 26 insertions, 36 deletions
diff --git a/gateway/.swcrc b/gateway/.swcrc

index 3079a89f..e8cbb8a1 100644 --- a/gateway/.swcrc +++ b/gateway/.swcrc
@@ -7,11 +7,10 @@ "syntax": "typescript", "decorators": true }, - "target": "es2021", + "target": "es5", "baseUrl": ".", "paths": { - "@fosscord/gateway": ["src/index"], - "@fosscord/gateway/*": ["src/*"] + "@fosscord/gateway": ["src/index"] } } } diff --git a/gateway/package-lock.json b/gateway/package-lock.json
index 38962a2a..07ae02f9 100644 --- a/gateway/package-lock.json +++ b/gateway/package-lock.json
@@ -65,7 +65,6 @@ "pg": "^8.7.1", "reflect-metadata": "^0.1.13", "sqlite3": "^5.0.2", - "swc": "^1.0.11", "tsconfig-paths": "^3.11.0", "typeorm": "^0.2.37", "typescript": "^4.4.2", @@ -10094,7 +10093,6 @@ "pg": "^8.7.1", "reflect-metadata": "^0.1.13", "sqlite3": "^5.0.2", - "swc": "^1.0.11", "tsconfig-paths": "^3.11.0", "typeorm": "^0.2.37", "typescript": "^4.4.2", diff --git a/gateway/src/Server.ts b/gateway/src/Server.ts
index b4e92a75..cf4f906c 100644 --- a/gateway/src/Server.ts +++ b/gateway/src/Server.ts
@@ -2,12 +2,12 @@ import "missing-native-js-functions"; import dotenv from "dotenv"; dotenv.config(); import { closeDatabase, Config, initDatabase, initEvent } from "@fosscord/util"; -import { Server as WebSocketServer } from "ws"; +import ws from "ws"; import { Connection } from "./events/Connection"; import http from "http"; export class Server { - public ws: WebSocketServer; + public ws: ws.Server; public port: number; public server: http.Server; public production: boolean; @@ -39,7 +39,7 @@ export class Server { }); }); - this.ws = new WebSocketServer({ + this.ws = new ws.Server({ maxPayload: 4096, noServer: true, }); diff --git a/gateway/src/events/Connection.ts b/gateway/src/events/Connection.ts
index f84f9d9b..c1a6b618 100644 --- a/gateway/src/events/Connection.ts +++ b/gateway/src/events/Connection.ts
@@ -1,11 +1,8 @@ import WS from "ws"; -import { - setHeartbeat, - Send, - CLOSECODES, - OPCODES, - WebSocket, -} from "@fosscord/gateway"; +import { WebSocket } from "@fosscord/gateway"; +import { Send } from "../util/Send"; +import { CLOSECODES, OPCODES } from "../util/Constants"; +import { setHeartbeat } from "../util/Heartbeat"; import { IncomingMessage } from "http"; import { Close } from "./Close"; import { Message } from "./Message"; diff --git a/gateway/src/events/Message.ts b/gateway/src/events/Message.ts
index 1f1c4f72..3648931d 100644 --- a/gateway/src/events/Message.ts +++ b/gateway/src/events/Message.ts
@@ -1,4 +1,5 @@ -import { WebSocket, Payload, CLOSECODES, OPCODES } from "@fosscord/gateway"; +import { CLOSECODES, OPCODES } from "../util/Constants"; +import { WebSocket, Payload } from "@fosscord/gateway"; var erlpack: any; try { erlpack = require("@yukikaze-bot/erlpack"); diff --git a/gateway/src/listener/listener.ts b/gateway/src/listener/listener.ts
index 0fa6bb08..ee640f38 100644 --- a/gateway/src/listener/listener.ts +++ b/gateway/src/listener/listener.ts
@@ -1,15 +1,15 @@ import { - User, getPermission, Permissions, - Channel, RabbitMQ, listenEvent, EventOpts, ListenEventOpts, Member, } from "@fosscord/util"; -import { OPCODES, WebSocket, Send } from "@fosscord/gateway"; +import { OPCODES } from "../util/Constants"; +import { Send } from "../util/Send"; +import { WebSocket } from "@fosscord/gateway"; import "missing-native-js-functions"; import { Channel as AMQChannel } from "amqplib"; import { Recipient } from "@fosscord/util"; diff --git a/gateway/src/opcodes/Heartbeat.ts b/gateway/src/opcodes/Heartbeat.ts
index 46caee56..50394130 100644 --- a/gateway/src/opcodes/Heartbeat.ts +++ b/gateway/src/opcodes/Heartbeat.ts
@@ -1,4 +1,6 @@ -import { Payload, Send, setHeartbeat, WebSocket } from "@fosscord/gateway"; +import { Payload, WebSocket } from "@fosscord/gateway"; +import { setHeartbeat } from "../util/Heartbeat"; +import { Send } from "../util/Send"; export async function onHeartbeat(this: WebSocket, data: Payload) { // TODO: validate payload diff --git a/gateway/src/opcodes/Identify.ts b/gateway/src/opcodes/Identify.ts
index 8233aade..6decf21c 100644 --- a/gateway/src/opcodes/Identify.ts +++ b/gateway/src/opcodes/Identify.ts
@@ -1,14 +1,6 @@ +import { WebSocket, Payload } from "@fosscord/gateway"; import { - WebSocket, - CLOSECODES, - Payload, - OPCODES, - genSessionId, -} from "@fosscord/gateway"; -import { - Channel, checkToken, - Guild, Intents, Member, ReadyEventData, @@ -16,16 +8,15 @@ import { Session, EVENTEnum, Config, - dbConnection, - PublicMemberProjection, PublicMember, - ChannelType, PublicUser, PrivateUserProjection, } from "@fosscord/util"; +import { Send } from "../util/Send"; +import { CLOSECODES, OPCODES } from "../util/Constants"; +import { genSessionId } from "../util/SessionUtils"; import { setupListener } from "../listener/listener"; import { IdentifySchema } from "../schema/Identify"; -import { Send } from "@fosscord/gateway/util/Send"; // import experiments from "./experiments.json"; const experiments: any = []; import { check } from "./instanceOf"; diff --git a/gateway/src/opcodes/LazyRequest.ts b/gateway/src/opcodes/LazyRequest.ts
index 5b6ac444..d37e32da 100644 --- a/gateway/src/opcodes/LazyRequest.ts +++ b/gateway/src/opcodes/LazyRequest.ts
@@ -5,7 +5,9 @@ import { Role, } from "@fosscord/util"; import { LazyRequest } from "../schema/LazyRequest"; -import { WebSocket, Send, OPCODES, Payload } from "@fosscord/gateway"; +import { Send } from "../util/Send"; +import { OPCODES } from "../util/Constants"; +import { WebSocket, Payload } from "@fosscord/gateway"; import { check } from "./instanceOf"; import "missing-native-js-functions"; diff --git a/gateway/tsconfig.json b/gateway/tsconfig.json
index e2ac5b0b..2ad38f93 100644 --- a/gateway/tsconfig.json +++ b/gateway/tsconfig.json
@@ -5,7 +5,7 @@ /* Visit https://aka.ms/tsconfig.json to read more about this file */ /* Basic Options */ - "incremental": true, /* Enable incremental compilation */ + "incremental": true /* Enable incremental compilation */, "target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, "lib": ["ES2015", "ES2020.BigInt", "DOM"] /* Specify library files to be included in the compilation. */, @@ -70,7 +70,7 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@fosscord/gateway": ["src/index"], + "@fosscord/gateway": ["src/index.ts"], "@fosscord/gateway/*": ["src/*"] }, "plugins": [{ "transform": "@zerollup/ts-transform-paths" }]