Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Jazcash committed Oct 31, 2021
0 parents commit 903f9f7
Show file tree
Hide file tree
Showing 31 changed files with 6,361 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
root: true,
env: {
node: true
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
plugins: [
"@typescript-eslint",
"simple-import-sort",
],
parserOptions: {
ecmaVersion: 2020
},
ignorePatterns: ["working-files/", "node_modules/", "dist/"],
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"key-spacing": ["error", {
"beforeColon": false,
"afterColon": true
}],

"simple-import-sort/imports": "warn",
"simple-import-sort/exports": "warn",

"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/quotes": ["error", "double"],
"@typescript-eslint/indent": ["error", 4],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-namespace": "off"
}
};
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
config.json
demos
maps
/start.sh
/working-files
/logs
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",
"typescript"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Jazcash

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Tachyon Client
Client API for interfacing with Beyond All Reason's Teiserver via the Tachyon protocol
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./tachyon-client";
14 changes: 14 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions dist/model/commands/client-commands.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export declare const clientCommandSchema: {
"c.system.ping": import("@sinclair/typebox").TVoid;
"c.auth.register": import("@sinclair/typebox").TObject<{
username: import("@sinclair/typebox").TString;
email: import("@sinclair/typebox").TString;
password: import("@sinclair/typebox").TString;
}>;
"c.auth.get_token": import("@sinclair/typebox").TObject<{
email: import("@sinclair/typebox").TString;
password: import("@sinclair/typebox").TString;
}>;
"c.auth.login": import("@sinclair/typebox").TObject<{
token: import("@sinclair/typebox").TString;
lobby_name: import("@sinclair/typebox").TString;
lobby_version: import("@sinclair/typebox").TString;
}>;
"c.auth.verify": import("@sinclair/typebox").TObject<{
token: import("@sinclair/typebox").TString;
code: import("@sinclair/typebox").TString;
}>;
"c.auth.disconnect": import("@sinclair/typebox").TVoid;
};
27 changes: 27 additions & 0 deletions dist/model/commands/client-commands.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/model/commands/client-commands.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/model/commands/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ClientCommands as _ClientCommands } from "./client-commands";
export declare namespace Commands {
export import Client = _ClientCommands;
}
10 changes: 10 additions & 0 deletions dist/model/commands/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/model/commands/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions dist/model/commands/server-commands.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export declare const serverCommandSchema: {
"s.system.pong": import("@sinclair/typebox").TVoid;
"s.auth.register": import("@sinclair/typebox").TObject<{
result: import("@sinclair/typebox").TString;
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
}>;
"s.auth.get_token": import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
result: import("@sinclair/typebox").TString;
token: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
}>]>;
"s.auth.login": import("@sinclair/typebox").TObject<{
result: import("@sinclair/typebox").TString;
user: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
agreement: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
}>;
"s.auth.verify": import("@sinclair/typebox").TObject<{
result: import("@sinclair/typebox").TString;
user: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TAny>;
reason: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
}>;
};
30 changes: 30 additions & 0 deletions dist/model/commands/server-commands.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/model/commands/server-commands.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added dist/model/system.ping.d.ts
Empty file.
2 changes: 2 additions & 0 deletions dist/model/system.ping.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/model/system.ping.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions dist/tachyon-client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/// <reference types="node" />
import { Static } from "@sinclair/typebox";
import { Signal } from "jaz-ts-utils";
import * as tls from "tls";
import { clientCommandSchema } from "./model/commands/client-commands";
import { serverCommandSchema } from "./model/commands/server-commands";
export interface TachyonClientOptions extends tls.ConnectionOptions {
host: string;
port: number;
verbose?: boolean;
}
export declare const defaultTachyonClientOptions: Partial<TachyonClientOptions>;
export declare type ClientCommandType<T> = T extends keyof typeof clientCommandSchema ? Static<typeof clientCommandSchema[T]> : void;
export declare type ServerCommandType<T> = T extends keyof typeof serverCommandSchema ? Static<typeof serverCommandSchema[T]> : void;
export interface TachyonClient {
[key: string]: unknown;
ping(): Promise<ServerCommandType<"s.system.pong">>;
getToken(options: ClientCommandType<"c.auth.get_token">): Promise<ServerCommandType<"s.auth.get_token">>;
}
export declare class TachyonClient {
protected config: TachyonClientOptions;
protected socket: tls.TLSSocket;
protected tachyonModeEnabled: boolean;
protected onCommand: Signal<{
[key: string]: unknown;
cmd: string;
}>;
constructor(options: TachyonClientOptions);
connect(): Promise<void>;
rawRequest(request: Record<string, unknown>): void;
protected addClientCommand<C extends keyof typeof clientCommandSchema, S extends keyof typeof serverCommandSchema, Args = Static<typeof clientCommandSchema[C]> extends Record<string, never> ? undefined : Static<typeof clientCommandSchema[C]>>(name: string, clientCmd: C, serverCmd?: S): void;
}
Loading

0 comments on commit 903f9f7

Please sign in to comment.