diff --git a/packages/electron/package.json b/packages/electron/package.json index 0b909583e..b9933b11d 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -42,7 +42,6 @@ "electron": "^33.4.3", "execa": "catalog:", "h3": "^1.15.1", - "ip": "^2.0.1", "pathe": "catalog:", "socket.io": "^4.8.1", "socket.io-client": "^4.8.1" diff --git a/packages/electron/src/devtools.ts b/packages/electron/src/devtools.ts index 7610c0bc9..bae0d08dc 100644 --- a/packages/electron/src/devtools.ts +++ b/packages/electron/src/devtools.ts @@ -1,11 +1,19 @@ +import os from 'node:os' import { functions } from '@vue/devtools-core' import { createRpcClient, setElectronClientContext } from '@vue/devtools-kit' -import ip from 'ip' import io from 'socket.io-client/dist/socket.io.js' import { createConnectionApp, initDevTools } from '../client/devtools-panel' const port = window.process.env.PORT || 8098 +function address() { + return Object.values(os.networkInterfaces()).map((addresses) => { + return addresses?.filter((details) => { + return !details.internal && details.family === 'IPv4' + }) + }).flat()[0] +} + function init() { const localhost = `http://localhost:${port}` const socket = io(localhost) @@ -13,7 +21,7 @@ function init() { const app = createConnectionApp('#app', { local: localhost, - network: `http://${ip.address()}:${port}`, + network: `http://${address()}:${port}`, }) socket.on('vue-devtools:init', () => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ca527e42e..664623813 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -523,9 +523,6 @@ importers: h3: specifier: ^1.15.1 version: 1.15.1 - ip: - specifier: ^2.0.1 - version: 2.0.1 pathe: specifier: 'catalog:' version: 2.0.3 @@ -5840,9 +5837,6 @@ packages: ini@1.3.8: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} - ip@2.0.1: - resolution: {integrity: sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==} - ipaddr.js@1.9.1: resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} engines: {node: '>= 0.10'} @@ -15172,8 +15166,6 @@ snapshots: ini@1.3.8: {} - ip@2.0.1: {} - ipaddr.js@1.9.1: {} ipaddr.js@2.2.0: {}