versacompiler 2.5.0 → 2.6.0

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 (49) hide show
  1. package/dist/compiler/compile-worker-pool.js +12 -0
  2. package/dist/compiler/compile.js +97 -17
  3. package/dist/compiler/error-reporter.js +12 -0
  4. package/dist/compiler/integrity-validator.js +12 -0
  5. package/dist/compiler/linter.js +12 -0
  6. package/dist/compiler/minify.js +12 -0
  7. package/dist/compiler/minifyTemplate.js +12 -0
  8. package/dist/compiler/module-resolution-optimizer.js +13 -1
  9. package/dist/compiler/parser.js +12 -0
  10. package/dist/compiler/performance-monitor.js +12 -0
  11. package/dist/compiler/pipeline/build-pipeline.js +12 -0
  12. package/dist/compiler/pipeline/core-plugins.js +12 -0
  13. package/dist/compiler/pipeline/module-graph.js +12 -0
  14. package/dist/compiler/pipeline/plugin-driver.js +12 -0
  15. package/dist/compiler/pipeline/types.js +12 -0
  16. package/dist/compiler/tailwindcss.js +12 -0
  17. package/dist/compiler/transform-optimizer.js +12 -0
  18. package/dist/compiler/transformTStoJS.js +38 -5
  19. package/dist/compiler/transforms.js +12 -0
  20. package/dist/compiler/typescript-compiler.js +12 -0
  21. package/dist/compiler/typescript-error-parser.js +12 -0
  22. package/dist/compiler/typescript-manager.js +12 -0
  23. package/dist/compiler/typescript-sync-validator.js +12 -0
  24. package/dist/compiler/typescript-worker-pool.js +12 -0
  25. package/dist/compiler/typescript-worker.js +12 -0
  26. package/dist/compiler/vuejs.js +41 -15
  27. package/dist/config.js +12 -0
  28. package/dist/hrm/VueHRM.js +132 -7
  29. package/dist/hrm/errorScreen.js +12 -0
  30. package/dist/hrm/getInstanciaVue.js +12 -0
  31. package/dist/hrm/initHRM.js +117 -9
  32. package/dist/hrm/versaHMR.js +317 -0
  33. package/dist/main.js +21 -2
  34. package/dist/servicios/browserSync.js +119 -4
  35. package/dist/servicios/file-watcher.js +104 -15
  36. package/dist/servicios/logger.js +12 -0
  37. package/dist/servicios/readConfig.js +13 -1
  38. package/dist/servicios/versacompile.config.types.js +12 -0
  39. package/dist/utils/excluded-modules.js +12 -0
  40. package/dist/utils/module-resolver.js +12 -0
  41. package/dist/utils/promptUser.js +12 -0
  42. package/dist/utils/proxyValidator.js +12 -0
  43. package/dist/utils/resolve-bin.js +12 -0
  44. package/dist/utils/utils.js +12 -0
  45. package/dist/utils/vue-types-setup.js +14 -2
  46. package/dist/wrappers/eslint-node.js +12 -0
  47. package/dist/wrappers/oxlint-node.js +12 -0
  48. package/dist/wrappers/tailwind-node.js +12 -0
  49. package/package.json +4 -3
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import * as os from 'node:os';
2
14
  import * as path from 'node:path';
3
15
  import * as process from 'node:process';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { createHash } from 'node:crypto';
2
14
  import { glob, mkdir, readFile, stat, unlink, writeFile, } from 'node:fs/promises';
3
15
  import * as os from 'node:os';
@@ -74,18 +86,22 @@ class OptimizedModuleManager {
74
86
  }
75
87
  /**
76
88
  * ✨ NUEVO: Precarga módulos críticos en background
89
+ * Cada módulo se precarga de forma independiente con su propio try-catch
90
+ * para que un fallo individual no rechace toda la Promise raíz.
77
91
  */
78
92
  async preloadCriticalModules() {
79
- try {
80
- // Precargar módulos críticos de forma asíncrona
81
- const preloadPromises = this.HOT_MODULES.map(moduleName => this.ensureModuleLoaded(moduleName).catch(() => {
82
- // Silenciar errores de precarga, se intentará cargar después
83
- }));
84
- await Promise.allSettled(preloadPromises);
85
- }
86
- catch {
87
- // Fallos en precarga no deben afectar la funcionalidad principal
88
- }
93
+ const preloadPromises = this.HOT_MODULES.map(async (moduleName) => {
94
+ try {
95
+ await this.ensureModuleLoaded(moduleName);
96
+ }
97
+ catch {
98
+ // Fallo individual no debe afectar otros módulos ni la Promise raíz
99
+ if (env.VERBOSE === 'true') {
100
+ console.warn(`[ModuleManager] Precarga fallida para '${moduleName}', se intentará al primer uso`);
101
+ }
102
+ }
103
+ });
104
+ await Promise.all(preloadPromises);
89
105
  }
90
106
  /**
91
107
  * ✨ MEJORADO: Precarga contextual basada en tipos de archivo con lock para prevenir cargas concurrentes
@@ -352,21 +368,25 @@ class OptimizedModuleManager {
352
368
  if (currentMemory > this.MAX_POOL_MEMORY ||
353
369
  currentSize > this.MAX_POOL_SIZE) {
354
370
  // LRU: Ordenar por menos usado
355
- const sortedModules = Array.from(this.usageStats.entries())
356
- .sort((a, b) => a[1] - b[1]) // Ascendente por uso
357
- .filter(([name]) => !this.HOT_MODULES.includes(name)); // No eliminar HOT_MODULES
371
+ const sortedModules = Array.from(this.usageStats.entries()).sort((a, b) => a[1] - b[1]); // Ascendente por uso
358
372
  // Eliminar módulos hasta estar por debajo del 70% del límite
359
373
  const targetMemory = this.MAX_POOL_MEMORY * 0.7;
360
374
  const targetSize = this.MAX_POOL_SIZE * 0.7;
375
+ const criticalPressure = currentMemory > this.MAX_POOL_MEMORY * 0.9;
361
376
  for (const [moduleName] of sortedModules) {
362
- this.modulePool.delete(moduleName);
363
- this.loadedModules.delete(moduleName);
364
- this.usageStats.delete(moduleName);
365
377
  const newMemory = this.getPoolMemoryUsage();
366
378
  const newSize = this.modulePool.size;
367
379
  if (newMemory <= targetMemory && newSize <= targetSize) {
368
380
  break;
369
381
  }
382
+ // HOT_MODULES solo se desalojan si la presión de memoria es crítica (>90%)
383
+ if (this.HOT_MODULES.includes(moduleName) &&
384
+ !criticalPressure) {
385
+ continue;
386
+ }
387
+ this.modulePool.delete(moduleName);
388
+ this.loadedModules.delete(moduleName);
389
+ this.usageStats.delete(moduleName);
370
390
  }
371
391
  if (env.VERBOSE === 'true') {
372
392
  console.log(`[ModuleManager] Limpieza: ${currentSize} → ${this.modulePool.size} módulos, ` +
@@ -1609,6 +1629,59 @@ export async function runPipelineHotUpdate(filePath, type) {
1609
1629
  }
1610
1630
  return getBuildPipeline().hotUpdate({ path: filePath, type });
1611
1631
  }
1632
+ /**
1633
+ * Extrae los imports locales (rutas absolutas con /) del código compilado.
1634
+ * Solo imports estáticos de rutas absolutas del proyecto (excluye /node_modules/).
1635
+ */
1636
+ function extractLocalImports(code) {
1637
+ const imports = [];
1638
+ const importRegex = /(?:from|import)\s+['"](\/((?!node_modules)[^'"?#]+\.js))['"]/g;
1639
+ let match;
1640
+ while ((match = importRegex.exec(code)) !== null) {
1641
+ const importPath = match[1];
1642
+ if (importPath && !imports.includes(importPath)) {
1643
+ imports.push(importPath);
1644
+ }
1645
+ }
1646
+ return imports;
1647
+ }
1648
+ /**
1649
+ * Inyecta el shim de import.meta.hot al inicio de archivos JS compilados en modo dev.
1650
+ * Adicionalmente registra accept() para cada dependencia local: cuando una dependencia
1651
+ * se actualiza en versaHMR, el módulo actual se re-importa con timestamp nuevo,
1652
+ * forzando al browser a crear un nuevo module record con la dependencia actualizada.
1653
+ * Solo se llama cuando env.isPROD !== 'true' y la salida es un archivo .js.
1654
+ */
1655
+ function injectHmrShim(code) {
1656
+ const localImports = extractLocalImports(code);
1657
+ // Detecta si es un Vue SFC (el compilador Vue inyecta 'data-versa-hmr-component')
1658
+ const isVueComponent = code.includes('data-versa-hmr-component');
1659
+ const depsAccept = localImports.length > 0
1660
+ ? localImports
1661
+ .map(dep => {
1662
+ if (isVueComponent) {
1663
+ // Vue SFC: tras actualizar dependencia, re-cargar instancia Vue en DOM
1664
+ return ` window.__versaHMR.accept(${JSON.stringify(dep)}, async () => { await window.__versaHMR._reloadVueByPath?.(_id); });`;
1665
+ }
1666
+ // Módulo JS/TS plano: re-importar con nuevo timestamp para actualizar module record
1667
+ return ` window.__versaHMR.accept(${JSON.stringify(dep)}, () => { import(_id + '?t=' + Date.now()); });`;
1668
+ })
1669
+ .join('\n') + '\n'
1670
+ : '';
1671
+ const shim = `/* VersaCompiler HMR shim [dev] */
1672
+ if (typeof window !== 'undefined' && window.__versaHMR) {
1673
+ (() => {
1674
+ const _id = new URL(import.meta.url).pathname;
1675
+ import.meta.hot = {
1676
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
1677
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
1678
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
1679
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
1680
+ };
1681
+ ${depsAccept} })();
1682
+ }\n`;
1683
+ return shim + code;
1684
+ }
1612
1685
  async function compileWithPipeline(inPath, outPath, mode = 'individual') {
1613
1686
  const pipeline = getBuildPipeline();
1614
1687
  const result = await pipeline.compileFile(inPath);
@@ -1624,7 +1697,11 @@ async function compileWithPipeline(inPath, outPath, mode = 'individual') {
1624
1697
  }
1625
1698
  const destinationDir = path.dirname(outPath);
1626
1699
  await mkdir(destinationDir, { recursive: true });
1627
- await writeFile(outPath, result.code, 'utf-8');
1700
+ let pipelineCode = result.code;
1701
+ if (env.isPROD !== 'true' && outPath.endsWith('.js')) {
1702
+ pipelineCode = injectHmrShim(pipelineCode);
1703
+ }
1704
+ await writeFile(outPath, pipelineCode, 'utf-8');
1628
1705
  if (result.dependencies.length > 0) {
1629
1706
  smartCache.registerDependencies(inPath, result.dependencies);
1630
1707
  }
@@ -1803,6 +1880,9 @@ async function compileJS(inPath, outPath, mode = 'individual') {
1803
1880
  } // Escribir archivo final
1804
1881
  const destinationDir = path.dirname(outPath);
1805
1882
  await mkdir(destinationDir, { recursive: true });
1883
+ if (env.isPROD !== 'true' && outPath.endsWith('.js')) {
1884
+ code = injectHmrShim(code);
1885
+ }
1806
1886
  await writeFile(outPath, code, 'utf-8');
1807
1887
  // Logs de timing detallados en modo verbose
1808
1888
  if (shouldShowDetailedLogs) {
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  // Lazy loading optimizations - Only import lightweight modules synchronously
2
14
  // Heavy dependencies will be loaded dynamically when needed
3
15
  let chalk;
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { parseSync } from 'oxc-parser';
2
14
  import { logger } from '../servicios/logger.js';
3
15
  /**
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { env } from 'node:process';
2
14
  import { logger } from '../servicios/logger.js';
3
15
  import { ESLintNode, } from './../wrappers/eslint-node.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { createHash } from 'node:crypto';
2
14
  import { minifySync } from 'oxc-minify';
3
15
  import { logger } from '../servicios/logger.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { minifyHTMLLiterals } from 'minify-html-literals';
2
14
  import { logger } from '../servicios/logger.js';
3
15
  import { integrityValidator } from './integrity-validator.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  /**
2
14
  * Module Resolution Optimizer
3
15
  *
@@ -123,7 +135,7 @@ export class ModuleResolutionOptimizer {
123
135
  for (const entry of entries) {
124
136
  const modulePath = join(nodeModulesPath, entry);
125
137
  try {
126
- if (entry.startsWith('/dist')) {
138
+ if (entry.startsWith('/dist/public')) {
127
139
  // Scoped packages
128
140
  const scopedModules = readdirSync(modulePath);
129
141
  this.metrics.filesystemAccess++;
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { createHash } from 'node:crypto';
2
14
  import { statSync } from 'node:fs';
3
15
  import { open, readFile } from 'node:fs/promises';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  /**
2
14
  * Performance Monitor - Sistema centralizado de monitoreo de optimizaciones
3
15
  * Reúne todas las métricas de cache y performance del VersaCompiler
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { stat } from 'node:fs/promises';
2
14
  import path from 'node:path';
3
15
  import { parser } from '../parser.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import path from 'node:path';
2
14
  import { env } from 'node:process';
3
15
  import { logger } from '../../servicios/logger.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  export class ModuleGraph {
2
14
  nodes = new Map();
3
15
  getNode(id) {
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  export class PluginDriver {
2
14
  plugins;
3
15
  constructor(plugins) {
@@ -1,2 +1,14 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  export {};
2
14
  //# sourceMappingURL=types.js.map
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { env } from 'node:process';
2
14
  import { logger } from '../servicios/logger.js';
3
15
  import { TailwindNode } from '../wrappers/tailwind-node.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  /**
2
14
  * Transform Optimizer - Sistema de optimización de transformaciones AST
3
15
  * Implementa procesamiento paralelo y caching inteligente para transformaciones
@@ -1,16 +1,49 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { transform } from '/node_modules/oxc-transform/browser.js';
2
- export async function traspileTStoJS(filePath, sourceCode) {
14
+ export async function transpileTStoJS(filePath, sourceCode) {
3
15
  try {
4
16
  const { code: outputText, declaration, errors: diagnostics, } = await transform(filePath, sourceCode);
17
+ // Si oxc-transform devuelve código vacío ante una entrada no vacía,
18
+ // usar el fuente original como fallback para no corromper el pipeline.
19
+ if (!outputText && sourceCode.trim()) {
20
+ return {
21
+ outputText: sourceCode,
22
+ declaration: declaration || '',
23
+ diagnostics: [
24
+ `Warning: oxc-transform produjo salida vacía para ${filePath}, usando fuente original`,
25
+ ...(diagnostics ?? []).map(d => typeof d === 'string' ? d : JSON.stringify(d)),
26
+ ],
27
+ };
28
+ }
5
29
  return {
6
- outputText: outputText,
30
+ outputText: outputText ?? sourceCode,
7
31
  declaration: declaration || '',
8
- diagnostics: diagnostics || [],
32
+ diagnostics: (diagnostics ?? []).map(d => typeof d === 'string' ? d : JSON.stringify(d)),
9
33
  };
10
34
  }
11
35
  catch (error) {
12
- console.error(`Error transpiling ${filePath}:`, error);
13
- return { outputText: '', declaration: '', diagnostics: [error] };
36
+ const errorMsg = error instanceof Error ? error.message : String(error);
37
+ // Fallback al fuente original para que el pipeline no reciba código vacío
38
+ return {
39
+ outputText: sourceCode,
40
+ declaration: '',
41
+ diagnostics: [
42
+ `Error durante transpilación de ${filePath}: ${errorMsg}. Usando fuente original.`,
43
+ ],
44
+ };
14
45
  }
15
46
  }
47
+ /** @deprecated Usar transpileTStoJS (corrección de typo histórico) */
48
+ export const traspileTStoJS = transpileTStoJS;
16
49
  //# sourceMappingURL=transformTStoJS.js.map
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import path from 'node:path';
2
14
  import { env } from 'node:process';
3
15
  import { logger } from '../servicios/logger.js';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import fs from 'node:fs';
2
14
  import path from 'node:path';
3
15
  import * as process from 'node:process';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import { readFileSync } from 'node:fs';
2
14
  import * as typescript from 'typescript';
3
15
  /**
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  import fs from 'node:fs';
2
14
  import path from 'node:path';
3
15
  import * as process from 'node:process';
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  /**
2
14
  * TypeScript Sync Validator - Validación síncrona de tipos como fallback
3
15
  * Contiene la lógica extraída del módulo principal para cuando el worker no está disponible
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  /**
2
14
  * TypeScript Worker Pool - Pool de workers para compilación paralela
3
15
  * Reemplaza el worker único con múltiples workers para aprovecha la concurrencia real
@@ -1,3 +1,15 @@
1
+ /* VersaCompiler HMR shim [dev] */
2
+ if (typeof window !== 'undefined' && window.__versaHMR) {
3
+ (() => {
4
+ const _id = new URL(import.meta.url).pathname;
5
+ import.meta.hot = {
6
+ accept(cb) { window.__versaHMR.accept(_id, typeof cb === 'function' ? cb : () => {}); },
7
+ invalidate() { window.__versaHMR._invalidate?.(_id); },
8
+ dispose(cb) { window.__versaHMR._onDispose?.(_id, cb); },
9
+ get data() { return window.__versaHMR._getHotData?.(_id) ?? {}; },
10
+ };
11
+ })();
12
+ }
1
13
  /**
2
14
  * TypeScript Worker Manager - Gestiona workers dedicados para type checking asíncrono
3
15
  * Implementa el patrón Singleton para reutilizar workers entre compilaciones