versacompiler 2.1.0 → 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 -25
- 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 -1
- 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 -22
- 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 +589 -2
- package/dist/servicios/file-watcher.js +425 -4
- package/dist/servicios/logger.js +63 -3
- package/dist/servicios/readConfig.js +399 -53
- 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 +1 -1
- package/dist/wrappers/oxlint-node.js +122 -1
- package/dist/wrappers/tailwind-node.js +94 -1
- package/package.json +106 -103
|
@@ -1 +1,313 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Script para obtener la instancia de Vue usando solo JavaScript
|
|
3
|
+
* Compatible con Vue 2 y Vue 3
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} VueInstance
|
|
8
|
+
* @property {string} [version] - Versión de Vue
|
|
9
|
+
* @property {Object} [config] - Configuración de Vue
|
|
10
|
+
* @property {Object} [proxy] - Proxy del componente
|
|
11
|
+
* @property {Object} [$options] - Opciones del componente (Vue 2)
|
|
12
|
+
* @property {Object} [$router] - Router de Vue
|
|
13
|
+
* @property {Object} [$store] - Store de Vuex/Pinia
|
|
14
|
+
* @property {Array} [$children] - Componentes hijos (Vue 2)
|
|
15
|
+
* @property {Object} [$data] - Datos del componente (Vue 2)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @typedef {Object} VueInstanceInfo
|
|
20
|
+
* @property {string|null} version - Versión de Vue detectada
|
|
21
|
+
* @property {string|null} type - Tipo de instancia de Vue
|
|
22
|
+
* @property {boolean} hasRouter - Indica si tiene Vue Router
|
|
23
|
+
* @property {boolean} hasStore - Indica si tiene Vuex/Pinia
|
|
24
|
+
* @property {Object|number} components - Información de componentes
|
|
25
|
+
* @property {string[]|null} data - Claves de datos del componente
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Obtiene la instancia de Vue desde un elemento específico del DOM
|
|
30
|
+
* @param {string} [selector='#app'] - Selector CSS del elemento que contiene la aplicación Vue
|
|
31
|
+
* @returns {VueInstance|null} Instancia de Vue o null si no se encuentra
|
|
32
|
+
*/
|
|
33
|
+
function getVueInstanceFromElement(selector = '#app') {
|
|
34
|
+
const element = document.querySelector(selector);
|
|
35
|
+
if (!element) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Para Vue 3
|
|
40
|
+
if (element.__vue_app__) {
|
|
41
|
+
return element.__vue_app__;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Para Vue 2
|
|
45
|
+
if (element.__vue__) {
|
|
46
|
+
return element.__vue__;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Busca instancias de Vue en todos los elementos del DOM
|
|
54
|
+
* @returns {VueInstance|null} Primera instancia de Vue encontrada o null si no se encuentra ninguna
|
|
55
|
+
*/
|
|
56
|
+
function findVueInstanceInDOM() {
|
|
57
|
+
const allElements = document.querySelectorAll('*');
|
|
58
|
+
|
|
59
|
+
for (const element of allElements) {
|
|
60
|
+
// Vue 3
|
|
61
|
+
if (element.__vue_app__) {
|
|
62
|
+
return element.__vue_app__;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Vue 2
|
|
66
|
+
if (element.__vue__) {
|
|
67
|
+
return element.__vue__;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Obtiene la instancia de Vue desde variables globales o herramientas de desarrollo
|
|
76
|
+
* @returns {VueInstance|null} Instancia de Vue desde el contexto global o null si no se encuentra
|
|
77
|
+
*/
|
|
78
|
+
function getVueFromGlobal() {
|
|
79
|
+
// Verificar si Vue está en el objeto global
|
|
80
|
+
if (typeof window !== 'undefined') {
|
|
81
|
+
// Vue como variable global
|
|
82
|
+
if (window.Vue) {
|
|
83
|
+
return window.Vue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Instancia específica guardada globalmente
|
|
87
|
+
if (window.__VUE_APP_INSTANCE__) {
|
|
88
|
+
return window.__VUE_APP_INSTANCE__;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Vue DevTools
|
|
92
|
+
if (window.__VUE_DEVTOOLS_GLOBAL_HOOK__) {
|
|
93
|
+
const apps = window.__VUE_DEVTOOLS_GLOBAL_HOOK__.apps;
|
|
94
|
+
if (apps && apps.length > 0) {
|
|
95
|
+
return apps[0];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Obtiene el componente raíz específico de Vue 3
|
|
105
|
+
* @param {string} [selector='#app'] - Selector CSS del elemento que contiene la aplicación Vue
|
|
106
|
+
* @returns {VueInstance|null} Componente raíz de Vue 3 o null si no se encuentra
|
|
107
|
+
*/
|
|
108
|
+
function getVue3RootComponent(selector = '#app') {
|
|
109
|
+
const element = document.querySelector(selector);
|
|
110
|
+
if (!element) return null;
|
|
111
|
+
|
|
112
|
+
// Vue 3 específico
|
|
113
|
+
if (element._vnode && element._vnode.component) {
|
|
114
|
+
return element._vnode.component;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (element.__vueParentComponent) {
|
|
118
|
+
return element.__vueParentComponent;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Método principal que intenta obtener la instancia de Vue usando múltiples estrategias
|
|
126
|
+
* @param {string} [selector='#app'] - Selector CSS del elemento que contiene la aplicación Vue
|
|
127
|
+
* @returns {VueInstance|null} Instancia de Vue encontrada o null si no se encuentra
|
|
128
|
+
*/
|
|
129
|
+
function getVueInstance(selector = '#app') {
|
|
130
|
+
let instance = null;
|
|
131
|
+
|
|
132
|
+
// Intentar método 1: Desde elemento específico
|
|
133
|
+
instance = getVueInstanceFromElement(selector);
|
|
134
|
+
if (instance) {
|
|
135
|
+
return instance;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Intentar método 2: Buscar en DOM
|
|
139
|
+
instance = findVueInstanceInDOM();
|
|
140
|
+
if (instance) {
|
|
141
|
+
return instance;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Intentar método 3: Desde global
|
|
145
|
+
instance = getVueFromGlobal();
|
|
146
|
+
if (instance) {
|
|
147
|
+
return instance;
|
|
148
|
+
} // Intentar método 4: Componente raíz Vue 3
|
|
149
|
+
instance = getVue3RootComponent(selector);
|
|
150
|
+
if (instance) {
|
|
151
|
+
return instance;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Espera a que una instancia de Vue esté disponible en el DOM
|
|
159
|
+
* @param {string} [selector='#app'] - Selector CSS del elemento que contiene la aplicación Vue
|
|
160
|
+
* @param {number} [timeout=5000] - Tiempo máximo de espera en milisegundos
|
|
161
|
+
* @returns {Promise<VueInstance>} Promise que resuelve con la instancia de Vue o rechaza si hay timeout
|
|
162
|
+
*/
|
|
163
|
+
function waitForVue(selector = '#app', timeout = 5000) {
|
|
164
|
+
return new Promise((resolve, reject) => {
|
|
165
|
+
const startTime = Date.now();
|
|
166
|
+
|
|
167
|
+
function check() {
|
|
168
|
+
const instance = getVueInstance(selector);
|
|
169
|
+
|
|
170
|
+
if (instance) {
|
|
171
|
+
resolve(instance);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (Date.now() - startTime > timeout) {
|
|
176
|
+
reject(
|
|
177
|
+
new Error(
|
|
178
|
+
'Timeout: No se pudo encontrar la instancia de Vue',
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setTimeout(check, 100);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
check();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Obtiene información detallada sobre una instancia de Vue
|
|
193
|
+
* @param {VueInstance} instance - Instancia de Vue a analizar
|
|
194
|
+
* @returns {VueInstanceInfo|null} Objeto con información detallada de la instancia o null si no es válida
|
|
195
|
+
*/
|
|
196
|
+
function getVueInstanceInfo(instance) {
|
|
197
|
+
if (!instance) return null;
|
|
198
|
+
|
|
199
|
+
const info = {
|
|
200
|
+
version: null,
|
|
201
|
+
type: null,
|
|
202
|
+
hasRouter: false,
|
|
203
|
+
hasStore: false,
|
|
204
|
+
components: {},
|
|
205
|
+
data: null,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// Detectar versión y tipo
|
|
209
|
+
if (instance.version) {
|
|
210
|
+
info.version = instance.version;
|
|
211
|
+
info.type = 'Vue Constructor';
|
|
212
|
+
} else if (instance.config && instance.config.globalProperties) {
|
|
213
|
+
info.type = 'Vue 3 App Instance';
|
|
214
|
+
info.version = '3.x';
|
|
215
|
+
} else if (instance.$options) {
|
|
216
|
+
info.type = 'Vue 2 Component Instance';
|
|
217
|
+
info.version = '2.x';
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Verificar router
|
|
221
|
+
if (
|
|
222
|
+
instance.$router ||
|
|
223
|
+
(instance.config && instance.config.globalProperties.$router)
|
|
224
|
+
) {
|
|
225
|
+
info.hasRouter = true;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Verificar store (Vuex/Pinia)
|
|
229
|
+
if (
|
|
230
|
+
instance.$store ||
|
|
231
|
+
(instance.config && instance.config.globalProperties.$store)
|
|
232
|
+
) {
|
|
233
|
+
info.hasStore = true;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Obtener componentes (Vue 2)
|
|
237
|
+
if (instance.$children) {
|
|
238
|
+
info.components = instance.$children.length;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Obtener data (Vue 2)
|
|
242
|
+
if (instance.$data) {
|
|
243
|
+
info.data = Object.keys(instance.$data);
|
|
244
|
+
}
|
|
245
|
+
return info;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Función principal que obtiene la instancia de Vue con toda la lógica integrada
|
|
250
|
+
* @param {string} [selector='#app'] - Selector CSS del elemento que contiene la aplicación Vue
|
|
251
|
+
* @param {number} [timeout=3000] - Tiempo máximo de espera en milisegundos
|
|
252
|
+
* @returns {Promise<VueInstance|null>} Promise que resuelve con la instancia de Vue o null si no se encuentra
|
|
253
|
+
*/
|
|
254
|
+
async function obtenerInstanciaVue(selector = '#app', timeout = 3000) {
|
|
255
|
+
try {
|
|
256
|
+
// Intentar obtener la instancia inmediatamente
|
|
257
|
+
let instance = getVueInstance(selector);
|
|
258
|
+
|
|
259
|
+
if (instance) {
|
|
260
|
+
// Obtener información detallada
|
|
261
|
+
const info = getVueInstanceInfo(instance);
|
|
262
|
+
console.log('✔️ Instancia Vue encontrada:', {
|
|
263
|
+
instance,
|
|
264
|
+
info,
|
|
265
|
+
version: info?.version || 'Desconocida',
|
|
266
|
+
type: info?.type || 'Desconocido',
|
|
267
|
+
});
|
|
268
|
+
return instance;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Si no se encuentra inmediatamente, esperar
|
|
272
|
+
console.log('⏳ Esperando instancia Vue...');
|
|
273
|
+
instance = await waitForVue(selector, timeout);
|
|
274
|
+
|
|
275
|
+
if (instance) {
|
|
276
|
+
const info = getVueInstanceInfo(instance);
|
|
277
|
+
console.log('✔️ Instancia Vue encontrada después de esperar:', {
|
|
278
|
+
instance,
|
|
279
|
+
info,
|
|
280
|
+
version: info?.version || 'Desconocida',
|
|
281
|
+
type: info?.type || 'Desconocido',
|
|
282
|
+
});
|
|
283
|
+
return instance;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
console.warn('⚠️ No se pudo encontrar la instancia de Vue');
|
|
287
|
+
return null;
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.error('❌ Error obteniendo instancia Vue:', error);
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Exporta la función principal para obtener instancias de Vue
|
|
296
|
+
* @default obtenerInstanciaVue
|
|
297
|
+
*/
|
|
298
|
+
export default obtenerInstanciaVue;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Exporta funciones adicionales para uso individual
|
|
302
|
+
* @namespace VueInstanceHelpers
|
|
303
|
+
*/
|
|
304
|
+
export {
|
|
305
|
+
findVueInstanceInDOM,
|
|
306
|
+
getVue3RootComponent,
|
|
307
|
+
getVueFromGlobal,
|
|
308
|
+
getVueInstance,
|
|
309
|
+
getVueInstanceFromElement,
|
|
310
|
+
getVueInstanceInfo,
|
|
311
|
+
obtenerInstanciaVue,
|
|
312
|
+
waitForVue,
|
|
313
|
+
};
|