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
|
@@ -218,8 +218,8 @@
|
|
|
218
218
|
resolveUrl = (baseUrl, path = "") => new URL(String(path).replace(/^\//, ""), `${normalizeBaseUrl(baseUrl)}/`).href;
|
|
219
219
|
hostName = (baseUrl) => new URL(normalizeBaseUrl(baseUrl)).hostname;
|
|
220
220
|
asNumber = (value, fallback = 0) => {
|
|
221
|
-
const
|
|
222
|
-
return Number.isFinite(
|
|
221
|
+
const number2 = Number(value);
|
|
222
|
+
return Number.isFinite(number2) ? number2 : fallback;
|
|
223
223
|
};
|
|
224
224
|
wsModulePromise = null;
|
|
225
225
|
}
|
|
@@ -774,6 +774,14 @@
|
|
|
774
774
|
}
|
|
775
775
|
});
|
|
776
776
|
|
|
777
|
+
// src/protocol/codec/ui-integer.js
|
|
778
|
+
function encodeUnsigned(value) {
|
|
779
|
+
if (value < 64) return [value];
|
|
780
|
+
if (value < 256) return [128, value];
|
|
781
|
+
if (value < 65536) return [129, value & 255, value >>> 8];
|
|
782
|
+
return [130, value & 255, value >>> 8 & 255, value >>> 16 & 255, value >>> 24];
|
|
783
|
+
}
|
|
784
|
+
|
|
777
785
|
// src/protocol/outbound/machine-config.js
|
|
778
786
|
init_constants();
|
|
779
787
|
function uint32(value, name) {
|
|
@@ -782,25 +790,19 @@
|
|
|
782
790
|
}
|
|
783
791
|
return value;
|
|
784
792
|
}
|
|
785
|
-
function encodeUnsigned(value) {
|
|
786
|
-
if (value < 64) return [value];
|
|
787
|
-
if (value < 256) return [128, value];
|
|
788
|
-
if (value < 65536) return [129, value & 255, value >>> 8];
|
|
789
|
-
return [130, value & 255, value >>> 8 & 255, value >>> 16 & 255, value >>> 24];
|
|
790
|
-
}
|
|
791
793
|
function encodeFloat(value, name, max) {
|
|
792
794
|
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > max) {
|
|
793
795
|
throw new RangeError(`${name} must be a finite number between 0 and ${max}`);
|
|
794
796
|
}
|
|
795
|
-
const
|
|
796
|
-
if (Number.isInteger(
|
|
797
|
-
if (
|
|
798
|
-
if (
|
|
799
|
-
return [133,
|
|
797
|
+
const number2 = Math.fround(value);
|
|
798
|
+
if (Number.isInteger(number2)) {
|
|
799
|
+
if (number2 < 64) return [number2];
|
|
800
|
+
if (number2 < 128) return [132, number2];
|
|
801
|
+
return [133, number2 & 255, number2 >>> 8];
|
|
800
802
|
}
|
|
801
803
|
const bytes = new Uint8Array(5);
|
|
802
804
|
bytes[0] = 136;
|
|
803
|
-
new DataView(bytes.buffer).setFloat32(1,
|
|
805
|
+
new DataView(bytes.buffer).setFloat32(1, number2, true);
|
|
804
806
|
return [...bytes];
|
|
805
807
|
}
|
|
806
808
|
function section(name, values) {
|
|
@@ -951,8 +953,8 @@
|
|
|
951
953
|
});
|
|
952
954
|
}
|
|
953
955
|
var DisconnectError = class extends Error {
|
|
954
|
-
constructor(disconnect,
|
|
955
|
-
super(`${
|
|
956
|
+
constructor(disconnect, message3 = "Disconnected") {
|
|
957
|
+
super(`${message3}: ${disconnect.name ?? "Unknown"} (${disconnect.code})${disconnect.reason ? ` \u2014 ${disconnect.reason}` : ""}`);
|
|
956
958
|
this.name = "DisconnectError";
|
|
957
959
|
this.disconnect = disconnect;
|
|
958
960
|
}
|
|
@@ -2103,7 +2105,7 @@
|
|
|
2103
2105
|
{
|
|
2104
2106
|
"id": 219,
|
|
2105
2107
|
"name": "Spawn Point (Packaged)",
|
|
2106
|
-
"desc": "Buildable. Can be set to spawn
|
|
2108
|
+
"desc": "Buildable. Can be set to spawn specific ranks.",
|
|
2107
2109
|
"image": "item/spawn",
|
|
2108
2110
|
"rarity": 0,
|
|
2109
2111
|
"max_stack": 1,
|
|
@@ -2124,7 +2126,7 @@
|
|
|
2124
2126
|
{
|
|
2125
2127
|
"id": 220,
|
|
2126
2128
|
"name": "Door (Packaged)",
|
|
2127
|
-
"desc": "Buildable. Can be restricted to specific ranks.
|
|
2129
|
+
"desc": "Buildable. Can be restricted to specific ranks.",
|
|
2128
2130
|
"image": "item/door",
|
|
2129
2131
|
"rarity": 0,
|
|
2130
2132
|
"max_stack": 1,
|
|
@@ -2803,6 +2805,22 @@
|
|
|
2803
2805
|
"rarity": 1,
|
|
2804
2806
|
"max_stack": 1
|
|
2805
2807
|
},
|
|
2808
|
+
{
|
|
2809
|
+
"id": 266,
|
|
2810
|
+
"name": "Advanced Expando Box (Packaged)",
|
|
2811
|
+
"desc": "Buildable. Dense bulk storage with configurable size limits. Spills more items when shot.",
|
|
2812
|
+
"image": "item/exbox_adv",
|
|
2813
|
+
"rarity": 2,
|
|
2814
|
+
"max_stack": 1
|
|
2815
|
+
},
|
|
2816
|
+
{
|
|
2817
|
+
"id": 267,
|
|
2818
|
+
"name": "Advanced Logistics Controller",
|
|
2819
|
+
"desc": "Component. Used to produce advanced logistics machinery.",
|
|
2820
|
+
"image": "item/adv_logi_controller",
|
|
2821
|
+
"rarity": 2,
|
|
2822
|
+
"max_stack": 1
|
|
2823
|
+
},
|
|
2806
2824
|
{
|
|
2807
2825
|
"id": 300,
|
|
2808
2826
|
"name": "Eternal Bronze Wrench",
|
|
@@ -3800,35 +3818,35 @@
|
|
|
3800
3818
|
return out;
|
|
3801
3819
|
}
|
|
3802
3820
|
function encodeNumberWithFormat(value, format) {
|
|
3803
|
-
const
|
|
3821
|
+
const number2 = Number(value);
|
|
3804
3822
|
switch (format) {
|
|
3805
3823
|
case "positive-fixint":
|
|
3806
|
-
return Uint8Array.of(
|
|
3824
|
+
return Uint8Array.of(number2 & 127);
|
|
3807
3825
|
case "negative-fixint":
|
|
3808
|
-
return Uint8Array.of(
|
|
3826
|
+
return Uint8Array.of(number2 & 255);
|
|
3809
3827
|
case "uint8":
|
|
3810
|
-
return Uint8Array.of(204,
|
|
3828
|
+
return Uint8Array.of(204, number2 & 255);
|
|
3811
3829
|
case "uint16":
|
|
3812
|
-
return Uint8Array.of(205,
|
|
3830
|
+
return Uint8Array.of(205, number2 >>> 8 & 255, number2 & 255);
|
|
3813
3831
|
case "uint32":
|
|
3814
|
-
return Uint8Array.of(206,
|
|
3832
|
+
return Uint8Array.of(206, number2 >>> 24 & 255, number2 >>> 16 & 255, number2 >>> 8 & 255, number2 & 255);
|
|
3815
3833
|
case "int8":
|
|
3816
|
-
return Uint8Array.of(208,
|
|
3834
|
+
return Uint8Array.of(208, number2 & 255);
|
|
3817
3835
|
case "int16":
|
|
3818
|
-
return Uint8Array.of(209,
|
|
3836
|
+
return Uint8Array.of(209, number2 >> 8 & 255, number2 & 255);
|
|
3819
3837
|
case "int32":
|
|
3820
|
-
return Uint8Array.of(210,
|
|
3838
|
+
return Uint8Array.of(210, number2 >> 24 & 255, number2 >> 16 & 255, number2 >> 8 & 255, number2 & 255);
|
|
3821
3839
|
case "float64": {
|
|
3822
3840
|
const out = new Uint8Array(9);
|
|
3823
3841
|
out[0] = 203;
|
|
3824
|
-
new DataView(out.buffer).setFloat64(1,
|
|
3842
|
+
new DataView(out.buffer).setFloat64(1, number2, false);
|
|
3825
3843
|
return out;
|
|
3826
3844
|
}
|
|
3827
3845
|
case "float32":
|
|
3828
3846
|
default: {
|
|
3829
3847
|
const out = new Uint8Array(5);
|
|
3830
3848
|
out[0] = 202;
|
|
3831
|
-
new DataView(out.buffer).setFloat32(1,
|
|
3849
|
+
new DataView(out.buffer).setFloat32(1, number2, false);
|
|
3832
3850
|
return out;
|
|
3833
3851
|
}
|
|
3834
3852
|
}
|
|
@@ -5052,7 +5070,17 @@
|
|
|
5052
5070
|
// Append new wire components without shifting stable Dredless table IDs.
|
|
5053
5071
|
[79, { name: "launcher_config", defaults: { q20: 0, q24: 300 }, fields: numericFields({ 1: 20, 2: 24 }) }],
|
|
5054
5072
|
[80, { name: "rank_filter", defaults: { q20: 4 }, fields: numericFields({ 1: 20 }) }],
|
|
5055
|
-
[81, { name: "spawn_point", fields: [] }]
|
|
5073
|
+
[81, { name: "spawn_point", fields: [] }],
|
|
5074
|
+
// Official production WASM e0ed7795 (2026-11-14), dispatcher tags 173/174.
|
|
5075
|
+
// Keep the wire field names until their public domain semantics are exposed.
|
|
5076
|
+
[82, {
|
|
5077
|
+
name: "advanced_expando_size_config",
|
|
5078
|
+
defaults: { q20: 20, q24: 100, q28: 20, q32: 100, q36: 0, q37: 0, q38: 0, q39: 0 },
|
|
5079
|
+
packedBeforeValues: true,
|
|
5080
|
+
packedBits: [{ bit: 16, offset: 37 }, { bit: 32, offset: 38 }, { bit: 64, offset: 39 }],
|
|
5081
|
+
fields: numericFields({ 1: 20, 2: 24, 4: 28, 8: 32 })
|
|
5082
|
+
}],
|
|
5083
|
+
[83, { name: "advanced_expando_color_config", defaults: { q20: 14540253, q24: 4210752, q28: 100, q32: 0 }, fields: numericFields({ 1: 20, 2: 24, 4: 28 }) }]
|
|
5056
5084
|
]);
|
|
5057
5085
|
for (const spec of MODEL_TABLE_SPECS.values()) {
|
|
5058
5086
|
for (const blob of spec.blobs || []) blob.key = blobKey(blob.offset);
|
|
@@ -5153,7 +5181,9 @@
|
|
|
5153
5181
|
[169, 77],
|
|
5154
5182
|
[170, 79],
|
|
5155
5183
|
[171, 80],
|
|
5156
|
-
[172, 81]
|
|
5184
|
+
[172, 81],
|
|
5185
|
+
[173, 82],
|
|
5186
|
+
[174, 83]
|
|
5157
5187
|
]);
|
|
5158
5188
|
var MASK_ONLY_TABLES = /* @__PURE__ */ new Set([13, 22, 23, 27, 28, 30, 36, 40, 46, 48, 52, 58, 64, 65, 66, 68, 73, 74]);
|
|
5159
5189
|
var ENTITY_FOOTPRINTS = /* @__PURE__ */ new Map([
|
|
@@ -5204,7 +5234,8 @@
|
|
|
5204
5234
|
261,
|
|
5205
5235
|
263,
|
|
5206
5236
|
264,
|
|
5207
|
-
265
|
|
5237
|
+
265,
|
|
5238
|
+
266
|
|
5208
5239
|
]);
|
|
5209
5240
|
var FabricatorType = Object.freeze({
|
|
5210
5241
|
Starter: "starter",
|
|
@@ -5355,9 +5386,9 @@
|
|
|
5355
5386
|
}
|
|
5356
5387
|
function boundedProgress(value) {
|
|
5357
5388
|
if (value == null) return null;
|
|
5358
|
-
const
|
|
5359
|
-
if (!Number.isFinite(
|
|
5360
|
-
return Math.max(0, Math.min(100,
|
|
5389
|
+
const number2 = Number(value);
|
|
5390
|
+
if (!Number.isFinite(number2)) return null;
|
|
5391
|
+
return Math.max(0, Math.min(100, number2));
|
|
5361
5392
|
}
|
|
5362
5393
|
function summarizeFabricator(entity, record, itemHolderRecord = null, typeRecord = null) {
|
|
5363
5394
|
if (!record) return null;
|
|
@@ -5556,12 +5587,12 @@
|
|
|
5556
5587
|
}
|
|
5557
5588
|
function summarizeProjectile(entity, record) {
|
|
5558
5589
|
if (!record) return null;
|
|
5559
|
-
const
|
|
5590
|
+
const color2 = record.q20 ?? 16777215;
|
|
5560
5591
|
const itemId = record.q28 ?? 1;
|
|
5561
5592
|
return {
|
|
5562
5593
|
entity,
|
|
5563
|
-
color,
|
|
5564
|
-
colorCss: colorToCss(
|
|
5594
|
+
color: color2,
|
|
5595
|
+
colorCss: colorToCss(color2),
|
|
5565
5596
|
botStyle: Boolean(record.q33),
|
|
5566
5597
|
indicatorCount: record.q24 ?? 1,
|
|
5567
5598
|
spriteItemId: itemId === 0 ? null : itemId,
|
|
@@ -5719,7 +5750,7 @@
|
|
|
5719
5750
|
}
|
|
5720
5751
|
function summarizeShipControl(entity, record) {
|
|
5721
5752
|
if (!record) return null;
|
|
5722
|
-
const
|
|
5753
|
+
const color2 = record.q32 == null ? null : Number(record.q32);
|
|
5723
5754
|
const shieldMaxHpOffset = typeof record.q68 === "number" ? record.q68 : null;
|
|
5724
5755
|
const shieldMaxHp = shieldMaxHpOffset == null ? null : shieldMaxHpOffset + 2e3;
|
|
5725
5756
|
const shieldBaseHp = typeof record.q72 === "number" ? record.q72 : null;
|
|
@@ -5735,8 +5766,8 @@
|
|
|
5735
5766
|
name: decodeText(record.blob116),
|
|
5736
5767
|
hexCode: decodeText(record.blob128),
|
|
5737
5768
|
shipWorldId: record.q20 ?? null,
|
|
5738
|
-
color: Number.isFinite(
|
|
5739
|
-
colorCss: Number.isFinite(
|
|
5769
|
+
color: Number.isFinite(color2) ? color2 : null,
|
|
5770
|
+
colorCss: Number.isFinite(color2) ? colorToCss(color2) : null,
|
|
5740
5771
|
thrustX: numberOrNull(record.q24, 20),
|
|
5741
5772
|
thrustY: numberOrNull(record.q28, 20),
|
|
5742
5773
|
value52: numberOrNull(record.q52, 20),
|
|
@@ -5804,14 +5835,14 @@
|
|
|
5804
5835
|
}
|
|
5805
5836
|
function summarizeShipWorldMetadata(lockdownRecord, shipRecord) {
|
|
5806
5837
|
if (!lockdownRecord && !shipRecord) return null;
|
|
5807
|
-
const
|
|
5838
|
+
const color2 = shipRecord?.q24 == null ? null : Number(shipRecord.q24);
|
|
5808
5839
|
const lockdownCountdownSeconds = typeof lockdownRecord?.q20 === "number" ? lockdownRecord.q20 : null;
|
|
5809
5840
|
const onlineShipOwnerCount = typeof lockdownRecord?.q24 === "number" ? lockdownRecord.q24 : null;
|
|
5810
5841
|
const requiredShipOwnerCount = typeof lockdownRecord?.q28 === "number" ? lockdownRecord.q28 : null;
|
|
5811
5842
|
return {
|
|
5812
5843
|
name: decodeText(shipRecord?.blob20),
|
|
5813
|
-
color: Number.isFinite(
|
|
5814
|
-
colorCss: Number.isFinite(
|
|
5844
|
+
color: Number.isFinite(color2) ? color2 : null,
|
|
5845
|
+
colorCss: Number.isFinite(color2) ? colorToCss(color2) : null,
|
|
5815
5846
|
width: typeof shipRecord?.q32 === "number" ? shipRecord.q32 : null,
|
|
5816
5847
|
height: typeof shipRecord?.q36 === "number" ? shipRecord.q36 : null,
|
|
5817
5848
|
lockdownTimerSeconds: lockdownCountdownSeconds,
|
|
@@ -5826,14 +5857,17 @@
|
|
|
5826
5857
|
}
|
|
5827
5858
|
function summarizeItemCrate(entity, sizeRecord, itemRecord = null, healthRecord = null) {
|
|
5828
5859
|
if (!sizeRecord) return null;
|
|
5860
|
+
const size = scaledSizeSummary(sizeRecord);
|
|
5829
5861
|
const itemId = itemRecord?.q20 ?? null;
|
|
5830
5862
|
const count = itemRecord?.q24 ?? null;
|
|
5831
5863
|
return {
|
|
5832
5864
|
entity,
|
|
5833
5865
|
...itemSummary(itemId, count),
|
|
5834
5866
|
boxSprite: Boolean(itemRecord?.q29),
|
|
5835
|
-
width:
|
|
5836
|
-
height:
|
|
5867
|
+
width: size.width,
|
|
5868
|
+
height: size.height,
|
|
5869
|
+
rawWidth: size.rawWidth,
|
|
5870
|
+
rawHeight: size.rawHeight,
|
|
5837
5871
|
itemState: cloneRecord(itemRecord || healthRecord || {}),
|
|
5838
5872
|
sizeState: cloneRecord(sizeRecord)
|
|
5839
5873
|
};
|
|
@@ -5850,11 +5884,26 @@
|
|
|
5850
5884
|
state: cloneRecord(record)
|
|
5851
5885
|
};
|
|
5852
5886
|
}
|
|
5853
|
-
function summarizeExpandoBox(entity, itemHolderRecord, sizeRecord) {
|
|
5854
|
-
if (!itemHolderRecord && !sizeRecord) return null;
|
|
5887
|
+
function summarizeExpandoBox(entity, itemHolderRecord, sizeRecord, sizeConfig = null, colorConfig = null, advanced = false) {
|
|
5888
|
+
if (!itemHolderRecord && !sizeRecord && !advanced) return null;
|
|
5855
5889
|
const size = scaledSizeSummary(sizeRecord);
|
|
5856
5890
|
return {
|
|
5857
5891
|
entity,
|
|
5892
|
+
advanced,
|
|
5893
|
+
config: advanced ? {
|
|
5894
|
+
minWidth: (sizeConfig?.q20 ?? 20) / 10,
|
|
5895
|
+
maxWidth: (sizeConfig?.q24 ?? 100) / 10,
|
|
5896
|
+
minHeight: (sizeConfig?.q28 ?? 20) / 10,
|
|
5897
|
+
maxHeight: (sizeConfig?.q32 ?? 100) / 10,
|
|
5898
|
+
minEnabled: Boolean(sizeConfig?.q37),
|
|
5899
|
+
maxEnabled: Boolean(sizeConfig?.q38),
|
|
5900
|
+
fixedSize: Boolean(sizeConfig?.q39),
|
|
5901
|
+
backgroundColor: (colorConfig?.q20 ?? 14540253) >>> 0,
|
|
5902
|
+
borderColor: (colorConfig?.q24 ?? 4210752) >>> 0,
|
|
5903
|
+
opacity: (colorConfig?.q28 ?? 100) / 100
|
|
5904
|
+
} : null,
|
|
5905
|
+
sizeConfigState: cloneRecord(sizeConfig || {}),
|
|
5906
|
+
colorConfigState: cloneRecord(colorConfig || {}),
|
|
5858
5907
|
...itemSummary(itemHolderRecord?.q20 ?? null, itemHolderRecord?.q24 ?? null),
|
|
5859
5908
|
width: size?.width ?? null,
|
|
5860
5909
|
height: size?.height ?? null,
|
|
@@ -5874,7 +5923,7 @@
|
|
|
5874
5923
|
const title = decodeText(zoneRecord?.blob28) ?? decodeText(labelRecord?.blob20);
|
|
5875
5924
|
const key = decodeText(labelRecord?.blob24) ?? decodeText(labelRecord?.blob28);
|
|
5876
5925
|
const description = decodeText(zoneRecord?.blob40);
|
|
5877
|
-
const
|
|
5926
|
+
const color2 = zoneRecord?.q20 ?? labelRecord?.q28 ?? null;
|
|
5878
5927
|
const accentColor = zoneRecord?.q24 ?? labelRecord?.q32 ?? null;
|
|
5879
5928
|
const kind = key === "mine" ? "mining_zone" : key === "dock" ? "dock" : zoneRecord ? "portal" : "marker";
|
|
5880
5929
|
return {
|
|
@@ -5883,8 +5932,8 @@
|
|
|
5883
5932
|
title,
|
|
5884
5933
|
key,
|
|
5885
5934
|
description,
|
|
5886
|
-
color,
|
|
5887
|
-
colorCss:
|
|
5935
|
+
color: color2,
|
|
5936
|
+
colorCss: color2 != null && Number.isFinite(Number(color2)) ? colorToCss(Number(color2)) : null,
|
|
5888
5937
|
accentColor,
|
|
5889
5938
|
accentColorCss: accentColor != null && Number.isFinite(Number(accentColor)) ? colorToCss(Number(accentColor)) : null,
|
|
5890
5939
|
width: sizeRecord?.q20 ?? null,
|
|
@@ -5893,13 +5942,13 @@
|
|
|
5893
5942
|
zoneState: cloneRecord(zoneRecord || {})
|
|
5894
5943
|
};
|
|
5895
5944
|
}
|
|
5896
|
-
function summarizeDockingSpring(entity, springRecord,
|
|
5897
|
-
if (!springRecord
|
|
5945
|
+
function summarizeDockingSpring(entity, springRecord, sizeRecord = null) {
|
|
5946
|
+
if (!springRecord) return null;
|
|
5898
5947
|
return {
|
|
5899
5948
|
entity,
|
|
5900
5949
|
id: springRecord.q20 ?? null,
|
|
5901
|
-
width: sizeRecord.q20,
|
|
5902
|
-
height: sizeRecord.q24,
|
|
5950
|
+
width: sizeRecord?.q20 == null ? null : sizeRecord.q20 / 10,
|
|
5951
|
+
height: sizeRecord?.q24 == null ? null : sizeRecord.q24 / 10,
|
|
5903
5952
|
state: cloneRecord(springRecord)
|
|
5904
5953
|
};
|
|
5905
5954
|
}
|
|
@@ -6056,13 +6105,13 @@
|
|
|
6056
6105
|
function enumValueName(map, value) {
|
|
6057
6106
|
return value == null ? null : map.get(value) ?? null;
|
|
6058
6107
|
}
|
|
6059
|
-
function colorToCss(
|
|
6060
|
-
return `rgb(${
|
|
6108
|
+
function colorToCss(color2) {
|
|
6109
|
+
return `rgb(${color2 >> 16 & 255},${color2 >> 8 & 255},${color2 & 255})`;
|
|
6061
6110
|
}
|
|
6062
|
-
function previewActionName(
|
|
6063
|
-
if (
|
|
6064
|
-
if (
|
|
6065
|
-
if (
|
|
6111
|
+
function previewActionName(color2) {
|
|
6112
|
+
if (color2 === 65280) return "place";
|
|
6113
|
+
if (color2 === 16711680) return "break";
|
|
6114
|
+
if (color2 === 255) return "blueprint";
|
|
6066
6115
|
return null;
|
|
6067
6116
|
}
|
|
6068
6117
|
function bitOffsets(value) {
|
|
@@ -6111,10 +6160,10 @@
|
|
|
6111
6160
|
}
|
|
6112
6161
|
function summarizePlayerPreview(entity, record, blueprintItems = []) {
|
|
6113
6162
|
if (!record) return null;
|
|
6114
|
-
const
|
|
6163
|
+
const color2 = record.q40 == null ? null : Number(record.q40);
|
|
6115
6164
|
const active = typeof record.q36 === "number" && record.q36 !== 0;
|
|
6116
6165
|
if (!active && record.q36 == null) return null;
|
|
6117
|
-
const actionName = Number.isFinite(
|
|
6166
|
+
const actionName = Number.isFinite(color2) ? previewActionName(color2) : null;
|
|
6118
6167
|
return {
|
|
6119
6168
|
entity,
|
|
6120
6169
|
active,
|
|
@@ -6123,8 +6172,8 @@
|
|
|
6123
6172
|
width: numberOrNull(record.q28, 10),
|
|
6124
6173
|
height: numberOrNull(record.q32, 10),
|
|
6125
6174
|
progress: record.q36 ?? null,
|
|
6126
|
-
color: Number.isFinite(
|
|
6127
|
-
colorCss: Number.isFinite(
|
|
6175
|
+
color: Number.isFinite(color2) ? color2 : null,
|
|
6176
|
+
colorCss: Number.isFinite(color2) ? colorToCss(color2) : null,
|
|
6128
6177
|
actionName,
|
|
6129
6178
|
blueprintId: record.q44 ?? null,
|
|
6130
6179
|
blueprintItems: actionName === "blueprint" ? blueprintItems : [],
|
|
@@ -6471,6 +6520,10 @@
|
|
|
6471
6520
|
defineLazyProperty: defineLazyProperty2
|
|
6472
6521
|
} = decoder_exports;
|
|
6473
6522
|
var ModelState = class {
|
|
6523
|
+
#entityRevisions = /* @__PURE__ */ new Map();
|
|
6524
|
+
#entityIds = null;
|
|
6525
|
+
#recordRevisions = /* @__PURE__ */ new WeakMap();
|
|
6526
|
+
#revision = 0;
|
|
6474
6527
|
#localPlayerEntity = null;
|
|
6475
6528
|
#blueprintItems = null;
|
|
6476
6529
|
#helmOccupied = /* @__PURE__ */ new Map();
|
|
@@ -6509,6 +6562,28 @@
|
|
|
6509
6562
|
record(tableId, entityId) {
|
|
6510
6563
|
return this.table(tableId).get(Number(entityId)) || null;
|
|
6511
6564
|
}
|
|
6565
|
+
/** Monotonic local revision, independent of the server's generation counter. */
|
|
6566
|
+
get revision() {
|
|
6567
|
+
return this.#revision;
|
|
6568
|
+
}
|
|
6569
|
+
/** Live component IDs without creating entity/debug summaries. */
|
|
6570
|
+
componentEntityIds() {
|
|
6571
|
+
this.#entityIds ??= [...this.#entityRevisions.keys()].sort((a, b) => a - b);
|
|
6572
|
+
return this.#entityIds.values();
|
|
6573
|
+
}
|
|
6574
|
+
/** Latest record mutation for a live entity, or zero after removal. */
|
|
6575
|
+
entityRevision(entityId) {
|
|
6576
|
+
return this.#entityRevisions.get(Number(entityId)) ?? 0;
|
|
6577
|
+
}
|
|
6578
|
+
/** Revision of a decoded record, without creating entity/debug summaries. */
|
|
6579
|
+
recordRevision(record) {
|
|
6580
|
+
return record ? this.#recordRevisions.get(record) ?? 0 : 0;
|
|
6581
|
+
}
|
|
6582
|
+
/** Stateful navigation destination without constructing derived entity lists. */
|
|
6583
|
+
navigationDestination(entityId) {
|
|
6584
|
+
const record = this.record(78, entityId);
|
|
6585
|
+
return this.#navigationUnitAutoWarp.get(Number(entityId))?.destination ?? navigationDestinationFromRecord2(record);
|
|
6586
|
+
}
|
|
6512
6587
|
entity(entityId) {
|
|
6513
6588
|
const id = Number(entityId);
|
|
6514
6589
|
if (!Number.isFinite(id)) return null;
|
|
@@ -6528,6 +6603,7 @@
|
|
|
6528
6603
|
return this.#blocksIndex().get(blockKey2(x, y)) || null;
|
|
6529
6604
|
}
|
|
6530
6605
|
apply(bytes, { full = false } = {}) {
|
|
6606
|
+
this.#revision++;
|
|
6531
6607
|
this.#blueprintItems = null;
|
|
6532
6608
|
const reader = new ModelReader2(bytes);
|
|
6533
6609
|
const update = {
|
|
@@ -6561,9 +6637,9 @@
|
|
|
6561
6637
|
if (reader.trailingZeroOnly()) break;
|
|
6562
6638
|
throw new Error(`unsupported model_data section tag ${tag}`);
|
|
6563
6639
|
}
|
|
6564
|
-
const
|
|
6565
|
-
update.sections.push(
|
|
6566
|
-
for (const record of
|
|
6640
|
+
const section3 = this.#readSection(reader, tag, tableId);
|
|
6641
|
+
update.sections.push(section3);
|
|
6642
|
+
for (const record of section3.records) update.changedEntities.add(record.entity);
|
|
6567
6643
|
}
|
|
6568
6644
|
} catch (error) {
|
|
6569
6645
|
update.error = error;
|
|
@@ -6703,11 +6779,11 @@
|
|
|
6703
6779
|
const derived = this._derived;
|
|
6704
6780
|
if (!derived) return;
|
|
6705
6781
|
if (!update.removals.length && !update.changedEntities.size) return;
|
|
6706
|
-
for (const
|
|
6707
|
-
for (const record of
|
|
6782
|
+
for (const section3 of update.sections) {
|
|
6783
|
+
for (const record of section3.records || []) this.#addDerivedEntityTable(record.entity, section3.table);
|
|
6708
6784
|
}
|
|
6709
6785
|
const dirty = derived.dirtyEntities ??= /* @__PURE__ */ new Set();
|
|
6710
|
-
if (update.sections.some((
|
|
6786
|
+
if (update.sections.some((section3) => section3.table === 12)) {
|
|
6711
6787
|
for (const entityId of this.table(55).keys()) update.changedEntities.add(entityId);
|
|
6712
6788
|
}
|
|
6713
6789
|
for (const entityId of update.removals) {
|
|
@@ -6736,9 +6812,9 @@
|
|
|
6736
6812
|
#updateNavigationUnitAutoWarp(update) {
|
|
6737
6813
|
const trackedBeforeUpdate = new Set(this.#navigationUnitAutoWarp.keys());
|
|
6738
6814
|
const initializedThisUpdate = /* @__PURE__ */ new Set();
|
|
6739
|
-
for (const
|
|
6740
|
-
if (
|
|
6741
|
-
for (const changed of
|
|
6815
|
+
for (const section3 of update.sections || []) {
|
|
6816
|
+
if (section3.table !== 78) continue;
|
|
6817
|
+
for (const changed of section3.records || []) {
|
|
6742
6818
|
const typeId = entityTypeIdFromRecord2(this.record(7, changed.entity));
|
|
6743
6819
|
if (typeId !== NAVIGATION_UNIT_TYPE_ID2) continue;
|
|
6744
6820
|
const record = this.record(78, changed.entity);
|
|
@@ -6801,12 +6877,12 @@
|
|
|
6801
6877
|
}
|
|
6802
6878
|
}
|
|
6803
6879
|
#updateHelmOccupancy(update) {
|
|
6804
|
-
const table7 = update.sections.find((
|
|
6880
|
+
const table7 = update.sections.find((section3) => section3.table === 7);
|
|
6805
6881
|
if (!table7) return;
|
|
6806
6882
|
const changedZoomState = /* @__PURE__ */ new Map();
|
|
6807
|
-
for (const
|
|
6808
|
-
if (
|
|
6809
|
-
for (const changed of
|
|
6883
|
+
for (const section3 of update.sections) {
|
|
6884
|
+
if (section3.table !== 55) continue;
|
|
6885
|
+
for (const changed of section3.records) {
|
|
6810
6886
|
if (!(changed.mask & 16)) continue;
|
|
6811
6887
|
const player = this.record(55, changed.entity);
|
|
6812
6888
|
changedZoomState.set(changed.entity, Boolean(player?.q107));
|
|
@@ -6825,7 +6901,7 @@
|
|
|
6825
6901
|
}
|
|
6826
6902
|
}
|
|
6827
6903
|
#updateCommsStationOccupancy(update) {
|
|
6828
|
-
const table7 = update.sections.find((
|
|
6904
|
+
const table7 = update.sections.find((section3) => section3.table === 7);
|
|
6829
6905
|
if (!table7) return;
|
|
6830
6906
|
for (const changed of table7.records) {
|
|
6831
6907
|
const record = this.record(7, changed.entity);
|
|
@@ -7124,7 +7200,7 @@
|
|
|
7124
7200
|
const thrusterRecord = rec(50);
|
|
7125
7201
|
const labelRecord = rec(9);
|
|
7126
7202
|
const zoneLabelRecord = rec(25);
|
|
7127
|
-
const dockingSpringRecord = rec(
|
|
7203
|
+
const dockingSpringRecord = rec(22);
|
|
7128
7204
|
const hugeThrusterRecord = rec(23);
|
|
7129
7205
|
const bodyStateRecord = rec(1);
|
|
7130
7206
|
const typeRecord = rec(7);
|
|
@@ -7139,7 +7215,8 @@
|
|
|
7139
7215
|
const dynamicBody = bodyStateRecord?.q20 === -4;
|
|
7140
7216
|
const typeId = entityTypeIdFromRecord2(typeRecord);
|
|
7141
7217
|
const itemHolder = summarizeItemHolder2(entityId, itemHolderRecord);
|
|
7142
|
-
const
|
|
7218
|
+
const isAdvancedExpandoBox = typeId === 266 || Boolean(rec(82) || rec(83));
|
|
7219
|
+
const isExpandoBox = isAdvancedExpandoBox || typeId === EXPANDO_BOX_TYPE_ID2 || markerTypeId === EXPANDO_BOX_TYPE_ID2;
|
|
7143
7220
|
const health = summarizeHealth2(entityId, healthRecord);
|
|
7144
7221
|
const projectile = summarizeProjectile2(entityId, rec(24));
|
|
7145
7222
|
const combatBeams = summarizeCombatBeams2(entityId, rec(15));
|
|
@@ -7173,9 +7250,9 @@
|
|
|
7173
7250
|
const door = typeId === 220 ? summarizeDoor2(entityId, spawnPointRecord, doorRecord, rec(80)) : null;
|
|
7174
7251
|
const shipSize = shipControl && this.isOverworld ? summarizeShipSize2(entityId, rec(3)) : null;
|
|
7175
7252
|
const hoverOutline = summarizeHoverOutline2(entityId, crateSizeRecord);
|
|
7176
|
-
const expandoBox = isExpandoBox ? summarizeExpandoBox2(entityId, itemHolderRecord, expandoSizeRecord) : null;
|
|
7253
|
+
const expandoBox = isExpandoBox ? summarizeExpandoBox2(entityId, itemHolderRecord, expandoSizeRecord, rec(82), rec(83), isAdvancedExpandoBox) : null;
|
|
7177
7254
|
const mapMarker = this.isOverworld ? summarizeMapMarker2(entityId, labelRecord, zoneLabelRecord, crateSizeRecord) : null;
|
|
7178
|
-
const dockingSpring = this.isOverworld ? summarizeDockingSpring2(entityId, dockingSpringRecord,
|
|
7255
|
+
const dockingSpring = this.isOverworld ? summarizeDockingSpring2(entityId, dockingSpringRecord, crateSizeRecord) : null;
|
|
7179
7256
|
const hugeThruster = this.isOverworld ? summarizeHugeThruster2(entityId, hugeThrusterRecord, crateSizeRecord) : null;
|
|
7180
7257
|
const itemCrate = this.isOverworld && !rec(2) && !rec(18) && !combatBeams && !projectile && !ball && !rcd && health && crateSizeRecord ? summarizeItemCrate2(entityId, crateSizeRecord, crateItemRecord, healthRecord) : null;
|
|
7181
7258
|
const bot = (this.isOverworld || rec(18) || combatBeams) && !projectile && !ball && !rcd ? summarizeBot2(entityId, {
|
|
@@ -7414,6 +7491,8 @@
|
|
|
7414
7491
|
if (delta === 0) break;
|
|
7415
7492
|
entity += delta;
|
|
7416
7493
|
removals.push(entity);
|
|
7494
|
+
this.#entityRevisions.delete(entity);
|
|
7495
|
+
this.#entityIds = null;
|
|
7417
7496
|
for (const records of this.tables.values()) records.delete(entity);
|
|
7418
7497
|
this.#helmOccupied.delete(entity);
|
|
7419
7498
|
this.#commsStationOccupied.delete(entity);
|
|
@@ -7428,7 +7507,7 @@
|
|
|
7428
7507
|
return this.#readSectionRecords(reader, tag, tableId, spec);
|
|
7429
7508
|
}
|
|
7430
7509
|
#readSectionRecords(reader, tag, tableId, spec) {
|
|
7431
|
-
const
|
|
7510
|
+
const section3 = { tag, table: tableId, name: spec?.name || null, records: [] };
|
|
7432
7511
|
let records = this.tables.get(tableId);
|
|
7433
7512
|
let entity = 0;
|
|
7434
7513
|
while (reader.remaining > 0) {
|
|
@@ -7450,6 +7529,9 @@
|
|
|
7450
7529
|
if (!records) this.tables.set(tableId, records = /* @__PURE__ */ new Map());
|
|
7451
7530
|
let record = records.get(entity);
|
|
7452
7531
|
if (!record) records.set(entity, record = { ...spec?.defaults });
|
|
7532
|
+
if (!this.#entityRevisions.has(entity)) this.#entityIds = null;
|
|
7533
|
+
this.#entityRevisions.set(entity, this.#revision);
|
|
7534
|
+
this.#recordRevisions.set(record, this.#revision);
|
|
7453
7535
|
record.lastMask = mask;
|
|
7454
7536
|
try {
|
|
7455
7537
|
if (spec) this.#applyRecordSpec(reader, record, mask, spec);
|
|
@@ -7458,9 +7540,9 @@
|
|
|
7458
7540
|
throw new Error(`model table ${tableId} tag ${tag} entity ${entity} mask ${mask} offset ${reader.offset}: ${error.message}`);
|
|
7459
7541
|
}
|
|
7460
7542
|
const changed = { entity, mask };
|
|
7461
|
-
|
|
7543
|
+
section3.records.push(changed);
|
|
7462
7544
|
}
|
|
7463
|
-
return
|
|
7545
|
+
return section3;
|
|
7464
7546
|
}
|
|
7465
7547
|
#applyRecordSpec(reader, record, mask, spec) {
|
|
7466
7548
|
if (typeof spec.read === "function") {
|
|
@@ -7508,11 +7590,11 @@
|
|
|
7508
7590
|
removals: update.removals.length,
|
|
7509
7591
|
unknownTags: update.unknownTags,
|
|
7510
7592
|
error: update.error?.message || null,
|
|
7511
|
-
sections: update.sections.map((
|
|
7512
|
-
tag:
|
|
7513
|
-
table:
|
|
7514
|
-
name:
|
|
7515
|
-
records:
|
|
7593
|
+
sections: update.sections.map((section3) => ({
|
|
7594
|
+
tag: section3.tag,
|
|
7595
|
+
table: section3.table,
|
|
7596
|
+
name: section3.name,
|
|
7597
|
+
records: section3.records.length
|
|
7516
7598
|
}))
|
|
7517
7599
|
};
|
|
7518
7600
|
}
|
|
@@ -7813,7 +7895,7 @@
|
|
|
7813
7895
|
this.meta = null;
|
|
7814
7896
|
}
|
|
7815
7897
|
readMeta(packet) {
|
|
7816
|
-
this.meta = packet;
|
|
7898
|
+
this.meta = { ...this.meta, ...packet };
|
|
7817
7899
|
this.seed = packet.seed ?? this.seed;
|
|
7818
7900
|
const isOverworld = packet.is_overworld ?? this.isOverworld;
|
|
7819
7901
|
this.isOverworld = isOverworld == null ? null : Boolean(isOverworld);
|
|
@@ -7834,15 +7916,15 @@
|
|
|
7834
7916
|
}
|
|
7835
7917
|
addCommsBubble(packet) {
|
|
7836
7918
|
const raw = packet?.bubble && typeof packet.bubble === "object" ? packet.bubble : {};
|
|
7837
|
-
const
|
|
7919
|
+
const color2 = Number.isFinite(Number(raw.color)) ? Number(raw.color) : null;
|
|
7838
7920
|
const bubble = {
|
|
7839
7921
|
sequence: ++this._bubbleSequence,
|
|
7840
7922
|
worldId: this.id,
|
|
7841
7923
|
entity: Number.isFinite(Number(raw.model_id)) ? Number(raw.model_id) : null,
|
|
7842
7924
|
modelId: Number.isFinite(Number(raw.model_id)) ? Number(raw.model_id) : null,
|
|
7843
7925
|
message: typeof raw.msg === "string" ? raw.msg : "",
|
|
7844
|
-
color,
|
|
7845
|
-
colorCss:
|
|
7926
|
+
color: color2,
|
|
7927
|
+
colorCss: color2 == null ? null : `rgb(${color2 >> 16 & 255},${color2 >> 8 & 255},${color2 & 255})`,
|
|
7846
7928
|
durationSeconds: Number.isFinite(Number(raw.time)) ? Number(raw.time) : null,
|
|
7847
7929
|
raw: { ...raw }
|
|
7848
7930
|
};
|
|
@@ -7858,8 +7940,8 @@
|
|
|
7858
7940
|
}
|
|
7859
7941
|
applyTile(value) {
|
|
7860
7942
|
if (!Array.isArray(value) || value.length !== 6) return null;
|
|
7861
|
-
const [x, y, material, shape, hp,
|
|
7862
|
-
return this.setTile({ x, y, material, shape, hp, integrity: hp, color });
|
|
7943
|
+
const [x, y, material, shape, hp, color2] = value;
|
|
7944
|
+
return this.setTile({ x, y, material, shape, hp, integrity: hp, color: color2 });
|
|
7863
7945
|
}
|
|
7864
7946
|
applyChunk(value) {
|
|
7865
7947
|
const patch = this.applyChunkPatch(value);
|
|
@@ -8012,7 +8094,7 @@
|
|
|
8012
8094
|
}
|
|
8013
8095
|
this.#touchChunk(grid);
|
|
8014
8096
|
}
|
|
8015
|
-
#buildTile(x, y, material, shape, hp,
|
|
8097
|
+
#buildTile(x, y, material, shape, hp, color2) {
|
|
8016
8098
|
const def = this.tileDefinition(material);
|
|
8017
8099
|
const maxHp = def?.hp ?? null;
|
|
8018
8100
|
const value = hp ?? null;
|
|
@@ -8023,7 +8105,7 @@
|
|
|
8023
8105
|
shape,
|
|
8024
8106
|
hp: value,
|
|
8025
8107
|
integrity: value,
|
|
8026
|
-
color,
|
|
8108
|
+
color: color2,
|
|
8027
8109
|
materialName: def?.name ?? null,
|
|
8028
8110
|
shapeName: tileShapeName(shape),
|
|
8029
8111
|
solid: def?.solid ?? null,
|
|
@@ -8452,14 +8534,14 @@
|
|
|
8452
8534
|
// src/protocol/outbound/blueprint.js
|
|
8453
8535
|
var BLUEPRINT_PLACEMENT_TYPE = 9;
|
|
8454
8536
|
function requireFiniteNumber(value, name) {
|
|
8455
|
-
const
|
|
8456
|
-
if (!Number.isFinite(
|
|
8457
|
-
return
|
|
8537
|
+
const number2 = Number(value);
|
|
8538
|
+
if (!Number.isFinite(number2)) throw new TypeError(`${name} must be a finite number`);
|
|
8539
|
+
return number2;
|
|
8458
8540
|
}
|
|
8459
8541
|
function requirePositiveInteger(value, name) {
|
|
8460
|
-
const
|
|
8461
|
-
if (!Number.isInteger(
|
|
8462
|
-
return
|
|
8542
|
+
const number2 = Number(value);
|
|
8543
|
+
if (!Number.isInteger(number2) || number2 <= 0) throw new RangeError(`${name} must be a positive integer`);
|
|
8544
|
+
return number2;
|
|
8463
8545
|
}
|
|
8464
8546
|
function normalizeBlueprintDimension(placement, publicName, protocolName) {
|
|
8465
8547
|
const value = placement[publicName] ?? placement[protocolName];
|
|
@@ -8480,19 +8562,19 @@
|
|
|
8480
8562
|
|
|
8481
8563
|
// src/protocol/outbound/chat.js
|
|
8482
8564
|
var CHAT_MESSAGE_TYPE = 2;
|
|
8483
|
-
function buildChatMessage(
|
|
8565
|
+
function buildChatMessage(message3 = "") {
|
|
8484
8566
|
return {
|
|
8485
8567
|
type: CHAT_MESSAGE_TYPE,
|
|
8486
|
-
msg: String(
|
|
8568
|
+
msg: String(message3)
|
|
8487
8569
|
};
|
|
8488
8570
|
}
|
|
8489
8571
|
|
|
8490
8572
|
// src/protocol/outbound/comms.js
|
|
8491
8573
|
var COMMS_MESSAGE_TYPE = 3;
|
|
8492
|
-
function buildCommsMessage(
|
|
8574
|
+
function buildCommsMessage(message3 = "") {
|
|
8493
8575
|
return {
|
|
8494
8576
|
type: COMMS_MESSAGE_TYPE,
|
|
8495
|
-
msg: String(
|
|
8577
|
+
msg: String(message3)
|
|
8496
8578
|
};
|
|
8497
8579
|
}
|
|
8498
8580
|
function normalizeCommsEvent(event) {
|
|
@@ -8501,9 +8583,9 @@
|
|
|
8501
8583
|
...event,
|
|
8502
8584
|
entity: event?.ent_id != null && Number.isFinite(Number(event.ent_id)) ? Number(event.ent_id) : null,
|
|
8503
8585
|
rawMessages,
|
|
8504
|
-
messages: rawMessages.map((
|
|
8505
|
-
raw:
|
|
8506
|
-
text: flattenRichText(
|
|
8586
|
+
messages: rawMessages.map((message3) => ({
|
|
8587
|
+
raw: message3,
|
|
8588
|
+
text: flattenRichText(message3)
|
|
8507
8589
|
}))
|
|
8508
8590
|
};
|
|
8509
8591
|
}
|
|
@@ -8800,19 +8882,19 @@
|
|
|
8800
8882
|
};
|
|
8801
8883
|
}
|
|
8802
8884
|
function normalizeInventoryIndex(value, name) {
|
|
8803
|
-
const
|
|
8804
|
-
if (!Number.isInteger(
|
|
8805
|
-
return
|
|
8885
|
+
const number2 = Number(value);
|
|
8886
|
+
if (!Number.isInteger(number2) || number2 < 0) throw new RangeError(`${name} must be a non-negative integer inventory slot`);
|
|
8887
|
+
return number2;
|
|
8806
8888
|
}
|
|
8807
8889
|
function normalizeCount(value) {
|
|
8808
|
-
const
|
|
8809
|
-
return Number.isFinite(
|
|
8890
|
+
const number2 = Number(value ?? 0);
|
|
8891
|
+
return Number.isFinite(number2) ? number2 : 0;
|
|
8810
8892
|
}
|
|
8811
8893
|
function normalizeItemId(value, count) {
|
|
8812
8894
|
if (value == null) return null;
|
|
8813
|
-
const
|
|
8814
|
-
if (!Number.isFinite(
|
|
8815
|
-
return
|
|
8895
|
+
const number2 = Number(value);
|
|
8896
|
+
if (!Number.isFinite(number2)) return null;
|
|
8897
|
+
return number2 === 0 && count === 0 ? null : number2;
|
|
8816
8898
|
}
|
|
8817
8899
|
|
|
8818
8900
|
// src/protocol/outbound/ship-management.js
|
|
@@ -8846,9 +8928,9 @@
|
|
|
8846
8928
|
throw new RangeError('direction must be "down", "up", "left", "right", or an integer from 0 to 3');
|
|
8847
8929
|
}
|
|
8848
8930
|
function requireNonNegativeInteger(value, name) {
|
|
8849
|
-
const
|
|
8850
|
-
if (!Number.isInteger(
|
|
8851
|
-
return
|
|
8931
|
+
const number2 = Number(value);
|
|
8932
|
+
if (!Number.isInteger(number2) || number2 < 0) throw new RangeError(`${name} must be a non-negative integer`);
|
|
8933
|
+
return number2;
|
|
8852
8934
|
}
|
|
8853
8935
|
function normalizePrivacy(value) {
|
|
8854
8936
|
if (value === true || value === 1 || value === "private") return 1;
|
|
@@ -8866,9 +8948,9 @@
|
|
|
8866
8948
|
}
|
|
8867
8949
|
function buildShipManagementMessage(act, arg = null, extra = null) {
|
|
8868
8950
|
if (typeof act !== "string" || !act) throw new TypeError(`act must be a non-empty string`);
|
|
8869
|
-
const
|
|
8870
|
-
if (extra && typeof extra === "object") Object.assign(
|
|
8871
|
-
return
|
|
8951
|
+
const message3 = { type: SHIP_MANAGEMENT_TYPE, act, arg };
|
|
8952
|
+
if (extra && typeof extra === "object") Object.assign(message3, extra);
|
|
8953
|
+
return message3;
|
|
8872
8954
|
}
|
|
8873
8955
|
function buildShipPrivacyMessage(privacy) {
|
|
8874
8956
|
return buildShipManagementMessage(SET_PRIVACY_ACTION, normalizePrivacy(privacy));
|
|
@@ -8910,13 +8992,13 @@
|
|
|
8910
8992
|
function buildShipRenameRequestMessage() {
|
|
8911
8993
|
return buildShipManagementMessage(RENAME_REQUEST_ACTION);
|
|
8912
8994
|
}
|
|
8913
|
-
function buildShipRenameCommitMessage(name,
|
|
8995
|
+
function buildShipRenameCommitMessage(name, color2) {
|
|
8914
8996
|
if (typeof name !== "string") throw new TypeError("name must be a string");
|
|
8915
8997
|
if (name.length > 32) throw new RangeError("name must be at most 32 UTF-16 code units");
|
|
8916
|
-
if (typeof
|
|
8998
|
+
if (typeof color2 !== "string" || !/^#[0-9a-f]{6}$/i.test(color2)) {
|
|
8917
8999
|
throw new TypeError("color must be a #RRGGBB hex string");
|
|
8918
9000
|
}
|
|
8919
|
-
return buildShipManagementMessage(RENAME_COMMIT_ACTION, name, { arg2:
|
|
9001
|
+
return buildShipManagementMessage(RENAME_COMMIT_ACTION, name, { arg2: color2 });
|
|
8920
9002
|
}
|
|
8921
9003
|
function normalizeShipConfig(event = {}) {
|
|
8922
9004
|
const source = event && typeof event === "object" ? event : {};
|
|
@@ -9032,8 +9114,8 @@
|
|
|
9032
9114
|
};
|
|
9033
9115
|
}
|
|
9034
9116
|
function normalizeNonNegativeNumber(value) {
|
|
9035
|
-
const
|
|
9036
|
-
return Number.isFinite(
|
|
9117
|
+
const number2 = Number(value);
|
|
9118
|
+
return Number.isFinite(number2) && number2 > 0 ? number2 : 0;
|
|
9037
9119
|
}
|
|
9038
9120
|
function ownerRankForPlayers(players) {
|
|
9039
9121
|
const ranks = players.filter((player) => Number(player.captainRank) > 0).map((player) => Number(player.captainRank)).filter(Number.isFinite);
|
|
@@ -9090,6 +9172,79 @@
|
|
|
9090
9172
|
};
|
|
9091
9173
|
}
|
|
9092
9174
|
|
|
9175
|
+
// src/protocol/outbound/advanced-expando.js
|
|
9176
|
+
init_constants();
|
|
9177
|
+
function number(value, name, min, max) {
|
|
9178
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < min || value > max) {
|
|
9179
|
+
throw new RangeError(`${name} must be a finite number between ${min} and ${max}`);
|
|
9180
|
+
}
|
|
9181
|
+
return value;
|
|
9182
|
+
}
|
|
9183
|
+
function float(value, name, min, max) {
|
|
9184
|
+
const bytes = new Uint8Array(5);
|
|
9185
|
+
bytes[0] = 136;
|
|
9186
|
+
new DataView(bytes.buffer).setFloat32(1, number(value, name, min, max), true);
|
|
9187
|
+
return [...bytes];
|
|
9188
|
+
}
|
|
9189
|
+
function color(value, name) {
|
|
9190
|
+
number(value, name, 0, 16777215);
|
|
9191
|
+
if (!Number.isInteger(value)) throw new RangeError(`${name} must be an integer RGB color`);
|
|
9192
|
+
return encodeUnsigned(value);
|
|
9193
|
+
}
|
|
9194
|
+
function bool(value, name) {
|
|
9195
|
+
if (typeof value !== "boolean") throw new TypeError(`${name} must be a boolean`);
|
|
9196
|
+
return value ? 141 : 142;
|
|
9197
|
+
}
|
|
9198
|
+
function section2(name, values) {
|
|
9199
|
+
const text2 = encoder.encode(name);
|
|
9200
|
+
return [138, text2.length, ...text2, 0, 144, ...values, 145];
|
|
9201
|
+
}
|
|
9202
|
+
function message2(entity, action, config) {
|
|
9203
|
+
number(entity, "entity", 0, 4294967295);
|
|
9204
|
+
if (!Number.isInteger(entity)) throw new RangeError("entity must be an unsigned 32-bit integer");
|
|
9205
|
+
const {
|
|
9206
|
+
minWidth = 2,
|
|
9207
|
+
maxWidth = 10,
|
|
9208
|
+
minHeight = 2,
|
|
9209
|
+
maxHeight = 10,
|
|
9210
|
+
minEnabled = false,
|
|
9211
|
+
maxEnabled = false,
|
|
9212
|
+
fixedSize = false,
|
|
9213
|
+
backgroundColor = 14540253,
|
|
9214
|
+
borderColor = 4210752,
|
|
9215
|
+
opacity = 1
|
|
9216
|
+
} = config;
|
|
9217
|
+
return Uint8Array.from([
|
|
9218
|
+
144,
|
|
9219
|
+
action,
|
|
9220
|
+
...encodeUnsigned(entity),
|
|
9221
|
+
...section2("config_expando_size", [
|
|
9222
|
+
...float(minWidth, "minWidth", 2, 100),
|
|
9223
|
+
...float(maxWidth, "maxWidth", 2, 100),
|
|
9224
|
+
...float(minHeight, "minHeight", 2, 100),
|
|
9225
|
+
...float(maxHeight, "maxHeight", 2, 100),
|
|
9226
|
+
bool(minEnabled, "minEnabled"),
|
|
9227
|
+
bool(maxEnabled, "maxEnabled"),
|
|
9228
|
+
bool(fixedSize, "fixedSize")
|
|
9229
|
+
]),
|
|
9230
|
+
...section2("config_expando_colors", [
|
|
9231
|
+
...color(backgroundColor, "backgroundColor"),
|
|
9232
|
+
...color(borderColor, "borderColor"),
|
|
9233
|
+
...float(opacity, "opacity", 0, 1)
|
|
9234
|
+
]),
|
|
9235
|
+
145
|
|
9236
|
+
]);
|
|
9237
|
+
}
|
|
9238
|
+
function buildAdvancedExpandoBoxConfigData(entity, config = {}) {
|
|
9239
|
+
return message2(entity, 0, config);
|
|
9240
|
+
}
|
|
9241
|
+
function buildAdvancedExpandoBoxCopyConfigData(config = {}) {
|
|
9242
|
+
return message2(11, 1, config);
|
|
9243
|
+
}
|
|
9244
|
+
function buildAdvancedExpandoBoxPasteConfigData(entity, config = {}) {
|
|
9245
|
+
return message2(entity, 2, config);
|
|
9246
|
+
}
|
|
9247
|
+
|
|
9093
9248
|
// src/protocol/outbound/ui-config.js
|
|
9094
9249
|
init_constants();
|
|
9095
9250
|
var NAV_UNIT_COMMAND = "config_nav_unit";
|
|
@@ -9145,18 +9300,11 @@
|
|
|
9145
9300
|
High: "high"
|
|
9146
9301
|
});
|
|
9147
9302
|
function requireByteInteger(value, name) {
|
|
9148
|
-
const
|
|
9149
|
-
if (!Number.isInteger(
|
|
9303
|
+
const number2 = Number(value);
|
|
9304
|
+
if (!Number.isInteger(number2) || number2 < 0 || number2 > 255) {
|
|
9150
9305
|
throw new RangeError(`${name} must be an integer between 0 and 255`);
|
|
9151
9306
|
}
|
|
9152
|
-
return
|
|
9153
|
-
}
|
|
9154
|
-
function requireUint16(value, name) {
|
|
9155
|
-
const number = Number(value);
|
|
9156
|
-
if (!Number.isInteger(number) || number < 0 || number > 65535) {
|
|
9157
|
-
throw new RangeError(`${name} must be an integer between 0 and 65535`);
|
|
9158
|
-
}
|
|
9159
|
-
return number;
|
|
9307
|
+
return number2;
|
|
9160
9308
|
}
|
|
9161
9309
|
function navConfigBool(value) {
|
|
9162
9310
|
return value ? NAV_UNIT_TRUE : NAV_UNIT_FALSE;
|
|
@@ -9167,32 +9315,32 @@
|
|
|
9167
9315
|
throw new TypeError(`warp must be true, false, "start", "idle", or "cancel"`);
|
|
9168
9316
|
}
|
|
9169
9317
|
function requirePusherMode(value, name) {
|
|
9170
|
-
const
|
|
9171
|
-
if (
|
|
9318
|
+
const number2 = PUSHER_MODE_VALUES.get(value);
|
|
9319
|
+
if (number2 == null || !Number.isInteger(number2) || number2 < 0 || number2 > 2) {
|
|
9172
9320
|
throw new RangeError(`${name} must be PusherMode.Push, PusherMode.Pull, or PusherMode.DoNothing`);
|
|
9173
9321
|
}
|
|
9174
|
-
return
|
|
9322
|
+
return number2;
|
|
9175
9323
|
}
|
|
9176
9324
|
function requireLoaderPosition(value, name) {
|
|
9177
|
-
const
|
|
9178
|
-
if (
|
|
9325
|
+
const number2 = LOADER_POSITION_VALUES.get(value);
|
|
9326
|
+
if (number2 == null || !Number.isInteger(number2) || number2 < 0 || number2 > 7) {
|
|
9179
9327
|
throw new RangeError(`${name} must be a LoaderPosition value`);
|
|
9180
9328
|
}
|
|
9181
|
-
return
|
|
9329
|
+
return number2;
|
|
9182
9330
|
}
|
|
9183
9331
|
function requireLoaderPriority(value, name) {
|
|
9184
|
-
const
|
|
9185
|
-
if (
|
|
9332
|
+
const number2 = LOADER_PRIORITY_VALUES.get(value);
|
|
9333
|
+
if (number2 == null || !Number.isInteger(number2) || number2 < -1 || number2 > 1) {
|
|
9186
9334
|
throw new RangeError(`${name} must be a LoaderPriority value`);
|
|
9187
9335
|
}
|
|
9188
|
-
return
|
|
9336
|
+
return number2 + 1;
|
|
9189
9337
|
}
|
|
9190
9338
|
function requireLoaderFilterMode(value, name) {
|
|
9191
|
-
const
|
|
9192
|
-
if (
|
|
9339
|
+
const number2 = LOADER_FILTER_MODE_VALUES.get(value);
|
|
9340
|
+
if (number2 == null || !Number.isInteger(number2) || number2 < 0 || number2 > 3) {
|
|
9193
9341
|
throw new RangeError(`${name} must be a LoaderFilterMode value`);
|
|
9194
9342
|
}
|
|
9195
|
-
return
|
|
9343
|
+
return number2;
|
|
9196
9344
|
}
|
|
9197
9345
|
var CLIPBOARD_TARGET_VALUES = /* @__PURE__ */ new Map([
|
|
9198
9346
|
["launcher", 8],
|
|
@@ -9229,54 +9377,54 @@
|
|
|
9229
9377
|
[FixedAngleDirection.Down, 3]
|
|
9230
9378
|
]);
|
|
9231
9379
|
function requireClipboardTarget(value, name = "target") {
|
|
9232
|
-
const
|
|
9233
|
-
if (
|
|
9380
|
+
const number2 = typeof value === "string" ? CLIPBOARD_TARGET_VALUES.get(value) : Number(value);
|
|
9381
|
+
if (number2 == null || !Number.isInteger(number2) || number2 < 0 || number2 > 255) {
|
|
9234
9382
|
throw new RangeError(`${name} must be a clipboard target byte or known target name`);
|
|
9235
9383
|
}
|
|
9236
|
-
return
|
|
9384
|
+
return number2;
|
|
9237
9385
|
}
|
|
9238
9386
|
function requireFixedAngle(value, name = "direction") {
|
|
9239
|
-
const
|
|
9240
|
-
if (
|
|
9387
|
+
const number2 = FIXED_ANGLE_VALUES.get(value);
|
|
9388
|
+
if (number2 == null || !Number.isInteger(number2) || number2 < 0 || number2 > 3) {
|
|
9241
9389
|
throw new RangeError(`${name} must be a FixedAngleDirection value`);
|
|
9242
9390
|
}
|
|
9243
|
-
return
|
|
9391
|
+
return number2;
|
|
9244
9392
|
}
|
|
9245
9393
|
function requireAngleDegrees(value, name = "angle") {
|
|
9246
|
-
const
|
|
9247
|
-
if (!Number.isInteger(
|
|
9394
|
+
const number2 = Number(value);
|
|
9395
|
+
if (!Number.isInteger(number2) || number2 < 0 || number2 > 359) {
|
|
9248
9396
|
throw new RangeError(`${name} must be an integer degree value between 0 and 359`);
|
|
9249
9397
|
}
|
|
9250
|
-
return
|
|
9398
|
+
return number2;
|
|
9251
9399
|
}
|
|
9252
9400
|
function requireFiniteNumber2(value, name) {
|
|
9253
|
-
const
|
|
9254
|
-
if (!Number.isFinite(
|
|
9255
|
-
return
|
|
9401
|
+
const number2 = Number(value);
|
|
9402
|
+
if (!Number.isFinite(number2)) throw new RangeError(`${name} must be a finite number`);
|
|
9403
|
+
return number2;
|
|
9256
9404
|
}
|
|
9257
9405
|
function requireNonNegativeInteger2(value, name) {
|
|
9258
|
-
const
|
|
9259
|
-
if (!Number.isInteger(
|
|
9260
|
-
return
|
|
9406
|
+
const number2 = Number(value);
|
|
9407
|
+
if (!Number.isInteger(number2) || number2 < 0) throw new RangeError(`${name} must be a non-negative integer`);
|
|
9408
|
+
return number2;
|
|
9261
9409
|
}
|
|
9262
9410
|
function encodeCompactNumber(value, name) {
|
|
9263
|
-
const
|
|
9264
|
-
if (!Number.isInteger(
|
|
9411
|
+
const number2 = requireFiniteNumber2(value, name);
|
|
9412
|
+
if (!Number.isInteger(number2)) {
|
|
9265
9413
|
const out = new Uint8Array(5);
|
|
9266
9414
|
out[0] = 136;
|
|
9267
|
-
new DataView(out.buffer).setFloat32(1,
|
|
9415
|
+
new DataView(out.buffer).setFloat32(1, number2, true);
|
|
9268
9416
|
return [...out];
|
|
9269
9417
|
}
|
|
9270
|
-
if (
|
|
9271
|
-
if (
|
|
9272
|
-
if (
|
|
9273
|
-
if (
|
|
9418
|
+
if (number2 < 0) throw new RangeError(`${name} must be non-negative`);
|
|
9419
|
+
if (number2 <= 31) return [number2];
|
|
9420
|
+
if (number2 <= 127) return [132, number2];
|
|
9421
|
+
if (number2 <= 65535) return [133, number2 & 255, number2 >> 8 & 255];
|
|
9274
9422
|
throw new RangeError(`${name} must be 65535 or lower`);
|
|
9275
9423
|
}
|
|
9276
9424
|
function encodeCompactItemId(value, name) {
|
|
9277
|
-
const
|
|
9278
|
-
if (
|
|
9279
|
-
return encodeCompactNumber(
|
|
9425
|
+
const number2 = requireNonNegativeInteger2(value, name);
|
|
9426
|
+
if (number2 === 0) return [0];
|
|
9427
|
+
return encodeCompactNumber(number2, name);
|
|
9280
9428
|
}
|
|
9281
9429
|
function encodeLoaderCycle(cycle) {
|
|
9282
9430
|
const seconds = requireFiniteNumber2(cycle, "cycle");
|
|
@@ -9288,16 +9436,12 @@
|
|
|
9288
9436
|
throw new RangeError(`cycle is too large`);
|
|
9289
9437
|
}
|
|
9290
9438
|
function encodeUiCommandTarget(entity, action = 0) {
|
|
9291
|
-
const entityId =
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
throw new RangeError(`copy/paste UI config currently requires an entity id below 256`);
|
|
9439
|
+
const entityId = Number(entity);
|
|
9440
|
+
if (!Number.isInteger(entityId) || entityId < 0 || entityId > 4294967295) {
|
|
9441
|
+
throw new RangeError("entity must be an unsigned 32-bit integer");
|
|
9295
9442
|
}
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
actionId ? actionId : entityId >> 8 & 255,
|
|
9299
|
-
entityId & 255
|
|
9300
|
-
];
|
|
9443
|
+
const actionId = requireByteInteger(action, "action");
|
|
9444
|
+
return [NAV_UNIT_HEADER_TAG, actionId, ...encodeUnsigned(entityId)];
|
|
9301
9445
|
}
|
|
9302
9446
|
function encodeUiCommandSection(commandName) {
|
|
9303
9447
|
const command = encoder.encode(commandName);
|
|
@@ -9646,11 +9790,11 @@
|
|
|
9646
9790
|
send(command = {}) {
|
|
9647
9791
|
return this.client.send(command);
|
|
9648
9792
|
}
|
|
9649
|
-
sendMessage(
|
|
9650
|
-
return this.client.sendMessage(
|
|
9793
|
+
sendMessage(message3, options = {}) {
|
|
9794
|
+
return this.client.sendMessage(message3, options);
|
|
9651
9795
|
}
|
|
9652
|
-
sendRaw(
|
|
9653
|
-
return this.client.sendRaw(
|
|
9796
|
+
sendRaw(message3, options = {}) {
|
|
9797
|
+
return this.client.sendRaw(message3, options);
|
|
9654
9798
|
}
|
|
9655
9799
|
sendEntityCommand(cmd, args = [-1, -1, -1]) {
|
|
9656
9800
|
return this.client.sendEntityCommand(cmd, args);
|
|
@@ -10647,8 +10791,8 @@
|
|
|
10647
10791
|
panel() {
|
|
10648
10792
|
return this.client.commsPanels.get(this.id) || null;
|
|
10649
10793
|
}
|
|
10650
|
-
sendMessage(
|
|
10651
|
-
return this.client.sendCommsMessage(
|
|
10794
|
+
sendMessage(message3 = "") {
|
|
10795
|
+
return this.client.sendCommsMessage(message3);
|
|
10652
10796
|
}
|
|
10653
10797
|
};
|
|
10654
10798
|
var SignHandle = class extends MachineHandle {
|
|
@@ -10795,6 +10939,21 @@
|
|
|
10795
10939
|
get count() {
|
|
10796
10940
|
return this.state?.count;
|
|
10797
10941
|
}
|
|
10942
|
+
#requireAdvanced() {
|
|
10943
|
+
if (!this.state?.advanced) throw new Error("Configuration requires an Advanced Expando Box");
|
|
10944
|
+
}
|
|
10945
|
+
configure(config = {}) {
|
|
10946
|
+
this.#requireAdvanced();
|
|
10947
|
+
return this.client.sendAdvancedExpandoBoxConfig(this.id, config);
|
|
10948
|
+
}
|
|
10949
|
+
copy(config = {}) {
|
|
10950
|
+
this.#requireAdvanced();
|
|
10951
|
+
return this.client.copyAdvancedExpandoBoxConfig(this.id, config);
|
|
10952
|
+
}
|
|
10953
|
+
paste(config = {}) {
|
|
10954
|
+
this.#requireAdvanced();
|
|
10955
|
+
return this.client.pasteAdvancedExpandoBoxConfig(this.id, config);
|
|
10956
|
+
}
|
|
10798
10957
|
};
|
|
10799
10958
|
var CargoEjectorHandle = class extends MachineHandle {
|
|
10800
10959
|
get state() {
|
|
@@ -11067,9 +11226,9 @@
|
|
|
11067
11226
|
return normalizeInventorySlotIndex(value, name);
|
|
11068
11227
|
}
|
|
11069
11228
|
function normalizeInventorySlotIndex(value, name = "slot") {
|
|
11070
|
-
const
|
|
11071
|
-
if (!Number.isInteger(
|
|
11072
|
-
return
|
|
11229
|
+
const number2 = Number(value);
|
|
11230
|
+
if (!Number.isInteger(number2) || number2 < 0) throw new RangeError(`${name} must be a non-negative inventory slot index`);
|
|
11231
|
+
return number2;
|
|
11073
11232
|
}
|
|
11074
11233
|
function currentPlayerSummary(client, scope = "current") {
|
|
11075
11234
|
const sid = Number(client?.sid);
|
|
@@ -11151,14 +11310,14 @@
|
|
|
11151
11310
|
return normalized;
|
|
11152
11311
|
}
|
|
11153
11312
|
function normalizePositiveFinite(value, name) {
|
|
11154
|
-
const
|
|
11155
|
-
if (!Number.isFinite(
|
|
11156
|
-
return
|
|
11313
|
+
const number2 = Number(value);
|
|
11314
|
+
if (!Number.isFinite(number2) || number2 <= 0) throw new RangeError(`${name} must be a positive finite number`);
|
|
11315
|
+
return number2;
|
|
11157
11316
|
}
|
|
11158
11317
|
function normalizePositiveInteger(value, name) {
|
|
11159
|
-
const
|
|
11160
|
-
if (!Number.isInteger(
|
|
11161
|
-
return
|
|
11318
|
+
const number2 = Number(value);
|
|
11319
|
+
if (!Number.isInteger(number2) || number2 <= 0) throw new RangeError(`${name} must be a positive integer`);
|
|
11320
|
+
return number2;
|
|
11162
11321
|
}
|
|
11163
11322
|
function normalizeScannerResultPacket(packet) {
|
|
11164
11323
|
const manifest = packet?.manifest && typeof packet.manifest === "object" ? packet.manifest : {};
|
|
@@ -11379,18 +11538,18 @@
|
|
|
11379
11538
|
this.emit("command", normalized);
|
|
11380
11539
|
return this;
|
|
11381
11540
|
}
|
|
11382
|
-
sendMessage(
|
|
11541
|
+
sendMessage(message3, { afterReady = true } = {}) {
|
|
11383
11542
|
this.#assertWritable();
|
|
11384
11543
|
if (!this.connected || afterReady && !this.ready) {
|
|
11385
|
-
this.#queuedMessages.push({ message:
|
|
11544
|
+
this.#queuedMessages.push({ message: message3, afterReady });
|
|
11386
11545
|
return this;
|
|
11387
11546
|
}
|
|
11388
|
-
this.ws.send(encodeMsgpack(
|
|
11389
|
-
this.emit("message",
|
|
11547
|
+
this.ws.send(encodeMsgpack(message3));
|
|
11548
|
+
this.emit("message", message3);
|
|
11390
11549
|
return this;
|
|
11391
11550
|
}
|
|
11392
|
-
sendRaw(
|
|
11393
|
-
return this.sendMessage(
|
|
11551
|
+
sendRaw(message3, options = {}) {
|
|
11552
|
+
return this.sendMessage(message3, options);
|
|
11394
11553
|
}
|
|
11395
11554
|
sendBlueprintPlacement(placement) {
|
|
11396
11555
|
return this.sendMessage(buildBlueprintPlacementMessage(placement));
|
|
@@ -11443,9 +11602,9 @@
|
|
|
11443
11602
|
this.#savePending = false;
|
|
11444
11603
|
}
|
|
11445
11604
|
}
|
|
11446
|
-
async renameShip(name, { color, timeout = 1e4 } = {}) {
|
|
11605
|
+
async renameShip(name, { color: color2, timeout = 1e4 } = {}) {
|
|
11447
11606
|
this.#assertWritable();
|
|
11448
|
-
buildShipRenameCommitMessage(name,
|
|
11607
|
+
buildShipRenameCommitMessage(name, color2 === void 0 ? "#000000" : color2);
|
|
11449
11608
|
if (!Number.isFinite(timeout) || timeout <= 0 || timeout > 2147483647) {
|
|
11450
11609
|
throw new RangeError("timeout must be positive milliseconds no greater than 2147483647");
|
|
11451
11610
|
}
|
|
@@ -11476,7 +11635,7 @@
|
|
|
11476
11635
|
try {
|
|
11477
11636
|
if (!response.allow) throw new Error(response.message || "Ship rename unavailable");
|
|
11478
11637
|
if (this.worlds.currentWorldId !== worldId) throw new Error("World changed while requesting ship rename");
|
|
11479
|
-
this.sendMessage(buildShipRenameCommitMessage(name,
|
|
11638
|
+
this.sendMessage(buildShipRenameCommitMessage(name, color2 === void 0 ? response.initial_color : color2));
|
|
11480
11639
|
resolve();
|
|
11481
11640
|
} catch (error) {
|
|
11482
11641
|
reject(error);
|
|
@@ -11518,7 +11677,7 @@
|
|
|
11518
11677
|
}
|
|
11519
11678
|
async recoverStarterItem(itemId, { timeout = 1e4 } = {}) {
|
|
11520
11679
|
this.#assertWritable();
|
|
11521
|
-
const
|
|
11680
|
+
const message3 = buildStarterRecoveryMessage(itemId);
|
|
11522
11681
|
if (!Number.isFinite(timeout) || timeout <= 0 || timeout > 2147483647) {
|
|
11523
11682
|
throw new RangeError("timeout must be positive milliseconds no greater than 2147483647");
|
|
11524
11683
|
}
|
|
@@ -11556,7 +11715,7 @@
|
|
|
11556
11715
|
this.on("disconnect", disconnected);
|
|
11557
11716
|
this.on("demote", demoted);
|
|
11558
11717
|
try {
|
|
11559
|
-
this.sendMessage(
|
|
11718
|
+
this.sendMessage(message3);
|
|
11560
11719
|
} catch (error) {
|
|
11561
11720
|
cleanup();
|
|
11562
11721
|
reject(error);
|
|
@@ -11590,7 +11749,7 @@
|
|
|
11590
11749
|
async demoteSelf(options = {}) {
|
|
11591
11750
|
await this.#awaitManagementConfirmation("Self-demotion", buildDemoteSelfMessage(), "demote", () => true, options);
|
|
11592
11751
|
}
|
|
11593
|
-
async #awaitManagementConfirmation(operation,
|
|
11752
|
+
async #awaitManagementConfirmation(operation, message3, event, accept, { timeout = 1e4 } = {}) {
|
|
11594
11753
|
this.#assertWritable();
|
|
11595
11754
|
if (!Number.isFinite(timeout) || timeout <= 0 || timeout > 2147483647) {
|
|
11596
11755
|
throw new RangeError("timeout must be positive milliseconds no greater than 2147483647");
|
|
@@ -11626,7 +11785,7 @@
|
|
|
11626
11785
|
this.on("disconnect", disconnected);
|
|
11627
11786
|
if (event !== "demote") this.on("demote", demoted);
|
|
11628
11787
|
try {
|
|
11629
|
-
this.sendMessage(
|
|
11788
|
+
this.sendMessage(message3);
|
|
11630
11789
|
} catch (error) {
|
|
11631
11790
|
fail(error);
|
|
11632
11791
|
}
|
|
@@ -11638,11 +11797,11 @@
|
|
|
11638
11797
|
sendEntityCommand(cmd, args = [-1, -1, -1]) {
|
|
11639
11798
|
return this.sendMessage({ type: 5, cmd, args });
|
|
11640
11799
|
}
|
|
11641
|
-
sendChatMessage(
|
|
11642
|
-
return this.sendMessage(buildChatMessage(
|
|
11800
|
+
sendChatMessage(message3 = "") {
|
|
11801
|
+
return this.sendMessage(buildChatMessage(message3));
|
|
11643
11802
|
}
|
|
11644
|
-
sendCommsMessage(
|
|
11645
|
-
return this.sendMessage(buildCommsMessage(
|
|
11803
|
+
sendCommsMessage(message3 = "") {
|
|
11804
|
+
return this.sendMessage(buildCommsMessage(message3));
|
|
11646
11805
|
}
|
|
11647
11806
|
sendFabricatorMessage(cmd, args = [-1, -1, -1]) {
|
|
11648
11807
|
return this.sendEntityCommand(cmd, args);
|
|
@@ -11671,6 +11830,19 @@
|
|
|
11671
11830
|
fabricatorEject(row) {
|
|
11672
11831
|
return this.sendFabricatorMessage("eject", [row, -1, -1]);
|
|
11673
11832
|
}
|
|
11833
|
+
#advancedExpandoBoxConfigDefaults(entity, config) {
|
|
11834
|
+
const observed = this.worlds.shipWorld()?.entity(entity)?.contents?.expandoBox?.config;
|
|
11835
|
+
return { ...observed, ...Object.fromEntries(Object.entries(config).filter(([, value]) => value !== void 0)) };
|
|
11836
|
+
}
|
|
11837
|
+
sendAdvancedExpandoBoxConfig(entity, config = {}) {
|
|
11838
|
+
return this.sendUiConfig(buildAdvancedExpandoBoxConfigData(entity, this.#advancedExpandoBoxConfigDefaults(entity, config)));
|
|
11839
|
+
}
|
|
11840
|
+
copyAdvancedExpandoBoxConfig(entity, config = {}) {
|
|
11841
|
+
return this.sendUiConfig(buildAdvancedExpandoBoxCopyConfigData(this.#advancedExpandoBoxConfigDefaults(entity, config)));
|
|
11842
|
+
}
|
|
11843
|
+
pasteAdvancedExpandoBoxConfig(entity, config = {}) {
|
|
11844
|
+
return this.sendUiConfig(buildAdvancedExpandoBoxPasteConfigData(entity, this.#advancedExpandoBoxConfigDefaults(entity, config)));
|
|
11845
|
+
}
|
|
11674
11846
|
sendLauncherConfig(entity, config = {}) {
|
|
11675
11847
|
return this.sendUiConfig(buildLauncherConfigData(entity, this.#launcherConfigDefaults(entity, config)));
|
|
11676
11848
|
}
|
|
@@ -11904,14 +12076,14 @@
|
|
|
11904
12076
|
return this.useHeldItem(options, command);
|
|
11905
12077
|
}
|
|
11906
12078
|
placeBlueprint(placement, { invSlot = 0, hold = true, mx = null, my = null } = {}, command = {}) {
|
|
11907
|
-
const
|
|
11908
|
-
this.sendMessage(
|
|
12079
|
+
const message3 = buildBlueprintPlacementMessage(placement);
|
|
12080
|
+
this.sendMessage(message3);
|
|
11909
12081
|
return this.placeHeldItem(
|
|
11910
12082
|
{ invSlot, hold },
|
|
11911
12083
|
{
|
|
11912
12084
|
...command,
|
|
11913
|
-
mx: mx ??
|
|
11914
|
-
my: my ??
|
|
12085
|
+
mx: mx ?? message3.x,
|
|
12086
|
+
my: my ?? message3.y
|
|
11915
12087
|
}
|
|
11916
12088
|
);
|
|
11917
12089
|
}
|
|
@@ -12116,12 +12288,12 @@
|
|
|
12116
12288
|
}
|
|
12117
12289
|
#bindAttachedSocket() {
|
|
12118
12290
|
const open = () => this.#attachedOpen();
|
|
12119
|
-
const
|
|
12291
|
+
const message3 = (event) => this.#handleSocketMessage(event?.data ?? event);
|
|
12120
12292
|
const error = (event) => this.#fail(event?.error || new Error("WebSocket error"));
|
|
12121
12293
|
const close = (event, reason) => this.#handleSocketClose(event, reason);
|
|
12122
12294
|
if (typeof this.ws.addEventListener === "function") {
|
|
12123
12295
|
this.ws.addEventListener("open", open);
|
|
12124
|
-
this.ws.addEventListener("message",
|
|
12296
|
+
this.ws.addEventListener("message", message3);
|
|
12125
12297
|
this.ws.addEventListener("error", error);
|
|
12126
12298
|
this.ws.addEventListener("close", close);
|
|
12127
12299
|
return;
|
|
@@ -12133,7 +12305,7 @@
|
|
|
12133
12305
|
this.ws.on("close", close);
|
|
12134
12306
|
return;
|
|
12135
12307
|
}
|
|
12136
|
-
for (const [type, handler] of Object.entries({ open, message:
|
|
12308
|
+
for (const [type, handler] of Object.entries({ open, message: message3, error, close })) {
|
|
12137
12309
|
const previous = this.ws[`on${type}`];
|
|
12138
12310
|
this.ws[`on${type}`] = (...args) => {
|
|
12139
12311
|
if (typeof previous === "function") previous.apply(this.ws, args);
|
|
@@ -12437,7 +12609,7 @@
|
|
|
12437
12609
|
return headers;
|
|
12438
12610
|
}
|
|
12439
12611
|
#navigationUnitConfigDefaults(entity, config = {}) {
|
|
12440
|
-
const summary = this.entity(entity)?.contents?.navigationUnit || null;
|
|
12612
|
+
const summary = this.worlds.shipWorld()?.entity(entity)?.contents?.navigationUnit || null;
|
|
12441
12613
|
return {
|
|
12442
12614
|
destination: config.destination ?? summary?.destination,
|
|
12443
12615
|
page: config.page ?? 0,
|
|
@@ -12534,8 +12706,8 @@
|
|
|
12534
12706
|
init_constants();
|
|
12535
12707
|
init_runtime();
|
|
12536
12708
|
init_http();
|
|
12537
|
-
function createShipSpec(name = "",
|
|
12538
|
-
return { type: "new", name: String(name ?? ""), color: String(
|
|
12709
|
+
function createShipSpec(name = "", color2 = "") {
|
|
12710
|
+
return { type: "new", name: String(name ?? ""), color: String(color2 ?? "") };
|
|
12539
12711
|
}
|
|
12540
12712
|
function createInviteShipSpec(code) {
|
|
12541
12713
|
return { type: "invite", code: String(code ?? "") };
|
|
@@ -12686,7 +12858,7 @@
|
|
|
12686
12858
|
if (!found) throw new Error("Account page has no clan form; authentication may be required or the page format has changed");
|
|
12687
12859
|
const fields = /* @__PURE__ */ new Map();
|
|
12688
12860
|
let name = null;
|
|
12689
|
-
let
|
|
12861
|
+
let color2 = null;
|
|
12690
12862
|
for (const paragraph of source.matchAll(/<p\b[^>]*>([\s\S]*?)<\/p\s*>/gi)) {
|
|
12691
12863
|
const label = paragraph[1].match(/<b\b[^>]*>([\s\S]*?)<\/b\s*>/i);
|
|
12692
12864
|
const code = paragraph[1].match(/<code\b((?:"[^"]*"|'[^']*'|[^'">])*)>([\s\S]*?)<\/code\s*>/i);
|
|
@@ -12695,7 +12867,7 @@
|
|
|
12695
12867
|
if (label) fields.set(text(label[1]).replace(/:\s*$/, "").toLowerCase(), attrs.get("data-info") ?? null);
|
|
12696
12868
|
if ((attrs.get("class") || "").split(/\s+/).includes("user") && /^You are:$/i.test(text(paragraph[1].slice(0, code.index)))) {
|
|
12697
12869
|
name = decodeHtml(code[2].replace(/<[^>]*>/g, ""));
|
|
12698
|
-
|
|
12870
|
+
color2 = parseAccountColor(attrs.get("style") || "");
|
|
12699
12871
|
}
|
|
12700
12872
|
}
|
|
12701
12873
|
const rawIdentity = fields.get("identity (service)") || null;
|
|
@@ -12703,7 +12875,7 @@
|
|
|
12703
12875
|
const count = text(source).match(/Your current clan tag has\s+([\d,]+)\s+other users?\b/i);
|
|
12704
12876
|
return {
|
|
12705
12877
|
name,
|
|
12706
|
-
color,
|
|
12878
|
+
color: color2,
|
|
12707
12879
|
email: fields.get("email") || null,
|
|
12708
12880
|
identity: identityParts ? identityParts[1].trim() : rawIdentity,
|
|
12709
12881
|
identityService: identityParts ? identityParts[2].trim() : null,
|
|
@@ -12712,14 +12884,14 @@
|
|
|
12712
12884
|
};
|
|
12713
12885
|
}
|
|
12714
12886
|
function parseAccountColor(style) {
|
|
12715
|
-
let
|
|
12887
|
+
let color2 = null;
|
|
12716
12888
|
for (const declaration of style.split(";")) {
|
|
12717
12889
|
const match = declaration.match(/^\s*background(?:-color)?\s*:\s*#([0-9a-f]{6}|[0-9a-f]{3})\s*(?:!important\s*)?$/i);
|
|
12718
12890
|
if (!match) continue;
|
|
12719
12891
|
const hex = match[1].length === 3 ? [...match[1]].map((digit) => digit + digit).join("") : match[1];
|
|
12720
|
-
|
|
12892
|
+
color2 = parseInt(hex, 16);
|
|
12721
12893
|
}
|
|
12722
|
-
return
|
|
12894
|
+
return color2;
|
|
12723
12895
|
}
|
|
12724
12896
|
function parseShipsWithPerks(source) {
|
|
12725
12897
|
const heading = source.match(/<(b|strong)\b[^>]*>\s*Ships\s+with\s+Perks\s+Applied\s*:\s*<\/\1\s*>/i);
|
|
@@ -12849,8 +13021,8 @@
|
|
|
12849
13021
|
async startShipConnection(server2, ship = null) {
|
|
12850
13022
|
return this.#startShipConnection(server2, ship, false);
|
|
12851
13023
|
}
|
|
12852
|
-
async startNewShipConnection(server2, name = "",
|
|
12853
|
-
return this.#startShipConnection(server2, createShipSpec(name,
|
|
13024
|
+
async startNewShipConnection(server2, name = "", color2 = "") {
|
|
13025
|
+
return this.#startShipConnection(server2, createShipSpec(name, color2), false);
|
|
12854
13026
|
}
|
|
12855
13027
|
async joinInviteConnection(server2, code) {
|
|
12856
13028
|
return this.#startShipConnection(server2, createInviteShipSpec(code), false);
|
|
@@ -12861,8 +13033,8 @@
|
|
|
12861
13033
|
async startShip(server2, ship = null) {
|
|
12862
13034
|
return readyClient(await this.startShipConnection(server2, ship));
|
|
12863
13035
|
}
|
|
12864
|
-
async startNewShip(server2, name = "",
|
|
12865
|
-
return readyClient(await this.startNewShipConnection(server2, name,
|
|
13036
|
+
async startNewShip(server2, name = "", color2 = "") {
|
|
13037
|
+
return readyClient(await this.startNewShipConnection(server2, name, color2));
|
|
12866
13038
|
}
|
|
12867
13039
|
async joinInvite(server2, code) {
|
|
12868
13040
|
return readyClient(await this.joinInviteConnection(server2, code));
|
|
@@ -13043,8 +13215,8 @@
|
|
|
13043
13215
|
async startShipConnection(server2, ship = null) {
|
|
13044
13216
|
return this.#joinBrowserConnection(server2, ship, false);
|
|
13045
13217
|
}
|
|
13046
|
-
async startNewShipConnection(server2, name = "",
|
|
13047
|
-
return this.#joinBrowserConnection(server2, createShipSpec(name,
|
|
13218
|
+
async startNewShipConnection(server2, name = "", color2 = "") {
|
|
13219
|
+
return this.#joinBrowserConnection(server2, createShipSpec(name, color2), false);
|
|
13048
13220
|
}
|
|
13049
13221
|
async joinInviteConnection(server2, code) {
|
|
13050
13222
|
return this.#joinBrowserConnection(server2, createInviteShipSpec(code), false);
|
|
@@ -13055,8 +13227,8 @@
|
|
|
13055
13227
|
async startShip(server2, ship = null) {
|
|
13056
13228
|
return readyBrowserClient(await this.startShipConnection(server2, ship));
|
|
13057
13229
|
}
|
|
13058
|
-
async startNewShip(server2, name = "",
|
|
13059
|
-
return readyBrowserClient(await this.startNewShipConnection(server2, name,
|
|
13230
|
+
async startNewShip(server2, name = "", color2 = "") {
|
|
13231
|
+
return readyBrowserClient(await this.startNewShipConnection(server2, name, color2));
|
|
13060
13232
|
}
|
|
13061
13233
|
async joinInvite(server2, code) {
|
|
13062
13234
|
return readyBrowserClient(await this.joinInviteConnection(server2, code));
|
|
@@ -13163,8 +13335,8 @@
|
|
|
13163
13335
|
async function startShip(server2, ship = null, session = null) {
|
|
13164
13336
|
return (session || browserSession()).startShip(server2, ship);
|
|
13165
13337
|
}
|
|
13166
|
-
async function startNewShip(server2, name = "",
|
|
13167
|
-
return (session || browserSession()).startNewShip(server2, name,
|
|
13338
|
+
async function startNewShip(server2, name = "", color2 = "", session = null) {
|
|
13339
|
+
return (session || browserSession()).startNewShip(server2, name, color2);
|
|
13168
13340
|
}
|
|
13169
13341
|
async function joinInvite(server2, code, session = null) {
|
|
13170
13342
|
return (session || browserSession()).joinInvite(server2, code);
|