versacompiler 2.0.5 → 2.0.6
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/hrm/initHRM.js
CHANGED
|
@@ -68,6 +68,7 @@ async function initSocket(retries = 0) {
|
|
|
68
68
|
|
|
69
69
|
// Configurar listener para HMR de componentes Vue
|
|
70
70
|
socket.on('HRMVue', async (/** @type {ComponentInfo} */ data) => {
|
|
71
|
+
hideErrorOverlay();
|
|
71
72
|
vueInstance = window.__VUE_APP__ || vueInstance;
|
|
72
73
|
if (vueInstance) {
|
|
73
74
|
console.log('🔥 Preparando HMR para Vue...');
|
|
@@ -5,6 +5,8 @@ import process, { env } from 'node:process';
|
|
|
5
5
|
import browserSync from 'browser-sync';
|
|
6
6
|
|
|
7
7
|
import getPort from 'get-port';
|
|
8
|
+
import { promptUser } from '../utils/promptUser.js';
|
|
9
|
+
import { getProxyInfo, validateProxyAvailability, } from '../utils/proxyValidator.js';
|
|
8
10
|
import { logger } from './logger.js';
|
|
9
11
|
class BrowserSyncFileCache {
|
|
10
12
|
static instance;
|
|
@@ -283,7 +285,27 @@ export async function browserSyncServer() {
|
|
|
283
285
|
let proxy = {
|
|
284
286
|
server: './',
|
|
285
287
|
};
|
|
288
|
+
// ✨ VALIDACIÓN DE PROXY: Verificar disponibilidad antes de inicializar BrowserSync
|
|
286
289
|
if (env.proxyUrl) {
|
|
290
|
+
logger.info(`🔍 Validando disponibilidad del servidor proxy: ${env.proxyUrl}`);
|
|
291
|
+
const isProxyAvailable = await validateProxyAvailability(env.proxyUrl, 5000);
|
|
292
|
+
if (!isProxyAvailable) {
|
|
293
|
+
const proxyInfo = getProxyInfo(env.proxyUrl);
|
|
294
|
+
logger.warn(`⚠️ El servidor proxy no está disponible:`);
|
|
295
|
+
logger.warn(` Host: ${proxyInfo.host}`);
|
|
296
|
+
logger.warn(` Puerto: ${proxyInfo.port}`);
|
|
297
|
+
logger.warn(` Protocolo: ${proxyInfo.protocol}`);
|
|
298
|
+
const response = await promptUser('\n¿Desea continuar de todos modos? El modo proxy podría no funcionar correctamente. (s/n): ', 30000);
|
|
299
|
+
if (response.toLowerCase().trim() !== 's' &&
|
|
300
|
+
response.toLowerCase().trim() !== 'si') {
|
|
301
|
+
logger.info('🛑 Operación cancelada por el usuario.');
|
|
302
|
+
process.exit(0);
|
|
303
|
+
}
|
|
304
|
+
logger.warn('⚠️ Continuando con el servidor proxy no disponible...');
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
logger.info('✅ Servidor proxy disponible');
|
|
308
|
+
}
|
|
287
309
|
proxy = {
|
|
288
310
|
proxy: env.proxyUrl,
|
|
289
311
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { get as httpGet } from 'node:http';
|
|
2
|
+
import { get as httpsGet } from 'node:https';
|
|
3
|
+
import { URL } from 'node:url';
|
|
4
|
+
/**
|
|
5
|
+
* Valida si un servidor proxy está disponible
|
|
6
|
+
* @param proxyUrl URL del proxy a validar
|
|
7
|
+
* @param timeout Timeout en milisegundos (default: 5000)
|
|
8
|
+
* @returns Promise que resuelve a true si el proxy está disponible
|
|
9
|
+
*/
|
|
10
|
+
export async function validateProxyAvailability(proxyUrl, timeout = 5000) {
|
|
11
|
+
return new Promise(resolve => {
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(proxyUrl);
|
|
14
|
+
const isHttps = url.protocol === 'https:';
|
|
15
|
+
const requestMethod = isHttps ? httpsGet : httpGet;
|
|
16
|
+
const options = {
|
|
17
|
+
hostname: url.hostname,
|
|
18
|
+
port: url.port || (isHttps ? 443 : 80),
|
|
19
|
+
path: '/',
|
|
20
|
+
method: 'HEAD',
|
|
21
|
+
timeout: timeout,
|
|
22
|
+
headers: {
|
|
23
|
+
'User-Agent': 'VersaCompiler-ProxyValidator/1.0',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const req = requestMethod(options, _res => {
|
|
27
|
+
// Cualquier respuesta HTTP (incluso errores 4xx/5xx) indica que el servidor está arriba
|
|
28
|
+
resolve(true);
|
|
29
|
+
});
|
|
30
|
+
req.on('error', () => {
|
|
31
|
+
resolve(false);
|
|
32
|
+
});
|
|
33
|
+
req.on('timeout', () => {
|
|
34
|
+
req.destroy();
|
|
35
|
+
resolve(false);
|
|
36
|
+
});
|
|
37
|
+
req.setTimeout(timeout);
|
|
38
|
+
req.end();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Error al parsear URL o crear request
|
|
42
|
+
resolve(false);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Extrae información legible del proxy URL para mostrar al usuario
|
|
48
|
+
* @param proxyUrl URL del proxy
|
|
49
|
+
* @returns Objeto con información del proxy
|
|
50
|
+
*/
|
|
51
|
+
export function getProxyInfo(proxyUrl) {
|
|
52
|
+
try {
|
|
53
|
+
const url = new URL(proxyUrl);
|
|
54
|
+
return {
|
|
55
|
+
host: url.hostname,
|
|
56
|
+
port: url.port || (url.protocol === 'https:' ? '443' : '80'),
|
|
57
|
+
protocol: url.protocol.replace(':', ''),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return {
|
|
62
|
+
host: 'unknown',
|
|
63
|
+
port: 'unknown',
|
|
64
|
+
protocol: 'unknown',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=proxyValidator.js.map
|
package/package.json
CHANGED