versacompiler 2.0.8 → 2.2.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.
- package/README.md +1 -1
- package/dist/compiler/compile.js +2520 -26
- package/dist/compiler/error-reporter.js +467 -38
- package/dist/compiler/linter.js +72 -1
- package/dist/compiler/minify.js +272 -1
- package/dist/compiler/minifyTemplate.js +230 -0
- package/dist/compiler/module-resolution-optimizer.js +844 -1
- package/dist/compiler/parser.js +336 -1
- package/dist/compiler/performance-monitor.js +204 -56
- package/dist/compiler/tailwindcss.js +39 -1
- package/dist/compiler/transform-optimizer.js +392 -1
- package/dist/compiler/transformTStoJS.js +16 -1
- package/dist/compiler/transforms.js +554 -1
- package/dist/compiler/typescript-compiler.js +172 -2
- package/dist/compiler/typescript-error-parser.js +281 -10
- package/dist/compiler/typescript-manager.js +304 -2
- package/dist/compiler/typescript-sync-validator.js +295 -31
- package/dist/compiler/typescript-worker-pool.js +936 -1
- package/dist/compiler/typescript-worker-thread.cjs +466 -41
- package/dist/compiler/typescript-worker.js +339 -1
- package/dist/compiler/vuejs.js +396 -37
- package/dist/hrm/VueHRM.js +359 -1
- package/dist/hrm/errorScreen.js +83 -1
- package/dist/hrm/getInstanciaVue.js +313 -1
- package/dist/hrm/initHRM.js +586 -1
- package/dist/main.js +353 -7
- package/dist/servicios/browserSync.js +587 -5
- package/dist/servicios/file-watcher.js +425 -4
- package/dist/servicios/logger.js +63 -3
- package/dist/servicios/readConfig.js +399 -105
- package/dist/utils/excluded-modules.js +37 -1
- package/dist/utils/module-resolver.js +466 -1
- package/dist/utils/promptUser.js +48 -2
- package/dist/utils/proxyValidator.js +68 -1
- package/dist/utils/resolve-bin.js +58 -1
- package/dist/utils/utils.js +21 -1
- package/dist/utils/vue-types-setup.js +435 -241
- package/dist/wrappers/eslint-node.js +147 -1
- package/dist/wrappers/oxlint-node.js +122 -1
- package/dist/wrappers/tailwind-node.js +94 -1
- package/package.json +39 -42
|
@@ -1,248 +1,442 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
/**
|
|
2
|
+
* Utilidad para configurar automáticamente los tipos de Vue en proyectos
|
|
3
|
+
* Facilita la integración de tipado robusto para archivos Vue
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import * as fs from 'node:fs';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
/**
|
|
8
|
+
* Instala los archivos de tipos Vue en el proyecto
|
|
9
|
+
* @param projectRoot - Directorio raíz del proyecto
|
|
10
|
+
* @param config - Configuración para la instalación
|
|
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;
|
|
11
45
|
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Crea o actualiza tsconfig.json con configuración optimizada para Vue
|
|
49
|
+
*/
|
|
50
|
+
const createProjectTsConfig = async (projectRoot, options) => {
|
|
51
|
+
const tsconfigPath = path.join(projectRoot, 'tsconfig.json');
|
|
52
|
+
const tsconfigContent = {
|
|
53
|
+
compilerOptions: {
|
|
54
|
+
target: 'esnext',
|
|
55
|
+
module: 'esnext',
|
|
56
|
+
lib: ['esnext', 'dom', 'dom.iterable'],
|
|
57
|
+
allowJs: true,
|
|
58
|
+
checkJs: false,
|
|
59
|
+
jsx: 'preserve',
|
|
60
|
+
declaration: true,
|
|
61
|
+
declarationMap: true,
|
|
62
|
+
sourceMap: true,
|
|
63
|
+
outDir: './dist',
|
|
64
|
+
removeComments: true,
|
|
65
|
+
importHelpers: true,
|
|
66
|
+
isolatedModules: true,
|
|
67
|
+
allowSyntheticDefaultImports: true,
|
|
68
|
+
esModuleInterop: true,
|
|
69
|
+
forceConsistentCasingInFileNames: true,
|
|
70
|
+
useDefineForClassFields: true,
|
|
71
|
+
resolveJsonModule: true,
|
|
72
|
+
skipLibCheck: true,
|
|
73
|
+
moduleResolution: 'node',
|
|
74
|
+
// Configuraciones de strictness
|
|
75
|
+
strict: options.enableStrictMode,
|
|
76
|
+
noImplicitAny: options.enableStrictMode,
|
|
77
|
+
noImplicitReturns: options.enableStrictMode,
|
|
78
|
+
noImplicitThis: options.enableStrictMode,
|
|
79
|
+
strictNullChecks: options.enableStrictMode,
|
|
80
|
+
strictFunctionTypes: options.enableStrictMode,
|
|
81
|
+
// Paths para tipos
|
|
82
|
+
baseUrl: '.',
|
|
83
|
+
paths: {
|
|
84
|
+
'/dist/examples/*': ['src/*'],
|
|
85
|
+
'/dist/examples/types/*': ['src/types/*'],
|
|
86
|
+
},
|
|
87
|
+
types: [
|
|
88
|
+
'node',
|
|
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
|
+
}
|
|
55
126
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// Pinia tipos adicionales
|
|
59
|
-
declare module '@vue/runtime-core' {
|
|
60
|
-
interface ComponentCustomProperties {
|
|
61
|
-
$pinia: import('pinia').Pinia;
|
|
127
|
+
else {
|
|
128
|
+
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfigContent, null, 2));
|
|
62
129
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* Declaraciones de tipos Vue para VersaCompiler
|
|
67
|
-
* Proporciona tipado robusto para archivos Vue
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Genera tipos globales adicionales basados en las opciones
|
|
68
133
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
function
|
|
170
|
-
function
|
|
171
|
-
function
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
function
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
function
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
function
|
|
183
|
-
function
|
|
184
|
-
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
+
}
|
|
183
|
+
`;
|
|
184
|
+
if (options.includeRouterTypes) {
|
|
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
|
+
`;
|
|
194
|
+
}
|
|
195
|
+
if (options.includePiniaTypes) {
|
|
196
|
+
content += `
|
|
197
|
+
// Pinia tipos adicionales
|
|
198
|
+
declare module '@vue/runtime-core' {
|
|
199
|
+
interface ComponentCustomProperties {
|
|
200
|
+
$pinia: import('pinia').Pinia;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
}
|
|
205
|
+
content += '\nexport {};';
|
|
206
|
+
return content;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Genera el contenido del archivo vue-shims.d.ts
|
|
210
|
+
* @returns El contenido completo del archivo de shims
|
|
211
|
+
*/
|
|
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 {};
|
|
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
|
+
});
|
|
196
436
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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;
|
|
437
|
+
catch (error) {
|
|
438
|
+
console.error('Error in auto-setup Vue types:', error);
|
|
439
|
+
return false;
|
|
211
440
|
}
|
|
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}};
|
|
441
|
+
};
|
|
442
|
+
//# sourceMappingURL=vue-types-setup.js.map
|