@caisual/kit 0.3.0 → 0.5.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 +38 -1
- package/dist/kit.js +602 -79
- package/dist/node.d.ts +14 -1
- package/dist/node.js +458 -55
- package/dist/runtime.d.ts +7 -2
- package/dist/runtime.js +253 -51
- package/dist/server.d.ts +14 -0
- package/package.json +2 -1
package/dist/kit.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { DeviceReport } from '@caisual/contracts';
|
|
2
|
+
export type { DeviceReport } from '@caisual/contracts';
|
|
1
3
|
export type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
2
4
|
[key: string]: JsonValue;
|
|
3
5
|
};
|
|
@@ -50,6 +52,7 @@ export type VoiceMode = 'none' | 'room' | 'team' | 'proximity';
|
|
|
50
52
|
export type VoiceState = 'off' | 'joining' | 'on' | 'reconnecting';
|
|
51
53
|
export interface VoicePeer {
|
|
52
54
|
id: string;
|
|
55
|
+
mic: boolean;
|
|
53
56
|
muted: boolean;
|
|
54
57
|
speaking: boolean;
|
|
55
58
|
volume: number;
|
|
@@ -58,10 +61,13 @@ export interface VoicePeer {
|
|
|
58
61
|
export interface Voice {
|
|
59
62
|
readonly mode: VoiceMode;
|
|
60
63
|
readonly state: VoiceState;
|
|
64
|
+
readonly mic: boolean;
|
|
61
65
|
readonly muted: boolean;
|
|
62
66
|
readonly speaking: boolean;
|
|
63
67
|
readonly peers: readonly VoicePeer[];
|
|
64
|
-
join(
|
|
68
|
+
join(options?: {
|
|
69
|
+
mic?: boolean;
|
|
70
|
+
}): Promise<void>;
|
|
65
71
|
leave(): void;
|
|
66
72
|
mute(muted?: boolean): void;
|
|
67
73
|
setVolume(playerId: string, volume: number): void;
|
|
@@ -75,6 +81,7 @@ export interface RoomInvite {
|
|
|
75
81
|
export interface Room {
|
|
76
82
|
readonly state: JsonValue;
|
|
77
83
|
readonly tick: number;
|
|
84
|
+
readonly seed: number;
|
|
78
85
|
readonly status: RoomStatus;
|
|
79
86
|
readonly players: readonly RoomPlayer[];
|
|
80
87
|
readonly you: string;
|
|
@@ -95,15 +102,45 @@ export interface Room {
|
|
|
95
102
|
leave(): void;
|
|
96
103
|
serverTime(): number;
|
|
97
104
|
}
|
|
105
|
+
export interface Spectate {
|
|
106
|
+
readonly state: JsonValue;
|
|
107
|
+
readonly tick: number;
|
|
108
|
+
readonly seed: number;
|
|
109
|
+
readonly status: RoomStatus;
|
|
110
|
+
readonly players: readonly RoomPlayer[];
|
|
111
|
+
readonly host: string | null;
|
|
112
|
+
readonly code: string;
|
|
113
|
+
readonly result: JsonValue;
|
|
114
|
+
readonly delayMs: number;
|
|
115
|
+
onState(listener: (state: JsonValue, tick: number, serverTime: number) => void): () => void;
|
|
116
|
+
onPlayers(listener: (players: readonly RoomPlayer[]) => void): () => void;
|
|
117
|
+
onStatus(listener: (status: RoomStatus, result: JsonValue, at: number) => void): () => void;
|
|
118
|
+
onMessage(listener: (message: JsonValue) => void): () => void;
|
|
119
|
+
leave(): void;
|
|
120
|
+
serverTime(): number;
|
|
121
|
+
}
|
|
122
|
+
export interface MatchOptions {
|
|
123
|
+
mode: string;
|
|
124
|
+
key: Record<string, string | number>;
|
|
125
|
+
signal?: AbortSignal;
|
|
126
|
+
onWaiting?(waiting: {
|
|
127
|
+
players: number;
|
|
128
|
+
min: number;
|
|
129
|
+
max: number;
|
|
130
|
+
}): void;
|
|
131
|
+
}
|
|
98
132
|
export interface Rooms {
|
|
99
133
|
readonly invited: string | null;
|
|
100
134
|
create(options: {
|
|
101
135
|
mode: string | null;
|
|
102
136
|
}): Promise<Room>;
|
|
103
137
|
join(code?: string): Promise<Room>;
|
|
138
|
+
watch(code: string): Promise<Spectate>;
|
|
139
|
+
match(options: MatchOptions): Promise<Room>;
|
|
104
140
|
}
|
|
105
141
|
export interface CaisualConnection {
|
|
106
142
|
connected: boolean;
|
|
143
|
+
device: DeviceReport;
|
|
107
144
|
player: Player;
|
|
108
145
|
daily: {
|
|
109
146
|
day: string;
|