From b9647a91ba2f5c9836d9e316489920775f02a1cd Mon Sep 17 00:00:00 2001 From: Suyashtnt Date: Mon, 18 Jan 2021 16:13:47 +0200 Subject: [PATCH] add docs for types and edit a few types --- index.d.ts | 314 ++++++++++++++++++++++++++++++---------------- package-lock.json | 2 +- 2 files changed, 209 insertions(+), 107 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9bd5f10..2ed5e44 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,110 +1,212 @@ /// declare module "minecraft-launcher-core" { - type OS = "windows" | "osx" | "linux"; - - 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; - installer?: string; - root: string; - os?: OS; - customLaunchArgs?: Array; - customArgs?: Array; - version: { - number: string; - type: string; - custom?: string; - }; - memory: { - max: string | number; - min: string | number; - }; - 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; - fullscreen?: boolean; - }; - 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; + type OS = "windows" | "osx" | "linux"; + + 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; + }; } - \ No newline at end of file + + interface ILauncherOptions { + /** + * Path or URL to the client package zip file. + */ + clientPackage?: string; + /** + * if true MCLC will remove the client package zip file after its finished extracting. + */ + removePackage?: boolean; + /** + * Path to installer being executed. + */ + installer?: string; + /** + * Path where you want the launcher to work in. + * This will usually be your .minecraft folder + */ + root: string; + /** + * OS override for minecraft natives + * + * @default will autodetect + */ + os?: OS; + /** + * Array of custom Minecraft arguments. + */ + customLaunchArgs?: Array; + /** + * Array of custom Java arguments + */ + customArgs?: Array; + /** + * minecraft version info + */ + version: { + /** + * Actual version. + * + * @example '1.16.4' + */ + number: string; + /** + * type of release, usually `release` or `snapshot` + */ + type: 'release' | 'snapshot' | string; + /** + * The name of the folder, jar file, and version json in the version folder. + * + * ` MCLM will look in the `versions` folder for this name + * @example '1.16.4-fabric' + */ + custom?: string; + }; + memory: { + /** + * Min amount of memory being used by Minecraft. + */ + max: string | number; + /** + * Max amount of memory being used by Minecraft. + */ + min: string | number; + }; + /** + * Path to Forge Jar. + * + * Versions below 1.13 should be the "universal" jar while versions above 1.13+ should be the "installer" jar + */ + forge?: string; + /** + * Path to the JRE executable file, will default to java if not entered. + */ + javaPath?: string; + server?: { + /** + * Host url to the server, don't include the port. + */ + host: string; + /** + * Port of the host url + * + * @default 25565 + */ + port?: string; + }; + proxy?: { + /** + * Host url to the proxy, don't include the port. + */ + host: string; + /** + * Username for the proxy. + * + * @default 8080 + */ + port?: string; + /** + * Username for the proxy. + */ + username?: string; + /** + * Password for the proxy. + */ + password?: string; + }; + /** + * Timeout on download requests. + */ + timeout?: number; + window?: { + width?: number; + height?: number; + fullscreen?: boolean; + }; + 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 { + /** + * @param username email if using a password, else the username + * @param password password for mojang account + */ + getAuth(username: string, password?: string): Promise; + /** + * + * @param access_token Token being checked if it can be used to login with (online mode) + * @param client_token Client token being checked to see if there was a change of client (online mode) + */ + validate( + access_token: string, + client_token: string + ): Promise>; + /** + * + * @param access_token Token being checked if it can be used to login with (online mode) + * @param client_token Client token being checked to see if there was a change of client (online mode) + */ + refreshAuth( + access_token: string, + client_token: string, + selectedProfile: IProfile + ): Promise; + /** + * + * @param access_token Token being checked if it can be used to login with (online mode) + * @param client_token Client token being checked to see if there was a change of client (online mode) + */ + invalidate( + access_token: string, + client_token: string + ): Promise>; + /** + * @param username email if using a password, else the username + * @param password password for mojang account + */ + 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; +} diff --git a/package-lock.json b/package-lock.json index fd2a9e6..22e5e05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "minecraft-launcher-core", - "version": "3.14.6", + "version": "3.16.1", "lockfileVersion": 1, "requires": true, "dependencies": {