@caisual/kit 0.1.0 → 0.3.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.
package/dist/kit.d.ts CHANGED
@@ -36,6 +36,72 @@ export type BoardOffline = {
36
36
  accepted: false;
37
37
  reason: 'offline';
38
38
  };
39
+ export type RoomStatus = 'lobby' | 'countdown' | 'playing' | 'ended';
40
+ export interface RoomPlayer {
41
+ id: string;
42
+ name: string;
43
+ guest: boolean;
44
+ role: string | null;
45
+ team: number | null;
46
+ ready: boolean;
47
+ connected: boolean;
48
+ }
49
+ export type VoiceMode = 'none' | 'room' | 'team' | 'proximity';
50
+ export type VoiceState = 'off' | 'joining' | 'on' | 'reconnecting';
51
+ export interface VoicePeer {
52
+ id: string;
53
+ muted: boolean;
54
+ speaking: boolean;
55
+ volume: number;
56
+ gain: number;
57
+ }
58
+ export interface Voice {
59
+ readonly mode: VoiceMode;
60
+ readonly state: VoiceState;
61
+ readonly muted: boolean;
62
+ readonly speaking: boolean;
63
+ readonly peers: readonly VoicePeer[];
64
+ join(): Promise<void>;
65
+ leave(): void;
66
+ mute(muted?: boolean): void;
67
+ setVolume(playerId: string, volume: number): void;
68
+ onPeers(listener: (peers: readonly VoicePeer[]) => void): () => void;
69
+ onState(listener: (state: VoiceState) => void): () => void;
70
+ }
71
+ export interface RoomInvite {
72
+ code: string;
73
+ url: string;
74
+ }
75
+ export interface Room {
76
+ readonly state: JsonValue;
77
+ readonly tick: number;
78
+ readonly status: RoomStatus;
79
+ readonly players: readonly RoomPlayer[];
80
+ readonly you: string;
81
+ readonly host: string | null;
82
+ readonly code: string;
83
+ readonly result: JsonValue;
84
+ readonly voice: Voice;
85
+ invite(): RoomInvite;
86
+ onState(listener: (state: JsonValue, tick: number, serverTime: number) => void): () => void;
87
+ onPlayers(listener: (players: readonly RoomPlayer[]) => void): () => void;
88
+ onStatus(listener: (status: RoomStatus, result: JsonValue, at: number) => void): () => void;
89
+ onMessage(listener: (message: JsonValue) => void): () => void;
90
+ send(message: JsonValue): void;
91
+ ready(ready: boolean): void;
92
+ setRole(role: string): void;
93
+ setTeam(team: number): void;
94
+ start(): void;
95
+ leave(): void;
96
+ serverTime(): number;
97
+ }
98
+ export interface Rooms {
99
+ readonly invited: string | null;
100
+ create(options: {
101
+ mode: string | null;
102
+ }): Promise<Room>;
103
+ join(code?: string): Promise<Room>;
104
+ }
39
105
  export interface CaisualConnection {
40
106
  connected: boolean;
41
107
  player: Player;
@@ -63,6 +129,7 @@ export interface CaisualConnection {
63
129
  guests?: boolean;
64
130
  }): Promise<BoardTop>;
65
131
  };
132
+ room: Rooms;
66
133
  }
67
134
  export interface Caisual {
68
135
  connect(): Promise<CaisualConnection>;