dredless 0.3.0 → 0.4.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/dist/browser/dredless.global.js +13 -1
- package/dist/browser/dredless.global.js.map +3 -3
- package/docs/API_REFERENCE.md +20 -3
- package/package.json +1 -1
- package/src/client/core.js +6 -1
- package/src/index.d.ts +12 -4
- 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
|
@@ -322,7 +322,7 @@ interface ClientSnapshot {
|
|
|
322
322
|
currentWorldId: number | null;
|
|
323
323
|
worlds: WorldSnapshot[];
|
|
324
324
|
cpuLoad: number | null;
|
|
325
|
-
inventory: InventoryState
|
|
325
|
+
inventory: InventoryState;
|
|
326
326
|
puiPanels: PuiEvent[];
|
|
327
327
|
commsPanels: CommsEvent[];
|
|
328
328
|
currentCommsPanel: CommsEvent | null;
|
|
@@ -493,7 +493,7 @@ const EquipmentSlot = { Head: "head", Face: "face", Body: "body", Back: "back",
|
|
|
493
493
|
type EquipmentSlot = typeof EquipmentSlot[keyof typeof EquipmentSlot];
|
|
494
494
|
|
|
495
495
|
interface InventoryDomain {
|
|
496
|
-
state(): InventoryState
|
|
496
|
+
state(): InventoryState;
|
|
497
497
|
hotbarSize(): number;
|
|
498
498
|
allSlots(): InventorySlotHandle[];
|
|
499
499
|
slot(ref: InventorySlotRef): InventorySlotHandle;
|
|
@@ -1320,7 +1320,7 @@ interface HelmHandle extends MachineHandle {
|
|
|
1320
1320
|
occupied: boolean | undefined;
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
|
-
interface DoorHandle extends
|
|
1323
|
+
interface DoorHandle extends EntityHandle {
|
|
1324
1324
|
state: DoorSummary | null;
|
|
1325
1325
|
rank: number | undefined;
|
|
1326
1326
|
open: boolean | undefined;
|
|
@@ -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("/save");
|
|
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
|
+
"version": "0.4.0",
|
|
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";
|
|
@@ -143,7 +144,7 @@ export class DredlessClient extends EventBus {
|
|
|
143
144
|
this.inventory = new InventoryDomain(this);
|
|
144
145
|
this.management = new ShipManagementDomain(this);
|
|
145
146
|
this.cpuLoad = null;
|
|
146
|
-
this.inventoryState =
|
|
147
|
+
this.inventoryState = normalizeInventoryEvent({type: "inventory", general_slots: 5});
|
|
147
148
|
this.puiPanels = new Map();
|
|
148
149
|
this.commsPanels = new Map();
|
|
149
150
|
this.currentCommsPanel = null;
|
|
@@ -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
|
|
|
@@ -605,7 +612,7 @@ export interface ShipManagementDomain {
|
|
|
605
612
|
}
|
|
606
613
|
|
|
607
614
|
export interface InventoryDomain {
|
|
608
|
-
state(): InventoryState
|
|
615
|
+
state(): InventoryState;
|
|
609
616
|
|
|
610
617
|
hotbarSize(): number;
|
|
611
618
|
|
|
@@ -1107,7 +1114,7 @@ export interface HelmHandle extends MachineHandle {
|
|
|
1107
1114
|
occupied: boolean | undefined;
|
|
1108
1115
|
}
|
|
1109
1116
|
|
|
1110
|
-
export interface DoorHandle extends
|
|
1117
|
+
export interface DoorHandle extends EntityHandle {
|
|
1111
1118
|
state: DoorSummary | null;
|
|
1112
1119
|
rank: number | undefined;
|
|
1113
1120
|
open: boolean | undefined;
|
|
@@ -1173,7 +1180,7 @@ export interface ClientSnapshot {
|
|
|
1173
1180
|
currentWorldId: number | null;
|
|
1174
1181
|
worlds: WorldSnapshot[];
|
|
1175
1182
|
cpuLoad: number | null;
|
|
1176
|
-
inventory: InventoryState
|
|
1183
|
+
inventory: InventoryState;
|
|
1177
1184
|
puiPanels: PuiEvent[];
|
|
1178
1185
|
commsPanels: CommsEvent[];
|
|
1179
1186
|
currentCommsPanel: CommsEvent | null;
|
|
@@ -1756,7 +1763,6 @@ export interface BotSummary {
|
|
|
1756
1763
|
export interface FabricatorSummary {
|
|
1757
1764
|
entity: number;
|
|
1758
1765
|
type: FabricatorType | null;
|
|
1759
|
-
typeIndex: number | null;
|
|
1760
1766
|
typeIndex: number | null;
|
|
1761
1767
|
state: ModelRecord;
|
|
1762
1768
|
rows: { itemId: number | null; itemName: string | null; count: number | null }[];
|
|
@@ -2108,6 +2114,8 @@ export function decodeMsgpack(bytes: Uint8Array | ArrayBuffer | number[]): unkno
|
|
|
2108
2114
|
|
|
2109
2115
|
export function encodeMsgpack(value: unknown): Uint8Array;
|
|
2110
2116
|
|
|
2117
|
+
export function buildChatMessage(message?: string): ChatMessage;
|
|
2118
|
+
|
|
2111
2119
|
export function buildCommsMessage(message?: string): CommsMessage;
|
|
2112
2120
|
|
|
2113
2121
|
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 {
|