@nativescript/vite 0.0.1-alpha.6 → 0.0.1-alpha.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.
@@ -15,12 +15,12 @@ const recentHmr = new Map();
15
15
  let httpOriginForVite;
16
16
  function deriveHttpOrigin(wsUrl) {
17
17
  try {
18
- const url = new URL(wsUrl || "ws://localhost:5173/ns-hmr");
18
+ const url = new URL(wsUrl || "ws://10.0.2.2:5173/ns-hmr");
19
19
  const http = url.protocol === "wss:" ? "https:" : "http:";
20
20
  return `${http}//${url.host}`;
21
21
  }
22
22
  catch {
23
- return "http://localhost:5173";
23
+ return "http://10.0.2.2:5173";
24
24
  }
25
25
  }
26
26
  function connectHmr() {
@@ -32,7 +32,7 @@ function connectHmr() {
32
32
  return;
33
33
  }
34
34
  try {
35
- const wsUrl = hmrWsUrl || "ws://localhost:5173/ns-hmr";
35
+ const wsUrl = hmrWsUrl || "ws://10.0.2.2:5173/ns-hmr";
36
36
  if (VERBOSE)
37
37
  console.log("[hmr-client-vue] Connecting to HMR WebSocket:", wsUrl);
38
38
  hmrSocket = new WebSocket(wsUrl);
@@ -20,9 +20,14 @@ export function hmrPluginVue(platform, verboseLogs = false) {
20
20
  return null;
21
21
  const clientPath = require.resolve("@nativescript/vite/dist/hmr/client-vue.js");
22
22
  // Build ws url from Vite server info
23
- const host = process.env.NS_HMR_HOST ||
24
- config?.server?.host ||
25
- (platform === 'android' ? "10.0.2.2" : "localhost");
23
+ let host = process.env.NS_HMR_HOST || config?.server?.host;
24
+ // Fix for Android: if host is 0.0.0.0 (which is used to expose server), use 10.0.2.2 for client connection
25
+ if (platform === 'android' && (host === '0.0.0.0' || !host)) {
26
+ host = "10.0.2.2";
27
+ }
28
+ else if (!host) {
29
+ host = "localhost";
30
+ }
26
31
  const port = Number(config?.server?.port || 5173);
27
32
  const secure = !!config?.server?.https;
28
33
  const protocol = secure ? "wss" : "ws";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/vite",
3
- "version": "0.0.1-alpha.6",
3
+ "version": "0.0.1-alpha.7",
4
4
  "description": "Vite for NativeScript",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",