dredless 1.5.0 → 1.5.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.
@@ -79,8 +79,11 @@ client.management.canSave(): boolean;
79
79
  client.management.save(options?: {timeout?: number}): Promise<DisconnectInfo>;
80
80
  ```
81
81
 
82
- `canSave()` requires a connected/ready client, a current ship with a known parent world, and parent `danger_level === 0`
83
- (Safe Zone). Missing or unsafe metadata returns `false`. Partial metadata updates retain the last known danger level. It does not check all server-side permission rules.
82
+ `canSave()` requires a connected/ready client and a current ship with a parent-world ID.
83
+ It permits attempts when the parent's `danger_level` is `0` or unknown (including missing parent metadata).
84
+ Mosaic (world `66`) is explicitly whitelisted regardless of its reported danger level. Other known unsafe
85
+ zones return `false`. Partial metadata updates retain the last known danger level.
86
+ This is permission to attempt a save, not a guarantee of success; server permissions still apply.
84
87
 
85
88
  **Fragment:** this saves the ship and ejects its players:
86
89
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dredless",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A fully-featured and from-scratch headless drednot.io client implementation written in pure js.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/certainhuman/dredless#readme",
@@ -117,6 +117,9 @@ function normalizeHistoryLimit(value, fallback) {
117
117
  return Math.floor(limit);
118
118
  }
119
119
 
120
+ // Mosaic accepts save attempts independently of its reported danger level.
121
+ const SAVE_ALLOWED_PARENT_WORLD_IDS = new Set([66]);
122
+
120
123
  export class DredlessClient extends EventBus {
121
124
  constructor(connection, {
122
125
  connect = true,
@@ -273,8 +276,12 @@ export class DredlessClient extends EventBus {
273
276
  if (!this.connected || !this.ready) return false;
274
277
  const ship = this.worlds.shipWorld();
275
278
  if (!ship || ship.isOverworld !== false || ship.parentWorld == null) return false;
276
- const parent = this.worlds.worlds.get(Number(ship.parentWorld));
277
- return parent?.meta?.danger_level === 0;
279
+ const parentId = Number(ship.parentWorld);
280
+ if (SAVE_ALLOWED_PARENT_WORLD_IDS.has(parentId)) return true;
281
+ const danger = this.worlds.worlds.get(parentId)?.meta?.danger_level;
282
+ // Missing metadata is not proof that saving is forbidden. The server
283
+ // remains authoritative, and saveShip waits for its Saved close code.
284
+ return danger == null || danger === 0;
278
285
  }
279
286
 
280
287
  async saveShip({timeout = 10000} = {}) {
@@ -283,7 +290,7 @@ export class DredlessClient extends EventBus {
283
290
  throw new RangeError("timeout must be positive milliseconds no greater than 2147483647");
284
291
  }
285
292
  if (this.#savePending) throw new Error("A ship save is already in progress");
286
- if (!this.canSaveShip()) throw new Error("Saving requires a connected, ready client with its ship in a known Safe Zone");
293
+ if (!this.canSaveShip()) throw new Error("Saving requires a connected, ready client with a current ship outside a known unsafe zone (Mosaic is allowed)");
287
294
  this.#savePending = true;
288
295
  try {
289
296
  return await new Promise((resolve, reject) => {
package/src/index.d.ts CHANGED
@@ -697,7 +697,7 @@ export class DredlessClient {
697
697
  disconnect(code?: number, reason?: string): this;
698
698
  sendChatMessage(message?: string): this;
699
699
  sendCommsMessage(message?: string): this;
700
- /** Whether the connected, ready client's ship has parent-world danger level 0. */
700
+ /** Whether a connected, ready client may attempt saving: safe or unknown parent danger, or Mosaic (66). */
701
701
  canSaveShip(): boolean;
702
702
  /** Save and await the server's Saved close code; reject on ineligibility, timeout, or any other disconnect. */
703
703
  saveShip(options?: SaveShipOptions): Promise<DisconnectInfo>;
@@ -872,7 +872,7 @@ export interface PlayerDomain {
872
872
  }
873
873
 
874
874
  export interface ShipManagementDomain {
875
- /** Checks the current ship's parent-world danger level; server permissions still apply. */
875
+ /** Allows safe/unknown parent danger or Mosaic (66); requires a connected, ready client. Server confirmation still applies. */
876
876
  canSave(): boolean;
877
877
 
878
878
  /** Save and await the server's Saved close code; reject on ineligibility, timeout, or any other disconnect. */