dredless 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -48
- package/dist/browser/dredless.global.js +12047 -0
- package/dist/browser/dredless.global.js.map +7 -0
- package/docs/API_REFERENCE.md +2481 -2481
- package/docs/BROWSER_API.md +98 -98
- package/docs/NODE_API.md +359 -359
- package/package.json +40 -35
- package/src/browser-global.js +3 -0
- package/src/browser.d.ts +212 -212
- package/src/browser.js +133 -133
- package/src/client/core.js +1202 -1202
- package/src/client/domains/index.js +1818 -1818
- package/src/client/index.d.ts +2 -2
- package/src/client/index.js +1 -1
- package/src/compression/lz4.d.ts +1 -1
- package/src/compression/lz4.js +112 -112
- package/src/constants.js +74 -74
- package/src/crypto/chacha-native.d.ts +9 -9
- package/src/crypto/chacha-native.js +48 -48
- package/src/crypto/chacha.d.ts +25 -25
- package/src/crypto/chacha.js +274 -274
- package/src/events.js +39 -39
- package/src/index.d.ts +2277 -2277
- package/src/index.js +125 -125
- package/src/network/browser-session.js +291 -291
- package/src/network/connection.d.ts +1 -1
- package/src/network/connection.js +31 -31
- package/src/network/cookies.js +85 -85
- package/src/network/http.js +34 -34
- package/src/network/index.d.ts +4 -4
- package/src/network/index.js +4 -4
- package/src/network/servers.d.ts +7 -7
- package/src/network/servers.js +133 -133
- package/src/network/session.d.ts +7 -7
- package/src/network/session.js +320 -320
- package/src/network/ships.d.ts +12 -12
- package/src/network/ships.js +73 -73
- package/src/node.d.ts +2 -2
- package/src/node.js +8 -8
- package/src/protocol/codec/binary.d.ts +3 -3
- package/src/protocol/codec/binary.js +52 -52
- package/src/protocol/codec/msgpack.d.ts +3 -3
- package/src/protocol/codec/msgpack.js +555 -555
- package/src/protocol/inbound/frame.d.ts +1 -1
- package/src/protocol/inbound/frame.js +8 -8
- package/src/protocol/inbound/world-payload.d.ts +3 -3
- package/src/protocol/inbound/world-payload.js +21 -21
- package/src/protocol/index.d.ts +11 -11
- package/src/protocol/index.js +19 -19
- package/src/protocol/outbound/blueprint.d.ts +22 -22
- package/src/protocol/outbound/blueprint.js +36 -36
- package/src/protocol/outbound/commands.d.ts +3 -3
- package/src/protocol/outbound/commands.js +149 -149
- package/src/protocol/outbound/comms.d.ts +28 -28
- package/src/protocol/outbound/comms.js +40 -40
- package/src/protocol/outbound/inventory.d.ts +64 -64
- package/src/protocol/outbound/inventory.js +147 -147
- package/src/protocol/outbound/ship-management.d.ts +84 -84
- package/src/protocol/outbound/ship-management.js +221 -221
- package/src/protocol/outbound/sign.d.ts +18 -18
- package/src/protocol/outbound/sign.js +45 -45
- package/src/protocol/outbound/ui-config.d.ts +157 -157
- package/src/protocol/outbound/ui-config.js +578 -578
- package/src/runtime.js +36 -36
- package/src/state/generator-maze.d.ts +32 -32
- package/src/state/generator-maze.js +370 -370
- package/src/state/index.d.ts +3 -3
- package/src/state/index.js +3 -3
- package/src/state/items.js +20 -20
- package/src/state/model/decoder.js +1554 -1554
- package/src/state/model/index.d.ts +33 -33
- package/src/state/model/index.js +2 -2
- package/src/state/model/loader-config.js +1020 -1020
- package/src/state/model/reader.js +69 -69
- package/src/state/model/state.js +1257 -1257
- package/src/state/overworld.js +72 -72
- package/src/state/tilesets.js +53 -53
- package/src/state/world/index.d.ts +29 -29
- package/src/state/world/index.js +180 -180
- package/src/state/world/state.js +297 -297
package/docs/BROWSER_API.md
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
# Dredless Browser API
|
|
2
|
-
|
|
3
|
-
This document covers the browser-specific top-level API: ambient browser sessions, browser cookie handling, and browser start/join helpers.
|
|
4
|
-
|
|
5
|
-
Use this entrypoint in browser contexts:
|
|
6
|
-
|
|
7
|
-
```js
|
|
8
|
-
import Dredless, { BrowserSession } from "dredless/browser";
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Normal browser usage:
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
const session = await Dredless.createAnonSession();
|
|
15
|
-
const servers = await Dredless.fetchServers();
|
|
16
|
-
const ships = await Dredless.fetchShips(servers[0]);
|
|
17
|
-
const client = await Dredless.startShip(servers[0], ships[0]);
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
The browser API uses the current browser cookie jar with `credentials: "include"`. Browser JavaScript cannot read `Set-Cookie`, cannot set the `Cookie` header, and cannot set custom WebSocket headers, so browser authentication is ambient rather than multi-session.
|
|
21
|
-
|
|
22
|
-
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).
|
|
23
|
-
|
|
24
|
-
## `DredlessBrowser` Namespace
|
|
25
|
-
|
|
26
|
-
`dredless/browser` exports a browser-first namespace. It assumes the current browser cookie jar and does not expose `Session` or `AnonSession`.
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
interface DredlessBrowserNamespace {
|
|
30
|
-
BrowserSession: typeof BrowserSession;
|
|
31
|
-
Connection: typeof Connection;
|
|
32
|
-
DredlessClient: typeof DredlessClient;
|
|
33
|
-
browserSession: typeof browserSession;
|
|
34
|
-
createBrowserSession: typeof createBrowserSession;
|
|
35
|
-
createSession: typeof createSession;
|
|
36
|
-
createAnonSession: typeof createAnonSession;
|
|
37
|
-
createAnonToken: typeof createAnonToken;
|
|
38
|
-
fetchAnonKey: typeof fetchAnonKey;
|
|
39
|
-
setBrowserSession: typeof setBrowserSession;
|
|
40
|
-
fetchAccountStatus: typeof fetchAccountStatus;
|
|
41
|
-
fetchNoticeVersion: typeof fetchNoticeVersion;
|
|
42
|
-
fetchGameVersion: typeof fetchGameVersion;
|
|
43
|
-
fetchServers: typeof fetchServers;
|
|
44
|
-
fetchShips: typeof fetchShips;
|
|
45
|
-
fetchShipList: typeof fetchShipList;
|
|
46
|
-
joinShip: typeof joinShip;
|
|
47
|
-
startShip: typeof startShip;
|
|
48
|
-
startNewShip: typeof startNewShip;
|
|
49
|
-
joinInvite: typeof joinInvite;
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
`createSession(noticeVersion?, baseUrl?)` initializes the ambient browser session, fetches account status, and returns the active `BrowserSession`.
|
|
54
|
-
|
|
55
|
-
`createAnonSession(anonKey?, noticeVersion?, baseUrl?)` creates or applies an anonymous browser session. If `anonKey` is omitted, it posts to `/account/login/anon`, then reads `anon_key` through `cookieStore` or `document.cookie`. If the key cannot be read, it throws. If `anonKey` is provided, it is written to the ambient cookie jar when possible. The return value is still the active `BrowserSession`, not an isolated cookie jar.
|
|
56
|
-
|
|
57
|
-
`fetchAnonKey(noticeVersion?, baseUrl?)` / `createAnonToken(noticeVersion?, baseUrl?)` posts to `/account/login/anon` and returns the JS-readable `anon_key`. It throws if the login succeeds but the key is not readable through `cookieStore` or `document.cookie`.
|
|
58
|
-
|
|
59
|
-
Browser support is tested in page and content-script contexts on `drednot.io`. Background pages, popups, workers, and other non-page contexts are unlikely to expose `drednot.io` cookies to this API.
|
|
60
|
-
|
|
61
|
-
`fetchShips(server)` and `fetchShipList(server)` use the default ambient `BrowserSession`. Pass an explicit `BrowserSession` as the last argument only when targeting a different `baseUrl`.
|
|
62
|
-
|
|
63
|
-
`joinShip`, `startShip`, `startNewShip`, and `joinInvite` return ready `DredlessClient` instances just like the Node helpers.
|
|
64
|
-
|
|
65
|
-
## `BrowserSession`
|
|
66
|
-
|
|
67
|
-
`BrowserSession` is the browser counterpart to `Session`, but it is ambient-cookie based. It cannot read `Set-Cookie` and cannot set websocket headers, so authentication must be accepted by the browser's cookie jar.
|
|
68
|
-
|
|
69
|
-
```ts
|
|
70
|
-
class BrowserSession {
|
|
71
|
-
constructor(baseUrl?: string);
|
|
72
|
-
baseUrl: string;
|
|
73
|
-
ambientAuth: true;
|
|
74
|
-
|
|
75
|
-
readAnonKey(): Promise<string>;
|
|
76
|
-
fetchAnonKey(noticeVersion?: number | null): Promise<string>;
|
|
77
|
-
fetchAccountStatus(): Promise<unknown>;
|
|
78
|
-
fetchShips(server: ServerRef): Promise<Ship[]>;
|
|
79
|
-
fetchShipList(server: ServerRef): Promise<ShipList>;
|
|
80
|
-
|
|
81
|
-
joinShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
82
|
-
startShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
83
|
-
startNewShipConnection(server: ServerRef, name?: string, color?: string): Promise<Connection>;
|
|
84
|
-
joinInviteConnection(server: ServerRef, code: string): Promise<Connection>;
|
|
85
|
-
|
|
86
|
-
joinShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
87
|
-
startShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
88
|
-
startNewShip(server: ServerRef, name?: string, color?: string): Promise<DredlessClient>;
|
|
89
|
-
joinInvite(server: ServerRef, code: string): Promise<DredlessClient>;
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## Browser Connections
|
|
95
|
-
|
|
96
|
-
Browser start/join helpers still produce `Connection` objects internally, but a browser `Connection` may have an empty `gameToken` when the token is only available through browser-managed cookies. `DredlessClient` uses the browser `WebSocket` implementation and relies on browser-managed cookies and origin headers.
|
|
97
|
-
|
|
98
|
-
The shared `DredlessClient` API is documented in [API_REFERENCE.md](./API_REFERENCE.md#dredlessclient).
|
|
1
|
+
# Dredless Browser API
|
|
2
|
+
|
|
3
|
+
This document covers the browser-specific top-level API: ambient browser sessions, browser cookie handling, and browser start/join helpers.
|
|
4
|
+
|
|
5
|
+
Use this entrypoint in browser contexts:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import Dredless, { BrowserSession } from "dredless/browser";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Normal browser usage:
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
const session = await Dredless.createAnonSession();
|
|
15
|
+
const servers = await Dredless.fetchServers();
|
|
16
|
+
const ships = await Dredless.fetchShips(servers[0]);
|
|
17
|
+
const client = await Dredless.startShip(servers[0], ships[0]);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The browser API uses the current browser cookie jar with `credentials: "include"`. Browser JavaScript cannot read `Set-Cookie`, cannot set the `Cookie` header, and cannot set custom WebSocket headers, so browser authentication is ambient rather than multi-session.
|
|
21
|
+
|
|
22
|
+
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).
|
|
23
|
+
|
|
24
|
+
## `DredlessBrowser` Namespace
|
|
25
|
+
|
|
26
|
+
`dredless/browser` exports a browser-first namespace. It assumes the current browser cookie jar and does not expose `Session` or `AnonSession`.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
interface DredlessBrowserNamespace {
|
|
30
|
+
BrowserSession: typeof BrowserSession;
|
|
31
|
+
Connection: typeof Connection;
|
|
32
|
+
DredlessClient: typeof DredlessClient;
|
|
33
|
+
browserSession: typeof browserSession;
|
|
34
|
+
createBrowserSession: typeof createBrowserSession;
|
|
35
|
+
createSession: typeof createSession;
|
|
36
|
+
createAnonSession: typeof createAnonSession;
|
|
37
|
+
createAnonToken: typeof createAnonToken;
|
|
38
|
+
fetchAnonKey: typeof fetchAnonKey;
|
|
39
|
+
setBrowserSession: typeof setBrowserSession;
|
|
40
|
+
fetchAccountStatus: typeof fetchAccountStatus;
|
|
41
|
+
fetchNoticeVersion: typeof fetchNoticeVersion;
|
|
42
|
+
fetchGameVersion: typeof fetchGameVersion;
|
|
43
|
+
fetchServers: typeof fetchServers;
|
|
44
|
+
fetchShips: typeof fetchShips;
|
|
45
|
+
fetchShipList: typeof fetchShipList;
|
|
46
|
+
joinShip: typeof joinShip;
|
|
47
|
+
startShip: typeof startShip;
|
|
48
|
+
startNewShip: typeof startNewShip;
|
|
49
|
+
joinInvite: typeof joinInvite;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`createSession(noticeVersion?, baseUrl?)` initializes the ambient browser session, fetches account status, and returns the active `BrowserSession`.
|
|
54
|
+
|
|
55
|
+
`createAnonSession(anonKey?, noticeVersion?, baseUrl?)` creates or applies an anonymous browser session. If `anonKey` is omitted, it posts to `/account/login/anon`, then reads `anon_key` through `cookieStore` or `document.cookie`. If the key cannot be read, it throws. If `anonKey` is provided, it is written to the ambient cookie jar when possible. The return value is still the active `BrowserSession`, not an isolated cookie jar.
|
|
56
|
+
|
|
57
|
+
`fetchAnonKey(noticeVersion?, baseUrl?)` / `createAnonToken(noticeVersion?, baseUrl?)` posts to `/account/login/anon` and returns the JS-readable `anon_key`. It throws if the login succeeds but the key is not readable through `cookieStore` or `document.cookie`.
|
|
58
|
+
|
|
59
|
+
Browser support is tested in page and content-script contexts on `drednot.io`. Background pages, popups, workers, and other non-page contexts are unlikely to expose `drednot.io` cookies to this API.
|
|
60
|
+
|
|
61
|
+
`fetchShips(server)` and `fetchShipList(server)` use the default ambient `BrowserSession`. Pass an explicit `BrowserSession` as the last argument only when targeting a different `baseUrl`.
|
|
62
|
+
|
|
63
|
+
`joinShip`, `startShip`, `startNewShip`, and `joinInvite` return ready `DredlessClient` instances just like the Node helpers.
|
|
64
|
+
|
|
65
|
+
## `BrowserSession`
|
|
66
|
+
|
|
67
|
+
`BrowserSession` is the browser counterpart to `Session`, but it is ambient-cookie based. It cannot read `Set-Cookie` and cannot set websocket headers, so authentication must be accepted by the browser's cookie jar.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
class BrowserSession {
|
|
71
|
+
constructor(baseUrl?: string);
|
|
72
|
+
baseUrl: string;
|
|
73
|
+
ambientAuth: true;
|
|
74
|
+
|
|
75
|
+
readAnonKey(): Promise<string>;
|
|
76
|
+
fetchAnonKey(noticeVersion?: number | null): Promise<string>;
|
|
77
|
+
fetchAccountStatus(): Promise<unknown>;
|
|
78
|
+
fetchShips(server: ServerRef): Promise<Ship[]>;
|
|
79
|
+
fetchShipList(server: ServerRef): Promise<ShipList>;
|
|
80
|
+
|
|
81
|
+
joinShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
82
|
+
startShipConnection(server: ServerRef, ship?: ShipRef): Promise<Connection>;
|
|
83
|
+
startNewShipConnection(server: ServerRef, name?: string, color?: string): Promise<Connection>;
|
|
84
|
+
joinInviteConnection(server: ServerRef, code: string): Promise<Connection>;
|
|
85
|
+
|
|
86
|
+
joinShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
87
|
+
startShip(server: ServerRef, ship?: ShipRef): Promise<DredlessClient>;
|
|
88
|
+
startNewShip(server: ServerRef, name?: string, color?: string): Promise<DredlessClient>;
|
|
89
|
+
joinInvite(server: ServerRef, code: string): Promise<DredlessClient>;
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Browser Connections
|
|
95
|
+
|
|
96
|
+
Browser start/join helpers still produce `Connection` objects internally, but a browser `Connection` may have an empty `gameToken` when the token is only available through browser-managed cookies. `DredlessClient` uses the browser `WebSocket` implementation and relies on browser-managed cookies and origin headers.
|
|
97
|
+
|
|
98
|
+
The shared `DredlessClient` API is documented in [API_REFERENCE.md](./API_REFERENCE.md#dredlessclient).
|