dredless 0.3.0 → 0.3.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/dist/browser/dredless.global.js +12 -0
- package/dist/browser/dredless.global.js.map +3 -3
- package/docs/API_REFERENCE.md +17 -0
- package/package.json +1 -1
- package/src/client/core.js +5 -0
- package/src/index.d.ts +9 -0
- package/src/index.js +1 -0
- package/src/protocol/index.d.ts +1 -0
- package/src/protocol/index.js +1 -0
- package/src/protocol/outbound/chat.d.ts +8 -0
- package/src/protocol/outbound/chat.js +13 -0
package/docs/API_REFERENCE.md
CHANGED
|
@@ -2117,6 +2117,23 @@ interface InventoryDragCommand {
|
|
|
2117
2117
|
|
|
2118
2118
|
`normalizeInventoryEvent()` returns the normalized `InventoryState` shape documented under `client.inventory`.
|
|
2119
2119
|
|
|
2120
|
+
### Chat helpers
|
|
2121
|
+
|
|
2122
|
+
Module: `dredless/protocol/chat` or root.
|
|
2123
|
+
|
|
2124
|
+
```ts
|
|
2125
|
+
function buildChatMessage(message?: string): ChatMessage;
|
|
2126
|
+
```
|
|
2127
|
+
|
|
2128
|
+
Ship chat uses protocol message type 2. It is separate from comms-station
|
|
2129
|
+
messages, which use type 3. The game handles ship chat through the same
|
|
2130
|
+
chat-command path used by its chat commands, so client.sendChatMessage() can
|
|
2131
|
+
send executable chat commands as well as ordinary chat text. For example:
|
|
2132
|
+
|
|
2133
|
+
```js
|
|
2134
|
+
client.sendChatMessage("/help");
|
|
2135
|
+
```
|
|
2136
|
+
|
|
2120
2137
|
### Comms helpers
|
|
2121
2138
|
|
|
2122
2139
|
Module: `dredless/protocol/comms` or root.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dredless",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A fully-featured and from-scratch headless drednot.io client implementation written in pure js.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/certainhuman/dredless#readme",
|
package/src/client/core.js
CHANGED
|
@@ -7,6 +7,7 @@ import {Connection} from "../network/connection.js";
|
|
|
7
7
|
import {itemEquipmentSlotFromId} from "../state/items.js";
|
|
8
8
|
import {WorldStore} from "../state/world/index.js";
|
|
9
9
|
import {buildBlueprintPlacementMessage} from "../protocol/outbound/blueprint.js";
|
|
10
|
+
import {buildChatMessage} from "../protocol/outbound/chat.js";
|
|
10
11
|
import {buildCommsMessage, normalizeCommsEvent} from "../protocol/outbound/comms.js";
|
|
11
12
|
import {buildSignedCommandPacket} from "../protocol/outbound/commands.js";
|
|
12
13
|
import {buildInventoryDragCommand, normalizeEquipmentSlot, normalizeInventoryEvent} from "../protocol/outbound/inventory.js";
|
|
@@ -286,6 +287,10 @@ export class DredlessClient extends EventBus {
|
|
|
286
287
|
return this.sendMessage({type: 5, cmd, args});
|
|
287
288
|
}
|
|
288
289
|
|
|
290
|
+
sendChatMessage(message = "") {
|
|
291
|
+
return this.sendMessage(buildChatMessage(message));
|
|
292
|
+
}
|
|
293
|
+
|
|
289
294
|
sendCommsMessage(message = "") {
|
|
290
295
|
return this.sendMessage(buildCommsMessage(message));
|
|
291
296
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -132,6 +132,11 @@ export interface BlueprintPlacement {
|
|
|
132
132
|
source: string;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
export interface ChatMessage {
|
|
136
|
+
type: 2;
|
|
137
|
+
msg: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
135
140
|
export interface BlueprintPlacementMessage {
|
|
136
141
|
type: 9;
|
|
137
142
|
x: number;
|
|
@@ -463,6 +468,8 @@ export class DredlessClient {
|
|
|
463
468
|
close(code?: number, reason?: string): this;
|
|
464
469
|
|
|
465
470
|
disconnect(code?: number, reason?: string): this;
|
|
471
|
+
sendChatMessage(message?: string): this;
|
|
472
|
+
sendCommsMessage(message?: string): this;
|
|
466
473
|
|
|
467
474
|
currentShip(): ShipDomain | null;
|
|
468
475
|
|
|
@@ -2108,6 +2115,8 @@ export function decodeMsgpack(bytes: Uint8Array | ArrayBuffer | number[]): unkno
|
|
|
2108
2115
|
|
|
2109
2116
|
export function encodeMsgpack(value: unknown): Uint8Array;
|
|
2110
2117
|
|
|
2118
|
+
export function buildChatMessage(message?: string): ChatMessage;
|
|
2119
|
+
|
|
2111
2120
|
export function buildCommsMessage(message?: string): CommsMessage;
|
|
2112
2121
|
|
|
2113
2122
|
export function normalizeCommsEvent(event: unknown): CommsEvent;
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export {WorldStore, WorldState} from "./state/world/index.js";
|
|
|
5
5
|
export {FabricatorType, ModelState, decodeModelData} from "./state/model/index.js";
|
|
6
6
|
export {generateGeneratorMaze, solveGeneratorMazeSeed, maybeSolveGeneratorMazeSeed} from "./state/generator-maze.js";
|
|
7
7
|
export {buildBlueprintPlacementMessage} from "./protocol/outbound/blueprint.js";
|
|
8
|
+
export {buildChatMessage} from "./protocol/outbound/chat.js";
|
|
8
9
|
export {decodeMsgpack, encodeMsgpack} from "./protocol/codec/msgpack.js";
|
|
9
10
|
export {
|
|
10
11
|
buildCommsMessage,
|
package/src/protocol/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./codec/binary.js";
|
|
|
3
3
|
export * from "./inbound/frame.js";
|
|
4
4
|
export * from "./inbound/world-payload.js";
|
|
5
5
|
export * from "./outbound/blueprint.js";
|
|
6
|
+
export * from "./outbound/chat.js";
|
|
6
7
|
export * from "./outbound/comms.js";
|
|
7
8
|
export * from "./outbound/commands.js";
|
|
8
9
|
export * from "./outbound/inventory.js";
|
package/src/protocol/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export {toUint8Array, concatBytes, valuesEqual} from "./codec/binary.js";
|
|
|
3
3
|
export {decodeIncomingFrame} from "./inbound/frame.js";
|
|
4
4
|
export {decodeWorldPayload, decodeModelPayload, decompressWorldChunk} from "./inbound/world-payload.js";
|
|
5
5
|
export {buildBlueprintPlacementMessage} from "./outbound/blueprint.js";
|
|
6
|
+
export {buildChatMessage} from "./outbound/chat.js";
|
|
6
7
|
export {buildCommsMessage, flattenRichText, normalizeCommsEvent} from "./outbound/comms.js";
|
|
7
8
|
export {buildSignedCommandPacket} from "./outbound/commands.js";
|
|
8
9
|
export {
|