quake2ts 0.0.503 → 0.0.504

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.
@@ -15825,6 +15825,41 @@ function createSession(options) {
15825
15825
  return new GameSession(options);
15826
15826
  }
15827
15827
 
15828
+ // src/net/master.ts
15829
+ async function queryMasterServer(masterUrl) {
15830
+ try {
15831
+ const response = await fetch(masterUrl);
15832
+ if (!response.ok) {
15833
+ throw new Error(`Master server request failed: ${response.status} ${response.statusText}`);
15834
+ }
15835
+ const data = await response.json();
15836
+ if (!Array.isArray(data)) {
15837
+ throw new Error("Invalid master server response: expected array");
15838
+ }
15839
+ return data.map((entry) => {
15840
+ const address = entry.address || entry.ip + ":" + entry.port;
15841
+ const info = entry.info || {};
15842
+ let wsAddress = address;
15843
+ if (!address.startsWith("ws://") && !address.startsWith("wss://")) {
15844
+ wsAddress = `ws://${address}`;
15845
+ }
15846
+ return {
15847
+ name: info.hostname || entry.name || address,
15848
+ address: wsAddress,
15849
+ map: info.mapname || entry.map || "unknown",
15850
+ players: parseInt(info.clients || entry.players || "0", 10),
15851
+ maxPlayers: parseInt(info.maxclients || entry.maxPlayers || "0", 10),
15852
+ gamemode: info.gamename || entry.gamemode || "baseq2",
15853
+ ping: void 0
15854
+ // Ping is client-side latency, not server reported usually
15855
+ };
15856
+ });
15857
+ } catch (error) {
15858
+ console.error("Failed to query master server:", error);
15859
+ return [];
15860
+ }
15861
+ }
15862
+
15828
15863
  // src/index.ts
15829
15864
  var ZERO_VEC32 = { x: 0, y: 0, z: 0 };
15830
15865
  var ClientMode = /* @__PURE__ */ ((ClientMode2) => {
@@ -16794,7 +16829,8 @@ export {
16794
16829
  createSession,
16795
16830
  interpolatePredictionState3 as interpolatePredictionState,
16796
16831
  normalizeCommand,
16797
- normalizeInputCode
16832
+ normalizeInputCode,
16833
+ queryMasterServer
16798
16834
  };
16799
16835
  /*! Bundled license information:
16800
16836