versacompiler 2.4.0 → 2.5.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 (33) hide show
  1. package/README.md +722 -722
  2. package/dist/compiler/compile-worker-pool.js +96 -0
  3. package/dist/compiler/compile-worker-thread.cjs +72 -0
  4. package/dist/compiler/compile.js +81 -2
  5. package/dist/compiler/integrity-validator.js +1 -1
  6. package/dist/compiler/module-resolution-optimizer.js +23 -20
  7. package/dist/compiler/performance-monitor.js +61 -61
  8. package/dist/compiler/pipeline/build-pipeline.js +127 -0
  9. package/dist/compiler/pipeline/core-plugins.js +218 -0
  10. package/dist/compiler/pipeline/module-graph.js +63 -0
  11. package/dist/compiler/pipeline/plugin-driver.js +87 -0
  12. package/dist/compiler/pipeline/types.js +2 -0
  13. package/dist/compiler/transforms.js +222 -16
  14. package/dist/compiler/typescript-manager.js +3 -1
  15. package/dist/compiler/typescript-sync-validator.js +33 -31
  16. package/dist/compiler/typescript-worker-pool.js +66 -19
  17. package/dist/compiler/typescript-worker-thread.cjs +482 -469
  18. package/dist/compiler/vuejs.js +32 -32
  19. package/dist/config.js +2 -0
  20. package/dist/hrm/VueHRM.js +359 -359
  21. package/dist/hrm/errorScreen.js +83 -83
  22. package/dist/hrm/getInstanciaVue.js +313 -313
  23. package/dist/hrm/initHRM.js +628 -586
  24. package/dist/main.js +2 -1
  25. package/dist/servicios/browserSync.js +8 -2
  26. package/dist/servicios/file-watcher.js +48 -6
  27. package/dist/servicios/readConfig.js +129 -54
  28. package/dist/servicios/versacompile.config.types.js +2 -0
  29. package/dist/utils/module-resolver.js +74 -40
  30. package/dist/utils/vue-types-setup.js +248 -248
  31. package/dist/wrappers/eslint-node.js +3 -1
  32. package/dist/wrappers/oxlint-node.js +3 -1
  33. package/package.json +73 -54
@@ -81,8 +81,8 @@ const createProjectTsConfig = async (projectRoot, options) => {
81
81
  // Paths para tipos
82
82
  baseUrl: '.',
83
83
  paths: {
84
- '/dist/examples/*': ['src/*'],
85
- '/dist/examples/types/*': ['src/types/*'],
84
+ '/dist/*': ['src/*'],
85
+ '/dist/types/*': ['src/types/*'],
86
86
  },
87
87
  types: [
88
88
  'node',
@@ -132,74 +132,74 @@ const createProjectTsConfig = async (projectRoot, options) => {
132
132
  * Genera tipos globales adicionales basados en las opciones
133
133
  */
134
134
  const generateGlobalTypes = (options) => {
135
- let content = `/**
136
- * Tipos globales adicionales para el proyecto
137
- * Generado automáticamente por VersaCompiler
138
- */
139
-
140
- // Extensiones para window object si es necesario
141
- declare global {
142
- interface Window {
143
- // Agregar propiedades globales si es necesario
144
- [key: string]: any;
145
- }
146
- }
147
-
148
- // Tipos para archivos de assets
149
- declare module '*.svg' {
150
- const src: string;
151
- export default src;
152
- }
153
-
154
- declare module '*.png' {
155
- const src: string;
156
- export default src;
157
- }
158
-
159
- declare module '*.jpg' {
160
- const src: string;
161
- export default src;
162
- }
163
-
164
- declare module '*.jpeg' {
165
- const src: string;
166
- export default src;
167
- }
168
-
169
- declare module '*.webp' {
170
- const src: string;
171
- export default src;
172
- }
173
-
174
- declare module '*.gif' {
175
- const src: string;
176
- export default src;
177
- }
178
-
179
- declare module '*.ico' {
180
- const src: string;
181
- export default src;
182
- }
135
+ let content = `/**
136
+ * Tipos globales adicionales para el proyecto
137
+ * Generado automáticamente por VersaCompiler
138
+ */
139
+
140
+ // Extensiones para window object si es necesario
141
+ declare global {
142
+ interface Window {
143
+ // Agregar propiedades globales si es necesario
144
+ [key: string]: any;
145
+ }
146
+ }
147
+
148
+ // Tipos para archivos de assets
149
+ declare module '*.svg' {
150
+ const src: string;
151
+ export default src;
152
+ }
153
+
154
+ declare module '*.png' {
155
+ const src: string;
156
+ export default src;
157
+ }
158
+
159
+ declare module '*.jpg' {
160
+ const src: string;
161
+ export default src;
162
+ }
163
+
164
+ declare module '*.jpeg' {
165
+ const src: string;
166
+ export default src;
167
+ }
168
+
169
+ declare module '*.webp' {
170
+ const src: string;
171
+ export default src;
172
+ }
173
+
174
+ declare module '*.gif' {
175
+ const src: string;
176
+ export default src;
177
+ }
178
+
179
+ declare module '*.ico' {
180
+ const src: string;
181
+ export default src;
182
+ }
183
183
  `;
184
184
  if (options.includeRouterTypes) {
185
- content += `
186
- // Vue Router tipos adicionales
187
- declare module '@vue/runtime-core' {
188
- interface ComponentCustomProperties {
189
- $route: import('/node_modules/vue-router/dist/vue-router.esm-browser.js').RouteLocationNormalized;
190
- $router: import('/node_modules/vue-router/dist/vue-router.esm-browser.js').Router;
191
- }
192
- }
185
+ content += `
186
+ // Vue Router tipos adicionales
187
+ declare module '@vue/runtime-core' {
188
+ interface ComponentCustomProperties {
189
+ $route: import('vue-router').RouteLocationNormalized;
190
+ $router: import('vue-router').Router;
191
+ }
192
+ }
193
193
  `;
194
194
  }
195
195
  if (options.includePiniaTypes) {
196
- content += `
197
- // Pinia tipos adicionales
198
- declare module '@vue/runtime-core' {
199
- interface ComponentCustomProperties {
200
- $pinia: import('/node_modules/pinia/dist/pinia.esm-browser.js').Pinia;
201
- }
202
- }
196
+ content += `
197
+ // Pinia tipos adicionales
198
+ declare module '@vue/runtime-core' {
199
+ interface ComponentCustomProperties {
200
+ $pinia: import('pinia').Pinia;
201
+ }
202
+ }
203
203
  `;
204
204
  }
205
205
  content += '\nexport {};';
@@ -210,189 +210,189 @@ declare module '@vue/runtime-core' {
210
210
  * @returns El contenido completo del archivo de shims
211
211
  */
212
212
  const generateVueShimsContent = () => {
213
- return `/**
214
- * Declaraciones de tipos Vue para VersaCompiler
215
- * Proporciona tipado robusto para archivos Vue
216
- */
217
-
218
- /// <reference types="vue/ref-macros" />
219
- /// <reference types="vue/reactivity-transform/macros" />
220
-
221
- declare module '*.vue' {
222
- import type { DefineComponent } from 'vue';
223
- const component: DefineComponent<{}, {}, any>;
224
- export default component;
225
- }
226
-
227
- // Declaraciones globales para Composition API
228
- declare global {
229
- // Reactivity API
230
- function ref<T>(value: T): { value: T };
231
- function reactive<T extends object>(target: T): T;
232
- function computed<T>(getter: () => T): { value: T };
233
- function readonly<T>(target: T): T;
234
- function unref<T>(ref: T): T extends { value: infer V } ? V : T;
235
- function toRef<T, K extends keyof T>(object: T, key: K): { value: T[K] };
236
- function toRefs<T extends object>(
237
- object: T,
238
- ): { [K in keyof T]: { value: T[K] } };
239
- function isRef<T>(ref: any): ref is { value: T };
240
- function isReactive(value: any): boolean;
241
- function isReadonly(value: any): boolean;
242
- function isProxy(value: any): boolean;
243
- function shallowRef<T>(value: T): { value: T };
244
- function shallowReactive<T extends object>(target: T): T;
245
- function shallowReadonly<T>(target: T): T;
246
- function toRaw<T>(observed: T): T;
247
- function markRaw<T>(value: T): T;
248
- function triggerRef<T>(ref: { value: T }): void;
249
-
250
- // Component API
251
- function defineComponent<T extends Record<string, any>>(options: T): T;
252
- function defineAsyncComponent<T>(loader: () => Promise<T>): T;
253
-
254
- // Props & Emits
255
- function defineProps<T = {}>(): T;
256
- function defineEmits<T extends Record<string, any> = {}>(): T;
257
- function defineExpose<T = {}>(exposed: T): void;
258
- function defineModel<T>(modelName?: string): { value: T };
259
- function withDefaults<T, D>(props: T, defaults: D): T & D;
260
-
261
- // Lifecycle Hooks
262
- function onBeforeMount(hook: () => void): void;
263
- function onMounted(hook: () => void): void;
264
- function onBeforeUpdate(hook: () => void): void;
265
- function onUpdated(hook: () => void): void;
266
- function onBeforeUnmount(hook: () => void): void;
267
- function onUnmounted(hook: () => void): void;
268
- function onActivated(hook: () => void): void;
269
- function onDeactivated(hook: () => void): void;
270
- function onErrorCaptured(
271
- hook: (err: Error, instance: any, info: string) => boolean | void,
272
- ): void;
273
- function onRenderTracked(hook: (event: any) => void): void;
274
- function onRenderTriggered(hook: (event: any) => void): void;
275
- function onServerPrefetch(hook: () => Promise<any>): void;
276
-
277
- // Dependency Injection
278
- function provide<T>(key: string | symbol, value: T): void;
279
- function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
280
-
281
- // Template Refs
282
- function templateRef<T = any>(key?: string): { value: T | null };
283
-
284
- // Watchers
285
- type WatchCallback<T> = (newValue: T, oldValue: T) => void;
286
- type WatchStopHandle = () => void;
287
- function watch<T>(
288
- source: () => T,
289
- callback: WatchCallback<T>,
290
- options?: any,
291
- ): WatchStopHandle;
292
- function watchEffect(effect: () => void, options?: any): WatchStopHandle;
293
- function watchPostEffect(
294
- effect: () => void,
295
- options?: any,
296
- ): WatchStopHandle;
297
- function watchSyncEffect(
298
- effect: () => void,
299
- options?: any,
300
- ): WatchStopHandle;
301
-
302
- // Utilities
303
- function nextTick(callback?: () => void): Promise<void>;
304
- function useSlots(): { [key: string]: (...args: any[]) => any };
305
- function useAttrs(): { [key: string]: any };
306
- function useModel<T>(modelName?: string): { value: T };
307
- function useCssModule(name?: string): { [key: string]: string };
308
- function useCssVars(vars: Record<string, string>): void;
309
-
310
- // Advanced Reactivity
311
- function customRef<T>(
312
- factory: (
313
- track: () => void,
314
- trigger: () => void,
315
- ) => { get: () => T; set: (value: T) => void },
316
- ): { value: T };
317
- function effectScope(): any;
318
- function getCurrentScope(): any;
319
- function onScopeDispose(fn: () => void): void;
320
-
321
- // Component Instance
322
- function getCurrentInstance(): any;
323
- function hasInjectionContext(): boolean;
324
-
325
- // Vue Router (common imports)
326
- function useRouter(): any;
327
- function useRoute(): any;
328
-
329
- // Pinia (common imports)
330
- function useStore(): any;
331
- function defineStore(id: string, setup: () => any): any;
332
-
333
- // Legacy Options API support
334
- interface ComponentOptions {
335
- name?: string;
336
- props?: any;
337
- data?: () => any;
338
- computed?: any;
339
- methods?: any;
340
- watch?: any;
341
- emits?: any;
342
- setup?: any;
343
- [key: string]: any;
344
- }
345
-
346
- // Vue 3 specific APIs
347
- function createApp(rootComponent: any, rootProps?: any): any;
348
- function defineCustomElement(options: any): any;
349
- function mergeModels<T>(models: T): T;
350
- }
351
-
352
- // Module augmentation for common Vue ecosystem types
353
- declare module '@vue/runtime-core' {
354
- interface ComponentCustomProperties {
355
- $route: any;
356
- $router: any;
357
- $store: any;
358
- [key: string]: any;
359
- }
360
- }
361
-
362
- // Support for .vue files in TypeScript
363
- declare module '*.vue' {
364
- import type { DefineComponent } from 'vue';
365
- const component: DefineComponent<{}, {}, any>;
366
- export default component;
367
- }
368
-
369
- // CSS Modules support
370
- declare module '*.module.css' {
371
- const classes: { [key: string]: string };
372
- export default classes;
373
- }
374
-
375
- declare module '*.module.scss' {
376
- const classes: { [key: string]: string };
377
- export default classes;
378
- }
379
-
380
- declare module '*.module.sass' {
381
- const classes: { [key: string]: string };
382
- export default classes;
383
- }
384
-
385
- declare module '*.module.less' {
386
- const classes: { [key: string]: string };
387
- export default classes;
388
- }
389
-
390
- declare module '*.module.styl' {
391
- const classes: { [key: string]: string };
392
- export default classes;
393
- }
394
-
395
- export {};
213
+ return `/**
214
+ * Declaraciones de tipos Vue para VersaCompiler
215
+ * Proporciona tipado robusto para archivos Vue
216
+ */
217
+
218
+ /// <reference types="vue/ref-macros" />
219
+ /// <reference types="vue/reactivity-transform/macros" />
220
+
221
+ declare module '*.vue' {
222
+ import type { DefineComponent } from 'vue';
223
+ const component: DefineComponent<{}, {}, any>;
224
+ export default component;
225
+ }
226
+
227
+ // Declaraciones globales para Composition API
228
+ declare global {
229
+ // Reactivity API
230
+ function ref<T>(value: T): { value: T };
231
+ function reactive<T extends object>(target: T): T;
232
+ function computed<T>(getter: () => T): { value: T };
233
+ function readonly<T>(target: T): T;
234
+ function unref<T>(ref: T): T extends { value: infer V } ? V : T;
235
+ function toRef<T, K extends keyof T>(object: T, key: K): { value: T[K] };
236
+ function toRefs<T extends object>(
237
+ object: T,
238
+ ): { [K in keyof T]: { value: T[K] } };
239
+ function isRef<T>(ref: any): ref is { value: T };
240
+ function isReactive(value: any): boolean;
241
+ function isReadonly(value: any): boolean;
242
+ function isProxy(value: any): boolean;
243
+ function shallowRef<T>(value: T): { value: T };
244
+ function shallowReactive<T extends object>(target: T): T;
245
+ function shallowReadonly<T>(target: T): T;
246
+ function toRaw<T>(observed: T): T;
247
+ function markRaw<T>(value: T): T;
248
+ function triggerRef<T>(ref: { value: T }): void;
249
+
250
+ // Component API
251
+ function defineComponent<T extends Record<string, any>>(options: T): T;
252
+ function defineAsyncComponent<T>(loader: () => Promise<T>): T;
253
+
254
+ // Props & Emits
255
+ function defineProps<T = {}>(): T;
256
+ function defineEmits<T extends Record<string, any> = {}>(): T;
257
+ function defineExpose<T = {}>(exposed: T): void;
258
+ function defineModel<T>(modelName?: string): { value: T };
259
+ function withDefaults<T, D>(props: T, defaults: D): T & D;
260
+
261
+ // Lifecycle Hooks
262
+ function onBeforeMount(hook: () => void): void;
263
+ function onMounted(hook: () => void): void;
264
+ function onBeforeUpdate(hook: () => void): void;
265
+ function onUpdated(hook: () => void): void;
266
+ function onBeforeUnmount(hook: () => void): void;
267
+ function onUnmounted(hook: () => void): void;
268
+ function onActivated(hook: () => void): void;
269
+ function onDeactivated(hook: () => void): void;
270
+ function onErrorCaptured(
271
+ hook: (err: Error, instance: any, info: string) => boolean | void,
272
+ ): void;
273
+ function onRenderTracked(hook: (event: any) => void): void;
274
+ function onRenderTriggered(hook: (event: any) => void): void;
275
+ function onServerPrefetch(hook: () => Promise<any>): void;
276
+
277
+ // Dependency Injection
278
+ function provide<T>(key: string | symbol, value: T): void;
279
+ function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
280
+
281
+ // Template Refs
282
+ function templateRef<T = any>(key?: string): { value: T | null };
283
+
284
+ // Watchers
285
+ type WatchCallback<T> = (newValue: T, oldValue: T) => void;
286
+ type WatchStopHandle = () => void;
287
+ function watch<T>(
288
+ source: () => T,
289
+ callback: WatchCallback<T>,
290
+ options?: any,
291
+ ): WatchStopHandle;
292
+ function watchEffect(effect: () => void, options?: any): WatchStopHandle;
293
+ function watchPostEffect(
294
+ effect: () => void,
295
+ options?: any,
296
+ ): WatchStopHandle;
297
+ function watchSyncEffect(
298
+ effect: () => void,
299
+ options?: any,
300
+ ): WatchStopHandle;
301
+
302
+ // Utilities
303
+ function nextTick(callback?: () => void): Promise<void>;
304
+ function useSlots(): { [key: string]: (...args: any[]) => any };
305
+ function useAttrs(): { [key: string]: any };
306
+ function useModel<T>(modelName?: string): { value: T };
307
+ function useCssModule(name?: string): { [key: string]: string };
308
+ function useCssVars(vars: Record<string, string>): void;
309
+
310
+ // Advanced Reactivity
311
+ function customRef<T>(
312
+ factory: (
313
+ track: () => void,
314
+ trigger: () => void,
315
+ ) => { get: () => T; set: (value: T) => void },
316
+ ): { value: T };
317
+ function effectScope(): any;
318
+ function getCurrentScope(): any;
319
+ function onScopeDispose(fn: () => void): void;
320
+
321
+ // Component Instance
322
+ function getCurrentInstance(): any;
323
+ function hasInjectionContext(): boolean;
324
+
325
+ // Vue Router (common imports)
326
+ function useRouter(): any;
327
+ function useRoute(): any;
328
+
329
+ // Pinia (common imports)
330
+ function useStore(): any;
331
+ function defineStore(id: string, setup: () => any): any;
332
+
333
+ // Legacy Options API support
334
+ interface ComponentOptions {
335
+ name?: string;
336
+ props?: any;
337
+ data?: () => any;
338
+ computed?: any;
339
+ methods?: any;
340
+ watch?: any;
341
+ emits?: any;
342
+ setup?: any;
343
+ [key: string]: any;
344
+ }
345
+
346
+ // Vue 3 specific APIs
347
+ function createApp(rootComponent: any, rootProps?: any): any;
348
+ function defineCustomElement(options: any): any;
349
+ function mergeModels<T>(models: T): T;
350
+ }
351
+
352
+ // Module augmentation for common Vue ecosystem types
353
+ declare module '@vue/runtime-core' {
354
+ interface ComponentCustomProperties {
355
+ $route: any;
356
+ $router: any;
357
+ $store: any;
358
+ [key: string]: any;
359
+ }
360
+ }
361
+
362
+ // Support for .vue files in TypeScript
363
+ declare module '*.vue' {
364
+ import type { DefineComponent } from 'vue';
365
+ const component: DefineComponent<{}, {}, any>;
366
+ export default component;
367
+ }
368
+
369
+ // CSS Modules support
370
+ declare module '*.module.css' {
371
+ const classes: { [key: string]: string };
372
+ export default classes;
373
+ }
374
+
375
+ declare module '*.module.scss' {
376
+ const classes: { [key: string]: string };
377
+ export default classes;
378
+ }
379
+
380
+ declare module '*.module.sass' {
381
+ const classes: { [key: string]: string };
382
+ export default classes;
383
+ }
384
+
385
+ declare module '*.module.less' {
386
+ const classes: { [key: string]: string };
387
+ export default classes;
388
+ }
389
+
390
+ declare module '*.module.styl' {
391
+ const classes: { [key: string]: string };
392
+ export default classes;
393
+ }
394
+
395
+ export {};
396
396
  `;
397
397
  };
398
398
  /**
@@ -54,7 +54,9 @@ export class ESLintNode {
54
54
  await Promise.all(this.formats.map(async (format) => {
55
55
  const cliArgs = this.toCliArgs(format, targetPaths);
56
56
  try {
57
- const { stdout, stderr, exitCode } = await execa(this.binPath, cliArgs, { reject: false });
57
+ const { stdout, stderr, exitCode } = await execa(this.binPath, cliArgs, {
58
+ reject: false,
59
+ });
58
60
  if (exitCode !== 0 &&
59
61
  format !== 'json' &&
60
62
  format !== 'sarif') {
@@ -53,7 +53,9 @@ export class OxlintNode {
53
53
  await Promise.all(this.formats.map(async (format) => {
54
54
  const cliArgs = this.toCliArgs(format, targetPaths);
55
55
  try {
56
- const { stdout, stderr, exitCode } = await execa(this.binPath, cliArgs, { reject: false });
56
+ const { stdout, stderr, exitCode } = await execa(this.binPath, cliArgs, {
57
+ reject: false,
58
+ });
57
59
  if (exitCode !== 0 &&
58
60
  format !== 'json' &&
59
61
  format !== 'sarif') {