leglas 0.7.2 → 0.7.3

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/bin.js CHANGED
@@ -2624,18 +2624,23 @@ async function freePort() {
2624
2624
  });
2625
2625
  });
2626
2626
  }
2627
- function answers(port) {
2628
- return new Promise((resolve5) => {
2629
- const socket = net2.connect(port, "127.0.0.1");
2627
+ var LOOPBACK = ["127.0.0.1", "::1"];
2628
+ function forUrl(host) {
2629
+ return host.includes(":") ? `[${host}]` : host;
2630
+ }
2631
+ async function answeringHost(port) {
2632
+ const reached = await Promise.all(LOOPBACK.map((host) => new Promise((resolve5) => {
2633
+ const socket = net2.connect({ port, host });
2630
2634
  const settle = (value) => {
2631
2635
  socket.destroy();
2632
2636
  resolve5(value);
2633
2637
  };
2634
2638
  socket.setTimeout(400);
2635
- socket.once("connect", () => settle(true));
2636
- socket.once("timeout", () => settle(false));
2637
- socket.once("error", () => settle(false));
2638
- });
2639
+ socket.once("connect", () => settle(host));
2640
+ socket.once("timeout", () => settle(null));
2641
+ socket.once("error", () => settle(null));
2642
+ })));
2643
+ return reached.find((host) => host !== null) ?? null;
2639
2644
  }
2640
2645
  async function startWorktree(options) {
2641
2646
  const readyTimeoutMs = options.readyTimeoutMs ?? 9e4;
@@ -2730,8 +2735,9 @@ async function startAppProcess(options) {
2730
2735
  if (exited !== null) {
2731
2736
  throw new Error(`${options.label} did not start: its dev command exited with code ${exited}.`);
2732
2737
  }
2733
- if (await answers(port)) {
2734
- return { port, url: `http://127.0.0.1:${port}`, stop };
2738
+ const host = await answeringHost(port);
2739
+ if (host !== null) {
2740
+ return { port, url: `http://${forUrl(host)}:${port}`, stop };
2735
2741
  }
2736
2742
  await new Promise((resolve5) => setTimeout(resolve5, 250));
2737
2743
  }
package/dist/index.js CHANGED
@@ -3000,18 +3000,23 @@ async function freePort() {
3000
3000
  });
3001
3001
  });
3002
3002
  }
3003
- function answers(port) {
3004
- return new Promise((resolve5) => {
3005
- const socket = net2.connect(port, "127.0.0.1");
3003
+ var LOOPBACK = ["127.0.0.1", "::1"];
3004
+ function forUrl(host) {
3005
+ return host.includes(":") ? `[${host}]` : host;
3006
+ }
3007
+ async function answeringHost(port) {
3008
+ const reached = await Promise.all(LOOPBACK.map((host) => new Promise((resolve5) => {
3009
+ const socket = net2.connect({ port, host });
3006
3010
  const settle = (value) => {
3007
3011
  socket.destroy();
3008
3012
  resolve5(value);
3009
3013
  };
3010
3014
  socket.setTimeout(400);
3011
- socket.once("connect", () => settle(true));
3012
- socket.once("timeout", () => settle(false));
3013
- socket.once("error", () => settle(false));
3014
- });
3015
+ socket.once("connect", () => settle(host));
3016
+ socket.once("timeout", () => settle(null));
3017
+ socket.once("error", () => settle(null));
3018
+ })));
3019
+ return reached.find((host) => host !== null) ?? null;
3015
3020
  }
3016
3021
  async function startWorktree(options) {
3017
3022
  const readyTimeoutMs = options.readyTimeoutMs ?? 9e4;
@@ -3106,8 +3111,9 @@ async function startAppProcess(options) {
3106
3111
  if (exited !== null) {
3107
3112
  throw new Error(`${options.label} did not start: its dev command exited with code ${exited}.`);
3108
3113
  }
3109
- if (await answers(port)) {
3110
- return { port, url: `http://127.0.0.1:${port}`, stop };
3114
+ const host = await answeringHost(port);
3115
+ if (host !== null) {
3116
+ return { port, url: `http://${forUrl(host)}:${port}`, stop };
3111
3117
  }
3112
3118
  await new Promise((resolve5) => setTimeout(resolve5, 250));
3113
3119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leglas",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Compare design directions inside your own running app.",
5
5
  "license": "MIT",
6
6
  "repository": {