@4players/odin-common 1.5.0 → 1.5.1

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.
@@ -1,9 +1,10 @@
1
+ /// <reference types="ws" />
1
2
  import * as z from 'zod';
2
- import { WebSocket } from 'ws';
3
3
  import { MessagePackRpc } from '../schema/serialization';
4
4
  import { Accept, Result } from './result';
5
5
  import { Commands } from '../rpc/commands';
6
6
  import { Notifications } from '../rpc/notifications';
7
+ import { WebSocketClient } from './websocket';
7
8
  export declare function msgpackEncode(value: unknown): ArrayBuffer;
8
9
  export declare function msgpackDecode(buffer: ArrayBuffer): unknown;
9
10
  export interface RpcMessage {
@@ -15,7 +16,7 @@ export interface RpcRequest {
15
16
  timeoutId: ReturnType<typeof setTimeout> | undefined;
16
17
  }
17
18
  export declare class RpcConnection {
18
- readonly webSocket: WebSocket;
19
+ readonly webSocket: WebSocketClient;
19
20
  private readonly _SendQueue;
20
21
  private readonly _RecvQueue;
21
22
  private readonly _Requests;
@@ -23,7 +24,7 @@ export declare class RpcConnection {
23
24
  private _NextId;
24
25
  get closed(): boolean;
25
26
  get closeSignal(): AbortSignal;
26
- constructor(webSocket: WebSocket);
27
+ constructor(webSocket: WebSocketClient);
27
28
  request(name: string, properties: unknown): Promise<Result<unknown> | 'closed'>;
28
29
  request(name: string, properties: unknown, timeout: number): Promise<Result<unknown> | 'closed' | 'timeout'>;
29
30
  notify(name: string, properties: unknown): void;
@@ -47,7 +48,7 @@ export type RealizedEvents<E extends Notifications> = {
47
48
  export declare class TypedRpcConnection<C extends Commands, E extends Notifications> extends RpcConnection {
48
49
  readonly _Commands: C;
49
50
  readonly _Events: E;
50
- constructor(webSocket: WebSocket, _Commands: C, _Events: E);
51
+ constructor(webSocket: WebSocketClient, _Commands: C, _Events: E);
51
52
  request<Name extends Extract<keyof C, string>>(name: Name, properties: z.infer<C[Name]['request']>): Promise<Result<z.infer<C[Name]['response']>> | 'closed'>;
52
53
  request<Name extends Extract<keyof C, string>>(name: Name, properties: z.infer<C[Name]['request']>, timeout: number): Promise<Result<z.infer<C[Name]['response']>> | 'closed' | 'timeout'>;
53
54
  notify<Name extends Extract<keyof C, string>>(name: Name, properties: z.infer<C[Name]['request']>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4players/odin-common",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A collection of commonly used type definitions and utility functions across ODIN web projects",
5
5
  "author": "Josho Bleicker <josho.bleicker@4players.io> (https://www.4players.io)",
6
6
  "homepage": "https://www.4players.io",