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.
- package/dist/compiler/compile.js +26 -2332
- package/dist/compiler/error-reporter.js +38 -467
- package/dist/compiler/linter.js +1 -72
- package/dist/compiler/minify.js +1 -229
- package/dist/compiler/module-resolution-optimizer.js +1 -821
- package/dist/compiler/parser.js +1 -203
- package/dist/compiler/performance-monitor.js +56 -192
- package/dist/compiler/tailwindcss.js +1 -39
- package/dist/compiler/transform-optimizer.js +1 -392
- package/dist/compiler/transformTStoJS.js +1 -16
- package/dist/compiler/transforms.js +1 -550
- package/dist/compiler/typescript-compiler.js +2 -172
- package/dist/compiler/typescript-error-parser.js +10 -281
- package/dist/compiler/typescript-manager.js +2 -273
- package/dist/compiler/typescript-sync-validator.js +31 -295
- package/dist/compiler/typescript-worker-pool.js +1 -842
- package/dist/compiler/typescript-worker-thread.cjs +41 -466
- package/dist/compiler/typescript-worker.js +1 -339
- package/dist/compiler/vuejs.js +37 -392
- package/dist/hrm/VueHRM.js +1 -353
- package/dist/hrm/errorScreen.js +1 -83
- package/dist/hrm/getInstanciaVue.js +1 -313
- package/dist/hrm/initHRM.js +1 -141
- package/dist/main.js +7 -347
- package/dist/servicios/browserSync.js +5 -501
- package/dist/servicios/file-watcher.js +4 -379
- package/dist/servicios/logger.js +3 -63
- package/dist/servicios/readConfig.js +105 -430
- package/dist/utils/excluded-modules.js +1 -36
- package/dist/utils/module-resolver.js +1 -466
- package/dist/utils/promptUser.js +2 -48
- package/dist/utils/proxyValidator.js +1 -68
- package/dist/utils/resolve-bin.js +1 -48
- package/dist/utils/utils.js +1 -21
- package/dist/utils/vue-types-setup.js +241 -435
- package/dist/wrappers/eslint-node.js +1 -145
- package/dist/wrappers/oxlint-node.js +1 -120
- package/dist/wrappers/tailwind-node.js +1 -92
- package/package.json +36 -35
|
@@ -1,442 +1,248 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
import*as e from"node:fs";import*as t from"node:path";export const setupVueTypes=async(n,o={})=>{try{let{targetDir:s=`src/types`,createTsConfig:c=!1,enableStrictMode:l=!1,includeRouterTypes:u=!0,includePiniaTypes:d=!0}=o,f=t.join(n,s);e.existsSync(f)||e.mkdirSync(f,{recursive:!0});let p=t.join(f,`vue-shims.d.ts`);if(!e.existsSync(p)){let t=a();e.writeFileSync(p,t)}c&&await r(n,{enableStrictMode:l,includeRouterTypes:u,includePiniaTypes:d});let m=t.join(f,`global.d.ts`),h=i({includeRouterTypes:u,includePiniaTypes:d});return e.writeFileSync(m,h),!0}catch(e){return console.error(`Error setting up Vue types:`,e),!1}};const r=async(n,r)=>{let i=t.join(n,`tsconfig.json`),a={compilerOptions:{target:`esnext`,module:`esnext`,lib:[`esnext`,`dom`,`dom.iterable`],allowJs:!0,checkJs:!1,jsx:`preserve`,declaration:!0,declarationMap:!0,sourceMap:!0,outDir:`./dist`,removeComments:!0,importHelpers:!0,isolatedModules:!0,allowSyntheticDefaultImports:!0,esModuleInterop:!0,forceConsistentCasingInFileNames:!0,useDefineForClassFields:!0,resolveJsonModule:!0,skipLibCheck:!0,moduleResolution:`node`,strict:r.enableStrictMode,noImplicitAny:r.enableStrictMode,noImplicitReturns:r.enableStrictMode,noImplicitThis:r.enableStrictMode,strictNullChecks:r.enableStrictMode,strictFunctionTypes:r.enableStrictMode,baseUrl:`.`,paths:{"/dist/examples/*":[`src/*`],"/dist/examples/types/*":[`src/types/*`]},types:[`node`,`vue/ref-macros`,...r.includeRouterTypes?[`@vue/router`]:[],...r.includePiniaTypes?[`pinia`]:[]]},include:[`src/**/*.ts`,`src/**/*.tsx`,`src/**/*.vue`,`src/types/**/*.d.ts`],exclude:[`node_modules`,`dist`],"ts-node":{esm:!0}};if(e.existsSync(i))try{let t=JSON.parse(e.readFileSync(i,`utf-8`)),n={...t,compilerOptions:{...t.compilerOptions,...a.compilerOptions},include:Array.from(new Set([...t.include||[],...a.include]))};e.writeFileSync(i,JSON.stringify(n,null,2))}catch{e.writeFileSync(i,JSON.stringify(a,null,2))}else e.writeFileSync(i,JSON.stringify(a,null,2))},i=e=>{let t=`/**
|
|
2
|
+
* Tipos globales adicionales para el proyecto
|
|
3
|
+
* Generado automáticamente por VersaCompiler
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
export const setupVueTypes = async (projectRoot, config = {}) => {
|
|
13
|
-
try {
|
|
14
|
-
const { targetDir = 'src/types', createTsConfig = false, enableStrictMode = false, includeRouterTypes = true, includePiniaTypes = true, } = config;
|
|
15
|
-
const typesDir = path.join(projectRoot, targetDir);
|
|
16
|
-
// Crear directorio de tipos si no existe
|
|
17
|
-
if (!fs.existsSync(typesDir)) {
|
|
18
|
-
fs.mkdirSync(typesDir, { recursive: true });
|
|
19
|
-
} // Crear vue-shims.d.ts si no existe
|
|
20
|
-
const vueShimsPath = path.join(typesDir, 'vue-shims.d.ts');
|
|
21
|
-
if (!fs.existsSync(vueShimsPath)) {
|
|
22
|
-
const shimsContent = generateVueShimsContent();
|
|
23
|
-
fs.writeFileSync(vueShimsPath, shimsContent);
|
|
24
|
-
}
|
|
25
|
-
// Crear archivo de configuración específico del proyecto si se solicita
|
|
26
|
-
if (createTsConfig) {
|
|
27
|
-
await createProjectTsConfig(projectRoot, {
|
|
28
|
-
enableStrictMode,
|
|
29
|
-
includeRouterTypes,
|
|
30
|
-
includePiniaTypes,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// Crear archivo de entorno global para tipos adicionales
|
|
34
|
-
const globalTypesPath = path.join(typesDir, 'global.d.ts');
|
|
35
|
-
const globalTypesContent = generateGlobalTypes({
|
|
36
|
-
includeRouterTypes,
|
|
37
|
-
includePiniaTypes,
|
|
38
|
-
});
|
|
39
|
-
fs.writeFileSync(globalTypesPath, globalTypesContent);
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
console.error('Error setting up Vue types:', error);
|
|
44
|
-
return false;
|
|
5
|
+
|
|
6
|
+
// Extensiones para window object si es necesario
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
// Agregar propiedades globales si es necesario
|
|
10
|
+
[key: string]: any;
|
|
45
11
|
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'vue/ref-macros',
|
|
90
|
-
...(options.includeRouterTypes ? ['@vue/router'] : []),
|
|
91
|
-
...(options.includePiniaTypes ? ['pinia'] : []),
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
include: [
|
|
95
|
-
'src/**/*.ts',
|
|
96
|
-
'src/**/*.tsx',
|
|
97
|
-
'src/**/*.vue',
|
|
98
|
-
'src/types/**/*.d.ts',
|
|
99
|
-
],
|
|
100
|
-
exclude: ['node_modules', 'dist'],
|
|
101
|
-
'ts-node': {
|
|
102
|
-
esm: true,
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
// Si ya existe tsconfig.json, hacer merge inteligente
|
|
106
|
-
if (fs.existsSync(tsconfigPath)) {
|
|
107
|
-
try {
|
|
108
|
-
const existingConfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
109
|
-
const mergedConfig = {
|
|
110
|
-
...existingConfig,
|
|
111
|
-
compilerOptions: {
|
|
112
|
-
...existingConfig.compilerOptions,
|
|
113
|
-
...tsconfigContent.compilerOptions,
|
|
114
|
-
},
|
|
115
|
-
include: Array.from(new Set([
|
|
116
|
-
...(existingConfig.include || []),
|
|
117
|
-
...tsconfigContent.include,
|
|
118
|
-
])),
|
|
119
|
-
};
|
|
120
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify(mergedConfig, null, 2));
|
|
121
|
-
}
|
|
122
|
-
catch {
|
|
123
|
-
// Si hay error parseando, crear nuevo archivo
|
|
124
|
-
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfigContent, null, 2));
|
|
125
|
-
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Tipos para archivos de assets
|
|
15
|
+
declare module '*.svg' {
|
|
16
|
+
const src: string;
|
|
17
|
+
export default src;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module '*.png' {
|
|
21
|
+
const src: string;
|
|
22
|
+
export default src;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare module '*.jpg' {
|
|
26
|
+
const src: string;
|
|
27
|
+
export default src;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare module '*.jpeg' {
|
|
31
|
+
const src: string;
|
|
32
|
+
export default src;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare module '*.webp' {
|
|
36
|
+
const src: string;
|
|
37
|
+
export default src;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare module '*.gif' {
|
|
41
|
+
const src: string;
|
|
42
|
+
export default src;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare module '*.ico' {
|
|
46
|
+
const src: string;
|
|
47
|
+
export default src;
|
|
48
|
+
}
|
|
49
|
+
`;return e.includeRouterTypes&&(t+=`
|
|
50
|
+
// Vue Router tipos adicionales
|
|
51
|
+
declare module '@vue/runtime-core' {
|
|
52
|
+
interface ComponentCustomProperties {
|
|
53
|
+
$route: import('vue-router').RouteLocationNormalized;
|
|
54
|
+
$router: import('vue-router').Router;
|
|
126
55
|
}
|
|
127
|
-
|
|
128
|
-
|
|
56
|
+
}
|
|
57
|
+
`),e.includePiniaTypes&&(t+=`
|
|
58
|
+
// Pinia tipos adicionales
|
|
59
|
+
declare module '@vue/runtime-core' {
|
|
60
|
+
interface ComponentCustomProperties {
|
|
61
|
+
$pinia: import('pinia').Pinia;
|
|
129
62
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
63
|
+
}
|
|
64
|
+
`),t+=`
|
|
65
|
+
export {};`,t},a=()=>`/**
|
|
66
|
+
* Declaraciones de tipos Vue para VersaCompiler
|
|
67
|
+
* Proporciona tipado robusto para archivos Vue
|
|
133
68
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
//
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
function
|
|
235
|
-
function
|
|
236
|
-
function
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
function
|
|
240
|
-
function
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
function
|
|
244
|
-
function
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
function
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
`;
|
|
397
|
-
};
|
|
398
|
-
/**
|
|
399
|
-
* Verifica si el proyecto ya tiene tipos Vue configurados
|
|
400
|
-
*/
|
|
401
|
-
export const hasVueTypesSetup = (projectRoot) => {
|
|
402
|
-
const typesDir = path.join(projectRoot, 'src/types');
|
|
403
|
-
const vueShimsPath = path.join(typesDir, 'vue-shims.d.ts');
|
|
404
|
-
return fs.existsSync(vueShimsPath);
|
|
405
|
-
};
|
|
406
|
-
/**
|
|
407
|
-
* Configuración automática para proyectos Vue detectados
|
|
408
|
-
*/
|
|
409
|
-
export const autoSetupVueTypes = async (projectRoot) => {
|
|
410
|
-
// Verificar si es un proyecto Vue
|
|
411
|
-
const packageJsonPath = path.join(projectRoot, 'package.json');
|
|
412
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
try {
|
|
416
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
417
|
-
const hasVue = packageJson.dependencies?.vue || packageJson.devDependencies?.vue;
|
|
418
|
-
if (!hasVue) {
|
|
419
|
-
return false;
|
|
420
|
-
}
|
|
421
|
-
// Si ya tiene tipos configurados, no hacer nada
|
|
422
|
-
if (hasVueTypesSetup(projectRoot)) {
|
|
423
|
-
return true;
|
|
424
|
-
}
|
|
425
|
-
// Detectar qué librerías adicionales usar
|
|
426
|
-
const hasRouter = packageJson.dependencies?.['vue-router'] ||
|
|
427
|
-
packageJson.devDependencies?.['vue-router'];
|
|
428
|
-
const hasPinia = packageJson.dependencies?.pinia ||
|
|
429
|
-
packageJson.devDependencies?.pinia;
|
|
430
|
-
// Configurar tipos automáticamente
|
|
431
|
-
return await setupVueTypes(projectRoot, {
|
|
432
|
-
createTsConfig: !fs.existsSync(path.join(projectRoot, 'tsconfig.json')),
|
|
433
|
-
includeRouterTypes: !!hasRouter,
|
|
434
|
-
includePiniaTypes: !!hasPinia,
|
|
435
|
-
});
|
|
69
|
+
|
|
70
|
+
/// <reference types="vue/ref-macros" />
|
|
71
|
+
/// <reference types="vue/reactivity-transform/macros" />
|
|
72
|
+
|
|
73
|
+
declare module '*.vue' {
|
|
74
|
+
import type { DefineComponent } from 'vue';
|
|
75
|
+
const component: DefineComponent<{}, {}, any>;
|
|
76
|
+
export default component;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Declaraciones globales para Composition API
|
|
80
|
+
declare global {
|
|
81
|
+
// Reactivity API
|
|
82
|
+
function ref<T>(value: T): { value: T };
|
|
83
|
+
function reactive<T extends object>(target: T): T;
|
|
84
|
+
function computed<T>(getter: () => T): { value: T };
|
|
85
|
+
function readonly<T>(target: T): T;
|
|
86
|
+
function unref<T>(ref: T): T extends { value: infer V } ? V : T;
|
|
87
|
+
function toRef<T, K extends keyof T>(object: T, key: K): { value: T[K] };
|
|
88
|
+
function toRefs<T extends object>(
|
|
89
|
+
object: T,
|
|
90
|
+
): { [K in keyof T]: { value: T[K] } };
|
|
91
|
+
function isRef<T>(ref: any): ref is { value: T };
|
|
92
|
+
function isReactive(value: any): boolean;
|
|
93
|
+
function isReadonly(value: any): boolean;
|
|
94
|
+
function isProxy(value: any): boolean;
|
|
95
|
+
function shallowRef<T>(value: T): { value: T };
|
|
96
|
+
function shallowReactive<T extends object>(target: T): T;
|
|
97
|
+
function shallowReadonly<T>(target: T): T;
|
|
98
|
+
function toRaw<T>(observed: T): T;
|
|
99
|
+
function markRaw<T>(value: T): T;
|
|
100
|
+
function triggerRef<T>(ref: { value: T }): void;
|
|
101
|
+
|
|
102
|
+
// Component API
|
|
103
|
+
function defineComponent<T extends Record<string, any>>(options: T): T;
|
|
104
|
+
function defineAsyncComponent<T>(loader: () => Promise<T>): T;
|
|
105
|
+
|
|
106
|
+
// Props & Emits
|
|
107
|
+
function defineProps<T = {}>(): T;
|
|
108
|
+
function defineEmits<T extends Record<string, any> = {}>(): T;
|
|
109
|
+
function defineExpose<T = {}>(exposed: T): void;
|
|
110
|
+
function defineModel<T>(modelName?: string): { value: T };
|
|
111
|
+
function withDefaults<T, D>(props: T, defaults: D): T & D;
|
|
112
|
+
|
|
113
|
+
// Lifecycle Hooks
|
|
114
|
+
function onBeforeMount(hook: () => void): void;
|
|
115
|
+
function onMounted(hook: () => void): void;
|
|
116
|
+
function onBeforeUpdate(hook: () => void): void;
|
|
117
|
+
function onUpdated(hook: () => void): void;
|
|
118
|
+
function onBeforeUnmount(hook: () => void): void;
|
|
119
|
+
function onUnmounted(hook: () => void): void;
|
|
120
|
+
function onActivated(hook: () => void): void;
|
|
121
|
+
function onDeactivated(hook: () => void): void;
|
|
122
|
+
function onErrorCaptured(
|
|
123
|
+
hook: (err: Error, instance: any, info: string) => boolean | void,
|
|
124
|
+
): void;
|
|
125
|
+
function onRenderTracked(hook: (event: any) => void): void;
|
|
126
|
+
function onRenderTriggered(hook: (event: any) => void): void;
|
|
127
|
+
function onServerPrefetch(hook: () => Promise<any>): void;
|
|
128
|
+
|
|
129
|
+
// Dependency Injection
|
|
130
|
+
function provide<T>(key: string | symbol, value: T): void;
|
|
131
|
+
function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
|
|
132
|
+
|
|
133
|
+
// Template Refs
|
|
134
|
+
function templateRef<T = any>(key?: string): { value: T | null };
|
|
135
|
+
|
|
136
|
+
// Watchers
|
|
137
|
+
type WatchCallback<T> = (newValue: T, oldValue: T) => void;
|
|
138
|
+
type WatchStopHandle = () => void;
|
|
139
|
+
function watch<T>(
|
|
140
|
+
source: () => T,
|
|
141
|
+
callback: WatchCallback<T>,
|
|
142
|
+
options?: any,
|
|
143
|
+
): WatchStopHandle;
|
|
144
|
+
function watchEffect(effect: () => void, options?: any): WatchStopHandle;
|
|
145
|
+
function watchPostEffect(
|
|
146
|
+
effect: () => void,
|
|
147
|
+
options?: any,
|
|
148
|
+
): WatchStopHandle;
|
|
149
|
+
function watchSyncEffect(
|
|
150
|
+
effect: () => void,
|
|
151
|
+
options?: any,
|
|
152
|
+
): WatchStopHandle;
|
|
153
|
+
|
|
154
|
+
// Utilities
|
|
155
|
+
function nextTick(callback?: () => void): Promise<void>;
|
|
156
|
+
function useSlots(): { [key: string]: (...args: any[]) => any };
|
|
157
|
+
function useAttrs(): { [key: string]: any };
|
|
158
|
+
function useModel<T>(modelName?: string): { value: T };
|
|
159
|
+
function useCssModule(name?: string): { [key: string]: string };
|
|
160
|
+
function useCssVars(vars: Record<string, string>): void;
|
|
161
|
+
|
|
162
|
+
// Advanced Reactivity
|
|
163
|
+
function customRef<T>(
|
|
164
|
+
factory: (
|
|
165
|
+
track: () => void,
|
|
166
|
+
trigger: () => void,
|
|
167
|
+
) => { get: () => T; set: (value: T) => void },
|
|
168
|
+
): { value: T };
|
|
169
|
+
function effectScope(): any;
|
|
170
|
+
function getCurrentScope(): any;
|
|
171
|
+
function onScopeDispose(fn: () => void): void;
|
|
172
|
+
|
|
173
|
+
// Component Instance
|
|
174
|
+
function getCurrentInstance(): any;
|
|
175
|
+
function hasInjectionContext(): boolean;
|
|
176
|
+
|
|
177
|
+
// Vue Router (common imports)
|
|
178
|
+
function useRouter(): any;
|
|
179
|
+
function useRoute(): any;
|
|
180
|
+
|
|
181
|
+
// Pinia (common imports)
|
|
182
|
+
function useStore(): any;
|
|
183
|
+
function defineStore(id: string, setup: () => any): any;
|
|
184
|
+
|
|
185
|
+
// Legacy Options API support
|
|
186
|
+
interface ComponentOptions {
|
|
187
|
+
name?: string;
|
|
188
|
+
props?: any;
|
|
189
|
+
data?: () => any;
|
|
190
|
+
computed?: any;
|
|
191
|
+
methods?: any;
|
|
192
|
+
watch?: any;
|
|
193
|
+
emits?: any;
|
|
194
|
+
setup?: any;
|
|
195
|
+
[key: string]: any;
|
|
436
196
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
197
|
+
|
|
198
|
+
// Vue 3 specific APIs
|
|
199
|
+
function createApp(rootComponent: any, rootProps?: any): any;
|
|
200
|
+
function defineCustomElement(options: any): any;
|
|
201
|
+
function mergeModels<T>(models: T): T;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Module augmentation for common Vue ecosystem types
|
|
205
|
+
declare module '@vue/runtime-core' {
|
|
206
|
+
interface ComponentCustomProperties {
|
|
207
|
+
$route: any;
|
|
208
|
+
$router: any;
|
|
209
|
+
$store: any;
|
|
210
|
+
[key: string]: any;
|
|
440
211
|
}
|
|
441
|
-
}
|
|
442
|
-
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Support for .vue files in TypeScript
|
|
215
|
+
declare module '*.vue' {
|
|
216
|
+
import type { DefineComponent } from 'vue';
|
|
217
|
+
const component: DefineComponent<{}, {}, any>;
|
|
218
|
+
export default component;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// CSS Modules support
|
|
222
|
+
declare module '*.module.css' {
|
|
223
|
+
const classes: { [key: string]: string };
|
|
224
|
+
export default classes;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare module '*.module.scss' {
|
|
228
|
+
const classes: { [key: string]: string };
|
|
229
|
+
export default classes;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
declare module '*.module.sass' {
|
|
233
|
+
const classes: { [key: string]: string };
|
|
234
|
+
export default classes;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
declare module '*.module.less' {
|
|
238
|
+
const classes: { [key: string]: string };
|
|
239
|
+
export default classes;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
declare module '*.module.styl' {
|
|
243
|
+
const classes: { [key: string]: string };
|
|
244
|
+
export default classes;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export {};
|
|
248
|
+
`;export const hasVueTypesSetup=n=>{let r=t.join(n,`src/types`),i=t.join(r,`vue-shims.d.ts`);return e.existsSync(i)};export const autoSetupVueTypes=async r=>{let i=t.join(r,`package.json`);if(!e.existsSync(i))return!1;try{let a=JSON.parse(e.readFileSync(i,`utf-8`)),s=a.dependencies?.vue||a.devDependencies?.vue;if(!s)return!1;if(hasVueTypesSetup(r))return!0;let c=a.dependencies?.[`vue-router`]||a.devDependencies?.[`vue-router`],l=a.dependencies?.pinia||a.devDependencies?.pinia;return await setupVueTypes(r,{createTsConfig:!e.existsSync(t.join(r,`tsconfig.json`)),includeRouterTypes:!!c,includePiniaTypes:!!l})}catch(e){return console.error(`Error in auto-setup Vue types:`,e),!1}};
|