From 715de3fb57f12b0b999b66381cd43778eaf78908 Mon Sep 17 00:00:00 2001 From: Louis Bailleau Date: Thu, 30 Jul 2020 02:47:30 +0200 Subject: [PATCH 1/2] Created typescript typings for the library - Created module declaration file - Added `@types/node` to dev dependancies --- index.d.ts | 110 ++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 8 +++- package.json | 3 +- 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..5b6a7cf --- /dev/null +++ b/index.d.ts @@ -0,0 +1,110 @@ +/// + +declare module "minecraft-launcher-core" { + type OS = "windows" | "osx" | "linux"; + type Type = "release" | "snapshot"; + + interface IOverrides { + minArgs?: number; + minecraftJar?: string; + versionJson?: string; + directory?: string; + natives?: string; + assetRoot?: string; + libraryRoot?: string; + cwd?: string; + detached?: boolean; + classes?: Array; + maxSockets?: number; + url?: { + meta?: string; + resources?: string; + mavenForge?: string; + defaultRepoForge?: string; + fallbackMaven?: string; + }; + } + + interface ILauncherOptions { + clientPackage?: string; + removePackage?: boolean; + installed?: string; + root: string; + os?: OS; + customLaunchArgs?: Array; + customArgs?: Array; + version: { + number: string; + type: Type; + custom?: string; + }; + memory: { + max: string; + min: string; + }; + forge?: string; + javaPath?: string; + server?: { + host: string; + port: string; + }; + proxy?: { + host: string; + port: string; + username?: string; + password?: string; + }; + timeout?: number; + window?: { + width?: number; + height?: number; + }; + overrides?: IOverrides; + authorization: Promise; + } + + interface IUser { + access_token: string; + client_token: string; + uuid: string; + name: string; + user_properties: Partial; + } + + interface IProfile { + id: number; + name: string; + } + + interface IAuthenticator { + getAuth(username: string, password?: string): Promise; + validate( + access_token: string, + client_token: string + ): Promise>; + refreshAuth( + access_token: string, + client_token: string, + selectedProfile: IProfile + ): Promise; + invalidate( + access_token: string, + client_token: string + ): Promise>; + signOut( + username: string, + password: string + ): Promise>; + changeApiUrl(url: string): void; + } + + import { EventEmitter } from 'events' + import { ChildProcessWithoutNullStreams } from 'child_process' + + export class Client extends EventEmitter { + launch(options: ILauncherOptions): ChildProcessWithoutNullStreams | null; + } + + export const Authenticator: IAuthenticator; + } + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 2546ea9..088acbc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "3.14.4", + "version": "3.14.6", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -36,6 +36,12 @@ "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, + "@types/node": { + "version": "14.0.27", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", + "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==", + "dev": true + }, "acorn": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", diff --git a/package.json b/package.json index cf5b14d..4686a4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "3.14.6", + "version": "3.14.7", "description": "Lightweight module that downloads and runs Minecraft using javascript / NodeJS", "main": "index.js", "dependencies": { @@ -11,6 +11,7 @@ "uuid": "^3.3.2" }, "devDependencies": { + "@types/node": "^14.0.27", "eslint": "^6.8.0", "eslint-config-standard": "^14.1.1", "eslint-plugin-import": "^2.20.2", From c1d37b4bb778051587b8a86642ede5701788825d Mon Sep 17 00:00:00 2001 From: Louis Bailleau Date: Thu, 30 Jul 2020 03:08:31 +0200 Subject: [PATCH 2/2] Fixed a typing in the declaration file --- index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 5b6a7cf..9bb85f7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,7 +2,6 @@ declare module "minecraft-launcher-core" { type OS = "windows" | "osx" | "linux"; - type Type = "release" | "snapshot"; interface IOverrides { minArgs?: number; @@ -35,7 +34,7 @@ declare module "minecraft-launcher-core" { customArgs?: Array; version: { number: string; - type: Type; + type: string; custom?: string; }; memory: {