dredless 1.4.2 → 1.5.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 +417 -245
- package/dist/browser/dredless.global.js.map +4 -4
- package/docs/MACHINES.md +43 -0
- package/docs/MANAGEMENT.md +2 -2
- package/docs/WORLD_STATE.md +25 -0
- package/package.json +1 -1
- package/src/client/core.js +19 -1
- package/src/client/domains/index.js +19 -0
- package/src/data/item-schema.js +18 -2
- package/src/index.d.ts +52 -5
- package/src/index.js +1 -0
- package/src/protocol/codec/ui-integer.js +7 -0
- package/src/protocol/outbound/advanced-expando.js +65 -0
- package/src/protocol/outbound/machine-config.js +1 -6
- package/src/protocol/outbound/ui-config.d.ts +6 -0
- package/src/protocol/outbound/ui-config.js +7 -9
- package/src/state/model/decoder.js +43 -11
- package/src/state/model/state.js +37 -4
- package/src/state/world/state.js +1 -1
package/docs/MACHINES.md
CHANGED
|
@@ -437,3 +437,46 @@ Cargo ejector rendering state uses table 49 `q20 / 100` for `progress`,
|
|
|
437
437
|
`q24` for the signed `direction` offset, `q28 / 100` for `extension`, and
|
|
438
438
|
`q33` for `noMount`. `active` reports a nonzero cycle or extension; it is
|
|
439
439
|
not the mount flag. The summary also exposes the raw `state`.
|
|
440
|
+
|
|
441
|
+
## Advanced Expando Boxes
|
|
442
|
+
|
|
443
|
+
Item `266` is an Advanced Expando Box; item `267` is the Advanced Logistics Controller
|
|
444
|
+
crafting component. `ship.machines.expandoBoxes()` includes both basic and advanced boxes.
|
|
445
|
+
An advanced box exposes `state.advanced === true` and `state.config`, containing its
|
|
446
|
+
minimum/maximum dimensions, enable flags, RGB colors, and opacity. Actual observed
|
|
447
|
+
`state.width` and `state.height` remain separate from the configured limits.
|
|
448
|
+
|
|
449
|
+
```js
|
|
450
|
+
const box = client.currentShip().machines.expandoBox(entityId);
|
|
451
|
+
box.configure({minEnabled: true, minWidth: 4, minHeight: 2, opacity: 0.5});
|
|
452
|
+
box.copy(); // Copies observed settings into clipboard class 11.
|
|
453
|
+
box.paste({backgroundColor: 0x224466});
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
`configure`, `copy`, and `paste` preserve omitted settings from the observed configuration.
|
|
457
|
+
They require an advanced box and return immediately; observe subsequent replicated state
|
|
458
|
+
for confirmation. Basic boxes retain their inventory and dimensions but reject these methods.
|
|
459
|
+
|
|
460
|
+
`AdvancedExpandoBoxConfig` fields:
|
|
461
|
+
|
|
462
|
+
| Field | Meaning |
|
|
463
|
+
| --- | --- |
|
|
464
|
+
| `minWidth`, `minHeight` | Minimum dimensions; also the dimensions used by fixed-size mode |
|
|
465
|
+
| `maxWidth`, `maxHeight` | Maximum dimensions |
|
|
466
|
+
| `minEnabled`, `maxEnabled` | Enable the respective limits |
|
|
467
|
+
| `fixedSize` | Request fixed dimensions instead of automatic expansion |
|
|
468
|
+
| `backgroundColor`, `borderColor` | Integer RGB colors, `0x000000`–`0xffffff` |
|
|
469
|
+
| `opacity` | Background opacity, `0`–`1` |
|
|
470
|
+
|
|
471
|
+
Dimensions use world units and accept values from `2` to `100`. Defaults are minimum
|
|
472
|
+
`2×2`, maximum `10×10`, all limit flags disabled, background `0xdddddd`, border
|
|
473
|
+
`0x404040`, and opacity `1`. The server enforces expansion space, capacity, and the
|
|
474
|
+
4:1 aspect-ratio limit. Like the official client, Dredless permits minimum dimensions
|
|
475
|
+
larger than maximum dimensions; the maximum applies where enabled.
|
|
476
|
+
|
|
477
|
+
Low-level builders are `buildAdvancedExpandoBoxConfigData(entity, config?)`,
|
|
478
|
+
`buildAdvancedExpandoBoxCopyConfigData(config?)`, and
|
|
479
|
+
`buildAdvancedExpandoBoxPasteConfigData(entity, config?)`. They return UI configuration
|
|
480
|
+
bytes and use defaults for omitted fields; they cannot read observed state. Direct client
|
|
481
|
+
methods are `sendAdvancedExpandoBoxConfig`, `copyAdvancedExpandoBoxConfig`, and
|
|
482
|
+
`pasteAdvancedExpandoBoxConfig`, each taking an entity ID and optional settings.
|
package/docs/MANAGEMENT.md
CHANGED
|
@@ -80,12 +80,12 @@ client.management.save(options?: {timeout?: number}): Promise<DisconnectInfo>;
|
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
`canSave()` requires a connected/ready client, a current ship with a known parent world, and parent `danger_level === 0`
|
|
83
|
-
(Safe Zone). Missing or unsafe metadata returns `false`. It does not check all server-side permission rules.
|
|
83
|
+
(Safe Zone). Missing or unsafe metadata returns `false`. Partial metadata updates retain the last known danger level. It does not check all server-side permission rules.
|
|
84
84
|
|
|
85
85
|
**Fragment:** this saves the ship and ejects its players:
|
|
86
86
|
|
|
87
87
|
```js
|
|
88
|
-
if (!client.management.canSave()) throw new Error("Ship is not
|
|
88
|
+
if (!client.management.canSave()) throw new Error("Ship is not locally eligible to save");
|
|
89
89
|
const result = await client.management.save();
|
|
90
90
|
console.log(result.name); // Saved
|
|
91
91
|
```
|
package/docs/WORLD_STATE.md
CHANGED
|
@@ -406,3 +406,28 @@ discrete direction enums have operation-specific wire mappings. [Machines](MACHI
|
|
|
406
406
|
Readiness does not guarantee all component tables, a local player, a panel, or another ship's interior. Watch `model`/
|
|
407
407
|
`world` events, tolerate missing fields, and inspect [decode errors](PROTOCOL.md#debug-domains-and-state-classes) when
|
|
408
408
|
apparently present objects cannot be read.
|
|
409
|
+
|
|
410
|
+
## Direct component reads
|
|
411
|
+
|
|
412
|
+
Renderers and other frequent readers can use `WorldState.model` without building entity debug summaries or category lists:
|
|
413
|
+
|
|
414
|
+
```js
|
|
415
|
+
const model = client.worlds.shipWorld()?.model;
|
|
416
|
+
if (model) {
|
|
417
|
+
for (const id of model.componentEntityIds()) {
|
|
418
|
+
const revision = model.entityRevision(id);
|
|
419
|
+
const transform = model.record(0, id);
|
|
420
|
+
// Retain derived render data until this entity's revision changes.
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
`componentEntityIds()` returns a sorted iterator over live component entity IDs. `entityRevision(id)` returns the last local
|
|
426
|
+
apply revision that touched the entity, or zero after removal. `revision` increases on every `apply()`, independently of the
|
|
427
|
+
wire generation counter. This covers several packets between reads, removal/recreation of the same ID, and partially
|
|
428
|
+
applied records when decoding reports an error. These indexes are maintained by the decoder; they describe decoded
|
|
429
|
+
component mutations, not local-player selection or other external rendering context.
|
|
430
|
+
|
|
431
|
+
Raw records mutate in place. `recordRevision(record)` reports their last local apply revision; retain copied render values
|
|
432
|
+
rather than relying on raw record identity. `navigationDestination(id)` reads the tracked navigation destination without
|
|
433
|
+
constructing entity summaries, preserving the destination across flag-only updates.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dredless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
} from "../protocol/outbound/ship-management.js";
|
|
37
37
|
import {buildSignTextMessage} from "../protocol/outbound/sign.js";
|
|
38
38
|
import {
|
|
39
|
+
buildAdvancedExpandoBoxConfigData, buildAdvancedExpandoBoxCopyConfigData, buildAdvancedExpandoBoxPasteConfigData,
|
|
39
40
|
buildLauncherConfigData,
|
|
40
41
|
buildLauncherCopyConfigData,
|
|
41
42
|
buildLauncherPasteConfigData,
|
|
@@ -571,6 +572,23 @@ export class DredlessClient extends EventBus {
|
|
|
571
572
|
return this.sendFabricatorMessage("eject", [row, -1, -1]);
|
|
572
573
|
}
|
|
573
574
|
|
|
575
|
+
#advancedExpandoBoxConfigDefaults(entity, config) {
|
|
576
|
+
const observed = this.worlds.shipWorld()?.entity(entity)?.contents?.expandoBox?.config;
|
|
577
|
+
return {...observed, ...Object.fromEntries(Object.entries(config).filter(([, value]) => value !== undefined))};
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
sendAdvancedExpandoBoxConfig(entity, config = {}) {
|
|
581
|
+
return this.sendUiConfig(buildAdvancedExpandoBoxConfigData(entity, this.#advancedExpandoBoxConfigDefaults(entity, config)));
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
copyAdvancedExpandoBoxConfig(entity, config = {}) {
|
|
585
|
+
return this.sendUiConfig(buildAdvancedExpandoBoxCopyConfigData(this.#advancedExpandoBoxConfigDefaults(entity, config)));
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
pasteAdvancedExpandoBoxConfig(entity, config = {}) {
|
|
589
|
+
return this.sendUiConfig(buildAdvancedExpandoBoxPasteConfigData(entity, this.#advancedExpandoBoxConfigDefaults(entity, config)));
|
|
590
|
+
}
|
|
591
|
+
|
|
574
592
|
sendLauncherConfig(entity, config = {}) {
|
|
575
593
|
return this.sendUiConfig(buildLauncherConfigData(entity, this.#launcherConfigDefaults(entity, config)));
|
|
576
594
|
}
|
|
@@ -1464,7 +1482,7 @@ export class DredlessClient extends EventBus {
|
|
|
1464
1482
|
}
|
|
1465
1483
|
|
|
1466
1484
|
#navigationUnitConfigDefaults(entity, config = {}) {
|
|
1467
|
-
const summary = this.entity(entity)?.contents?.navigationUnit || null;
|
|
1485
|
+
const summary = this.worlds.shipWorld()?.entity(entity)?.contents?.navigationUnit || null;
|
|
1468
1486
|
return {
|
|
1469
1487
|
destination: config.destination ?? summary?.destination,
|
|
1470
1488
|
page: config.page ?? 0,
|
|
@@ -1518,6 +1518,25 @@ export class ExpandoBoxHandle extends MachineHandle {
|
|
|
1518
1518
|
get count() {
|
|
1519
1519
|
return this.state?.count;
|
|
1520
1520
|
}
|
|
1521
|
+
#requireAdvanced() {
|
|
1522
|
+
if (!this.state?.advanced) throw new Error("Configuration requires an Advanced Expando Box");
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
configure(config = {}) {
|
|
1526
|
+
this.#requireAdvanced();
|
|
1527
|
+
return this.client.sendAdvancedExpandoBoxConfig(this.id, config);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
copy(config = {}) {
|
|
1531
|
+
this.#requireAdvanced();
|
|
1532
|
+
return this.client.copyAdvancedExpandoBoxConfig(this.id, config);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
paste(config = {}) {
|
|
1536
|
+
this.#requireAdvanced();
|
|
1537
|
+
return this.client.pasteAdvancedExpandoBoxConfig(this.id, config);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1521
1540
|
}
|
|
1522
1541
|
|
|
1523
1542
|
export class CargoEjectorHandle extends MachineHandle {
|
package/src/data/item-schema.js
CHANGED
|
@@ -938,7 +938,7 @@ export const ITEM_SCHEMA = Object.freeze([
|
|
|
938
938
|
{
|
|
939
939
|
"id": 219,
|
|
940
940
|
"name": "Spawn Point (Packaged)",
|
|
941
|
-
"desc": "Buildable. Can be set to spawn
|
|
941
|
+
"desc": "Buildable. Can be set to spawn specific ranks.",
|
|
942
942
|
"image": "item/spawn",
|
|
943
943
|
"rarity": 0,
|
|
944
944
|
"max_stack": 1,
|
|
@@ -959,7 +959,7 @@ export const ITEM_SCHEMA = Object.freeze([
|
|
|
959
959
|
{
|
|
960
960
|
"id": 220,
|
|
961
961
|
"name": "Door (Packaged)",
|
|
962
|
-
"desc": "Buildable. Can be restricted to specific ranks.
|
|
962
|
+
"desc": "Buildable. Can be restricted to specific ranks.",
|
|
963
963
|
"image": "item/door",
|
|
964
964
|
"rarity": 0,
|
|
965
965
|
"max_stack": 1,
|
|
@@ -1638,6 +1638,22 @@ export const ITEM_SCHEMA = Object.freeze([
|
|
|
1638
1638
|
"rarity": 1,
|
|
1639
1639
|
"max_stack": 1
|
|
1640
1640
|
},
|
|
1641
|
+
{
|
|
1642
|
+
"id": 266,
|
|
1643
|
+
"name": "Advanced Expando Box (Packaged)",
|
|
1644
|
+
"desc": "Buildable. Dense bulk storage with configurable size limits. Spills more items when shot.",
|
|
1645
|
+
"image": "item/exbox_adv",
|
|
1646
|
+
"rarity": 2,
|
|
1647
|
+
"max_stack": 1
|
|
1648
|
+
},
|
|
1649
|
+
{
|
|
1650
|
+
"id": 267,
|
|
1651
|
+
"name": "Advanced Logistics Controller",
|
|
1652
|
+
"desc": "Component. Used to produce advanced logistics machinery.",
|
|
1653
|
+
"image": "item/adv_logi_controller",
|
|
1654
|
+
"rarity": 2,
|
|
1655
|
+
"max_stack": 1
|
|
1656
|
+
},
|
|
1641
1657
|
{
|
|
1642
1658
|
"id": 300,
|
|
1643
1659
|
"name": "Eternal Bronze Wrench",
|
package/src/index.d.ts
CHANGED
|
@@ -438,6 +438,24 @@ export interface RankFilterConfig {
|
|
|
438
438
|
/** 0–7, or 0xffffffff for all current and future ranks. */
|
|
439
439
|
rankMask?: number;
|
|
440
440
|
}
|
|
441
|
+
/** Advanced Expando Box settings. Dimensions are world units (2–100).
|
|
442
|
+
* fixedSize uses minWidth/minHeight; RGB colors are integers 0–0xffffff.
|
|
443
|
+
* The server applies expansion, capacity and aspect-ratio rules.
|
|
444
|
+
*/
|
|
445
|
+
export interface AdvancedExpandoBoxConfig {
|
|
446
|
+
minWidth?: number;
|
|
447
|
+
maxWidth?: number;
|
|
448
|
+
minHeight?: number;
|
|
449
|
+
maxHeight?: number;
|
|
450
|
+
minEnabled?: boolean;
|
|
451
|
+
maxEnabled?: boolean;
|
|
452
|
+
fixedSize?: boolean;
|
|
453
|
+
backgroundColor?: number;
|
|
454
|
+
borderColor?: number;
|
|
455
|
+
/** Background opacity, from 0 to 1. */
|
|
456
|
+
opacity?: number;
|
|
457
|
+
}
|
|
458
|
+
|
|
441
459
|
export interface LauncherConfig {
|
|
442
460
|
/** Degrees, 0–360. */
|
|
443
461
|
angle?: number;
|
|
@@ -485,7 +503,7 @@ export interface AccountDetails {
|
|
|
485
503
|
}
|
|
486
504
|
|
|
487
505
|
export class Session {
|
|
488
|
-
constructor(gameSession?: string | null, gameVersion?: string | null);
|
|
506
|
+
constructor(gameSession?: string | null, gameVersion?: string | null, baseUrl?: string);
|
|
489
507
|
|
|
490
508
|
baseUrl: string;
|
|
491
509
|
cookies: Map<string, string>;
|
|
@@ -505,7 +523,7 @@ export class Session {
|
|
|
505
523
|
get noticeVersion(): number | string | null;
|
|
506
524
|
set noticeVersion(value: number | string | null);
|
|
507
525
|
|
|
508
|
-
request(path: string, init?: RequestInit & { body?:
|
|
526
|
+
request(path: string, init?: Omit<RequestInit, "body"> & { body?: RequestInit["body"] | Record<string, unknown> | null }): Promise<Response>;
|
|
509
527
|
|
|
510
528
|
fetchAccountStatus(): Promise<unknown>;
|
|
511
529
|
|
|
@@ -543,7 +561,7 @@ export class Session {
|
|
|
543
561
|
}
|
|
544
562
|
|
|
545
563
|
export class AnonSession extends Session {
|
|
546
|
-
constructor(gameSession?: string | null, anonKey?: string | null, gameVersion?: string | null);
|
|
564
|
+
constructor(gameSession?: string | null, anonKey?: string | null, gameVersion?: string | null, baseUrl?: string);
|
|
547
565
|
|
|
548
566
|
get anonKey(): string;
|
|
549
567
|
}
|
|
@@ -658,6 +676,10 @@ export class DredlessClient {
|
|
|
658
676
|
|
|
659
677
|
whenReady(): Promise<this>;
|
|
660
678
|
|
|
679
|
+
sendAdvancedExpandoBoxConfig(entity: number, config?: AdvancedExpandoBoxConfig): DredlessClient;
|
|
680
|
+
copyAdvancedExpandoBoxConfig(entity: number, config?: AdvancedExpandoBoxConfig): DredlessClient;
|
|
681
|
+
pasteAdvancedExpandoBoxConfig(entity: number, config?: AdvancedExpandoBoxConfig): DredlessClient;
|
|
682
|
+
|
|
661
683
|
sendLauncherConfig(entity: number, config?: LauncherConfig): DredlessClient;
|
|
662
684
|
setLauncherAngle(entity: number, angle: number, config?: LauncherConfig): DredlessClient;
|
|
663
685
|
setLauncherPower(entity: number, power: number, config?: LauncherConfig): DredlessClient;
|
|
@@ -1541,6 +1563,10 @@ export interface FluidTankHandle extends MachineHandle {
|
|
|
1541
1563
|
|
|
1542
1564
|
export interface ExpandoBoxHandle extends MachineHandle {
|
|
1543
1565
|
state: ExpandoBoxSummary | null;
|
|
1566
|
+
/** Configure/copy/paste require an Advanced Expando Box. */
|
|
1567
|
+
configure(config?: AdvancedExpandoBoxConfig): DredlessClient;
|
|
1568
|
+
copy(config?: AdvancedExpandoBoxConfig): DredlessClient;
|
|
1569
|
+
paste(config?: AdvancedExpandoBoxConfig): DredlessClient;
|
|
1544
1570
|
item: number | null | undefined;
|
|
1545
1571
|
count: number | null | undefined;
|
|
1546
1572
|
}
|
|
@@ -2079,6 +2105,16 @@ export interface CommsBubbleSummary {
|
|
|
2079
2105
|
}
|
|
2080
2106
|
|
|
2081
2107
|
export class ModelState {
|
|
2108
|
+
/** Local monotonic apply revision; independent of wire generation values. */
|
|
2109
|
+
readonly revision: number;
|
|
2110
|
+
/** Sorted live component IDs without materializing debug summaries. */
|
|
2111
|
+
componentEntityIds(): IterableIterator<number>;
|
|
2112
|
+
/** Latest mutation revision of a live entity, zero after removal. */
|
|
2113
|
+
entityRevision(entityId: number): number;
|
|
2114
|
+
/** Last local apply revision that touched this decoded record. */
|
|
2115
|
+
recordRevision(record: ModelRecord | null | undefined): number;
|
|
2116
|
+
/** Stateful navigation destination without materializing entity summaries. */
|
|
2117
|
+
navigationDestination(entityId: number): number;
|
|
2082
2118
|
/** Local entity identified by the decrypted camera-focus message, when known. */
|
|
2083
2119
|
readonly localPlayerEntity: number | null;
|
|
2084
2120
|
setLocalPlayerEntity(entity: number | null): void;
|
|
@@ -2183,14 +2219,21 @@ export interface ItemCrateSummary {
|
|
|
2183
2219
|
count: number | null;
|
|
2184
2220
|
/** Use the box sprite instead of the item's normal sprite. */
|
|
2185
2221
|
boxSprite: boolean;
|
|
2222
|
+
/** Dimensions in world units; raw dimensions use tenths of a unit. */
|
|
2186
2223
|
width: number | null;
|
|
2187
2224
|
height: number | null;
|
|
2225
|
+
rawWidth: number | null;
|
|
2226
|
+
rawHeight: number | null;
|
|
2188
2227
|
itemState: ModelRecord;
|
|
2189
2228
|
sizeState: ModelRecord;
|
|
2190
2229
|
}
|
|
2191
2230
|
|
|
2192
2231
|
export interface ExpandoBoxSummary {
|
|
2193
2232
|
entity: number;
|
|
2233
|
+
advanced: boolean;
|
|
2234
|
+
config: Required<AdvancedExpandoBoxConfig> | null;
|
|
2235
|
+
sizeConfigState: ModelRecord;
|
|
2236
|
+
colorConfigState: ModelRecord;
|
|
2194
2237
|
itemId: number | null;
|
|
2195
2238
|
itemName: string | null;
|
|
2196
2239
|
count: number | null;
|
|
@@ -2230,8 +2273,8 @@ export interface MapMarkerSummary {
|
|
|
2230
2273
|
export interface DockingSpringSummary {
|
|
2231
2274
|
entity: number;
|
|
2232
2275
|
id: number | null;
|
|
2233
|
-
width: number;
|
|
2234
|
-
height: number;
|
|
2276
|
+
width: number | null;
|
|
2277
|
+
height: number | null;
|
|
2235
2278
|
state: ModelRecord;
|
|
2236
2279
|
}
|
|
2237
2280
|
|
|
@@ -2996,3 +3039,7 @@ export interface DredlessNamespace {
|
|
|
2996
3039
|
}
|
|
2997
3040
|
export const Dredless: DredlessNamespace;
|
|
2998
3041
|
export default Dredless;
|
|
3042
|
+
|
|
3043
|
+
export function buildAdvancedExpandoBoxConfigData(entity: number, config?: AdvancedExpandoBoxConfig): Uint8Array;
|
|
3044
|
+
export function buildAdvancedExpandoBoxCopyConfigData(config?: AdvancedExpandoBoxConfig): Uint8Array;
|
|
3045
|
+
export function buildAdvancedExpandoBoxPasteConfigData(entity: number, config?: AdvancedExpandoBoxConfig): Uint8Array;
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Compact unsigned integers used by the UI command format (little endian).
|
|
2
|
+
export function encodeUnsigned(value) {
|
|
3
|
+
if (value < 64) return [value];
|
|
4
|
+
if (value < 256) return [0x80, value];
|
|
5
|
+
if (value < 65536) return [0x81, value & 255, value >>> 8];
|
|
6
|
+
return [0x82, value & 255, value >>> 8 & 255, value >>> 16 & 255, value >>> 24];
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {encoder} from "../../constants.js";
|
|
2
|
+
import {encodeUnsigned} from "../codec/ui-integer.js";
|
|
3
|
+
|
|
4
|
+
function number(value, name, min, max) {
|
|
5
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < min || value > max) {
|
|
6
|
+
throw new RangeError(`${name} must be a finite number between ${min} and ${max}`);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function float(value, name, min, max) {
|
|
12
|
+
const bytes = new Uint8Array(5);
|
|
13
|
+
bytes[0] = 0x88;
|
|
14
|
+
new DataView(bytes.buffer).setFloat32(1, number(value, name, min, max), true);
|
|
15
|
+
return [...bytes];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function color(value, name) {
|
|
19
|
+
number(value, name, 0, 0xffffff);
|
|
20
|
+
if (!Number.isInteger(value)) throw new RangeError(`${name} must be an integer RGB color`);
|
|
21
|
+
return encodeUnsigned(value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function bool(value, name) {
|
|
25
|
+
if (typeof value !== "boolean") throw new TypeError(`${name} must be a boolean`);
|
|
26
|
+
return value ? 0x8d : 0x8e;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function section(name, values) {
|
|
30
|
+
const text = encoder.encode(name);
|
|
31
|
+
return [0x8a, text.length, ...text, 0, 0x90, ...values, 0x91];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function message(entity, action, config) {
|
|
35
|
+
number(entity, "entity", 0, 0xffffffff);
|
|
36
|
+
if (!Number.isInteger(entity)) throw new RangeError("entity must be an unsigned 32-bit integer");
|
|
37
|
+
const {
|
|
38
|
+
minWidth = 2, maxWidth = 10, minHeight = 2, maxHeight = 10,
|
|
39
|
+
minEnabled = false, maxEnabled = false, fixedSize = false,
|
|
40
|
+
backgroundColor = 0xdddddd, borderColor = 0x404040, opacity = 1
|
|
41
|
+
} = config;
|
|
42
|
+
// Native ConfigExpandoSize order: min X, max X, min Y, max Y, then flags.
|
|
43
|
+
return Uint8Array.from([0x90, action, ...encodeUnsigned(entity),
|
|
44
|
+
...section("config_expando_size", [
|
|
45
|
+
...float(minWidth, "minWidth", 2, 100), ...float(maxWidth, "maxWidth", 2, 100),
|
|
46
|
+
...float(minHeight, "minHeight", 2, 100), ...float(maxHeight, "maxHeight", 2, 100),
|
|
47
|
+
bool(minEnabled, "minEnabled"), bool(maxEnabled, "maxEnabled"), bool(fixedSize, "fixedSize")
|
|
48
|
+
]),
|
|
49
|
+
...section("config_expando_colors", [
|
|
50
|
+
...color(backgroundColor, "backgroundColor"), ...color(borderColor, "borderColor"),
|
|
51
|
+
...float(opacity, "opacity", 0, 1)
|
|
52
|
+
]), 0x91]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function buildAdvancedExpandoBoxConfigData(entity, config = {}) {
|
|
56
|
+
return message(entity, 0, config);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function buildAdvancedExpandoBoxCopyConfigData(config = {}) {
|
|
60
|
+
return message(11, 1, config);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function buildAdvancedExpandoBoxPasteConfigData(entity, config = {}) {
|
|
64
|
+
return message(entity, 2, config);
|
|
65
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {encodeUnsigned} from "../codec/ui-integer.js";
|
|
1
2
|
import {encoder} from "../../constants.js";
|
|
2
3
|
|
|
3
4
|
function uint32(value, name) {
|
|
@@ -7,12 +8,6 @@ function uint32(value, name) {
|
|
|
7
8
|
return value;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
function encodeUnsigned(value) {
|
|
11
|
-
if (value < 64) return [value];
|
|
12
|
-
if (value < 256) return [0x80, value];
|
|
13
|
-
if (value < 65536) return [0x81, value & 255, value >>> 8];
|
|
14
|
-
return [0x82, value & 255, value >>> 8 & 255, value >>> 16 & 255, value >>> 24];
|
|
15
|
-
}
|
|
16
11
|
|
|
17
12
|
function encodeFloat(value, name, max) {
|
|
18
13
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > max) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export {buildAdvancedExpandoBoxConfigData, buildAdvancedExpandoBoxCopyConfigData, buildAdvancedExpandoBoxPasteConfigData} from "./advanced-expando.js";
|
|
2
|
+
import {encodeUnsigned} from "../codec/ui-integer.js";
|
|
1
3
|
import {encoder} from "../../constants.js";
|
|
2
4
|
export * from "./machine-config.js";
|
|
3
5
|
|
|
@@ -221,16 +223,12 @@ function encodeLoaderCycle(cycle) {
|
|
|
221
223
|
}
|
|
222
224
|
|
|
223
225
|
function encodeUiCommandTarget(entity, action = 0) {
|
|
224
|
-
const entityId =
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
throw new RangeError(`copy/paste UI config currently requires an entity id below 256`);
|
|
226
|
+
const entityId = Number(entity);
|
|
227
|
+
if (!Number.isInteger(entityId) || entityId < 0 || entityId > 0xffffffff) {
|
|
228
|
+
throw new RangeError("entity must be an unsigned 32-bit integer");
|
|
228
229
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
actionId ? actionId : (entityId >> 8) & 0xff,
|
|
232
|
-
entityId & 0xff
|
|
233
|
-
];
|
|
230
|
+
const actionId = requireByteInteger(action, "action");
|
|
231
|
+
return [NAV_UNIT_HEADER_TAG, actionId, ...encodeUnsigned(entityId)];
|
|
234
232
|
}
|
|
235
233
|
|
|
236
234
|
function encodeUiCommandSection(commandName) {
|
|
@@ -359,7 +359,17 @@ export const MODEL_TABLE_SPECS = new Map([
|
|
|
359
359
|
// Append new wire components without shifting stable Dredless table IDs.
|
|
360
360
|
[79, {name: "launcher_config", defaults: {q20: 0, q24: 300}, fields: numericFields({1: 20, 2: 24})}],
|
|
361
361
|
[80, {name: "rank_filter", defaults: {q20: 4}, fields: numericFields({1: 20})}],
|
|
362
|
-
[81, {name: "spawn_point", fields: []}]
|
|
362
|
+
[81, {name: "spawn_point", fields: []}],
|
|
363
|
+
// Official production WASM e0ed7795 (2026-11-14), dispatcher tags 173/174.
|
|
364
|
+
// Keep the wire field names until their public domain semantics are exposed.
|
|
365
|
+
[82, {
|
|
366
|
+
name: "advanced_expando_size_config",
|
|
367
|
+
defaults: {q20: 20, q24: 100, q28: 20, q32: 100, q36: 0, q37: 0, q38: 0, q39: 0},
|
|
368
|
+
packedBeforeValues: true,
|
|
369
|
+
packedBits: [{bit: 16, offset: 37}, {bit: 32, offset: 38}, {bit: 64, offset: 39}],
|
|
370
|
+
fields: numericFields({1: 20, 2: 24, 4: 28, 8: 32})
|
|
371
|
+
}],
|
|
372
|
+
[83, {name: "advanced_expando_color_config", defaults: {q20: 0xdddddd, q24: 0x404040, q28: 100, q32: 0}, fields: numericFields({1: 20, 2: 24, 4: 28})}]
|
|
363
373
|
]);
|
|
364
374
|
|
|
365
375
|
// Precompute everything about a spec that is fixed at module load. Decoding a
|
|
@@ -466,7 +476,9 @@ export const WIRE_TAG_TABLES = new Map([
|
|
|
466
476
|
[169, 77],
|
|
467
477
|
[170, 79],
|
|
468
478
|
[171, 80],
|
|
469
|
-
[172, 81]
|
|
479
|
+
[172, 81],
|
|
480
|
+
[173, 82],
|
|
481
|
+
[174, 83]
|
|
470
482
|
]);
|
|
471
483
|
|
|
472
484
|
export const MASK_ONLY_TABLES = new Set([13, 22, 23, 27, 28, 30, 36, 40, 46, 48, 52, 58, 64, 65, 66, 68, 73, 74]);
|
|
@@ -484,7 +496,7 @@ export const ENTITY_FOOTPRINTS = new Map([
|
|
|
484
496
|
export const PLACED_ENTITY_TYPE_IDS = new Set([
|
|
485
497
|
215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 226, 227, 228, 229,
|
|
486
498
|
230, 231, 240, 241, 242, 243, 245, 246, 247, 248, 249, 250, 251, 252,
|
|
487
|
-
253, 255, 256, 257, 258, 259, 260, 261, 263, 264, 265
|
|
499
|
+
253, 255, 256, 257, 258, 259, 260, 261, 263, 264, 265, 266
|
|
488
500
|
]);
|
|
489
501
|
|
|
490
502
|
export const FabricatorType = Object.freeze({
|
|
@@ -1216,14 +1228,17 @@ export function summarizeShipWorldMetadata(lockdownRecord, shipRecord) {
|
|
|
1216
1228
|
|
|
1217
1229
|
export function summarizeItemCrate(entity, sizeRecord, itemRecord = null, healthRecord = null) {
|
|
1218
1230
|
if (!sizeRecord) return null;
|
|
1231
|
+
const size = scaledSizeSummary(sizeRecord);
|
|
1219
1232
|
const itemId = itemRecord?.q20 ?? null;
|
|
1220
1233
|
const count = itemRecord?.q24 ?? null;
|
|
1221
1234
|
return {
|
|
1222
1235
|
entity,
|
|
1223
1236
|
...itemSummary(itemId, count),
|
|
1224
1237
|
boxSprite: Boolean(itemRecord?.q29),
|
|
1225
|
-
width:
|
|
1226
|
-
height:
|
|
1238
|
+
width: size.width,
|
|
1239
|
+
height: size.height,
|
|
1240
|
+
rawWidth: size.rawWidth,
|
|
1241
|
+
rawHeight: size.rawHeight,
|
|
1227
1242
|
itemState: cloneRecord(itemRecord || healthRecord || {}),
|
|
1228
1243
|
sizeState: cloneRecord(sizeRecord)
|
|
1229
1244
|
};
|
|
@@ -1242,11 +1257,26 @@ export function scaledSizeSummary(record) {
|
|
|
1242
1257
|
};
|
|
1243
1258
|
}
|
|
1244
1259
|
|
|
1245
|
-
export function summarizeExpandoBox(entity, itemHolderRecord, sizeRecord) {
|
|
1246
|
-
if (!itemHolderRecord && !sizeRecord) return null;
|
|
1260
|
+
export function summarizeExpandoBox(entity, itemHolderRecord, sizeRecord, sizeConfig = null, colorConfig = null, advanced = false) {
|
|
1261
|
+
if (!itemHolderRecord && !sizeRecord && !advanced) return null;
|
|
1247
1262
|
const size = scaledSizeSummary(sizeRecord);
|
|
1248
1263
|
return {
|
|
1249
1264
|
entity,
|
|
1265
|
+
advanced,
|
|
1266
|
+
config: advanced ? {
|
|
1267
|
+
minWidth: (sizeConfig?.q20 ?? 20) / 10,
|
|
1268
|
+
maxWidth: (sizeConfig?.q24 ?? 100) / 10,
|
|
1269
|
+
minHeight: (sizeConfig?.q28 ?? 20) / 10,
|
|
1270
|
+
maxHeight: (sizeConfig?.q32 ?? 100) / 10,
|
|
1271
|
+
minEnabled: Boolean(sizeConfig?.q37),
|
|
1272
|
+
maxEnabled: Boolean(sizeConfig?.q38),
|
|
1273
|
+
fixedSize: Boolean(sizeConfig?.q39),
|
|
1274
|
+
backgroundColor: (colorConfig?.q20 ?? 0xdddddd) >>> 0,
|
|
1275
|
+
borderColor: (colorConfig?.q24 ?? 0x404040) >>> 0,
|
|
1276
|
+
opacity: (colorConfig?.q28 ?? 100) / 100
|
|
1277
|
+
} : null,
|
|
1278
|
+
sizeConfigState: cloneRecord(sizeConfig || {}),
|
|
1279
|
+
colorConfigState: cloneRecord(colorConfig || {}),
|
|
1250
1280
|
...itemSummary(itemHolderRecord?.q20 ?? null, itemHolderRecord?.q24 ?? null),
|
|
1251
1281
|
width: size?.width ?? null,
|
|
1252
1282
|
height: size?.height ?? null,
|
|
@@ -1288,13 +1318,15 @@ export function summarizeMapMarker(entity, labelRecord, zoneRecord = null, sizeR
|
|
|
1288
1318
|
};
|
|
1289
1319
|
}
|
|
1290
1320
|
|
|
1291
|
-
export function summarizeDockingSpring(entity, springRecord,
|
|
1292
|
-
|
|
1321
|
+
export function summarizeDockingSpring(entity, springRecord, sizeRecord = null) {
|
|
1322
|
+
// Wire 85 is the marker iterated by the official dock_springs renderer.
|
|
1323
|
+
// Generic wire 89 plus size/body heuristics also matched decorative walls.
|
|
1324
|
+
if (!springRecord) return null;
|
|
1293
1325
|
return {
|
|
1294
1326
|
entity,
|
|
1295
1327
|
id: springRecord.q20 ?? null,
|
|
1296
|
-
width: sizeRecord.q20,
|
|
1297
|
-
height: sizeRecord.q24,
|
|
1328
|
+
width: sizeRecord?.q20 == null ? null : sizeRecord.q20 / 10,
|
|
1329
|
+
height: sizeRecord?.q24 == null ? null : sizeRecord.q24 / 10,
|
|
1298
1330
|
state: cloneRecord(springRecord)
|
|
1299
1331
|
};
|
|
1300
1332
|
}
|