@crowdedkingdomstudios/crowdyjs 5.1.0 → 5.2.1
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/MIGRATION.md +64 -0
- package/README.md +19 -0
- package/dist/client.d.ts +98 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +74 -5
- package/dist/crowdy-client.d.ts +31 -0
- package/dist/crowdy-client.d.ts.map +1 -1
- package/dist/crowdy-client.js +8 -0
- package/dist/domains/actors.d.ts +88 -5
- package/dist/domains/actors.d.ts.map +1 -1
- package/dist/domains/actors.js +89 -6
- package/dist/domains/apps.d.ts +95 -41
- package/dist/domains/apps.d.ts.map +1 -1
- package/dist/domains/apps.js +80 -33
- package/dist/domains/auth.d.ts +139 -19
- package/dist/domains/auth.d.ts.map +1 -1
- package/dist/domains/auth.js +137 -17
- package/dist/domains/channels.d.ts +264 -5
- package/dist/domains/channels.d.ts.map +1 -1
- package/dist/domains/channels.js +264 -5
- package/dist/domains/chunks.d.ts +116 -3
- package/dist/domains/chunks.d.ts.map +1 -1
- package/dist/domains/chunks.js +116 -3
- package/dist/domains/gameModel.d.ts +412 -6
- package/dist/domains/gameModel.d.ts.map +1 -1
- package/dist/domains/gameModel.js +412 -6
- package/dist/domains/platform.d.ts +36 -20
- package/dist/domains/platform.d.ts.map +1 -1
- package/dist/domains/platform.js +29 -18
- package/dist/domains/serverStatus.d.ts +74 -6
- package/dist/domains/serverStatus.d.ts.map +1 -1
- package/dist/domains/serverStatus.js +74 -6
- package/dist/domains/state.d.ts +50 -2
- package/dist/domains/state.d.ts.map +1 -1
- package/dist/domains/state.js +50 -2
- package/dist/domains/teams.d.ts +265 -7
- package/dist/domains/teams.d.ts.map +1 -1
- package/dist/domains/teams.js +267 -9
- package/dist/domains/teleport.d.ts +30 -2
- package/dist/domains/teleport.d.ts.map +1 -1
- package/dist/domains/teleport.js +30 -2
- package/dist/domains/udp.d.ts +341 -5
- package/dist/domains/udp.d.ts.map +1 -1
- package/dist/domains/udp.js +341 -5
- package/dist/domains/users.d.ts +42 -11
- package/dist/domains/users.d.ts.map +1 -1
- package/dist/domains/users.js +41 -10
- package/dist/domains/voxels.d.ts +107 -2
- package/dist/domains/voxels.d.ts.map +1 -1
- package/dist/domains/voxels.js +107 -2
- package/dist/errors.d.ts +116 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +100 -0
- package/dist/generated/graphql.d.ts +1787 -110
- package/dist/generated/graphql.d.ts.map +1 -1
- package/dist/generated/graphql.js +75 -9
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/realtime.d.ts +226 -0
- package/dist/realtime.d.ts.map +1 -1
- package/dist/realtime.js +90 -0
- package/dist/session.d.ts +46 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +35 -0
- package/dist/types.d.ts +429 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +53 -0
- package/dist/utils.d.ts +86 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +86 -0
- package/dist/world.d.ts +192 -0
- package/dist/world.d.ts.map +1 -1
- package/dist/world.js +170 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,229 +1,658 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Type definitions for Crowded Kingdoms SDK
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* A GraphQL `BigInt` scalar as carried by the SDK: the **decimal-string**
|
|
6
|
+
* representation of a 64-bit integer (e.g. `"1"`, `"9223372036854775807"`).
|
|
7
|
+
* Ids and coordinates that can exceed JavaScript's safe-integer range use this
|
|
8
|
+
* so they are never lossy; parse with the native `BigInt()` when you need to do
|
|
9
|
+
* arithmetic.
|
|
10
|
+
*/
|
|
4
11
|
export type BigInt = string;
|
|
12
|
+
/**
|
|
13
|
+
* Address of a chunk in the world grid as returned by the API. A chunk is a
|
|
14
|
+
* 16×16×16 voxel cube; each axis is a signed int64 carried as a {@link BigInt}
|
|
15
|
+
* decimal string.
|
|
16
|
+
*/
|
|
5
17
|
export interface ChunkCoordinates {
|
|
18
|
+
/** Chunk X coordinate (signed int64 as a decimal string). */
|
|
6
19
|
x: BigInt;
|
|
20
|
+
/** Chunk Y coordinate (signed int64 as a decimal string). */
|
|
7
21
|
y: BigInt;
|
|
22
|
+
/** Chunk Z coordinate (signed int64 as a decimal string). */
|
|
8
23
|
z: BigInt;
|
|
9
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Chunk address supplied as input, with each axis as a plain JavaScript
|
|
27
|
+
* `number`. Values must fall within signed int64 range — use
|
|
28
|
+
* {@link validateChunkCoordinates} to check before sending.
|
|
29
|
+
*/
|
|
10
30
|
export interface ChunkCoordinatesInput {
|
|
31
|
+
/** Chunk X coordinate. */
|
|
11
32
|
x: number;
|
|
33
|
+
/** Chunk Y coordinate. */
|
|
12
34
|
y: number;
|
|
35
|
+
/** Chunk Z coordinate. */
|
|
13
36
|
z: number;
|
|
14
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Position of a single voxel **within** its chunk (a 16×16×16 cube). Each axis
|
|
40
|
+
* is a plain `number`; on the wire voxel coordinates are int16 (−32768…32767).
|
|
41
|
+
*/
|
|
15
42
|
export interface VoxelCoordinates {
|
|
43
|
+
/** Voxel X coordinate within the chunk. */
|
|
16
44
|
x: number;
|
|
45
|
+
/** Voxel Y coordinate within the chunk. */
|
|
17
46
|
y: number;
|
|
47
|
+
/** Voxel Z coordinate within the chunk. */
|
|
18
48
|
z: number;
|
|
19
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Voxel position supplied as input on a voxel update. Each axis must be in the
|
|
52
|
+
* int16 range (−32768…32767).
|
|
53
|
+
*/
|
|
20
54
|
export interface VoxelCoordinatesInput {
|
|
55
|
+
/** Voxel X coordinate within the chunk (int16). */
|
|
21
56
|
x: number;
|
|
57
|
+
/** Voxel Y coordinate within the chunk (int16). */
|
|
22
58
|
y: number;
|
|
59
|
+
/** Voxel Z coordinate within the chunk (int16). */
|
|
23
60
|
z: number;
|
|
24
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Reason codes returned by the UDP game servers and surfaced on
|
|
64
|
+
* {@link GenericErrorResponse}'s `errorCode` (re-exported from the codegen enum
|
|
65
|
+
* so the SDK has exactly one canonical shape). `NoError` means success; every
|
|
66
|
+
* other value is a failure. The numeric value is the byte sent on the wire;
|
|
67
|
+
* the SDK exposes the name. Note that a failed message does **not** always
|
|
68
|
+
* produce an error — some auth failures are dropped silently.
|
|
69
|
+
*
|
|
70
|
+
* Each member and the server condition it represents:
|
|
71
|
+
* - `NoError` — no error (the byte `0`); the message was accepted.
|
|
72
|
+
* - `UnknownError` — unspecified server error (the byte `1`); retry, and report
|
|
73
|
+
* it if it persists.
|
|
74
|
+
* - `AppNotFound` — no app matches the supplied appId.
|
|
75
|
+
* - `AppNotLoaded` — the app exists but isn't currently loaded/active on this
|
|
76
|
+
* server.
|
|
77
|
+
* - `InvalidAppId` — the appId was missing, zero, or otherwise not valid.
|
|
78
|
+
* - `ChunkNotFound` — no chunk exists at the referenced coordinates.
|
|
79
|
+
* - `InvalidRequest` — the message was malformed or failed validation; check the
|
|
80
|
+
* byte layout.
|
|
81
|
+
* - `InvalidStateData` — the state/payload bytes were invalid for this message
|
|
82
|
+
* type.
|
|
83
|
+
* - `NameTooLong` — a supplied name exceeded the maximum length.
|
|
84
|
+
* - `UserNotAuthenticated` — this client has no authenticated session on the
|
|
85
|
+
* server; complete the UDP token handshake (or open the UDP proxy) before
|
|
86
|
+
* sending spatial messages.
|
|
87
|
+
* - `Unauthorized` — the caller lacks the runtime/grid permission for this
|
|
88
|
+
* action. Grid permissions can load asynchronously, so the first message into
|
|
89
|
+
* a newly entered region may transiently return this — retry shortly.
|
|
90
|
+
* - `UserNotAppAdmin` — the action requires app-admin privileges (the
|
|
91
|
+
* `manage_apps` permission).
|
|
92
|
+
* - `InvalidToken` — the game token was rejected (expired, malformed, or
|
|
93
|
+
* revoked); re-authenticate against the Management API for a fresh token.
|
|
94
|
+
* - `InvalidTokenLength` — the supplied token was not a valid length.
|
|
95
|
+
* - `GameTokenWrongSize` — the game token isn't the expected length; send the
|
|
96
|
+
* exact token returned by login (don't trim or re-encode it).
|
|
97
|
+
* - `GridAlreadyExists` — a grid already exists at these coordinates.
|
|
98
|
+
* - `GridOverlapsExisting` — the requested grid overlaps an existing grid.
|
|
99
|
+
* - `GridOutsideAssignment` — the target coordinates fall outside any grid
|
|
100
|
+
* assigned to the caller.
|
|
101
|
+
* - `InvalidGridCoordinates` — the grid coordinates were invalid.
|
|
102
|
+
* - `NoMatchingGridAssignment` — no grid assignment covers the referenced
|
|
103
|
+
* coordinates.
|
|
104
|
+
* - `BadPassword` — the password did not match (login validation).
|
|
105
|
+
* - `EmailNotFound` — no account matches the supplied email (login validation).
|
|
106
|
+
* - `EmailAlreadyExists` — registration failed because the email is already in
|
|
107
|
+
* use.
|
|
108
|
+
* - `EmailInvalid` — email failed format validation.
|
|
109
|
+
* - `EmailTooLong` / `EmailTooShort` — email failed maximum-/minimum-length
|
|
110
|
+
* validation.
|
|
111
|
+
* - `PasswordTooLong` / `PasswordTooShort` — password failed maximum-/minimum-
|
|
112
|
+
* length validation.
|
|
113
|
+
* - `GamertagAlreadyExists` — the requested gamertag is already taken.
|
|
114
|
+
*/
|
|
25
115
|
export { UdpErrorCode } from './generated/graphql.js';
|
|
26
116
|
import type { UdpErrorCode } from './generated/graphql.js';
|
|
117
|
+
/**
|
|
118
|
+
* A Crowded Kingdoms user/account record. Returned by the auth/profile reads
|
|
119
|
+
* (e.g. `client.users.me`). Several fields are optional because the server
|
|
120
|
+
* omits them when they are unset or the caller isn't authorized to see them.
|
|
121
|
+
*/
|
|
27
122
|
export interface User {
|
|
123
|
+
/** Unique user id and primary key ({@link BigInt} decimal string). */
|
|
28
124
|
userId: BigInt;
|
|
125
|
+
/** Account email; omitted for anonymized/soft-deleted accounts. */
|
|
29
126
|
email?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Public display name; omitted when unset or anonymized. Unique in
|
|
129
|
+
* combination with {@link disambiguation}.
|
|
130
|
+
*/
|
|
30
131
|
gamertag?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Discriminator paired with {@link gamertag} to form a unique handle;
|
|
134
|
+
* omitted when unset.
|
|
135
|
+
*/
|
|
31
136
|
disambiguation?: string;
|
|
137
|
+
/** User-level state blob, base64-encoded binary; omitted when cleared. */
|
|
32
138
|
state?: string;
|
|
139
|
+
/** Whether the account email has been confirmed. */
|
|
33
140
|
isConfirmed: boolean;
|
|
141
|
+
/** Account creation timestamp (ISO-8601 string). */
|
|
34
142
|
createdAt: string;
|
|
143
|
+
/**
|
|
144
|
+
* Whether the user qualifies for early access through normal eligibility
|
|
145
|
+
* (the free-play window/rollout).
|
|
146
|
+
*/
|
|
35
147
|
grantEarlyAccess: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Admin override that forces early access on/off regardless of normal
|
|
150
|
+
* eligibility.
|
|
151
|
+
*/
|
|
36
152
|
grantEarlyAccessOverride: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Organization the user belongs to ({@link BigInt} decimal string); omitted
|
|
155
|
+
* when the user isn't in an org.
|
|
156
|
+
*/
|
|
37
157
|
orgId?: BigInt;
|
|
158
|
+
/** External identity-provider id for federated accounts; omitted otherwise. */
|
|
38
159
|
externalId?: string;
|
|
160
|
+
/** Account type, e.g. `"direct"` or `"deleted"`. */
|
|
39
161
|
userType: string;
|
|
40
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Result of a successful login/registration. Carries the session token to send
|
|
165
|
+
* on subsequent requests plus the authenticated {@link User}.
|
|
166
|
+
*/
|
|
41
167
|
export interface AuthResponse {
|
|
168
|
+
/**
|
|
169
|
+
* Opaque session token. Send it on subsequent requests as the
|
|
170
|
+
* `Authorization: Bearer <token>` header (the SDK does this for you once it's
|
|
171
|
+
* stored).
|
|
172
|
+
*/
|
|
42
173
|
token: string;
|
|
174
|
+
/** Identifier of the underlying session (game_token) row. */
|
|
43
175
|
gameTokenId: string;
|
|
176
|
+
/** The authenticated user. */
|
|
44
177
|
user: User;
|
|
45
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Status of the per-session UDP proxy connection between the game-api and a UDP
|
|
181
|
+
* game server. Returned by `udpProxyConnectionStatus` / `connectUdpProxy`.
|
|
182
|
+
*/
|
|
46
183
|
export interface UdpProxyConnectionStatus {
|
|
184
|
+
/** Whether the user is currently connected to a UDP game server via the proxy. */
|
|
47
185
|
connected: boolean;
|
|
186
|
+
/** IPv6 address of the UDP game server; present only when {@link connected}. */
|
|
48
187
|
serverIp6?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Client port of the UDP game server (what native clients connect to
|
|
190
|
+
* directly); present only when {@link connected}.
|
|
191
|
+
*/
|
|
49
192
|
serverClientPort?: number;
|
|
193
|
+
/**
|
|
194
|
+
* Timestamp of the last message received from the UDP server (present only
|
|
195
|
+
* when {@link connected}); useful for detecting connection health.
|
|
196
|
+
*/
|
|
50
197
|
lastMessageTime?: string;
|
|
51
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* Input for sending an actor (player/NPC) update to the UDP game server,
|
|
201
|
+
* replicated to nearby clients in the target chunk.
|
|
202
|
+
*/
|
|
52
203
|
export interface ActorUpdateRequestInput {
|
|
204
|
+
/** Id of the app the actor belongs to. */
|
|
53
205
|
appId: number;
|
|
206
|
+
/** Chunk the actor is located in (a 16×16×16 voxel cube). */
|
|
54
207
|
chunk: ChunkCoordinatesInput;
|
|
208
|
+
/** The actor's 32-ASCII-character id (see {@link generateCrowdyUuid}). */
|
|
55
209
|
uuid: string;
|
|
210
|
+
/**
|
|
211
|
+
* Actor state data, base64-encoded. May be an empty string for
|
|
212
|
+
* registration-only updates that carry no state payload.
|
|
213
|
+
*/
|
|
56
214
|
state: string;
|
|
215
|
+
/**
|
|
216
|
+
* Chunk replication distance, `0`–`8` (clamped). Higher reaches more
|
|
217
|
+
* surrounding chunks. Defaults server-side to `8` for actor updates.
|
|
218
|
+
*/
|
|
57
219
|
distance?: number;
|
|
220
|
+
/**
|
|
221
|
+
* Decay algorithm controlling how replication weakens with distance:
|
|
222
|
+
* `0` none, `1` exponential, `2` linear 50%, `3` linear 25%, `4` linear 10%,
|
|
223
|
+
* `5` linear 5%. Defaults server-side to `1` (exponential) for actor updates.
|
|
224
|
+
*/
|
|
58
225
|
decayRate?: number;
|
|
226
|
+
/**
|
|
227
|
+
* Client-assigned correlation id for this datagram: a uint8 (`0`–`255`) that
|
|
228
|
+
* wraps modulo 256. **Correlation only** — not an idempotency key. Echoed on
|
|
229
|
+
* the matching response and on any `GenericErrorResponse` for this send.
|
|
230
|
+
*/
|
|
59
231
|
sequenceNumber?: number;
|
|
60
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Input for setting/changing a single voxel and replicating the change to
|
|
235
|
+
* nearby clients.
|
|
236
|
+
*/
|
|
61
237
|
export interface VoxelUpdateRequestInput {
|
|
238
|
+
/** Id of the app the voxel belongs to. */
|
|
62
239
|
appId: number;
|
|
240
|
+
/** Chunk containing the voxel (a 16×16×16 voxel cube). */
|
|
63
241
|
chunk: ChunkCoordinatesInput;
|
|
242
|
+
/** A 32-ASCII-character id for this voxel update. */
|
|
64
243
|
uuid: string;
|
|
244
|
+
/** The voxel's coordinates within the chunk (int16 per axis). */
|
|
65
245
|
voxel: VoxelCoordinatesInput;
|
|
246
|
+
/** The new voxel type id, which determines its appearance/properties. */
|
|
66
247
|
voxelType: number;
|
|
248
|
+
/** Voxel state data, base64-encoded. */
|
|
67
249
|
voxelState: string;
|
|
250
|
+
/** Chunk replication distance, `0`–`8` (clamped). Defaults to `8`. */
|
|
68
251
|
distance?: number;
|
|
252
|
+
/**
|
|
253
|
+
* Decay algorithm (`0` none, `1` exponential, `2`–`5` linear 50/25/10/5%).
|
|
254
|
+
* Defaults server-side to `0` (none) for voxel updates.
|
|
255
|
+
*/
|
|
69
256
|
decayRate?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Client-assigned correlation id (uint8 `0`–`255`, wraps modulo 256).
|
|
259
|
+
* **Correlation only** — not an idempotency key. Echoed on the matching
|
|
260
|
+
* response and on any `GenericErrorResponse` for this send.
|
|
261
|
+
*/
|
|
70
262
|
sequenceNumber?: number;
|
|
71
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Input for sending a voice/audio packet, broadcast to nearby players.
|
|
266
|
+
*/
|
|
72
267
|
export interface ClientAudioPacketInput {
|
|
268
|
+
/** Id of the app the audio is sent from. */
|
|
73
269
|
appId: number;
|
|
270
|
+
/** Chunk the audio source is located in. */
|
|
74
271
|
chunk: ChunkCoordinatesInput;
|
|
272
|
+
/** The audio source's 32-ASCII-character id (typically the player's). */
|
|
75
273
|
uuid: string;
|
|
274
|
+
/** Compressed audio data, base64-encoded. */
|
|
76
275
|
audioData: string;
|
|
276
|
+
/** Chunk replication distance, `0`–`8` (clamped). Defaults to `1` for audio. */
|
|
77
277
|
distance?: number;
|
|
278
|
+
/**
|
|
279
|
+
* Decay algorithm (`0` none, `1` exponential, `2`–`5` linear 50/25/10/5%).
|
|
280
|
+
* Defaults server-side to `0` (none) for audio packets.
|
|
281
|
+
*/
|
|
78
282
|
decayRate?: number;
|
|
283
|
+
/**
|
|
284
|
+
* Client-assigned correlation id (uint8 `0`–`255`, wraps modulo 256).
|
|
285
|
+
* **Correlation only** — not an idempotency key. Echoed on any
|
|
286
|
+
* `GenericErrorResponse` for this send.
|
|
287
|
+
*/
|
|
79
288
|
sequenceNumber?: number;
|
|
80
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Input for sending a text/chat message, broadcast to nearby players.
|
|
292
|
+
*/
|
|
81
293
|
export interface ClientTextPacketInput {
|
|
294
|
+
/** Id of the app the message is sent from. */
|
|
82
295
|
appId: number;
|
|
296
|
+
/** Chunk the text source is located in. */
|
|
83
297
|
chunk: ChunkCoordinatesInput;
|
|
298
|
+
/** The text source's 32-ASCII-character id (typically the player's). */
|
|
84
299
|
uuid: string;
|
|
300
|
+
/** The text message content, UTF-8 encoded; displayed to nearby players. */
|
|
85
301
|
text: string;
|
|
302
|
+
/** Chunk replication distance, `0`–`8` (clamped). Defaults to `8` for text. */
|
|
86
303
|
distance?: number;
|
|
304
|
+
/**
|
|
305
|
+
* Decay algorithm (`0` none, `1` exponential, `2`–`5` linear 50/25/10/5%).
|
|
306
|
+
* Defaults server-side to `0` (none) for text packets.
|
|
307
|
+
*/
|
|
87
308
|
decayRate?: number;
|
|
309
|
+
/**
|
|
310
|
+
* Client-assigned correlation id (uint8 `0`–`255`, wraps modulo 256).
|
|
311
|
+
* **Correlation only** — not an idempotency key. Echoed on any
|
|
312
|
+
* `GenericErrorResponse` for this send.
|
|
313
|
+
*/
|
|
88
314
|
sequenceNumber?: number;
|
|
89
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Input for sending a custom client event — a client/mod-defined gameplay
|
|
318
|
+
* signal replicated to nearby players. The `eventType` and `state` format are
|
|
319
|
+
* defined by your application.
|
|
320
|
+
*/
|
|
90
321
|
export interface ClientEventNotificationInput {
|
|
322
|
+
/** Id of the app where the event occurs. */
|
|
91
323
|
appId: number;
|
|
324
|
+
/** Chunk the event is located in. */
|
|
92
325
|
chunk: ChunkCoordinatesInput;
|
|
326
|
+
/** A 32-ASCII-character id for the object controlling this event. */
|
|
93
327
|
uuid: string;
|
|
328
|
+
/**
|
|
329
|
+
* Client-defined event type id (uint16, `0`–`65535`) that determines how the
|
|
330
|
+
* event is processed.
|
|
331
|
+
*/
|
|
94
332
|
eventType: number;
|
|
333
|
+
/** Event state data, base64-encoded; its format is defined by {@link eventType}. */
|
|
95
334
|
state: string;
|
|
335
|
+
/** Chunk replication distance, `0`–`8` (clamped). Defaults to `8` for events. */
|
|
96
336
|
distance?: number;
|
|
337
|
+
/**
|
|
338
|
+
* Decay algorithm (`0` none, `1` exponential, `2`–`5` linear 50/25/10/5%).
|
|
339
|
+
* Defaults server-side to `0` (none) for events.
|
|
340
|
+
*/
|
|
97
341
|
decayRate?: number;
|
|
342
|
+
/**
|
|
343
|
+
* Client-assigned correlation id (uint8 `0`–`255`, wraps modulo 256).
|
|
344
|
+
* **Correlation only** — not an idempotency key. Echoed on any
|
|
345
|
+
* `GenericErrorResponse` for this send.
|
|
346
|
+
*/
|
|
98
347
|
sequenceNumber?: number;
|
|
99
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Fan-out notification that another actor's position/state changed within your
|
|
351
|
+
* area of interest. Delivered on the `udpNotifications` subscription.
|
|
352
|
+
*/
|
|
100
353
|
export interface ActorUpdateNotification {
|
|
354
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
101
355
|
__typename: 'ActorUpdateNotification';
|
|
356
|
+
/** Id of the app the actor is in ({@link BigInt} decimal string). */
|
|
102
357
|
appId: BigInt;
|
|
358
|
+
/** X coordinate of the actor's chunk ({@link BigInt} int64 decimal string). */
|
|
103
359
|
chunkX: BigInt;
|
|
360
|
+
/** Y coordinate of the actor's chunk ({@link BigInt} int64 decimal string). */
|
|
104
361
|
chunkY: BigInt;
|
|
362
|
+
/** Z coordinate of the actor's chunk ({@link BigInt} int64 decimal string). */
|
|
105
363
|
chunkZ: BigInt;
|
|
364
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
106
365
|
distance: number;
|
|
366
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
107
367
|
decayRate: number;
|
|
368
|
+
/** The 32-ASCII-character id of the actor that was updated. */
|
|
108
369
|
uuid: string;
|
|
370
|
+
/**
|
|
371
|
+
* Actor state data, base64-encoded. Decode it (e.g. with
|
|
372
|
+
* {@link decodeBase64}) to read position, rotation, velocity, animation
|
|
373
|
+
* flags, etc.
|
|
374
|
+
*/
|
|
109
375
|
state: string;
|
|
376
|
+
/** The sender's sequence number for this message (`0`–`255`). */
|
|
110
377
|
sequenceNumber: number;
|
|
378
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
111
379
|
epochMillis: BigInt;
|
|
112
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* Server acknowledgement echoing one of **your own** actor updates — the
|
|
383
|
+
* correlation target for `sendActorUpdateAndWait`. Has no `state` payload.
|
|
384
|
+
*/
|
|
113
385
|
export interface ActorUpdateResponse {
|
|
386
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
114
387
|
__typename: 'ActorUpdateResponse';
|
|
388
|
+
/** Id of the app where the update was processed ({@link BigInt} decimal string). */
|
|
115
389
|
appId: BigInt;
|
|
390
|
+
/** X coordinate of the actor's chunk ({@link BigInt} int64 decimal string). */
|
|
116
391
|
chunkX: BigInt;
|
|
392
|
+
/** Y coordinate of the actor's chunk ({@link BigInt} int64 decimal string). */
|
|
117
393
|
chunkY: BigInt;
|
|
394
|
+
/** Z coordinate of the actor's chunk ({@link BigInt} int64 decimal string). */
|
|
118
395
|
chunkZ: BigInt;
|
|
396
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
119
397
|
distance: number;
|
|
398
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
120
399
|
decayRate: number;
|
|
400
|
+
/** The 32-ASCII-character id of the actor that was updated. */
|
|
121
401
|
uuid: string;
|
|
402
|
+
/**
|
|
403
|
+
* The `sequenceNumber` echoed from the originating `sendActorUpdate`
|
|
404
|
+
* (uint8 `0`–`255`, wrapping modulo 256). Use it to correlate this response
|
|
405
|
+
* with that send. Correlation only — not an idempotency key.
|
|
406
|
+
*/
|
|
122
407
|
sequenceNumber: number;
|
|
408
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
123
409
|
epochMillis: BigInt;
|
|
124
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Fan-out notification that a voxel changed within range (another client's
|
|
413
|
+
* voxel edit). Delivered on the `udpNotifications` subscription.
|
|
414
|
+
*/
|
|
125
415
|
export interface VoxelUpdateNotification {
|
|
416
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
126
417
|
__typename: 'VoxelUpdateNotification';
|
|
418
|
+
/** Id of the app the voxel is in ({@link BigInt} decimal string). */
|
|
127
419
|
appId: BigInt;
|
|
420
|
+
/** X coordinate of the voxel's chunk ({@link BigInt} int64 decimal string). */
|
|
128
421
|
chunkX: BigInt;
|
|
422
|
+
/** Y coordinate of the voxel's chunk ({@link BigInt} int64 decimal string). */
|
|
129
423
|
chunkY: BigInt;
|
|
424
|
+
/** Z coordinate of the voxel's chunk ({@link BigInt} int64 decimal string). */
|
|
130
425
|
chunkZ: BigInt;
|
|
426
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
131
427
|
distance: number;
|
|
428
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
132
429
|
decayRate: number;
|
|
430
|
+
/** The 32-ASCII-character id for this voxel update. */
|
|
133
431
|
uuid: string;
|
|
432
|
+
/** X coordinate of the voxel within its chunk (int16). */
|
|
134
433
|
voxelX: number;
|
|
434
|
+
/** Y coordinate of the voxel within its chunk (int16). */
|
|
135
435
|
voxelY: number;
|
|
436
|
+
/** Z coordinate of the voxel within its chunk (int16). */
|
|
136
437
|
voxelZ: number;
|
|
438
|
+
/** The voxel type id that was set. */
|
|
137
439
|
voxelType: number;
|
|
440
|
+
/** Voxel state data, base64-encoded. */
|
|
138
441
|
voxelState: string;
|
|
442
|
+
/** The sender's sequence number for this message (`0`–`255`). */
|
|
139
443
|
sequenceNumber: number;
|
|
444
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
140
445
|
epochMillis: BigInt;
|
|
141
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Server acknowledgement echoing one of **your own** voxel updates — the
|
|
449
|
+
* correlation target for `sendVoxelUpdateAndWait`. Has no voxel payload.
|
|
450
|
+
*/
|
|
142
451
|
export interface VoxelUpdateResponse {
|
|
452
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
143
453
|
__typename: 'VoxelUpdateResponse';
|
|
454
|
+
/** Id of the app where the update was processed ({@link BigInt} decimal string). */
|
|
144
455
|
appId: BigInt;
|
|
456
|
+
/** X coordinate of the voxel's chunk ({@link BigInt} int64 decimal string). */
|
|
145
457
|
chunkX: BigInt;
|
|
458
|
+
/** Y coordinate of the voxel's chunk ({@link BigInt} int64 decimal string). */
|
|
146
459
|
chunkY: BigInt;
|
|
460
|
+
/** Z coordinate of the voxel's chunk ({@link BigInt} int64 decimal string). */
|
|
147
461
|
chunkZ: BigInt;
|
|
462
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
148
463
|
distance: number;
|
|
464
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
149
465
|
decayRate: number;
|
|
466
|
+
/** The 32-ASCII-character id for this voxel update. */
|
|
150
467
|
uuid: string;
|
|
468
|
+
/**
|
|
469
|
+
* The `sequenceNumber` echoed from the originating `sendVoxelUpdate`
|
|
470
|
+
* (uint8 `0`–`255`, wrapping modulo 256). Use it to correlate this response
|
|
471
|
+
* with that send. Correlation only — not an idempotency key.
|
|
472
|
+
*/
|
|
151
473
|
sequenceNumber: number;
|
|
474
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
152
475
|
epochMillis: BigInt;
|
|
153
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Fan-out notification carrying a nearby client's voice/audio packet.
|
|
479
|
+
* Delivered on the `udpNotifications` subscription.
|
|
480
|
+
*/
|
|
154
481
|
export interface ClientAudioNotification {
|
|
482
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
155
483
|
__typename: 'ClientAudioNotification';
|
|
484
|
+
/** Id of the app the audio is from ({@link BigInt} decimal string). */
|
|
156
485
|
appId: BigInt;
|
|
486
|
+
/** X coordinate of the audio source's chunk ({@link BigInt} int64 decimal string). */
|
|
157
487
|
chunkX: BigInt;
|
|
488
|
+
/** Y coordinate of the audio source's chunk ({@link BigInt} int64 decimal string). */
|
|
158
489
|
chunkY: BigInt;
|
|
490
|
+
/** Z coordinate of the audio source's chunk ({@link BigInt} int64 decimal string). */
|
|
159
491
|
chunkZ: BigInt;
|
|
492
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
160
493
|
distance: number;
|
|
494
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
161
495
|
decayRate: number;
|
|
496
|
+
/** The 32-ASCII-character id of the audio source (typically the player). */
|
|
162
497
|
uuid: string;
|
|
498
|
+
/** Compressed audio data, base64-encoded (decode with {@link decodeBase64}). */
|
|
163
499
|
audioData: string;
|
|
500
|
+
/** The sender's sequence number for this message (`0`–`255`). */
|
|
164
501
|
sequenceNumber: number;
|
|
502
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
165
503
|
epochMillis: BigInt;
|
|
166
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* Fan-out notification carrying a nearby client's text/chat message.
|
|
507
|
+
* Delivered on the `udpNotifications` subscription.
|
|
508
|
+
*/
|
|
167
509
|
export interface ClientTextNotification {
|
|
510
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
168
511
|
__typename: 'ClientTextNotification';
|
|
512
|
+
/** Id of the app the message is from ({@link BigInt} decimal string). */
|
|
169
513
|
appId: BigInt;
|
|
514
|
+
/** X coordinate of the text source's chunk ({@link BigInt} int64 decimal string). */
|
|
170
515
|
chunkX: BigInt;
|
|
516
|
+
/** Y coordinate of the text source's chunk ({@link BigInt} int64 decimal string). */
|
|
171
517
|
chunkY: BigInt;
|
|
518
|
+
/** Z coordinate of the text source's chunk ({@link BigInt} int64 decimal string). */
|
|
172
519
|
chunkZ: BigInt;
|
|
520
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
173
521
|
distance: number;
|
|
522
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
174
523
|
decayRate: number;
|
|
524
|
+
/** The 32-ASCII-character id of the text source (typically the player). */
|
|
175
525
|
uuid: string;
|
|
526
|
+
/** The text message content, UTF-8 encoded; display it to the user. */
|
|
176
527
|
text: string;
|
|
528
|
+
/** The sender's sequence number for this message (`0`–`255`). */
|
|
177
529
|
sequenceNumber: number;
|
|
530
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
178
531
|
epochMillis: BigInt;
|
|
179
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* Fan-out notification carrying a nearby client's custom event (a
|
|
535
|
+
* client/mod-defined gameplay signal). Delivered on the `udpNotifications`
|
|
536
|
+
* subscription.
|
|
537
|
+
*/
|
|
180
538
|
export interface ClientEventNotification {
|
|
539
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
181
540
|
__typename: 'ClientEventNotification';
|
|
541
|
+
/** Id of the app where the event occurs ({@link BigInt} decimal string). */
|
|
182
542
|
appId: BigInt;
|
|
543
|
+
/** X coordinate of the event's chunk ({@link BigInt} int64 decimal string). */
|
|
183
544
|
chunkX: BigInt;
|
|
545
|
+
/** Y coordinate of the event's chunk ({@link BigInt} int64 decimal string). */
|
|
184
546
|
chunkY: BigInt;
|
|
547
|
+
/** Z coordinate of the event's chunk ({@link BigInt} int64 decimal string). */
|
|
185
548
|
chunkZ: BigInt;
|
|
549
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
186
550
|
distance: number;
|
|
551
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
187
552
|
decayRate: number;
|
|
553
|
+
/** The 32-ASCII-character id of the object controlling this event. */
|
|
188
554
|
uuid: string;
|
|
555
|
+
/** The client-defined event type id (uint16) that determines processing. */
|
|
189
556
|
eventType: number;
|
|
557
|
+
/** Event state data, base64-encoded; format is defined by {@link eventType}. */
|
|
190
558
|
state: string;
|
|
559
|
+
/** The sender's sequence number for this message (`0`–`255`). */
|
|
191
560
|
sequenceNumber: number;
|
|
561
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
192
562
|
epochMillis: BigInt;
|
|
193
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* Notification carrying a server-originated spatial event broadcast to a region
|
|
566
|
+
* (e.g. world or NPC events). Same shape as {@link ClientEventNotification} but
|
|
567
|
+
* emitted by the server. Delivered on the `udpNotifications` subscription.
|
|
568
|
+
*/
|
|
194
569
|
export interface ServerEventNotification {
|
|
570
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
195
571
|
__typename: 'ServerEventNotification';
|
|
572
|
+
/** Id of the app where the event occurs ({@link BigInt} decimal string). */
|
|
196
573
|
appId: BigInt;
|
|
574
|
+
/** X coordinate of the event's chunk ({@link BigInt} int64 decimal string). */
|
|
197
575
|
chunkX: BigInt;
|
|
576
|
+
/** Y coordinate of the event's chunk ({@link BigInt} int64 decimal string). */
|
|
198
577
|
chunkY: BigInt;
|
|
578
|
+
/** Z coordinate of the event's chunk ({@link BigInt} int64 decimal string). */
|
|
199
579
|
chunkZ: BigInt;
|
|
580
|
+
/** Chunk replication distance (`0`–`8`) from the original message. */
|
|
200
581
|
distance: number;
|
|
582
|
+
/** Decay algorithm (`0`–`5`) from the original message. */
|
|
201
583
|
decayRate: number;
|
|
584
|
+
/** The 32-ASCII-character id of the object controlling this event. */
|
|
202
585
|
uuid: string;
|
|
586
|
+
/** The event type id (uint16) that determines processing. */
|
|
203
587
|
eventType: number;
|
|
588
|
+
/** Event state data, base64-encoded; format is defined by {@link eventType}. */
|
|
204
589
|
state: string;
|
|
590
|
+
/** The sender's sequence number for this message (`0`–`255`). */
|
|
205
591
|
sequenceNumber: number;
|
|
592
|
+
/** Server-generated timestamp in epoch milliseconds ({@link BigInt} string). */
|
|
206
593
|
epochMillis: BigInt;
|
|
207
594
|
}
|
|
595
|
+
/**
|
|
596
|
+
* Asynchronous error for a previously sent datagram (e.g. a `send*` request).
|
|
597
|
+
* Delivered as a member of the {@link UdpNotification} union on the
|
|
598
|
+
* subscription — **not** as a GraphQL error on the mutation. Match it to the
|
|
599
|
+
* originating send via {@link sequenceNumber} and read {@link errorCode} for
|
|
600
|
+
* the reason. Note: not every failure produces one — some auth failures are
|
|
601
|
+
* dropped silently (see {@link UdpErrorCode}).
|
|
602
|
+
*/
|
|
208
603
|
export interface GenericErrorResponse {
|
|
604
|
+
/** Discriminator for the {@link UdpNotification} union. */
|
|
209
605
|
__typename: 'GenericErrorResponse';
|
|
606
|
+
/**
|
|
607
|
+
* Echoes the `sequenceNumber` of the request that failed (uint8 `0`–`255`,
|
|
608
|
+
* wrapping modulo 256) so you can correlate this error with the `send*` that
|
|
609
|
+
* produced it. Correlation only — not an idempotency key.
|
|
610
|
+
*/
|
|
210
611
|
sequenceNumber: number;
|
|
612
|
+
/** Code indicating the reason for the failure. See {@link UdpErrorCode}. */
|
|
211
613
|
errorCode: UdpErrorCode;
|
|
212
614
|
}
|
|
615
|
+
/**
|
|
616
|
+
* Discriminated union of every realtime payload a consumer can receive on the
|
|
617
|
+
* subscription. Narrow it by switching on the `__typename` field. (The realtime
|
|
618
|
+
* client uses the equivalent codegen-derived {@link SpatialNotification}
|
|
619
|
+
* /`UdpNotification` shapes; these hand-written interfaces mirror them.)
|
|
620
|
+
*/
|
|
213
621
|
export type UdpNotification = ActorUpdateNotification | ActorUpdateResponse | VoxelUpdateNotification | VoxelUpdateResponse | ClientAudioNotification | ClientTextNotification | ClientEventNotification | ServerEventNotification | GenericErrorResponse;
|
|
622
|
+
/**
|
|
623
|
+
* Minimal endpoint/timeout configuration shape (HTTP + WebSocket endpoints and
|
|
624
|
+
* a request timeout). The full client options used by the package entry point
|
|
625
|
+
* live on `CrowdyClient`'s own config.
|
|
626
|
+
*/
|
|
214
627
|
export interface CrowdyClientConfig {
|
|
628
|
+
/** GraphQL HTTP endpoint URL. */
|
|
215
629
|
graphqlEndpoint?: string;
|
|
630
|
+
/** GraphQL WebSocket endpoint URL for the subscription stream. */
|
|
216
631
|
wsEndpoint?: string;
|
|
632
|
+
/** Request timeout in milliseconds. */
|
|
217
633
|
timeout?: number;
|
|
218
634
|
}
|
|
635
|
+
/** Callback for an {@link ActorUpdateNotification} (another actor moved/changed). */
|
|
219
636
|
export type ActorUpdateHandler = (notification: ActorUpdateNotification) => void;
|
|
637
|
+
/** Callback for an {@link ActorUpdateResponse} (echo of your own actor update). */
|
|
220
638
|
export type ActorUpdateResponseHandler = (response: ActorUpdateResponse) => void;
|
|
639
|
+
/** Callback for a {@link VoxelUpdateNotification} (a nearby voxel changed). */
|
|
221
640
|
export type VoxelUpdateHandler = (notification: VoxelUpdateNotification) => void;
|
|
641
|
+
/** Callback for a {@link VoxelUpdateResponse} (echo of your own voxel update). */
|
|
222
642
|
export type VoxelUpdateResponseHandler = (response: VoxelUpdateResponse) => void;
|
|
643
|
+
/** Callback for a {@link ClientAudioNotification} (nearby voice/audio packet). */
|
|
223
644
|
export type ClientAudioHandler = (notification: ClientAudioNotification) => void;
|
|
645
|
+
/** Callback for a {@link ClientTextNotification} (nearby text/chat message). */
|
|
224
646
|
export type ClientTextHandler = (notification: ClientTextNotification) => void;
|
|
647
|
+
/** Callback for a {@link ClientEventNotification} (nearby custom client event). */
|
|
225
648
|
export type ClientEventHandler = (notification: ClientEventNotification) => void;
|
|
649
|
+
/** Callback for a {@link ServerEventNotification} (server-originated spatial event). */
|
|
226
650
|
export type ServerEventHandler = (notification: ServerEventNotification) => void;
|
|
651
|
+
/** Callback for a {@link GenericErrorResponse} (async error for a prior send). */
|
|
227
652
|
export type GenericErrorHandler = (response: GenericErrorResponse) => void;
|
|
653
|
+
/**
|
|
654
|
+
* Function returned by subscribe-style helpers; call it (no arguments) to
|
|
655
|
+
* remove the listener/subscription it represents.
|
|
656
|
+
*/
|
|
228
657
|
export type UnsubscribeFn = () => void;
|
|
229
658
|
//# sourceMappingURL=types.d.ts.map
|