dredless 0.5.0 → 0.5.2
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.
|
@@ -346,10 +346,10 @@
|
|
|
346
346
|
const resolved = await resolveServer(server2, baseUrl);
|
|
347
347
|
if (!resolved?.domain) throw new Error(`Unable to resolve server ${serverId(server2)}`);
|
|
348
348
|
const WebSocket2 = await getWebSocket();
|
|
349
|
-
const startedAt = Date.now();
|
|
350
349
|
const socket = new WebSocket2(`wss://${resolved.domain}:4000/`);
|
|
351
350
|
return new Promise((resolve, reject) => {
|
|
352
351
|
let settled = false;
|
|
352
|
+
let startedAt = 0;
|
|
353
353
|
const finish = (callback, value) => {
|
|
354
354
|
if (settled) return;
|
|
355
355
|
settled = true;
|
|
@@ -358,7 +358,10 @@
|
|
|
358
358
|
if (socket.readyState === 0 || socket.readyState === 1) socket.close();
|
|
359
359
|
};
|
|
360
360
|
const timeout = setTimeout(() => finish(reject, new Error(`Timed out fetching status for ${resolved.domain}`)), 1e4);
|
|
361
|
-
const onOpen = () =>
|
|
361
|
+
const onOpen = () => {
|
|
362
|
+
startedAt = Date.now();
|
|
363
|
+
socket.send("yo");
|
|
364
|
+
};
|
|
362
365
|
const onMessage = async (event) => {
|
|
363
366
|
try {
|
|
364
367
|
const data = JSON.parse(await websocketText(event?.data ?? event));
|
|
@@ -9475,7 +9478,7 @@
|
|
|
9475
9478
|
}
|
|
9476
9479
|
};
|
|
9477
9480
|
var ENTITY_SNAPSHOT_CACHE = /* @__PURE__ */ new WeakMap();
|
|
9478
|
-
function
|
|
9481
|
+
function entitySnapshotFor(summary) {
|
|
9479
9482
|
if (!summary || typeof summary !== "object") return null;
|
|
9480
9483
|
let snapshot = ENTITY_SNAPSHOT_CACHE.get(summary);
|
|
9481
9484
|
if (!snapshot) {
|
|
@@ -9532,7 +9535,7 @@
|
|
|
9532
9535
|
return summariesFor(this.client, this.scope).map((summary) => new EntityHandle(this.client, summary.entity, this.scope));
|
|
9533
9536
|
}
|
|
9534
9537
|
snapshots() {
|
|
9535
|
-
return summariesFor(this.client, this.scope).map(
|
|
9538
|
+
return summariesFor(this.client, this.scope).map(entitySnapshotFor);
|
|
9536
9539
|
}
|
|
9537
9540
|
states() {
|
|
9538
9541
|
return this.snapshots();
|
|
@@ -9715,7 +9718,7 @@
|
|
|
9715
9718
|
const summary = worldStateFor(this.client, this.scope)?.entity(this.id) || null;
|
|
9716
9719
|
if (summary !== this._cachedSummary) {
|
|
9717
9720
|
this._cachedSummary = summary;
|
|
9718
|
-
this._cachedSnapshot =
|
|
9721
|
+
this._cachedSnapshot = entitySnapshotFor(summary);
|
|
9719
9722
|
}
|
|
9720
9723
|
return this._cachedSnapshot;
|
|
9721
9724
|
}
|
|
@@ -10411,7 +10414,8 @@
|
|
|
10411
10414
|
function currentPlayerSummary(client, scope = "current") {
|
|
10412
10415
|
const sid = Number(client?.sid);
|
|
10413
10416
|
if (!Number.isFinite(sid)) return null;
|
|
10414
|
-
|
|
10417
|
+
const players = worldStateFor(client, scope)?.model.players() || [];
|
|
10418
|
+
return players.find((player) => player.state?.q109) || null;
|
|
10415
10419
|
}
|
|
10416
10420
|
function currentPlayerRank(client) {
|
|
10417
10421
|
const player = currentPlayerSummary(client);
|