dredless 0.2.0 → 0.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.
Files changed (77) hide show
  1. package/README.md +48 -48
  2. package/docs/API_REFERENCE.md +2481 -2481
  3. package/docs/BROWSER_API.md +98 -98
  4. package/docs/NODE_API.md +359 -359
  5. package/package.json +34 -34
  6. package/src/browser.d.ts +212 -212
  7. package/src/browser.js +133 -133
  8. package/src/client/core.js +1202 -1202
  9. package/src/client/domains/index.js +1818 -1818
  10. package/src/client/index.d.ts +2 -2
  11. package/src/client/index.js +1 -1
  12. package/src/compression/lz4.d.ts +1 -1
  13. package/src/compression/lz4.js +112 -112
  14. package/src/constants.js +74 -74
  15. package/src/crypto/chacha-native.d.ts +9 -9
  16. package/src/crypto/chacha-native.js +48 -48
  17. package/src/crypto/chacha.d.ts +25 -25
  18. package/src/crypto/chacha.js +274 -274
  19. package/src/events.js +39 -39
  20. package/src/index.d.ts +2277 -2277
  21. package/src/index.js +125 -125
  22. package/src/network/browser-session.js +291 -291
  23. package/src/network/connection.d.ts +1 -1
  24. package/src/network/connection.js +31 -31
  25. package/src/network/cookies.js +85 -85
  26. package/src/network/http.js +34 -34
  27. package/src/network/index.d.ts +4 -4
  28. package/src/network/index.js +4 -4
  29. package/src/network/servers.d.ts +7 -7
  30. package/src/network/servers.js +133 -133
  31. package/src/network/session.d.ts +7 -7
  32. package/src/network/session.js +320 -320
  33. package/src/network/ships.d.ts +12 -12
  34. package/src/network/ships.js +73 -73
  35. package/src/node.d.ts +2 -2
  36. package/src/node.js +8 -8
  37. package/src/protocol/codec/binary.d.ts +3 -3
  38. package/src/protocol/codec/binary.js +52 -52
  39. package/src/protocol/codec/msgpack.d.ts +3 -3
  40. package/src/protocol/codec/msgpack.js +555 -555
  41. package/src/protocol/inbound/frame.d.ts +1 -1
  42. package/src/protocol/inbound/frame.js +8 -8
  43. package/src/protocol/inbound/world-payload.d.ts +3 -3
  44. package/src/protocol/inbound/world-payload.js +21 -21
  45. package/src/protocol/index.d.ts +11 -11
  46. package/src/protocol/index.js +19 -19
  47. package/src/protocol/outbound/blueprint.d.ts +22 -22
  48. package/src/protocol/outbound/blueprint.js +36 -36
  49. package/src/protocol/outbound/commands.d.ts +3 -3
  50. package/src/protocol/outbound/commands.js +149 -149
  51. package/src/protocol/outbound/comms.d.ts +28 -28
  52. package/src/protocol/outbound/comms.js +40 -40
  53. package/src/protocol/outbound/inventory.d.ts +64 -64
  54. package/src/protocol/outbound/inventory.js +147 -147
  55. package/src/protocol/outbound/ship-management.d.ts +84 -84
  56. package/src/protocol/outbound/ship-management.js +221 -221
  57. package/src/protocol/outbound/sign.d.ts +18 -18
  58. package/src/protocol/outbound/sign.js +45 -45
  59. package/src/protocol/outbound/ui-config.d.ts +157 -157
  60. package/src/protocol/outbound/ui-config.js +578 -578
  61. package/src/runtime.js +36 -36
  62. package/src/state/generator-maze.d.ts +32 -32
  63. package/src/state/generator-maze.js +370 -370
  64. package/src/state/index.d.ts +3 -3
  65. package/src/state/index.js +3 -3
  66. package/src/state/items.js +20 -20
  67. package/src/state/model/decoder.js +1554 -1554
  68. package/src/state/model/index.d.ts +33 -33
  69. package/src/state/model/index.js +2 -2
  70. package/src/state/model/loader-config.js +1020 -1020
  71. package/src/state/model/reader.js +69 -69
  72. package/src/state/model/state.js +1257 -1257
  73. package/src/state/overworld.js +72 -72
  74. package/src/state/tilesets.js +53 -53
  75. package/src/state/world/index.d.ts +29 -29
  76. package/src/state/world/index.js +180 -180
  77. package/src/state/world/state.js +297 -297
package/docs/NODE_API.md CHANGED
@@ -1,359 +1,359 @@
1
- # Dredless Node API
2
-
3
- This document covers the Node-specific top-level API: explicit sessions, anonymous token/session creation, connection descriptors, and convenience start/join helpers.
4
-
5
- Use this entrypoint when you want the multi-session cookie-jar API:
6
-
7
- ```js
8
- import Dredless, {
9
- Session,
10
- AnonSession,
11
- Connection,
12
- DredlessClient
13
- } from "dredless/node";
14
- ```
15
-
16
- Normal Node usage:
17
-
18
- ```js
19
- const session = await Dredless.createAnonSession();
20
- const servers = await Dredless.fetchServers();
21
- const ships = await session.fetchShips(servers[0]);
22
- const client = await session.startShip(servers[0], ships[0]);
23
-
24
- await client.whenReady();
25
- ```
26
-
27
- Shared input shapes such as `Server`, `ServerRef`, `Ship`, `ShipRef`, and `ShipSpec` are documented in [API_REFERENCE.md](./API_REFERENCE.md#common-input-types). Shared client/world/entity/domain APIs are also documented in [API_REFERENCE.md](./API_REFERENCE.md).
28
-
29
- ## `Dredless` Namespace
30
-
31
- The default export is a namespace of constructors and convenience factories.
32
-
33
- ```ts
34
- interface DredlessNamespace {
35
- Session: typeof Session;
36
- AnonSession: typeof AnonSession;
37
- Connection: typeof Connection;
38
- DredlessClient: typeof DredlessClient;
39
- createSession: typeof createSession;
40
- createAnonSession: typeof createAnonSession;
41
- createAnonToken: typeof createAnonToken;
42
- fetchNoticeVersion: typeof fetchNoticeVersion;
43
- fetchGameVersion: typeof fetchGameVersion;
44
- fetchServers: typeof fetchServers;
45
- fetchShips: typeof fetchShips;
46
- fetchShipList: typeof fetchShipList;
47
- joinShip: typeof joinShip;
48
- startShip: typeof startShip;
49
- startNewShip: typeof startNewShip;
50
- joinInvite: typeof joinInvite;
51
- }
52
- ```
53
-
54
- ### `Dredless.createSession(noticeVersion?)`
55
-
56
- ```ts
57
- function createSession(noticeVersion?: number | null): Promise<Session>;
58
- ```
59
-
60
- Creates a `Session` using the current game version lookup and optional notice
61
- version. It does not create an anonymous account.
62
-
63
- ### `Dredless.createAnonSession(anonKey?, noticeVersion?, baseUrl?)`
64
-
65
- ```ts
66
- function createAnonSession(
67
- anonKey?: string | null,
68
- noticeVersion?: number | null,
69
- baseUrl?: string
70
- ): Promise<AnonSession>;
71
- ```
72
-
73
- Creates an anonymous session. If `anonKey` is omitted, the library requests one
74
- from the server.
75
-
76
- Returns an `AnonSession`.
77
-
78
- ### `Dredless.createAnonToken(noticeVersion?, baseUrl?)`
79
-
80
- ```ts
81
- function createAnonToken(
82
- noticeVersion?: number | null,
83
- baseUrl?: string
84
- ): Promise<string>;
85
- ```
86
-
87
- Requests a new anonymous account token.
88
-
89
- ### `Dredless.fetchNoticeVersion()`
90
-
91
- ```ts
92
- function fetchNoticeVersion(): Promise<number>;
93
- ```
94
-
95
- Scrapes the current notice version needed by anon login.
96
-
97
- ### `Dredless.fetchGameVersion()`
98
-
99
- ```ts
100
- function fetchGameVersion(): Promise<string>;
101
- ```
102
-
103
- Scrapes the current game version string from the site.
104
-
105
- ### `Dredless.fetchServers()`
106
-
107
- ```ts
108
- function fetchServers(): Promise<Server[]>;
109
- ```
110
-
111
- Scrapes and returns known game servers.
112
-
113
- ### `Dredless.fetchShips(session, server)`
114
-
115
- ```ts
116
- function fetchShips(session: Session, server: ServerRef): Promise<Ship[]>;
117
- ```
118
-
119
- Authenticated convenience wrapper around `session.fetchShips(server)`.
120
-
121
- ### `Dredless.fetchShipList(session, server)`
122
-
123
- ```ts
124
- function fetchShipList(session: Session, server: ServerRef): Promise<ShipList>;
125
- ```
126
-
127
- Authenticated convenience wrapper around `session.fetchShipList(server)`.
128
-
129
- ### `Dredless.joinShip(server, ship?, session?)`
130
-
131
- ```ts
132
- function joinShip(
133
- server: ServerRef,
134
- ship?: ShipRef,
135
- session?: Session | null
136
- ): Promise<DredlessClient>;
137
- ```
138
-
139
- Starts a websocket client using `never_load: true`. This is useful when you need
140
- to join without loading the full ship world.
141
-
142
- If `session` is omitted, an anonymous session is created.
143
-
144
- ### `Dredless.startShip(server, ship?, session?)`
145
-
146
- ```ts
147
- function startShip(
148
- server: ServerRef,
149
- ship?: ShipRef,
150
- session?: Session | null
151
- ): Promise<DredlessClient>;
152
- ```
153
-
154
- Starts a websocket client using normal world loading.
155
-
156
- If `session` is omitted, an anonymous session is created.
157
-
158
- ### `Dredless.startNewShip(server, name?, color?, session?)`
159
-
160
- ```ts
161
- function startNewShip(
162
- server: ServerRef,
163
- name?: string,
164
- color?: string,
165
- session?: Session | null
166
- ): Promise<DredlessClient>;
167
- ```
168
-
169
- Creates/starts a new ship and returns a live client.
170
-
171
- ### `Dredless.joinInvite(server, code, session?)`
172
-
173
- ```ts
174
- function joinInvite(
175
- server: ServerRef,
176
- code: string,
177
- session?: Session | null
178
- ): Promise<DredlessClient>;
179
- ```
180
-
181
- Joins through an invite code and returns a live client.
182
-
183
-
184
- ## `Session`
185
-
186
- `Session` represents an authenticated HTTP session and owns cookies, account
187
- status, ship list fetches, and `/join`.
188
-
189
- ```ts
190
- class Session {
191
- constructor(gameSession?: string | null, gameVersion?: string | null);
192
-
193
- baseUrl: string;
194
- cookies: Map<string, string>;
195
- gameVersion: string | null;
196
- account: Account | null;
197
- geoServer: number | null;
198
- upgraded: boolean;
199
- isRegistered: boolean;
200
- showAds: boolean;
201
- forceTutorial: boolean;
202
- ban: unknown;
203
-
204
- get gameSession(): string;
205
- get gameToken(): string;
206
- get noticeVersion(): number | string | null;
207
- set noticeVersion(value: number | string | null);
208
-
209
- request(path: string, init?: RequestInit & {
210
- body?: BodyInit | Record<string, unknown> | null
211
- }): Promise<Response>;
212
-
213
- fetchAccountStatus(): Promise<unknown>;
214
- fetchShips(server: ServerRef): Promise<Ship[]>;
215
- fetchShipList(server: ServerRef): Promise<ShipList>;
216
-
217
- joinShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
218
- startShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
219
- startNewShipConnection(
220
- server: ServerRef,
221
- name?: string,
222
- color?: string
223
- ): Promise<Connection>;
224
- joinInviteConnection(server: ServerRef, code: string): Promise<Connection>;
225
-
226
- joinShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
227
- startShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
228
- startNewShip(server: ServerRef, name?: string, color?: string): Promise<DredlessClient>;
229
- joinInvite(server: ServerRef, code: string): Promise<DredlessClient>;
230
-
231
- toJSON(): SessionSnapshot;
232
- }
233
- ```
234
-
235
- ### `new Session(gameSession?, gameVersion?)`
236
-
237
- Constructs an existing session wrapper. Does not perform network I/O.
238
-
239
- ### `session.request(path, init?)`
240
-
241
- Authenticated HTTP helper. The `path` is relative to `session.baseUrl` unless a
242
- full URL is supplied by the implementation path handling.
243
-
244
- Input body may be a normal `BodyInit`, an object, or `null`.
245
-
246
- Returns the raw `Response`.
247
-
248
- ### `session.fetchAccountStatus()`
249
-
250
- Fetches and applies account status. Returns the decoded server response as
251
- `unknown` because the live shape is not fully stabilized.
252
-
253
- ### `session.fetchShips(server)`
254
-
255
- Returns `Ship[]`.
256
-
257
- ### `session.fetchShipList(server)`
258
-
259
- Returns `ShipList`.
260
-
261
- ### Connection factories
262
-
263
- These return `Connection` objects and do not open the websocket:
264
-
265
- ```ts
266
- session.joinShipConnection(server, ship?): Promise<Connection>;
267
- session.startShipConnection(server, ship?): Promise<Connection>;
268
- session.startNewShipConnection(server, name?, color?): Promise<Connection>;
269
- session.joinInviteConnection(server, code): Promise<Connection>;
270
- ```
271
-
272
- Use these when you want to construct `DredlessClient` yourself.
273
-
274
- ### Client factories
275
-
276
- These return live `DredlessClient` objects:
277
-
278
- ```ts
279
- session.joinShip(server, ship?): Promise<DredlessClient>;
280
- session.startShip(server, ship?): Promise<DredlessClient>;
281
- session.startNewShip(server, name?, color?): Promise<DredlessClient>;
282
- session.joinInvite(server, code): Promise<DredlessClient>;
283
- ```
284
-
285
- ### `session.toJSON()`
286
-
287
- ```ts
288
- interface SessionSnapshot {
289
- baseUrl: string;
290
- gameSession: string;
291
- gameToken: string;
292
- gameVersion: string | null;
293
- noticeVersion: number | string | null;
294
- cookies: Record<string, string>;
295
- account: Account | null;
296
- geoServer: number | null;
297
- upgraded: boolean;
298
- isRegistered: boolean;
299
- showAds: boolean;
300
- forceTutorial: boolean;
301
- ban: unknown;
302
- anonKey?: string;
303
- }
304
- ```
305
-
306
- ## `AnonSession`
307
-
308
- ```ts
309
- class AnonSession extends Session {
310
- constructor(
311
- gameSession?: string | null,
312
- anonKey?: string | null,
313
- gameVersion?: string | null
314
- );
315
-
316
- get anonKey(): string;
317
- }
318
- ```
319
-
320
- `AnonSession` is a `Session` with anonymous account key handling.
321
-
322
- ## `Connection`
323
-
324
- `Connection` is a no-I/O descriptor for an already joined game session.
325
-
326
- ```ts
327
- class Connection {
328
- constructor(
329
- session: Session,
330
- gameToken: string,
331
- netPort: number,
332
- serverId: number | Server,
333
- server?: Server | null
334
- );
335
-
336
- session: Session;
337
- baseUrl: string;
338
- gameToken: string;
339
- netPort: number;
340
- serverId: number;
341
- server: Server | null;
342
-
343
- toJSON(): ConnectionSnapshot;
344
- }
345
- ```
346
-
347
- ### `connection.toJSON()`
348
-
349
- ```ts
350
- interface ConnectionSnapshot {
351
- baseUrl: string;
352
- gameToken: string;
353
- netPort: number;
354
- serverId: number;
355
- server: Server | null;
356
- session: SessionSnapshot;
357
- }
358
- ```
359
-
1
+ # Dredless Node API
2
+
3
+ This document covers the Node-specific top-level API: explicit sessions, anonymous token/session creation, connection descriptors, and convenience start/join helpers.
4
+
5
+ Use this entrypoint when you want the multi-session cookie-jar API:
6
+
7
+ ```js
8
+ import Dredless, {
9
+ Session,
10
+ AnonSession,
11
+ Connection,
12
+ DredlessClient
13
+ } from "dredless/node";
14
+ ```
15
+
16
+ Normal Node usage:
17
+
18
+ ```js
19
+ const session = await Dredless.createAnonSession();
20
+ const servers = await Dredless.fetchServers();
21
+ const ships = await session.fetchShips(servers[0]);
22
+ const client = await session.startShip(servers[0], ships[0]);
23
+
24
+ await client.whenReady();
25
+ ```
26
+
27
+ Shared input shapes such as `Server`, `ServerRef`, `Ship`, `ShipRef`, and `ShipSpec` are documented in [API_REFERENCE.md](./API_REFERENCE.md#common-input-types). Shared client/world/entity/domain APIs are also documented in [API_REFERENCE.md](./API_REFERENCE.md).
28
+
29
+ ## `Dredless` Namespace
30
+
31
+ The default export is a namespace of constructors and convenience factories.
32
+
33
+ ```ts
34
+ interface DredlessNamespace {
35
+ Session: typeof Session;
36
+ AnonSession: typeof AnonSession;
37
+ Connection: typeof Connection;
38
+ DredlessClient: typeof DredlessClient;
39
+ createSession: typeof createSession;
40
+ createAnonSession: typeof createAnonSession;
41
+ createAnonToken: typeof createAnonToken;
42
+ fetchNoticeVersion: typeof fetchNoticeVersion;
43
+ fetchGameVersion: typeof fetchGameVersion;
44
+ fetchServers: typeof fetchServers;
45
+ fetchShips: typeof fetchShips;
46
+ fetchShipList: typeof fetchShipList;
47
+ joinShip: typeof joinShip;
48
+ startShip: typeof startShip;
49
+ startNewShip: typeof startNewShip;
50
+ joinInvite: typeof joinInvite;
51
+ }
52
+ ```
53
+
54
+ ### `Dredless.createSession(noticeVersion?)`
55
+
56
+ ```ts
57
+ function createSession(noticeVersion?: number | null): Promise<Session>;
58
+ ```
59
+
60
+ Creates a `Session` using the current game version lookup and optional notice
61
+ version. It does not create an anonymous account.
62
+
63
+ ### `Dredless.createAnonSession(anonKey?, noticeVersion?, baseUrl?)`
64
+
65
+ ```ts
66
+ function createAnonSession(
67
+ anonKey?: string | null,
68
+ noticeVersion?: number | null,
69
+ baseUrl?: string
70
+ ): Promise<AnonSession>;
71
+ ```
72
+
73
+ Creates an anonymous session. If `anonKey` is omitted, the library requests one
74
+ from the server.
75
+
76
+ Returns an `AnonSession`.
77
+
78
+ ### `Dredless.createAnonToken(noticeVersion?, baseUrl?)`
79
+
80
+ ```ts
81
+ function createAnonToken(
82
+ noticeVersion?: number | null,
83
+ baseUrl?: string
84
+ ): Promise<string>;
85
+ ```
86
+
87
+ Requests a new anonymous account token.
88
+
89
+ ### `Dredless.fetchNoticeVersion()`
90
+
91
+ ```ts
92
+ function fetchNoticeVersion(): Promise<number>;
93
+ ```
94
+
95
+ Scrapes the current notice version needed by anon login.
96
+
97
+ ### `Dredless.fetchGameVersion()`
98
+
99
+ ```ts
100
+ function fetchGameVersion(): Promise<string>;
101
+ ```
102
+
103
+ Scrapes the current game version string from the site.
104
+
105
+ ### `Dredless.fetchServers()`
106
+
107
+ ```ts
108
+ function fetchServers(): Promise<Server[]>;
109
+ ```
110
+
111
+ Scrapes and returns known game servers.
112
+
113
+ ### `Dredless.fetchShips(session, server)`
114
+
115
+ ```ts
116
+ function fetchShips(session: Session, server: ServerRef): Promise<Ship[]>;
117
+ ```
118
+
119
+ Authenticated convenience wrapper around `session.fetchShips(server)`.
120
+
121
+ ### `Dredless.fetchShipList(session, server)`
122
+
123
+ ```ts
124
+ function fetchShipList(session: Session, server: ServerRef): Promise<ShipList>;
125
+ ```
126
+
127
+ Authenticated convenience wrapper around `session.fetchShipList(server)`.
128
+
129
+ ### `Dredless.joinShip(server, ship?, session?)`
130
+
131
+ ```ts
132
+ function joinShip(
133
+ server: ServerRef,
134
+ ship?: ShipRef,
135
+ session?: Session | null
136
+ ): Promise<DredlessClient>;
137
+ ```
138
+
139
+ Starts a websocket client using `never_load: true`. This is useful when you need
140
+ to join without loading the full ship world.
141
+
142
+ If `session` is omitted, an anonymous session is created.
143
+
144
+ ### `Dredless.startShip(server, ship?, session?)`
145
+
146
+ ```ts
147
+ function startShip(
148
+ server: ServerRef,
149
+ ship?: ShipRef,
150
+ session?: Session | null
151
+ ): Promise<DredlessClient>;
152
+ ```
153
+
154
+ Starts a websocket client using normal world loading.
155
+
156
+ If `session` is omitted, an anonymous session is created.
157
+
158
+ ### `Dredless.startNewShip(server, name?, color?, session?)`
159
+
160
+ ```ts
161
+ function startNewShip(
162
+ server: ServerRef,
163
+ name?: string,
164
+ color?: string,
165
+ session?: Session | null
166
+ ): Promise<DredlessClient>;
167
+ ```
168
+
169
+ Creates/starts a new ship and returns a live client.
170
+
171
+ ### `Dredless.joinInvite(server, code, session?)`
172
+
173
+ ```ts
174
+ function joinInvite(
175
+ server: ServerRef,
176
+ code: string,
177
+ session?: Session | null
178
+ ): Promise<DredlessClient>;
179
+ ```
180
+
181
+ Joins through an invite code and returns a live client.
182
+
183
+
184
+ ## `Session`
185
+
186
+ `Session` represents an authenticated HTTP session and owns cookies, account
187
+ status, ship list fetches, and `/join`.
188
+
189
+ ```ts
190
+ class Session {
191
+ constructor(gameSession?: string | null, gameVersion?: string | null);
192
+
193
+ baseUrl: string;
194
+ cookies: Map<string, string>;
195
+ gameVersion: string | null;
196
+ account: Account | null;
197
+ geoServer: number | null;
198
+ upgraded: boolean;
199
+ isRegistered: boolean;
200
+ showAds: boolean;
201
+ forceTutorial: boolean;
202
+ ban: unknown;
203
+
204
+ get gameSession(): string;
205
+ get gameToken(): string;
206
+ get noticeVersion(): number | string | null;
207
+ set noticeVersion(value: number | string | null);
208
+
209
+ request(path: string, init?: RequestInit & {
210
+ body?: BodyInit | Record<string, unknown> | null
211
+ }): Promise<Response>;
212
+
213
+ fetchAccountStatus(): Promise<unknown>;
214
+ fetchShips(server: ServerRef): Promise<Ship[]>;
215
+ fetchShipList(server: ServerRef): Promise<ShipList>;
216
+
217
+ joinShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
218
+ startShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
219
+ startNewShipConnection(
220
+ server: ServerRef,
221
+ name?: string,
222
+ color?: string
223
+ ): Promise<Connection>;
224
+ joinInviteConnection(server: ServerRef, code: string): Promise<Connection>;
225
+
226
+ joinShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
227
+ startShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
228
+ startNewShip(server: ServerRef, name?: string, color?: string): Promise<DredlessClient>;
229
+ joinInvite(server: ServerRef, code: string): Promise<DredlessClient>;
230
+
231
+ toJSON(): SessionSnapshot;
232
+ }
233
+ ```
234
+
235
+ ### `new Session(gameSession?, gameVersion?)`
236
+
237
+ Constructs an existing session wrapper. Does not perform network I/O.
238
+
239
+ ### `session.request(path, init?)`
240
+
241
+ Authenticated HTTP helper. The `path` is relative to `session.baseUrl` unless a
242
+ full URL is supplied by the implementation path handling.
243
+
244
+ Input body may be a normal `BodyInit`, an object, or `null`.
245
+
246
+ Returns the raw `Response`.
247
+
248
+ ### `session.fetchAccountStatus()`
249
+
250
+ Fetches and applies account status. Returns the decoded server response as
251
+ `unknown` because the live shape is not fully stabilized.
252
+
253
+ ### `session.fetchShips(server)`
254
+
255
+ Returns `Ship[]`.
256
+
257
+ ### `session.fetchShipList(server)`
258
+
259
+ Returns `ShipList`.
260
+
261
+ ### Connection factories
262
+
263
+ These return `Connection` objects and do not open the websocket:
264
+
265
+ ```ts
266
+ session.joinShipConnection(server, ship?): Promise<Connection>;
267
+ session.startShipConnection(server, ship?): Promise<Connection>;
268
+ session.startNewShipConnection(server, name?, color?): Promise<Connection>;
269
+ session.joinInviteConnection(server, code): Promise<Connection>;
270
+ ```
271
+
272
+ Use these when you want to construct `DredlessClient` yourself.
273
+
274
+ ### Client factories
275
+
276
+ These return live `DredlessClient` objects:
277
+
278
+ ```ts
279
+ session.joinShip(server, ship?): Promise<DredlessClient>;
280
+ session.startShip(server, ship?): Promise<DredlessClient>;
281
+ session.startNewShip(server, name?, color?): Promise<DredlessClient>;
282
+ session.joinInvite(server, code): Promise<DredlessClient>;
283
+ ```
284
+
285
+ ### `session.toJSON()`
286
+
287
+ ```ts
288
+ interface SessionSnapshot {
289
+ baseUrl: string;
290
+ gameSession: string;
291
+ gameToken: string;
292
+ gameVersion: string | null;
293
+ noticeVersion: number | string | null;
294
+ cookies: Record<string, string>;
295
+ account: Account | null;
296
+ geoServer: number | null;
297
+ upgraded: boolean;
298
+ isRegistered: boolean;
299
+ showAds: boolean;
300
+ forceTutorial: boolean;
301
+ ban: unknown;
302
+ anonKey?: string;
303
+ }
304
+ ```
305
+
306
+ ## `AnonSession`
307
+
308
+ ```ts
309
+ class AnonSession extends Session {
310
+ constructor(
311
+ gameSession?: string | null,
312
+ anonKey?: string | null,
313
+ gameVersion?: string | null
314
+ );
315
+
316
+ get anonKey(): string;
317
+ }
318
+ ```
319
+
320
+ `AnonSession` is a `Session` with anonymous account key handling.
321
+
322
+ ## `Connection`
323
+
324
+ `Connection` is a no-I/O descriptor for an already joined game session.
325
+
326
+ ```ts
327
+ class Connection {
328
+ constructor(
329
+ session: Session,
330
+ gameToken: string,
331
+ netPort: number,
332
+ serverId: number | Server,
333
+ server?: Server | null
334
+ );
335
+
336
+ session: Session;
337
+ baseUrl: string;
338
+ gameToken: string;
339
+ netPort: number;
340
+ serverId: number;
341
+ server: Server | null;
342
+
343
+ toJSON(): ConnectionSnapshot;
344
+ }
345
+ ```
346
+
347
+ ### `connection.toJSON()`
348
+
349
+ ```ts
350
+ interface ConnectionSnapshot {
351
+ baseUrl: string;
352
+ gameToken: string;
353
+ netPort: number;
354
+ serverId: number;
355
+ server: Server | null;
356
+ session: SessionSnapshot;
357
+ }
358
+ ```
359
+