@srvquery/protocol-minecraft-java 0.0.1-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ /** Builds the Java Edition status handshake packet. */
2
+ export declare const buildHandshakePacket: ({ host, port }: {
3
+ host: string;
4
+ port: number;
5
+ }) => Buffer;
6
+ /** Builds a Java Edition status request packet. */
7
+ export declare const buildStatusRequestPacket: () => Buffer;
8
+ /** Builds a Java Edition ping packet. */
9
+ export declare const buildPingPacket: ({ payload }: {
10
+ payload: bigint;
11
+ }) => Buffer;
12
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/packet/request.ts"],"names":[],"mappings":"AAOA,uDAAuD;AACvD,eAAO,MAAM,oBAAoB,mBAAoB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KAAG,MASlF,CAAC;AAEL,mDAAmD;AACnD,eAAO,MAAM,wBAAwB,QAAO,MACU,CAAC;AAEvD,yCAAyC;AACzC,eAAO,MAAM,eAAe,gBAAiB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,KAAG,MAIlE,CAAC"}
@@ -0,0 +1,47 @@
1
+ import z from "zod";
2
+ /** Validates the version information returned by a Minecraft status query. */
3
+ export declare const MinecraftVersionSchema: z.ZodObject<{
4
+ name: z.ZodString;
5
+ protocol: z.ZodNumber;
6
+ }, z.core.$strip>;
7
+ /** A sample player returned by a Minecraft status query. */
8
+ export declare const MinecraftPlayerSchema: z.ZodObject<{
9
+ name: z.ZodString;
10
+ id: z.ZodString;
11
+ }, z.core.$strip>;
12
+ /** Validates the player counts and optional samples in a Minecraft status response. */
13
+ export declare const MinecraftPlayersSchema: z.ZodObject<{
14
+ max: z.ZodNumber;
15
+ online: z.ZodNumber;
16
+ sample: z.ZodOptional<z.ZodArray<z.ZodObject<{
17
+ name: z.ZodString;
18
+ id: z.ZodString;
19
+ }, z.core.$strip>>>;
20
+ }, z.core.$strip>;
21
+ /** Validates a Minecraft status description, which may be plain text or a chat component. */
22
+ export declare const MinecraftDescriptionSchema: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
23
+ /** Validates the response to a Minecraft Java Server List Ping status request. */
24
+ export declare const MinecraftServerStatusSchema: z.ZodObject<{
25
+ version: z.ZodObject<{
26
+ name: z.ZodString;
27
+ protocol: z.ZodNumber;
28
+ }, z.core.$strip>;
29
+ players: z.ZodObject<{
30
+ max: z.ZodNumber;
31
+ online: z.ZodNumber;
32
+ sample: z.ZodOptional<z.ZodArray<z.ZodObject<{
33
+ name: z.ZodString;
34
+ id: z.ZodString;
35
+ }, z.core.$strip>>>;
36
+ }, z.core.$strip>;
37
+ description: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>;
38
+ favicon: z.ZodOptional<z.ZodString>;
39
+ enforcesSecureChat: z.ZodOptional<z.ZodBoolean>;
40
+ previewsChat: z.ZodOptional<z.ZodBoolean>;
41
+ }, z.core.$strip>;
42
+ export type MinecraftVersion = z.infer<typeof MinecraftVersionSchema>;
43
+ export type MinecraftPlayer = z.infer<typeof MinecraftPlayerSchema>;
44
+ export type MinecraftPlayers = z.infer<typeof MinecraftPlayersSchema>;
45
+ export type MinecraftDescription = z.infer<typeof MinecraftDescriptionSchema>;
46
+ export type MinecraftServerStatus = z.infer<typeof MinecraftServerStatusSchema>;
47
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/packet/schema.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,8EAA8E;AAC9E,eAAO,MAAM,sBAAsB;;;iBAA6D,CAAC;AAEjG,4DAA4D;AAC5D,eAAO,MAAM,qBAAqB;;;iBAAiD,CAAC;AAEpF,uFAAuF;AACvF,eAAO,MAAM,sBAAsB;;;;;;;iBAIjC,CAAC;AAEH,6FAA6F;AAC7F,eAAO,MAAM,0BAA0B,4EAA2D,CAAC;AAEnG,kFAAkF;AAClF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Encodes a signed Minecraft protocol VarInt. */
2
+ export declare const encodeVarInt: ({ value }: {
3
+ value: number;
4
+ }) => Buffer;
5
+ /** Decodes a Minecraft protocol VarInt. */
6
+ export declare const decodeVarInt: ({ buffer, offset, }: {
7
+ buffer: Buffer;
8
+ offset?: number;
9
+ }) => {
10
+ value: number;
11
+ bytes: number;
12
+ };
13
+ /** Prefixes a payload with its Minecraft packet length. */
14
+ export declare const framePacket: ({ payload }: {
15
+ payload: Buffer;
16
+ }) => Buffer;
17
+ //# sourceMappingURL=varint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varint.d.ts","sourceRoot":"","sources":["../../src/packet/varint.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,eAAO,MAAM,YAAY,cAAe;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,KAAG,MAY3D,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,YAAY,wBAGtB;IACD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,KAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAWjC,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,WAAW,gBAAiB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,KAAG,MACI,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type CreateHttpClientParams, type RetryOptions } from "@srvquery/core";
2
+ import { type MinecraftServerStatus } from "./packet/schema";
3
+ /** Connection and retry settings used to create a Minecraft Java protocol client. */
4
+ export type CreateMinecraftJavaProtocolParams = Omit<CreateHttpClientParams, "port"> & {
5
+ /** Minecraft Java Edition's default server port. */
6
+ port?: number;
7
+ /** Time in milliseconds to wait for a response to a single query attempt. */
8
+ timeout?: number;
9
+ /** Retry behavior for a query. */
10
+ retry?: RetryOptions;
11
+ };
12
+ /** Default TCP port used by Minecraft Java Edition servers. */
13
+ export declare const defaultMinecraftJavaPort = 25565;
14
+ /** Query operations supported by the Minecraft Java Server List Ping protocol. */
15
+ export type MinecraftJavaProtocolRequestOpcode = "STATUS" | "PING";
16
+ type MinecraftJavaProtocolResponseMap = {
17
+ STATUS: MinecraftServerStatus;
18
+ PING: number;
19
+ };
20
+ /** Client for querying Minecraft Java Edition servers. */
21
+ export interface MinecraftJavaProtocol {
22
+ /** Queries one Minecraft Java status opcode. */
23
+ query<Opcode extends MinecraftJavaProtocolRequestOpcode>(params: {
24
+ opcode: Opcode;
25
+ }): Promise<MinecraftJavaProtocolResponseMap[Opcode]>;
26
+ }
27
+ /** Creates a client for querying a Minecraft Java Edition server. */
28
+ export declare const createMinecraftJavaProtocol: ({ host, port, retry, timeout, }: CreateMinecraftJavaProtocolParams) => MinecraftJavaProtocol;
29
+ export {};
30
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAK3B,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAA+B,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG1F,qFAAqF;AACrF,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,GAAG;IACrF,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C,kFAAkF;AAClF,MAAM,MAAM,kCAAkC,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnE,KAAK,gCAAgC,GAAG;IACtC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,0DAA0D;AAC1D,MAAM,WAAW,qBAAqB;IACpC,gDAAgD;IAChD,KAAK,CAAC,MAAM,SAAS,kCAAkC,EAAE,MAAM,EAAE;QAC/D,MAAM,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC,gCAAgC,CAAC,MAAM,CAAC,CAAC,CAAC;CACvD;AA+ED,qEAAqE;AACrE,eAAO,MAAM,2BAA2B,oCAKrC,iCAAiC,KAAG,qBAuDtC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@srvquery/protocol-minecraft-java",
3
+ "version": "0.0.1-next.0",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "zod": "^4.5.4"
16
+ },
17
+ "devDependencies": {
18
+ "@internal/typescript-config": "0.0.0",
19
+ "@srvquery/core": "0.0.1-next.0",
20
+ "@types/node": "^26.4.1",
21
+ "rolldown": "^1.2.7",
22
+ "typescript": "^7.0.2",
23
+ "vitest": "^5.0.0"
24
+ },
25
+ "peerDependencies": {
26
+ "@srvquery/core": "0.0.1-next.0"
27
+ },
28
+ "scripts": {
29
+ "build": "rolldown -c rolldown.config.ts && tsc -p tsconfig.json",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest"
32
+ }
33
+ }