@indiegems/gem-web-sdk 5.9.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/bin/gem-sdk-stamp.mjs +95 -0
- package/dist/game.d.ts +2601 -0
- package/dist/gem-web-sdk.bridge.js +1 -0
- package/dist/gem-web-sdk.capture.js +1 -0
- package/dist/gem-web-sdk.esm.js +3 -0
- package/dist/gem-web-sdk.game.js +3 -0
- package/dist/gem-web-sdk.min.js +2 -0
- package/dist/gem-web-sdk.sdk.js +3 -0
- package/dist/gem-web-sdk.server-api.js +2 -0
- package/dist/gem-web-sdk.server.js +3 -0
- package/dist/index.d.ts +1981 -0
- package/dist/sdk.d.ts +3841 -0
- package/dist/server-api.d.ts +1078 -0
- package/dist/server.d.ts +1438 -0
- package/package.json +43 -0
- package/schema/bridge.v1.json +2624 -0
package/dist/game.d.ts
ADDED
|
@@ -0,0 +1,2601 @@
|
|
|
1
|
+
type PortMessageHandler = {
|
|
2
|
+
handle(event: {
|
|
3
|
+
data: unknown;
|
|
4
|
+
ports?: ReadonlyArray<MessagePort>;
|
|
5
|
+
}): void;
|
|
6
|
+
}["handle"];
|
|
7
|
+
interface PortLike {
|
|
8
|
+
postMessage(data: unknown, transfer?: unknown[]): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
onmessage: PortMessageHandler | null;
|
|
11
|
+
start?(): void;
|
|
12
|
+
}
|
|
13
|
+
interface HandshakeEvent {
|
|
14
|
+
readonly data: unknown;
|
|
15
|
+
readonly origin: string;
|
|
16
|
+
readonly source?: unknown;
|
|
17
|
+
readonly ports?: readonly PortLike[];
|
|
18
|
+
}
|
|
19
|
+
interface Clock {
|
|
20
|
+
now(): number;
|
|
21
|
+
setTimeout(fn: () => void, ms: number): unknown;
|
|
22
|
+
clearTimeout(handle: unknown): void;
|
|
23
|
+
}
|
|
24
|
+
type AuthFailure = "chain_exhausted" | "unavailable" | "timeout" | "internal";
|
|
25
|
+
type AuthState = "ready" | "pending" | "degraded" | "lost";
|
|
26
|
+
declare class AuthError extends Error {
|
|
27
|
+
readonly reason: AuthFailure;
|
|
28
|
+
constructor(reason: AuthFailure, message: string);
|
|
29
|
+
static isAuthError(error: unknown): error is AuthError;
|
|
30
|
+
}
|
|
31
|
+
declare class TransportRefusal extends Error {
|
|
32
|
+
readonly retryable: false;
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
static isRefusal(error: unknown): error is TransportRefusal;
|
|
35
|
+
}
|
|
36
|
+
declare const CONDITIONAL_HEADERS: readonly [
|
|
37
|
+
"if-match",
|
|
38
|
+
"if-none-match"
|
|
39
|
+
];
|
|
40
|
+
type ConditionalRequestHeaders = Partial<Record<(typeof CONDITIONAL_HEADERS)[number], string>>;
|
|
41
|
+
interface TransportRequest {
|
|
42
|
+
readonly method: "GET" | "PUT" | "POST" | "PATCH" | "DELETE";
|
|
43
|
+
readonly path: string;
|
|
44
|
+
readonly body?: unknown;
|
|
45
|
+
readonly headers?: ConditionalRequestHeaders;
|
|
46
|
+
readonly signal?: AbortSignal;
|
|
47
|
+
readonly keepalive?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface TransportResponse {
|
|
50
|
+
readonly status: number;
|
|
51
|
+
readonly body: unknown;
|
|
52
|
+
readonly etag?: string;
|
|
53
|
+
readonly retryAfterSeconds?: number;
|
|
54
|
+
}
|
|
55
|
+
interface Transport {
|
|
56
|
+
request(request: TransportRequest): Promise<TransportResponse>;
|
|
57
|
+
}
|
|
58
|
+
type GemErrorReason = "invalid" | "forbidden" | "not_found" | "conflict" | "precondition_failed" | "not_modified" | "insufficient_funds" | "too_large" | "rate_limited" | "unavailable";
|
|
59
|
+
declare class GemApiError extends Error {
|
|
60
|
+
readonly reason: GemErrorReason;
|
|
61
|
+
readonly status: number;
|
|
62
|
+
readonly detail: string;
|
|
63
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
64
|
+
readonly code?: string | undefined;
|
|
65
|
+
constructor(reason: GemErrorReason, status: number, detail: string, retryAfterSeconds?: number | undefined, code?: string | undefined);
|
|
66
|
+
get retryable(): boolean;
|
|
67
|
+
}
|
|
68
|
+
interface ClientOptions {
|
|
69
|
+
readonly transport: Transport;
|
|
70
|
+
readonly clock: Clock;
|
|
71
|
+
readonly maxRetries?: number;
|
|
72
|
+
}
|
|
73
|
+
interface RequestOptions {
|
|
74
|
+
readonly keepalive?: boolean;
|
|
75
|
+
readonly ifMatch?: string;
|
|
76
|
+
readonly replaySafe?: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface VersionedGetOptions {
|
|
79
|
+
readonly signal?: AbortSignal;
|
|
80
|
+
readonly ifNoneMatch?: string;
|
|
81
|
+
}
|
|
82
|
+
type VersionedResponse<T> = {
|
|
83
|
+
readonly modified: true;
|
|
84
|
+
readonly body: T;
|
|
85
|
+
readonly etag?: string;
|
|
86
|
+
} | {
|
|
87
|
+
readonly modified: false;
|
|
88
|
+
readonly etag?: string;
|
|
89
|
+
};
|
|
90
|
+
declare class GemClient {
|
|
91
|
+
private readonly options;
|
|
92
|
+
constructor(options: ClientOptions);
|
|
93
|
+
get<T>(path: string, signal?: AbortSignal): Promise<T>;
|
|
94
|
+
getWithEtag<T>(path: string, options?: VersionedGetOptions): Promise<VersionedResponse<T>>;
|
|
95
|
+
put<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
96
|
+
post<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
97
|
+
patch<T>(path: string, body: unknown, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
98
|
+
delete<T>(path: string, signal?: AbortSignal, options?: RequestOptions): Promise<T>;
|
|
99
|
+
private send;
|
|
100
|
+
private sendRaw;
|
|
101
|
+
private backoff;
|
|
102
|
+
}
|
|
103
|
+
interface GameApi {
|
|
104
|
+
readonly client: GemClient;
|
|
105
|
+
gameId(): string;
|
|
106
|
+
}
|
|
107
|
+
type Affix = {
|
|
108
|
+
"group"?: string | null;
|
|
109
|
+
"is_active"?: boolean;
|
|
110
|
+
"properties": Record<string, unknown>;
|
|
111
|
+
"slug": string;
|
|
112
|
+
"tier"?: string | null;
|
|
113
|
+
"weight": number;
|
|
114
|
+
};
|
|
115
|
+
type AffixPoolRef = {
|
|
116
|
+
"by_id": string;
|
|
117
|
+
} | {
|
|
118
|
+
"inline": Affix[];
|
|
119
|
+
};
|
|
120
|
+
type AffixSelection = {
|
|
121
|
+
"allow_duplicates"?: boolean;
|
|
122
|
+
"count": CountSpec;
|
|
123
|
+
"pity"?: null | PityRule;
|
|
124
|
+
"pool": AffixPoolRef;
|
|
125
|
+
"respect_groups"?: boolean;
|
|
126
|
+
};
|
|
127
|
+
type BucketColumn = "bucket_1" | "bucket_2";
|
|
128
|
+
type BucketConfig = {
|
|
129
|
+
"grant_sources"?: OrderSource[];
|
|
130
|
+
"name": string;
|
|
131
|
+
"priority": number;
|
|
132
|
+
"reset_amount"?: number | null;
|
|
133
|
+
"reset_cap"?: number | null;
|
|
134
|
+
"reset_interval": BucketResetInterval;
|
|
135
|
+
};
|
|
136
|
+
type BucketResetInterval = "never" | "daily" | "weekly" | "monthly";
|
|
137
|
+
type CountSpec = {
|
|
138
|
+
"exact": number;
|
|
139
|
+
} | {
|
|
140
|
+
"range": {
|
|
141
|
+
"max": number;
|
|
142
|
+
"min": number;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
type EntityType = "player" | "character";
|
|
146
|
+
type EntriesPerEntity = "all" | "best";
|
|
147
|
+
type EventSource = "client" | "server";
|
|
148
|
+
type ExclusionCondition = {
|
|
149
|
+
"item_definition_id": string;
|
|
150
|
+
"min_quantity"?: number;
|
|
151
|
+
"type": "owns_item";
|
|
152
|
+
} | {
|
|
153
|
+
"progression_definition_id": string;
|
|
154
|
+
"type": "progression_complete";
|
|
155
|
+
} | {
|
|
156
|
+
"currency_id": string;
|
|
157
|
+
"min_amount": number;
|
|
158
|
+
"type": "has_currency";
|
|
159
|
+
} | {
|
|
160
|
+
"min_level": number;
|
|
161
|
+
"progression_definition_id": string;
|
|
162
|
+
"type": "progression_level";
|
|
163
|
+
};
|
|
164
|
+
type GameConfigSnapshot = {
|
|
165
|
+
"affix_pools"?: SnapshotAffixPool[];
|
|
166
|
+
"analytics_events"?: SnapshotAnalyticsEvent[];
|
|
167
|
+
"analytics_funnels"?: SnapshotAnalyticsFunnel[];
|
|
168
|
+
"async_opponent_types"?: SnapshotAsyncOpponentType[];
|
|
169
|
+
"catalogs": SnapshotCatalog[];
|
|
170
|
+
"currencies": SnapshotCurrency[];
|
|
171
|
+
"game_room_templates": SnapshotGameRoomTemplate[];
|
|
172
|
+
"hash": string;
|
|
173
|
+
"items": SnapshotItem[];
|
|
174
|
+
"kv": Record<string, unknown>;
|
|
175
|
+
"leaderboards"?: SnapshotLeaderboard[];
|
|
176
|
+
"loot_tables": SnapshotLootTable[];
|
|
177
|
+
"progressions": SnapshotProgression[];
|
|
178
|
+
"run_types"?: SnapshotRunType[];
|
|
179
|
+
"version": number;
|
|
180
|
+
};
|
|
181
|
+
type ItemGeneration = {
|
|
182
|
+
"affix_selections"?: AffixSelection[];
|
|
183
|
+
"property_rolls"?: Record<string, unknown>;
|
|
184
|
+
};
|
|
185
|
+
type LevelDefinition = {
|
|
186
|
+
"auto_claim"?: boolean;
|
|
187
|
+
"level": number;
|
|
188
|
+
"rewards"?: RecipeOperation[];
|
|
189
|
+
"threshold": number;
|
|
190
|
+
};
|
|
191
|
+
type OrderBySpec = {
|
|
192
|
+
"column": RunValueColumn;
|
|
193
|
+
"direction": SortDirection;
|
|
194
|
+
};
|
|
195
|
+
type OrderSource = "real_money_purchase" | "real_money_refund" | "full_game_purchase" | "full_game_refund" | "platform_purchase" | "reward" | "admin" | "system" | "promo" | "game_consume" | "play" | "recipe" | "transfer" | "platform_funded_game_inventory_purchase";
|
|
196
|
+
type OverflowBehavior = "fail" | "clamp" | "allow";
|
|
197
|
+
type PityEffect = "guarantee_tier" | {
|
|
198
|
+
"weight_boost": {
|
|
199
|
+
"per_miss_bps": number;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
type PityRule = {
|
|
203
|
+
"counter_id": string;
|
|
204
|
+
"effect": PityEffect;
|
|
205
|
+
"reset_on_hit"?: boolean;
|
|
206
|
+
"target_tier": string;
|
|
207
|
+
"threshold": number;
|
|
208
|
+
};
|
|
209
|
+
type PlatformDisplay = "none" | "challenge";
|
|
210
|
+
type PlatformGrantMapping = {
|
|
211
|
+
"amount"?: number | null;
|
|
212
|
+
"max_per_window"?: number | null;
|
|
213
|
+
"mode": PlatformGrantMode;
|
|
214
|
+
"target": PlatformGrantTarget;
|
|
215
|
+
};
|
|
216
|
+
type PlatformGrantMode = "on_add" | "on_complete";
|
|
217
|
+
type PlatformGrantTarget = {
|
|
218
|
+
"platform_currency_id"?: string | null;
|
|
219
|
+
"platform_currency_slug"?: string | null;
|
|
220
|
+
};
|
|
221
|
+
type PlatformPrice = {
|
|
222
|
+
"platform_currency_id": string;
|
|
223
|
+
"price": number;
|
|
224
|
+
};
|
|
225
|
+
type PrerequisiteType = "owns_item" | "progression_complete" | "min_progression_value" | "progression_level";
|
|
226
|
+
type ProgressionConfig = {
|
|
227
|
+
"client_writable"?: boolean;
|
|
228
|
+
"completion_threshold"?: number | null;
|
|
229
|
+
"label"?: string | null;
|
|
230
|
+
"max_completions"?: number | null;
|
|
231
|
+
"platform_display"?: PlatformDisplay;
|
|
232
|
+
"platform_grants"?: PlatformGrantMapping[];
|
|
233
|
+
"reset_schedule"?: null | ResetSchedule;
|
|
234
|
+
"rewards_on_complete"?: RecipeOperation[];
|
|
235
|
+
"tracks"?: TrackDefinition[];
|
|
236
|
+
};
|
|
237
|
+
type RecipeOperation = {
|
|
238
|
+
"amount": number;
|
|
239
|
+
"currency_id": string;
|
|
240
|
+
"overflow"?: OverflowBehavior;
|
|
241
|
+
"reason"?: string | null;
|
|
242
|
+
"type": "currency_grant";
|
|
243
|
+
} | {
|
|
244
|
+
"amount": number;
|
|
245
|
+
"currency_id": string;
|
|
246
|
+
"overflow"?: OverflowBehavior;
|
|
247
|
+
"reason"?: string | null;
|
|
248
|
+
"type": "currency_consume";
|
|
249
|
+
} | {
|
|
250
|
+
"custom_data"?: Record<string, unknown> | null;
|
|
251
|
+
"generation"?: ItemGeneration;
|
|
252
|
+
"instance_id"?: string | null;
|
|
253
|
+
"item_definition_id": string;
|
|
254
|
+
"overflow"?: OverflowBehavior;
|
|
255
|
+
"properties"?: Record<string, unknown> | null;
|
|
256
|
+
"quantity"?: number;
|
|
257
|
+
"reason"?: string | null;
|
|
258
|
+
"type": "item_grant";
|
|
259
|
+
} | {
|
|
260
|
+
"instance_id"?: string | null;
|
|
261
|
+
"item_definition_id": string;
|
|
262
|
+
"overflow"?: OverflowBehavior;
|
|
263
|
+
"quantity"?: number;
|
|
264
|
+
"reason"?: string | null;
|
|
265
|
+
"type": "item_remove";
|
|
266
|
+
} | {
|
|
267
|
+
"amount": number;
|
|
268
|
+
"progression_definition_id": string;
|
|
269
|
+
"reason"?: string | null;
|
|
270
|
+
"type": "progression_add";
|
|
271
|
+
} | {
|
|
272
|
+
"progression_definition_id": string;
|
|
273
|
+
"reason"?: string | null;
|
|
274
|
+
"type": "progression_set";
|
|
275
|
+
"value": number;
|
|
276
|
+
} | {
|
|
277
|
+
"progression_definition_id": string;
|
|
278
|
+
"reason"?: string | null;
|
|
279
|
+
"type": "progression_reset";
|
|
280
|
+
};
|
|
281
|
+
type RecipePrerequisite = {
|
|
282
|
+
"prerequisite_type": PrerequisiteType;
|
|
283
|
+
"reference_id": string;
|
|
284
|
+
"reference_value": number;
|
|
285
|
+
};
|
|
286
|
+
type ResetSchedule = {
|
|
287
|
+
"expr": string;
|
|
288
|
+
"type": "cron";
|
|
289
|
+
} | {
|
|
290
|
+
"event_id": string;
|
|
291
|
+
"type": "event_window";
|
|
292
|
+
} | {
|
|
293
|
+
"type": "daily";
|
|
294
|
+
} | {
|
|
295
|
+
"type": "weekly";
|
|
296
|
+
} | {
|
|
297
|
+
"type": "monthly";
|
|
298
|
+
};
|
|
299
|
+
type RoomArgType$1 = "string" | "int" | "float" | "bool";
|
|
300
|
+
type RoomArgsTemplate = {
|
|
301
|
+
"name": string;
|
|
302
|
+
} & {
|
|
303
|
+
"allowed"?: Record<string, unknown>[] | null;
|
|
304
|
+
"default"?: Record<string, unknown> | null;
|
|
305
|
+
"description"?: string | null;
|
|
306
|
+
"fixed"?: Record<string, unknown> | null;
|
|
307
|
+
"list"?: boolean;
|
|
308
|
+
"max"?: number | null;
|
|
309
|
+
"max_items"?: number | null;
|
|
310
|
+
"max_length"?: number | null;
|
|
311
|
+
"min"?: number | null;
|
|
312
|
+
"min_items"?: number | null;
|
|
313
|
+
"mutable"?: boolean | null;
|
|
314
|
+
"required"?: boolean;
|
|
315
|
+
"type": RoomArgType$1;
|
|
316
|
+
}[];
|
|
317
|
+
type RunValueColumn = "int_value_1" | "int_value_2" | "float_value_1" | "float_value_2";
|
|
318
|
+
type SnapshotAffix = {
|
|
319
|
+
"group"?: string | null;
|
|
320
|
+
"id": string;
|
|
321
|
+
"properties"?: Record<string, unknown> | null;
|
|
322
|
+
"slug": string;
|
|
323
|
+
"sort_order": number;
|
|
324
|
+
"tier"?: string | null;
|
|
325
|
+
"weight": number;
|
|
326
|
+
};
|
|
327
|
+
type SnapshotAffixPool = {
|
|
328
|
+
"affixes": SnapshotAffix[];
|
|
329
|
+
"description"?: string | null;
|
|
330
|
+
"display_name"?: string | null;
|
|
331
|
+
"id": string;
|
|
332
|
+
"slug"?: string | null;
|
|
333
|
+
};
|
|
334
|
+
type SnapshotAnalyticsEvent = {
|
|
335
|
+
"description"?: string | null;
|
|
336
|
+
"dimensions"?: Record<string, unknown>;
|
|
337
|
+
"id": string;
|
|
338
|
+
"measures"?: Record<string, unknown>;
|
|
339
|
+
"sources": EventSource[];
|
|
340
|
+
};
|
|
341
|
+
type SnapshotAnalyticsFunnel = {
|
|
342
|
+
"id": string;
|
|
343
|
+
"steps": string[];
|
|
344
|
+
};
|
|
345
|
+
type SnapshotAsyncOpponentType = {
|
|
346
|
+
"display_name"?: string | null;
|
|
347
|
+
"id": string;
|
|
348
|
+
"max_payload_bytes"?: number | null;
|
|
349
|
+
"max_slots_per_entity": number;
|
|
350
|
+
"player_writable": boolean;
|
|
351
|
+
"slug"?: string | null;
|
|
352
|
+
"ttl_seconds": number;
|
|
353
|
+
"versions": SnapshotAsyncOpponentTypeVersion[];
|
|
354
|
+
};
|
|
355
|
+
type SnapshotAsyncOpponentTypeVersion = {
|
|
356
|
+
"is_active": boolean;
|
|
357
|
+
"properties": Record<string, unknown>;
|
|
358
|
+
"searchable": string[];
|
|
359
|
+
"version": number;
|
|
360
|
+
};
|
|
361
|
+
type SnapshotCatalog = {
|
|
362
|
+
"description"?: string | null;
|
|
363
|
+
"display_name"?: string | null;
|
|
364
|
+
"id": string;
|
|
365
|
+
"recipes": SnapshotRecipe[];
|
|
366
|
+
"slug"?: string | null;
|
|
367
|
+
};
|
|
368
|
+
type SnapshotCurrency = {
|
|
369
|
+
"bucket_config"?: BucketConfig[] | null;
|
|
370
|
+
"display_name"?: string | null;
|
|
371
|
+
"history_tracking": boolean;
|
|
372
|
+
"id": string;
|
|
373
|
+
"max_balance": number;
|
|
374
|
+
"min_balance": number;
|
|
375
|
+
"slug"?: string | null;
|
|
376
|
+
};
|
|
377
|
+
type SnapshotGameRoomTemplate = {
|
|
378
|
+
"allow_host_transfer": boolean;
|
|
379
|
+
"allow_join_in_progress"?: boolean;
|
|
380
|
+
"allow_kick": boolean;
|
|
381
|
+
"allow_party_join": boolean;
|
|
382
|
+
"allow_ready_check": boolean;
|
|
383
|
+
"auto_close_when_empty": boolean;
|
|
384
|
+
"auto_leave_on_client_shutdown"?: boolean;
|
|
385
|
+
"auto_start_host"?: boolean;
|
|
386
|
+
"default_visibility": string;
|
|
387
|
+
"game_room_ttl_seconds": number;
|
|
388
|
+
"game_room_type": string;
|
|
389
|
+
"id": string;
|
|
390
|
+
"idle_timeout_seconds"?: number | null;
|
|
391
|
+
"match_type": string;
|
|
392
|
+
"max_match_duration_seconds"?: number | null;
|
|
393
|
+
"max_players": number;
|
|
394
|
+
"min_players": number;
|
|
395
|
+
"name": string;
|
|
396
|
+
"notify_on_host_transfer": string;
|
|
397
|
+
"notify_on_join": string;
|
|
398
|
+
"notify_on_kick": string;
|
|
399
|
+
"notify_on_leave": string;
|
|
400
|
+
"notify_on_ready": string;
|
|
401
|
+
"offline_member_timeout_seconds"?: number | null;
|
|
402
|
+
"room_args_template"?: null | RoomArgsTemplate;
|
|
403
|
+
"show_in_browser": boolean;
|
|
404
|
+
"slug"?: string | null;
|
|
405
|
+
"transports"?: string[];
|
|
406
|
+
};
|
|
407
|
+
type SnapshotItem = {
|
|
408
|
+
"consumable": boolean;
|
|
409
|
+
"description"?: string | null;
|
|
410
|
+
"display_name"?: string | null;
|
|
411
|
+
"fungible": boolean;
|
|
412
|
+
"icon_url"?: string | null;
|
|
413
|
+
"id": string;
|
|
414
|
+
"item_type": string;
|
|
415
|
+
"metadata"?: unknown;
|
|
416
|
+
"platform_prices"?: PlatformPrice[];
|
|
417
|
+
"properties"?: Record<string, unknown> | null;
|
|
418
|
+
"slug"?: string | null;
|
|
419
|
+
"stack_size"?: number | null;
|
|
420
|
+
"transfer_mode": string;
|
|
421
|
+
"transfer_policy": string;
|
|
422
|
+
};
|
|
423
|
+
type SnapshotLeaderboard = {
|
|
424
|
+
"bucket_by": BucketColumn[];
|
|
425
|
+
"entries_per_entity": EntriesPerEntity;
|
|
426
|
+
"expose_player": boolean;
|
|
427
|
+
"expose_properties"?: boolean;
|
|
428
|
+
"expose_stats": boolean;
|
|
429
|
+
"id": string;
|
|
430
|
+
"max_size": number;
|
|
431
|
+
"order_by": OrderBySpec[];
|
|
432
|
+
"run_type": string;
|
|
433
|
+
"update_frequency_seconds": number;
|
|
434
|
+
};
|
|
435
|
+
type SnapshotLootTable = {
|
|
436
|
+
"allow_duplicate_rolls": boolean;
|
|
437
|
+
"description"?: string | null;
|
|
438
|
+
"display_name"?: string | null;
|
|
439
|
+
"entries": SnapshotLootTableEntry[];
|
|
440
|
+
"event_id"?: string | null;
|
|
441
|
+
"id": string;
|
|
442
|
+
"pity"?: null | PityRule;
|
|
443
|
+
"roll_count": number;
|
|
444
|
+
"slug"?: string | null;
|
|
445
|
+
};
|
|
446
|
+
type SnapshotLootTableEntry = {
|
|
447
|
+
"exclusion_conditions"?: ExclusionCondition[] | null;
|
|
448
|
+
"grants"?: RecipeOperation[] | null;
|
|
449
|
+
"id": string;
|
|
450
|
+
"rarity_tier"?: string | null;
|
|
451
|
+
"replacement_entry_id"?: string | null;
|
|
452
|
+
"sort_order": number;
|
|
453
|
+
"weight": number;
|
|
454
|
+
};
|
|
455
|
+
type SnapshotProgression = {
|
|
456
|
+
"config": ProgressionConfig;
|
|
457
|
+
"description"?: string | null;
|
|
458
|
+
"display_name"?: string | null;
|
|
459
|
+
"icon_url"?: string | null;
|
|
460
|
+
"id": string;
|
|
461
|
+
"progression_type": string;
|
|
462
|
+
"slug"?: string | null;
|
|
463
|
+
"sort_order": number;
|
|
464
|
+
};
|
|
465
|
+
type SnapshotRecipe = {
|
|
466
|
+
"availability_end"?: string | null;
|
|
467
|
+
"availability_start"?: string | null;
|
|
468
|
+
"cooldown_seconds"?: number | null;
|
|
469
|
+
"costs"?: RecipeOperation[] | null;
|
|
470
|
+
"description"?: string | null;
|
|
471
|
+
"display_name"?: string | null;
|
|
472
|
+
"event_id"?: string | null;
|
|
473
|
+
"grants"?: RecipeOperation[] | null;
|
|
474
|
+
"id": string;
|
|
475
|
+
"loot_table_id"?: string | null;
|
|
476
|
+
"max_uses"?: number | null;
|
|
477
|
+
"platform_prices"?: PlatformPrice[];
|
|
478
|
+
"prerequisites"?: RecipePrerequisite[] | null;
|
|
479
|
+
"recipe_type": string;
|
|
480
|
+
"slug"?: string | null;
|
|
481
|
+
"sort_order": number;
|
|
482
|
+
};
|
|
483
|
+
type SnapshotRunType = {
|
|
484
|
+
"bucket_1_allowed_values"?: string[] | null;
|
|
485
|
+
"bucket_1_name"?: string | null;
|
|
486
|
+
"bucket_2_allowed_values"?: string[] | null;
|
|
487
|
+
"bucket_2_name"?: string | null;
|
|
488
|
+
"float_value_1_name"?: string | null;
|
|
489
|
+
"float_value_2_name"?: string | null;
|
|
490
|
+
"id": string;
|
|
491
|
+
"int_value_1_name"?: string | null;
|
|
492
|
+
"int_value_2_name"?: string | null;
|
|
493
|
+
"properties_schema"?: Record<string, unknown>;
|
|
494
|
+
};
|
|
495
|
+
type SortDirection = "asc" | "desc";
|
|
496
|
+
type TrackDefinition = {
|
|
497
|
+
"levels": LevelDefinition[];
|
|
498
|
+
"requires_item_id"?: string | null;
|
|
499
|
+
"track_id": string;
|
|
500
|
+
};
|
|
501
|
+
type CacheParam = string | number | boolean | undefined;
|
|
502
|
+
declare class EntityReadCache {
|
|
503
|
+
private readonly clock;
|
|
504
|
+
private readonly identity?;
|
|
505
|
+
private generation;
|
|
506
|
+
private readonly slots;
|
|
507
|
+
private readonly listeners;
|
|
508
|
+
private boundTo;
|
|
509
|
+
constructor(clock: Clock, identity?: (() => string | null) | undefined);
|
|
510
|
+
read<T>(route: string, params: readonly CacheParam[], fetch: () => Promise<T>, maxAgeMs?: number): Promise<T>;
|
|
511
|
+
invalidate(): void;
|
|
512
|
+
onInvalidate(listener: () => void): () => void;
|
|
513
|
+
private rebind;
|
|
514
|
+
}
|
|
515
|
+
interface Page<T> {
|
|
516
|
+
readonly data: readonly T[];
|
|
517
|
+
readonly nextCursor?: string;
|
|
518
|
+
}
|
|
519
|
+
interface InventoryItem {
|
|
520
|
+
readonly itemDefinitionId: string;
|
|
521
|
+
readonly instanceId: string;
|
|
522
|
+
readonly quantity: number;
|
|
523
|
+
readonly acquiredAt: number;
|
|
524
|
+
readonly properties?: unknown;
|
|
525
|
+
readonly customData?: unknown;
|
|
526
|
+
}
|
|
527
|
+
interface Progression {
|
|
528
|
+
readonly progressionDefinitionId: string;
|
|
529
|
+
readonly currentValue: number;
|
|
530
|
+
readonly completionCount: number;
|
|
531
|
+
readonly isCompleted: boolean;
|
|
532
|
+
}
|
|
533
|
+
interface CurrencyBucket {
|
|
534
|
+
readonly bucket: string;
|
|
535
|
+
readonly balance: number;
|
|
536
|
+
}
|
|
537
|
+
interface CurrencyRow {
|
|
538
|
+
readonly currencyId: string;
|
|
539
|
+
readonly total: number;
|
|
540
|
+
readonly buckets?: readonly CurrencyBucket[];
|
|
541
|
+
}
|
|
542
|
+
interface InventorySnapshot {
|
|
543
|
+
readonly currencies: Page<CurrencyRow>;
|
|
544
|
+
readonly items: Page<InventoryItem>;
|
|
545
|
+
readonly progressions: Page<Progression>;
|
|
546
|
+
readonly etag?: string;
|
|
547
|
+
}
|
|
548
|
+
interface SnapshotPageOptions {
|
|
549
|
+
readonly currencyCursor?: string;
|
|
550
|
+
readonly itemCursor?: string;
|
|
551
|
+
readonly progressionCursor?: string;
|
|
552
|
+
readonly currencyLimit?: number;
|
|
553
|
+
readonly itemLimit?: number;
|
|
554
|
+
readonly progressionLimit?: number;
|
|
555
|
+
readonly includeBuckets?: boolean;
|
|
556
|
+
readonly signal?: AbortSignal;
|
|
557
|
+
}
|
|
558
|
+
interface SnapshotOptions {
|
|
559
|
+
readonly buckets?: boolean;
|
|
560
|
+
}
|
|
561
|
+
declare class InventoryApi {
|
|
562
|
+
private readonly api;
|
|
563
|
+
private readonly entity;
|
|
564
|
+
private readonly cache;
|
|
565
|
+
constructor(api: GameApi, entity: EntityRef, cache: EntityReadCache);
|
|
566
|
+
snapshot(options?: SnapshotOptions): Promise<InventorySnapshot>;
|
|
567
|
+
instances(itemDefinitionId: string, signal?: AbortSignal): Promise<readonly InventoryItem[]>;
|
|
568
|
+
page(options: SnapshotPageOptions): Promise<InventorySnapshot>;
|
|
569
|
+
refresh(): void;
|
|
570
|
+
onChanged(listener: () => void): () => void;
|
|
571
|
+
invalidate(): void;
|
|
572
|
+
private fetch;
|
|
573
|
+
}
|
|
574
|
+
interface CurrencyBalance {
|
|
575
|
+
readonly currencyId: string;
|
|
576
|
+
readonly total: number | null;
|
|
577
|
+
readonly buckets?: readonly CurrencyBucket[];
|
|
578
|
+
}
|
|
579
|
+
interface CurrencyReadOptions {
|
|
580
|
+
readonly buckets?: boolean;
|
|
581
|
+
}
|
|
582
|
+
declare class CurrenciesApi {
|
|
583
|
+
private readonly inventory;
|
|
584
|
+
private readonly resolveCurrencyId?;
|
|
585
|
+
constructor(inventory: InventoryApi, resolveCurrencyId?: ((slugOrId: string) => Promise<string | undefined>) | undefined);
|
|
586
|
+
list(options?: CurrencyReadOptions): Promise<readonly CurrencyBalance[]>;
|
|
587
|
+
get(currencyId: string, options?: CurrencyReadOptions): Promise<CurrencyBalance>;
|
|
588
|
+
}
|
|
589
|
+
type GameOrderSource = "play" | "game_consume";
|
|
590
|
+
interface RecipeAvailability {
|
|
591
|
+
readonly canExecute: boolean;
|
|
592
|
+
readonly reasons: readonly string[];
|
|
593
|
+
readonly usesRemaining?: number;
|
|
594
|
+
readonly cooldownExpiresAt?: string;
|
|
595
|
+
}
|
|
596
|
+
interface RecipeUsage {
|
|
597
|
+
readonly recipeId: string;
|
|
598
|
+
readonly useCount: number;
|
|
599
|
+
readonly isOnCooldown: boolean;
|
|
600
|
+
readonly lastUsedAt?: string;
|
|
601
|
+
readonly cooldownExpiresAt?: string;
|
|
602
|
+
}
|
|
603
|
+
interface RecipeUsageList {
|
|
604
|
+
readonly usages: readonly RecipeUsage[];
|
|
605
|
+
readonly truncated: boolean;
|
|
606
|
+
}
|
|
607
|
+
type RecipeChange = {
|
|
608
|
+
readonly kind: "currency";
|
|
609
|
+
readonly currencyId: string;
|
|
610
|
+
readonly bucket: string;
|
|
611
|
+
readonly delta: number;
|
|
612
|
+
readonly balanceAfter: number;
|
|
613
|
+
} | {
|
|
614
|
+
readonly kind: "item";
|
|
615
|
+
readonly itemDefinitionId: string;
|
|
616
|
+
readonly instanceId: string;
|
|
617
|
+
readonly delta: number;
|
|
618
|
+
readonly quantityAfter: number;
|
|
619
|
+
} | {
|
|
620
|
+
readonly kind: "progression";
|
|
621
|
+
readonly progressionDefinitionId: string;
|
|
622
|
+
readonly delta: number;
|
|
623
|
+
readonly valueAfter: number;
|
|
624
|
+
readonly completed: boolean;
|
|
625
|
+
} | {
|
|
626
|
+
readonly kind: "other";
|
|
627
|
+
readonly type: string;
|
|
628
|
+
};
|
|
629
|
+
interface LootRoll {
|
|
630
|
+
readonly entryId: string;
|
|
631
|
+
readonly rarityTier?: string;
|
|
632
|
+
readonly rollNumber: number;
|
|
633
|
+
readonly wasReplacement: boolean;
|
|
634
|
+
readonly grants: readonly RecipeChange[];
|
|
635
|
+
}
|
|
636
|
+
interface RecipeResult {
|
|
637
|
+
readonly orderId: string;
|
|
638
|
+
readonly status: string;
|
|
639
|
+
readonly etag?: string;
|
|
640
|
+
readonly granted: readonly RecipeChange[];
|
|
641
|
+
readonly consumed: readonly RecipeChange[];
|
|
642
|
+
readonly autoClaimedRewards: readonly RecipeChange[];
|
|
643
|
+
readonly lootResults?: readonly LootRoll[];
|
|
644
|
+
}
|
|
645
|
+
interface ConfiguredPurchasePayment {
|
|
646
|
+
readonly kind: "configured";
|
|
647
|
+
}
|
|
648
|
+
interface PlatformCurrencyPurchasePayment {
|
|
649
|
+
readonly kind: "platform_currency";
|
|
650
|
+
readonly currencySlug: string;
|
|
651
|
+
}
|
|
652
|
+
interface ConfiguredPurchaseRequest {
|
|
653
|
+
readonly kind: "recipe";
|
|
654
|
+
readonly catalogId: string;
|
|
655
|
+
readonly targetId: string;
|
|
656
|
+
readonly quantity?: 1;
|
|
657
|
+
readonly payment: ConfiguredPurchasePayment;
|
|
658
|
+
}
|
|
659
|
+
type PlatformCurrencyPurchaseRequest = {
|
|
660
|
+
readonly kind: "recipe";
|
|
661
|
+
readonly catalogId: string;
|
|
662
|
+
readonly targetId: string;
|
|
663
|
+
readonly quantity?: 1;
|
|
664
|
+
readonly payment: PlatformCurrencyPurchasePayment;
|
|
665
|
+
} | {
|
|
666
|
+
readonly kind: "item";
|
|
667
|
+
readonly targetId: string;
|
|
668
|
+
readonly quantity?: number;
|
|
669
|
+
readonly payment: PlatformCurrencyPurchasePayment;
|
|
670
|
+
};
|
|
671
|
+
type DirectPurchaseRequest = ConfiguredPurchaseRequest | PlatformCurrencyPurchaseRequest;
|
|
672
|
+
interface PurchaseOptions {
|
|
673
|
+
readonly ifMatch?: string;
|
|
674
|
+
readonly signal?: AbortSignal;
|
|
675
|
+
}
|
|
676
|
+
interface ConfiguredPurchaseResult extends RecipeResult {
|
|
677
|
+
readonly payment: "configured";
|
|
678
|
+
}
|
|
679
|
+
interface PlatformCurrencyPurchaseResult {
|
|
680
|
+
readonly payment: "platform_currency";
|
|
681
|
+
readonly orderId: string;
|
|
682
|
+
readonly status: string;
|
|
683
|
+
readonly purchaseId: string;
|
|
684
|
+
readonly sourceOrderId: string;
|
|
685
|
+
readonly price: {
|
|
686
|
+
readonly currencyId: string;
|
|
687
|
+
readonly amount: number;
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
type DirectPurchaseResult = ConfiguredPurchaseResult | PlatformCurrencyPurchaseResult;
|
|
691
|
+
type InventoryOperation = {
|
|
692
|
+
readonly type: "currency_grant";
|
|
693
|
+
readonly currencyId: string;
|
|
694
|
+
readonly amount: number;
|
|
695
|
+
} | {
|
|
696
|
+
readonly type: "currency_consume";
|
|
697
|
+
readonly currencyId: string;
|
|
698
|
+
readonly amount: number;
|
|
699
|
+
} | {
|
|
700
|
+
readonly type: "item_grant";
|
|
701
|
+
readonly itemDefinitionId: string;
|
|
702
|
+
readonly quantity: number;
|
|
703
|
+
} | {
|
|
704
|
+
readonly type: "item_remove";
|
|
705
|
+
readonly itemDefinitionId: string;
|
|
706
|
+
readonly quantity: number;
|
|
707
|
+
};
|
|
708
|
+
interface OrderOptions {
|
|
709
|
+
readonly source?: GameOrderSource;
|
|
710
|
+
readonly ifMatch?: string;
|
|
711
|
+
readonly signal?: AbortSignal;
|
|
712
|
+
}
|
|
713
|
+
interface OrderResult {
|
|
714
|
+
readonly orderId: string;
|
|
715
|
+
readonly status: string;
|
|
716
|
+
readonly etag?: string;
|
|
717
|
+
}
|
|
718
|
+
declare class MutationsApi {
|
|
719
|
+
private readonly api;
|
|
720
|
+
private readonly entity;
|
|
721
|
+
private readonly cache;
|
|
722
|
+
constructor(api: GameApi, entity: EntityRef, cache: EntityReadCache);
|
|
723
|
+
create(operations: readonly InventoryOperation[], options?: OrderOptions): Promise<OrderResult>;
|
|
724
|
+
createMany(orders: ReadonlyArray<readonly InventoryOperation[]>, options?: OrderOptions): Promise<unknown>;
|
|
725
|
+
recipeAvailability(catalogId: string, recipeId: string, signal?: AbortSignal): Promise<RecipeAvailability>;
|
|
726
|
+
recipeUsageAll(): Promise<RecipeUsageList>;
|
|
727
|
+
recipeUsage(recipeId: string): Promise<RecipeUsage | null>;
|
|
728
|
+
purchase(request: ConfiguredPurchaseRequest, options?: PurchaseOptions): Promise<ConfiguredPurchaseResult>;
|
|
729
|
+
purchase(request: PlatformCurrencyPurchaseRequest, options?: PurchaseOptions): Promise<PlatformCurrencyPurchaseResult>;
|
|
730
|
+
executeRecipe(catalogId: string, recipeId: string, options?: OrderOptions): Promise<RecipeResult>;
|
|
731
|
+
addProgression(progressionId: string, amount: number, signal?: AbortSignal): Promise<OrderResult>;
|
|
732
|
+
maxProgression(progressionId: string, value: number, signal?: AbortSignal): Promise<OrderResult>;
|
|
733
|
+
claimProgression(progressionId: string, signal?: AbortSignal): Promise<OrderResult>;
|
|
734
|
+
resetProgression(progressionId: string, signal?: AbortSignal): Promise<OrderResult>;
|
|
735
|
+
private write;
|
|
736
|
+
}
|
|
737
|
+
interface Order {
|
|
738
|
+
readonly orderId: string;
|
|
739
|
+
readonly status: string;
|
|
740
|
+
readonly source: string;
|
|
741
|
+
readonly createdAt: number;
|
|
742
|
+
}
|
|
743
|
+
interface OrderPageOptions {
|
|
744
|
+
readonly limit?: number;
|
|
745
|
+
readonly cursor?: string;
|
|
746
|
+
readonly signal?: AbortSignal;
|
|
747
|
+
}
|
|
748
|
+
declare class OrdersApi {
|
|
749
|
+
private readonly api;
|
|
750
|
+
private readonly entity;
|
|
751
|
+
constructor(api: GameApi, entity: EntityRef);
|
|
752
|
+
list(options?: OrderPageOptions): Promise<Page<Order>>;
|
|
753
|
+
get(orderId: string, signal?: AbortSignal): Promise<Order>;
|
|
754
|
+
}
|
|
755
|
+
declare class ProgressionsApi {
|
|
756
|
+
private readonly api;
|
|
757
|
+
private readonly entity;
|
|
758
|
+
private readonly inventory;
|
|
759
|
+
constructor(api: GameApi, entity: EntityRef, inventory: InventoryApi);
|
|
760
|
+
list(): Promise<readonly Progression[]>;
|
|
761
|
+
get(progressionDefinitionId: string, signal?: AbortSignal): Promise<Progression | null>;
|
|
762
|
+
}
|
|
763
|
+
interface SaveRecord {
|
|
764
|
+
readonly key: string;
|
|
765
|
+
readonly sizeBytes: number;
|
|
766
|
+
readonly etag: string;
|
|
767
|
+
readonly metadata?: Record<string, unknown>;
|
|
768
|
+
readonly createdAt: number;
|
|
769
|
+
readonly updatedAt: number;
|
|
770
|
+
}
|
|
771
|
+
interface SavePage {
|
|
772
|
+
readonly saves: readonly SaveRecord[];
|
|
773
|
+
readonly nextCursor?: string;
|
|
774
|
+
}
|
|
775
|
+
declare class GemSaveError extends Error {
|
|
776
|
+
readonly reason: "upload_failed" | "download_failed" | "save_timeout" | "save_malformed";
|
|
777
|
+
constructor(reason: "upload_failed" | "download_failed" | "save_timeout" | "save_malformed", message: string);
|
|
778
|
+
}
|
|
779
|
+
interface SavesOptions {
|
|
780
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
781
|
+
readonly timeoutMs?: number;
|
|
782
|
+
}
|
|
783
|
+
interface PutSaveOptions {
|
|
784
|
+
readonly metadata?: Record<string, unknown>;
|
|
785
|
+
readonly signal?: AbortSignal;
|
|
786
|
+
readonly timeoutMs?: number;
|
|
787
|
+
}
|
|
788
|
+
interface PutBytesOptions extends PutSaveOptions {
|
|
789
|
+
readonly contentType?: string;
|
|
790
|
+
}
|
|
791
|
+
interface GetSaveOptions {
|
|
792
|
+
readonly signal?: AbortSignal;
|
|
793
|
+
readonly timeoutMs?: number;
|
|
794
|
+
}
|
|
795
|
+
interface DescribeSaveOptions {
|
|
796
|
+
readonly signal?: AbortSignal;
|
|
797
|
+
readonly ifNoneMatch?: string;
|
|
798
|
+
}
|
|
799
|
+
interface ListSavesOptions {
|
|
800
|
+
readonly signal?: AbortSignal;
|
|
801
|
+
readonly limit?: number;
|
|
802
|
+
readonly cursor?: string;
|
|
803
|
+
}
|
|
804
|
+
declare class SavesApi {
|
|
805
|
+
private readonly api;
|
|
806
|
+
private readonly entity;
|
|
807
|
+
private readonly options;
|
|
808
|
+
constructor(api: GameApi, entity: EntityRef, options?: SavesOptions);
|
|
809
|
+
put(key: string, value: unknown, options?: PutSaveOptions): Promise<SaveRecord>;
|
|
810
|
+
putBytes(key: string, bytes: Uint8Array, options?: PutBytesOptions): Promise<SaveRecord>;
|
|
811
|
+
get<T = unknown>(key: string, options?: GetSaveOptions): Promise<T | null>;
|
|
812
|
+
getBytes(key: string, options?: GetSaveOptions): Promise<Uint8Array | null>;
|
|
813
|
+
describe(key: string, options?: DescribeSaveOptions): Promise<SaveRecord | null>;
|
|
814
|
+
list(options?: ListSavesOptions): Promise<SavePage>;
|
|
815
|
+
delete(key: string, signal?: AbortSignal): Promise<void>;
|
|
816
|
+
private budget;
|
|
817
|
+
private timeout;
|
|
818
|
+
private rethrow;
|
|
819
|
+
}
|
|
820
|
+
interface Setting {
|
|
821
|
+
readonly key: string;
|
|
822
|
+
readonly value: string;
|
|
823
|
+
readonly etag?: string;
|
|
824
|
+
readonly updatedAt: number;
|
|
825
|
+
}
|
|
826
|
+
interface GetSettingOptions {
|
|
827
|
+
readonly signal?: AbortSignal;
|
|
828
|
+
readonly ifNoneMatch?: string;
|
|
829
|
+
}
|
|
830
|
+
interface PutSettingOptions {
|
|
831
|
+
readonly signal?: AbortSignal;
|
|
832
|
+
readonly ifMatch?: string;
|
|
833
|
+
}
|
|
834
|
+
declare class SettingsApi {
|
|
835
|
+
private readonly api;
|
|
836
|
+
private readonly entity;
|
|
837
|
+
constructor(api: GameApi, entity: EntityRef);
|
|
838
|
+
list(signal?: AbortSignal): Promise<readonly Setting[]>;
|
|
839
|
+
get(key: string, options?: GetSettingOptions): Promise<Setting | null>;
|
|
840
|
+
put(key: string, value: string, options?: PutSettingOptions): Promise<Setting>;
|
|
841
|
+
delete(key: string, signal?: AbortSignal): Promise<void>;
|
|
842
|
+
}
|
|
843
|
+
interface EntityRef {
|
|
844
|
+
readonly type: "players" | "characters";
|
|
845
|
+
readonly id: string;
|
|
846
|
+
}
|
|
847
|
+
interface EntityScope {
|
|
848
|
+
readonly settings: SettingsApi;
|
|
849
|
+
readonly inventory: InventoryApi;
|
|
850
|
+
readonly currencies: CurrenciesApi;
|
|
851
|
+
readonly mutations: MutationsApi;
|
|
852
|
+
readonly saves: SavesApi;
|
|
853
|
+
readonly orders: OrdersApi;
|
|
854
|
+
readonly progressions: ProgressionsApi;
|
|
855
|
+
}
|
|
856
|
+
interface Character extends EntityScope {
|
|
857
|
+
readonly id: string;
|
|
858
|
+
readonly playerId: string;
|
|
859
|
+
readonly gameId: string;
|
|
860
|
+
readonly channel: string;
|
|
861
|
+
readonly name: string;
|
|
862
|
+
readonly slotIndex: number;
|
|
863
|
+
readonly isActive: boolean;
|
|
864
|
+
readonly createdAt: string;
|
|
865
|
+
readonly updatedAt: string;
|
|
866
|
+
}
|
|
867
|
+
interface SlotInfo {
|
|
868
|
+
readonly totalSlots: number;
|
|
869
|
+
readonly availableSlots: number;
|
|
870
|
+
readonly activeCharacterCount: number;
|
|
871
|
+
readonly defaultMaxSlots: number;
|
|
872
|
+
readonly purchasedExtraSlots: number;
|
|
873
|
+
readonly canPurchaseMore: boolean;
|
|
874
|
+
}
|
|
875
|
+
interface CreateCharacterOptions {
|
|
876
|
+
readonly name: string;
|
|
877
|
+
readonly signal?: AbortSignal;
|
|
878
|
+
}
|
|
879
|
+
declare class CharactersApi {
|
|
880
|
+
private readonly api;
|
|
881
|
+
private readonly saves?;
|
|
882
|
+
private readonly identity?;
|
|
883
|
+
private readonly resolveCurrencyId?;
|
|
884
|
+
private readonly scopes;
|
|
885
|
+
constructor(api: GameApi, saves?: SavesOptions | undefined, identity?: (() => string | null) | undefined, resolveCurrencyId?: ((slugOrId: string) => Promise<string | undefined>) | undefined);
|
|
886
|
+
private readonly scope;
|
|
887
|
+
list(signal?: AbortSignal): Promise<readonly Character[]>;
|
|
888
|
+
get(id: string, signal?: AbortSignal): Promise<Character>;
|
|
889
|
+
create(options: CreateCharacterOptions): Promise<Character>;
|
|
890
|
+
update(id: string, name: string, signal?: AbortSignal): Promise<Character>;
|
|
891
|
+
delete(id: string, signal?: AbortSignal): Promise<void>;
|
|
892
|
+
slots(signal?: AbortSignal): Promise<SlotInfo>;
|
|
893
|
+
}
|
|
894
|
+
declare class PlayerText {
|
|
895
|
+
#private;
|
|
896
|
+
constructor(value: string);
|
|
897
|
+
toString(): string;
|
|
898
|
+
toJSON(): string;
|
|
899
|
+
get [Symbol.toStringTag](): string;
|
|
900
|
+
static unwrap(t: PlayerText): string;
|
|
901
|
+
}
|
|
902
|
+
declare function asPlayerText(value: string): PlayerText;
|
|
903
|
+
declare const text: {
|
|
904
|
+
toPlain(t: PlayerText): string;
|
|
905
|
+
compare(a: PlayerText | string, b: PlayerText | string, locale?: string): number;
|
|
906
|
+
equals(a: PlayerText | string, b: PlayerText | string): boolean;
|
|
907
|
+
};
|
|
908
|
+
type TransferDirection = "incoming" | "outgoing";
|
|
909
|
+
interface Transfer {
|
|
910
|
+
readonly id: string;
|
|
911
|
+
readonly status: string;
|
|
912
|
+
readonly sourceEntityId: string;
|
|
913
|
+
readonly targetEntityId: string;
|
|
914
|
+
readonly message?: PlayerText;
|
|
915
|
+
readonly createdAt: string;
|
|
916
|
+
readonly expiresAt: string;
|
|
917
|
+
readonly resolvedAt?: string;
|
|
918
|
+
}
|
|
919
|
+
interface InitiateTransferOptions {
|
|
920
|
+
readonly to: EntityRef;
|
|
921
|
+
readonly items?: ReadonlyArray<{
|
|
922
|
+
itemDefinitionId: string;
|
|
923
|
+
quantity: number;
|
|
924
|
+
}>;
|
|
925
|
+
readonly currencies?: ReadonlyArray<{
|
|
926
|
+
currencyId: string;
|
|
927
|
+
amount: number;
|
|
928
|
+
}>;
|
|
929
|
+
readonly message?: string;
|
|
930
|
+
readonly signal?: AbortSignal;
|
|
931
|
+
}
|
|
932
|
+
interface ListTransfersOptions {
|
|
933
|
+
readonly direction?: TransferDirection;
|
|
934
|
+
readonly status?: string;
|
|
935
|
+
readonly cursor?: string;
|
|
936
|
+
readonly limit?: number;
|
|
937
|
+
readonly signal?: AbortSignal;
|
|
938
|
+
}
|
|
939
|
+
declare class TransfersApi {
|
|
940
|
+
private readonly api;
|
|
941
|
+
private readonly self;
|
|
942
|
+
private readonly inventory;
|
|
943
|
+
constructor(api: GameApi, self: EntityRef, inventory: InventoryApi);
|
|
944
|
+
initiate(options: InitiateTransferOptions): Promise<Transfer>;
|
|
945
|
+
list(options?: ListTransfersOptions): Promise<{
|
|
946
|
+
readonly transfers: readonly Transfer[];
|
|
947
|
+
readonly nextCursor?: string;
|
|
948
|
+
}>;
|
|
949
|
+
get(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
950
|
+
accept(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
951
|
+
reject(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
952
|
+
cancel(transferId: string, signal?: AbortSignal): Promise<Transfer>;
|
|
953
|
+
private resolve;
|
|
954
|
+
}
|
|
955
|
+
interface GameConfig extends GameConfigSnapshot {
|
|
956
|
+
items: GameConfigSnapshot["items"];
|
|
957
|
+
currencies: GameConfigSnapshot["currencies"];
|
|
958
|
+
catalogs: GameConfigSnapshot["catalogs"];
|
|
959
|
+
loot_tables: GameConfigSnapshot["loot_tables"];
|
|
960
|
+
affix_pools?: GameConfigSnapshot["affix_pools"];
|
|
961
|
+
progressions: GameConfigSnapshot["progressions"];
|
|
962
|
+
game_room_templates: GameConfigSnapshot["game_room_templates"];
|
|
963
|
+
kv: GameConfigSnapshot["kv"];
|
|
964
|
+
run_types?: GameConfigSnapshot["run_types"];
|
|
965
|
+
leaderboards?: GameConfigSnapshot["leaderboards"];
|
|
966
|
+
async_opponent_types?: GameConfigSnapshot["async_opponent_types"];
|
|
967
|
+
analytics_events?: GameConfigSnapshot["analytics_events"];
|
|
968
|
+
analytics_funnels?: GameConfigSnapshot["analytics_funnels"];
|
|
969
|
+
version: GameConfigSnapshot["version"];
|
|
970
|
+
hash: GameConfigSnapshot["hash"];
|
|
971
|
+
item(idOrSlug: string): SnapshotItem | null;
|
|
972
|
+
currency(idOrSlug: string): SnapshotCurrency | null;
|
|
973
|
+
}
|
|
974
|
+
declare class GemConfigError extends Error {
|
|
975
|
+
readonly reason: "config_unreachable" | "config_too_large" | "config_malformed" | "config_timeout" | "config_channel_unknown";
|
|
976
|
+
constructor(reason: "config_unreachable" | "config_too_large" | "config_malformed" | "config_timeout" | "config_channel_unknown", message: string);
|
|
977
|
+
}
|
|
978
|
+
interface GameConfigOptions {
|
|
979
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
980
|
+
readonly timeoutMs?: number;
|
|
981
|
+
}
|
|
982
|
+
interface DropRateEntry {
|
|
983
|
+
readonly entryId: string;
|
|
984
|
+
readonly weight: number;
|
|
985
|
+
readonly dropRate: number;
|
|
986
|
+
readonly rarityTier?: string;
|
|
987
|
+
}
|
|
988
|
+
interface DropRates {
|
|
989
|
+
readonly lootTableId: string;
|
|
990
|
+
readonly name: string;
|
|
991
|
+
readonly rollCount: number;
|
|
992
|
+
readonly allowDuplicateRolls: boolean;
|
|
993
|
+
readonly totalWeight: number;
|
|
994
|
+
readonly entries: readonly DropRateEntry[];
|
|
995
|
+
}
|
|
996
|
+
declare class GameConfigApi {
|
|
997
|
+
private readonly api;
|
|
998
|
+
private readonly channel;
|
|
999
|
+
private readonly options;
|
|
1000
|
+
private loaded;
|
|
1001
|
+
private inFlight;
|
|
1002
|
+
private generation;
|
|
1003
|
+
private readonly dropRatesByConfig;
|
|
1004
|
+
constructor(api: GameApi, channel: () => string, options?: GameConfigOptions);
|
|
1005
|
+
load(): Promise<GameConfig | null>;
|
|
1006
|
+
refresh(): void;
|
|
1007
|
+
dropRates(lootTableId: string, signal?: AbortSignal): Promise<DropRates>;
|
|
1008
|
+
private fetchConfig;
|
|
1009
|
+
}
|
|
1010
|
+
declare const MAX_PERIODS_BACK = 400;
|
|
1011
|
+
type ChallengeWindow = "daily" | "weekly" | "monthly" | (string & {});
|
|
1012
|
+
interface Challenge {
|
|
1013
|
+
readonly id: string;
|
|
1014
|
+
readonly slug?: string;
|
|
1015
|
+
readonly window: ChallengeWindow;
|
|
1016
|
+
readonly periodStartAt: number;
|
|
1017
|
+
readonly periodEndsAt: number;
|
|
1018
|
+
readonly seed: string;
|
|
1019
|
+
}
|
|
1020
|
+
interface ListChallengesOptions {
|
|
1021
|
+
readonly periodsBack?: number;
|
|
1022
|
+
readonly signal?: AbortSignal;
|
|
1023
|
+
}
|
|
1024
|
+
declare class ChallengesApi {
|
|
1025
|
+
#private;
|
|
1026
|
+
constructor(api: GameApi);
|
|
1027
|
+
list(options?: ListChallengesOptions): Promise<Challenge[]>;
|
|
1028
|
+
}
|
|
1029
|
+
interface LeaderboardEntry extends RankedRow {
|
|
1030
|
+
readonly rank: number;
|
|
1031
|
+
readonly occurredAt: number;
|
|
1032
|
+
readonly entityId?: string;
|
|
1033
|
+
readonly entityType?: EntityType;
|
|
1034
|
+
readonly displayName?: string;
|
|
1035
|
+
readonly discriminator?: string;
|
|
1036
|
+
readonly displayTag?: string;
|
|
1037
|
+
readonly stats?: Readonly<Record<string, number>>;
|
|
1038
|
+
readonly properties?: Readonly<Record<string, unknown>>;
|
|
1039
|
+
readonly isViewer?: boolean;
|
|
1040
|
+
}
|
|
1041
|
+
interface Leaderboard {
|
|
1042
|
+
readonly leaderboardType: string;
|
|
1043
|
+
readonly runType: string;
|
|
1044
|
+
readonly bucket1?: string;
|
|
1045
|
+
readonly bucket2?: string;
|
|
1046
|
+
readonly entries: readonly LeaderboardEntry[];
|
|
1047
|
+
readonly generatedAt: number;
|
|
1048
|
+
readonly updateFrequencySeconds?: number;
|
|
1049
|
+
}
|
|
1050
|
+
interface RankedRow {
|
|
1051
|
+
readonly rank: number;
|
|
1052
|
+
readonly occurredAt: number;
|
|
1053
|
+
readonly stats?: Readonly<Record<string, number>>;
|
|
1054
|
+
readonly properties?: Readonly<Record<string, unknown>>;
|
|
1055
|
+
}
|
|
1056
|
+
interface EntityLeaderboardEntry extends RankedRow {
|
|
1057
|
+
readonly rank: number;
|
|
1058
|
+
readonly stats?: Readonly<Record<string, number>>;
|
|
1059
|
+
}
|
|
1060
|
+
interface EntityLeaderboard {
|
|
1061
|
+
readonly leaderboardType: string;
|
|
1062
|
+
readonly runType: string;
|
|
1063
|
+
readonly entityType: EntityType;
|
|
1064
|
+
readonly entityId: string;
|
|
1065
|
+
readonly bucket1?: string;
|
|
1066
|
+
readonly bucket2?: string;
|
|
1067
|
+
readonly entries: readonly EntityLeaderboardEntry[];
|
|
1068
|
+
readonly personalBest: EntityLeaderboardEntry | null;
|
|
1069
|
+
readonly totalRuns: number;
|
|
1070
|
+
readonly totalRunsExact: boolean;
|
|
1071
|
+
readonly generatedAt: number;
|
|
1072
|
+
}
|
|
1073
|
+
interface EntityLeaderboardOptions {
|
|
1074
|
+
readonly bucket1?: string;
|
|
1075
|
+
readonly bucket2?: string;
|
|
1076
|
+
readonly limit?: number;
|
|
1077
|
+
readonly signal?: AbortSignal;
|
|
1078
|
+
}
|
|
1079
|
+
interface GetLeaderboardOptions {
|
|
1080
|
+
readonly bucket1?: string;
|
|
1081
|
+
readonly bucket2?: string;
|
|
1082
|
+
readonly signal?: AbortSignal;
|
|
1083
|
+
}
|
|
1084
|
+
declare class LeaderboardsApi {
|
|
1085
|
+
#private;
|
|
1086
|
+
constructor(api: GameApi);
|
|
1087
|
+
get(leaderboardType: string, options?: GetLeaderboardOptions): Promise<Leaderboard>;
|
|
1088
|
+
friends(leaderboardType: string, options?: GetLeaderboardOptions): Promise<Leaderboard>;
|
|
1089
|
+
mine(leaderboardType: string, options?: EntityLeaderboardOptions): Promise<EntityLeaderboard>;
|
|
1090
|
+
character(leaderboardType: string, characterId: string, options?: EntityLeaderboardOptions): Promise<EntityLeaderboard>;
|
|
1091
|
+
}
|
|
1092
|
+
interface ShowcaseValue {
|
|
1093
|
+
readonly playerId: string;
|
|
1094
|
+
readonly key: string;
|
|
1095
|
+
readonly value: unknown;
|
|
1096
|
+
readonly updatedAt: number;
|
|
1097
|
+
}
|
|
1098
|
+
interface ShowcaseFriendEntry {
|
|
1099
|
+
readonly playerId: string;
|
|
1100
|
+
readonly displayName?: string;
|
|
1101
|
+
readonly discriminator?: string;
|
|
1102
|
+
readonly displayTag?: string;
|
|
1103
|
+
readonly value: unknown;
|
|
1104
|
+
readonly isViewer: boolean;
|
|
1105
|
+
readonly updatedAt: number;
|
|
1106
|
+
}
|
|
1107
|
+
interface ShowcaseFriends {
|
|
1108
|
+
readonly key: string;
|
|
1109
|
+
readonly entries: readonly ShowcaseFriendEntry[];
|
|
1110
|
+
readonly generatedAt: number;
|
|
1111
|
+
}
|
|
1112
|
+
interface ShowcaseCallOptions {
|
|
1113
|
+
readonly signal?: AbortSignal;
|
|
1114
|
+
}
|
|
1115
|
+
declare class ShowcaseApi {
|
|
1116
|
+
private readonly api;
|
|
1117
|
+
private readonly selfPlayerId;
|
|
1118
|
+
constructor(api: GameApi, selfPlayerId: () => Promise<string>);
|
|
1119
|
+
friends(key: string, options?: ShowcaseCallOptions): Promise<ShowcaseFriends>;
|
|
1120
|
+
of(playerId: string, key: string, options?: ShowcaseCallOptions): Promise<ShowcaseValue | null>;
|
|
1121
|
+
set(key: string, value: unknown, options?: ShowcaseCallOptions): Promise<ShowcaseValue>;
|
|
1122
|
+
clear(key: string, options?: ShowcaseCallOptions): Promise<void>;
|
|
1123
|
+
}
|
|
1124
|
+
interface Friend {
|
|
1125
|
+
readonly playerId: string;
|
|
1126
|
+
readonly displayName?: string;
|
|
1127
|
+
readonly discriminator?: string;
|
|
1128
|
+
readonly displayTag?: string;
|
|
1129
|
+
readonly avatarIconId?: string;
|
|
1130
|
+
readonly avatarIconUrl?: string;
|
|
1131
|
+
}
|
|
1132
|
+
interface FriendsPage {
|
|
1133
|
+
readonly friends: readonly Friend[];
|
|
1134
|
+
readonly nextCursor?: string;
|
|
1135
|
+
}
|
|
1136
|
+
interface ListFriendsOptions {
|
|
1137
|
+
readonly limit?: number;
|
|
1138
|
+
readonly cursor?: string;
|
|
1139
|
+
readonly signal?: AbortSignal;
|
|
1140
|
+
}
|
|
1141
|
+
declare class FriendsApi {
|
|
1142
|
+
#private;
|
|
1143
|
+
constructor(api: GameApi);
|
|
1144
|
+
list(options?: ListFriendsOptions): Promise<FriendsPage>;
|
|
1145
|
+
}
|
|
1146
|
+
type PlatformCurrencyAccess = "read" | "spend";
|
|
1147
|
+
interface PlatformCurrency {
|
|
1148
|
+
readonly slug: string;
|
|
1149
|
+
readonly currencyId: string;
|
|
1150
|
+
readonly balance: number;
|
|
1151
|
+
readonly access: PlatformCurrencyAccess;
|
|
1152
|
+
}
|
|
1153
|
+
interface PlatformCurrencyReadOptions {
|
|
1154
|
+
readonly signal?: AbortSignal;
|
|
1155
|
+
}
|
|
1156
|
+
declare class PlatformCurrenciesApi {
|
|
1157
|
+
#private;
|
|
1158
|
+
constructor(api: GameApi);
|
|
1159
|
+
get(options?: PlatformCurrencyReadOptions): Promise<readonly PlatformCurrency[]>;
|
|
1160
|
+
}
|
|
1161
|
+
declare class PlatformApi {
|
|
1162
|
+
readonly currencies: PlatformCurrenciesApi;
|
|
1163
|
+
constructor(api: GameApi);
|
|
1164
|
+
}
|
|
1165
|
+
interface ProfileShowcaseEntry {
|
|
1166
|
+
readonly key: string;
|
|
1167
|
+
readonly visibility: string;
|
|
1168
|
+
readonly value: unknown;
|
|
1169
|
+
readonly updatedAt: number;
|
|
1170
|
+
}
|
|
1171
|
+
interface PlayerProfile {
|
|
1172
|
+
readonly playerId: string;
|
|
1173
|
+
readonly displayName?: string;
|
|
1174
|
+
readonly discriminator?: string;
|
|
1175
|
+
readonly displayTag?: string;
|
|
1176
|
+
readonly avatarIconId?: string;
|
|
1177
|
+
readonly avatarIconUrl?: string;
|
|
1178
|
+
readonly showcase: readonly ProfileShowcaseEntry[];
|
|
1179
|
+
readonly generatedAt: number;
|
|
1180
|
+
}
|
|
1181
|
+
interface ProfileCallOptions {
|
|
1182
|
+
readonly signal?: AbortSignal;
|
|
1183
|
+
}
|
|
1184
|
+
declare class ProfilesApi {
|
|
1185
|
+
#private;
|
|
1186
|
+
constructor(api: GameApi);
|
|
1187
|
+
of(playerId: string, options?: ProfileCallOptions): Promise<PlayerProfile | null>;
|
|
1188
|
+
}
|
|
1189
|
+
type SessionEndReason = "grant_expiring" | "session_ended" | "navigating" | "kill_switch" | "pagehide";
|
|
1190
|
+
type MatchTransport = "dedicated" | "p2p";
|
|
1191
|
+
type PlatformEventName = "gem_session_start" | "gem_session_end" | "gem_pause" | "gem_resume" | "gem_boot_ready" | "gem_match_started" | "gem_match_ended" | "gem_auth_lost";
|
|
1192
|
+
declare const PLATFORM_EVENTS: readonly PlatformEventName[];
|
|
1193
|
+
type AnalyticsValue = string | number;
|
|
1194
|
+
interface AnalyticsRejection {
|
|
1195
|
+
readonly index: number;
|
|
1196
|
+
readonly code: string;
|
|
1197
|
+
}
|
|
1198
|
+
interface AnalyticsFlushResult {
|
|
1199
|
+
readonly accepted: number;
|
|
1200
|
+
readonly rejected: readonly AnalyticsRejection[];
|
|
1201
|
+
readonly dropped: number;
|
|
1202
|
+
readonly duplicate: boolean;
|
|
1203
|
+
}
|
|
1204
|
+
interface AnalyticsFlushOptions {
|
|
1205
|
+
readonly keepalive?: boolean;
|
|
1206
|
+
readonly signal?: AbortSignal;
|
|
1207
|
+
}
|
|
1208
|
+
interface AnalyticsOptions {
|
|
1209
|
+
readonly enabled?: boolean;
|
|
1210
|
+
readonly flushIntervalMs?: number;
|
|
1211
|
+
readonly maxQueue?: number;
|
|
1212
|
+
}
|
|
1213
|
+
interface AnalyticsApiOptions {
|
|
1214
|
+
readonly environment?: Readonly<Record<string, string>> | (() => Readonly<Record<string, string>>);
|
|
1215
|
+
readonly client: () => GemClient;
|
|
1216
|
+
readonly clock: Clock;
|
|
1217
|
+
readonly gameId: () => string | null;
|
|
1218
|
+
readonly playerId: () => string | null;
|
|
1219
|
+
readonly options?: AnalyticsOptions;
|
|
1220
|
+
readonly log?: ((message: string) => void) | null;
|
|
1221
|
+
}
|
|
1222
|
+
declare class AnalyticsApi {
|
|
1223
|
+
#private;
|
|
1224
|
+
constructor(options: AnalyticsApiOptions);
|
|
1225
|
+
track(name: string, props?: Readonly<Record<string, AnalyticsValue>>): void;
|
|
1226
|
+
setContext(props: Readonly<Record<string, AnalyticsValue>>): void;
|
|
1227
|
+
get environment(): Readonly<Record<string, string>>;
|
|
1228
|
+
flush(options?: AnalyticsFlushOptions): Promise<AnalyticsFlushResult>;
|
|
1229
|
+
trackPlatform(name: PlatformEventName, props?: Readonly<Record<string, AnalyticsValue>>): void;
|
|
1230
|
+
startSession(): void;
|
|
1231
|
+
endSession(reason: SessionEndReason): void;
|
|
1232
|
+
setPaused(paused: boolean): void;
|
|
1233
|
+
setHidden(hidden: boolean): void;
|
|
1234
|
+
dispose(): void;
|
|
1235
|
+
get pending(): number;
|
|
1236
|
+
}
|
|
1237
|
+
interface BootMark {
|
|
1238
|
+
readonly name: string;
|
|
1239
|
+
readonly at: number;
|
|
1240
|
+
}
|
|
1241
|
+
interface BootTimeline {
|
|
1242
|
+
mark(name: string, at?: number): boolean;
|
|
1243
|
+
timeline(): string;
|
|
1244
|
+
readonly marks: readonly BootMark[];
|
|
1245
|
+
}
|
|
1246
|
+
interface BootTimelineOptions {
|
|
1247
|
+
readonly now?: () => number;
|
|
1248
|
+
}
|
|
1249
|
+
declare function markOnResolve<T>(boot: BootTimeline, name: string, work: Promise<T>, log?: ((message: string) => void) | null): Promise<T>;
|
|
1250
|
+
declare function reportOnResolve(boot: BootTimeline, log?: ((message: string) => void) | null): <T>(work: Promise<T>) => Promise<T>;
|
|
1251
|
+
declare function createBootTimeline(options?: BootTimelineOptions): BootTimeline;
|
|
1252
|
+
type DevToolsOpener = "game" | "platform";
|
|
1253
|
+
interface GemDevTools {
|
|
1254
|
+
open(): Promise<boolean>;
|
|
1255
|
+
close(): void;
|
|
1256
|
+
readonly isOpen: boolean;
|
|
1257
|
+
}
|
|
1258
|
+
type ClusterTargetLike = string | null | undefined;
|
|
1259
|
+
declare const CLIENT_PLATFORMS: readonly [
|
|
1260
|
+
"universal",
|
|
1261
|
+
"mobile",
|
|
1262
|
+
"web"
|
|
1263
|
+
];
|
|
1264
|
+
type ClientPlatform = (typeof CLIENT_PLATFORMS)[number];
|
|
1265
|
+
interface ClientVersion {
|
|
1266
|
+
readonly platform?: ClientPlatform;
|
|
1267
|
+
readonly gameVersion: string;
|
|
1268
|
+
readonly engineVersion?: string;
|
|
1269
|
+
}
|
|
1270
|
+
interface ReadyMatch {
|
|
1271
|
+
readonly status: "ready";
|
|
1272
|
+
readonly matchId: string;
|
|
1273
|
+
readonly protocol: string;
|
|
1274
|
+
readonly joinCredential?: string;
|
|
1275
|
+
readonly credentialExpiresAt?: number;
|
|
1276
|
+
readonly host?: string;
|
|
1277
|
+
readonly port?: number;
|
|
1278
|
+
}
|
|
1279
|
+
interface StartMatchWaiting {
|
|
1280
|
+
readonly attempt: number;
|
|
1281
|
+
readonly elapsedMs: number;
|
|
1282
|
+
readonly budgetMs: number;
|
|
1283
|
+
readonly nextAttemptInMs: number;
|
|
1284
|
+
readonly status: number;
|
|
1285
|
+
readonly message: string;
|
|
1286
|
+
}
|
|
1287
|
+
interface StartMatchRetryOptions {
|
|
1288
|
+
readonly budgetMs?: number;
|
|
1289
|
+
readonly initialDelayMs?: number;
|
|
1290
|
+
readonly maxDelayMs?: number;
|
|
1291
|
+
readonly onWaiting?: (waiting: StartMatchWaiting) => void;
|
|
1292
|
+
}
|
|
1293
|
+
interface ClusterTarget {
|
|
1294
|
+
readonly id: string;
|
|
1295
|
+
readonly pressure: string;
|
|
1296
|
+
}
|
|
1297
|
+
type RoomArgScalar = string | number | boolean;
|
|
1298
|
+
type RoomArgValue$1 = RoomArgScalar | readonly RoomArgScalar[];
|
|
1299
|
+
type RoomArgs = Readonly<Record<string, RoomArgValue$1>>;
|
|
1300
|
+
type RoomArgType = "string" | "int" | "float" | "bool" | (string & {});
|
|
1301
|
+
interface RoomArgEntry {
|
|
1302
|
+
readonly name: string;
|
|
1303
|
+
readonly type: RoomArgType;
|
|
1304
|
+
readonly list: boolean;
|
|
1305
|
+
readonly required: boolean;
|
|
1306
|
+
readonly mutable: boolean;
|
|
1307
|
+
readonly fixed?: RoomArgValue$1;
|
|
1308
|
+
readonly default?: RoomArgValue$1;
|
|
1309
|
+
readonly description?: string;
|
|
1310
|
+
readonly allowed?: readonly RoomArgScalar[];
|
|
1311
|
+
readonly min?: number;
|
|
1312
|
+
readonly max?: number;
|
|
1313
|
+
readonly minItems?: number;
|
|
1314
|
+
readonly maxItems?: number;
|
|
1315
|
+
readonly maxLength?: number;
|
|
1316
|
+
}
|
|
1317
|
+
type DedicatedServerFailure = "timeout" | "aborted" | "allocation_failed" | "no_server_ready" | "start_rate_limited" | "p2p_unavailable" | "unsupported_protocol" | "credential_expired" | "credential_reused" | "join_rate_limited" | "signaling_unavailable" | "signaling_failed" | "offer_refused" | "invalid_sdp" | "media_refused" | "connection_failed" | "join_refused" | "match_ended" | "misconfigured";
|
|
1318
|
+
declare class DedicatedServerError extends Error {
|
|
1319
|
+
readonly reason: DedicatedServerFailure;
|
|
1320
|
+
readonly retryable: boolean;
|
|
1321
|
+
readonly platformCode: string | undefined;
|
|
1322
|
+
constructor(reason: DedicatedServerFailure, message: string, options?: {
|
|
1323
|
+
cause?: unknown;
|
|
1324
|
+
platformCode?: string;
|
|
1325
|
+
});
|
|
1326
|
+
}
|
|
1327
|
+
type SignalingIntent = "initial" | "ice_restart" | "full_reconnect";
|
|
1328
|
+
interface OfferRequest {
|
|
1329
|
+
readonly matchId: string;
|
|
1330
|
+
readonly sdp: string;
|
|
1331
|
+
readonly intent: SignalingIntent;
|
|
1332
|
+
}
|
|
1333
|
+
interface SignalingAnswer {
|
|
1334
|
+
readonly sdp: string;
|
|
1335
|
+
}
|
|
1336
|
+
interface SignalingChannel {
|
|
1337
|
+
exchange(request: OfferRequest, signal?: AbortSignal): Promise<SignalingAnswer>;
|
|
1338
|
+
close(): void;
|
|
1339
|
+
}
|
|
1340
|
+
type SdpType$1 = "offer" | "answer" | "pranswer" | "rollback";
|
|
1341
|
+
interface SessionDescriptionLike$1 {
|
|
1342
|
+
readonly type: SdpType$1;
|
|
1343
|
+
readonly sdp?: string;
|
|
1344
|
+
}
|
|
1345
|
+
interface DataChannelInitLike$1 {
|
|
1346
|
+
readonly ordered?: boolean;
|
|
1347
|
+
readonly maxRetransmits?: number;
|
|
1348
|
+
}
|
|
1349
|
+
interface EventTargetLike$1 {
|
|
1350
|
+
addEventListener(type: string, listener: (event: unknown) => void): void;
|
|
1351
|
+
removeEventListener(type: string, listener: (event: unknown) => void): void;
|
|
1352
|
+
}
|
|
1353
|
+
interface DataChannelLike$1 extends EventTargetLike$1 {
|
|
1354
|
+
readonly readyState: string;
|
|
1355
|
+
send(data: string | Uint8Array): void;
|
|
1356
|
+
close(): void;
|
|
1357
|
+
}
|
|
1358
|
+
interface PeerConnectionLike$1 extends EventTargetLike$1 {
|
|
1359
|
+
readonly localDescription: SessionDescriptionLike$1 | null;
|
|
1360
|
+
readonly iceGatheringState: string;
|
|
1361
|
+
createDataChannel(label: string, init?: DataChannelInitLike$1): DataChannelLike$1;
|
|
1362
|
+
createOffer(): Promise<SessionDescriptionLike$1>;
|
|
1363
|
+
setLocalDescription(description: SessionDescriptionLike$1): Promise<void>;
|
|
1364
|
+
setRemoteDescription(description: SessionDescriptionLike$1): Promise<void>;
|
|
1365
|
+
close(): void;
|
|
1366
|
+
}
|
|
1367
|
+
interface JoinWelcome {
|
|
1368
|
+
readonly playerId?: string;
|
|
1369
|
+
readonly matchId?: string;
|
|
1370
|
+
readonly heartbeatIntervalMs?: number;
|
|
1371
|
+
}
|
|
1372
|
+
interface JoinExchange {
|
|
1373
|
+
readonly welcome: JoinWelcome;
|
|
1374
|
+
detach(): void;
|
|
1375
|
+
}
|
|
1376
|
+
interface PresentCredentialOptions {
|
|
1377
|
+
readonly channel: DataChannelLike$1;
|
|
1378
|
+
readonly credential: string;
|
|
1379
|
+
readonly credentialExpiresAt: number;
|
|
1380
|
+
readonly clock: Clock;
|
|
1381
|
+
readonly ceilingMs?: number;
|
|
1382
|
+
readonly wire?: number;
|
|
1383
|
+
readonly heartbeat?: boolean;
|
|
1384
|
+
readonly onMessage?: (data: unknown) => void;
|
|
1385
|
+
readonly signal?: AbortSignal;
|
|
1386
|
+
}
|
|
1387
|
+
declare function presentJoinCredential(options: PresentCredentialOptions): Promise<JoinExchange>;
|
|
1388
|
+
type TransportKind = "webtransport" | "webrtc" | "websocket";
|
|
1389
|
+
declare const UNRELIABLE_CHANNEL_LABEL = "gem-uu";
|
|
1390
|
+
interface SendOptions$1 {
|
|
1391
|
+
readonly reliable?: boolean;
|
|
1392
|
+
readonly ordered?: boolean;
|
|
1393
|
+
}
|
|
1394
|
+
interface MessageMeta {
|
|
1395
|
+
readonly reliable: boolean;
|
|
1396
|
+
readonly ordered: boolean;
|
|
1397
|
+
}
|
|
1398
|
+
interface GameServerLink {
|
|
1399
|
+
readonly transport: TransportKind;
|
|
1400
|
+
send(data: Uint8Array | string, options?: SendOptions$1): void;
|
|
1401
|
+
onMessage(handler: (data: Uint8Array | string, meta: MessageMeta) => void): void;
|
|
1402
|
+
onClose(handler: (reason?: string) => void): void;
|
|
1403
|
+
close(): void;
|
|
1404
|
+
}
|
|
1405
|
+
interface TransportAdvert {
|
|
1406
|
+
readonly v: number;
|
|
1407
|
+
readonly host: string;
|
|
1408
|
+
readonly port: number;
|
|
1409
|
+
readonly match_id: string;
|
|
1410
|
+
readonly webrtc?: boolean;
|
|
1411
|
+
readonly webtransport?: {
|
|
1412
|
+
readonly url: string;
|
|
1413
|
+
readonly cert_sha256_b64: string;
|
|
1414
|
+
readonly expires_at?: number;
|
|
1415
|
+
readonly named_url?: string;
|
|
1416
|
+
};
|
|
1417
|
+
readonly websocket?: {
|
|
1418
|
+
readonly url: string;
|
|
1419
|
+
readonly tls?: boolean;
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
declare function readTemplateTransports(value: unknown): readonly TransportKind[] | null;
|
|
1423
|
+
declare function readTransportAdvert(settings: unknown, forMatch?: string): TransportAdvert | null;
|
|
1424
|
+
declare function webTransportAvailable(): boolean;
|
|
1425
|
+
type RoomStatus = "open" | "in_game" | "closed" | (string & {});
|
|
1426
|
+
type MatchConnectionState = "disconnected" | "connecting" | "connected" | "suspended";
|
|
1427
|
+
type MatchSessionPhase = "none" | "starting" | "ready" | "connected" | "suspended" | "ended" | (string & {});
|
|
1428
|
+
interface MatchSession {
|
|
1429
|
+
readonly phase: MatchSessionPhase;
|
|
1430
|
+
readonly matchId?: string;
|
|
1431
|
+
readonly reason?: string;
|
|
1432
|
+
readonly roomReopened?: boolean;
|
|
1433
|
+
}
|
|
1434
|
+
interface MatchEnded {
|
|
1435
|
+
readonly matchId: string;
|
|
1436
|
+
readonly reason: string;
|
|
1437
|
+
readonly roomReopened: boolean;
|
|
1438
|
+
}
|
|
1439
|
+
interface MatchSuspended {
|
|
1440
|
+
readonly matchId: string;
|
|
1441
|
+
readonly cause: string;
|
|
1442
|
+
}
|
|
1443
|
+
interface MatchReconnecting {
|
|
1444
|
+
readonly matchId: string;
|
|
1445
|
+
readonly attempt: number;
|
|
1446
|
+
readonly attempts: number;
|
|
1447
|
+
readonly remainingMs: number;
|
|
1448
|
+
}
|
|
1449
|
+
interface MatchReconnected {
|
|
1450
|
+
readonly matchId: string;
|
|
1451
|
+
readonly attempt: number;
|
|
1452
|
+
}
|
|
1453
|
+
interface AutoReconnectOptions {
|
|
1454
|
+
readonly budgetMs?: number;
|
|
1455
|
+
readonly attempts?: number;
|
|
1456
|
+
readonly maxDelayMs?: number;
|
|
1457
|
+
}
|
|
1458
|
+
interface RoomMember {
|
|
1459
|
+
readonly playerId: string;
|
|
1460
|
+
readonly isReady: boolean;
|
|
1461
|
+
readonly role: string;
|
|
1462
|
+
readonly joinedAt: number;
|
|
1463
|
+
readonly groupId?: string;
|
|
1464
|
+
readonly platform?: string;
|
|
1465
|
+
readonly displayName?: PlayerText;
|
|
1466
|
+
readonly displayTag?: PlayerText;
|
|
1467
|
+
readonly discriminator?: string;
|
|
1468
|
+
}
|
|
1469
|
+
interface Room {
|
|
1470
|
+
readonly id: string;
|
|
1471
|
+
readonly gameId: string;
|
|
1472
|
+
readonly name: string;
|
|
1473
|
+
readonly status: RoomStatus;
|
|
1474
|
+
readonly hostPlayerId: string;
|
|
1475
|
+
readonly maxPlayers: number;
|
|
1476
|
+
readonly memberCount: number;
|
|
1477
|
+
readonly members: readonly RoomMember[];
|
|
1478
|
+
readonly isPublic: boolean;
|
|
1479
|
+
readonly joinCode?: string;
|
|
1480
|
+
readonly settings?: unknown;
|
|
1481
|
+
readonly roomArgs?: RoomArgs;
|
|
1482
|
+
readonly roomArgsTemplate?: readonly RoomArgEntry[];
|
|
1483
|
+
readonly gameChannel: string;
|
|
1484
|
+
readonly region?: string;
|
|
1485
|
+
readonly matchId?: string;
|
|
1486
|
+
readonly version: number;
|
|
1487
|
+
readonly templateId?: string;
|
|
1488
|
+
readonly roomType: string;
|
|
1489
|
+
readonly transports?: readonly TransportKind[];
|
|
1490
|
+
readonly createdAt: number;
|
|
1491
|
+
readonly updatedAt: number;
|
|
1492
|
+
readonly startedAt?: number;
|
|
1493
|
+
}
|
|
1494
|
+
interface RoomSummary {
|
|
1495
|
+
readonly id: string;
|
|
1496
|
+
readonly gameId: string;
|
|
1497
|
+
readonly name: string;
|
|
1498
|
+
readonly status: RoomStatus;
|
|
1499
|
+
readonly hostPlayerId: string;
|
|
1500
|
+
readonly maxPlayers: number;
|
|
1501
|
+
readonly memberCount: number;
|
|
1502
|
+
readonly isPublic: boolean;
|
|
1503
|
+
readonly gameChannel: string;
|
|
1504
|
+
readonly roomType: string;
|
|
1505
|
+
readonly createdAt: number;
|
|
1506
|
+
}
|
|
1507
|
+
interface RoomPage {
|
|
1508
|
+
readonly rooms: readonly RoomSummary[];
|
|
1509
|
+
readonly nextCursor?: string;
|
|
1510
|
+
}
|
|
1511
|
+
interface RoomOperationError {
|
|
1512
|
+
readonly operation: string;
|
|
1513
|
+
readonly code: number;
|
|
1514
|
+
readonly reason: string;
|
|
1515
|
+
readonly message: string;
|
|
1516
|
+
readonly retryable: boolean;
|
|
1517
|
+
}
|
|
1518
|
+
interface CreateRoomOptions {
|
|
1519
|
+
readonly name: string;
|
|
1520
|
+
readonly maxPlayers?: number;
|
|
1521
|
+
readonly isPublic?: boolean;
|
|
1522
|
+
readonly settings?: unknown;
|
|
1523
|
+
readonly region?: string;
|
|
1524
|
+
readonly templateId?: string;
|
|
1525
|
+
readonly templateSlug?: string;
|
|
1526
|
+
readonly partyId?: string;
|
|
1527
|
+
readonly roomArgs?: RoomArgs;
|
|
1528
|
+
readonly signal?: AbortSignal;
|
|
1529
|
+
}
|
|
1530
|
+
interface JoinRoomOptions {
|
|
1531
|
+
readonly partyId?: string;
|
|
1532
|
+
readonly signal?: AbortSignal;
|
|
1533
|
+
}
|
|
1534
|
+
interface QuickJoinOptions extends JoinRoomOptions {
|
|
1535
|
+
readonly templateSlug?: string;
|
|
1536
|
+
readonly templateId?: string;
|
|
1537
|
+
readonly region?: string;
|
|
1538
|
+
readonly name?: string;
|
|
1539
|
+
}
|
|
1540
|
+
interface ListRoomsOptions {
|
|
1541
|
+
readonly status?: "open" | "in_game";
|
|
1542
|
+
readonly templateSlug?: string;
|
|
1543
|
+
readonly limit?: number;
|
|
1544
|
+
readonly cursor?: string;
|
|
1545
|
+
readonly signal?: AbortSignal;
|
|
1546
|
+
}
|
|
1547
|
+
interface UpdateRoomOptions {
|
|
1548
|
+
readonly name?: string;
|
|
1549
|
+
readonly maxPlayers?: number;
|
|
1550
|
+
readonly isPublic?: boolean;
|
|
1551
|
+
readonly settings?: unknown;
|
|
1552
|
+
readonly roomArgs?: RoomArgs;
|
|
1553
|
+
readonly signal?: AbortSignal;
|
|
1554
|
+
}
|
|
1555
|
+
interface RoomEventMap {
|
|
1556
|
+
created: [
|
|
1557
|
+
Room
|
|
1558
|
+
];
|
|
1559
|
+
joined: [
|
|
1560
|
+
Room
|
|
1561
|
+
];
|
|
1562
|
+
left: [
|
|
1563
|
+
];
|
|
1564
|
+
closed: [
|
|
1565
|
+
];
|
|
1566
|
+
updated: [
|
|
1567
|
+
Room
|
|
1568
|
+
];
|
|
1569
|
+
seated: [
|
|
1570
|
+
Room
|
|
1571
|
+
];
|
|
1572
|
+
listed: [
|
|
1573
|
+
RoomPage
|
|
1574
|
+
];
|
|
1575
|
+
mineListed: [
|
|
1576
|
+
readonly RoomSummary[]
|
|
1577
|
+
];
|
|
1578
|
+
memberJoined: [
|
|
1579
|
+
string
|
|
1580
|
+
];
|
|
1581
|
+
memberLeft: [
|
|
1582
|
+
string
|
|
1583
|
+
];
|
|
1584
|
+
kicked: [
|
|
1585
|
+
];
|
|
1586
|
+
readyChanged: [
|
|
1587
|
+
string,
|
|
1588
|
+
boolean
|
|
1589
|
+
];
|
|
1590
|
+
hostChanged: [
|
|
1591
|
+
string
|
|
1592
|
+
];
|
|
1593
|
+
matchStartWaiting: [
|
|
1594
|
+
StartMatchWaiting
|
|
1595
|
+
];
|
|
1596
|
+
matchAllocationStarted: [
|
|
1597
|
+
string
|
|
1598
|
+
];
|
|
1599
|
+
matchReady: [
|
|
1600
|
+
ReadyMatch
|
|
1601
|
+
];
|
|
1602
|
+
matchFailed: [
|
|
1603
|
+
string,
|
|
1604
|
+
string
|
|
1605
|
+
];
|
|
1606
|
+
matchEnded: [
|
|
1607
|
+
MatchEnded
|
|
1608
|
+
];
|
|
1609
|
+
matchSuspended: [
|
|
1610
|
+
MatchSuspended
|
|
1611
|
+
];
|
|
1612
|
+
matchReconnecting: [
|
|
1613
|
+
MatchReconnecting
|
|
1614
|
+
];
|
|
1615
|
+
matchReconnected: [
|
|
1616
|
+
MatchReconnected
|
|
1617
|
+
];
|
|
1618
|
+
versionUpdateAvailable: [
|
|
1619
|
+
ClientPlatform | undefined
|
|
1620
|
+
];
|
|
1621
|
+
error: [
|
|
1622
|
+
RoomOperationError
|
|
1623
|
+
];
|
|
1624
|
+
}
|
|
1625
|
+
type RoomEventName = keyof RoomEventMap;
|
|
1626
|
+
interface MatchEndHint {
|
|
1627
|
+
readonly matchId?: string;
|
|
1628
|
+
readonly reason?: string;
|
|
1629
|
+
}
|
|
1630
|
+
interface RelayedRoomEvent {
|
|
1631
|
+
readonly event: "updated" | "match_started" | "match_ready" | "match_failed" | "version_stale";
|
|
1632
|
+
readonly roomId: string;
|
|
1633
|
+
readonly matchId?: string;
|
|
1634
|
+
readonly version?: number;
|
|
1635
|
+
readonly reason?: string;
|
|
1636
|
+
readonly platform?: ClientPlatform;
|
|
1637
|
+
}
|
|
1638
|
+
interface StartMatchOptions {
|
|
1639
|
+
readonly clusterTargetId?: ClusterTargetLike;
|
|
1640
|
+
readonly retry?: StartMatchRetryOptions;
|
|
1641
|
+
readonly signal?: AbortSignal;
|
|
1642
|
+
}
|
|
1643
|
+
interface AwaitMatchOptions {
|
|
1644
|
+
readonly timeoutMs?: number;
|
|
1645
|
+
readonly pollIntervalMs?: number;
|
|
1646
|
+
readonly signal?: AbortSignal;
|
|
1647
|
+
}
|
|
1648
|
+
interface StartedMatch {
|
|
1649
|
+
readonly matchId: string;
|
|
1650
|
+
readonly status: string;
|
|
1651
|
+
}
|
|
1652
|
+
interface RoomManager {
|
|
1653
|
+
create(options: CreateRoomOptions): Promise<Room>;
|
|
1654
|
+
join(roomId: string, options?: JoinRoomOptions): Promise<Room>;
|
|
1655
|
+
joinByCode(code: string, options?: JoinRoomOptions): Promise<Room>;
|
|
1656
|
+
quickJoin(options: QuickJoinOptions): Promise<Room>;
|
|
1657
|
+
list(options?: ListRoomsOptions): Promise<RoomPage>;
|
|
1658
|
+
myRooms(signal?: AbortSignal): Promise<readonly RoomSummary[]>;
|
|
1659
|
+
leave(options?: {
|
|
1660
|
+
asGroup?: boolean;
|
|
1661
|
+
signal?: AbortSignal;
|
|
1662
|
+
keepalive?: boolean;
|
|
1663
|
+
}): Promise<void>;
|
|
1664
|
+
leaveAll(signal?: AbortSignal): Promise<readonly string[]>;
|
|
1665
|
+
close(signal?: AbortSignal): Promise<void>;
|
|
1666
|
+
refresh(signal?: AbortSignal): Promise<Room | null>;
|
|
1667
|
+
setReady(isReady: boolean, signal?: AbortSignal): Promise<Room>;
|
|
1668
|
+
kick(playerId: string, signal?: AbortSignal): Promise<Room>;
|
|
1669
|
+
transferHost(playerId: string, signal?: AbortSignal): Promise<Room>;
|
|
1670
|
+
update(options: UpdateRoomOptions): Promise<Room>;
|
|
1671
|
+
startMatch(options?: StartMatchOptions): Promise<StartedMatch>;
|
|
1672
|
+
awaitMatch(options?: AwaitMatchOptions): Promise<ReadyMatch>;
|
|
1673
|
+
pollMatchStatus(options?: AwaitMatchOptions): Promise<ReadyMatch>;
|
|
1674
|
+
notifyMatchConnected(matchId: string): void;
|
|
1675
|
+
notifyMatchDisconnected(cause?: string): Promise<void>;
|
|
1676
|
+
reconnectToMatch(options?: AwaitMatchOptions): Promise<ReadyMatch>;
|
|
1677
|
+
notifyLeavingMatch(options?: {
|
|
1678
|
+
keepalive?: boolean;
|
|
1679
|
+
}): Promise<void>;
|
|
1680
|
+
readonly gameId: string | null;
|
|
1681
|
+
readonly currentRoom: Room | null;
|
|
1682
|
+
readonly currentMatch: ReadyMatch | null;
|
|
1683
|
+
readonly matchConnectionState: MatchConnectionState;
|
|
1684
|
+
readonly matchSession: MatchSession;
|
|
1685
|
+
readonly isInRoom: boolean;
|
|
1686
|
+
readonly isHost: boolean;
|
|
1687
|
+
readonly members: readonly Room["members"][number][];
|
|
1688
|
+
on<K extends RoomEventName>(event: K, listener: (...args: RoomEventMap[K]) => void): () => void;
|
|
1689
|
+
off<K extends RoomEventName>(event: K, listener: (...args: RoomEventMap[K]) => void): void;
|
|
1690
|
+
once<K extends RoomEventName>(event: K, listener: (...args: RoomEventMap[K]) => void): () => void;
|
|
1691
|
+
handleRoomEvent(event: RelayedRoomEvent): void;
|
|
1692
|
+
handleSeated(roomId: string): void;
|
|
1693
|
+
reconcileSeats(): Promise<void>;
|
|
1694
|
+
reconcile(hint?: MatchEndHint): Promise<void>;
|
|
1695
|
+
startPolling(intervalMs?: number): void;
|
|
1696
|
+
stopPolling(): void;
|
|
1697
|
+
settled(): Promise<void>;
|
|
1698
|
+
dispose(): void;
|
|
1699
|
+
}
|
|
1700
|
+
declare const PROTOCOL: "gem-web-bridge";
|
|
1701
|
+
type GemErrorCode = "version_mismatch" | "handshake_timeout" | "handshake_duplicate" | "invalid_message" | "rate_limited" | "token_unavailable" | "unsupported" | "unsupported_capability" | "internal";
|
|
1702
|
+
interface GemToken {
|
|
1703
|
+
readonly gem: typeof PROTOCOL;
|
|
1704
|
+
readonly type: "gem.token";
|
|
1705
|
+
readonly token: string;
|
|
1706
|
+
readonly requestId?: string;
|
|
1707
|
+
readonly generation: number;
|
|
1708
|
+
readonly apiBaseUrl?: string;
|
|
1709
|
+
readonly playerId: string;
|
|
1710
|
+
readonly gameId: string;
|
|
1711
|
+
readonly channel: "dev" | "test" | "release";
|
|
1712
|
+
readonly gameVersion?: string;
|
|
1713
|
+
readonly expiresAt: number;
|
|
1714
|
+
readonly chainEndsAt: number;
|
|
1715
|
+
readonly allowDevTools?: boolean;
|
|
1716
|
+
}
|
|
1717
|
+
interface GemTokenDenied {
|
|
1718
|
+
readonly gem: typeof PROTOCOL;
|
|
1719
|
+
readonly type: "gem.token.denied";
|
|
1720
|
+
readonly requestId: string;
|
|
1721
|
+
readonly retryable: boolean;
|
|
1722
|
+
readonly retryAfterMs?: number;
|
|
1723
|
+
readonly reason: "chain_exhausted" | "unavailable";
|
|
1724
|
+
readonly correlationId: string;
|
|
1725
|
+
}
|
|
1726
|
+
interface GemPause {
|
|
1727
|
+
readonly gem: typeof PROTOCOL;
|
|
1728
|
+
readonly type: "gem.pause";
|
|
1729
|
+
readonly paused: boolean;
|
|
1730
|
+
}
|
|
1731
|
+
interface GemPrefs$1 {
|
|
1732
|
+
readonly gem: typeof PROTOCOL;
|
|
1733
|
+
readonly type: "gem.prefs";
|
|
1734
|
+
readonly reducedMotion: boolean;
|
|
1735
|
+
readonly muted: boolean;
|
|
1736
|
+
readonly showFrameStats?: boolean;
|
|
1737
|
+
readonly locale: string;
|
|
1738
|
+
}
|
|
1739
|
+
interface GemCohorts$1 {
|
|
1740
|
+
readonly gem: typeof PROTOCOL;
|
|
1741
|
+
readonly type: "gem.cohorts";
|
|
1742
|
+
readonly cohorts: {
|
|
1743
|
+
experimentId: string;
|
|
1744
|
+
variantKey: string;
|
|
1745
|
+
}[];
|
|
1746
|
+
}
|
|
1747
|
+
interface GemViewport$1 {
|
|
1748
|
+
readonly gem: typeof PROTOCOL;
|
|
1749
|
+
readonly type: "gem.viewport";
|
|
1750
|
+
readonly insets: {
|
|
1751
|
+
top: number;
|
|
1752
|
+
right: number;
|
|
1753
|
+
bottom: number;
|
|
1754
|
+
left: number;
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
interface GemDeviceSettings {
|
|
1758
|
+
readonly gem: typeof PROTOCOL;
|
|
1759
|
+
readonly type: "gem.deviceSettings";
|
|
1760
|
+
readonly settings?: unknown;
|
|
1761
|
+
}
|
|
1762
|
+
interface GemWillTerminate {
|
|
1763
|
+
readonly gem: typeof PROTOCOL;
|
|
1764
|
+
readonly type: "gem.willTerminate";
|
|
1765
|
+
readonly reason: "grant_expiring" | "session_ended" | "navigating" | "kill_switch";
|
|
1766
|
+
readonly graceMs: number;
|
|
1767
|
+
}
|
|
1768
|
+
interface GemRoomEvent {
|
|
1769
|
+
readonly gem: typeof PROTOCOL;
|
|
1770
|
+
readonly type: "gem.roomEvent";
|
|
1771
|
+
readonly event: "updated" | "match_started" | "match_ready" | "match_failed" | "version_stale";
|
|
1772
|
+
readonly roomId: string;
|
|
1773
|
+
readonly matchId?: string;
|
|
1774
|
+
readonly version?: number;
|
|
1775
|
+
readonly reason?: string;
|
|
1776
|
+
readonly platform?: "universal" | "mobile";
|
|
1777
|
+
}
|
|
1778
|
+
interface GemSocketState {
|
|
1779
|
+
readonly gem: typeof PROTOCOL;
|
|
1780
|
+
readonly type: "gem.socketState";
|
|
1781
|
+
readonly connected: boolean;
|
|
1782
|
+
readonly reason?: "connecting" | "dropped" | "watchdog" | "terminal";
|
|
1783
|
+
}
|
|
1784
|
+
interface GemSeatedEvent {
|
|
1785
|
+
readonly gem: typeof PROTOCOL;
|
|
1786
|
+
readonly type: "gem.seatedEvent";
|
|
1787
|
+
readonly roomId: string;
|
|
1788
|
+
}
|
|
1789
|
+
interface GemSignalEvent {
|
|
1790
|
+
readonly gem: typeof PROTOCOL;
|
|
1791
|
+
readonly type: "gem.signalEvent";
|
|
1792
|
+
readonly event: "hello" | "offer" | "answer" | "ice" | "peerJoined" | "peerLeft" | "migration" | "matchEnded" | "error";
|
|
1793
|
+
readonly matchId: string;
|
|
1794
|
+
readonly data: unknown;
|
|
1795
|
+
}
|
|
1796
|
+
interface GemDedicatedEvent {
|
|
1797
|
+
readonly gem: typeof PROTOCOL;
|
|
1798
|
+
readonly type: "gem.dedicatedEvent";
|
|
1799
|
+
readonly event: "answer" | "error" | "matchEnded";
|
|
1800
|
+
readonly matchId: string;
|
|
1801
|
+
readonly sdp?: string;
|
|
1802
|
+
readonly sessionId?: string;
|
|
1803
|
+
readonly code?: string;
|
|
1804
|
+
readonly message?: string;
|
|
1805
|
+
readonly reason?: string;
|
|
1806
|
+
}
|
|
1807
|
+
interface GemPartyResult {
|
|
1808
|
+
readonly gem: typeof PROTOCOL;
|
|
1809
|
+
readonly type: "gem.partyResult";
|
|
1810
|
+
readonly requestId: string;
|
|
1811
|
+
readonly partyId?: string;
|
|
1812
|
+
}
|
|
1813
|
+
interface GemClusterTarget {
|
|
1814
|
+
readonly gem: typeof PROTOCOL;
|
|
1815
|
+
readonly type: "gem.clusterTarget";
|
|
1816
|
+
readonly clusterTargetId: string;
|
|
1817
|
+
}
|
|
1818
|
+
interface GemScreenshotDenied {
|
|
1819
|
+
readonly gem: typeof PROTOCOL;
|
|
1820
|
+
readonly type: "gem.screenshot.denied";
|
|
1821
|
+
readonly reason: "not_wired" | "no_source" | "unsupported" | "unreadable" | "tainted" | "too_large" | "busy" | "declined" | "failed";
|
|
1822
|
+
readonly retryable: boolean;
|
|
1823
|
+
}
|
|
1824
|
+
interface GemDedicatedOffer {
|
|
1825
|
+
readonly gem: typeof PROTOCOL;
|
|
1826
|
+
readonly type: "gem.dedicatedOffer";
|
|
1827
|
+
readonly matchId: string;
|
|
1828
|
+
readonly sdp: string;
|
|
1829
|
+
readonly intent: "initial" | "ice_restart" | "full_reconnect";
|
|
1830
|
+
}
|
|
1831
|
+
interface GemLocalServer {
|
|
1832
|
+
readonly gem: typeof PROTOCOL;
|
|
1833
|
+
readonly type: "gem.localServer";
|
|
1834
|
+
readonly requestId: string;
|
|
1835
|
+
readonly serverId?: string;
|
|
1836
|
+
}
|
|
1837
|
+
interface GemLocalServerDenied {
|
|
1838
|
+
readonly gem: typeof PROTOCOL;
|
|
1839
|
+
readonly type: "gem.localServer.denied";
|
|
1840
|
+
readonly requestId: string;
|
|
1841
|
+
readonly retryable: boolean;
|
|
1842
|
+
readonly reason: "refused" | "unavailable";
|
|
1843
|
+
}
|
|
1844
|
+
interface GemPurchaseResult {
|
|
1845
|
+
readonly gem: typeof PROTOCOL;
|
|
1846
|
+
readonly type: "gem.purchaseResult";
|
|
1847
|
+
readonly requestId: string;
|
|
1848
|
+
readonly outcome: "ok" | "declined" | "unavailable";
|
|
1849
|
+
readonly purchaseId?: string;
|
|
1850
|
+
}
|
|
1851
|
+
interface GemDeviceSettingsResult {
|
|
1852
|
+
readonly gem: typeof PROTOCOL;
|
|
1853
|
+
readonly type: "gem.deviceSettings.result";
|
|
1854
|
+
readonly requestId: string;
|
|
1855
|
+
readonly outcome: "stored" | "too_large" | "unavailable";
|
|
1856
|
+
}
|
|
1857
|
+
interface GemAdResult {
|
|
1858
|
+
readonly gem: typeof PROTOCOL;
|
|
1859
|
+
readonly type: "gem.adResult";
|
|
1860
|
+
readonly requestId: string;
|
|
1861
|
+
readonly outcome: "shown" | "no_ad" | "unavailable";
|
|
1862
|
+
}
|
|
1863
|
+
interface GemSignInResult {
|
|
1864
|
+
readonly gem: typeof PROTOCOL;
|
|
1865
|
+
readonly type: "gem.signInResult";
|
|
1866
|
+
readonly requestId: string;
|
|
1867
|
+
readonly outcome: "signed_in" | "declined" | "unavailable";
|
|
1868
|
+
}
|
|
1869
|
+
interface ConnectOptions {
|
|
1870
|
+
readonly clusterTargetId?: ClusterTargetLike;
|
|
1871
|
+
readonly retry?: StartMatchRetryOptions;
|
|
1872
|
+
readonly timeoutMs?: number;
|
|
1873
|
+
readonly pollIntervalMs?: number;
|
|
1874
|
+
readonly signal?: AbortSignal;
|
|
1875
|
+
readonly signaling?: SignalingChannel;
|
|
1876
|
+
readonly peerConnection?: PeerConnectionLike$1;
|
|
1877
|
+
readonly intent?: SignalingIntent;
|
|
1878
|
+
readonly channelLabel?: string;
|
|
1879
|
+
readonly gatherTimeoutMs?: number;
|
|
1880
|
+
readonly exchangeTimeoutMs?: number;
|
|
1881
|
+
readonly openTimeoutMs?: number;
|
|
1882
|
+
readonly reportDisconnect?: boolean;
|
|
1883
|
+
readonly reportConnected?: boolean;
|
|
1884
|
+
readonly presentCredential?: boolean;
|
|
1885
|
+
readonly onMessage?: (data: unknown) => void;
|
|
1886
|
+
readonly onMatchEnded?: (reason?: string) => void;
|
|
1887
|
+
readonly welcomeTimeoutMs?: number;
|
|
1888
|
+
readonly transports?: readonly TransportKind[];
|
|
1889
|
+
readonly transportAttemptTimeoutMs?: number;
|
|
1890
|
+
readonly redial?: boolean;
|
|
1891
|
+
readonly deadlineAt?: number;
|
|
1892
|
+
}
|
|
1893
|
+
interface DedicatedServerSession {
|
|
1894
|
+
readonly matchId: string;
|
|
1895
|
+
readonly channel: RTCDataChannel;
|
|
1896
|
+
readonly peerConnection: PeerConnectionLike$1;
|
|
1897
|
+
readonly joinCredential: string;
|
|
1898
|
+
readonly credentialExpiresAt: number;
|
|
1899
|
+
readonly welcome: JoinWelcome | null;
|
|
1900
|
+
close(): void;
|
|
1901
|
+
}
|
|
1902
|
+
interface MultiTransportSession {
|
|
1903
|
+
readonly matchId: string;
|
|
1904
|
+
readonly transport: TransportKind;
|
|
1905
|
+
readonly link: GameServerLink;
|
|
1906
|
+
readonly joinCredential: string;
|
|
1907
|
+
readonly credentialExpiresAt: number;
|
|
1908
|
+
readonly welcome: JoinWelcome | null;
|
|
1909
|
+
readonly channel?: RTCDataChannel;
|
|
1910
|
+
readonly peerConnection?: PeerConnectionLike$1;
|
|
1911
|
+
close(): void;
|
|
1912
|
+
}
|
|
1913
|
+
interface DedicatedServerConnect {
|
|
1914
|
+
(options?: ConnectOptions & {
|
|
1915
|
+
transports?: undefined;
|
|
1916
|
+
}): Promise<DedicatedServerSession>;
|
|
1917
|
+
(options: ConnectOptions & {
|
|
1918
|
+
transports: readonly TransportKind[];
|
|
1919
|
+
}): Promise<MultiTransportSession>;
|
|
1920
|
+
(options?: ConnectOptions): Promise<DedicatedServerSession | MultiTransportSession>;
|
|
1921
|
+
}
|
|
1922
|
+
interface DedicatedServerApi {
|
|
1923
|
+
readonly connect: DedicatedServerConnect;
|
|
1924
|
+
listClusterTargets(options?: {
|
|
1925
|
+
signal?: AbortSignal;
|
|
1926
|
+
}): Promise<readonly ClusterTarget[]>;
|
|
1927
|
+
handleMatchEnded(matchId: string, reason?: string): void;
|
|
1928
|
+
}
|
|
1929
|
+
type TransportLabel = "p2p" | "dedicated" | "unknown";
|
|
1930
|
+
interface TelemetrySample {
|
|
1931
|
+
readonly type: string;
|
|
1932
|
+
readonly value?: number;
|
|
1933
|
+
readonly transport?: TransportLabel;
|
|
1934
|
+
}
|
|
1935
|
+
interface P2pApiOptions {
|
|
1936
|
+
readonly client: GemClient;
|
|
1937
|
+
readonly gameId: () => string;
|
|
1938
|
+
}
|
|
1939
|
+
interface JoinCredential {
|
|
1940
|
+
readonly credential: string;
|
|
1941
|
+
readonly hostFingerprint: string;
|
|
1942
|
+
readonly hostEpoch: number;
|
|
1943
|
+
readonly expiresAt: number;
|
|
1944
|
+
}
|
|
1945
|
+
interface IceServer {
|
|
1946
|
+
readonly urls: readonly string[];
|
|
1947
|
+
readonly username: string;
|
|
1948
|
+
readonly credential: string;
|
|
1949
|
+
}
|
|
1950
|
+
interface TurnLease {
|
|
1951
|
+
readonly iceServers: readonly IceServer[];
|
|
1952
|
+
readonly expiresAt: number;
|
|
1953
|
+
}
|
|
1954
|
+
type P2pTelemetryEvent = TelemetrySample;
|
|
1955
|
+
declare class P2pApi {
|
|
1956
|
+
private readonly options;
|
|
1957
|
+
private readonly reporter;
|
|
1958
|
+
constructor(options: P2pApiOptions);
|
|
1959
|
+
joinCredential(matchId: string, fingerprint: string, signal?: AbortSignal): Promise<JoinCredential>;
|
|
1960
|
+
turnLease(matchId: string, clusterTargetId: string, signal?: AbortSignal): Promise<TurnLease>;
|
|
1961
|
+
kick(matchId: string, playerId: string, signal?: AbortSignal): Promise<void>;
|
|
1962
|
+
leave(matchId: string, keepalive?: boolean): Promise<void>;
|
|
1963
|
+
telemetry(events: readonly P2pTelemetryEvent[], signal?: AbortSignal): Promise<void>;
|
|
1964
|
+
private match;
|
|
1965
|
+
}
|
|
1966
|
+
type P2pFailure = "timeout" | "aborted" | "unsupported_protocol" | "signaling_unavailable" | "signaling_failed" | "invalid_sdp" | "media_refused" | "peer_unauthenticated" | "not_expected_player" | "keys_unavailable" | "migration_failed" | "kicked" | "match_ended" | "connection_failed" | "misconfigured";
|
|
1967
|
+
declare class P2pError extends Error {
|
|
1968
|
+
readonly reason: P2pFailure;
|
|
1969
|
+
readonly retryable: boolean;
|
|
1970
|
+
constructor(reason: P2pFailure, message: string, options?: {
|
|
1971
|
+
cause?: unknown;
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
interface P2pEventMap {
|
|
1975
|
+
peerJoined: [
|
|
1976
|
+
P2pPeer
|
|
1977
|
+
];
|
|
1978
|
+
peerLeft: [
|
|
1979
|
+
string,
|
|
1980
|
+
string
|
|
1981
|
+
];
|
|
1982
|
+
migrating: [
|
|
1983
|
+
string,
|
|
1984
|
+
number
|
|
1985
|
+
];
|
|
1986
|
+
hostChanged: [
|
|
1987
|
+
string,
|
|
1988
|
+
number
|
|
1989
|
+
];
|
|
1990
|
+
matchEnded: [
|
|
1991
|
+
string
|
|
1992
|
+
];
|
|
1993
|
+
candidatesDropped: [
|
|
1994
|
+
number
|
|
1995
|
+
];
|
|
1996
|
+
error: [
|
|
1997
|
+
P2pError
|
|
1998
|
+
];
|
|
1999
|
+
}
|
|
2000
|
+
type P2pEventName = keyof P2pEventMap;
|
|
2001
|
+
interface KeySource {
|
|
2002
|
+
key(kid: string): Promise<CryptoKey | null>;
|
|
2003
|
+
}
|
|
2004
|
+
interface SignalTransport {
|
|
2005
|
+
signal(signal: string, matchId: string, data: Record<string, unknown>): void;
|
|
2006
|
+
parentSupports(capability: string): boolean;
|
|
2007
|
+
}
|
|
2008
|
+
interface SignalingOptions {
|
|
2009
|
+
readonly bridge: SignalTransport;
|
|
2010
|
+
readonly matchId: string;
|
|
2011
|
+
readonly clock: {
|
|
2012
|
+
now(): number;
|
|
2013
|
+
setTimeout(fn: () => void, ms: number): unknown;
|
|
2014
|
+
clearTimeout(handle: unknown): void;
|
|
2015
|
+
};
|
|
2016
|
+
readonly maxQueuedCandidates?: number;
|
|
2017
|
+
readonly candidateIntervalMs?: number;
|
|
2018
|
+
readonly onCandidatesDropped?: (dropped: number) => void;
|
|
2019
|
+
}
|
|
2020
|
+
declare class SignalingClient {
|
|
2021
|
+
private readonly options;
|
|
2022
|
+
private readonly queue;
|
|
2023
|
+
private drainHandle;
|
|
2024
|
+
private dropped;
|
|
2025
|
+
private closed;
|
|
2026
|
+
private dropListener;
|
|
2027
|
+
constructor(options: SignalingOptions);
|
|
2028
|
+
onDropped(listener: (dropped: number) => void): void;
|
|
2029
|
+
join(): void;
|
|
2030
|
+
offer(sdp: string, intent: "initial" | "ice_restart" | "full_reconnect"): void;
|
|
2031
|
+
answer(peerId: string, sdp: string, assignedPeerId: number): void;
|
|
2032
|
+
candidate(peerId: string, candidate: string, sdpMid?: string, sdpMLineIndex?: number): void;
|
|
2033
|
+
migrationAck(hostEpoch: number): void;
|
|
2034
|
+
reportHostUnreachable(hostEpoch: number, iceState: "disconnected" | "failed" | "closed"): void;
|
|
2035
|
+
discardQueued(): void;
|
|
2036
|
+
close(): void;
|
|
2037
|
+
private assertUsable;
|
|
2038
|
+
private schedule;
|
|
2039
|
+
}
|
|
2040
|
+
type SdpType = "offer" | "answer" | "pranswer" | "rollback";
|
|
2041
|
+
interface SessionDescriptionLike {
|
|
2042
|
+
readonly type: SdpType;
|
|
2043
|
+
readonly sdp?: string;
|
|
2044
|
+
}
|
|
2045
|
+
interface IceCandidateLike {
|
|
2046
|
+
readonly candidate: string;
|
|
2047
|
+
readonly sdpMid?: string | null;
|
|
2048
|
+
readonly sdpMLineIndex?: number | null;
|
|
2049
|
+
}
|
|
2050
|
+
interface EventTargetLike {
|
|
2051
|
+
addEventListener(type: string, listener: (event: never) => void): void;
|
|
2052
|
+
removeEventListener(type: string, listener: (event: never) => void): void;
|
|
2053
|
+
}
|
|
2054
|
+
interface DataChannelLike extends EventTargetLike {
|
|
2055
|
+
readonly readyState: string;
|
|
2056
|
+
readonly label: string;
|
|
2057
|
+
binaryType: string;
|
|
2058
|
+
send(data: string | ArrayBuffer): void;
|
|
2059
|
+
close(): void;
|
|
2060
|
+
}
|
|
2061
|
+
interface DataChannelInitLike {
|
|
2062
|
+
readonly ordered?: boolean;
|
|
2063
|
+
readonly maxRetransmits?: number;
|
|
2064
|
+
readonly negotiated?: boolean;
|
|
2065
|
+
readonly id?: number;
|
|
2066
|
+
}
|
|
2067
|
+
interface PeerConnectionLike extends EventTargetLike {
|
|
2068
|
+
readonly localDescription: SessionDescriptionLike | null;
|
|
2069
|
+
readonly remoteDescription: SessionDescriptionLike | null;
|
|
2070
|
+
readonly iceConnectionState: string;
|
|
2071
|
+
readonly connectionState: string;
|
|
2072
|
+
createDataChannel(label: string, init?: DataChannelInitLike): DataChannelLike;
|
|
2073
|
+
createOffer(): Promise<SessionDescriptionLike>;
|
|
2074
|
+
createAnswer(): Promise<SessionDescriptionLike>;
|
|
2075
|
+
setLocalDescription(description?: SessionDescriptionLike): Promise<void>;
|
|
2076
|
+
setRemoteDescription(description: SessionDescriptionLike): Promise<void>;
|
|
2077
|
+
addIceCandidate(candidate: IceCandidateLike): Promise<void>;
|
|
2078
|
+
close(): void;
|
|
2079
|
+
}
|
|
2080
|
+
interface PeerConnectionConfig {
|
|
2081
|
+
readonly iceServers: readonly {
|
|
2082
|
+
urls: readonly string[];
|
|
2083
|
+
username?: string;
|
|
2084
|
+
credential?: string;
|
|
2085
|
+
}[];
|
|
2086
|
+
readonly certificates?: readonly unknown[];
|
|
2087
|
+
}
|
|
2088
|
+
type PeerConnectionFactory = (config: PeerConnectionConfig) => PeerConnectionLike;
|
|
2089
|
+
type ChannelKind = "reliable" | "ordered" | "unreliable";
|
|
2090
|
+
declare class CredentialPacing {
|
|
2091
|
+
private readonly perMinute;
|
|
2092
|
+
private readonly sent;
|
|
2093
|
+
constructor(perMinute?: number);
|
|
2094
|
+
delayUntilAllowed(now: number): number;
|
|
2095
|
+
record(now: number): void;
|
|
2096
|
+
private prune;
|
|
2097
|
+
}
|
|
2098
|
+
interface P2pPeer {
|
|
2099
|
+
readonly playerId: string;
|
|
2100
|
+
readonly assignedPeerId: number;
|
|
2101
|
+
readonly connection: PeerConnectionLike;
|
|
2102
|
+
readonly channels: Readonly<Record<ChannelKind, DataChannelLike>>;
|
|
2103
|
+
send(data: string | ArrayBuffer, kind?: ChannelKind): void;
|
|
2104
|
+
}
|
|
2105
|
+
interface P2pSessionOptions {
|
|
2106
|
+
readonly api: P2pApi;
|
|
2107
|
+
readonly clock: Clock;
|
|
2108
|
+
readonly matchId: string;
|
|
2109
|
+
readonly gameId: string;
|
|
2110
|
+
readonly baseUrl: string;
|
|
2111
|
+
readonly signaling: SignalingClient;
|
|
2112
|
+
readonly clusterTargetId?: ClusterTargetLike;
|
|
2113
|
+
readonly peerConnectionFactory?: PeerConnectionFactory;
|
|
2114
|
+
readonly certificate?: unknown;
|
|
2115
|
+
readonly connectTimeoutMs?: number;
|
|
2116
|
+
readonly keys?: KeySource;
|
|
2117
|
+
readonly boot?: BootTimeline;
|
|
2118
|
+
readonly log?: ((message: string) => void) | null;
|
|
2119
|
+
readonly credentialPacing?: CredentialPacing;
|
|
2120
|
+
}
|
|
2121
|
+
declare class P2pSession {
|
|
2122
|
+
private readonly options;
|
|
2123
|
+
private readonly emitter;
|
|
2124
|
+
private readonly links;
|
|
2125
|
+
private readonly replays;
|
|
2126
|
+
private readonly keys;
|
|
2127
|
+
private localPlayerId;
|
|
2128
|
+
private migration;
|
|
2129
|
+
private iceServers;
|
|
2130
|
+
private credential;
|
|
2131
|
+
private nextPeerId;
|
|
2132
|
+
private ended;
|
|
2133
|
+
private closed;
|
|
2134
|
+
private ready;
|
|
2135
|
+
private helloSeen;
|
|
2136
|
+
private reportedUnreachableEpoch;
|
|
2137
|
+
private reportedStallEpoch;
|
|
2138
|
+
private counted;
|
|
2139
|
+
private readonly pendingOffers;
|
|
2140
|
+
private readonly answeredSessions;
|
|
2141
|
+
private credentialGeneration;
|
|
2142
|
+
private credentialDeadline;
|
|
2143
|
+
constructor(options: P2pSessionOptions);
|
|
2144
|
+
get matchId(): string;
|
|
2145
|
+
get playerId(): string;
|
|
2146
|
+
get isHost(): boolean;
|
|
2147
|
+
get hostPlayerId(): string;
|
|
2148
|
+
get hostEpoch(): number;
|
|
2149
|
+
get peers(): readonly P2pPeer[];
|
|
2150
|
+
peer(playerId: string): P2pPeer | null;
|
|
2151
|
+
on<K extends P2pEventName>(event: K, listener: (...args: P2pEventMap[K]) => void): () => void;
|
|
2152
|
+
off<K extends P2pEventName>(event: K, listener: (...args: P2pEventMap[K]) => void): void;
|
|
2153
|
+
once<K extends P2pEventName>(event: K, listener: (...args: P2pEventMap[K]) => void): () => void;
|
|
2154
|
+
start(signal?: AbortSignal): Promise<void>;
|
|
2155
|
+
kick(playerId: string): Promise<void>;
|
|
2156
|
+
leave(): Promise<void>;
|
|
2157
|
+
close(): void;
|
|
2158
|
+
report(events: readonly TelemetrySample[]): void;
|
|
2159
|
+
notifyCandidatesDropped(dropped: number): void;
|
|
2160
|
+
handleSignal(event: string, data: Record<string, unknown>): void;
|
|
2161
|
+
private route;
|
|
2162
|
+
private onHello;
|
|
2163
|
+
private drainPendingOffers;
|
|
2164
|
+
private offerToHost;
|
|
2165
|
+
private fetchCredential;
|
|
2166
|
+
private waitForCredential;
|
|
2167
|
+
private onOffer;
|
|
2168
|
+
private onAnswer;
|
|
2169
|
+
private hostVerified;
|
|
2170
|
+
private maybeAuthenticate;
|
|
2171
|
+
private applyAnswer;
|
|
2172
|
+
private onIce;
|
|
2173
|
+
private onPeerLeft;
|
|
2174
|
+
private onMigration;
|
|
2175
|
+
private watchMigration;
|
|
2176
|
+
private onMatchEnded;
|
|
2177
|
+
private onSignalingError;
|
|
2178
|
+
private openLink;
|
|
2179
|
+
private flushCandidates;
|
|
2180
|
+
private onReliableOpen;
|
|
2181
|
+
private onHandshakeMessage;
|
|
2182
|
+
private admit;
|
|
2183
|
+
private refuseLink;
|
|
2184
|
+
private finishAdmission;
|
|
2185
|
+
private onIceState;
|
|
2186
|
+
private onConnectionState;
|
|
2187
|
+
private expose;
|
|
2188
|
+
private dropLink;
|
|
2189
|
+
private settle;
|
|
2190
|
+
private fail;
|
|
2191
|
+
private report_;
|
|
2192
|
+
private count;
|
|
2193
|
+
private refuseMedia;
|
|
2194
|
+
private mark;
|
|
2195
|
+
private sleep;
|
|
2196
|
+
private warn;
|
|
2197
|
+
get endedReason(): string | null;
|
|
2198
|
+
}
|
|
2199
|
+
interface P2pConnectOptions {
|
|
2200
|
+
readonly clusterTargetId?: ClusterTargetLike;
|
|
2201
|
+
readonly timeoutMs?: number;
|
|
2202
|
+
readonly signal?: AbortSignal;
|
|
2203
|
+
readonly peerConnectionFactory?: PeerConnectionFactory;
|
|
2204
|
+
readonly certificate?: unknown;
|
|
2205
|
+
}
|
|
2206
|
+
interface P2pMatchApi {
|
|
2207
|
+
connect(options?: P2pConnectOptions): Promise<P2pSession>;
|
|
2208
|
+
handleSignalEvent(matchId: string, event: string, data: Record<string, unknown>): void;
|
|
2209
|
+
session(matchId: string): P2pSession | null;
|
|
2210
|
+
}
|
|
2211
|
+
type RoomArgValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
|
|
2212
|
+
interface ServerTokenGrant {
|
|
2213
|
+
readonly token: string;
|
|
2214
|
+
readonly expiresAt: number;
|
|
2215
|
+
}
|
|
2216
|
+
interface ServerBundleHost {
|
|
2217
|
+
readonly matchId: string;
|
|
2218
|
+
readonly gameId: string;
|
|
2219
|
+
readonly channel: string;
|
|
2220
|
+
readonly gameRoomId?: string;
|
|
2221
|
+
readonly apiBaseUrl?: string;
|
|
2222
|
+
serverToken?(): ServerTokenGrant | undefined;
|
|
2223
|
+
onServerToken?(listener: (grant: ServerTokenGrant) => void): () => void;
|
|
2224
|
+
}
|
|
2225
|
+
interface SendOptions {
|
|
2226
|
+
readonly reliable?: boolean;
|
|
2227
|
+
readonly ordered?: boolean;
|
|
2228
|
+
}
|
|
2229
|
+
interface BroadcastOptions extends SendOptions {
|
|
2230
|
+
readonly except?: string;
|
|
2231
|
+
}
|
|
2232
|
+
interface GemServerHostProfile {
|
|
2233
|
+
readonly displayName?: string;
|
|
2234
|
+
readonly displayTag?: string;
|
|
2235
|
+
readonly discriminator?: string;
|
|
2236
|
+
}
|
|
2237
|
+
interface GemServerHost extends ServerBundleHost {
|
|
2238
|
+
readonly sizeClass: string;
|
|
2239
|
+
readonly roomArgs?: Readonly<Record<string, RoomArgValue>>;
|
|
2240
|
+
readonly roster: readonly string[];
|
|
2241
|
+
players(): string[];
|
|
2242
|
+
profile?(playerId: string): GemServerHostProfile | undefined;
|
|
2243
|
+
playerNumber?(playerId: string): number | undefined;
|
|
2244
|
+
send(playerId: string, data: string | Uint8Array, options?: SendOptions): void;
|
|
2245
|
+
broadcast(data: string | Uint8Array, options?: BroadcastOptions): void;
|
|
2246
|
+
kick(playerId: string, reason?: string): void;
|
|
2247
|
+
endMatch?(): Promise<"ok" | "already_ended" | "refused" | "failed" | (string & {})>;
|
|
2248
|
+
log(message: string): void;
|
|
2249
|
+
warn(message: string): void;
|
|
2250
|
+
}
|
|
2251
|
+
interface GemServerBundle {
|
|
2252
|
+
init?(): void | Promise<void>;
|
|
2253
|
+
join?(playerId: string, meta?: {
|
|
2254
|
+
playerNumber?: number;
|
|
2255
|
+
transport?: string;
|
|
2256
|
+
rejoin?: boolean;
|
|
2257
|
+
superseded?: boolean;
|
|
2258
|
+
}): void | Promise<void>;
|
|
2259
|
+
leave?(playerId: string, meta?: {
|
|
2260
|
+
cause?: string;
|
|
2261
|
+
}): void | Promise<void>;
|
|
2262
|
+
message?(playerId: string, data: string | Uint8Array, isText: boolean, meta?: {
|
|
2263
|
+
reliable?: boolean;
|
|
2264
|
+
ordered?: boolean;
|
|
2265
|
+
sessionId?: number;
|
|
2266
|
+
playerNumber?: number;
|
|
2267
|
+
}): void | Promise<void>;
|
|
2268
|
+
shutdown?(info?: ServerShutdownInfo): void | Promise<void>;
|
|
2269
|
+
}
|
|
2270
|
+
interface ServerShutdownInfo {
|
|
2271
|
+
readonly reason: "match_ended" | "idle_timeout" | "signal" | (string & {});
|
|
2272
|
+
readonly endedReason?: string;
|
|
2273
|
+
}
|
|
2274
|
+
interface GemServerLifecycle {
|
|
2275
|
+
init(host: GemServerHost): Promise<void>;
|
|
2276
|
+
join?(playerId: string, meta?: {
|
|
2277
|
+
playerNumber?: number;
|
|
2278
|
+
transport?: string;
|
|
2279
|
+
rejoin?: boolean;
|
|
2280
|
+
superseded?: boolean;
|
|
2281
|
+
}): void | Promise<void>;
|
|
2282
|
+
leave?(playerId: string, meta?: {
|
|
2283
|
+
cause?: string;
|
|
2284
|
+
}): void | Promise<void>;
|
|
2285
|
+
message?(playerId: string, data: string | Uint8Array, isText: boolean, meta?: {
|
|
2286
|
+
reliable?: boolean;
|
|
2287
|
+
ordered?: boolean;
|
|
2288
|
+
sessionId?: number;
|
|
2289
|
+
playerNumber?: number;
|
|
2290
|
+
}): void | Promise<void>;
|
|
2291
|
+
shutdown(info?: RuntimeShutdownPayload): Promise<void>;
|
|
2292
|
+
}
|
|
2293
|
+
interface RuntimeShutdownPayload {
|
|
2294
|
+
readonly reason?: string;
|
|
2295
|
+
readonly platform_reason?: string;
|
|
2296
|
+
readonly endedReason?: string;
|
|
2297
|
+
}
|
|
2298
|
+
type GemServerFactory = () => GemServerLifecycle;
|
|
2299
|
+
type GemMatchServerModule = GemServerFactory | GemServerLifecycle;
|
|
2300
|
+
interface MatchServeOptions {
|
|
2301
|
+
readonly timeoutMs?: number;
|
|
2302
|
+
readonly signal?: AbortSignal;
|
|
2303
|
+
readonly clusterTargetId?: ClusterTargetLike;
|
|
2304
|
+
}
|
|
2305
|
+
interface MatchConnectOptions extends MatchServeOptions {
|
|
2306
|
+
readonly transports?: readonly TransportKind[];
|
|
2307
|
+
readonly onMatchEnded?: (reason?: string) => void;
|
|
2308
|
+
}
|
|
2309
|
+
type MatchHostingMode = "listen" | "dedicated" | "peer";
|
|
2310
|
+
interface MatchHosting {
|
|
2311
|
+
readonly mode: MatchHostingMode;
|
|
2312
|
+
readonly matchId: string;
|
|
2313
|
+
end(): Promise<void>;
|
|
2314
|
+
leave(): Promise<void>;
|
|
2315
|
+
stop(): Promise<void>;
|
|
2316
|
+
}
|
|
2317
|
+
interface MatchConnection {
|
|
2318
|
+
readonly matchId: string;
|
|
2319
|
+
readonly protocol: "dedicated" | "p2p" | "loopback";
|
|
2320
|
+
readonly transport?: TransportKind;
|
|
2321
|
+
send(data: string | Uint8Array, options?: SendOptions$1): void;
|
|
2322
|
+
onMessage(handler: (data: string | Uint8Array, meta: MessageMeta) => void): void;
|
|
2323
|
+
readonly state: "connected" | "suspended" | "closed";
|
|
2324
|
+
onClose(handler: (reason?: string) => void): void;
|
|
2325
|
+
close(): void;
|
|
2326
|
+
}
|
|
2327
|
+
interface GemMatchApi {
|
|
2328
|
+
serve(server: GemMatchServerModule, options?: MatchServeOptions): Promise<MatchHosting>;
|
|
2329
|
+
connect(options?: MatchConnectOptions): Promise<MatchConnection>;
|
|
2330
|
+
}
|
|
2331
|
+
interface PurchaseRequest {
|
|
2332
|
+
kind: "item" | "recipe";
|
|
2333
|
+
targetId: string;
|
|
2334
|
+
currencySlug: string;
|
|
2335
|
+
quantity?: number;
|
|
2336
|
+
catalogId?: string;
|
|
2337
|
+
}
|
|
2338
|
+
type PurchaseOutcome = {
|
|
2339
|
+
readonly outcome: "ok";
|
|
2340
|
+
readonly purchaseId?: string;
|
|
2341
|
+
} | {
|
|
2342
|
+
readonly outcome: "declined" | "unavailable";
|
|
2343
|
+
};
|
|
2344
|
+
interface PurchaseApi {
|
|
2345
|
+
request(req: PurchaseRequest): Promise<PurchaseOutcome>;
|
|
2346
|
+
}
|
|
2347
|
+
type SignInOutcomeKind = "signed_in" | "declined" | "unavailable";
|
|
2348
|
+
interface SignInOutcome {
|
|
2349
|
+
readonly outcome: SignInOutcomeKind;
|
|
2350
|
+
}
|
|
2351
|
+
interface AccountApi {
|
|
2352
|
+
requestSignIn(): Promise<SignInOutcome>;
|
|
2353
|
+
}
|
|
2354
|
+
type AdFormat = "interstitial" | "rewarded";
|
|
2355
|
+
interface AdRequest {
|
|
2356
|
+
placement: string;
|
|
2357
|
+
format: AdFormat;
|
|
2358
|
+
}
|
|
2359
|
+
type AdOutcomeKind = "shown" | "no_ad" | "unavailable";
|
|
2360
|
+
interface AdOutcome {
|
|
2361
|
+
readonly outcome: AdOutcomeKind;
|
|
2362
|
+
}
|
|
2363
|
+
interface AdsApi {
|
|
2364
|
+
requestAd(req: AdRequest): Promise<AdOutcome>;
|
|
2365
|
+
}
|
|
2366
|
+
type DeviceSettings = Readonly<Record<string, unknown>>;
|
|
2367
|
+
type DeviceSettingsPutOutcome = "stored" | "too_large" | "unavailable";
|
|
2368
|
+
interface DeviceSettingsApi {
|
|
2369
|
+
readonly current: DeviceSettings | null;
|
|
2370
|
+
wait(timeoutMs?: number): Promise<DeviceSettings | null>;
|
|
2371
|
+
put(settings: DeviceSettings): Promise<DeviceSettingsPutOutcome>;
|
|
2372
|
+
}
|
|
2373
|
+
interface RewardCue {
|
|
2374
|
+
currencySlug: string;
|
|
2375
|
+
expected?: number;
|
|
2376
|
+
origin?: {
|
|
2377
|
+
x: number;
|
|
2378
|
+
y: number;
|
|
2379
|
+
};
|
|
2380
|
+
}
|
|
2381
|
+
type FrameState = "waiting" | "connected" | "refused" | "closed";
|
|
2382
|
+
interface FrameCallbacks {
|
|
2383
|
+
onToken?(msg: GemToken): void;
|
|
2384
|
+
onPause?(msg: GemPause): void;
|
|
2385
|
+
onPrefs?(msg: GemPrefs$1): void;
|
|
2386
|
+
onCohorts?(msg: GemCohorts$1): void;
|
|
2387
|
+
onViewport?(msg: GemViewport$1): void;
|
|
2388
|
+
onWillTerminate?(msg: GemWillTerminate): void;
|
|
2389
|
+
onDevtools?(action: "open" | "close" | "toggle"): void;
|
|
2390
|
+
onScreenshot?(request: {
|
|
2391
|
+
maxWidth: number;
|
|
2392
|
+
maxHeight: number;
|
|
2393
|
+
}, port: MessagePort, deny: (reason: GemScreenshotDenied["reason"], retryable: boolean) => void): void;
|
|
2394
|
+
onRequestContext?(): void;
|
|
2395
|
+
onTokenDenied?(msg: GemTokenDenied): void;
|
|
2396
|
+
onLocalServer?(msg: GemLocalServer): void;
|
|
2397
|
+
onLocalServerDenied?(msg: GemLocalServerDenied): void;
|
|
2398
|
+
onPlayer?(player: {
|
|
2399
|
+
displayName: PlayerText;
|
|
2400
|
+
displayHandle: PlayerText;
|
|
2401
|
+
displayTag: string;
|
|
2402
|
+
avatarUrl?: string;
|
|
2403
|
+
}): void;
|
|
2404
|
+
onRoomEvent?(msg: GemRoomEvent): void;
|
|
2405
|
+
onSeatedEvent?(msg: GemSeatedEvent): void;
|
|
2406
|
+
onSocketState?(msg: GemSocketState): void;
|
|
2407
|
+
onSignalEvent?(msg: GemSignalEvent): void;
|
|
2408
|
+
onDedicatedEvent?(msg: GemDedicatedEvent): void;
|
|
2409
|
+
onClusterTarget?(msg: GemClusterTarget): void;
|
|
2410
|
+
onPartyResult?(msg: GemPartyResult): void;
|
|
2411
|
+
onPurchaseResult?(msg: GemPurchaseResult): void;
|
|
2412
|
+
onDeviceSettings?(msg: GemDeviceSettings): void;
|
|
2413
|
+
onDeviceSettingsResult?(msg: GemDeviceSettingsResult): void;
|
|
2414
|
+
onAdResult?(msg: GemAdResult): void;
|
|
2415
|
+
onSignInResult?(msg: GemSignInResult): void;
|
|
2416
|
+
onError?(code: GemErrorCode, message?: string): void;
|
|
2417
|
+
onDropped?(code: GemErrorCode, message?: string): void;
|
|
2418
|
+
onStateChange?(state: FrameState): void;
|
|
2419
|
+
onRefused?(reason: string): void;
|
|
2420
|
+
}
|
|
2421
|
+
interface FrameOptions extends FrameCallbacks {
|
|
2422
|
+
allowedEmbedders: readonly string[];
|
|
2423
|
+
selfOrigin?: string;
|
|
2424
|
+
expectedSource: unknown;
|
|
2425
|
+
capabilities?: readonly string[];
|
|
2426
|
+
clock?: Clock;
|
|
2427
|
+
}
|
|
2428
|
+
declare class GemFrame {
|
|
2429
|
+
private readonly options;
|
|
2430
|
+
private state;
|
|
2431
|
+
private port;
|
|
2432
|
+
private version;
|
|
2433
|
+
private peerCapabilities;
|
|
2434
|
+
private readyPending;
|
|
2435
|
+
private readySent;
|
|
2436
|
+
private settleWaiters;
|
|
2437
|
+
private readonly clock;
|
|
2438
|
+
private readonly inbound;
|
|
2439
|
+
private readonly outbound;
|
|
2440
|
+
private readonly expectedSource;
|
|
2441
|
+
constructor(options: FrameOptions);
|
|
2442
|
+
get currentState(): FrameState;
|
|
2443
|
+
get parentCapabilities(): readonly string[];
|
|
2444
|
+
parentSupports(capability: string): boolean;
|
|
2445
|
+
get protocolVersion(): number | null;
|
|
2446
|
+
handleWindowMessage(event: HandshakeEvent): boolean;
|
|
2447
|
+
ready(): void;
|
|
2448
|
+
settled(timeoutMs?: number): Promise<FrameState>;
|
|
2449
|
+
progress(loaded: number, total: number): void;
|
|
2450
|
+
requestToken(requestId: string, reason: "initial" | "expiring" | "rejected"): void;
|
|
2451
|
+
requestLocalServer(requestId: string, gameRoomId: string): boolean;
|
|
2452
|
+
exit(reason?: string): void;
|
|
2453
|
+
openExternal(url: string): void;
|
|
2454
|
+
requestFullscreen(enabled: boolean): void;
|
|
2455
|
+
reportMuted(muted: boolean): boolean;
|
|
2456
|
+
cueReward(cue: RewardCue): boolean;
|
|
2457
|
+
reportFrameStats(stats: {
|
|
2458
|
+
fps: number;
|
|
2459
|
+
frameTimeP95Ms: number;
|
|
2460
|
+
}): boolean;
|
|
2461
|
+
sendGameContext(context: Record<string, unknown>): boolean;
|
|
2462
|
+
signal(signal: string, matchId: string, data: Record<string, unknown>): void;
|
|
2463
|
+
dedicatedOffer(matchId: string, sdp: string, intent: GemDedicatedOffer["intent"]): void;
|
|
2464
|
+
requestParty(requestId: string): boolean;
|
|
2465
|
+
requestPurchase(requestId: string, purchaseKind: "item" | "recipe", targetId: string, currencySlug: string, quantity?: number, catalogId?: string): boolean;
|
|
2466
|
+
putDeviceSettings(requestId: string, settings: Readonly<Record<string, unknown>>): boolean;
|
|
2467
|
+
requestAd(requestId: string, placement: string, format: "interstitial" | "rewarded"): boolean;
|
|
2468
|
+
requestSignIn(requestId: string): boolean;
|
|
2469
|
+
close(): void;
|
|
2470
|
+
private transition;
|
|
2471
|
+
private refuseMalformed;
|
|
2472
|
+
private dropUnknownType;
|
|
2473
|
+
private refuse;
|
|
2474
|
+
private fail;
|
|
2475
|
+
private send;
|
|
2476
|
+
private receive;
|
|
2477
|
+
private dispatchInbound;
|
|
2478
|
+
private screenshotDenied;
|
|
2479
|
+
}
|
|
2480
|
+
declare const DEVICE_SETTINGS_MAX_BYTES = 16384;
|
|
2481
|
+
interface GemOptions {
|
|
2482
|
+
readonly allowedEmbedders?: readonly string[];
|
|
2483
|
+
readonly baseUrl?: string;
|
|
2484
|
+
readonly clock?: Clock;
|
|
2485
|
+
readonly onAuthStateChange?: (state: AuthState, reason?: AuthFailure) => void;
|
|
2486
|
+
readonly onDevToolsPermissionChange?: (canOpen: boolean) => void;
|
|
2487
|
+
readonly log?: ((message: string) => void) | null;
|
|
2488
|
+
readonly clientVersion?: ClientVersion;
|
|
2489
|
+
readonly pollRooms?: boolean;
|
|
2490
|
+
readonly recoverStaleMembership?: boolean;
|
|
2491
|
+
readonly watchSeats?: boolean;
|
|
2492
|
+
readonly seatPollIntervalMs?: number;
|
|
2493
|
+
readonly autoReconnect?: AutoReconnectOptions | false;
|
|
2494
|
+
readonly onRefused?: (reason: string) => void;
|
|
2495
|
+
readonly onError?: (code: GemErrorCode, message?: string) => void;
|
|
2496
|
+
readonly onStateChange?: (state: FrameState) => void;
|
|
2497
|
+
readonly onPlayer?: (player: GemPlayer) => void;
|
|
2498
|
+
readonly onPrefs?: (prefs: GemPrefs) => void;
|
|
2499
|
+
readonly onCohorts?: (cohorts: GemCohorts) => void;
|
|
2500
|
+
readonly onDeviceSettings?: (settings: DeviceSettings | null) => void;
|
|
2501
|
+
readonly onViewport?: (viewport: GemViewport) => void;
|
|
2502
|
+
readonly manageAudio?: boolean;
|
|
2503
|
+
readonly onPause?: (paused: boolean) => void;
|
|
2504
|
+
readonly onWillTerminate?: (notice: GemTerminationNotice) => void;
|
|
2505
|
+
readonly analytics?: AnalyticsOptions;
|
|
2506
|
+
readonly onFeedbackContext?: () => Record<string, unknown> | null | Promise<Record<string, unknown> | null>;
|
|
2507
|
+
readonly onScreenshot?: (request: {
|
|
2508
|
+
readonly maxWidth: number;
|
|
2509
|
+
readonly maxHeight: number;
|
|
2510
|
+
}) => Promise<ImageBitmap | null>;
|
|
2511
|
+
readonly handshakeWarningMs?: number | null;
|
|
2512
|
+
}
|
|
2513
|
+
interface GemPlayer {
|
|
2514
|
+
readonly displayName: PlayerText;
|
|
2515
|
+
readonly displayHandle: PlayerText;
|
|
2516
|
+
readonly displayTag: string;
|
|
2517
|
+
readonly avatarUrl?: string;
|
|
2518
|
+
}
|
|
2519
|
+
interface GemPrefs {
|
|
2520
|
+
readonly reducedMotion: boolean;
|
|
2521
|
+
readonly muted: boolean;
|
|
2522
|
+
readonly showFrameStats: boolean;
|
|
2523
|
+
readonly locale: string;
|
|
2524
|
+
}
|
|
2525
|
+
interface GemCohort {
|
|
2526
|
+
readonly experimentId: string;
|
|
2527
|
+
readonly variantKey: string;
|
|
2528
|
+
}
|
|
2529
|
+
type GemCohorts = readonly GemCohort[];
|
|
2530
|
+
interface GemInsets {
|
|
2531
|
+
readonly top: number;
|
|
2532
|
+
readonly right: number;
|
|
2533
|
+
readonly bottom: number;
|
|
2534
|
+
readonly left: number;
|
|
2535
|
+
}
|
|
2536
|
+
interface GemViewport {
|
|
2537
|
+
readonly insets: GemInsets;
|
|
2538
|
+
}
|
|
2539
|
+
interface GemTerminationNotice {
|
|
2540
|
+
readonly reason: GemWillTerminate["reason"];
|
|
2541
|
+
readonly graceMs: number;
|
|
2542
|
+
}
|
|
2543
|
+
interface GemIdentity {
|
|
2544
|
+
readonly playerId: string;
|
|
2545
|
+
readonly gameId: string;
|
|
2546
|
+
readonly channel: string;
|
|
2547
|
+
}
|
|
2548
|
+
interface Gem {
|
|
2549
|
+
readonly client: GemClient;
|
|
2550
|
+
readonly identity: GemIdentity | null;
|
|
2551
|
+
awaitIdentity(timeoutMs?: number): Promise<GemIdentity>;
|
|
2552
|
+
awaitBridge(timeoutMs?: number): Promise<FrameState | null>;
|
|
2553
|
+
readonly player: GemPlayer | null;
|
|
2554
|
+
readonly me: EntityScope;
|
|
2555
|
+
readonly characters: CharactersApi;
|
|
2556
|
+
readonly transfers: TransfersApi;
|
|
2557
|
+
readonly gameConfig: GameConfigApi;
|
|
2558
|
+
readonly purchases: PurchaseApi;
|
|
2559
|
+
readonly deviceSettings: DeviceSettingsApi;
|
|
2560
|
+
readonly ads: AdsApi;
|
|
2561
|
+
readonly account: AccountApi;
|
|
2562
|
+
readonly analytics: AnalyticsApi;
|
|
2563
|
+
readonly leaderboards: LeaderboardsApi;
|
|
2564
|
+
readonly challenges: ChallengesApi;
|
|
2565
|
+
readonly showcase: ShowcaseApi;
|
|
2566
|
+
readonly friends: FriendsApi;
|
|
2567
|
+
readonly platform: PlatformApi;
|
|
2568
|
+
readonly profiles: ProfilesApi;
|
|
2569
|
+
awaitPlayer(timeoutMs?: number): Promise<GemPlayer | null>;
|
|
2570
|
+
readonly prefs: GemPrefs | null;
|
|
2571
|
+
readonly cohorts: GemCohorts | null;
|
|
2572
|
+
readonly viewport: GemViewport | null;
|
|
2573
|
+
awaitCohorts(timeoutMs?: number): Promise<GemCohorts | null>;
|
|
2574
|
+
reportMuted(muted: boolean): void;
|
|
2575
|
+
cueReward(cue: RewardCue): boolean;
|
|
2576
|
+
exit(reason?: string): Promise<void>;
|
|
2577
|
+
readonly boot: BootTimeline;
|
|
2578
|
+
readonly frame: GemFrame;
|
|
2579
|
+
readonly devtools: GemDevTools;
|
|
2580
|
+
readonly rooms: RoomManager;
|
|
2581
|
+
readonly dedicatedServer: DedicatedServerApi;
|
|
2582
|
+
readonly p2p: P2pMatchApi;
|
|
2583
|
+
readonly match: GemMatchApi;
|
|
2584
|
+
}
|
|
2585
|
+
interface ExitBridge {
|
|
2586
|
+
readonly currentState: FrameState;
|
|
2587
|
+
exit(reason?: string): void;
|
|
2588
|
+
}
|
|
2589
|
+
interface ExitRooms {
|
|
2590
|
+
readonly isInRoom: boolean;
|
|
2591
|
+
leave(options?: {
|
|
2592
|
+
asGroup?: boolean;
|
|
2593
|
+
keepalive?: boolean;
|
|
2594
|
+
}): Promise<void>;
|
|
2595
|
+
}
|
|
2596
|
+
interface ExitAnalytics {
|
|
2597
|
+
endSession(reason: "session_ended"): void;
|
|
2598
|
+
}
|
|
2599
|
+
declare function leaveAndExit(rooms: ExitRooms, bridge: ExitBridge | null, reason?: string, analytics?: ExitAnalytics): Promise<void>;
|
|
2600
|
+
declare function createGem(options?: GemOptions): Gem;
|
|
2601
|
+
export { type AccountApi, type AdFormat, type AdOutcome, type AdOutcomeKind, type AdRequest, type AdsApi, AnalyticsApi, type AnalyticsFlushOptions, type AnalyticsFlushResult, type AnalyticsOptions, type AnalyticsRejection, type AnalyticsValue, AuthError, type AuthFailure, type AuthState, type BootMark, type BootTimeline, type Challenge, type ChallengeWindow, ChallengesApi, type ConfiguredPurchasePayment, type ConfiguredPurchaseRequest, type ConfiguredPurchaseResult, DEVICE_SETTINGS_MAX_BYTES, DedicatedServerError, type DedicatedServerFailure, type DedicatedServerSession, type DevToolsOpener, type DeviceSettings, type DeviceSettingsApi, type DeviceSettingsPutOutcome, type DirectPurchaseRequest, type DirectPurchaseResult, type EntityLeaderboard, type EntityLeaderboardEntry, type EntityLeaderboardOptions, type EntityType, type ExitAnalytics, type ExitBridge, type ExitRooms, type FrameState, type Friend, FriendsApi, type FriendsPage, type GameConfig, type GameServerLink, type Gem, GemApiError, GemClient, type GemCohort, type GemCohorts, GemConfigError, type GemDevTools, GemFrame, type GemIdentity, type GemInsets, type GemMatchApi, type GemMatchServerModule, type GemOptions, type GemPlayer, type GemPrefs, GemSaveError, type GemServerBundle, type GemServerFactory, type GemServerHost, type GemServerHostProfile, type GemServerLifecycle, type GemTerminationNotice, type GemViewport, type GetLeaderboardOptions, type JoinWelcome, type Leaderboard, type LeaderboardEntry, LeaderboardsApi, type ListChallengesOptions, type ListFriendsOptions, MAX_PERIODS_BACK, type MatchConnectOptions, type MatchConnection, type MatchHosting, type MatchHostingMode, type MatchServeOptions, type MatchTransport, type MessageMeta, type MultiTransportSession, PLATFORM_EVENTS, PlatformApi, PlatformCurrenciesApi, type PlatformCurrency, type PlatformCurrencyAccess, type PlatformCurrencyPurchasePayment, type PlatformCurrencyPurchaseRequest, type PlatformCurrencyPurchaseResult, type PlatformCurrencyReadOptions, type PlatformEventName, type PlayerProfile, PlayerText, type ProfileCallOptions, type ProfileShowcaseEntry, ProfilesApi, type PurchaseApi, type PurchaseOptions, type PurchaseOutcome, type PurchaseRequest, type PutBytesOptions, type PutSaveOptions, type RankedRow, type RewardCue, type SavePage, type SaveRecord, type SendOptions$1 as SendOptions, type ServerTokenGrant, type SessionEndReason, ShowcaseApi, type ShowcaseCallOptions, type ShowcaseFriendEntry, type ShowcaseFriends, type ShowcaseValue, type SignInOutcome, type SignInOutcomeKind, type SnapshotCurrency, type SnapshotItem, type TransportAdvert, type TransportKind, TransportRefusal, UNRELIABLE_CHANNEL_LABEL, asPlayerText, createBootTimeline, createGem, leaveAndExit, markOnResolve, presentJoinCredential, readTemplateTransports, readTransportAdvert, reportOnResolve, text, webTransportAvailable };
|