versacompiler 2.0.7 → 2.0.8

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.
Files changed (39) hide show
  1. package/dist/compiler/compile.js +26 -2332
  2. package/dist/compiler/error-reporter.js +38 -467
  3. package/dist/compiler/linter.js +1 -72
  4. package/dist/compiler/minify.js +1 -229
  5. package/dist/compiler/module-resolution-optimizer.js +1 -821
  6. package/dist/compiler/parser.js +1 -203
  7. package/dist/compiler/performance-monitor.js +56 -192
  8. package/dist/compiler/tailwindcss.js +1 -39
  9. package/dist/compiler/transform-optimizer.js +1 -392
  10. package/dist/compiler/transformTStoJS.js +1 -16
  11. package/dist/compiler/transforms.js +1 -550
  12. package/dist/compiler/typescript-compiler.js +2 -172
  13. package/dist/compiler/typescript-error-parser.js +10 -281
  14. package/dist/compiler/typescript-manager.js +2 -273
  15. package/dist/compiler/typescript-sync-validator.js +31 -295
  16. package/dist/compiler/typescript-worker-pool.js +1 -842
  17. package/dist/compiler/typescript-worker-thread.cjs +41 -466
  18. package/dist/compiler/typescript-worker.js +1 -339
  19. package/dist/compiler/vuejs.js +37 -392
  20. package/dist/hrm/VueHRM.js +1 -353
  21. package/dist/hrm/errorScreen.js +1 -83
  22. package/dist/hrm/getInstanciaVue.js +1 -313
  23. package/dist/hrm/initHRM.js +1 -141
  24. package/dist/main.js +7 -347
  25. package/dist/servicios/browserSync.js +5 -501
  26. package/dist/servicios/file-watcher.js +4 -379
  27. package/dist/servicios/logger.js +3 -63
  28. package/dist/servicios/readConfig.js +105 -430
  29. package/dist/utils/excluded-modules.js +1 -36
  30. package/dist/utils/module-resolver.js +1 -466
  31. package/dist/utils/promptUser.js +2 -48
  32. package/dist/utils/proxyValidator.js +1 -68
  33. package/dist/utils/resolve-bin.js +1 -48
  34. package/dist/utils/utils.js +1 -21
  35. package/dist/utils/vue-types-setup.js +241 -435
  36. package/dist/wrappers/eslint-node.js +1 -145
  37. package/dist/wrappers/oxlint-node.js +1 -120
  38. package/dist/wrappers/tailwind-node.js +1 -92
  39. package/package.json +36 -35
@@ -1,379 +1,4 @@
1
- import { readdir, rm, stat, unlink } from 'node:fs/promises';
2
- import path from 'node:path';
3
- import process, { env } from 'node:process';
4
- import * as chokidar from 'chokidar';
5
- import { minimatch } from 'minimatch';
6
- import { getOutputPath, initCompile, normalizeRuta } from '../compiler/compile.js';
7
- import { promptUser } from '../utils/promptUser.js';
8
- import { emitirCambios } from './browserSync.js';
9
- import { logger } from './logger.js';
10
- // Lazy loading para chalk
11
- let chalk;
12
- async function loadChalk() {
13
- if (!chalk) {
14
- chalk = (await import('chalk')).default;
15
- }
16
- return chalk;
17
- }
18
- class WatchDebouncer {
19
- pendingChanges = new Map();
20
- debounceTimer = null;
21
- DEBOUNCE_DELAY = 300; // 300ms debounce
22
- BATCH_SIZE = 10; // Máximo archivos por batch
23
- isProcessing = false;
24
- browserSyncInstance = null; // ✨ Almacenar referencia a browserSync
25
- /**
26
- * Establece la instancia de browserSync
27
- */
28
- setBrowserSyncInstance(bs) {
29
- this.browserSyncInstance = bs;
30
- }
31
- /**
32
- * Añade un cambio al sistema de debouncing
33
- */
34
- addChange(filePath, action, extensionAction, isAdditionalFile = false) {
35
- // Normalizar ruta para evitar duplicados
36
- const normalizedPath = normalizeRuta(filePath);
37
- // Agregar o actualizar el cambio pendiente
38
- this.pendingChanges.set(normalizedPath, {
39
- filePath: normalizedPath,
40
- action,
41
- timestamp: Date.now(),
42
- extensionAction,
43
- isAdditionalFile,
44
- });
45
- // Reiniciar el timer de debounce
46
- this.resetDebounceTimer();
47
- }
48
- /**
49
- * Reinicia el timer de debounce
50
- */
51
- resetDebounceTimer() {
52
- if (this.debounceTimer) {
53
- clearTimeout(this.debounceTimer);
54
- }
55
- this.debounceTimer = setTimeout(() => {
56
- this.processPendingChanges();
57
- }, this.DEBOUNCE_DELAY);
58
- }
59
- /**
60
- * Procesa todos los cambios pendientes en batch
61
- */
62
- async processPendingChanges() {
63
- if (this.isProcessing || this.pendingChanges.size === 0) {
64
- return;
65
- }
66
- this.isProcessing = true;
67
- const changes = Array.from(this.pendingChanges.values());
68
- this.pendingChanges.clear();
69
- try {
70
- // Agrupar por tipo de acción para optimización
71
- const deleteChanges = changes.filter(c => c.action === 'unlink');
72
- const compileChanges = changes.filter(c => c.action === 'add' || c.action === 'change');
73
- // Procesar eliminaciones primero
74
- if (deleteChanges.length > 0) {
75
- await this.processDeleteChanges(deleteChanges);
76
- }
77
- // Procesar compilaciones en batches
78
- if (compileChanges.length > 0) {
79
- await this.processCompileChanges(compileChanges);
80
- }
81
- }
82
- catch (error) {
83
- const chalkInstance = await loadChalk();
84
- logger.error(chalkInstance.red(`🚩 Error procesando cambios en batch: ${error instanceof Error ? error.message : String(error)}`));
85
- }
86
- finally {
87
- this.isProcessing = false;
88
- // Si hay más cambios pendientes, procesarlos
89
- if (this.pendingChanges.size > 0) {
90
- this.resetDebounceTimer();
91
- }
92
- }
93
- } /**
94
- * Procesa cambios de eliminación
95
- */
96
- async processDeleteChanges(deleteChanges) {
97
- for (const change of deleteChanges) {
98
- if (change.isAdditionalFile) {
99
- // ✨ Archivos adicionales: solo reload, sin eliminar del output
100
- logger.info(`\n🗑️ Archivo adicional eliminado: ${change.filePath}`);
101
- emitirCambios(this.browserSyncInstance, 'reloadFull', change.filePath);
102
- }
103
- else {
104
- // Archivos compilables: eliminar del output
105
- logger.info(`\n🗑️ Eliminando archivo compilado: ${change.filePath}`);
106
- const result = await deleteFile(getOutputPath(change.filePath));
107
- if (result) {
108
- logger.info(`Archivo eliminado: ${change.filePath}`);
109
- emitirCambios(this.browserSyncInstance, 'reloadFull', change.filePath);
110
- }
111
- }
112
- }
113
- }
114
- /**
115
- * Procesa cambios de compilación en paralelo con límite de concurrencia
116
- */
117
- async processCompileChanges(compileChanges) {
118
- // ✨ NUEVO: Separar archivos adicionales de archivos compilables
119
- const additionalFiles = compileChanges.filter(c => c.isAdditionalFile);
120
- const compilableFiles = compileChanges.filter(c => !c.isAdditionalFile);
121
- // ✨ Procesar archivos adicionales (solo reload, sin compilación)
122
- if (additionalFiles.length > 0) {
123
- await this.processAdditionalFiles(additionalFiles);
124
- }
125
- // Procesar archivos compilables normalmente
126
- if (compilableFiles.length > 0) {
127
- await this.processCompilableFiles(compilableFiles);
128
- }
129
- }
130
- /**
131
- * ✨ RENOMBRADO: Procesa archivos compilables
132
- */
133
- async processCompilableFiles(compilableFiles) {
134
- const chalkInstance = await loadChalk();
135
- // Procesar en batches para evitar sobrecarga
136
- for (let i = 0; i < compilableFiles.length; i += this.BATCH_SIZE) {
137
- const batch = compilableFiles.slice(i, i + this.BATCH_SIZE);
138
- if (batch.length > 1) {
139
- logger.info(chalkInstance.cyan(`📦 Procesando batch de ${batch.length} archivos compilables (${i + 1}-${Math.min(i + this.BATCH_SIZE, compilableFiles.length)} de ${compilableFiles.length})`));
140
- }
141
- const promises = batch.map(change => this.compileFile(change));
142
- await Promise.allSettled(promises);
143
- }
144
- if (compilableFiles.length > 1) {
145
- logger.info(chalkInstance.green(`✅ Batch completado: ${compilableFiles.length} archivos compilados`));
146
- }
147
- }
148
- /**
149
- * ✨ NUEVO: Procesa archivos adicionales (solo reloadFull)
150
- */
151
- async processAdditionalFiles(additionalFiles) {
152
- const chalkInstance = await loadChalk();
153
- logger.info(chalkInstance.blue(`🔄 Recargando ${additionalFiles.length} archivo(s) adicional(es) (sin compilación)`));
154
- for (const change of additionalFiles) {
155
- logger.info(`📄 Archivo adicional modificado: ${change.filePath}`);
156
- // Solo hacer reloadFull, sin compilación
157
- emitirCambios(this.browserSyncInstance, 'reloadFull', change.filePath);
158
- }
159
- }
160
- /**
161
- * Compila un archivo individual
162
- */
163
- async compileFile(change) {
164
- try {
165
- const result = await initCompile(change.filePath, true, 'watch');
166
- if (result.success) {
167
- let accion = result.action || change.extensionAction;
168
- accion =
169
- accion === 'extension' ? change.extensionAction : accion;
170
- emitirCambios(this.browserSyncInstance, accion || 'reloadFull', result.output);
171
- }
172
- }
173
- catch (error) {
174
- const chalkInstance = await loadChalk();
175
- logger.error(chalkInstance.red(`🚩 Error compilando ${change.filePath}: ${error instanceof Error ? error.message : String(error)}`));
176
- }
177
- }
178
- /**
179
- * Obtiene estadísticas del debouncer
180
- */
181
- getStats() {
182
- return {
183
- pendingChanges: this.pendingChanges.size,
184
- isProcessing: this.isProcessing,
185
- hasTimer: this.debounceTimer !== null,
186
- };
187
- }
188
- }
189
- // Instancia global del debouncer
190
- const watchDebouncer = new WatchDebouncer();
191
- // const cacheImportMap = new Map<string, string[]>();
192
- // const cacheComponentMap = new Map<string, string[]>();
193
- export async function cleanOutputDir(outputDir, primerInteraccion = true) {
194
- try {
195
- if (!outputDir) {
196
- throw new Error('El directorio de salida no está definido');
197
- }
198
- if (primerInteraccion) {
199
- const stats = await stat(outputDir).catch(() => null);
200
- if (!stats || !stats.isDirectory()) {
201
- logger.error(`🚩 El directorio de salida no existe o no es un directorio: ${outputDir}`);
202
- return;
203
- }
204
- try {
205
- if (env.yes === 'false') {
206
- const chalkInstance = await loadChalk();
207
- const answer = await promptUser('\n\n¿Estás seguro deseas limpiar la carpeta ' +
208
- chalkInstance.yellow(outputDir) +
209
- '? (s / N) : ');
210
- if (answer.toLowerCase() !== 's') {
211
- logger.info('🛑 Compilación cancelada por el usuario.');
212
- if (process.env.NODE_ENV !== 'test') {
213
- process.exit(0);
214
- }
215
- return;
216
- }
217
- }
218
- }
219
- catch (error) {
220
- logger.error(`Error en la entrada del usuario: ${error}`);
221
- if (process.env.NODE_ENV !== 'test') {
222
- process.exit(1);
223
- }
224
- throw error;
225
- }
226
- }
227
- const chalkInstance = await loadChalk();
228
- logger.info(`🗑️ Limpiando directorio de salida: ${chalkInstance.yellow(outputDir)}\n`);
229
- const items = await readdir(outputDir);
230
- await Promise.all(items.map(async (item) => {
231
- const itemPath = path.join(outputDir, item);
232
- const itemStat = await stat(itemPath);
233
- if (itemStat.isDirectory()) {
234
- await rm(itemPath, { recursive: true });
235
- }
236
- else {
237
- await unlink(itemPath);
238
- }
239
- }));
240
- logger.info(`✅ Directorio limpiado: ${outputDir}`);
241
- }
242
- catch (error) {
243
- logger.error(`🚩 Error al limpiar directorio de salida: ${error instanceof Error ? error.message : String(error)}`);
244
- }
245
- }
246
- async function deleteFile(filePath) {
247
- try {
248
- await unlink(filePath);
249
- return true;
250
- }
251
- catch (error) {
252
- logger.error(`🚩 Error eliminando archivo ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
253
- return false;
254
- }
255
- }
256
- function getAction(ruta, extendsionWatch) {
257
- const action = extendsionWatch
258
- .filter((item) => item !== undefined)
259
- .find(item => item.ext === ruta.split('.').pop())?.action;
260
- return action || 'reloadFull';
261
- }
262
- /**
263
- * Verifica si un archivo pertenece a las rutas adicionales (no compilables)
264
- */
265
- function isAdditionalWatchFile(filePath, additionalPatterns) {
266
- if (!additionalPatterns || additionalPatterns.length === 0) {
267
- return false;
268
- }
269
- const normalizedPath = normalizeRuta(filePath);
270
- return additionalPatterns.some(pattern => {
271
- // Normalizar el patrón también
272
- const normalizedPattern = pattern.replace(/\\/g, '/');
273
- return minimatch(normalizedPath, normalizedPattern);
274
- });
275
- }
276
- export async function initChokidar(bs) {
277
- try {
278
- if (!env.PATH_SOURCE) {
279
- logger.error('Error: La variable de entorno PATH_SOURCE no está definida.');
280
- if (process.env.NODE_ENV !== 'test') {
281
- process.exit(1);
282
- }
283
- throw new Error('PATH_SOURCE no está definida');
284
- }
285
- const watchJS = `${env.PATH_SOURCE}/**/*.js`;
286
- const watchVue = `${env.PATH_SOURCE}/**/*.vue`;
287
- const watchTS = `${env.PATH_SOURCE}/**/*.ts`;
288
- const watchCJS = `${env.PATH_SOURCE}/**/*.cjs`;
289
- const watchMJS = `${env.PATH_SOURCE}/**/*.mjs`;
290
- //TODO: agregar watch para CSS
291
- const watchAditional = JSON.parse(env.aditionalWatch || '[]');
292
- let fileWatch = [
293
- watchJS,
294
- watchVue,
295
- watchTS,
296
- watchCJS,
297
- watchMJS,
298
- ...watchAditional,
299
- ];
300
- //extraer sólo las extesniones de fileWatch
301
- const accionExtension = {
302
- vue: 'HRMVue',
303
- js: 'HRMHelper',
304
- ts: 'HRMHelper',
305
- cjs: 'HRMHelper',
306
- mjs: 'HRMHelper',
307
- };
308
- const extendsionWatch = fileWatch.map(item => {
309
- const ext = item.split('.').pop();
310
- if (ext) {
311
- return {
312
- ext,
313
- action: accionExtension[ext] ||
314
- 'reloadFull',
315
- };
316
- }
317
- });
318
- if (extendsionWatch.length === 0 || extendsionWatch[0] === undefined) {
319
- throw new Error('No se encontraron extensiones para observar');
320
- }
321
- const regExtExtension = new RegExp(`\\.(?!${extendsionWatch
322
- .filter(item => item !== undefined)
323
- .map(item => item.ext)
324
- .join('$|')}$).+$`);
325
- fileWatch = fileWatch.map(item => item.replace(/\/\*\*\//g, '/'));
326
- const directories = new Map();
327
- fileWatch.forEach(item => {
328
- const dir = item.substring(0, item.lastIndexOf('/'));
329
- if (!directories.has(dir)) {
330
- directories.set(dir, []);
331
- }
332
- directories.get(dir).push(item);
333
- });
334
- const DirWatch = Array.from(directories.keys());
335
- const watcher = chokidar.watch(DirWatch, {
336
- persistent: true,
337
- ignoreInitial: true,
338
- ignored: regExtExtension,
339
- });
340
- watcher.on('ready', async () => {
341
- const chalkInstance = await loadChalk();
342
- logger.info(chalkInstance.green(`👀 : Listo para observar \n${fileWatch
343
- .map((item) => `${item}`)
344
- .join('\n')}\n`));
345
- });
346
- // ✨ CONFIGURAR: Establecer la instancia de browserSync en el debouncer
347
- watchDebouncer.setBrowserSyncInstance(bs);
348
- // ✨ OPTIMIZADO: Evento cuando se añade un archivo - Con debouncing
349
- watcher.on('add', async (ruta) => {
350
- const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
351
- const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
352
- // Usar sistema de debouncing en lugar de compilación inmediata
353
- watchDebouncer.addChange(ruta, 'add', action, isAdditional);
354
- });
355
- // ✨ OPTIMIZADO: Evento cuando se modifica un archivo - Con debouncing
356
- watcher.on('change', async (ruta) => {
357
- const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
358
- const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
359
- // Usar sistema de debouncing en lugar de compilación inmediata
360
- watchDebouncer.addChange(ruta, 'change', action, isAdditional);
361
- });
362
- // ✨ OPTIMIZADO: Evento cuando se elimina un archivo - Con debouncing
363
- watcher.on('unlink', async (ruta) => {
364
- const action = getAction(ruta, extendsionWatch.filter((item) => item !== undefined));
365
- const isAdditional = isAdditionalWatchFile(ruta, watchAditional);
366
- // Usar sistema de debouncing para eliminaciones también
367
- watchDebouncer.addChange(ruta, 'unlink', action, isAdditional);
368
- });
369
- return watcher;
370
- }
371
- catch (error) {
372
- logger.error(`🚩 :Error al iniciar watch: ${error instanceof Error ? error.message : String(error)}`);
373
- if (process.env.NODE_ENV !== 'test') {
374
- process.exit(1);
375
- }
376
- throw error;
377
- }
378
- }
379
- //# sourceMappingURL=file-watcher.js.map
1
+ import{readdir as e,rm as n,stat as r,unlink as i}from"node:fs/promises";import a from"node:path";import o,{env as s}from"node:process";import*as c from"chokidar";import{minimatch as l}from"minimatch";import{getOutputPath as u,initCompile as d,normalizeRuta as f}from"../compiler/compile.js";import{promptUser as p}from"../utils/promptUser.js";import{emitirCambios as m}from"./browserSync.js";import{logger as h}from"./logger.js";let g;async function _(){return g||=(await import(`chalk`)).default,g}class v{pendingChanges=new Map;debounceTimer=null;DEBOUNCE_DELAY=300;BATCH_SIZE=10;isProcessing=!1;browserSyncInstance=null;setBrowserSyncInstance(e){this.browserSyncInstance=e}addChange(e,n,r,i=!1){let a=f(e);this.pendingChanges.set(a,{filePath:a,action:n,timestamp:Date.now(),extensionAction:r,isAdditionalFile:i}),this.resetDebounceTimer()}resetDebounceTimer(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.processPendingChanges()},this.DEBOUNCE_DELAY)}async processPendingChanges(){if(this.isProcessing||this.pendingChanges.size===0)return;this.isProcessing=!0;let e=Array.from(this.pendingChanges.values());this.pendingChanges.clear();try{let n=e.filter(e=>e.action===`unlink`),r=e.filter(e=>e.action===`add`||e.action===`change`);n.length>0&&await this.processDeleteChanges(n),r.length>0&&await this.processCompileChanges(r)}catch(e){let n=await _();h.error(n.red(`🚩 Error procesando cambios en batch: ${e instanceof Error?e.message:String(e)}`))}finally{this.isProcessing=!1,this.pendingChanges.size>0&&this.resetDebounceTimer()}}async processDeleteChanges(e){for(let n of e)if(n.isAdditionalFile)h.info(`\n🗑️ Archivo adicional eliminado: ${n.filePath}`),m(this.browserSyncInstance,`reloadFull`,n.filePath);else{h.info(`\n🗑️ Eliminando archivo compilado: ${n.filePath}`);let e=await x(u(n.filePath));e&&(h.info(`Archivo eliminado: ${n.filePath}`),m(this.browserSyncInstance,`reloadFull`,n.filePath))}}async processCompileChanges(e){let n=e.filter(e=>e.isAdditionalFile),r=e.filter(e=>!e.isAdditionalFile);n.length>0&&await this.processAdditionalFiles(n),r.length>0&&await this.processCompilableFiles(r)}async processCompilableFiles(e){let n=await _();for(let r=0;r<e.length;r+=this.BATCH_SIZE){let i=e.slice(r,r+this.BATCH_SIZE);i.length>1&&h.info(n.cyan(`📦 Procesando batch de ${i.length} archivos compilables (${r+1}-${Math.min(r+this.BATCH_SIZE,e.length)} de ${e.length})`));let a=i.map(e=>this.compileFile(e));await Promise.allSettled(a)}e.length>1&&h.info(n.green(`✅ Batch completado: ${e.length} archivos compilados`))}async processAdditionalFiles(e){let n=await _();h.info(n.blue(`🔄 Recargando ${e.length} archivo(s) adicional(es) (sin compilación)`));for(let n of e)h.info(`📄 Archivo adicional modificado: ${n.filePath}`),m(this.browserSyncInstance,`reloadFull`,n.filePath)}async compileFile(e){try{let n=await d(e.filePath,!0,`watch`);if(n.success){let r=n.action||e.extensionAction;r=r===`extension`?e.extensionAction:r,m(this.browserSyncInstance,r||`reloadFull`,n.output)}}catch(n){let r=await _();h.error(r.red(`🚩 Error compilando ${e.filePath}: ${n instanceof Error?n.message:String(n)}`))}}getStats(){return{pendingChanges:this.pendingChanges.size,isProcessing:this.isProcessing,hasTimer:this.debounceTimer!==null}}}const y=new v;export async function cleanOutputDir(c,l=!0){try{if(!c)throw Error(`El directorio de salida no está definido`);if(l){let e=await r(c).catch(()=>null);if(!e||!e.isDirectory()){h.error(`🚩 El directorio de salida no existe o no es un directorio: ${c}`);return}try{if(s.yes===`false`){let e=await _(),n=await p(`
2
+
3
+ ¿Estás seguro deseas limpiar la carpeta `+e.yellow(c)+`? (s / N) : `);if(n.toLowerCase()!==`s`){h.info(`🛑 Compilación cancelada por el usuario.`),o.env.NODE_ENV!==`test`&&o.exit(0);return}}}catch(e){throw h.error(`Error en la entrada del usuario: ${e}`),o.env.NODE_ENV!==`test`&&o.exit(1),e}}let u=await _();h.info(`🗑️ Limpiando directorio de salida: ${u.yellow(c)}\n`);let d=await e(c);await Promise.all(d.map(async e=>{let o=a.join(c,e),s=await r(o);s.isDirectory()?await n(o,{recursive:!0}):await i(o)})),h.info(`✅ Directorio limpiado: ${c}`)}catch(e){h.error(`🚩 Error al limpiar directorio de salida: ${e instanceof Error?e.message:String(e)}`)}}async function x(e){try{return await i(e),!0}catch(n){return h.error(`🚩 Error eliminando archivo ${e}: ${n instanceof Error?n.message:String(n)}`),!1}}function S(e,n){let r=n.filter(e=>e!==void 0).find(n=>n.ext===e.split(`.`).pop())?.action;return r||`reloadFull`}function C(e,n){if(!n||n.length===0)return!1;let r=f(e);return n.some(e=>{let n=e.replace(/\\/g,`/`);return l(r,n)})}export async function initChokidar(e){try{if(!s.PATH_SOURCE)throw h.error(`Error: La variable de entorno PATH_SOURCE no está definida.`),o.env.NODE_ENV!==`test`&&o.exit(1),Error(`PATH_SOURCE no está definida`);let n=`${s.PATH_SOURCE}/**/*.js`,r=`${s.PATH_SOURCE}/**/*.vue`,i=`${s.PATH_SOURCE}/**/*.ts`,a=`${s.PATH_SOURCE}/**/*.cjs`,l=`${s.PATH_SOURCE}/**/*.mjs`,u=JSON.parse(s.aditionalWatch||`[]`),d=[n,r,i,a,l,...u],f={vue:`HRMVue`,js:`HRMHelper`,ts:`HRMHelper`,cjs:`HRMHelper`,mjs:`HRMHelper`},p=d.map(e=>{let n=e.split(`.`).pop();if(n)return{ext:n,action:f[n]||`reloadFull`}});if(p.length===0||p[0]===void 0)throw Error(`No se encontraron extensiones para observar`);let m=RegExp(`\\.(?!${p.filter(e=>e!==void 0).map(e=>e.ext).join(`$|`)}$).+$`);d=d.map(e=>e.replace(/\/\*\*\//g,`/`));let g=new Map;d.forEach(e=>{let n=e.substring(0,e.lastIndexOf(`/`));g.has(n)||g.set(n,[]),g.get(n).push(e)});let v=Array.from(g.keys()),b=c.watch(v,{persistent:!0,ignoreInitial:!0,ignored:m});return b.on(`ready`,async()=>{let e=await _();h.info(e.green(`👀 : Listo para observar \n${d.map(e=>`${e}`).join(`
4
+ `)}\n`))}),y.setBrowserSyncInstance(e),b.on(`add`,async e=>{let n=C(e,u),r=S(e,p.filter(e=>e!==void 0));y.addChange(e,`add`,r,n)}),b.on(`change`,async e=>{let n=C(e,u),r=S(e,p.filter(e=>e!==void 0));y.addChange(e,`change`,r,n)}),b.on(`unlink`,async e=>{let n=S(e,p.filter(e=>e!==void 0)),r=C(e,u);y.addChange(e,`unlink`,n,r)}),b}catch(e){throw h.error(`🚩 :Error al iniciar watch: ${e instanceof Error?e.message:String(e)}`),o.env.NODE_ENV!==`test`&&o.exit(1),e}}
@@ -1,63 +1,3 @@
1
- import * as process from 'node:process';
2
- // Función para obtener ProgressManager (lazy import para evitar dependencias circulares)
3
- let getProgressManager = null;
4
- export function setProgressManagerGetter(getter) {
5
- getProgressManager = getter;
6
- }
7
- class Logger {
8
- constructor() {
9
- // Bind console methods
10
- process.stdout.write = process.stdout.write.bind(process.stdout);
11
- process.stderr.write = process.stderr.write.bind(process.stderr);
12
- }
13
- writeMessage(message, useStderr = false, immediate = false) {
14
- if (getProgressManager) {
15
- const progressManager = getProgressManager();
16
- if (progressManager && progressManager.isActive()) {
17
- // Si el progreso está activo, usar el sistema de logs apropiado
18
- if (immediate) {
19
- progressManager.addImmediateLog(message);
20
- }
21
- else {
22
- progressManager.addLog(message);
23
- }
24
- return;
25
- }
26
- }
27
- // Comportamiento normal si no hay progreso activo
28
- if (useStderr) {
29
- process.stderr.write(message + '\n');
30
- }
31
- else {
32
- process.stdout.write(message + '\n');
33
- }
34
- }
35
- log(...args) {
36
- this.writeMessage(args.map(arg => String(arg)).join(' '));
37
- }
38
- info(...args) {
39
- // En modo verbose, mostrar logs inmediatamente
40
- const isVerbose = process.env.VERBOSE === 'true';
41
- this.writeMessage(args.map(arg => String(arg)).join(' '), false, isVerbose);
42
- }
43
- error(...args) {
44
- this.writeMessage(args.map(arg => String(arg)).join(' '), true);
45
- }
46
- warn(...args) {
47
- this.writeMessage(args.map(arg => String(arg)).join(' '), true);
48
- }
49
- debug(...args) {
50
- this.writeMessage(args.map(arg => String(arg)).join(' '));
51
- }
52
- fatal(...args) {
53
- this.writeMessage(args.map(arg => String(arg)).join(' '), true);
54
- }
55
- table(data, title) {
56
- const tableString = title
57
- ? console.table(data, title)
58
- : console.table(data);
59
- this.writeMessage(String(tableString));
60
- }
61
- }
62
- export const logger = new Logger();
63
- //# sourceMappingURL=logger.js.map
1
+ import*as e from"node:process";let t=null;export function setProgressManagerGetter(e){t=e}class r{constructor(){e.stdout.write=e.stdout.write.bind(e.stdout),e.stderr.write=e.stderr.write.bind(e.stderr)}writeMessage(n,r=!1,i=!1){if(t){let e=t();if(e&&e.isActive()){i?e.addImmediateLog(n):e.addLog(n);return}}r?e.stderr.write(n+`
2
+ `):e.stdout.write(n+`
3
+ `)}log(...e){this.writeMessage(e.map(e=>String(e)).join(` `))}info(...t){let n=e.env.VERBOSE===`true`;this.writeMessage(t.map(e=>String(e)).join(` `),!1,n)}error(...e){this.writeMessage(e.map(e=>String(e)).join(` `),!0)}warn(...e){this.writeMessage(e.map(e=>String(e)).join(` `),!0)}debug(...e){this.writeMessage(e.map(e=>String(e)).join(` `))}fatal(...e){this.writeMessage(e.map(e=>String(e)).join(` `),!0)}table(e,t){let n=t?console.table(e,t):console.table(e);this.writeMessage(String(n))}}export const logger=new r;