quake2ts 0.0.503 → 0.0.505

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.
@@ -36,7 +36,8 @@ __export(index_exports, {
36
36
  createSession: () => createSession,
37
37
  interpolatePredictionState: () => import_cgame5.interpolatePredictionState,
38
38
  normalizeCommand: () => normalizeCommand,
39
- normalizeInputCode: () => normalizeInputCode
39
+ normalizeInputCode: () => normalizeInputCode,
40
+ queryMasterServer: () => queryMasterServer
40
41
  });
41
42
  module.exports = __toCommonJS(index_exports);
42
43
 
@@ -15858,6 +15859,41 @@ function createSession(options) {
15858
15859
  return new GameSession(options);
15859
15860
  }
15860
15861
 
15862
+ // src/net/master.ts
15863
+ async function queryMasterServer(masterUrl) {
15864
+ try {
15865
+ const response = await fetch(masterUrl);
15866
+ if (!response.ok) {
15867
+ throw new Error(`Master server request failed: ${response.status} ${response.statusText}`);
15868
+ }
15869
+ const data = await response.json();
15870
+ if (!Array.isArray(data)) {
15871
+ throw new Error("Invalid master server response: expected array");
15872
+ }
15873
+ return data.map((entry) => {
15874
+ const address = entry.address || entry.ip + ":" + entry.port;
15875
+ const info = entry.info || {};
15876
+ let wsAddress = address;
15877
+ if (!address.startsWith("ws://") && !address.startsWith("wss://")) {
15878
+ wsAddress = `ws://${address}`;
15879
+ }
15880
+ return {
15881
+ name: info.hostname || entry.name || address,
15882
+ address: wsAddress,
15883
+ map: info.mapname || entry.map || "unknown",
15884
+ players: parseInt(info.clients || entry.players || "0", 10),
15885
+ maxPlayers: parseInt(info.maxclients || entry.maxPlayers || "0", 10),
15886
+ gamemode: info.gamename || entry.gamemode || "baseq2",
15887
+ ping: void 0
15888
+ // Ping is client-side latency, not server reported usually
15889
+ };
15890
+ });
15891
+ } catch (error) {
15892
+ console.error("Failed to query master server:", error);
15893
+ return [];
15894
+ }
15895
+ }
15896
+
15861
15897
  // src/index.ts
15862
15898
  var ZERO_VEC32 = { x: 0, y: 0, z: 0 };
15863
15899
  var ClientMode = /* @__PURE__ */ ((ClientMode2) => {
@@ -16828,7 +16864,8 @@ function createClient(imports) {
16828
16864
  createSession,
16829
16865
  interpolatePredictionState,
16830
16866
  normalizeCommand,
16831
- normalizeInputCode
16867
+ normalizeInputCode,
16868
+ queryMasterServer
16832
16869
  });
16833
16870
  /*! Bundled license information:
16834
16871