versacompiler 2.0.5 → 2.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/compiler/typescript-manager.js +27 -5
- package/dist/hrm/initHRM.js +1 -0
- package/dist/main.js +16 -1
- package/dist/servicios/browserSync.js +46 -12
- package/dist/utils/proxyValidator.js +68 -0
- package/package.json +11 -11
|
@@ -164,6 +164,30 @@ export const validateVueTypes = (vueContent, fileName, options) => {
|
|
|
164
164
|
return validateTypesWithLanguageService(fileName, scriptContent, // Usar solo el contenido del script
|
|
165
165
|
compilerOptions);
|
|
166
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Limpia los export {} innecesarios que TypeScript agrega automáticamente
|
|
169
|
+
* @param compiledOutput - Código JavaScript compilado
|
|
170
|
+
* @param originalSource - Código TypeScript original
|
|
171
|
+
* @returns Código limpio sin export {} innecesarios
|
|
172
|
+
*/
|
|
173
|
+
const cleanupUnnecessaryExports = (compiledOutput, originalSource) => {
|
|
174
|
+
// Si el output está vacío o solo contiene export {}
|
|
175
|
+
if (compiledOutput.trim() === 'export {};') {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
// Verificar si el código fuente original tiene imports/exports reales
|
|
179
|
+
const hasRealImportsExports = /(?:^|\s)(?:import|export)\s+(?!(?:\s*\{\s*\}\s*;?\s*$))/m.test(originalSource);
|
|
180
|
+
// Si no hay imports/exports reales, eliminar export {} del final
|
|
181
|
+
if (!hasRealImportsExports) {
|
|
182
|
+
// Buscar el patrón exacto en el archivo
|
|
183
|
+
const exportPattern = /export\s*\{\s*\}\s*;\s*$/m;
|
|
184
|
+
const hasExportAtEnd = exportPattern.test(compiledOutput);
|
|
185
|
+
if (hasExportAtEnd) {
|
|
186
|
+
return compiledOutput.replace(exportPattern, '');
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return compiledOutput;
|
|
190
|
+
};
|
|
167
191
|
/**
|
|
168
192
|
* Precompila el código TypeScript con pipeline optimizado para máxima performance.
|
|
169
193
|
* @param {string} data - El código TypeScript a precompilar.
|
|
@@ -233,11 +257,9 @@ export const preCompileTS = async (data, fileName) => {
|
|
|
233
257
|
}
|
|
234
258
|
}
|
|
235
259
|
// PASO 3: Devolver resultado optimizado
|
|
236
|
-
|
|
237
|
-
// Limpiar
|
|
238
|
-
|
|
239
|
-
return { error: null, data: '', lang: 'ts' };
|
|
240
|
-
}
|
|
260
|
+
let output = transpileResult.outputText;
|
|
261
|
+
// Limpiar export {} innecesarios
|
|
262
|
+
output = cleanupUnnecessaryExports(output, data);
|
|
241
263
|
return { error: null, data: output, lang: 'ts' };
|
|
242
264
|
}
|
|
243
265
|
catch (error) {
|
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...');
|
package/dist/main.js
CHANGED
|
@@ -19,6 +19,20 @@ async function loadChalk() {
|
|
|
19
19
|
}
|
|
20
20
|
return chalk;
|
|
21
21
|
}
|
|
22
|
+
// Función para obtener la versión del package.json
|
|
23
|
+
async function getPackageVersion() {
|
|
24
|
+
try {
|
|
25
|
+
const fs = await import('node:fs/promises');
|
|
26
|
+
const packageJsonPath = path.resolve(env.PATH_PROY || path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
|
|
27
|
+
const packageContent = await fs.readFile(packageJsonPath, 'utf-8');
|
|
28
|
+
const packageData = JSON.parse(packageContent);
|
|
29
|
+
return packageData.version || 'unknown';
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Fallback si no se puede leer el package.json
|
|
33
|
+
return 'unknown';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
22
36
|
async function loadYargs() {
|
|
23
37
|
if (!yargs) {
|
|
24
38
|
const yargsModule = await import('yargs');
|
|
@@ -133,12 +147,13 @@ async function main() {
|
|
|
133
147
|
.parse());
|
|
134
148
|
try {
|
|
135
149
|
// 🎨 Header moderno y elegante
|
|
150
|
+
const version = await getPackageVersion();
|
|
136
151
|
const headerLine = '━'.repeat(60);
|
|
137
152
|
logger.log(`\n` +
|
|
138
153
|
chalk.cyan(headerLine) +
|
|
139
154
|
`\n` +
|
|
140
155
|
chalk.bold.cyan(' ⚡ VersaCompiler ') +
|
|
141
|
-
chalk.gray(
|
|
156
|
+
chalk.gray(`v${version}`) +
|
|
142
157
|
`\n` +
|
|
143
158
|
chalk.gray(' Vue · TypeScript · JavaScript Compiler') +
|
|
144
159
|
`\n` +
|
|
@@ -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
|
};
|
|
@@ -351,10 +373,14 @@ export async function browserSyncServer() {
|
|
|
351
373
|
if (cachedFile) {
|
|
352
374
|
res.setHeader('Content-Type', cachedFile.contentType);
|
|
353
375
|
res.setHeader('ETag', cachedFile.etag);
|
|
354
|
-
if (
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
376
|
+
// if (
|
|
377
|
+
// process.env.VERBOSE === 'true' &&
|
|
378
|
+
// cachedFile.cached
|
|
379
|
+
// ) {
|
|
380
|
+
// logger.info(
|
|
381
|
+
// `🚀 File cache hit para ${vueLoaderPath}`,
|
|
382
|
+
// );
|
|
383
|
+
// }
|
|
358
384
|
res.end(cachedFile.content);
|
|
359
385
|
}
|
|
360
386
|
else {
|
|
@@ -373,10 +399,14 @@ export async function browserSyncServer() {
|
|
|
373
399
|
if (cachedFile) {
|
|
374
400
|
res.setHeader('Content-Type', cachedFile.contentType);
|
|
375
401
|
res.setHeader('ETag', cachedFile.etag);
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
402
|
+
// if (
|
|
403
|
+
// process.env.VERBOSE === 'true' &&
|
|
404
|
+
// cachedFile.cached
|
|
405
|
+
// ) {
|
|
406
|
+
// logger.info(
|
|
407
|
+
// `🚀 File cache hit para ${filePath}`,
|
|
408
|
+
// );
|
|
409
|
+
// }
|
|
380
410
|
res.end(cachedFile.content);
|
|
381
411
|
}
|
|
382
412
|
else {
|
|
@@ -395,10 +425,14 @@ export async function browserSyncServer() {
|
|
|
395
425
|
if (cachedFile) {
|
|
396
426
|
res.setHeader('Content-Type', cachedFile.contentType);
|
|
397
427
|
res.setHeader('ETag', cachedFile.etag);
|
|
398
|
-
if (
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
428
|
+
// if (
|
|
429
|
+
// process.env.VERBOSE === 'true' &&
|
|
430
|
+
// cachedFile.cached
|
|
431
|
+
// ) {
|
|
432
|
+
// logger.info(
|
|
433
|
+
// `🚀 Module cache hit para ${modulePath}`,
|
|
434
|
+
// );
|
|
435
|
+
// }
|
|
402
436
|
res.end(cachedFile.content);
|
|
403
437
|
}
|
|
404
438
|
else {
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "versacompiler",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Una herramienta para compilar y minificar archivos .vue, .js y .ts para proyectos de Vue 3 con soporte para TypeScript.",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/kriollo/versaCompiler#readme",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@vue/compiler-dom": "^3.5.
|
|
53
|
-
"@vue/reactivity": "^3.5.
|
|
54
|
-
"@vue/runtime-core": "^3.5.
|
|
55
|
-
"@vue/runtime-dom": "^3.5.
|
|
52
|
+
"@vue/compiler-dom": "^3.5.17",
|
|
53
|
+
"@vue/reactivity": "^3.5.17",
|
|
54
|
+
"@vue/runtime-core": "^3.5.17",
|
|
55
|
+
"@vue/runtime-dom": "^3.5.17",
|
|
56
56
|
"browser-sync": "^3.0.4",
|
|
57
57
|
"chalk": "5.4.1",
|
|
58
58
|
"chokidar": "^4.0.3",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"fs-extra": "^11.3.0",
|
|
63
63
|
"get-port": "^7.1.0",
|
|
64
64
|
"minimatch": "^10.0.1",
|
|
65
|
-
"oxc-minify": "^0.
|
|
66
|
-
"oxc-parser": "^0.
|
|
67
|
-
"oxc-transform": "^0.
|
|
65
|
+
"oxc-minify": "^0.75.0",
|
|
66
|
+
"oxc-parser": "^0.75.0",
|
|
67
|
+
"oxc-transform": "^0.75.0",
|
|
68
68
|
"resolve": "^1.22.10",
|
|
69
69
|
"tsx": "^4.19.4",
|
|
70
70
|
"typescript": "^5.8.3",
|
|
@@ -96,10 +96,10 @@
|
|
|
96
96
|
"eslint-plugin-vue": "^10.2.0",
|
|
97
97
|
"happy-dom": "^18.0.1",
|
|
98
98
|
"jest": "^30.0.0",
|
|
99
|
-
"jest-environment-jsdom": "30.0.
|
|
100
|
-
"jest-environment-node": "30.0.
|
|
99
|
+
"jest-environment-jsdom": "30.0.2",
|
|
100
|
+
"jest-environment-node": "30.0.2",
|
|
101
101
|
"oxlint": "^1.0.0",
|
|
102
|
-
"prettier": "3.
|
|
102
|
+
"prettier": "3.6.2",
|
|
103
103
|
"rimraf": "^6.0.1",
|
|
104
104
|
"sweetalert2": "^11.22.0",
|
|
105
105
|
"tailwindcss": "^4.1.8",
|