@ksaa-nlp/gamehub-react-native-sdk 0.0.0-stage → 1.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/README.md +315 -2
- package/SPEC.md +294 -0
- package/dist/src/answers.d.ts +5 -0
- package/dist/src/answers.d.ts.map +1 -0
- package/dist/src/answers.js +32 -0
- package/dist/src/answers.js.map +1 -0
- package/dist/src/api-client.d.ts +7 -0
- package/dist/src/api-client.d.ts.map +1 -0
- package/dist/src/api-client.js +123 -0
- package/dist/src/api-client.js.map +1 -0
- package/dist/src/config.d.ts +15 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +45 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/constants.d.ts +6 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +6 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/content.d.ts +7 -0
- package/dist/src/content.d.ts.map +1 -0
- package/dist/src/content.js +70 -0
- package/dist/src/content.js.map +1 -0
- package/dist/src/host-events.d.ts +7 -0
- package/dist/src/host-events.d.ts.map +1 -0
- package/dist/src/host-events.js +20 -0
- package/dist/src/host-events.js.map +1 -0
- package/dist/src/identity.d.ts +10 -0
- package/dist/src/identity.d.ts.map +1 -0
- package/dist/src/identity.js +27 -0
- package/dist/src/identity.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +75 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/launch.d.ts +16 -0
- package/dist/src/launch.d.ts.map +1 -0
- package/dist/src/launch.js +115 -0
- package/dist/src/launch.js.map +1 -0
- package/dist/src/loading.d.ts +8 -0
- package/dist/src/loading.d.ts.map +1 -0
- package/dist/src/loading.js +96 -0
- package/dist/src/loading.js.map +1 -0
- package/dist/src/lobby-request.d.ts +4 -0
- package/dist/src/lobby-request.d.ts.map +1 -0
- package/dist/src/lobby-request.js +46 -0
- package/dist/src/lobby-request.js.map +1 -0
- package/dist/src/lobby.d.ts +34 -0
- package/dist/src/lobby.d.ts.map +1 -0
- package/dist/src/lobby.js +311 -0
- package/dist/src/lobby.js.map +1 -0
- package/dist/src/match-context.d.ts +10 -0
- package/dist/src/match-context.d.ts.map +1 -0
- package/dist/src/match-context.js +41 -0
- package/dist/src/match-context.js.map +1 -0
- package/dist/src/multiplayer-client.d.ts +27 -0
- package/dist/src/multiplayer-client.d.ts.map +1 -0
- package/dist/src/multiplayer-client.js +163 -0
- package/dist/src/multiplayer-client.js.map +1 -0
- package/dist/src/multiplayer-react.d.ts +4 -0
- package/dist/src/multiplayer-react.d.ts.map +1 -0
- package/dist/src/multiplayer-react.js +8 -0
- package/dist/src/multiplayer-react.js.map +1 -0
- package/dist/src/multiplayer-storage.d.ts +22 -0
- package/dist/src/multiplayer-storage.d.ts.map +1 -0
- package/dist/src/multiplayer-storage.js +65 -0
- package/dist/src/multiplayer-storage.js.map +1 -0
- package/dist/src/multiplayer-types.d.ts +56 -0
- package/dist/src/multiplayer-types.d.ts.map +1 -0
- package/dist/src/multiplayer-types.js +2 -0
- package/dist/src/multiplayer-types.js.map +1 -0
- package/dist/src/multiplayer.d.ts +5 -0
- package/dist/src/multiplayer.d.ts.map +1 -0
- package/dist/src/multiplayer.js +4 -0
- package/dist/src/multiplayer.js.map +1 -0
- package/dist/src/react.d.ts +12 -0
- package/dist/src/react.d.ts.map +1 -0
- package/dist/src/react.js +24 -0
- package/dist/src/react.js.map +1 -0
- package/dist/src/score.d.ts +9 -0
- package/dist/src/score.d.ts.map +1 -0
- package/dist/src/score.js +168 -0
- package/dist/src/score.js.map +1 -0
- package/dist/src/session-view.d.ts +4 -0
- package/dist/src/session-view.d.ts.map +1 -0
- package/dist/src/session-view.js +276 -0
- package/dist/src/session-view.js.map +1 -0
- package/dist/src/session.d.ts +10 -0
- package/dist/src/session.d.ts.map +1 -0
- package/dist/src/session.js +221 -0
- package/dist/src/session.js.map +1 -0
- package/dist/src/settings.d.ts +4 -0
- package/dist/src/settings.d.ts.map +1 -0
- package/dist/src/settings.js +40 -0
- package/dist/src/settings.js.map +1 -0
- package/dist/src/types.d.ts +137 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +5 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +16 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/vendor/colyseus-schemas/clock.d.ts +15 -0
- package/dist/vendor/colyseus-schemas/clock.js +67 -0
- package/dist/vendor/colyseus-schemas/common.d.ts +35 -0
- package/dist/vendor/colyseus-schemas/common.js +15 -0
- package/dist/vendor/colyseus-schemas/multiplayer.d.ts +8 -0
- package/dist/vendor/colyseus-schemas/multiplayer.js +26 -0
- package/dist/vendor/colyseus-schemas/ugc.d.ts +53 -0
- package/dist/vendor/colyseus-schemas/ugc.js +124 -0
- package/dist/vendor/gamehub-multiplayer-contracts/index.d.ts +200 -0
- package/dist/vendor/gamehub-multiplayer-contracts/index.js +289 -0
- package/dist/vendor/loading.d.ts +6 -0
- package/dist/vendor/loading.d.ts.map +1 -0
- package/dist/vendor/loading.js +2 -0
- package/dist/vendor/loading.js.map +1 -0
- package/dist/vendor/match.d.ts +37 -0
- package/dist/vendor/match.d.ts.map +1 -0
- package/dist/vendor/match.js +2 -0
- package/dist/vendor/match.js.map +1 -0
- package/dist/vendor/multiplayer-client.d.ts +52 -0
- package/dist/vendor/multiplayer-client.d.ts.map +1 -0
- package/dist/vendor/multiplayer-client.js +286 -0
- package/dist/vendor/multiplayer-client.js.map +1 -0
- package/dist/vendor/multiplayer-session.d.ts +82 -0
- package/dist/vendor/multiplayer-session.d.ts.map +1 -0
- package/dist/vendor/multiplayer-session.js +2 -0
- package/dist/vendor/multiplayer-session.js.map +1 -0
- package/dist/vendor/question.d.ts +35 -0
- package/dist/vendor/question.d.ts.map +1 -0
- package/dist/vendor/question.js +20 -0
- package/dist/vendor/question.js.map +1 -0
- package/dist/vendor/session.d.ts +174 -0
- package/dist/vendor/session.d.ts.map +1 -0
- package/dist/vendor/session.js +2 -0
- package/dist/vendor/session.js.map +1 -0
- package/dist/vendor/word.d.ts +147 -0
- package/dist/vendor/word.d.ts.map +1 -0
- package/dist/vendor/word.js +15 -0
- package/dist/vendor/word.js.map +1 -0
- package/package.json +90 -4
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `UgcState` schema for the `ugc` engine — user-uploaded games whose
|
|
3
|
+
* authoritative server logic runs inside an `isolated-vm` sandbox on the
|
|
4
|
+
* colyseus side. The platform-wide `allowUgcServerLogic` setting AND the
|
|
5
|
+
* per-game `serverLogicApproved` flag must both be true for a room to be
|
|
6
|
+
* created on this engine; otherwise the game falls back to relay.
|
|
7
|
+
*
|
|
8
|
+
* The lobby roster + lifecycle phase mirror the relay engine. Game-defined
|
|
9
|
+
* state is exposed as a `MapSchema` of opaque JSON-encoded values keyed by
|
|
10
|
+
* top-level property name. Game authors mutate `ctx.state.<key> = value`
|
|
11
|
+
* inside the sandbox; the host serializes each top-level value to JSON
|
|
12
|
+
* once per dispatch and writes the result into `state.game`.
|
|
13
|
+
*
|
|
14
|
+
* Storing JSON-encoded scalars/objects (instead of registering arbitrary
|
|
15
|
+
* schemas at runtime) is what lets games ship state of any shape without
|
|
16
|
+
* authoring `@colyseus/schema` classes. The trade-off: a top-level key
|
|
17
|
+
* whose value mutates anywhere in its subtree re-sends the entire JSON
|
|
18
|
+
* blob for that key. Game authors who care about granular updates should
|
|
19
|
+
* shard their state across multiple top-level keys.
|
|
20
|
+
*/
|
|
21
|
+
import { Schema, ArraySchema, MapSchema } from '@colyseus/schema';
|
|
22
|
+
import type { Phase } from './common.js';
|
|
23
|
+
export declare class UgcPlayer extends Schema {
|
|
24
|
+
peerId: string;
|
|
25
|
+
userId: string;
|
|
26
|
+
displayName: string;
|
|
27
|
+
avatar: string;
|
|
28
|
+
online: boolean;
|
|
29
|
+
ready: boolean;
|
|
30
|
+
joinedAt: number;
|
|
31
|
+
}
|
|
32
|
+
/** One entry in `UgcState.game`. The value is `JSON.stringify(...)` of any
|
|
33
|
+
* JSON-serializable subtree the guest assigned to that top-level key. */
|
|
34
|
+
export declare class UgcStateValue extends Schema {
|
|
35
|
+
json: string;
|
|
36
|
+
}
|
|
37
|
+
export declare class UgcState extends Schema {
|
|
38
|
+
phase: Phase;
|
|
39
|
+
roomCode: string;
|
|
40
|
+
hostPeerId: string;
|
|
41
|
+
maxPlayers: number;
|
|
42
|
+
createdAt: number;
|
|
43
|
+
startedAtMs: number;
|
|
44
|
+
endedAtMs: number;
|
|
45
|
+
/** Slug of the loaded UGC game. Diagnostic field; matches metadata.gameSlug. */
|
|
46
|
+
gameSlug: string;
|
|
47
|
+
/** sha256 of the currently running server bundle. Lets clients verify the
|
|
48
|
+
* authoritative code matches the version a moderator approved. */
|
|
49
|
+
serverBundleHash: string;
|
|
50
|
+
players: ArraySchema<UgcPlayer>;
|
|
51
|
+
/** Game-defined top-level keys. Each value is a JSON-encoded scalar/object. */
|
|
52
|
+
game: MapSchema<UgcStateValue, string>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `UgcState` schema for the `ugc` engine — user-uploaded games whose
|
|
3
|
+
* authoritative server logic runs inside an `isolated-vm` sandbox on the
|
|
4
|
+
* colyseus side. The platform-wide `allowUgcServerLogic` setting AND the
|
|
5
|
+
* per-game `serverLogicApproved` flag must both be true for a room to be
|
|
6
|
+
* created on this engine; otherwise the game falls back to relay.
|
|
7
|
+
*
|
|
8
|
+
* The lobby roster + lifecycle phase mirror the relay engine. Game-defined
|
|
9
|
+
* state is exposed as a `MapSchema` of opaque JSON-encoded values keyed by
|
|
10
|
+
* top-level property name. Game authors mutate `ctx.state.<key> = value`
|
|
11
|
+
* inside the sandbox; the host serializes each top-level value to JSON
|
|
12
|
+
* once per dispatch and writes the result into `state.game`.
|
|
13
|
+
*
|
|
14
|
+
* Storing JSON-encoded scalars/objects (instead of registering arbitrary
|
|
15
|
+
* schemas at runtime) is what lets games ship state of any shape without
|
|
16
|
+
* authoring `@colyseus/schema` classes. The trade-off: a top-level key
|
|
17
|
+
* whose value mutates anywhere in its subtree re-sends the entire JSON
|
|
18
|
+
* blob for that key. Game authors who care about granular updates should
|
|
19
|
+
* shard their state across multiple top-level keys.
|
|
20
|
+
*/
|
|
21
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
22
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
24
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
25
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
26
|
+
};
|
|
27
|
+
import { Schema, type, ArraySchema, MapSchema } from '@colyseus/schema';
|
|
28
|
+
export class UgcPlayer extends Schema {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.peerId = '';
|
|
32
|
+
this.userId = '';
|
|
33
|
+
this.displayName = '';
|
|
34
|
+
this.avatar = '';
|
|
35
|
+
this.online = true;
|
|
36
|
+
this.ready = false;
|
|
37
|
+
this.joinedAt = 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
__decorate([
|
|
41
|
+
type('string')
|
|
42
|
+
], UgcPlayer.prototype, "peerId", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
type('string')
|
|
45
|
+
], UgcPlayer.prototype, "userId", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
type('string')
|
|
48
|
+
], UgcPlayer.prototype, "displayName", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
type('string')
|
|
51
|
+
], UgcPlayer.prototype, "avatar", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
type('boolean')
|
|
54
|
+
], UgcPlayer.prototype, "online", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
type('boolean')
|
|
57
|
+
], UgcPlayer.prototype, "ready", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
type('number')
|
|
60
|
+
], UgcPlayer.prototype, "joinedAt", void 0);
|
|
61
|
+
/** One entry in `UgcState.game`. The value is `JSON.stringify(...)` of any
|
|
62
|
+
* JSON-serializable subtree the guest assigned to that top-level key. */
|
|
63
|
+
export class UgcStateValue extends Schema {
|
|
64
|
+
constructor() {
|
|
65
|
+
super(...arguments);
|
|
66
|
+
this.json = '';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
__decorate([
|
|
70
|
+
type('string')
|
|
71
|
+
], UgcStateValue.prototype, "json", void 0);
|
|
72
|
+
export class UgcState extends Schema {
|
|
73
|
+
constructor() {
|
|
74
|
+
super(...arguments);
|
|
75
|
+
this.phase = 'lobby';
|
|
76
|
+
this.roomCode = '';
|
|
77
|
+
this.hostPeerId = '';
|
|
78
|
+
this.maxPlayers = 2;
|
|
79
|
+
this.createdAt = 0;
|
|
80
|
+
this.startedAtMs = 0;
|
|
81
|
+
this.endedAtMs = 0;
|
|
82
|
+
/** Slug of the loaded UGC game. Diagnostic field; matches metadata.gameSlug. */
|
|
83
|
+
this.gameSlug = '';
|
|
84
|
+
/** sha256 of the currently running server bundle. Lets clients verify the
|
|
85
|
+
* authoritative code matches the version a moderator approved. */
|
|
86
|
+
this.serverBundleHash = '';
|
|
87
|
+
this.players = new ArraySchema();
|
|
88
|
+
/** Game-defined top-level keys. Each value is a JSON-encoded scalar/object. */
|
|
89
|
+
this.game = new MapSchema();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
__decorate([
|
|
93
|
+
type('string')
|
|
94
|
+
], UgcState.prototype, "phase", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
type('string')
|
|
97
|
+
], UgcState.prototype, "roomCode", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
type('string')
|
|
100
|
+
], UgcState.prototype, "hostPeerId", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
type('number')
|
|
103
|
+
], UgcState.prototype, "maxPlayers", void 0);
|
|
104
|
+
__decorate([
|
|
105
|
+
type('number')
|
|
106
|
+
], UgcState.prototype, "createdAt", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
type('number')
|
|
109
|
+
], UgcState.prototype, "startedAtMs", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
type('number')
|
|
112
|
+
], UgcState.prototype, "endedAtMs", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
type('string')
|
|
115
|
+
], UgcState.prototype, "gameSlug", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
type('string')
|
|
118
|
+
], UgcState.prototype, "serverBundleHash", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
type([UgcPlayer])
|
|
121
|
+
], UgcState.prototype, "players", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
type({ map: UgcStateValue })
|
|
124
|
+
], UgcState.prototype, "game", void 0);
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/** Plain-data v2 wire contract. This entry must remain dependency and side-effect free. */
|
|
2
|
+
export declare const LAUNCH_VERSION: 2;
|
|
3
|
+
export declare const MULTIPLAYER_CAPABILITY: "multiplayer.launch.v2";
|
|
4
|
+
export declare const MULTIPLAYER_LOBBY_CAPABILITY: "multiplayer.lobby.v2";
|
|
5
|
+
export type LobbyMode = 'platform' | 'game';
|
|
6
|
+
export declare const CONTROL_TIMEOUT_MS = 10000;
|
|
7
|
+
export declare const ARRIVAL_WINDOW_MS = 90000;
|
|
8
|
+
export declare const RECOVERY_GRACE_MS = 60000;
|
|
9
|
+
export declare const RESERVATION_LEASE_MS = 15000;
|
|
10
|
+
export type ParticipantKind = 'human' | 'bot';
|
|
11
|
+
export declare const BOT_LEVELS: readonly ["easy", "medium", "hard"];
|
|
12
|
+
export type BotLevel = (typeof BOT_LEVELS)[number];
|
|
13
|
+
/** Bots stored before levels existed play at `medium`. */
|
|
14
|
+
export declare const DEFAULT_BOT_LEVEL: BotLevel;
|
|
15
|
+
export declare const isBotLevel: (value: unknown) => value is BotLevel;
|
|
16
|
+
/** UGC bots are game-owned; quiz bots are played by the built-in engine. Relay has none. */
|
|
17
|
+
export declare const BOT_ENGINES: readonly Engine[];
|
|
18
|
+
export interface PlayerPolicy {
|
|
19
|
+
minPlayers: number;
|
|
20
|
+
maxPlayers: number;
|
|
21
|
+
minHumanPlayers: number;
|
|
22
|
+
maxBots: number;
|
|
23
|
+
maxSpectators: number;
|
|
24
|
+
}
|
|
25
|
+
/** Missing policy identifies an existing two-human v2 package/round. */
|
|
26
|
+
export declare function playerPolicy(binding: {
|
|
27
|
+
playerPolicy?: PlayerPolicy;
|
|
28
|
+
}): PlayerPolicy;
|
|
29
|
+
export declare function parsePlayerPolicy(manifest: Record<string, unknown>, ceiling?: number): PlayerPolicy;
|
|
30
|
+
export type SeatType = 'player' | 'spectator';
|
|
31
|
+
export type SessionPhase = 'waiting' | 'in_round' | 'completed' | 'closed';
|
|
32
|
+
export type RoundPhase = 'preparing' | 'loading' | 'playing' | 'finishing' | 'completed' | 'aborted' | 'interrupted';
|
|
33
|
+
export type Authority = 'server' | 'unverified';
|
|
34
|
+
export type Engine = 'ugc' | 'quiz-template' | 'relay';
|
|
35
|
+
export interface PackageBinding {
|
|
36
|
+
lobbyMode?: LobbyMode;
|
|
37
|
+
/** Manifest lobbyUi:"game" capability required when the admin selects a game-owned lobby. */
|
|
38
|
+
gameLobbySupported?: boolean;
|
|
39
|
+
playerPolicy?: PlayerPolicy;
|
|
40
|
+
gameId: string;
|
|
41
|
+
gameSlug: string;
|
|
42
|
+
ownerId: string;
|
|
43
|
+
versionId: string;
|
|
44
|
+
versionKey: string;
|
|
45
|
+
contentHash: string;
|
|
46
|
+
serverHash: string | null;
|
|
47
|
+
gameUrl: string;
|
|
48
|
+
engine: Engine;
|
|
49
|
+
protocol: 'gamehub.v2';
|
|
50
|
+
scorePolicy?: 'history-only' | 'account';
|
|
51
|
+
profileId?: string | null;
|
|
52
|
+
questions?: 'none' | 'required';
|
|
53
|
+
}
|
|
54
|
+
export interface Seat {
|
|
55
|
+
/** Omitted only on records created before participant support; means human. */
|
|
56
|
+
kind?: ParticipantKind;
|
|
57
|
+
/** Bot seats only; omitted on bots created before levels means `medium`. */
|
|
58
|
+
botLevel?: BotLevel;
|
|
59
|
+
seatId: string;
|
|
60
|
+
displayName: string;
|
|
61
|
+
type: SeatType;
|
|
62
|
+
ready: boolean;
|
|
63
|
+
online: boolean;
|
|
64
|
+
status: 'joined' | 'left' | 'removed';
|
|
65
|
+
}
|
|
66
|
+
export interface LaunchReference {
|
|
67
|
+
recoveryGraceMs?: number;
|
|
68
|
+
version: 2;
|
|
69
|
+
multiplayerSessionId: string;
|
|
70
|
+
roundId: string;
|
|
71
|
+
attemptId: string;
|
|
72
|
+
seatId: string;
|
|
73
|
+
hostInstanceId: string;
|
|
74
|
+
gameUrl: string;
|
|
75
|
+
scoreAuthority: Authority;
|
|
76
|
+
}
|
|
77
|
+
export interface Reservation {
|
|
78
|
+
name: string;
|
|
79
|
+
roomId: string;
|
|
80
|
+
sessionId: string;
|
|
81
|
+
processId?: string;
|
|
82
|
+
publicAddress?: string;
|
|
83
|
+
}
|
|
84
|
+
export declare const ERROR_CODES: readonly ["INVALID_REQUEST", "UNAUTHORIZED", "LOGIN_REQUIRED", "FORBIDDEN", "NOT_FOUND", "GAME_MISMATCH", "GAME_UNAVAILABLE", "NO_QUESTIONS", "PROTOCOL_UNSUPPORTED", "PASSCODE_REQUIRED", "INVALID_PASSCODE", "ROOM_FULL", "SEAT_REMOVED", "SEAT_LEFT", "ROSTER_FROZEN", "NOT_HOST", "STALE_REVISION", "NOT_READY", "STALE_ATTEMPT", "STALE_GENERATION", "ALREADY_CONNECTED", "LAUNCH_PENDING", "LAUNCH_EXPIRED", "ARRIVAL_TIMEOUT", "RECOVERY_EXPIRED", "INTERRUPTED", "ROUND_TERMINAL", "RESULT_CONFLICT", "INVALID_RESULT", "RATE_LIMITED", "UNAVAILABLE", "CANCELLED", "STORAGE_UNAVAILABLE"];
|
|
85
|
+
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
86
|
+
export interface MultiplayerError {
|
|
87
|
+
code: ErrorCode;
|
|
88
|
+
retryable: boolean;
|
|
89
|
+
message: string;
|
|
90
|
+
phase?: RoundPhase | SessionPhase;
|
|
91
|
+
retryAfterMs?: number;
|
|
92
|
+
}
|
|
93
|
+
export declare class MultiplayerFault extends Error {
|
|
94
|
+
readonly code: ErrorCode;
|
|
95
|
+
readonly retryable: boolean;
|
|
96
|
+
readonly status: number;
|
|
97
|
+
constructor(code: ErrorCode, retryable?: boolean, status?: number);
|
|
98
|
+
toJSON(): MultiplayerError;
|
|
99
|
+
}
|
|
100
|
+
export type LaunchOutcome = {
|
|
101
|
+
status: 'reserved';
|
|
102
|
+
launch: LaunchReference;
|
|
103
|
+
reservation: Reservation;
|
|
104
|
+
wsEndpoint: string;
|
|
105
|
+
generation: number;
|
|
106
|
+
expiresAt: number;
|
|
107
|
+
} | {
|
|
108
|
+
status: 'recoverable' | 'terminal';
|
|
109
|
+
error: MultiplayerError;
|
|
110
|
+
};
|
|
111
|
+
export interface SessionView {
|
|
112
|
+
/** Normal rooms use host Start without confirmations; party/league retain readiness. */
|
|
113
|
+
lobbyReadyRequired?: boolean;
|
|
114
|
+
/** Derived public website URLs. Absent/null outside waiting or for invalid site configuration. */
|
|
115
|
+
invitations?: {
|
|
116
|
+
playerUrl: string;
|
|
117
|
+
spectatorUrl: string | null;
|
|
118
|
+
} | null;
|
|
119
|
+
/** Trusted host telemetry identity, excluded from the game lobby projection. */
|
|
120
|
+
gameId?: string;
|
|
121
|
+
/** Frozen presentation choice; old sessions retain the platform lobby. */
|
|
122
|
+
lobbyMode?: LobbyMode;
|
|
123
|
+
lobbyGameUrl?: string;
|
|
124
|
+
playerPolicy?: PlayerPolicy;
|
|
125
|
+
version: 2;
|
|
126
|
+
multiplayerSessionId: string;
|
|
127
|
+
roomCode: string;
|
|
128
|
+
gameSlug: string;
|
|
129
|
+
phase: SessionPhase;
|
|
130
|
+
revision: number;
|
|
131
|
+
hostSeatId: string;
|
|
132
|
+
ownSeatId: string;
|
|
133
|
+
rematchAllowed?: boolean;
|
|
134
|
+
/** Trusted host metadata; never part of the game-owned launch reference. */
|
|
135
|
+
contentOrigin?: string | null;
|
|
136
|
+
contentReady?: boolean;
|
|
137
|
+
seats: Seat[];
|
|
138
|
+
round: null | {
|
|
139
|
+
roundId: string;
|
|
140
|
+
revision?: number;
|
|
141
|
+
phase: RoundPhase;
|
|
142
|
+
reason: string | null;
|
|
143
|
+
projection?: 'pending' | 'applied' | 'rejected';
|
|
144
|
+
projectionReason?: string | null;
|
|
145
|
+
result: CanonicalResult | null;
|
|
146
|
+
launch: LaunchReference;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export interface ResultProposal {
|
|
150
|
+
version: 2;
|
|
151
|
+
scores: Record<string, number>;
|
|
152
|
+
winnerSeatIds: string[];
|
|
153
|
+
reason: 'win' | 'draw' | 'forfeit' | 'abort';
|
|
154
|
+
metadata?: Record<string, string | number | boolean | null>;
|
|
155
|
+
}
|
|
156
|
+
export interface CanonicalResult extends ResultProposal {
|
|
157
|
+
participants?: Array<{
|
|
158
|
+
seatId: string;
|
|
159
|
+
displayName: string;
|
|
160
|
+
kind: ParticipantKind;
|
|
161
|
+
}>;
|
|
162
|
+
roundId: string;
|
|
163
|
+
multiplayerSessionId: string;
|
|
164
|
+
authority: Authority;
|
|
165
|
+
package: PackageBinding;
|
|
166
|
+
startedAt: number;
|
|
167
|
+
endedAt: number;
|
|
168
|
+
}
|
|
169
|
+
/** Public presentation of a party game's result; contains no admission credentials. */
|
|
170
|
+
export interface PartyGameResult {
|
|
171
|
+
multiplayerSessionId: string;
|
|
172
|
+
roundId: string;
|
|
173
|
+
gameSlug: string;
|
|
174
|
+
completed: boolean;
|
|
175
|
+
reason: ResultProposal['reason'] | null;
|
|
176
|
+
memberMetric?: 'correct-answers';
|
|
177
|
+
teams: Array<{
|
|
178
|
+
teamId: string;
|
|
179
|
+
name: string;
|
|
180
|
+
score: number | null;
|
|
181
|
+
winner: boolean;
|
|
182
|
+
members: Array<{
|
|
183
|
+
seatId: string;
|
|
184
|
+
displayName: string;
|
|
185
|
+
score: number | null;
|
|
186
|
+
correctAnswers?: number | null;
|
|
187
|
+
}>;
|
|
188
|
+
}>;
|
|
189
|
+
}
|
|
190
|
+
export declare const terminalRound: (phase: RoundPhase) => boolean;
|
|
191
|
+
export declare function canTransition(from: RoundPhase, to: RoundPhase): boolean;
|
|
192
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
193
|
+
export declare function isBoundedId(value: unknown): value is string;
|
|
194
|
+
export declare function isLaunchReference(value: unknown): value is LaunchReference;
|
|
195
|
+
export declare function isLaunchOutcome(value: unknown): value is LaunchOutcome;
|
|
196
|
+
export declare function parseResultProposal(value: unknown, participantSeatIds: readonly string[]): ResultProposal;
|
|
197
|
+
/** Stable, bounded canonical JSON; callers validate their domain payload first. */
|
|
198
|
+
export declare function canonicalJson(value: unknown): string;
|
|
199
|
+
export declare function normalizeError(error: unknown): MultiplayerError;
|
|
200
|
+
export declare function errorMessage(code: ErrorCode): string;
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/** Plain-data v2 wire contract. This entry must remain dependency and side-effect free. */
|
|
2
|
+
export const LAUNCH_VERSION = 2;
|
|
3
|
+
export const MULTIPLAYER_CAPABILITY = 'multiplayer.launch.v2';
|
|
4
|
+
export const MULTIPLAYER_LOBBY_CAPABILITY = 'multiplayer.lobby.v2';
|
|
5
|
+
export const CONTROL_TIMEOUT_MS = 10000;
|
|
6
|
+
export const ARRIVAL_WINDOW_MS = 90000;
|
|
7
|
+
export const RECOVERY_GRACE_MS = 60000;
|
|
8
|
+
export const RESERVATION_LEASE_MS = 15000;
|
|
9
|
+
export const BOT_LEVELS = ['easy', 'medium', 'hard'];
|
|
10
|
+
/** Bots stored before levels existed play at `medium`. */
|
|
11
|
+
export const DEFAULT_BOT_LEVEL = 'medium';
|
|
12
|
+
export const isBotLevel = (value) => BOT_LEVELS.includes(value);
|
|
13
|
+
/** UGC bots are game-owned; quiz bots are played by the built-in engine. Relay has none. */
|
|
14
|
+
export const BOT_ENGINES = ['ugc', 'quiz-template'];
|
|
15
|
+
/** Missing policy identifies an existing two-human v2 package/round. */
|
|
16
|
+
export function playerPolicy(binding) {
|
|
17
|
+
return (binding.playerPolicy ?? {
|
|
18
|
+
minPlayers: 2,
|
|
19
|
+
maxPlayers: 2,
|
|
20
|
+
minHumanPlayers: 1,
|
|
21
|
+
maxBots: 0,
|
|
22
|
+
maxSpectators: 16,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function parsePlayerPolicy(manifest, ceiling = 256) {
|
|
26
|
+
const minPlayers = manifest.minPlayers;
|
|
27
|
+
const maxPlayers = manifest.maxPlayers;
|
|
28
|
+
const minHumanPlayers = (manifest.minHumanPlayers ?? 1);
|
|
29
|
+
const maxBots = (manifest.maxBots ?? 0);
|
|
30
|
+
if (![minPlayers, maxPlayers, minHumanPlayers, maxBots].every(Number.isSafeInteger) ||
|
|
31
|
+
minPlayers < 1 ||
|
|
32
|
+
maxPlayers < minPlayers ||
|
|
33
|
+
maxPlayers > ceiling ||
|
|
34
|
+
minHumanPlayers < 1 ||
|
|
35
|
+
minHumanPlayers > maxPlayers ||
|
|
36
|
+
maxBots < 0 ||
|
|
37
|
+
maxBots > maxPlayers - minHumanPlayers ||
|
|
38
|
+
typeof manifest.spectators !== 'boolean' ||
|
|
39
|
+
(maxBots > 0 && !BOT_ENGINES.includes(manifest.engine)))
|
|
40
|
+
throw new MultiplayerFault('PROTOCOL_UNSUPPORTED');
|
|
41
|
+
return {
|
|
42
|
+
minPlayers,
|
|
43
|
+
maxPlayers,
|
|
44
|
+
minHumanPlayers,
|
|
45
|
+
maxBots,
|
|
46
|
+
maxSpectators: manifest.spectators ? 16 : 0,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export const ERROR_CODES = [
|
|
50
|
+
'INVALID_REQUEST',
|
|
51
|
+
'UNAUTHORIZED',
|
|
52
|
+
'LOGIN_REQUIRED',
|
|
53
|
+
'FORBIDDEN',
|
|
54
|
+
'NOT_FOUND',
|
|
55
|
+
'GAME_MISMATCH',
|
|
56
|
+
'GAME_UNAVAILABLE',
|
|
57
|
+
'NO_QUESTIONS',
|
|
58
|
+
'PROTOCOL_UNSUPPORTED',
|
|
59
|
+
'PASSCODE_REQUIRED',
|
|
60
|
+
'INVALID_PASSCODE',
|
|
61
|
+
'ROOM_FULL',
|
|
62
|
+
'SEAT_REMOVED',
|
|
63
|
+
'SEAT_LEFT',
|
|
64
|
+
'ROSTER_FROZEN',
|
|
65
|
+
'NOT_HOST',
|
|
66
|
+
'STALE_REVISION',
|
|
67
|
+
'NOT_READY',
|
|
68
|
+
'STALE_ATTEMPT',
|
|
69
|
+
'STALE_GENERATION',
|
|
70
|
+
'ALREADY_CONNECTED',
|
|
71
|
+
'LAUNCH_PENDING',
|
|
72
|
+
'LAUNCH_EXPIRED',
|
|
73
|
+
'ARRIVAL_TIMEOUT',
|
|
74
|
+
'RECOVERY_EXPIRED',
|
|
75
|
+
'INTERRUPTED',
|
|
76
|
+
'ROUND_TERMINAL',
|
|
77
|
+
'RESULT_CONFLICT',
|
|
78
|
+
'INVALID_RESULT',
|
|
79
|
+
'RATE_LIMITED',
|
|
80
|
+
'UNAVAILABLE',
|
|
81
|
+
'CANCELLED',
|
|
82
|
+
'STORAGE_UNAVAILABLE',
|
|
83
|
+
];
|
|
84
|
+
export class MultiplayerFault extends Error {
|
|
85
|
+
constructor(code, retryable = false, status = 409) {
|
|
86
|
+
super(errorMessage(code));
|
|
87
|
+
this.code = code;
|
|
88
|
+
this.retryable = retryable;
|
|
89
|
+
this.status = status;
|
|
90
|
+
}
|
|
91
|
+
toJSON() {
|
|
92
|
+
return {
|
|
93
|
+
code: this.code,
|
|
94
|
+
message: this.message,
|
|
95
|
+
retryable: this.retryable,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export const terminalRound = (phase) => ['completed', 'aborted', 'interrupted'].includes(phase);
|
|
100
|
+
const transitions = {
|
|
101
|
+
preparing: ['loading', 'aborted'],
|
|
102
|
+
loading: ['playing', 'aborted'],
|
|
103
|
+
playing: ['finishing', 'interrupted'],
|
|
104
|
+
finishing: ['completed', 'interrupted'],
|
|
105
|
+
completed: [],
|
|
106
|
+
aborted: [],
|
|
107
|
+
interrupted: [],
|
|
108
|
+
};
|
|
109
|
+
export function canTransition(from, to) {
|
|
110
|
+
return transitions[from]?.includes(to) ?? false;
|
|
111
|
+
}
|
|
112
|
+
export function isRecord(value) {
|
|
113
|
+
return (!!value &&
|
|
114
|
+
typeof value === 'object' &&
|
|
115
|
+
!Array.isArray(value) &&
|
|
116
|
+
(Object.getPrototypeOf(value) === Object.prototype ||
|
|
117
|
+
Object.getPrototypeOf(value) === null));
|
|
118
|
+
}
|
|
119
|
+
export function isBoundedId(value) {
|
|
120
|
+
return typeof value === 'string' && /^[a-zA-Z0-9_-]{1,160}$/.test(value);
|
|
121
|
+
}
|
|
122
|
+
export function isLaunchReference(value) {
|
|
123
|
+
if (!isRecord(value) ||
|
|
124
|
+
value.version !== 2 ||
|
|
125
|
+
(value.recoveryGraceMs !== undefined &&
|
|
126
|
+
(!Number.isSafeInteger(value.recoveryGraceMs) ||
|
|
127
|
+
Number(value.recoveryGraceMs) < 1000 ||
|
|
128
|
+
Number(value.recoveryGraceMs) > 120000)))
|
|
129
|
+
return false;
|
|
130
|
+
return ([
|
|
131
|
+
'multiplayerSessionId',
|
|
132
|
+
'roundId',
|
|
133
|
+
'attemptId',
|
|
134
|
+
'seatId',
|
|
135
|
+
'hostInstanceId',
|
|
136
|
+
].every((k) => isBoundedId(value[k])) &&
|
|
137
|
+
typeof value.gameUrl === 'string' &&
|
|
138
|
+
value.gameUrl.startsWith('/games/') &&
|
|
139
|
+
value.gameUrl.length < 2048 &&
|
|
140
|
+
(value.scoreAuthority === 'server' || value.scoreAuthority === 'unverified'));
|
|
141
|
+
}
|
|
142
|
+
export function isLaunchOutcome(value) {
|
|
143
|
+
if (!isRecord(value))
|
|
144
|
+
return false;
|
|
145
|
+
if (value.status === 'reserved')
|
|
146
|
+
return (isLaunchReference(value.launch) &&
|
|
147
|
+
isRecord(value.reservation) &&
|
|
148
|
+
['name', 'roomId', 'sessionId'].every((k) => isBoundedId(value.reservation[k])) &&
|
|
149
|
+
typeof value.wsEndpoint === 'string' &&
|
|
150
|
+
/^wss?:\/\//.test(value.wsEndpoint) &&
|
|
151
|
+
value.wsEndpoint.length < 2048 &&
|
|
152
|
+
Number.isSafeInteger(value.generation) &&
|
|
153
|
+
Number(value.generation) > 0 &&
|
|
154
|
+
Number.isSafeInteger(value.expiresAt));
|
|
155
|
+
return ((value.status === 'terminal' || value.status === 'recoverable') &&
|
|
156
|
+
isRecord(value.error) &&
|
|
157
|
+
ERROR_CODES.includes(value.error.code) &&
|
|
158
|
+
typeof value.error.retryable === 'boolean' &&
|
|
159
|
+
typeof value.error.message === 'string' &&
|
|
160
|
+
value.error.message.length <= 1000);
|
|
161
|
+
}
|
|
162
|
+
export function parseResultProposal(value, participantSeatIds) {
|
|
163
|
+
if (!isRecord(value) ||
|
|
164
|
+
value.version !== 2 ||
|
|
165
|
+
!isRecord(value.scores) ||
|
|
166
|
+
!Array.isArray(value.winnerSeatIds) ||
|
|
167
|
+
!['win', 'draw', 'forfeit', 'abort'].includes(String(value.reason)))
|
|
168
|
+
throw new MultiplayerFault('INVALID_RESULT');
|
|
169
|
+
const allowed = new Set(participantSeatIds);
|
|
170
|
+
if (allowed.size !== participantSeatIds.length || !allowed.size)
|
|
171
|
+
throw new MultiplayerFault('INVALID_RESULT');
|
|
172
|
+
const scores = {};
|
|
173
|
+
for (const [seat, score] of Object.entries(value.scores)) {
|
|
174
|
+
if (!allowed.has(seat) ||
|
|
175
|
+
typeof score !== 'number' ||
|
|
176
|
+
!Number.isFinite(score) ||
|
|
177
|
+
Math.abs(score) > 1000000000)
|
|
178
|
+
throw new MultiplayerFault('INVALID_RESULT');
|
|
179
|
+
scores[seat] = score;
|
|
180
|
+
}
|
|
181
|
+
if (Object.keys(scores).length !== allowed.size ||
|
|
182
|
+
new Set(value.winnerSeatIds).size !== value.winnerSeatIds.length ||
|
|
183
|
+
value.winnerSeatIds.some((id) => typeof id !== 'string' || !allowed.has(id)) ||
|
|
184
|
+
(value.reason === 'draw' && value.winnerSeatIds.length !== 0) ||
|
|
185
|
+
(value.reason === 'win' && value.winnerSeatIds.length === 0))
|
|
186
|
+
throw new MultiplayerFault('INVALID_RESULT');
|
|
187
|
+
let metadata;
|
|
188
|
+
if (value.metadata !== undefined) {
|
|
189
|
+
if (!isRecord(value.metadata) ||
|
|
190
|
+
JSON.stringify(value.metadata).length > 4096 ||
|
|
191
|
+
Object.keys(value.metadata).length > 32 ||
|
|
192
|
+
Object.values(value.metadata).some((v) => (v !== null && !['string', 'number', 'boolean'].includes(typeof v)) ||
|
|
193
|
+
(typeof v === 'number' && !Number.isFinite(v))))
|
|
194
|
+
throw new MultiplayerFault('INVALID_RESULT');
|
|
195
|
+
metadata = value.metadata;
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
version: 2,
|
|
199
|
+
scores,
|
|
200
|
+
winnerSeatIds: [...value.winnerSeatIds].sort(),
|
|
201
|
+
reason: value.reason,
|
|
202
|
+
...(metadata ? { metadata } : {}),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/** Stable, bounded canonical JSON; callers validate their domain payload first. */
|
|
206
|
+
export function canonicalJson(value) {
|
|
207
|
+
if (Array.isArray(value))
|
|
208
|
+
return '[' + value.map(canonicalJson).join(',') + ']';
|
|
209
|
+
if (isRecord(value))
|
|
210
|
+
return ('{' +
|
|
211
|
+
Object.keys(value)
|
|
212
|
+
.sort()
|
|
213
|
+
.map((k) => JSON.stringify(k) + ':' + canonicalJson(value[k]))
|
|
214
|
+
.join(',') +
|
|
215
|
+
'}');
|
|
216
|
+
const encoded = JSON.stringify(value);
|
|
217
|
+
if (encoded === undefined)
|
|
218
|
+
throw new MultiplayerFault('INVALID_REQUEST');
|
|
219
|
+
return encoded;
|
|
220
|
+
}
|
|
221
|
+
export function normalizeError(error) {
|
|
222
|
+
if (error instanceof MultiplayerFault)
|
|
223
|
+
return error.toJSON();
|
|
224
|
+
const numeric = {
|
|
225
|
+
4210: 'ROUND_TERMINAL',
|
|
226
|
+
4211: 'SEAT_REMOVED',
|
|
227
|
+
4212: 'STALE_GENERATION',
|
|
228
|
+
4213: 'ALREADY_CONNECTED',
|
|
229
|
+
4214: 'RECOVERY_EXPIRED',
|
|
230
|
+
4215: 'ARRIVAL_TIMEOUT',
|
|
231
|
+
4216: 'INTERRUPTED',
|
|
232
|
+
4217: 'GAME_UNAVAILABLE',
|
|
233
|
+
4218: 'INVALID_RESULT',
|
|
234
|
+
4219: 'NOT_READY',
|
|
235
|
+
4220: 'LOGIN_REQUIRED',
|
|
236
|
+
4221: 'UNAVAILABLE',
|
|
237
|
+
522: 'LAUNCH_EXPIRED',
|
|
238
|
+
};
|
|
239
|
+
const raw = isRecord(error)
|
|
240
|
+
? error
|
|
241
|
+
: error instanceof Error
|
|
242
|
+
? {
|
|
243
|
+
code: error.code,
|
|
244
|
+
message: error.message,
|
|
245
|
+
}
|
|
246
|
+
: {};
|
|
247
|
+
const code = typeof raw.code === 'number'
|
|
248
|
+
? numeric[raw.code]
|
|
249
|
+
: ERROR_CODES.includes(raw.code)
|
|
250
|
+
? raw.code
|
|
251
|
+
: undefined;
|
|
252
|
+
return {
|
|
253
|
+
code: code ?? 'UNAVAILABLE',
|
|
254
|
+
message: code
|
|
255
|
+
? errorMessage(code)
|
|
256
|
+
: 'Connection unavailable. Check your network and retry.',
|
|
257
|
+
retryable: !code ||
|
|
258
|
+
['LAUNCH_EXPIRED', 'UNAVAILABLE', 'LAUNCH_PENDING'].includes(code),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
export function errorMessage(code) {
|
|
262
|
+
const messages = {
|
|
263
|
+
UNAUTHORIZED: 'Sign in, or rejoin with this host’s original guest session.',
|
|
264
|
+
LOGIN_REQUIRED: 'Sign in to play or spectate this game.',
|
|
265
|
+
GAME_MISMATCH: 'This invitation belongs to a different game. Open its invitation link.',
|
|
266
|
+
GAME_UNAVAILABLE: 'This game or its approved package is unavailable. Return to the lobby.',
|
|
267
|
+
NO_QUESTIONS: 'The selected profile has no published questions. Add questions or choose another profile.',
|
|
268
|
+
PROTOCOL_UNSUPPORTED: 'This game and host do not support the same multiplayer version.',
|
|
269
|
+
PASSCODE_REQUIRED: 'Enter the room passcode to join, including as a spectator.',
|
|
270
|
+
INVALID_PASSCODE: 'The passcode is incorrect. Check it and retry.',
|
|
271
|
+
ROOM_FULL: 'There are no free seats of this type.',
|
|
272
|
+
NOT_HOST: 'Only the current lobby host can start or rematch.',
|
|
273
|
+
NOT_READY: 'Meet the required player counts and keep human players connected. Confirm readiness only when this lobby requires it.',
|
|
274
|
+
STALE_REVISION: 'The lobby changed. Refresh its status and retry.',
|
|
275
|
+
ROSTER_FROZEN: 'This round has already selected its players. Join as a spectator or wait for a rematch.',
|
|
276
|
+
LAUNCH_PENDING: 'Your launch is being prepared. Retry shortly.',
|
|
277
|
+
LAUNCH_EXPIRED: 'The reservation expired. Request a fresh launch.',
|
|
278
|
+
ALREADY_CONNECTED: 'This seat is already connected in another tab. Return to that tab.',
|
|
279
|
+
ARRIVAL_TIMEOUT: 'A required player did not arrive in time. Return to the lobby and rematch.',
|
|
280
|
+
RECOVERY_EXPIRED: 'The reconnect window ended. Return to the lobby for a new round.',
|
|
281
|
+
SEAT_REMOVED: 'This seat has left or was removed and cannot reconnect.',
|
|
282
|
+
SEAT_LEFT: 'Your lobby membership ended. Rejoin the room if it is still available.',
|
|
283
|
+
INTERRUPTED: 'The round was interrupted before its result was saved. Return to the lobby.',
|
|
284
|
+
ROUND_TERMINAL: 'This round has ended. Return to the lobby.',
|
|
285
|
+
RATE_LIMITED: 'Too many requests. Wait a moment and retry.',
|
|
286
|
+
UNAVAILABLE: 'The service is temporarily unavailable. Retry or leave the session.',
|
|
287
|
+
};
|
|
288
|
+
return messages[code] ?? code;
|
|
289
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LaunchReference } from '#multiplayer-contracts';
|
|
2
|
+
/** Presentation only: null reveals the game when no other channel is busy. */
|
|
3
|
+
export type GameLoadingState = 'loading' | 'waiting-for-players' | 'reconnecting' | 'failed' | null;
|
|
4
|
+
/** The adapter supplies this identity for its independent connection channel. */
|
|
5
|
+
export type GameLoadingLaunch = Pick<LaunchReference, 'multiplayerSessionId' | 'roundId' | 'attemptId' | 'seatId' | 'hostInstanceId'>;
|
|
6
|
+
//# sourceMappingURL=loading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading.d.ts","sourceRoot":"","sources":["../../vendor/loading.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,8EAA8E;AAC9E,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,qBAAqB,GACrB,cAAc,GACd,QAAQ,GACR,IAAI,CAAC;AAET,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,eAAe,EACf,sBAAsB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,gBAAgB,CAC/E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading.js","sourceRoot":"","sources":["../../vendor/loading.ts"],"names":[],"mappings":""}
|