@realtimex/sdk 1.0.6 → 1.0.7

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.
package/dist/index.d.mts CHANGED
@@ -186,9 +186,13 @@ declare class PortModule {
186
186
  */
187
187
  getSuggestedPort(): number;
188
188
  /**
189
- * Check if a port is available
189
+ * Check if a port is available on a specific host
190
+ */
191
+ private isPortAvailableOn;
192
+ /**
193
+ * Check if a port is available (checks both IPv4 and IPv6)
190
194
  * @param port - Port number to check
191
- * @returns Promise resolving to true if port is available
195
+ * @returns Promise resolving to true if port is available on ALL interfaces
192
196
  */
193
197
  isPortAvailable(port: number): Promise<boolean>;
194
198
  /**
package/dist/index.d.ts CHANGED
@@ -186,9 +186,13 @@ declare class PortModule {
186
186
  */
187
187
  getSuggestedPort(): number;
188
188
  /**
189
- * Check if a port is available
189
+ * Check if a port is available on a specific host
190
+ */
191
+ private isPortAvailableOn;
192
+ /**
193
+ * Check if a port is available (checks both IPv4 and IPv6)
190
194
  * @param port - Port number to check
191
- * @returns Promise resolving to true if port is available
195
+ * @returns Promise resolving to true if port is available on ALL interfaces
192
196
  */
193
197
  isPortAvailable(port: number): Promise<boolean>;
194
198
  /**
package/dist/index.js CHANGED
@@ -258,11 +258,9 @@ var PortModule = class {
258
258
  return envPort ? parseInt(envPort, 10) : this.defaultPort;
259
259
  }
260
260
  /**
261
- * Check if a port is available
262
- * @param port - Port number to check
263
- * @returns Promise resolving to true if port is available
261
+ * Check if a port is available on a specific host
264
262
  */
265
- async isPortAvailable(port) {
263
+ async isPortAvailableOn(port, host) {
266
264
  return new Promise((resolve) => {
267
265
  const server = net.createServer();
268
266
  server.once("error", () => resolve(false));
@@ -270,9 +268,22 @@ var PortModule = class {
270
268
  server.close();
271
269
  resolve(true);
272
270
  });
273
- server.listen(port, "127.0.0.1");
271
+ server.listen(port, host);
274
272
  });
275
273
  }
274
+ /**
275
+ * Check if a port is available (checks both IPv4 and IPv6)
276
+ * @param port - Port number to check
277
+ * @returns Promise resolving to true if port is available on ALL interfaces
278
+ */
279
+ async isPortAvailable(port) {
280
+ const ipv4Available = await this.isPortAvailableOn(port, "127.0.0.1");
281
+ if (!ipv4Available) return false;
282
+ const ipv6Available = await this.isPortAvailableOn(port, "::1");
283
+ if (!ipv6Available) return false;
284
+ const allInterfacesAvailable = await this.isPortAvailableOn(port, "0.0.0.0");
285
+ return allInterfacesAvailable;
286
+ }
276
287
  /**
277
288
  * Find an available port starting from the suggested port
278
289
  * @param startPort - Starting port number (default: RTX_PORT or defaultPort)
package/dist/index.mjs CHANGED
@@ -217,11 +217,9 @@ var PortModule = class {
217
217
  return envPort ? parseInt(envPort, 10) : this.defaultPort;
218
218
  }
219
219
  /**
220
- * Check if a port is available
221
- * @param port - Port number to check
222
- * @returns Promise resolving to true if port is available
220
+ * Check if a port is available on a specific host
223
221
  */
224
- async isPortAvailable(port) {
222
+ async isPortAvailableOn(port, host) {
225
223
  return new Promise((resolve) => {
226
224
  const server = net.createServer();
227
225
  server.once("error", () => resolve(false));
@@ -229,9 +227,22 @@ var PortModule = class {
229
227
  server.close();
230
228
  resolve(true);
231
229
  });
232
- server.listen(port, "127.0.0.1");
230
+ server.listen(port, host);
233
231
  });
234
232
  }
233
+ /**
234
+ * Check if a port is available (checks both IPv4 and IPv6)
235
+ * @param port - Port number to check
236
+ * @returns Promise resolving to true if port is available on ALL interfaces
237
+ */
238
+ async isPortAvailable(port) {
239
+ const ipv4Available = await this.isPortAvailableOn(port, "127.0.0.1");
240
+ if (!ipv4Available) return false;
241
+ const ipv6Available = await this.isPortAvailableOn(port, "::1");
242
+ if (!ipv6Available) return false;
243
+ const allInterfacesAvailable = await this.isPortAvailableOn(port, "0.0.0.0");
244
+ return allInterfacesAvailable;
245
+ }
235
246
  /**
236
247
  * Find an available port starting from the suggested port
237
248
  * @param startPort - Starting port number (default: RTX_PORT or defaultPort)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@realtimex/sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "SDK for building Local Apps that integrate with RealtimeX",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -40,4 +40,4 @@
40
40
  "engines": {
41
41
  "node": ">=18.0.0"
42
42
  }
43
- }
43
+ }