@thegeem/protocol 0.1.23 → 0.1.25
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/index.cjs +24 -5
- package/dist/index.d.cts +51 -4
- package/dist/index.d.ts +51 -4
- package/dist/index.js +22 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
CHARACTER_IDS: () => CHARACTER_IDS,
|
|
23
24
|
ClientMsg: () => ClientMsg,
|
|
25
|
+
EMOTE_IDS: () => EMOTE_IDS,
|
|
24
26
|
GAMES: () => GAMES,
|
|
25
27
|
GAME_IDS: () => GAME_IDS,
|
|
26
28
|
LIMITS: () => LIMITS,
|
|
@@ -69,6 +71,8 @@ var MODES = [
|
|
|
69
71
|
{ id: "snag", gameId: "snag", label: "Snag", onlineEligible: true }
|
|
70
72
|
];
|
|
71
73
|
var modesForGame = (gameId) => MODES.filter((m) => m.gameId === gameId);
|
|
74
|
+
var EMOTE_IDS = ["laugh", "wow", "think", "gg"];
|
|
75
|
+
var CHARACTER_IDS = ["m", "f"];
|
|
72
76
|
var ROOM_ALPHABET = "ACDEFGHJKMNPQRTUVWXY2346789";
|
|
73
77
|
var UNSAFE_CHARS = /[\p{Cc}<>]/gu;
|
|
74
78
|
var DisplayName = import_zod.z.string().trim().min(1).max(LIMITS.MAX_NAME_LEN).transform((s) => s.replace(UNSAFE_CHARS, "").trim()).refine((s) => s.length >= 1, "name is empty after sanitizing");
|
|
@@ -90,9 +94,10 @@ var Avatar = import_zod.z.object({
|
|
|
90
94
|
emoji: import_zod.z.string().min(1).max(16).transform((s) => s.replace(UNSAFE_CHARS, "")).refine((s) => s.length >= 1, "empty emoji"),
|
|
91
95
|
color: import_zod.z.string().regex(/^#[0-9a-fA-F]{6}$/, "color must be #rrggbb")
|
|
92
96
|
});
|
|
97
|
+
var Character = import_zod.z.enum(CHARACTER_IDS);
|
|
93
98
|
var ClientMsg = import_zod.z.discriminatedUnion("t", [
|
|
94
99
|
// room / lobby
|
|
95
|
-
import_zod.z.object({ t: import_zod.z.literal("createRoom"), name: DisplayName.optional(), avatar: Avatar.optional(), game: import_zod.z.enum(GAME_IDS).optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
100
|
+
import_zod.z.object({ t: import_zod.z.literal("createRoom"), name: DisplayName.optional(), avatar: Avatar.optional(), game: import_zod.z.enum(GAME_IDS).optional(), character: Character.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
96
101
|
// Host sets/changes their display name AFTER createRoom (for anonymous one-tap
|
|
97
102
|
// hosts who started nameless). Host-only; the relay re-broadcasts the lobby.
|
|
98
103
|
// SUPERSEDED by setProfile (kept working for shipped builds).
|
|
@@ -105,9 +110,9 @@ var ClientMsg = import_zod.z.discriminatedUnion("t", [
|
|
|
105
110
|
// Note: mid-game propagation depends on what the running game's state carries — trivia's
|
|
106
111
|
// view carries names+avatars so it updates live; dama/ersimha views are id-keyed (clients
|
|
107
112
|
// map ids→names from the lobby roster), so a change there lands on the next lobby.
|
|
108
|
-
import_zod.z.object({ t: import_zod.z.literal("setProfile"), name: DisplayName.optional(), avatar: Avatar.optional() }),
|
|
109
|
-
import_zod.z.object({ t: import_zod.z.literal("joinRoom"), code: RoomCode, name: DisplayName, avatar: Avatar.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
110
|
-
import_zod.z.object({ t: import_zod.z.literal("resume"), code: RoomCode, token: import_zod.z.string().max(120), avatar: Avatar.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
113
|
+
import_zod.z.object({ t: import_zod.z.literal("setProfile"), name: DisplayName.optional(), avatar: Avatar.optional(), character: Character.optional() }),
|
|
114
|
+
import_zod.z.object({ t: import_zod.z.literal("joinRoom"), code: RoomCode, name: DisplayName, avatar: Avatar.optional(), character: Character.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
115
|
+
import_zod.z.object({ t: import_zod.z.literal("resume"), code: RoomCode, token: import_zod.z.string().max(120), avatar: Avatar.optional(), character: Character.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
111
116
|
import_zod.z.object({ t: import_zod.z.literal("leaveRoom") }),
|
|
112
117
|
import_zod.z.object({ t: import_zod.z.literal("approve"), playerId: PlayerId }),
|
|
113
118
|
import_zod.z.object({ t: import_zod.z.literal("reject"), playerId: PlayerId }),
|
|
@@ -123,7 +128,14 @@ var ClientMsg = import_zod.z.discriminatedUnion("t", [
|
|
|
123
128
|
// Host's IN-PROGRESS mode selection in the lobby — a live preview so waiting players see which mode
|
|
124
129
|
// is coming before start. Distinct from startGame.modeId (which commits it); the relay defaults
|
|
125
130
|
// startGame to this when modeId is omitted. Re-broadcasts the lobby.
|
|
126
|
-
|
|
131
|
+
// The room's "what's next" announcement (gs#49) — host-only, LOBBY-only. In a room-first قعدة the
|
|
132
|
+
// room outlives each game, so this is how joiners learn what they're about to play instead of
|
|
133
|
+
// finding out when the board appears. Carries the GAME (tile) and/or the trivia MODE; the server
|
|
134
|
+
// re-broadcasts `lobby` so everyone — including someone who joins later — sees `gameId`/`modeId`.
|
|
135
|
+
// `modeId` alone still works (pre-gs#49 clients); `game` is what lets a host announce a tile with
|
|
136
|
+
// no modes (dama/ersimha), which `modeId` could never express. An incoherent pair (a mode that
|
|
137
|
+
// doesn't belong to the game) is rejected with `bad_mode` rather than silently resolved.
|
|
138
|
+
import_zod.z.object({ t: import_zod.z.literal("setMode"), game: import_zod.z.enum(GAME_IDS).optional(), modeId: import_zod.z.enum(MODE_IDS).optional() }),
|
|
127
139
|
// Host signals it's busy configuring the game (categories/rounds/mode) so waiting players can show
|
|
128
140
|
// a "host is setting up…" state instead of a frozen-looking lobby. 'idle' when the settings close.
|
|
129
141
|
import_zod.z.object({ t: import_zod.z.literal("hostActivity"), activity: import_zod.z.enum(["configuring", "idle"]) }),
|
|
@@ -166,6 +178,11 @@ var ClientMsg = import_zod.z.discriminatedUnion("t", [
|
|
|
166
178
|
import_zod.z.object({ t: import_zod.z.literal("noHostNobody") }),
|
|
167
179
|
// player actions
|
|
168
180
|
import_zod.z.object({ t: import_zod.z.literal("buzz") }),
|
|
181
|
+
// «طقطقة» (D-038): send one of the four closed emotes. Server-enforced 5s per-player throttle on
|
|
182
|
+
// its OWN rate lane — a client-side throttle is trivially bypassed, and this is a family app, so
|
|
183
|
+
// Shape B applies exactly as it does to buzz arrival order. Over-rate emotes are dropped silently.
|
|
184
|
+
// Ephemeral: relayed, never stored. Allowed only while a game whose driver permits emotes is running.
|
|
185
|
+
import_zod.z.object({ t: import_zod.z.literal("sendEmote"), emoteId: import_zod.z.enum(EMOTE_IDS) }),
|
|
169
186
|
import_zod.z.object({ t: import_zod.z.literal("answer"), index: import_zod.z.number().int().min(0).max(3) }),
|
|
170
187
|
// trivia is 4-option (0–3)
|
|
171
188
|
import_zod.z.object({ t: import_zod.z.literal("useHelp"), helpType: HelpType }),
|
|
@@ -216,7 +233,9 @@ var ClientMsg = import_zod.z.discriminatedUnion("t", [
|
|
|
216
233
|
]);
|
|
217
234
|
// Annotate the CommonJS export names for ESM import in node:
|
|
218
235
|
0 && (module.exports = {
|
|
236
|
+
CHARACTER_IDS,
|
|
219
237
|
ClientMsg,
|
|
238
|
+
EMOTE_IDS,
|
|
220
239
|
GAMES,
|
|
221
240
|
GAME_IDS,
|
|
222
241
|
LIMITS,
|
package/dist/index.d.cts
CHANGED
|
@@ -83,6 +83,24 @@ interface ModeInfo {
|
|
|
83
83
|
declare const MODES: readonly ModeInfo[];
|
|
84
84
|
/** The modes available for a given game (for a client's mode picker). */
|
|
85
85
|
declare const modesForGame: (gameId: GameId) => ModeInfo[];
|
|
86
|
+
/**
|
|
87
|
+
* «طقطقة» (tagtaga) emotes — D-038 (filed as D-036 in gs#50), design `geem-design DESIGN.md § tagtaga`.
|
|
88
|
+
* A CLOSED, POSITIVE-ONLY set of exactly four: ههههه · يا سلام · قاعد أفكر · لعب زين. The ids match the
|
|
89
|
+
* art masters (`art/tagtaga/Tagtaga-<emoteId>-<character>.png`), so the wire addresses the sprite directly.
|
|
90
|
+
* ⚠ Never add hurry-up / gloat / crying / angry — that's a RULING, not an oversight: «think» exists so a
|
|
91
|
+
* slow player can speak about THEMSELVES rather than anyone pressuring anyone. A closed enum with no
|
|
92
|
+
* free-form payload is also what keeps emotes off the UGC/moderation surface entirely.
|
|
93
|
+
*/
|
|
94
|
+
declare const EMOTE_IDS: readonly ["laugh", "wow", "think", "gg"];
|
|
95
|
+
type EmoteId = (typeof EMOTE_IDS)[number];
|
|
96
|
+
/**
|
|
97
|
+
* Which character sprite a player is drawn as: `m` = ghutra, `f` = hijab (the `-m`/`-f` art suffix).
|
|
98
|
+
* Both carry the identical emote set. It's a display preference, not identity: set it on room entry
|
|
99
|
+
* or change it any time via `setProfile`, and the server stamps it on that player's outgoing emotes
|
|
100
|
+
* so receivers can pick the right sprite without a roster lookup.
|
|
101
|
+
*/
|
|
102
|
+
declare const CHARACTER_IDS: readonly ["m", "f"];
|
|
103
|
+
type CharacterId = (typeof CHARACTER_IDS)[number];
|
|
86
104
|
/** Unambiguous room-code alphabet — no 0/O, 1/I/L. */
|
|
87
105
|
declare const ROOM_ALPHABET = "ACDEFGHJKMNPQRTUVWXY2346789";
|
|
88
106
|
declare const HelpType: z.ZodEnum<["removeTwoAnswers", "changeQuestion", "extraTime", "doublePoints", "stealPoints", "restPlayer", "tripLevel"]>;
|
|
@@ -100,6 +118,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
100
118
|
color: string;
|
|
101
119
|
}>>;
|
|
102
120
|
game: z.ZodOptional<z.ZodEnum<["seedha", "snag", "trivia", "dama", "ersimha"]>>;
|
|
121
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
103
122
|
pv: z.ZodOptional<z.ZodNumber>;
|
|
104
123
|
idToken: z.ZodOptional<z.ZodString>;
|
|
105
124
|
platform: z.ZodOptional<z.ZodEnum<["web", "ios", "android"]>>;
|
|
@@ -111,6 +130,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
111
130
|
color: string;
|
|
112
131
|
} | undefined;
|
|
113
132
|
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
133
|
+
character?: "m" | "f" | undefined;
|
|
114
134
|
pv?: number | undefined;
|
|
115
135
|
idToken?: string | undefined;
|
|
116
136
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -122,6 +142,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
122
142
|
color: string;
|
|
123
143
|
} | undefined;
|
|
124
144
|
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
145
|
+
character?: "m" | "f" | undefined;
|
|
125
146
|
pv?: number | undefined;
|
|
126
147
|
idToken?: string | undefined;
|
|
127
148
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -147,6 +168,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
147
168
|
emoji: string;
|
|
148
169
|
color: string;
|
|
149
170
|
}>>;
|
|
171
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
150
172
|
}, "strip", z.ZodTypeAny, {
|
|
151
173
|
t: "setProfile";
|
|
152
174
|
name?: string | undefined;
|
|
@@ -154,6 +176,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
154
176
|
emoji: string;
|
|
155
177
|
color: string;
|
|
156
178
|
} | undefined;
|
|
179
|
+
character?: "m" | "f" | undefined;
|
|
157
180
|
}, {
|
|
158
181
|
t: "setProfile";
|
|
159
182
|
name?: string | undefined;
|
|
@@ -161,6 +184,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
161
184
|
emoji: string;
|
|
162
185
|
color: string;
|
|
163
186
|
} | undefined;
|
|
187
|
+
character?: "m" | "f" | undefined;
|
|
164
188
|
}>, z.ZodObject<{
|
|
165
189
|
t: z.ZodLiteral<"joinRoom">;
|
|
166
190
|
code: z.ZodString;
|
|
@@ -175,6 +199,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
175
199
|
emoji: string;
|
|
176
200
|
color: string;
|
|
177
201
|
}>>;
|
|
202
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
178
203
|
pv: z.ZodOptional<z.ZodNumber>;
|
|
179
204
|
idToken: z.ZodOptional<z.ZodString>;
|
|
180
205
|
platform: z.ZodOptional<z.ZodEnum<["web", "ios", "android"]>>;
|
|
@@ -186,6 +211,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
186
211
|
emoji: string;
|
|
187
212
|
color: string;
|
|
188
213
|
} | undefined;
|
|
214
|
+
character?: "m" | "f" | undefined;
|
|
189
215
|
pv?: number | undefined;
|
|
190
216
|
idToken?: string | undefined;
|
|
191
217
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -197,6 +223,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
197
223
|
emoji: string;
|
|
198
224
|
color: string;
|
|
199
225
|
} | undefined;
|
|
226
|
+
character?: "m" | "f" | undefined;
|
|
200
227
|
pv?: number | undefined;
|
|
201
228
|
idToken?: string | undefined;
|
|
202
229
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -214,6 +241,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
214
241
|
emoji: string;
|
|
215
242
|
color: string;
|
|
216
243
|
}>>;
|
|
244
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
217
245
|
pv: z.ZodOptional<z.ZodNumber>;
|
|
218
246
|
idToken: z.ZodOptional<z.ZodString>;
|
|
219
247
|
platform: z.ZodOptional<z.ZodEnum<["web", "ios", "android"]>>;
|
|
@@ -225,6 +253,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
225
253
|
emoji: string;
|
|
226
254
|
color: string;
|
|
227
255
|
} | undefined;
|
|
256
|
+
character?: "m" | "f" | undefined;
|
|
228
257
|
pv?: number | undefined;
|
|
229
258
|
idToken?: string | undefined;
|
|
230
259
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -236,6 +265,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
236
265
|
emoji: string;
|
|
237
266
|
color: string;
|
|
238
267
|
} | undefined;
|
|
268
|
+
character?: "m" | "f" | undefined;
|
|
239
269
|
pv?: number | undefined;
|
|
240
270
|
idToken?: string | undefined;
|
|
241
271
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -301,13 +331,16 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
301
331
|
teamIndex: number;
|
|
302
332
|
}>, z.ZodObject<{
|
|
303
333
|
t: z.ZodLiteral<"setMode">;
|
|
304
|
-
|
|
334
|
+
game: z.ZodOptional<z.ZodEnum<["seedha", "snag", "trivia", "dama", "ersimha"]>>;
|
|
335
|
+
modeId: z.ZodOptional<z.ZodEnum<["solo", "oneDevice", "snag", "multiplayer"]>>;
|
|
305
336
|
}, "strip", z.ZodTypeAny, {
|
|
306
337
|
t: "setMode";
|
|
307
|
-
|
|
338
|
+
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
339
|
+
modeId?: "snag" | "solo" | "oneDevice" | "multiplayer" | undefined;
|
|
308
340
|
}, {
|
|
309
341
|
t: "setMode";
|
|
310
|
-
|
|
342
|
+
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
343
|
+
modeId?: "snag" | "solo" | "oneDevice" | "multiplayer" | undefined;
|
|
311
344
|
}>, z.ZodObject<{
|
|
312
345
|
t: z.ZodLiteral<"hostActivity">;
|
|
313
346
|
activity: z.ZodEnum<["configuring", "idle"]>;
|
|
@@ -404,6 +437,15 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
404
437
|
t: "buzz";
|
|
405
438
|
}, {
|
|
406
439
|
t: "buzz";
|
|
440
|
+
}>, z.ZodObject<{
|
|
441
|
+
t: z.ZodLiteral<"sendEmote">;
|
|
442
|
+
emoteId: z.ZodEnum<["laugh", "wow", "think", "gg"]>;
|
|
443
|
+
}, "strip", z.ZodTypeAny, {
|
|
444
|
+
t: "sendEmote";
|
|
445
|
+
emoteId: "laugh" | "wow" | "think" | "gg";
|
|
446
|
+
}, {
|
|
447
|
+
t: "sendEmote";
|
|
448
|
+
emoteId: "laugh" | "wow" | "think" | "gg";
|
|
407
449
|
}>, z.ZodObject<{
|
|
408
450
|
t: z.ZodLiteral<"answer">;
|
|
409
451
|
index: z.ZodNumber;
|
|
@@ -824,6 +866,11 @@ type ServerMsg = {
|
|
|
824
866
|
} | {
|
|
825
867
|
t: 'roomClosed';
|
|
826
868
|
reason: string;
|
|
869
|
+
} | {
|
|
870
|
+
t: 'emote';
|
|
871
|
+
from: string;
|
|
872
|
+
emoteId: EmoteId;
|
|
873
|
+
character: CharacterId;
|
|
827
874
|
} | {
|
|
828
875
|
t: 'lobby';
|
|
829
876
|
code: string;
|
|
@@ -888,4 +935,4 @@ type ServerMsg = {
|
|
|
888
935
|
message: string;
|
|
889
936
|
};
|
|
890
937
|
|
|
891
|
-
export { type AvatarView, type BuzzerGameMode, type CategoryView, ClientMsg, type DamaMoveView, type DamaPieceView, type DamaStateView, type Effect, type ErsimhaStateView, GAMES, GAME_IDS, type GameId, type GameInfo, type GameStateView, type GameStatus, type GameplayFlow, type HelpName, LIMITS, type LobbyPlayer, MIN_SUPPORTED_PV, MODES, MODE_IDS, type ModeId, type ModeInfo, PROTOCOL_VERSION, type QuestionView, ROOM_ALPHABET, type ServerMsg, type SoundName, type TeamSlotView, type TeamView, type YouContext, gameIdForPv, gamesForPv, modesForGame };
|
|
938
|
+
export { type AvatarView, type BuzzerGameMode, CHARACTER_IDS, type CategoryView, type CharacterId, ClientMsg, type DamaMoveView, type DamaPieceView, type DamaStateView, EMOTE_IDS, type Effect, type EmoteId, type ErsimhaStateView, GAMES, GAME_IDS, type GameId, type GameInfo, type GameStateView, type GameStatus, type GameplayFlow, type HelpName, LIMITS, type LobbyPlayer, MIN_SUPPORTED_PV, MODES, MODE_IDS, type ModeId, type ModeInfo, PROTOCOL_VERSION, type QuestionView, ROOM_ALPHABET, type ServerMsg, type SoundName, type TeamSlotView, type TeamView, type YouContext, gameIdForPv, gamesForPv, modesForGame };
|
package/dist/index.d.ts
CHANGED
|
@@ -83,6 +83,24 @@ interface ModeInfo {
|
|
|
83
83
|
declare const MODES: readonly ModeInfo[];
|
|
84
84
|
/** The modes available for a given game (for a client's mode picker). */
|
|
85
85
|
declare const modesForGame: (gameId: GameId) => ModeInfo[];
|
|
86
|
+
/**
|
|
87
|
+
* «طقطقة» (tagtaga) emotes — D-038 (filed as D-036 in gs#50), design `geem-design DESIGN.md § tagtaga`.
|
|
88
|
+
* A CLOSED, POSITIVE-ONLY set of exactly four: ههههه · يا سلام · قاعد أفكر · لعب زين. The ids match the
|
|
89
|
+
* art masters (`art/tagtaga/Tagtaga-<emoteId>-<character>.png`), so the wire addresses the sprite directly.
|
|
90
|
+
* ⚠ Never add hurry-up / gloat / crying / angry — that's a RULING, not an oversight: «think» exists so a
|
|
91
|
+
* slow player can speak about THEMSELVES rather than anyone pressuring anyone. A closed enum with no
|
|
92
|
+
* free-form payload is also what keeps emotes off the UGC/moderation surface entirely.
|
|
93
|
+
*/
|
|
94
|
+
declare const EMOTE_IDS: readonly ["laugh", "wow", "think", "gg"];
|
|
95
|
+
type EmoteId = (typeof EMOTE_IDS)[number];
|
|
96
|
+
/**
|
|
97
|
+
* Which character sprite a player is drawn as: `m` = ghutra, `f` = hijab (the `-m`/`-f` art suffix).
|
|
98
|
+
* Both carry the identical emote set. It's a display preference, not identity: set it on room entry
|
|
99
|
+
* or change it any time via `setProfile`, and the server stamps it on that player's outgoing emotes
|
|
100
|
+
* so receivers can pick the right sprite without a roster lookup.
|
|
101
|
+
*/
|
|
102
|
+
declare const CHARACTER_IDS: readonly ["m", "f"];
|
|
103
|
+
type CharacterId = (typeof CHARACTER_IDS)[number];
|
|
86
104
|
/** Unambiguous room-code alphabet — no 0/O, 1/I/L. */
|
|
87
105
|
declare const ROOM_ALPHABET = "ACDEFGHJKMNPQRTUVWXY2346789";
|
|
88
106
|
declare const HelpType: z.ZodEnum<["removeTwoAnswers", "changeQuestion", "extraTime", "doublePoints", "stealPoints", "restPlayer", "tripLevel"]>;
|
|
@@ -100,6 +118,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
100
118
|
color: string;
|
|
101
119
|
}>>;
|
|
102
120
|
game: z.ZodOptional<z.ZodEnum<["seedha", "snag", "trivia", "dama", "ersimha"]>>;
|
|
121
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
103
122
|
pv: z.ZodOptional<z.ZodNumber>;
|
|
104
123
|
idToken: z.ZodOptional<z.ZodString>;
|
|
105
124
|
platform: z.ZodOptional<z.ZodEnum<["web", "ios", "android"]>>;
|
|
@@ -111,6 +130,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
111
130
|
color: string;
|
|
112
131
|
} | undefined;
|
|
113
132
|
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
133
|
+
character?: "m" | "f" | undefined;
|
|
114
134
|
pv?: number | undefined;
|
|
115
135
|
idToken?: string | undefined;
|
|
116
136
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -122,6 +142,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
122
142
|
color: string;
|
|
123
143
|
} | undefined;
|
|
124
144
|
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
145
|
+
character?: "m" | "f" | undefined;
|
|
125
146
|
pv?: number | undefined;
|
|
126
147
|
idToken?: string | undefined;
|
|
127
148
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -147,6 +168,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
147
168
|
emoji: string;
|
|
148
169
|
color: string;
|
|
149
170
|
}>>;
|
|
171
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
150
172
|
}, "strip", z.ZodTypeAny, {
|
|
151
173
|
t: "setProfile";
|
|
152
174
|
name?: string | undefined;
|
|
@@ -154,6 +176,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
154
176
|
emoji: string;
|
|
155
177
|
color: string;
|
|
156
178
|
} | undefined;
|
|
179
|
+
character?: "m" | "f" | undefined;
|
|
157
180
|
}, {
|
|
158
181
|
t: "setProfile";
|
|
159
182
|
name?: string | undefined;
|
|
@@ -161,6 +184,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
161
184
|
emoji: string;
|
|
162
185
|
color: string;
|
|
163
186
|
} | undefined;
|
|
187
|
+
character?: "m" | "f" | undefined;
|
|
164
188
|
}>, z.ZodObject<{
|
|
165
189
|
t: z.ZodLiteral<"joinRoom">;
|
|
166
190
|
code: z.ZodString;
|
|
@@ -175,6 +199,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
175
199
|
emoji: string;
|
|
176
200
|
color: string;
|
|
177
201
|
}>>;
|
|
202
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
178
203
|
pv: z.ZodOptional<z.ZodNumber>;
|
|
179
204
|
idToken: z.ZodOptional<z.ZodString>;
|
|
180
205
|
platform: z.ZodOptional<z.ZodEnum<["web", "ios", "android"]>>;
|
|
@@ -186,6 +211,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
186
211
|
emoji: string;
|
|
187
212
|
color: string;
|
|
188
213
|
} | undefined;
|
|
214
|
+
character?: "m" | "f" | undefined;
|
|
189
215
|
pv?: number | undefined;
|
|
190
216
|
idToken?: string | undefined;
|
|
191
217
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -197,6 +223,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
197
223
|
emoji: string;
|
|
198
224
|
color: string;
|
|
199
225
|
} | undefined;
|
|
226
|
+
character?: "m" | "f" | undefined;
|
|
200
227
|
pv?: number | undefined;
|
|
201
228
|
idToken?: string | undefined;
|
|
202
229
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -214,6 +241,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
214
241
|
emoji: string;
|
|
215
242
|
color: string;
|
|
216
243
|
}>>;
|
|
244
|
+
character: z.ZodOptional<z.ZodEnum<["m", "f"]>>;
|
|
217
245
|
pv: z.ZodOptional<z.ZodNumber>;
|
|
218
246
|
idToken: z.ZodOptional<z.ZodString>;
|
|
219
247
|
platform: z.ZodOptional<z.ZodEnum<["web", "ios", "android"]>>;
|
|
@@ -225,6 +253,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
225
253
|
emoji: string;
|
|
226
254
|
color: string;
|
|
227
255
|
} | undefined;
|
|
256
|
+
character?: "m" | "f" | undefined;
|
|
228
257
|
pv?: number | undefined;
|
|
229
258
|
idToken?: string | undefined;
|
|
230
259
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -236,6 +265,7 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
236
265
|
emoji: string;
|
|
237
266
|
color: string;
|
|
238
267
|
} | undefined;
|
|
268
|
+
character?: "m" | "f" | undefined;
|
|
239
269
|
pv?: number | undefined;
|
|
240
270
|
idToken?: string | undefined;
|
|
241
271
|
platform?: "web" | "ios" | "android" | undefined;
|
|
@@ -301,13 +331,16 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
301
331
|
teamIndex: number;
|
|
302
332
|
}>, z.ZodObject<{
|
|
303
333
|
t: z.ZodLiteral<"setMode">;
|
|
304
|
-
|
|
334
|
+
game: z.ZodOptional<z.ZodEnum<["seedha", "snag", "trivia", "dama", "ersimha"]>>;
|
|
335
|
+
modeId: z.ZodOptional<z.ZodEnum<["solo", "oneDevice", "snag", "multiplayer"]>>;
|
|
305
336
|
}, "strip", z.ZodTypeAny, {
|
|
306
337
|
t: "setMode";
|
|
307
|
-
|
|
338
|
+
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
339
|
+
modeId?: "snag" | "solo" | "oneDevice" | "multiplayer" | undefined;
|
|
308
340
|
}, {
|
|
309
341
|
t: "setMode";
|
|
310
|
-
|
|
342
|
+
game?: "seedha" | "snag" | "trivia" | "dama" | "ersimha" | undefined;
|
|
343
|
+
modeId?: "snag" | "solo" | "oneDevice" | "multiplayer" | undefined;
|
|
311
344
|
}>, z.ZodObject<{
|
|
312
345
|
t: z.ZodLiteral<"hostActivity">;
|
|
313
346
|
activity: z.ZodEnum<["configuring", "idle"]>;
|
|
@@ -404,6 +437,15 @@ declare const ClientMsg: z.ZodDiscriminatedUnion<"t", [z.ZodObject<{
|
|
|
404
437
|
t: "buzz";
|
|
405
438
|
}, {
|
|
406
439
|
t: "buzz";
|
|
440
|
+
}>, z.ZodObject<{
|
|
441
|
+
t: z.ZodLiteral<"sendEmote">;
|
|
442
|
+
emoteId: z.ZodEnum<["laugh", "wow", "think", "gg"]>;
|
|
443
|
+
}, "strip", z.ZodTypeAny, {
|
|
444
|
+
t: "sendEmote";
|
|
445
|
+
emoteId: "laugh" | "wow" | "think" | "gg";
|
|
446
|
+
}, {
|
|
447
|
+
t: "sendEmote";
|
|
448
|
+
emoteId: "laugh" | "wow" | "think" | "gg";
|
|
407
449
|
}>, z.ZodObject<{
|
|
408
450
|
t: z.ZodLiteral<"answer">;
|
|
409
451
|
index: z.ZodNumber;
|
|
@@ -824,6 +866,11 @@ type ServerMsg = {
|
|
|
824
866
|
} | {
|
|
825
867
|
t: 'roomClosed';
|
|
826
868
|
reason: string;
|
|
869
|
+
} | {
|
|
870
|
+
t: 'emote';
|
|
871
|
+
from: string;
|
|
872
|
+
emoteId: EmoteId;
|
|
873
|
+
character: CharacterId;
|
|
827
874
|
} | {
|
|
828
875
|
t: 'lobby';
|
|
829
876
|
code: string;
|
|
@@ -888,4 +935,4 @@ type ServerMsg = {
|
|
|
888
935
|
message: string;
|
|
889
936
|
};
|
|
890
937
|
|
|
891
|
-
export { type AvatarView, type BuzzerGameMode, type CategoryView, ClientMsg, type DamaMoveView, type DamaPieceView, type DamaStateView, type Effect, type ErsimhaStateView, GAMES, GAME_IDS, type GameId, type GameInfo, type GameStateView, type GameStatus, type GameplayFlow, type HelpName, LIMITS, type LobbyPlayer, MIN_SUPPORTED_PV, MODES, MODE_IDS, type ModeId, type ModeInfo, PROTOCOL_VERSION, type QuestionView, ROOM_ALPHABET, type ServerMsg, type SoundName, type TeamSlotView, type TeamView, type YouContext, gameIdForPv, gamesForPv, modesForGame };
|
|
938
|
+
export { type AvatarView, type BuzzerGameMode, CHARACTER_IDS, type CategoryView, type CharacterId, ClientMsg, type DamaMoveView, type DamaPieceView, type DamaStateView, EMOTE_IDS, type Effect, type EmoteId, type ErsimhaStateView, GAMES, GAME_IDS, type GameId, type GameInfo, type GameStateView, type GameStatus, type GameplayFlow, type HelpName, LIMITS, type LobbyPlayer, MIN_SUPPORTED_PV, MODES, MODE_IDS, type ModeId, type ModeInfo, PROTOCOL_VERSION, type QuestionView, ROOM_ALPHABET, type ServerMsg, type SoundName, type TeamSlotView, type TeamView, type YouContext, gameIdForPv, gamesForPv, modesForGame };
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,8 @@ var MODES = [
|
|
|
34
34
|
{ id: "snag", gameId: "snag", label: "Snag", onlineEligible: true }
|
|
35
35
|
];
|
|
36
36
|
var modesForGame = (gameId) => MODES.filter((m) => m.gameId === gameId);
|
|
37
|
+
var EMOTE_IDS = ["laugh", "wow", "think", "gg"];
|
|
38
|
+
var CHARACTER_IDS = ["m", "f"];
|
|
37
39
|
var ROOM_ALPHABET = "ACDEFGHJKMNPQRTUVWXY2346789";
|
|
38
40
|
var UNSAFE_CHARS = /[\p{Cc}<>]/gu;
|
|
39
41
|
var DisplayName = z.string().trim().min(1).max(LIMITS.MAX_NAME_LEN).transform((s) => s.replace(UNSAFE_CHARS, "").trim()).refine((s) => s.length >= 1, "name is empty after sanitizing");
|
|
@@ -55,9 +57,10 @@ var Avatar = z.object({
|
|
|
55
57
|
emoji: z.string().min(1).max(16).transform((s) => s.replace(UNSAFE_CHARS, "")).refine((s) => s.length >= 1, "empty emoji"),
|
|
56
58
|
color: z.string().regex(/^#[0-9a-fA-F]{6}$/, "color must be #rrggbb")
|
|
57
59
|
});
|
|
60
|
+
var Character = z.enum(CHARACTER_IDS);
|
|
58
61
|
var ClientMsg = z.discriminatedUnion("t", [
|
|
59
62
|
// room / lobby
|
|
60
|
-
z.object({ t: z.literal("createRoom"), name: DisplayName.optional(), avatar: Avatar.optional(), game: z.enum(GAME_IDS).optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
63
|
+
z.object({ t: z.literal("createRoom"), name: DisplayName.optional(), avatar: Avatar.optional(), game: z.enum(GAME_IDS).optional(), character: Character.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
61
64
|
// Host sets/changes their display name AFTER createRoom (for anonymous one-tap
|
|
62
65
|
// hosts who started nameless). Host-only; the relay re-broadcasts the lobby.
|
|
63
66
|
// SUPERSEDED by setProfile (kept working for shipped builds).
|
|
@@ -70,9 +73,9 @@ var ClientMsg = z.discriminatedUnion("t", [
|
|
|
70
73
|
// Note: mid-game propagation depends on what the running game's state carries — trivia's
|
|
71
74
|
// view carries names+avatars so it updates live; dama/ersimha views are id-keyed (clients
|
|
72
75
|
// map ids→names from the lobby roster), so a change there lands on the next lobby.
|
|
73
|
-
z.object({ t: z.literal("setProfile"), name: DisplayName.optional(), avatar: Avatar.optional() }),
|
|
74
|
-
z.object({ t: z.literal("joinRoom"), code: RoomCode, name: DisplayName, avatar: Avatar.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
75
|
-
z.object({ t: z.literal("resume"), code: RoomCode, token: z.string().max(120), avatar: Avatar.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
76
|
+
z.object({ t: z.literal("setProfile"), name: DisplayName.optional(), avatar: Avatar.optional(), character: Character.optional() }),
|
|
77
|
+
z.object({ t: z.literal("joinRoom"), code: RoomCode, name: DisplayName, avatar: Avatar.optional(), character: Character.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
78
|
+
z.object({ t: z.literal("resume"), code: RoomCode, token: z.string().max(120), avatar: Avatar.optional(), character: Character.optional(), pv: Pv, idToken: IdToken, platform: Platform }),
|
|
76
79
|
z.object({ t: z.literal("leaveRoom") }),
|
|
77
80
|
z.object({ t: z.literal("approve"), playerId: PlayerId }),
|
|
78
81
|
z.object({ t: z.literal("reject"), playerId: PlayerId }),
|
|
@@ -88,7 +91,14 @@ var ClientMsg = z.discriminatedUnion("t", [
|
|
|
88
91
|
// Host's IN-PROGRESS mode selection in the lobby — a live preview so waiting players see which mode
|
|
89
92
|
// is coming before start. Distinct from startGame.modeId (which commits it); the relay defaults
|
|
90
93
|
// startGame to this when modeId is omitted. Re-broadcasts the lobby.
|
|
91
|
-
|
|
94
|
+
// The room's "what's next" announcement (gs#49) — host-only, LOBBY-only. In a room-first قعدة the
|
|
95
|
+
// room outlives each game, so this is how joiners learn what they're about to play instead of
|
|
96
|
+
// finding out when the board appears. Carries the GAME (tile) and/or the trivia MODE; the server
|
|
97
|
+
// re-broadcasts `lobby` so everyone — including someone who joins later — sees `gameId`/`modeId`.
|
|
98
|
+
// `modeId` alone still works (pre-gs#49 clients); `game` is what lets a host announce a tile with
|
|
99
|
+
// no modes (dama/ersimha), which `modeId` could never express. An incoherent pair (a mode that
|
|
100
|
+
// doesn't belong to the game) is rejected with `bad_mode` rather than silently resolved.
|
|
101
|
+
z.object({ t: z.literal("setMode"), game: z.enum(GAME_IDS).optional(), modeId: z.enum(MODE_IDS).optional() }),
|
|
92
102
|
// Host signals it's busy configuring the game (categories/rounds/mode) so waiting players can show
|
|
93
103
|
// a "host is setting up…" state instead of a frozen-looking lobby. 'idle' when the settings close.
|
|
94
104
|
z.object({ t: z.literal("hostActivity"), activity: z.enum(["configuring", "idle"]) }),
|
|
@@ -131,6 +141,11 @@ var ClientMsg = z.discriminatedUnion("t", [
|
|
|
131
141
|
z.object({ t: z.literal("noHostNobody") }),
|
|
132
142
|
// player actions
|
|
133
143
|
z.object({ t: z.literal("buzz") }),
|
|
144
|
+
// «طقطقة» (D-038): send one of the four closed emotes. Server-enforced 5s per-player throttle on
|
|
145
|
+
// its OWN rate lane — a client-side throttle is trivially bypassed, and this is a family app, so
|
|
146
|
+
// Shape B applies exactly as it does to buzz arrival order. Over-rate emotes are dropped silently.
|
|
147
|
+
// Ephemeral: relayed, never stored. Allowed only while a game whose driver permits emotes is running.
|
|
148
|
+
z.object({ t: z.literal("sendEmote"), emoteId: z.enum(EMOTE_IDS) }),
|
|
134
149
|
z.object({ t: z.literal("answer"), index: z.number().int().min(0).max(3) }),
|
|
135
150
|
// trivia is 4-option (0–3)
|
|
136
151
|
z.object({ t: z.literal("useHelp"), helpType: HelpType }),
|
|
@@ -180,7 +195,9 @@ var ClientMsg = z.discriminatedUnion("t", [
|
|
|
180
195
|
z.object({ t: z.literal("skipWord") })
|
|
181
196
|
]);
|
|
182
197
|
export {
|
|
198
|
+
CHARACTER_IDS,
|
|
183
199
|
ClientMsg,
|
|
200
|
+
EMOTE_IDS,
|
|
184
201
|
GAMES,
|
|
185
202
|
GAME_IDS,
|
|
186
203
|
LIMITS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thegeem/protocol",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"description": "Geem's wire protocol — shared zod schemas + TypeScript types for talking to the Geem game server over Socket.IO. The source of truth all clients implement against.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://geem.tv",
|