dredless 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -774,6 +774,110 @@
774
774
  }
775
775
  });
776
776
 
777
+ // src/protocol/outbound/machine-config.js
778
+ init_constants();
779
+ function uint32(value, name) {
780
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0 || value > 4294967295) {
781
+ throw new RangeError(`${name} must be an unsigned 32-bit integer`);
782
+ }
783
+ return value;
784
+ }
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
+ function encodeFloat(value, name, max) {
792
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > max) {
793
+ throw new RangeError(`${name} must be a finite number between 0 and ${max}`);
794
+ }
795
+ const number = Math.fround(value);
796
+ if (Number.isInteger(number)) {
797
+ if (number < 64) return [number];
798
+ if (number < 128) return [132, number];
799
+ return [133, number & 255, number >>> 8];
800
+ }
801
+ const bytes = new Uint8Array(5);
802
+ bytes[0] = 136;
803
+ new DataView(bytes.buffer).setFloat32(1, number, true);
804
+ return [...bytes];
805
+ }
806
+ function section(name, values) {
807
+ const bytes = encoder.encode(name);
808
+ return [138, bytes.length, ...bytes, 0, 144, ...values, 145];
809
+ }
810
+ function message(target, action, sections) {
811
+ return Uint8Array.from([144, action, ...encodeUnsigned(uint32(target, "target")), ...sections.flat(), 145]);
812
+ }
813
+ function normalizeRankMask({ allowedRanks, rankMask } = {}) {
814
+ if (allowedRanks !== void 0 && rankMask !== void 0) {
815
+ throw new TypeError("provide allowedRanks or rankMask, not both");
816
+ }
817
+ if (rankMask !== void 0) {
818
+ const value = uint32(rankMask, "rankMask");
819
+ if (value > 7 && value !== 4294967295) throw new RangeError("rankMask must be 0\u20137 or 0xffffffff");
820
+ return value;
821
+ }
822
+ if (allowedRanks === void 0) return 4;
823
+ if (allowedRanks === "all") return 4294967295;
824
+ if (!Array.isArray(allowedRanks)) throw new TypeError('allowedRanks must be an array of rank names or "all"');
825
+ let mask = 0;
826
+ for (const rank of allowedRanks) {
827
+ const bit = { guest: 1, crew: 2, captain: 4 }[rank];
828
+ if (typeof rank !== "string" || !["guest", "crew", "captain"].includes(rank)) throw new RangeError(`unsupported rank: ${rank}`);
829
+ mask |= bit;
830
+ }
831
+ return mask;
832
+ }
833
+ function rankSection(config) {
834
+ return section("filter_ranks", encodeUnsigned(normalizeRankMask(config)));
835
+ }
836
+ function launcherSection({ angle = 0, power = 30 } = {}) {
837
+ return section("config_item_launcher", [...encodeFloat(angle, "angle", 360), ...encodeFloat(power, "power", 30)]);
838
+ }
839
+ function doorSections(config = {}, clipboard = false) {
840
+ if (!clipboard && config.orientation !== void 0) {
841
+ throw new TypeError("door orientation is only available for placement/clipboard configuration");
842
+ }
843
+ const sections = [rankSection(config)];
844
+ if (clipboard) {
845
+ const orientation = config.orientation ?? "vertical";
846
+ if (orientation !== "vertical" && orientation !== "horizontal") {
847
+ throw new RangeError('orientation must be "vertical" or "horizontal"');
848
+ }
849
+ sections.unshift(section("angle_symmetric", [orientation === "horizontal" ? 1 : 0]));
850
+ }
851
+ return sections;
852
+ }
853
+ function buildLauncherConfigData(entity, config = {}) {
854
+ return message(entity, 0, [launcherSection(config)]);
855
+ }
856
+ function buildLauncherCopyConfigData(config = {}) {
857
+ return message(8, 1, [launcherSection(config)]);
858
+ }
859
+ function buildLauncherPasteConfigData(entity, config = {}) {
860
+ return message(entity, 2, [launcherSection(config)]);
861
+ }
862
+ function buildDoorConfigData(entity, config = {}) {
863
+ return message(entity, 0, doorSections(config));
864
+ }
865
+ function buildDoorCopyConfigData(config = {}) {
866
+ return message(10, 1, doorSections(config, true));
867
+ }
868
+ function buildDoorPasteConfigData(entity, config = {}) {
869
+ return message(entity, 2, doorSections(config, true));
870
+ }
871
+ function buildSpawnPointConfigData(entity, config = {}) {
872
+ return message(entity, 0, [rankSection(config)]);
873
+ }
874
+ function buildSpawnPointCopyConfigData(config = {}) {
875
+ return message(9, 1, [rankSection(config)]);
876
+ }
877
+ function buildSpawnPointPasteConfigData(entity, config = {}) {
878
+ return message(entity, 2, [rankSection(config)]);
879
+ }
880
+
777
881
  // src/network/connection.js
778
882
  init_constants();
779
883
  init_runtime();
@@ -847,8 +951,8 @@
847
951
  });
848
952
  }
849
953
  var DisconnectError = class extends Error {
850
- constructor(disconnect, message = "Disconnected") {
851
- super(`${message}: ${disconnect.name ?? "Unknown"} (${disconnect.code})${disconnect.reason ? ` \u2014 ${disconnect.reason}` : ""}`);
954
+ constructor(disconnect, message2 = "Disconnected") {
955
+ super(`${message2}: ${disconnect.name ?? "Unknown"} (${disconnect.code})${disconnect.reason ? ` \u2014 ${disconnect.reason}` : ""}`);
852
956
  this.name = "DisconnectError";
853
957
  this.disconnect = disconnect;
854
958
  }
@@ -892,281 +996,6 @@
892
996
  }
893
997
  };
894
998
 
895
- // src/protocol/outbound/comms.js
896
- var COMMS_MESSAGE_TYPE = 3;
897
- function buildCommsMessage(message = "") {
898
- return {
899
- type: COMMS_MESSAGE_TYPE,
900
- msg: String(message)
901
- };
902
- }
903
- function normalizeCommsEvent(event) {
904
- const rawMessages = Array.isArray(event?.msgs_text) ? event.msgs_text : [];
905
- return {
906
- ...event,
907
- entity: event?.ent_id != null && Number.isFinite(Number(event.ent_id)) ? Number(event.ent_id) : null,
908
- rawMessages,
909
- messages: rawMessages.map((message) => ({
910
- raw: message,
911
- text: flattenRichText(message)
912
- }))
913
- };
914
- }
915
- function flattenRichText(value) {
916
- if (value == null) return "";
917
- if (typeof value === "string") return value;
918
- if (typeof value === "number" || typeof value === "boolean") return String(value);
919
- if (Array.isArray(value)) return value.map(flattenRichText).join("");
920
- if (typeof value === "object") {
921
- if (Object.hasOwn(value, "c")) return flattenRichText(value.c);
922
- if (Object.hasOwn(value, "text")) return flattenRichText(value.text);
923
- }
924
- return "";
925
- }
926
-
927
- // src/protocol/outbound/ship-management.js
928
- var SHIP_MANAGEMENT_TYPE = 4;
929
- var CREW_LOG_LENGTH = 500;
930
- var SET_PRIVACY_ACTION = "set_privacy";
931
- var GRAVITY_ACTION = "gravity";
932
- var SET_PATRON_PERKS_ACTION = "set_patron_perks";
933
- var STARTER_RECOVERY_ACTION = "starter_recovery";
934
- var PLAYER_LIST_ACTION = "player_list";
935
- var INVITE_RESET_ACTION = "invite_reset";
936
- var SET_RANK_ACTION = "set_rank";
937
- var KICK_ACTION = "kick";
938
- var BAN_ACTION = "ban";
939
- var UNBAN_ACTION = "unban";
940
- var DEMOTE_SELF_ACTION = "demote_self";
941
- var SAVE_SHIP_ACTION = "save_team";
942
- var RENAME_REQUEST_ACTION = "rename_request";
943
- var RENAME_COMMIT_ACTION = "rename_commit";
944
- var GravityDirection = Object.freeze({
945
- Down: "down",
946
- Up: "up",
947
- Left: "left",
948
- Right: "right"
949
- });
950
- function normalizeGravityDirection(value) {
951
- if (value === GravityDirection.Down || value === 0) return 0;
952
- if (value === GravityDirection.Up || value === 1) return 1;
953
- if (value === GravityDirection.Left || value === 2) return 2;
954
- if (value === GravityDirection.Right || value === 3) return 3;
955
- throw new RangeError('direction must be "down", "up", "left", "right", or an integer from 0 to 3');
956
- }
957
- function requireNonNegativeInteger(value, name) {
958
- const number = Number(value);
959
- if (!Number.isInteger(number) || number < 0) throw new RangeError(`${name} must be a non-negative integer`);
960
- return number;
961
- }
962
- function normalizePrivacy(value) {
963
- if (value === true || value === 1 || value === "private") return 1;
964
- if (value === false || value === 0 || value === "public") return 0;
965
- throw new RangeError(`privacy must be 0, 1, true, false, "public", or "private"`);
966
- }
967
- function normalizePlayerRef(value) {
968
- return requireNonNegativeInteger(value, "refId");
969
- }
970
- function normalizePlayerRank(value) {
971
- if (value === 0 || value === "guest") return 0;
972
- if (value === 1 || value === "crew") return 1;
973
- if (value === 3 || value === "captain") return 3;
974
- throw new RangeError(`rank must be 0, 1, 3, "guest", "crew", or "captain"`);
975
- }
976
- function buildShipManagementMessage(act, arg = null, extra = null) {
977
- if (typeof act !== "string" || !act) throw new TypeError(`act must be a non-empty string`);
978
- const message = { type: SHIP_MANAGEMENT_TYPE, act, arg };
979
- if (extra && typeof extra === "object") Object.assign(message, extra);
980
- return message;
981
- }
982
- function buildShipPrivacyMessage(privacy) {
983
- return buildShipManagementMessage(SET_PRIVACY_ACTION, normalizePrivacy(privacy));
984
- }
985
- function buildShipGravityMessage(direction) {
986
- return buildShipManagementMessage(GRAVITY_ACTION, normalizeGravityDirection(direction));
987
- }
988
- function buildSetPatronPerksMessage(enabled) {
989
- if (typeof enabled !== "boolean") throw new TypeError("enabled must be a boolean");
990
- return buildShipManagementMessage(SET_PATRON_PERKS_ACTION, enabled);
991
- }
992
- function buildStarterRecoveryMessage(itemId) {
993
- return buildShipManagementMessage(STARTER_RECOVERY_ACTION, requireNonNegativeInteger(itemId, "itemId"));
994
- }
995
- function buildPlayerListMessage() {
996
- return buildShipManagementMessage(PLAYER_LIST_ACTION);
997
- }
998
- function buildInviteResetMessage() {
999
- return buildShipManagementMessage(INVITE_RESET_ACTION);
1000
- }
1001
- function buildSetPlayerRankMessage(refId, rank) {
1002
- return buildShipManagementMessage(SET_RANK_ACTION, normalizePlayerRef(refId), { rank: normalizePlayerRank(rank) });
1003
- }
1004
- function buildKickPlayerMessage(refId) {
1005
- return buildShipManagementMessage(KICK_ACTION, normalizePlayerRef(refId));
1006
- }
1007
- function buildBanPlayerMessage(refId) {
1008
- return buildShipManagementMessage(BAN_ACTION, normalizePlayerRef(refId));
1009
- }
1010
- function buildUnbanPlayerMessage(refId) {
1011
- return buildShipManagementMessage(UNBAN_ACTION, normalizePlayerRef(refId));
1012
- }
1013
- function buildDemoteSelfMessage() {
1014
- return buildShipManagementMessage(DEMOTE_SELF_ACTION);
1015
- }
1016
- function buildSaveShipMessage() {
1017
- return buildShipManagementMessage(SAVE_SHIP_ACTION);
1018
- }
1019
- function buildShipRenameRequestMessage() {
1020
- return buildShipManagementMessage(RENAME_REQUEST_ACTION);
1021
- }
1022
- function buildShipRenameCommitMessage(name, color) {
1023
- if (typeof name !== "string") throw new TypeError("name must be a string");
1024
- if (name.length > 32) throw new RangeError("name must be at most 32 UTF-16 code units");
1025
- if (typeof color !== "string" || !/^#[0-9a-f]{6}$/i.test(color)) {
1026
- throw new TypeError("color must be a #RRGGBB hex string");
1027
- }
1028
- return buildShipManagementMessage(RENAME_COMMIT_ACTION, name, { arg2: color });
1029
- }
1030
- function normalizeShipConfig(event = {}) {
1031
- const source = event && typeof event === "object" ? event : {};
1032
- const config = source.config && typeof source.config === "object" ? source.config : {};
1033
- return {
1034
- privacy: config.privacy ?? null,
1035
- privacyName: config.privacy === 0 ? "public" : config.privacy === 1 ? "private" : null,
1036
- inviteKey: config.invite_key ?? null,
1037
- teamId: source.team_id ?? null,
1038
- patronPerks: Array.isArray(source.patron_perks) ? source.patron_perks.slice() : []
1039
- };
1040
- }
1041
- function normalizeCaptainSubrank(event = {}) {
1042
- const source = event && typeof event === "object" ? event : {};
1043
- return {
1044
- subrank: source.subrank ?? null,
1045
- enableCheats: Boolean(source.enable_cheats)
1046
- };
1047
- }
1048
- function normalizeCrewLog(event = {}, previous = null) {
1049
- const source = event && typeof event === "object" ? event : {};
1050
- const reset = Boolean(source.reset);
1051
- const amend = Boolean(source.amend);
1052
- const entries = reset ? [] : (previous?.entries || []).slice();
1053
- if (amend) entries.pop();
1054
- const changes = Array.isArray(source.entries) ? source.entries.map((entry) => {
1055
- const value = entry && typeof entry === "object" ? entry : {};
1056
- return {
1057
- icon: value.icon ?? null,
1058
- text: flattenRichText(value.text),
1059
- rawText: value.text ?? null,
1060
- count: value.count ?? 1,
1061
- refId: value.ref ?? null,
1062
- secondaryRefId: value.ref2 ?? null
1063
- };
1064
- }) : [];
1065
- for (const entry of changes) entries.push(entry);
1066
- if (entries.length > CREW_LOG_LENGTH) entries.splice(0, entries.length - CREW_LOG_LENGTH);
1067
- return { entries, changes, reset, amend };
1068
- }
1069
- function normalizeShipPlayerList(event = {}, previous = null, currentCaptainSubrank = null) {
1070
- const source = event && typeof event === "object" ? event : {};
1071
- const changes = Array.isArray(source.player_list) ? source.player_list.map(normalizePlayerListChange) : [];
1072
- const removedPlayers = changes.filter((change) => change.remove && Number.isFinite(Number(change.refId))).map((change) => Number(change.refId));
1073
- const changedPlayers = changes.filter((change) => !change.remove).map(({ remove: _remove, ...change }) => change);
1074
- const players = mergePlayerListChanges(previous?.players, changes);
1075
- const ownerCaptainRank = ownerRankForPlayers(players);
1076
- applyPlayerControlState(players, currentCaptainSubrank);
1077
- applyPlayerControlState(changedPlayers, currentCaptainSubrank);
1078
- return {
1079
- ownerCaptainRank,
1080
- shipOwners: players.filter((player) => player.isShipOwner),
1081
- players,
1082
- changes: changedPlayers,
1083
- removedPlayers
1084
- };
1085
- }
1086
- function mergePlayerListChanges(previousPlayers, changes) {
1087
- if (!Array.isArray(previousPlayers) || !previousPlayers.length) return changes.filter((change) => !change.remove).map(({
1088
- remove: _remove,
1089
- ...player
1090
- }) => ({ ...player }));
1091
- const existing = /* @__PURE__ */ new Map();
1092
- for (const player of previousPlayers) {
1093
- if (player?.refId == null) continue;
1094
- existing.set(player.refId, { ...player, isShipOwner: false });
1095
- }
1096
- const changedRefs = /* @__PURE__ */ new Set();
1097
- const merged = [];
1098
- for (const change of changes) {
1099
- if (change.refId == null) {
1100
- if (!change.remove) {
1101
- const { remove: _remove2, ...player2 } = change;
1102
- merged.push({ ...player2, isShipOwner: false });
1103
- }
1104
- continue;
1105
- }
1106
- changedRefs.add(change.refId);
1107
- if (change.remove) {
1108
- existing.delete(change.refId);
1109
- continue;
1110
- }
1111
- const { remove: _remove, ...changePlayer } = change;
1112
- const player = { ...existing.get(change.refId) || {}, ...changePlayer, isShipOwner: false };
1113
- existing.set(change.refId, player);
1114
- merged.push(player);
1115
- }
1116
- for (const player of previousPlayers) {
1117
- if (player?.refId == null || changedRefs.has(player.refId)) continue;
1118
- const retained = existing.get(player.refId);
1119
- if (retained) merged.push(retained);
1120
- }
1121
- return merged;
1122
- }
1123
- function normalizePlayerListChange(entry = {}) {
1124
- const source = entry && typeof entry === "object" ? entry : {};
1125
- if (source._removed) return { refId: source.ref_id ?? null, remove: true };
1126
- return {
1127
- refId: source.ref_id ?? null,
1128
- remove: false,
1129
- discrim: source.discrim ?? null,
1130
- discrimColor: source.discrim_color ?? null,
1131
- teamRank: source.team_rank ?? null,
1132
- captainRank: source.captain_rank ?? null,
1133
- isCaptain: Number(source.captain_rank) > 0,
1134
- isShipOwner: false,
1135
- canBeManaged: false,
1136
- time: source.time ?? null,
1137
- items: Array.isArray(source.items) ? source.items.slice() : [],
1138
- aliasDiscrims: Array.isArray(source.alias_discrims) ? source.alias_discrims.slice() : [],
1139
- extraAliasCount: normalizeNonNegativeNumber(source.extra_aliases),
1140
- onlineCount: source.online_count ?? null
1141
- };
1142
- }
1143
- function normalizeNonNegativeNumber(value) {
1144
- const number = Number(value);
1145
- return Number.isFinite(number) && number > 0 ? number : 0;
1146
- }
1147
- function ownerRankForPlayers(players) {
1148
- const ranks = players.filter((player) => Number(player.captainRank) > 0).map((player) => Number(player.captainRank)).filter(Number.isFinite);
1149
- if (!ranks.length) return null;
1150
- const ownerRank = Math.min(...ranks);
1151
- for (const player of players) player.isShipOwner = Number(player.captainRank) === ownerRank;
1152
- return ownerRank;
1153
- }
1154
- function applyPlayerControlState(players, currentCaptainSubrank) {
1155
- const currentRank = currentCaptainRank(currentCaptainSubrank);
1156
- for (const player of players) player.canBeManaged = playerCanBeManagedBy(player, currentRank);
1157
- }
1158
- function currentCaptainRank(currentCaptainSubrank) {
1159
- const rank = Number(currentCaptainSubrank?.subrank);
1160
- return Number.isFinite(rank) && rank > 0 ? rank : null;
1161
- }
1162
- function playerCanBeManagedBy(player, currentRank) {
1163
- if (!Number.isFinite(currentRank) || !player) return false;
1164
- const targetCaptainRank = Number(player.captainRank);
1165
- if (Number.isFinite(targetCaptainRank) && targetCaptainRank > 0) return currentRank < targetCaptainRank;
1166
- const targetTeamRank = Number(player.teamRank);
1167
- return targetTeamRank === 0 || targetTeamRank === 1;
1168
- }
1169
-
1170
999
  // src/client/domains/tips.js
1171
1000
  function timeoutValue(options) {
1172
1001
  const timeout = options.timeout ?? 5e3;
@@ -1329,25 +1158,6 @@
1329
1158
  return this.#select(option);
1330
1159
  });
1331
1160
  }
1332
- setRank(handle, rank, options = {}) {
1333
- return this.#exclusive(async () => {
1334
- const value = normalizePlayerRank(rank);
1335
- const timeout = timeoutValue(options);
1336
- if (!handle.exists()) throw new Error("Rank target no longer exists");
1337
- if (handle.rank === value) return this.client;
1338
- const text2 = { 0: "Restrict to Guests", 1: "Restrict to Crew", 3: "Restrict to Captains" }[value];
1339
- await this.#open(handle, options);
1340
- await waitFor(
1341
- this.client,
1342
- "model",
1343
- () => handle.rank === value,
1344
- timeout,
1345
- "access rank update",
1346
- () => this.#select(text2)
1347
- );
1348
- return this.client;
1349
- });
1350
- }
1351
1161
  };
1352
1162
 
1353
1163
  // src/client/core.js
@@ -4737,14 +4547,18 @@
4737
4547
  return this.bytes[this.offset++];
4738
4548
  }
4739
4549
  readUnsigned() {
4740
- let result = 0;
4741
- let shift = 0;
4550
+ const first = this.readByte();
4551
+ if (first < 128) return first;
4552
+ let result = first & 127;
4553
+ let multiplier = 128;
4554
+ let shift = 7;
4742
4555
  while (true) {
4743
4556
  const byte = this.readByte();
4744
- result += (byte & 127) * 2 ** shift;
4557
+ result += (byte & 127) * multiplier;
4745
4558
  if ((byte & 128) === 0) return result;
4746
4559
  shift += 7;
4747
4560
  if (shift > 70) throw new Error("model_data varint too large");
4561
+ multiplier *= 128;
4748
4562
  }
4749
4563
  }
4750
4564
  readStreamInt() {
@@ -4907,7 +4721,7 @@
4907
4721
  [4, { name: "motion_aux", packedBits: [{ bit: 8, offset: 33 }], fields: numericFields({ 1: 20, 2: 24, 4: 28 }) }],
4908
4722
  [5, {
4909
4723
  name: "entity_health",
4910
- // The official table starts both bar dimensions at 10 (one world unit).
4724
+ // Bar half-width and vertical offset start at 10 (one world unit).
4911
4725
  // Field values on the wire are deltas relative to these defaults.
4912
4726
  defaults: { q28: 10, q32: 10 },
4913
4727
  fields: numericFields({ 1: 20, 2: 24, 4: 28, 8: 32 })
@@ -5191,7 +5005,11 @@
5191
5005
  record.q44 = (record.q44 || 0) + reader.readFieldDelta();
5192
5006
  }
5193
5007
  }
5194
- }]
5008
+ }],
5009
+ // Append new wire components without shifting stable Dredless table IDs.
5010
+ [79, { name: "launcher_config", defaults: { q20: 0, q24: 300 }, fields: numericFields({ 1: 20, 2: 24 }) }],
5011
+ [80, { name: "rank_filter", defaults: { q20: 4 }, fields: numericFields({ 1: 20 }) }],
5012
+ [81, { name: "spawn_point", fields: [] }]
5195
5013
  ]);
5196
5014
  for (const spec of MODEL_TABLE_SPECS.values()) {
5197
5015
  for (const blob of spec.blobs || []) blob.key = blobKey(blob.offset);
@@ -5288,7 +5106,10 @@
5288
5106
  [166, 75],
5289
5107
  [167, 76],
5290
5108
  [168, 78],
5291
- [169, 77]
5109
+ [169, 77],
5110
+ [170, 79],
5111
+ [171, 80],
5112
+ [172, 81]
5292
5113
  ]);
5293
5114
  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]);
5294
5115
  var ENTITY_FOOTPRINTS = /* @__PURE__ */ new Map([
@@ -5642,6 +5463,8 @@
5642
5463
  hp,
5643
5464
  maxHp,
5644
5465
  ratio: typeof hp === "number" && typeof maxHp === "number" && maxHp !== 0 ? hp / maxHp : null,
5466
+ barWidth: (record.q28 ?? 10) / 5,
5467
+ barOffsetY: (record.q32 ?? 10) / 10,
5645
5468
  state: cloneRecord(record)
5646
5469
  };
5647
5470
  }
@@ -5964,6 +5787,7 @@
5964
5787
  return {
5965
5788
  entity,
5966
5789
  ...itemSummary(itemId, count),
5790
+ boxSprite: Boolean(itemRecord?.q29),
5967
5791
  width: sizeRecord.q20 ?? null,
5968
5792
  height: sizeRecord.q24 ?? null,
5969
5793
  itemState: cloneRecord(itemRecord || healthRecord || {}),
@@ -6129,15 +5953,17 @@
6129
5953
  if (!Number.isFinite(Number(value))) return null;
6130
5954
  return (Number(value) % 360 + 360) % 360;
6131
5955
  }
6132
- function summarizeItemLauncher(entity, typeId, launcherRecord) {
6133
- if (typeId !== ITEM_LAUNCHER_TYPE_ID || !launcherRecord) return null;
6134
- const angleRadians = numberOrNull(launcherRecord.q32 ?? 0, 200);
5956
+ function summarizeItemLauncher(entity, typeId, launcherRecord, configRecord = null) {
5957
+ if (typeId !== ITEM_LAUNCHER_TYPE_ID || !launcherRecord && !configRecord) return null;
5958
+ const angleRadians = configRecord ? (configRecord.q20 ?? 0) / 10 * Math.PI / 180 : numberOrNull(launcherRecord.q32 ?? 0, 200);
6135
5959
  return {
6136
5960
  entity,
6137
- angleRaw: launcherRecord.q32 ?? null,
5961
+ angleRaw: configRecord ? configRecord.q20 ?? 0 : launcherRecord.q32 ?? null,
6138
5962
  angleRadians,
6139
5963
  angleDegrees: angleRadians == null ? null : normalizeDegrees(angleRadians * 180 / Math.PI),
6140
- state: cloneRecord(launcherRecord)
5964
+ power: configRecord ? (configRecord.q24 ?? 300) / 10 : null,
5965
+ configState: configRecord ? cloneRecord(configRecord) : null,
5966
+ state: cloneRecord(launcherRecord || {})
6141
5967
  };
6142
5968
  }
6143
5969
  function summarizeSign(entity, signRecord) {
@@ -6158,23 +5984,28 @@
6158
5984
  state: cloneRecord(projectorRecord || {})
6159
5985
  };
6160
5986
  }
6161
- function summarizeSpawnPoint(entity, spawnRecord) {
6162
- const rank = Number.isFinite(Number(spawnRecord?.q20)) ? Number(spawnRecord.q20) : 0;
5987
+ function summarizeRankFilter(legacyRecord, filterRecord, modern = false) {
5988
+ const legacyRank = Number.isFinite(Number(legacyRecord?.q20)) ? Number(legacyRecord.q20) : 0;
5989
+ const rankMask = filterRecord ? (filterRecord.q20 ?? 4) >>> 0 : modern ? null : { 0: 7, 1: 6, 3: 4 }[legacyRank] ?? 0;
5990
+ return {
5991
+ rankMask,
5992
+ allowedRanks: rankMask == null ? null : ["guest", "crew", "captain"].filter((_, i) => rankMask & 1 << i),
5993
+ allRanks: rankMask === 4294967295,
5994
+ rankState: cloneRecord(filterRecord || legacyRecord || {})
5995
+ };
5996
+ }
5997
+ function summarizeSpawnPoint(entity, spawnRecord, filterRecord = null, markerRecord = null) {
6163
5998
  return {
6164
5999
  entity,
6165
- rank,
6166
- rankName: enumValueName(TEAM_RANK_NAMES, rank),
6167
- state: cloneRecord(spawnRecord || {})
6000
+ ...summarizeRankFilter(spawnRecord, filterRecord, markerRecord != null),
6001
+ state: cloneRecord(markerRecord || spawnRecord || {})
6168
6002
  };
6169
6003
  }
6170
- function summarizeDoor(entity, rankRecord, doorRecord) {
6171
- const rank = Number.isFinite(Number(rankRecord?.q20)) ? Number(rankRecord.q20) : 0;
6004
+ function summarizeDoor(entity, rankRecord, doorRecord, filterRecord = null) {
6172
6005
  return {
6173
6006
  entity,
6174
- rank,
6175
- rankName: enumValueName(TEAM_RANK_NAMES, rank),
6007
+ ...summarizeRankFilter(rankRecord, filterRecord),
6176
6008
  open: doorRecord?.q21 === 1,
6177
- rankState: cloneRecord(rankRecord || {}),
6178
6009
  state: cloneRecord(doorRecord || {})
6179
6010
  };
6180
6011
  }
@@ -6686,9 +6517,9 @@
6686
6517
  if (reader.trailingZeroOnly()) break;
6687
6518
  throw new Error(`unsupported model_data section tag ${tag}`);
6688
6519
  }
6689
- const section = this.#readSection(reader, tag, tableId);
6690
- update.sections.push(section);
6691
- for (const record of section.records) update.changedEntities.add(record.entity);
6520
+ const section2 = this.#readSection(reader, tag, tableId);
6521
+ update.sections.push(section2);
6522
+ for (const record of section2.records) update.changedEntities.add(record.entity);
6692
6523
  }
6693
6524
  } catch (error) {
6694
6525
  update.error = error;
@@ -6827,10 +6658,10 @@
6827
6658
  #updateDerived(update) {
6828
6659
  if (!this._derived) return;
6829
6660
  if (!update.removals.length && !update.changedEntities.size) return;
6830
- for (const section of update.sections) {
6831
- for (const record of section.records || []) this.#addDerivedEntityTable(record.entity, section.table);
6661
+ for (const section2 of update.sections) {
6662
+ for (const record of section2.records || []) this.#addDerivedEntityTable(record.entity, section2.table);
6832
6663
  }
6833
- if (update.sections.some((section) => section.table === 12)) {
6664
+ if (update.sections.some((section2) => section2.table === 12)) {
6834
6665
  for (const entityId of this.table(55).keys()) update.changedEntities.add(entityId);
6835
6666
  }
6836
6667
  for (const entityId of update.removals) this.#removeDerivedEntity(entityId);
@@ -6841,9 +6672,9 @@
6841
6672
  #updateNavigationUnitAutoWarp(update) {
6842
6673
  const trackedBeforeUpdate = new Set(this.#navigationUnitAutoWarp.keys());
6843
6674
  const initializedThisUpdate = /* @__PURE__ */ new Set();
6844
- for (const section of update.sections || []) {
6845
- if (section.table !== 78) continue;
6846
- for (const changed of section.records || []) {
6675
+ for (const section2 of update.sections || []) {
6676
+ if (section2.table !== 78) continue;
6677
+ for (const changed of section2.records || []) {
6847
6678
  const typeId = entityTypeIdFromRecord2(this.record(7, changed.entity));
6848
6679
  if (typeId !== NAVIGATION_UNIT_TYPE_ID2) continue;
6849
6680
  const record = this.record(78, changed.entity);
@@ -6906,12 +6737,12 @@
6906
6737
  }
6907
6738
  }
6908
6739
  #updateHelmOccupancy(update) {
6909
- const table7 = update.sections.find((section) => section.table === 7);
6740
+ const table7 = update.sections.find((section2) => section2.table === 7);
6910
6741
  if (!table7) return;
6911
6742
  const changedZoomState = /* @__PURE__ */ new Map();
6912
- for (const section of update.sections) {
6913
- if (section.table !== 55) continue;
6914
- for (const changed of section.records) {
6743
+ for (const section2 of update.sections) {
6744
+ if (section2.table !== 55) continue;
6745
+ for (const changed of section2.records) {
6915
6746
  if (!(changed.mask & 16)) continue;
6916
6747
  const player = this.record(55, changed.entity);
6917
6748
  changedZoomState.set(changed.entity, Boolean(player?.q107));
@@ -6930,7 +6761,7 @@
6930
6761
  }
6931
6762
  }
6932
6763
  #updateCommsStationOccupancy(update) {
6933
- const table7 = update.sections.find((section) => section.table === 7);
6764
+ const table7 = update.sections.find((section2) => section2.table === 7);
6934
6765
  if (!table7) return;
6935
6766
  for (const changed of table7.records) {
6936
6767
  const record = this.record(7, changed.entity);
@@ -7256,7 +7087,7 @@
7256
7087
  const thruster = summarizeThruster2(entityId, typeId, thrusterRecord);
7257
7088
  const pusher = summarizePusher2(entityId, pusherRecord, loaderFilterSlotsRecord);
7258
7089
  const pusherBeam = summarizePusherBeam2(entityId, pusherBeamRecord);
7259
- const launcher = summarizeItemLauncher2(entityId, typeId, launcherRecord);
7090
+ const launcher = summarizeItemLauncher2(entityId, typeId, launcherRecord, rec(79));
7260
7091
  const loader = typeId === LOADER_TYPE_ID2 || typeId == null && (loaderRecord || loaderFilterRecord || loaderFilterSlotsRecord) ? summarizeLoader2(entityId, loaderRecord, loaderFilterRecord, loaderFilterSlotsRecord, typeId === LOADER_TYPE_ID2, itemHolderRecord) : null;
7261
7092
  const cargoHatch = summarizeCargoHatch2(entityId, typeId, loaderFilterRecord, loaderFilterSlotsRecord, rec(45));
7262
7093
  const navigationUnit = summarizeNavigationUnit2(entityId, typeId, navigationRecord, this.#navigationUnitAutoWarp.get(entityId));
@@ -7273,8 +7104,8 @@
7273
7104
  const helm = summarizeHelm2(entityId, typeId, this.#helmOccupied.get(entityId));
7274
7105
  const commsStation = summarizeCommsStation2(entityId, typeId, commsStationRecord, this.#commsStationOccupied.get(entityId));
7275
7106
  const sign = typeId === 218 ? summarizeSign2(entityId, signRecord) : null;
7276
- const spawnPoint = typeId === 219 ? summarizeSpawnPoint2(entityId, spawnPointRecord) : null;
7277
- const door = typeId === 220 ? summarizeDoor2(entityId, spawnPointRecord, doorRecord) : null;
7107
+ const spawnPoint = typeId === 219 || rec(81) ? summarizeSpawnPoint2(entityId, spawnPointRecord, rec(80), rec(81)) : null;
7108
+ const door = typeId === 220 ? summarizeDoor2(entityId, spawnPointRecord, doorRecord, rec(80)) : null;
7278
7109
  const shipSize = shipControl && this.isOverworld ? summarizeShipSize2(entityId, rec(3)) : null;
7279
7110
  const hoverOutline = summarizeHoverOutline2(entityId, crateSizeRecord);
7280
7111
  const expandoBox = isExpandoBox ? summarizeExpandoBox2(entityId, itemHolderRecord, expandoSizeRecord) : null;
@@ -7532,7 +7363,8 @@
7532
7363
  return this.#readSectionRecords(reader, tag, tableId, spec);
7533
7364
  }
7534
7365
  #readSectionRecords(reader, tag, tableId, spec) {
7535
- const section = { tag, table: tableId, name: spec?.name || null, records: [] };
7366
+ const section2 = { tag, table: tableId, name: spec?.name || null, records: [] };
7367
+ let records = this.tables.get(tableId);
7536
7368
  let entity = 0;
7537
7369
  while (reader.remaining > 0) {
7538
7370
  const recordOffset = reader.offset;
@@ -7550,7 +7382,9 @@
7550
7382
  } catch (error) {
7551
7383
  throw new Error(`model table ${tableId} tag ${tag} entity ${entity} mask offset ${reader.offset}: ${error.message}`);
7552
7384
  }
7553
- const record = this.#getRecord(tableId, entity);
7385
+ if (!records) this.tables.set(tableId, records = /* @__PURE__ */ new Map());
7386
+ let record = records.get(entity);
7387
+ if (!record) records.set(entity, record = { ...spec?.defaults });
7554
7388
  record.lastMask = mask;
7555
7389
  try {
7556
7390
  if (spec) this.#applyRecordSpec(reader, record, mask, spec);
@@ -7559,15 +7393,9 @@
7559
7393
  throw new Error(`model table ${tableId} tag ${tag} entity ${entity} mask ${mask} offset ${reader.offset}: ${error.message}`);
7560
7394
  }
7561
7395
  const changed = { entity, mask };
7562
- section.records.push(changed);
7396
+ section2.records.push(changed);
7563
7397
  }
7564
- return section;
7565
- }
7566
- #getRecord(tableId, entity) {
7567
- if (!this.tables.has(tableId)) this.tables.set(tableId, /* @__PURE__ */ new Map());
7568
- const records = this.tables.get(tableId);
7569
- if (!records.has(entity)) records.set(entity, { ...MODEL_TABLE_SPECS2.get(tableId)?.defaults });
7570
- return records.get(entity);
7398
+ return section2;
7571
7399
  }
7572
7400
  #applyRecordSpec(reader, record, mask, spec) {
7573
7401
  if (typeof spec.read === "function") {
@@ -7617,11 +7445,11 @@
7617
7445
  removals: update.removals.length,
7618
7446
  unknownTags: update.unknownTags,
7619
7447
  error: update.error?.message || null,
7620
- sections: update.sections.map((section) => ({
7621
- tag: section.tag,
7622
- table: section.table,
7623
- name: section.name,
7624
- records: section.records.length
7448
+ sections: update.sections.map((section2) => ({
7449
+ tag: section2.tag,
7450
+ table: section2.table,
7451
+ name: section2.name,
7452
+ records: section2.records.length
7625
7453
  }))
7626
7454
  };
7627
7455
  }
@@ -8299,12 +8127,44 @@
8299
8127
 
8300
8128
  // src/protocol/outbound/chat.js
8301
8129
  var CHAT_MESSAGE_TYPE = 2;
8302
- function buildChatMessage(message = "") {
8130
+ function buildChatMessage(message2 = "") {
8303
8131
  return {
8304
8132
  type: CHAT_MESSAGE_TYPE,
8305
- msg: String(message)
8133
+ msg: String(message2)
8134
+ };
8135
+ }
8136
+
8137
+ // src/protocol/outbound/comms.js
8138
+ var COMMS_MESSAGE_TYPE = 3;
8139
+ function buildCommsMessage(message2 = "") {
8140
+ return {
8141
+ type: COMMS_MESSAGE_TYPE,
8142
+ msg: String(message2)
8143
+ };
8144
+ }
8145
+ function normalizeCommsEvent(event) {
8146
+ const rawMessages = Array.isArray(event?.msgs_text) ? event.msgs_text : [];
8147
+ return {
8148
+ ...event,
8149
+ entity: event?.ent_id != null && Number.isFinite(Number(event.ent_id)) ? Number(event.ent_id) : null,
8150
+ rawMessages,
8151
+ messages: rawMessages.map((message2) => ({
8152
+ raw: message2,
8153
+ text: flattenRichText(message2)
8154
+ }))
8306
8155
  };
8307
8156
  }
8157
+ function flattenRichText(value) {
8158
+ if (value == null) return "";
8159
+ if (typeof value === "string") return value;
8160
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
8161
+ if (Array.isArray(value)) return value.map(flattenRichText).join("");
8162
+ if (typeof value === "object") {
8163
+ if (Object.hasOwn(value, "c")) return flattenRichText(value.c);
8164
+ if (Object.hasOwn(value, "text")) return flattenRichText(value.text);
8165
+ }
8166
+ return "";
8167
+ }
8308
8168
 
8309
8169
  // src/protocol/outbound/commands.js
8310
8170
  init_constants();
@@ -8525,81 +8385,324 @@
8525
8385
  if (!EQUIPMENT_SLOT_NAMES.has(normalized)) {
8526
8386
  throw new RangeError(`equipment slot must be an EquipmentSlot value`);
8527
8387
  }
8528
- return normalized;
8388
+ return normalized;
8389
+ }
8390
+ function equipmentSlotName(slot) {
8391
+ return EQUIPMENT_SLOT_NAMES.get(Number(slot)) ?? null;
8392
+ }
8393
+ function buildInventoryDragCommand(source, target, split = false) {
8394
+ return {
8395
+ drag: {
8396
+ source: normalizeInventoryIndex(source, "source"),
8397
+ target: normalizeInventoryIndex(target, "target"),
8398
+ split: Boolean(split)
8399
+ }
8400
+ };
8401
+ }
8402
+ function normalizeInventoryEvent(event) {
8403
+ const items = Array.isArray(event?.items) ? event.items : [];
8404
+ const counts = Array.isArray(event?.item_counts) ? event.item_counts : [];
8405
+ const rawHotbarSize = Number(event?.general_slots ?? 0);
8406
+ const hotbarSize = Number.isFinite(rawHotbarSize) && rawHotbarSize > 0 ? Math.trunc(rawHotbarSize) : 0;
8407
+ const slotSnapshot = (index, kind) => {
8408
+ const count = normalizeCount(counts[index]);
8409
+ const itemId = normalizeItemId(items[index], count);
8410
+ return {
8411
+ index,
8412
+ itemId,
8413
+ itemName: itemNameFromId(itemId),
8414
+ count,
8415
+ kind,
8416
+ equipmentSlot: equipmentSlotName(index),
8417
+ empty: itemId == null || count <= 0
8418
+ };
8419
+ };
8420
+ const slotsByIndex = /* @__PURE__ */ new Map();
8421
+ for (let index = 0; index < hotbarSize; index++) {
8422
+ slotsByIndex.set(index, slotSnapshot(index, "hotbar"));
8423
+ }
8424
+ slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.head, slotSnapshot(EQUIPMENT_SLOT_INDEXES.head, "equipment"));
8425
+ slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.face, slotSnapshot(EQUIPMENT_SLOT_INDEXES.face, "equipment"));
8426
+ slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.body, slotSnapshot(EQUIPMENT_SLOT_INDEXES.body, "equipment"));
8427
+ slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.back, slotSnapshot(EQUIPMENT_SLOT_INDEXES.back, "equipment"));
8428
+ slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.hands, slotSnapshot(EQUIPMENT_SLOT_INDEXES.hands, "equipment"));
8429
+ slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.feet, slotSnapshot(EQUIPMENT_SLOT_INDEXES.feet, "equipment"));
8430
+ const slots = [...slotsByIndex.values()].sort((a, b) => a.index - b.index);
8431
+ const hotbar = slots.filter((slot) => slot.kind === "hotbar");
8432
+ const equipment = {
8433
+ head: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.head),
8434
+ face: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.face),
8435
+ body: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.body),
8436
+ back: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.back),
8437
+ hands: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.hands),
8438
+ feet: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.feet)
8439
+ };
8440
+ return {
8441
+ type: "inventory",
8442
+ filter: event?.filter,
8443
+ hotbarSize,
8444
+ slots,
8445
+ hotbar,
8446
+ equipment
8447
+ };
8448
+ }
8449
+ function normalizeInventoryIndex(value, name) {
8450
+ const number = Number(value);
8451
+ if (!Number.isInteger(number) || number < 0) throw new RangeError(`${name} must be a non-negative integer inventory slot`);
8452
+ return number;
8453
+ }
8454
+ function normalizeCount(value) {
8455
+ const number = Number(value ?? 0);
8456
+ return Number.isFinite(number) ? number : 0;
8457
+ }
8458
+ function normalizeItemId(value, count) {
8459
+ if (value == null) return null;
8460
+ const number = Number(value);
8461
+ if (!Number.isFinite(number)) return null;
8462
+ return number === 0 && count === 0 ? null : number;
8463
+ }
8464
+
8465
+ // src/protocol/outbound/ship-management.js
8466
+ var SHIP_MANAGEMENT_TYPE = 4;
8467
+ var CREW_LOG_LENGTH = 500;
8468
+ var SET_PRIVACY_ACTION = "set_privacy";
8469
+ var GRAVITY_ACTION = "gravity";
8470
+ var SET_PATRON_PERKS_ACTION = "set_patron_perks";
8471
+ var STARTER_RECOVERY_ACTION = "starter_recovery";
8472
+ var PLAYER_LIST_ACTION = "player_list";
8473
+ var INVITE_RESET_ACTION = "invite_reset";
8474
+ var SET_RANK_ACTION = "set_rank";
8475
+ var KICK_ACTION = "kick";
8476
+ var BAN_ACTION = "ban";
8477
+ var UNBAN_ACTION = "unban";
8478
+ var DEMOTE_SELF_ACTION = "demote_self";
8479
+ var SAVE_SHIP_ACTION = "save_team";
8480
+ var RENAME_REQUEST_ACTION = "rename_request";
8481
+ var RENAME_COMMIT_ACTION = "rename_commit";
8482
+ var GravityDirection = Object.freeze({
8483
+ Down: "down",
8484
+ Up: "up",
8485
+ Left: "left",
8486
+ Right: "right"
8487
+ });
8488
+ function normalizeGravityDirection(value) {
8489
+ if (value === GravityDirection.Down || value === 0) return 0;
8490
+ if (value === GravityDirection.Up || value === 1) return 1;
8491
+ if (value === GravityDirection.Left || value === 2) return 2;
8492
+ if (value === GravityDirection.Right || value === 3) return 3;
8493
+ throw new RangeError('direction must be "down", "up", "left", "right", or an integer from 0 to 3');
8494
+ }
8495
+ function requireNonNegativeInteger(value, name) {
8496
+ const number = Number(value);
8497
+ if (!Number.isInteger(number) || number < 0) throw new RangeError(`${name} must be a non-negative integer`);
8498
+ return number;
8499
+ }
8500
+ function normalizePrivacy(value) {
8501
+ if (value === true || value === 1 || value === "private") return 1;
8502
+ if (value === false || value === 0 || value === "public") return 0;
8503
+ throw new RangeError(`privacy must be 0, 1, true, false, "public", or "private"`);
8504
+ }
8505
+ function normalizePlayerRef(value) {
8506
+ return requireNonNegativeInteger(value, "refId");
8507
+ }
8508
+ function normalizePlayerRank(value) {
8509
+ if (value === 0 || value === "guest") return 0;
8510
+ if (value === 1 || value === "crew") return 1;
8511
+ if (value === 3 || value === "captain") return 3;
8512
+ throw new RangeError(`rank must be 0, 1, 3, "guest", "crew", or "captain"`);
8513
+ }
8514
+ function buildShipManagementMessage(act, arg = null, extra = null) {
8515
+ if (typeof act !== "string" || !act) throw new TypeError(`act must be a non-empty string`);
8516
+ const message2 = { type: SHIP_MANAGEMENT_TYPE, act, arg };
8517
+ if (extra && typeof extra === "object") Object.assign(message2, extra);
8518
+ return message2;
8519
+ }
8520
+ function buildShipPrivacyMessage(privacy) {
8521
+ return buildShipManagementMessage(SET_PRIVACY_ACTION, normalizePrivacy(privacy));
8522
+ }
8523
+ function buildShipGravityMessage(direction) {
8524
+ return buildShipManagementMessage(GRAVITY_ACTION, normalizeGravityDirection(direction));
8525
+ }
8526
+ function buildSetPatronPerksMessage(enabled) {
8527
+ if (typeof enabled !== "boolean") throw new TypeError("enabled must be a boolean");
8528
+ return buildShipManagementMessage(SET_PATRON_PERKS_ACTION, enabled);
8529
+ }
8530
+ function buildStarterRecoveryMessage(itemId) {
8531
+ return buildShipManagementMessage(STARTER_RECOVERY_ACTION, requireNonNegativeInteger(itemId, "itemId"));
8532
+ }
8533
+ function buildPlayerListMessage() {
8534
+ return buildShipManagementMessage(PLAYER_LIST_ACTION);
8535
+ }
8536
+ function buildInviteResetMessage() {
8537
+ return buildShipManagementMessage(INVITE_RESET_ACTION);
8538
+ }
8539
+ function buildSetPlayerRankMessage(refId, rank) {
8540
+ return buildShipManagementMessage(SET_RANK_ACTION, normalizePlayerRef(refId), { rank: normalizePlayerRank(rank) });
8541
+ }
8542
+ function buildKickPlayerMessage(refId) {
8543
+ return buildShipManagementMessage(KICK_ACTION, normalizePlayerRef(refId));
8544
+ }
8545
+ function buildBanPlayerMessage(refId) {
8546
+ return buildShipManagementMessage(BAN_ACTION, normalizePlayerRef(refId));
8547
+ }
8548
+ function buildUnbanPlayerMessage(refId) {
8549
+ return buildShipManagementMessage(UNBAN_ACTION, normalizePlayerRef(refId));
8550
+ }
8551
+ function buildDemoteSelfMessage() {
8552
+ return buildShipManagementMessage(DEMOTE_SELF_ACTION);
8553
+ }
8554
+ function buildSaveShipMessage() {
8555
+ return buildShipManagementMessage(SAVE_SHIP_ACTION);
8556
+ }
8557
+ function buildShipRenameRequestMessage() {
8558
+ return buildShipManagementMessage(RENAME_REQUEST_ACTION);
8559
+ }
8560
+ function buildShipRenameCommitMessage(name, color) {
8561
+ if (typeof name !== "string") throw new TypeError("name must be a string");
8562
+ if (name.length > 32) throw new RangeError("name must be at most 32 UTF-16 code units");
8563
+ if (typeof color !== "string" || !/^#[0-9a-f]{6}$/i.test(color)) {
8564
+ throw new TypeError("color must be a #RRGGBB hex string");
8565
+ }
8566
+ return buildShipManagementMessage(RENAME_COMMIT_ACTION, name, { arg2: color });
8529
8567
  }
8530
- function equipmentSlotName(slot) {
8531
- return EQUIPMENT_SLOT_NAMES.get(Number(slot)) ?? null;
8568
+ function normalizeShipConfig(event = {}) {
8569
+ const source = event && typeof event === "object" ? event : {};
8570
+ const config = source.config && typeof source.config === "object" ? source.config : {};
8571
+ return {
8572
+ privacy: config.privacy ?? null,
8573
+ privacyName: config.privacy === 0 ? "public" : config.privacy === 1 ? "private" : null,
8574
+ inviteKey: config.invite_key ?? null,
8575
+ teamId: source.team_id ?? null,
8576
+ patronPerks: Array.isArray(source.patron_perks) ? source.patron_perks.slice() : []
8577
+ };
8532
8578
  }
8533
- function buildInventoryDragCommand(source, target, split = false) {
8579
+ function normalizeCaptainSubrank(event = {}) {
8580
+ const source = event && typeof event === "object" ? event : {};
8534
8581
  return {
8535
- drag: {
8536
- source: normalizeInventoryIndex(source, "source"),
8537
- target: normalizeInventoryIndex(target, "target"),
8538
- split: Boolean(split)
8539
- }
8582
+ subrank: source.subrank ?? null,
8583
+ enableCheats: Boolean(source.enable_cheats)
8540
8584
  };
8541
8585
  }
8542
- function normalizeInventoryEvent(event) {
8543
- const items = Array.isArray(event?.items) ? event.items : [];
8544
- const counts = Array.isArray(event?.item_counts) ? event.item_counts : [];
8545
- const rawHotbarSize = Number(event?.general_slots ?? 0);
8546
- const hotbarSize = Number.isFinite(rawHotbarSize) && rawHotbarSize > 0 ? Math.trunc(rawHotbarSize) : 0;
8547
- const slotSnapshot = (index, kind) => {
8548
- const count = normalizeCount(counts[index]);
8549
- const itemId = normalizeItemId(items[index], count);
8586
+ function normalizeCrewLog(event = {}, previous = null) {
8587
+ const source = event && typeof event === "object" ? event : {};
8588
+ const reset = Boolean(source.reset);
8589
+ const amend = Boolean(source.amend);
8590
+ const entries = reset ? [] : (previous?.entries || []).slice();
8591
+ if (amend) entries.pop();
8592
+ const changes = Array.isArray(source.entries) ? source.entries.map((entry) => {
8593
+ const value = entry && typeof entry === "object" ? entry : {};
8550
8594
  return {
8551
- index,
8552
- itemId,
8553
- itemName: itemNameFromId(itemId),
8554
- count,
8555
- kind,
8556
- equipmentSlot: equipmentSlotName(index),
8557
- empty: itemId == null || count <= 0
8595
+ icon: value.icon ?? null,
8596
+ text: flattenRichText(value.text),
8597
+ rawText: value.text ?? null,
8598
+ count: value.count ?? 1,
8599
+ refId: value.ref ?? null,
8600
+ secondaryRefId: value.ref2 ?? null
8558
8601
  };
8602
+ }) : [];
8603
+ for (const entry of changes) entries.push(entry);
8604
+ if (entries.length > CREW_LOG_LENGTH) entries.splice(0, entries.length - CREW_LOG_LENGTH);
8605
+ return { entries, changes, reset, amend };
8606
+ }
8607
+ function normalizeShipPlayerList(event = {}, previous = null, currentCaptainSubrank = null) {
8608
+ const source = event && typeof event === "object" ? event : {};
8609
+ const changes = Array.isArray(source.player_list) ? source.player_list.map(normalizePlayerListChange) : [];
8610
+ const removedPlayers = changes.filter((change) => change.remove && Number.isFinite(Number(change.refId))).map((change) => Number(change.refId));
8611
+ const changedPlayers = changes.filter((change) => !change.remove).map(({ remove: _remove, ...change }) => change);
8612
+ const players = mergePlayerListChanges(previous?.players, changes);
8613
+ const ownerCaptainRank = ownerRankForPlayers(players);
8614
+ applyPlayerControlState(players, currentCaptainSubrank);
8615
+ applyPlayerControlState(changedPlayers, currentCaptainSubrank);
8616
+ return {
8617
+ ownerCaptainRank,
8618
+ shipOwners: players.filter((player) => player.isShipOwner),
8619
+ players,
8620
+ changes: changedPlayers,
8621
+ removedPlayers
8559
8622
  };
8560
- const slotsByIndex = /* @__PURE__ */ new Map();
8561
- for (let index = 0; index < hotbarSize; index++) {
8562
- slotsByIndex.set(index, slotSnapshot(index, "hotbar"));
8623
+ }
8624
+ function mergePlayerListChanges(previousPlayers, changes) {
8625
+ if (!Array.isArray(previousPlayers) || !previousPlayers.length) return changes.filter((change) => !change.remove).map(({
8626
+ remove: _remove,
8627
+ ...player
8628
+ }) => ({ ...player }));
8629
+ const existing = /* @__PURE__ */ new Map();
8630
+ for (const player of previousPlayers) {
8631
+ if (player?.refId == null) continue;
8632
+ existing.set(player.refId, { ...player, isShipOwner: false });
8563
8633
  }
8564
- slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.head, slotSnapshot(EQUIPMENT_SLOT_INDEXES.head, "equipment"));
8565
- slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.face, slotSnapshot(EQUIPMENT_SLOT_INDEXES.face, "equipment"));
8566
- slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.body, slotSnapshot(EQUIPMENT_SLOT_INDEXES.body, "equipment"));
8567
- slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.back, slotSnapshot(EQUIPMENT_SLOT_INDEXES.back, "equipment"));
8568
- slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.hands, slotSnapshot(EQUIPMENT_SLOT_INDEXES.hands, "equipment"));
8569
- slotsByIndex.set(EQUIPMENT_SLOT_INDEXES.feet, slotSnapshot(EQUIPMENT_SLOT_INDEXES.feet, "equipment"));
8570
- const slots = [...slotsByIndex.values()].sort((a, b) => a.index - b.index);
8571
- const hotbar = slots.filter((slot) => slot.kind === "hotbar");
8572
- const equipment = {
8573
- head: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.head),
8574
- face: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.face),
8575
- body: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.body),
8576
- back: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.back),
8577
- hands: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.hands),
8578
- feet: slotsByIndex.get(EQUIPMENT_SLOT_INDEXES.feet)
8579
- };
8634
+ const changedRefs = /* @__PURE__ */ new Set();
8635
+ const merged = [];
8636
+ for (const change of changes) {
8637
+ if (change.refId == null) {
8638
+ if (!change.remove) {
8639
+ const { remove: _remove2, ...player2 } = change;
8640
+ merged.push({ ...player2, isShipOwner: false });
8641
+ }
8642
+ continue;
8643
+ }
8644
+ changedRefs.add(change.refId);
8645
+ if (change.remove) {
8646
+ existing.delete(change.refId);
8647
+ continue;
8648
+ }
8649
+ const { remove: _remove, ...changePlayer } = change;
8650
+ const player = { ...existing.get(change.refId) || {}, ...changePlayer, isShipOwner: false };
8651
+ existing.set(change.refId, player);
8652
+ merged.push(player);
8653
+ }
8654
+ for (const player of previousPlayers) {
8655
+ if (player?.refId == null || changedRefs.has(player.refId)) continue;
8656
+ const retained = existing.get(player.refId);
8657
+ if (retained) merged.push(retained);
8658
+ }
8659
+ return merged;
8660
+ }
8661
+ function normalizePlayerListChange(entry = {}) {
8662
+ const source = entry && typeof entry === "object" ? entry : {};
8663
+ if (source._removed) return { refId: source.ref_id ?? null, remove: true };
8580
8664
  return {
8581
- type: "inventory",
8582
- filter: event?.filter,
8583
- hotbarSize,
8584
- slots,
8585
- hotbar,
8586
- equipment
8665
+ refId: source.ref_id ?? null,
8666
+ remove: false,
8667
+ discrim: source.discrim ?? null,
8668
+ discrimColor: source.discrim_color ?? null,
8669
+ teamRank: source.team_rank ?? null,
8670
+ captainRank: source.captain_rank ?? null,
8671
+ isCaptain: Number(source.captain_rank) > 0,
8672
+ isShipOwner: false,
8673
+ canBeManaged: false,
8674
+ time: source.time ?? null,
8675
+ items: Array.isArray(source.items) ? source.items.slice() : [],
8676
+ aliasDiscrims: Array.isArray(source.alias_discrims) ? source.alias_discrims.slice() : [],
8677
+ extraAliasCount: normalizeNonNegativeNumber(source.extra_aliases),
8678
+ onlineCount: source.online_count ?? null
8587
8679
  };
8588
8680
  }
8589
- function normalizeInventoryIndex(value, name) {
8681
+ function normalizeNonNegativeNumber(value) {
8590
8682
  const number = Number(value);
8591
- if (!Number.isInteger(number) || number < 0) throw new RangeError(`${name} must be a non-negative integer inventory slot`);
8592
- return number;
8683
+ return Number.isFinite(number) && number > 0 ? number : 0;
8593
8684
  }
8594
- function normalizeCount(value) {
8595
- const number = Number(value ?? 0);
8596
- return Number.isFinite(number) ? number : 0;
8685
+ function ownerRankForPlayers(players) {
8686
+ const ranks = players.filter((player) => Number(player.captainRank) > 0).map((player) => Number(player.captainRank)).filter(Number.isFinite);
8687
+ if (!ranks.length) return null;
8688
+ const ownerRank = Math.min(...ranks);
8689
+ for (const player of players) player.isShipOwner = Number(player.captainRank) === ownerRank;
8690
+ return ownerRank;
8597
8691
  }
8598
- function normalizeItemId(value, count) {
8599
- if (value == null) return null;
8600
- const number = Number(value);
8601
- if (!Number.isFinite(number)) return null;
8602
- return number === 0 && count === 0 ? null : number;
8692
+ function applyPlayerControlState(players, currentCaptainSubrank) {
8693
+ const currentRank = currentCaptainRank(currentCaptainSubrank);
8694
+ for (const player of players) player.canBeManaged = playerCanBeManagedBy(player, currentRank);
8695
+ }
8696
+ function currentCaptainRank(currentCaptainSubrank) {
8697
+ const rank = Number(currentCaptainSubrank?.subrank);
8698
+ return Number.isFinite(rank) && rank > 0 ? rank : null;
8699
+ }
8700
+ function playerCanBeManagedBy(player, currentRank) {
8701
+ if (!Number.isFinite(currentRank) || !player) return false;
8702
+ const targetCaptainRank = Number(player.captainRank);
8703
+ if (Number.isFinite(targetCaptainRank) && targetCaptainRank > 0) return currentRank < targetCaptainRank;
8704
+ const targetTeamRank = Number(player.teamRank);
8705
+ return targetTeamRank === 0 || targetTeamRank === 1;
8603
8706
  }
8604
8707
 
8605
8708
  // src/protocol/outbound/sign.js
@@ -8739,6 +8842,11 @@
8739
8842
  return number;
8740
8843
  }
8741
8844
  var CLIPBOARD_TARGET_VALUES = /* @__PURE__ */ new Map([
8845
+ ["launcher", 8],
8846
+ ["spawn", 9],
8847
+ ["spawn-point", 9],
8848
+ ["spawnPoint", 9],
8849
+ ["door", 10],
8742
8850
  ["loader", 1],
8743
8851
  ["loader-config", 1],
8744
8852
  ["loaderConfig", 1],
@@ -9185,11 +9293,11 @@
9185
9293
  send(command = {}) {
9186
9294
  return this.client.send(command);
9187
9295
  }
9188
- sendMessage(message, options = {}) {
9189
- return this.client.sendMessage(message, options);
9296
+ sendMessage(message2, options = {}) {
9297
+ return this.client.sendMessage(message2, options);
9190
9298
  }
9191
- sendRaw(message, options = {}) {
9192
- return this.client.sendRaw(message, options);
9299
+ sendRaw(message2, options = {}) {
9300
+ return this.client.sendRaw(message2, options);
9193
9301
  }
9194
9302
  sendEntityCommand(cmd, args = [-1, -1, -1]) {
9195
9303
  return this.client.sendEntityCommand(cmd, args);
@@ -9597,7 +9705,7 @@
9597
9705
  this.id = Number(data.entity ?? data.id);
9598
9706
  this.entity = this.id;
9599
9707
  this.position = data.transform || null;
9600
- this.rotation = data.transform?.rotation ?? null;
9708
+ this.rotation = data.transform?.rot ?? null;
9601
9709
  this.type = entityPublicType(data, this.#contents);
9602
9710
  this.features = Object.freeze(entityFeatures(data, this.#contents));
9603
9711
  deepFreeze(this.#contents);
@@ -10051,11 +10159,23 @@
10051
10159
  get state() {
10052
10160
  return summaryForEntity(this.client, this.scope, this.id)?.contents?.launcher || null;
10053
10161
  }
10054
- setAngle(angle) {
10055
- return this.client.setLauncherAngle(angle);
10162
+ configure(config = {}) {
10163
+ return this.client.sendLauncherConfig(this.id, config);
10164
+ }
10165
+ copy(config = {}) {
10166
+ return this.client.copyLauncherConfig(this.id, config);
10167
+ }
10168
+ paste(config = {}) {
10169
+ return this.client.pasteLauncherConfig(this.id, config);
10170
+ }
10171
+ setAngle(angle, config = {}) {
10172
+ return this.client.setLauncherAngle(this.id, angle, config);
10173
+ }
10174
+ setPower(power, config = {}) {
10175
+ return this.client.setLauncherPower(this.id, power, config);
10056
10176
  }
10057
- setPower(power) {
10058
- return this.client.setLauncherPower(power);
10177
+ get power() {
10178
+ return this.state?.power;
10059
10179
  }
10060
10180
  get angleDegrees() {
10061
10181
  return this.state?.angleDegrees;
@@ -10152,8 +10272,8 @@
10152
10272
  panel() {
10153
10273
  return this.client.commsPanels.get(this.id) || null;
10154
10274
  }
10155
- sendMessage(message = "") {
10156
- return this.client.sendCommsMessage(message);
10275
+ sendMessage(message2 = "") {
10276
+ return this.client.sendCommsMessage(message2);
10157
10277
  }
10158
10278
  };
10159
10279
  var SignHandle = class extends MachineHandle {
@@ -10220,28 +10340,58 @@
10220
10340
  }
10221
10341
  };
10222
10342
  var DoorHandle = class extends MachineHandle {
10223
- setRank(rank, options = {}) {
10224
- return this.client.tips.setRank(this, rank, options);
10343
+ configure(config = {}) {
10344
+ return this.client.sendDoorConfig(this.id, config);
10345
+ }
10346
+ copy(config = {}) {
10347
+ return this.client.copyDoorConfig(this.id, config);
10348
+ }
10349
+ paste(config = {}) {
10350
+ return this.client.pasteDoorConfig(this.id, config);
10351
+ }
10352
+ setAllowedRanks(allowedRanks) {
10353
+ return this.configure({ allowedRanks });
10354
+ }
10355
+ setRankMask(rankMask) {
10356
+ return this.configure({ rankMask });
10225
10357
  }
10226
10358
  get state() {
10227
10359
  return summaryForEntity(this.client, this.scope, this.id)?.contents?.door || null;
10228
10360
  }
10229
- get rank() {
10230
- return this.state?.rank;
10361
+ get rankMask() {
10362
+ return this.state?.rankMask;
10363
+ }
10364
+ get allowedRanks() {
10365
+ return this.state?.allowedRanks;
10231
10366
  }
10232
10367
  get open() {
10233
10368
  return this.state?.open;
10234
10369
  }
10235
10370
  };
10236
10371
  var SpawnPointHandle = class extends MachineHandle {
10237
- setRank(rank, options = {}) {
10238
- return this.client.tips.setRank(this, rank, options);
10372
+ configure(config = {}) {
10373
+ return this.client.sendSpawnPointConfig(this.id, config);
10374
+ }
10375
+ copy(config = {}) {
10376
+ return this.client.copySpawnPointConfig(this.id, config);
10377
+ }
10378
+ paste(config = {}) {
10379
+ return this.client.pasteSpawnPointConfig(this.id, config);
10380
+ }
10381
+ setAllowedRanks(allowedRanks) {
10382
+ return this.configure({ allowedRanks });
10383
+ }
10384
+ setRankMask(rankMask) {
10385
+ return this.configure({ rankMask });
10239
10386
  }
10240
10387
  get state() {
10241
10388
  return summaryForEntity(this.client, this.scope, this.id)?.contents?.spawnPoint || null;
10242
10389
  }
10243
- get rank() {
10244
- return this.state?.rank;
10390
+ get rankMask() {
10391
+ return this.state?.rankMask;
10392
+ }
10393
+ get allowedRanks() {
10394
+ return this.state?.allowedRanks;
10245
10395
  }
10246
10396
  };
10247
10397
  var ShieldProjectorHandle = class extends MachineHandle {
@@ -10635,18 +10785,6 @@
10635
10785
  if (!Number.isInteger(number) || number <= 0) throw new RangeError(`${name} must be a positive integer`);
10636
10786
  return number;
10637
10787
  }
10638
- function normalizeDegrees3(value) {
10639
- const number = Number(value);
10640
- if (!Number.isFinite(number)) throw new RangeError(`angle must be a finite number`);
10641
- return (Math.round(number) % 360 + 360) % 360;
10642
- }
10643
- function normalizeLauncherPower(value) {
10644
- const number = Number(value);
10645
- if (!Number.isInteger(number) || number < 0 || number > 30) {
10646
- throw new RangeError(`launcher power must be an integer between 0 and 30`);
10647
- }
10648
- return number;
10649
- }
10650
10788
  function normalizeScannerResultPacket(packet) {
10651
10789
  const manifest = packet?.manifest && typeof packet.manifest === "object" ? packet.manifest : {};
10652
10790
  const hasMaterials = manifest.materials && typeof manifest.materials === "object";
@@ -10866,18 +11004,18 @@
10866
11004
  this.emit("command", normalized);
10867
11005
  return this;
10868
11006
  }
10869
- sendMessage(message, { afterReady = true } = {}) {
11007
+ sendMessage(message2, { afterReady = true } = {}) {
10870
11008
  this.#assertWritable();
10871
11009
  if (!this.connected || afterReady && !this.ready) {
10872
- this.#queuedMessages.push({ message, afterReady });
11010
+ this.#queuedMessages.push({ message: message2, afterReady });
10873
11011
  return this;
10874
11012
  }
10875
- this.ws.send(encodeMsgpack(message));
10876
- this.emit("message", message);
11013
+ this.ws.send(encodeMsgpack(message2));
11014
+ this.emit("message", message2);
10877
11015
  return this;
10878
11016
  }
10879
- sendRaw(message, options = {}) {
10880
- return this.sendMessage(message, options);
11017
+ sendRaw(message2, options = {}) {
11018
+ return this.sendMessage(message2, options);
10881
11019
  }
10882
11020
  sendBlueprintPlacement(placement) {
10883
11021
  return this.sendMessage(buildBlueprintPlacementMessage(placement));
@@ -11005,7 +11143,7 @@
11005
11143
  }
11006
11144
  async recoverStarterItem(itemId, { timeout = 1e4 } = {}) {
11007
11145
  this.#assertWritable();
11008
- const message = buildStarterRecoveryMessage(itemId);
11146
+ const message2 = buildStarterRecoveryMessage(itemId);
11009
11147
  if (!Number.isFinite(timeout) || timeout <= 0 || timeout > 2147483647) {
11010
11148
  throw new RangeError("timeout must be positive milliseconds no greater than 2147483647");
11011
11149
  }
@@ -11043,7 +11181,7 @@
11043
11181
  this.on("disconnect", disconnected);
11044
11182
  this.on("demote", demoted);
11045
11183
  try {
11046
- this.sendMessage(message);
11184
+ this.sendMessage(message2);
11047
11185
  } catch (error) {
11048
11186
  cleanup();
11049
11187
  reject(error);
@@ -11077,7 +11215,7 @@
11077
11215
  async demoteSelf(options = {}) {
11078
11216
  await this.#awaitManagementConfirmation("Self-demotion", buildDemoteSelfMessage(), "demote", () => true, options);
11079
11217
  }
11080
- async #awaitManagementConfirmation(operation, message, event, accept, { timeout = 1e4 } = {}) {
11218
+ async #awaitManagementConfirmation(operation, message2, event, accept, { timeout = 1e4 } = {}) {
11081
11219
  this.#assertWritable();
11082
11220
  if (!Number.isFinite(timeout) || timeout <= 0 || timeout > 2147483647) {
11083
11221
  throw new RangeError("timeout must be positive milliseconds no greater than 2147483647");
@@ -11113,7 +11251,7 @@
11113
11251
  this.on("disconnect", disconnected);
11114
11252
  if (event !== "demote") this.on("demote", demoted);
11115
11253
  try {
11116
- this.sendMessage(message);
11254
+ this.sendMessage(message2);
11117
11255
  } catch (error) {
11118
11256
  fail(error);
11119
11257
  }
@@ -11125,11 +11263,11 @@
11125
11263
  sendEntityCommand(cmd, args = [-1, -1, -1]) {
11126
11264
  return this.sendMessage({ type: 5, cmd, args });
11127
11265
  }
11128
- sendChatMessage(message = "") {
11129
- return this.sendMessage(buildChatMessage(message));
11266
+ sendChatMessage(message2 = "") {
11267
+ return this.sendMessage(buildChatMessage(message2));
11130
11268
  }
11131
- sendCommsMessage(message = "") {
11132
- return this.sendMessage(buildCommsMessage(message));
11269
+ sendCommsMessage(message2 = "") {
11270
+ return this.sendMessage(buildCommsMessage(message2));
11133
11271
  }
11134
11272
  sendFabricatorMessage(cmd, args = [-1, -1, -1]) {
11135
11273
  return this.sendEntityCommand(cmd, args);
@@ -11158,11 +11296,38 @@
11158
11296
  fabricatorEject(row) {
11159
11297
  return this.sendFabricatorMessage("eject", [row, -1, -1]);
11160
11298
  }
11161
- setLauncherAngle(angle) {
11162
- return this.sendEntityCommand("angle", [normalizeDegrees3(angle)]);
11299
+ sendLauncherConfig(entity, config = {}) {
11300
+ return this.sendUiConfig(buildLauncherConfigData(entity, this.#launcherConfigDefaults(entity, config)));
11163
11301
  }
11164
- setLauncherPower(power) {
11165
- return this.sendEntityCommand("power", [normalizeLauncherPower(power)]);
11302
+ setLauncherAngle(entity, angle, config = {}) {
11303
+ return this.sendLauncherConfig(entity, { ...config, angle });
11304
+ }
11305
+ setLauncherPower(entity, power, config = {}) {
11306
+ return this.sendLauncherConfig(entity, { ...config, power });
11307
+ }
11308
+ copyLauncherConfig(entity, config = {}) {
11309
+ return this.sendUiConfig(buildLauncherCopyConfigData(this.#launcherConfigDefaults(entity, config)));
11310
+ }
11311
+ pasteLauncherConfig(entity, config = {}) {
11312
+ return this.sendUiConfig(buildLauncherPasteConfigData(entity, this.#launcherConfigDefaults(entity, config)));
11313
+ }
11314
+ sendDoorConfig(entity, config = {}) {
11315
+ return this.sendUiConfig(buildDoorConfigData(entity, this.#rankFilterConfigDefaults(entity, "door", config)));
11316
+ }
11317
+ copyDoorConfig(entity, config = {}) {
11318
+ return this.sendUiConfig(buildDoorCopyConfigData(this.#doorClipboardConfigDefaults(entity, config)));
11319
+ }
11320
+ pasteDoorConfig(entity, config = {}) {
11321
+ return this.sendUiConfig(buildDoorPasteConfigData(entity, this.#doorClipboardConfigDefaults(entity, config)));
11322
+ }
11323
+ sendSpawnPointConfig(entity, config = {}) {
11324
+ return this.sendUiConfig(buildSpawnPointConfigData(entity, this.#rankFilterConfigDefaults(entity, "spawnPoint", config)));
11325
+ }
11326
+ copySpawnPointConfig(entity, config = {}) {
11327
+ return this.sendUiConfig(buildSpawnPointCopyConfigData(this.#rankFilterConfigDefaults(entity, "spawnPoint", config)));
11328
+ }
11329
+ pasteSpawnPointConfig(entity, config = {}) {
11330
+ return this.sendUiConfig(buildSpawnPointPasteConfigData(entity, this.#rankFilterConfigDefaults(entity, "spawnPoint", config)));
11166
11331
  }
11167
11332
  setSignText(text2 = "", mode = 0) {
11168
11333
  return this.sendMessage(buildSignTextMessage(text2, mode));
@@ -11364,14 +11529,14 @@
11364
11529
  return this.useHeldItem(options, command);
11365
11530
  }
11366
11531
  placeBlueprint(placement, { invSlot = 0, hold = true, mx = null, my = null } = {}, command = {}) {
11367
- const message = buildBlueprintPlacementMessage(placement);
11368
- this.sendMessage(message);
11532
+ const message2 = buildBlueprintPlacementMessage(placement);
11533
+ this.sendMessage(message2);
11369
11534
  return this.placeHeldItem(
11370
11535
  { invSlot, hold },
11371
11536
  {
11372
11537
  ...command,
11373
- mx: mx ?? message.x,
11374
- my: my ?? message.y
11538
+ mx: mx ?? message2.x,
11539
+ my: my ?? message2.y
11375
11540
  }
11376
11541
  );
11377
11542
  }
@@ -11576,12 +11741,12 @@
11576
11741
  }
11577
11742
  #bindAttachedSocket() {
11578
11743
  const open = () => this.#attachedOpen();
11579
- const message = (event) => this.#handleSocketMessage(event?.data ?? event);
11744
+ const message2 = (event) => this.#handleSocketMessage(event?.data ?? event);
11580
11745
  const error = (event) => this.#fail(event?.error || new Error("WebSocket error"));
11581
11746
  const close = (event, reason) => this.#handleSocketClose(event, reason);
11582
11747
  if (typeof this.ws.addEventListener === "function") {
11583
11748
  this.ws.addEventListener("open", open);
11584
- this.ws.addEventListener("message", message);
11749
+ this.ws.addEventListener("message", message2);
11585
11750
  this.ws.addEventListener("error", error);
11586
11751
  this.ws.addEventListener("close", close);
11587
11752
  return;
@@ -11593,7 +11758,7 @@
11593
11758
  this.ws.on("close", close);
11594
11759
  return;
11595
11760
  }
11596
- for (const [type, handler] of Object.entries({ open, message, error, close })) {
11761
+ for (const [type, handler] of Object.entries({ open, message: message2, error, close })) {
11597
11762
  const previous = this.ws[`on${type}`];
11598
11763
  this.ws[`on${type}`] = (...args) => {
11599
11764
  if (typeof previous === "function") previous.apply(this.ws, args);
@@ -11906,6 +12071,25 @@
11906
12071
  autoWarpOnNoCaptains: config.autoWarpOnNoCaptains ?? summary?.autoWarpOnNoCaptains ?? false
11907
12072
  };
11908
12073
  }
12074
+ #launcherConfigDefaults(entity, config = {}) {
12075
+ const summary = this.worlds.shipWorld()?.entity(entity)?.contents?.launcher;
12076
+ return {
12077
+ angle: config.angle !== void 0 ? config.angle : summary?.angleDegrees ?? 0,
12078
+ power: config.power !== void 0 ? config.power : summary?.power ?? 30
12079
+ };
12080
+ }
12081
+ #rankFilterConfigDefaults(entity, kind, config = {}) {
12082
+ if (config.allowedRanks !== void 0 || config.rankMask !== void 0) return { ...config };
12083
+ const summary = this.worlds.shipWorld()?.entity(entity)?.contents?.[kind];
12084
+ return { ...config, rankMask: summary?.rankMask ?? 4 };
12085
+ }
12086
+ #doorClipboardConfigDefaults(entity, config = {}) {
12087
+ const angle = this.entity(entity)?.transform?.rot ?? 0;
12088
+ return {
12089
+ ...this.#rankFilterConfigDefaults(entity, "door", config),
12090
+ orientation: config.orientation ?? (Math.abs(Math.round(angle / (Math.PI / 2))) % 2 ? "horizontal" : "vertical")
12091
+ };
12092
+ }
11909
12093
  #pusherConfigDefaults(entity, config = {}) {
11910
12094
  const summary = this.entity(entity)?.contents?.pusher || null;
11911
12095
  return {