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,466 +1,41 @@
1
- /**
2
- * TypeScript Worker Thread - Ejecuta type checking asíncrono
3
- * Este archivo se ejecuta en un worker thread separado para validación de tipos
4
- */
5
-
6
- const fs = require('node:fs');
7
- const path = require('node:path');
8
- const { parentPort } = require('node:worker_threads');
9
-
10
- // Debug: Log de inicio del worker
11
- // console.log('[Worker] TypeScript Worker Thread iniciado');
12
-
13
- let ts;
14
- try {
15
- ts = require('typescript');
16
- // console.log('[Worker] TypeScript cargado exitosamente');
17
- } catch (error) {
18
- console.error('[Worker] Error cargando TypeScript:', error);
19
- process.exit(1);
20
- }
21
-
22
- /**
23
- * Language Service Host para validación de tipos en el worker
24
- */
25
- class WorkerTypeScriptLanguageServiceHost {
26
- constructor(compilerOptions) {
27
- this.files = new Map();
28
- // Crear opciones ultra-limpias para evitar problemas de serialización
29
- this.compilerOptions =
30
- this.createUltraCleanCompilerOptions(compilerOptions);
31
- } /**
32
- * Crea opciones del compilador que respetan la configuración del tsconfig.json
33
- */
34
- createUltraCleanCompilerOptions(options) {
35
- // Usar las opciones del tsconfig.json pasadas desde el hilo principal
36
- const cleanOptions = {
37
- // target: options.target || ts.ScriptTarget.ES2020,
38
- // module: options.module || ts.ModuleKind.ES2020,
39
- // strict: Boolean(options.strict),
40
- // noEmitOnError: Boolean(options.noEmitOnError),
41
- // skipLibCheck: Boolean(options.skipLibCheck !== false), // true por defecto
42
- // skipDefaultLibCheck: Boolean(options.skipDefaultLibCheck !== false), // true por defecto
43
- // allowJs: Boolean(options.allowJs !== false), // true por defecto
44
- // esModuleInterop: Boolean(options.esModuleInterop !== false), // true por defecto
45
- // allowSyntheticDefaultImports: Boolean(
46
- // options.allowSyntheticDefaultImports !== false,
47
- // ), // true por defecto
48
- // declaration: Boolean(options.declaration),
49
- // sourceMap: Boolean(options.sourceMap),
50
- // noImplicitAny: Boolean(options.noImplicitAny),
51
- // noImplicitReturns: Boolean(options.noImplicitReturns),
52
- // noImplicitThis: Boolean(options.noImplicitThis),
53
- // noUnusedLocals: Boolean(options.noUnusedLocals),
54
- // noUnusedParameters: Boolean(options.noUnusedParameters),
55
- // isolatedModules: Boolean(options.isolatedModules !== false), // true por defecto // Usar las librerías especificadas en el tsconfig.json
56
- // lib: Array.isArray(options.lib)
57
- // ? options.lib
58
- // : ['es2020', 'dom', 'dom.iterable'],
59
-
60
- // // Soporte para decorators
61
- // experimentalDecorators: Boolean(
62
- // options.experimentalDecorators !== false,
63
- // ),
64
- // emitDecoratorMetadata: Boolean(
65
- // options.emitDecoratorMetadata !== false,
66
- // ),
67
-
68
- // // Opciones críticas para el worker pero manteniendo compatibilidad
69
- // noLib: false, // Permitir librerías para APIs básicas (DOM, Promise, etc.)
70
- // noResolve: true, // Evitar resolución de módulos compleja pero mantener tipos globales
71
- // suppressOutputPathCheck: true,
72
- // allowNonTsExtensions: true,
73
- ...options,
74
- };
75
-
76
- // console.log(
77
- // '[Worker] Opciones del compilador limpias creadas:',
78
- // Object.keys(cleanOptions),
79
- // );
80
- return cleanOptions;
81
- }
82
-
83
- addFile(fileName, content) {
84
- const existing = this.files.get(fileName);
85
- this.files.set(fileName, {
86
- version: existing ? existing.version + 1 : 1,
87
- content,
88
- });
89
- }
90
-
91
- getCompilationSettings() {
92
- return this.compilerOptions;
93
- }
94
-
95
- getScriptFileNames() {
96
- return Array.from(this.files.keys());
97
- }
98
-
99
- getScriptVersion(fileName) {
100
- const file = this.files.get(fileName);
101
- return file ? file.version.toString() : '0';
102
- }
103
-
104
- getScriptSnapshot(fileName) {
105
- const file = this.files.get(fileName);
106
- if (file) {
107
- return ts.ScriptSnapshot.fromString(file.content);
108
- }
109
-
110
- // Intentar leer el archivo del sistema de archivos para dependencias
111
- if (fs.existsSync(fileName)) {
112
- try {
113
- const content = fs.readFileSync(fileName, 'utf-8');
114
- return ts.ScriptSnapshot.fromString(content);
115
- } catch {
116
- return undefined;
117
- }
118
- }
119
-
120
- return undefined;
121
- }
122
-
123
- getCurrentDirectory() {
124
- return process.cwd();
125
- }
126
-
127
- getDefaultLibFileName(options) {
128
- return ts.getDefaultLibFilePath(options);
129
- }
130
-
131
- fileExists(path) {
132
- return this.files.has(path) || fs.existsSync(path);
133
- }
134
-
135
- readFile(path) {
136
- const file = this.files.get(path);
137
- if (file) {
138
- return file.content;
139
- }
140
-
141
- if (fs.existsSync(path)) {
142
- try {
143
- return fs.readFileSync(path, 'utf-8');
144
- } catch {
145
- return undefined;
146
- }
147
- }
148
-
149
- return undefined;
150
- }
151
-
152
- getNewLine() {
153
- return ts.sys.newLine;
154
- }
155
- }
156
-
157
- /**
158
- * Realiza validación de tipos en el worker thread
159
- */
160
- function validateTypesInWorker(fileName, content, compilerOptions) {
161
- let actualFileName = fileName;
162
- try {
163
- const scriptContent = content;
164
-
165
- // Si el script está vacío o es solo espacios en blanco, no validar
166
- if (!scriptContent.trim()) {
167
- return { diagnostics: [], hasErrors: false };
168
- }
169
-
170
- // Crear Language Service Host
171
- const host = new WorkerTypeScriptLanguageServiceHost(compilerOptions); // Para archivos Vue, crear un archivo virtual .ts
172
- if (fileName.endsWith('.vue')) {
173
- // Crear un nombre de archivo virtual único
174
- const virtualFileName = `${fileName}.ts`;
175
- host.addFile(virtualFileName, scriptContent);
176
- actualFileName = virtualFileName;
177
- // console.log('[Worker] Archivo Vue agregado como:', virtualFileName);
178
- } else {
179
- // Para archivos virtuales, usar el nombre tal como viene
180
- host.addFile(fileName, scriptContent);
181
- actualFileName = fileName;
182
- // console.log('[Worker] Archivo agregado como:', fileName);
183
- }
184
-
185
- // console.log(
186
- // '[Worker] Contenido del archivo:',
187
- // scriptContent.substring(0, 100) + '...',
188
- // );
189
- // console.log('[Worker] Archivos en host:', host.getScriptFileNames());
190
-
191
- // Agregar declaraciones básicas de tipos para Vue si es necesario
192
- if (fileName.endsWith('.vue')) {
193
- // Usar el directorio del archivo actual para las declaraciones
194
- const projectDir = path.dirname(actualFileName);
195
- const vueTypesPath = path.join(projectDir, 'vue-types.d.ts');
196
- const vueTypesDeclaration = `// Declaraciones de tipos Vue para validación
197
- declare global {
198
- function ref<T>(value: T): { value: T };
199
- function reactive<T extends object>(target: T): T;
200
- function computed<T>(getter: () => T): { value: T };
201
- function defineComponent<T>(options: T): T;
202
- function defineProps<T = {}>(): T;
203
- function defineEmits<T = {}>(): T;
204
- function defineExpose<T = {}>(exposed: T): void;
205
- function mergeModels<T>(models: T): T;
206
- function provide<T>(key: string | symbol, value: T): void;
207
- function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
208
- function useSlots(): { [key: string]: (...args: any[]) => any };
209
- function useAttrs(): { [key: string]: any };
210
- function useModel<T>(modelName: string): { value: T };
211
- function onMounted(fn: () => void): void;
212
- function onUnmounted(fn: () => void): void;
213
- function watch<T>(source: () => T, callback: (newValue: T, oldValue: T) => void): void;
214
- }
215
- export {};`;
216
- host.addFile(vueTypesPath, vueTypesDeclaration);
217
- }
218
-
219
- // Crear Language Service
220
- const languageService = ts.createLanguageService(host);
221
-
222
- try {
223
- // Verificar que el archivo existe en el host antes de solicitar diagnósticos
224
- if (!host.fileExists(actualFileName)) {
225
- return { diagnostics: [], hasErrors: false };
226
- }
227
-
228
- // Obtener diagnósticos de tipos con manejo de errores
229
- let syntacticDiagnostics = [];
230
- let semanticDiagnostics = [];
231
- try {
232
- syntacticDiagnostics =
233
- languageService.getSyntacticDiagnostics(actualFileName);
234
- // console.log(
235
- // '[Worker] Diagnósticos sintácticos:',
236
- // syntacticDiagnostics.length,
237
- // );
238
- } catch (error) {
239
- console.error(
240
- '[Worker] Error obteniendo diagnósticos sintácticos:',
241
- error.message,
242
- );
243
- }
244
-
245
- try {
246
- semanticDiagnostics =
247
- languageService.getSemanticDiagnostics(actualFileName);
248
- // console.log(
249
- // '[Worker] Diagnósticos semánticos:',
250
- // semanticDiagnostics.length,
251
- // );
252
- } catch (error) {
253
- console.error(
254
- '[Worker] Error obteniendo diagnósticos semánticos:',
255
- error.message,
256
- );
257
- } // Combinar todos los diagnósticos
258
- const allDiagnostics = [
259
- ...syntacticDiagnostics,
260
- ...semanticDiagnostics,
261
- ];
262
-
263
- // console.log(
264
- // '[Worker] Total diagnósticos encontrados:',
265
- // allDiagnostics.length,
266
- // );
267
-
268
- // Log de todos los diagnósticos antes del filtrado
269
- // allDiagnostics.forEach((diag, index) => {
270
- // const messageText = ts.flattenDiagnosticMessageText(
271
- // diag.messageText,
272
- // '\n',
273
- // );
274
- // console.log(
275
- // `[Worker] Diagnóstico ${index + 1}: [${diag.category}] ${messageText}`,
276
- // );
277
- // });
278
-
279
- // Filtrar diagnósticos relevantes
280
- const filteredDiagnostics = allDiagnostics.filter(diag => {
281
- const messageText = ts.flattenDiagnosticMessageText(
282
- diag.messageText,
283
- '\n',
284
- );
285
-
286
- // Solo errores de categoría Error
287
- if (diag.category !== ts.DiagnosticCategory.Error) {
288
- return false;
289
- } // Ignorar SOLO errores específicos de infraestructura Vue y rutas de módulos
290
- return (
291
- !messageText.includes('Cannot find module') &&
292
- !messageText.includes('Could not find source file') &&
293
- !messageText.includes(
294
- "has no exported member 'mergeModels'",
295
- ) &&
296
- !messageText.includes(
297
- "Parameter '$props' implicitly has an 'any' type",
298
- ) &&
299
- !messageText.includes(
300
- "Parameter '$setup' implicitly has an 'any' type",
301
- ) &&
302
- !messageText.includes(
303
- "Parameter '$data' implicitly has an 'any' type",
304
- ) &&
305
- !messageText.includes(
306
- "Parameter '$options' implicitly has an 'any' type",
307
- ) &&
308
- !messageText.includes(
309
- "Parameter '$event' implicitly has an 'any' type",
310
- ) &&
311
- !messageText.includes(
312
- "Parameter '_ctx' implicitly has an 'any' type",
313
- ) &&
314
- !messageText.includes(
315
- "Parameter '_cache' implicitly has an 'any' type",
316
- ) &&
317
- // Ignorar errores específicos de decorators cuando están mal configurados
318
- !messageText.includes(
319
- 'Unable to resolve signature of method decorator when called as an expression',
320
- ) &&
321
- !messageText.includes(
322
- 'The runtime will invoke the decorator with',
323
- ) &&
324
- // NO ignorar errores TS7031 y TS7006 de forma general, solo para parámetros específicos de Vue
325
- // diag.code !== 7031 &&
326
- // diag.code !== 7006 &&
327
- // Ignorar errores TS1241 (decorator signature mismatch) durante desarrollo
328
- diag.code !== 1241 &&
329
- !(
330
- messageText.includes("implicitly has an 'any' type") &&
331
- (messageText.includes('_ctx') ||
332
- messageText.includes('_cache') ||
333
- messageText.includes('$props') ||
334
- messageText.includes('$setup') ||
335
- messageText.includes('__expose') ||
336
- messageText.includes('__emit'))
337
- )
338
- );
339
- });
340
-
341
- return {
342
- diagnostics: filteredDiagnostics,
343
- hasErrors: filteredDiagnostics.length > 0,
344
- };
345
- } catch {
346
- return { diagnostics: [], hasErrors: false };
347
- }
348
- } catch (error) {
349
- // En caso de error, devolver diagnóstico de error
350
- const errorDiagnostic = {
351
- file: undefined,
352
- start: undefined,
353
- length: undefined,
354
- messageText: `Error en validación de tipos: ${error instanceof Error ? error.message : 'Error desconocido'}`,
355
- category: ts.DiagnosticCategory.Error,
356
- code: 0,
357
- };
358
-
359
- return {
360
- diagnostics: [errorDiagnostic],
361
- hasErrors: true,
362
- };
363
- }
364
- }
365
-
366
- // Escuchar mensajes del proceso principal
367
- if (parentPort) {
368
- parentPort.on('message', message => {
369
- try {
370
- // console.log('[Worker] Mensaje recibido:', {
371
- // id: message.id,
372
- // fileName: message.fileName,
373
- // contentLength: message.content?.length,
374
- // compilerOptions: Object.keys(message.compilerOptions || {}),
375
- // });
376
-
377
- const { id, fileName, content, compilerOptions } = message;
378
-
379
- // Validar que el mensaje tiene la estructura correcta
380
- if (!id || !fileName || typeof content !== 'string') {
381
- parentPort.postMessage({
382
- id: id || 'unknown',
383
- success: false,
384
- error: 'Mensaje del worker inválido',
385
- });
386
- return;
387
- }
388
-
389
- // Realizar validación de tipos
390
- const result = validateTypesInWorker(
391
- fileName,
392
- content,
393
- compilerOptions,
394
- ); // Serializar diagnósticos de forma segura
395
- const serializableDiagnostics = result.diagnostics.map(diag => ({
396
- category: diag.category,
397
- code: diag.code,
398
- messageText:
399
- typeof diag.messageText === 'string'
400
- ? diag.messageText
401
- : ts.flattenDiagnosticMessageText(
402
- diag.messageText,
403
- '\n',
404
- ),
405
- file: diag.file
406
- ? {
407
- fileName: diag.file.fileName,
408
- text: diag.file.text,
409
- }
410
- : undefined,
411
- start: diag.start,
412
- length: diag.length,
413
- }));
414
-
415
- // Enviar respuesta al proceso principal
416
- // console.log('[Worker] Enviando respuesta:', {
417
- // id,
418
- // success: true,
419
- // diagnosticsCount: serializableDiagnostics.length,
420
- // hasErrors: result.hasErrors,
421
- // });
422
-
423
- parentPort.postMessage({
424
- id,
425
- success: true,
426
- diagnostics: serializableDiagnostics,
427
- hasErrors: result.hasErrors,
428
- });
429
- } catch (error) {
430
- // Enviar error al proceso principal
431
- parentPort.postMessage({
432
- id: message?.id || 'unknown',
433
- success: false,
434
- error:
435
- error instanceof Error
436
- ? error.message
437
- : 'Error desconocido en worker',
438
- });
439
- }
440
- });
441
- }
442
-
443
- // Manejar errores no capturados en el worker
444
- process.on('uncaughtException', error => {
445
- console.error('[Worker] Error no capturado en TypeScript worker:', error);
446
- if (parentPort) {
447
- parentPort.postMessage({
448
- id: 'error',
449
- success: false,
450
- error: `Error crítico en worker: ${error.message}`,
451
- });
452
- }
453
- process.exit(1);
454
- });
455
-
456
- // Log de confirmación de que el worker está listo
457
- // console.log('[Worker] TypeScript Worker Thread listo para recibir mensajes');
458
-
459
- // Señal de que el worker está listo
460
- if (parentPort) {
461
- parentPort.postMessage({
462
- id: 'worker-ready',
463
- success: true,
464
- message: 'TypeScript worker iniciado correctamente',
465
- });
466
- }
1
+ const e=require(`node:fs`),t=require(`node:path`),{parentPort:n}=require(`node:worker_threads`);let r;try{r=require(`typescript`)}catch(e){console.error(`[Worker] Error cargando TypeScript:`,e),process.exit(1)}class i{constructor(e){this.files=new Map,this.compilerOptions=this.createUltraCleanCompilerOptions(e)}createUltraCleanCompilerOptions(e){let t={...e};return t}addFile(e,t){let n=this.files.get(e);this.files.set(e,{version:n?n.version+1:1,content:t})}getCompilationSettings(){return this.compilerOptions}getScriptFileNames(){return Array.from(this.files.keys())}getScriptVersion(e){let t=this.files.get(e);return t?t.version.toString():`0`}getScriptSnapshot(t){let n=this.files.get(t);if(n)return r.ScriptSnapshot.fromString(n.content);if(e.existsSync(t))try{let n=e.readFileSync(t,`utf-8`);return r.ScriptSnapshot.fromString(n)}catch{return}}getCurrentDirectory(){return process.cwd()}getDefaultLibFileName(e){return r.getDefaultLibFilePath(e)}fileExists(t){return this.files.has(t)||e.existsSync(t)}readFile(t){let n=this.files.get(t);if(n)return n.content;if(e.existsSync(t))try{return e.readFileSync(t,`utf-8`)}catch{return}}getNewLine(){return r.sys.newLine}}function a(e,n,a){let o=e;try{let s=n;if(!s.trim())return{diagnostics:[],hasErrors:!1};let c=new i(a);if(e.endsWith(`.vue`)){let t=`${e}.ts`;c.addFile(t,s),o=t}else c.addFile(e,s),o=e;if(e.endsWith(`.vue`)){let e=t.dirname(o),n=t.join(e,`vue-types.d.ts`),r=`// Declaraciones de tipos Vue para validación
2
+ declare global {
3
+ function ref<T>(value: T): { value: T };
4
+ function reactive<T extends object>(target: T): T;
5
+ function computed<T>(getter: () => T): { value: T };
6
+ function defineComponent<T>(options: T): T;
7
+ function defineProps<T = {}>(): T;
8
+ function defineEmits<T = {}>(): T;
9
+ function defineExpose<T = {}>(exposed: T): void;
10
+ function mergeModels<T>(models: T): T;
11
+ function provide<T>(key: string | symbol, value: T): void;
12
+ function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
13
+ function useSlots(): { [key: string]: (...args: any[]) => any };
14
+ function useAttrs(): { [key: string]: any };
15
+ function useModel<T>(modelName: string): { value: T };
16
+ function onMounted(fn: () => void): void;
17
+ function onUnmounted(fn: () => void): void;
18
+ function watch<T>(source: () => T, callback: (newValue: T, oldValue: T) => void): void;
19
+ }
20
+ export {};`;c.addFile(n,`// Declaraciones de tipos Vue para validación
21
+ declare global {
22
+ function ref<T>(value: T): { value: T };
23
+ function reactive<T extends object>(target: T): T;
24
+ function computed<T>(getter: () => T): { value: T };
25
+ function defineComponent<T>(options: T): T;
26
+ function defineProps<T = {}>(): T;
27
+ function defineEmits<T = {}>(): T;
28
+ function defineExpose<T = {}>(exposed: T): void;
29
+ function mergeModels<T>(models: T): T;
30
+ function provide<T>(key: string | symbol, value: T): void;
31
+ function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
32
+ function useSlots(): { [key: string]: (...args: any[]) => any };
33
+ function useAttrs(): { [key: string]: any };
34
+ function useModel<T>(modelName: string): { value: T };
35
+ function onMounted(fn: () => void): void;
36
+ function onUnmounted(fn: () => void): void;
37
+ function watch<T>(source: () => T, callback: (newValue: T, oldValue: T) => void): void;
38
+ }
39
+ export {};`)}let l=r.createLanguageService(c);try{if(!c.fileExists(o))return{diagnostics:[],hasErrors:!1};let e=[],t=[];try{e=l.getSyntacticDiagnostics(o)}catch(e){console.error(`[Worker] Error obteniendo diagnósticos sintácticos:`,e.message)}try{t=l.getSemanticDiagnostics(o)}catch(e){console.error(`[Worker] Error obteniendo diagnósticos semánticos:`,e.message)}let n=[...e,...t],i=n.filter(e=>{let t=r.flattenDiagnosticMessageText(e.messageText,`
40
+ `);return e.category===r.DiagnosticCategory.Error?!t.includes(`Cannot find module`)&&!t.includes(`Could not find source file`)&&!t.includes(`has no exported member 'mergeModels'`)&&!t.includes(`Parameter '$props' implicitly has an 'any' type`)&&!t.includes(`Parameter '$setup' implicitly has an 'any' type`)&&!t.includes(`Parameter '$data' implicitly has an 'any' type`)&&!t.includes(`Parameter '$options' implicitly has an 'any' type`)&&!t.includes(`Parameter '$event' implicitly has an 'any' type`)&&!t.includes(`Parameter '_ctx' implicitly has an 'any' type`)&&!t.includes(`Parameter '_cache' implicitly has an 'any' type`)&&!t.includes(`Unable to resolve signature of method decorator when called as an expression`)&&!t.includes(`The runtime will invoke the decorator with`)&&e.code!==1241&&!(t.includes(`implicitly has an 'any' type`)&&(t.includes(`_ctx`)||t.includes(`_cache`)||t.includes(`$props`)||t.includes(`$setup`)||t.includes(`__expose`)||t.includes(`__emit`))):!1});return{diagnostics:i,hasErrors:i.length>0}}catch{return{diagnostics:[],hasErrors:!1}}}catch(e){let t={file:void 0,start:void 0,length:void 0,messageText:`Error en validación de tipos: ${e instanceof Error?e.message:`Error desconocido`}`,category:r.DiagnosticCategory.Error,code:0};return{diagnostics:[t],hasErrors:!0}}}n&&n.on(`message`,e=>{try{let{id:t,fileName:i,content:o,compilerOptions:s}=e;if(!t||!i||typeof o!=`string`){n.postMessage({id:t||`unknown`,success:!1,error:`Mensaje del worker inválido`});return}let c=a(i,o,s),l=c.diagnostics.map(e=>({category:e.category,code:e.code,messageText:typeof e.messageText==`string`?e.messageText:r.flattenDiagnosticMessageText(e.messageText,`
41
+ `),file:e.file?{fileName:e.file.fileName,text:e.file.text}:void 0,start:e.start,length:e.length}));n.postMessage({id:t,success:!0,diagnostics:l,hasErrors:c.hasErrors})}catch(t){n.postMessage({id:e?.id||`unknown`,success:!1,error:t instanceof Error?t.message:`Error desconocido en worker`})}}),process.on(`uncaughtException`,e=>{console.error(`[Worker] Error no capturado en TypeScript worker:`,e),n&&n.postMessage({id:`error`,success:!1,error:`Error crítico en worker: ${e.message}`}),process.exit(1)}),n&&n.postMessage({id:`worker-ready`,success:!0,message:`TypeScript worker iniciado correctamente`});