Skip to content

Commit

Permalink
feat: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Sceat committed Aug 9, 2024
1 parent 56abf80 commit dd8dbbb
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 53 deletions.
2 changes: 0 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { fromBinary, fromJson, toBinary, toJson } from '@bufbuild/protobuf'

import * as Packets from '../generated/ares_pb.js'

/** @typedef {ReturnType<create_client>} Client */

export function create_client({ socket_write, socket_end }) {
const controller = new AbortController()
const stream = new PassThrough({
Expand Down
2 changes: 0 additions & 2 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export interface TypedEmitter<T extends EventMap> {
removeAllListeners(): this
}

type Client = import('./index').Client

type Position = {
x: number
y: number
Expand Down
125 changes: 94 additions & 31 deletions types/generated/ares_pb.d.ts
Original file line number Diff line number Diff line change
@@ -1,127 +1,190 @@
/**
* Describes the file ares.proto.
*/
export const file_ares: import("@bufbuild/protobuf").DescFile;
export const file_ares: import('@bufbuild/protobuf').DescFile
/**
* Describes the message ares.Packet.
* Use `create(PacketSchema)` to create a new message.
*/
export const PacketSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const PacketSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.SignatureRequest.
* Use `create(SignatureRequestSchema)` to create a new message.
*/
export const SignatureRequestSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const SignatureRequestSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.Error.
* Use `create(ErrorSchema)` to create a new message.
*/
export const ErrorSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const ErrorSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.EntityGroupSpawn.
* Use `create(EntityGroupSpawnSchema)` to create a new message.
*/
export const EntityGroupSpawnSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const EntityGroupSpawnSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.CharactersDespawn.
* Use `create(CharactersDespawnSchema)` to create a new message.
*/
export const CharactersDespawnSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const CharactersDespawnSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.EntityGroupsDespawn.
* Use `create(EntityGroupsDespawnSchema)` to create a new message.
*/
export const EntityGroupsDespawnSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const EntityGroupsDespawnSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.FightsDespawn.
* Use `create(FightsDespawnSchema)` to create a new message.
*/
export const FightsDespawnSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const FightsDespawnSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.ServerInfo.
* Use `create(ServerInfoSchema)` to create a new message.
*/
export const ServerInfoSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const ServerInfoSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.CharacterHealth.
* Use `create(CharacterHealthSchema)` to create a new message.
*/
export const CharacterHealthSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const CharacterHealthSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.FightSpawn.
* Use `create(FightSpawnSchema)` to create a new message.
*/
export const FightSpawnSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const FightSpawnSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.SignatureResponse.
* Use `create(SignatureResponseSchema)` to create a new message.
*/
export const SignatureResponseSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const SignatureResponseSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.CharacterAttackMobGroup.
* Use `create(CharacterAttackMobGroupSchema)` to create a new message.
*/
export const CharacterAttackMobGroupSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const CharacterAttackMobGroupSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.CharacterAction.
* Use `create(CharacterActionSchema)` to create a new message.
*/
export const CharacterActionSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const CharacterActionSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.CharacterPosition.
* Use `create(CharacterPositionSchema)` to create a new message.
*/
export const CharacterPositionSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const CharacterPositionSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.ChatMessage.
* Use `create(ChatMessageSchema)` to create a new message.
*/
export const ChatMessageSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const ChatMessageSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.RequestResponse.
* Use `create(RequestResponseSchema)` to create a new message.
*/
export const RequestResponseSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const RequestResponseSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.Position.
* Use `create(PositionSchema)` to create a new message.
*/
export const PositionSchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const PositionSchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the message ares.Entity.
* Use `create(EntitySchema)` to create a new message.
*/
export const EntitySchema: import("@bufbuild/protobuf/codegenv1").GenMessage<import("@bufbuild/protobuf").Message, import("@bufbuild/protobuf").JsonValue>;
export const EntitySchema: import('@bufbuild/protobuf/codegenv1').GenMessage<
import('@bufbuild/protobuf').Message,
import('@bufbuild/protobuf').JsonValue
>
/**
* Describes the enum ares.Classe.
*/
export const ClasseSchema: import("@bufbuild/protobuf/codegenv1").GenEnum<number, import("@bufbuild/protobuf").JsonValue>;
export const ClasseSchema: import('@bufbuild/protobuf/codegenv1').GenEnum<
number,
import('@bufbuild/protobuf').JsonValue
>
/**
* @generated from enum ares.Classe
*/
export const Classe: {
[key: number]: string;
[k: string]: string | number;
};
[key: number]: string
[k: string]: string | number
}
/**
* Describes the enum ares.ErrorCode.
*/
export const ErrorCodeSchema: import("@bufbuild/protobuf/codegenv1").GenEnum<number, import("@bufbuild/protobuf").JsonValue>;
export const ErrorCodeSchema: import('@bufbuild/protobuf/codegenv1').GenEnum<
number,
import('@bufbuild/protobuf').JsonValue
>
/**
* @generated from enum ares.ErrorCode
*/
export const ErrorCode: {
[key: number]: string;
[k: string]: string | number;
};
[key: number]: string
[k: string]: string | number
}
/**
* Describes the enum ares.Action.
*/
export const ActionSchema: import("@bufbuild/protobuf/codegenv1").GenEnum<number, import("@bufbuild/protobuf").JsonValue>;
export const ActionSchema: import('@bufbuild/protobuf/codegenv1').GenEnum<
number,
import('@bufbuild/protobuf').JsonValue
>
/**
* @generated from enum ares.Action
*/
export const Action: {
[key: number]: string;
[k: string]: string | number;
};
[key: number]: string
[k: string]: string | number
}
40 changes: 22 additions & 18 deletions types/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
/** @typedef {ReturnType<create_client>} Client */
export function create_client({ socket_write, socket_end }: {
socket_write: any;
socket_end: any;
export function create_client({
socket_write,
socket_end,
}: {
socket_write: any
socket_end: any
}): {
controller: AbortController;
stream: PassThrough;
/** @type {import("./types").send} */
send<T extends keyof import("./types").Packets>(type: T, payload: import("./types").Packets[T]): void;
/** @type {(message: string) => void} */
end(message: string): void;
on_end: (handler: any) => any;
/** @type {(message: string) => void} */
notify_end: (message: string) => void;
/** @type {(message: ArrayBuffer) => void} */
notify_message(message: ArrayBuffer): void;
};
export type Client = ReturnType<typeof create_client>;
import { PassThrough } from 'stream';
controller: AbortController
stream: PassThrough
/** @type {import("./types").send} */
send<T extends keyof import('./types').Packets>(
type: T,
payload: import('./types').Packets[T],
): void
/** @type {(message: string) => void} */
end(message: string): void
on_end: (handler: any) => any
/** @type {(message: string) => void} */
notify_end: (message: string) => void
/** @type {(message: ArrayBuffer) => void} */
notify_message(message: ArrayBuffer): void
}
import { PassThrough } from 'stream'

0 comments on commit dd8dbbb

Please sign in to comment.