wu-framework 1.0.1 → 1.0.2
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/package.json +1 -1
- package/src/index.js +49 -32
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -75,41 +75,58 @@
|
|
|
75
75
|
|
|
76
76
|
import { WuCore } from './core/wu-core.js';
|
|
77
77
|
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
//
|
|
78
|
+
// 🔑 SINGLETON PATTERN: Reusar instancia global si existe
|
|
79
|
+
// Esto permite que los microfrontends importen wu-framework y usen la misma instancia del host
|
|
80
|
+
let wu;
|
|
81
|
+
|
|
82
|
+
if (typeof window !== 'undefined' && window.wu && window.wu._isWuFramework) {
|
|
83
|
+
// Ya existe una instancia del host - reutilizarla
|
|
84
|
+
wu = window.wu;
|
|
85
|
+
console.log('🔗 Wu Framework - Reusing existing instance from host');
|
|
86
|
+
} else {
|
|
87
|
+
// Primera carga - crear nueva instancia
|
|
88
|
+
wu = new WuCore({
|
|
89
|
+
healthMonitoring: true,
|
|
90
|
+
autoHeal: true,
|
|
91
|
+
agingThreshold: Infinity,
|
|
92
|
+
healthCheckInterval: 60000
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Marcar como instancia de wu-framework
|
|
96
|
+
wu._isWuFramework = true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Hacer wu disponible globalmente
|
|
88
100
|
if (typeof window !== 'undefined') {
|
|
89
|
-
window.wu
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
wu.info = {
|
|
94
|
-
name: 'Wu Framework',
|
|
95
|
-
description: 'Universal Microfrontends',
|
|
96
|
-
features: [
|
|
97
|
-
'Framework Agnostic',
|
|
98
|
-
'Zero Config',
|
|
99
|
-
'Shadow DOM Isolation',
|
|
100
|
-
'Runtime Loading',
|
|
101
|
-
'Component Sharing'
|
|
102
|
-
]
|
|
103
|
-
};
|
|
101
|
+
if (!window.wu) {
|
|
102
|
+
window.wu = wu;
|
|
103
|
+
console.log('🚀 Wu Framework loaded - Universal Microfrontends ready');
|
|
104
|
+
}
|
|
104
105
|
|
|
105
|
-
//
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
// Siempre configurar estas propiedades (pueden faltar si es instancia reutilizada)
|
|
107
|
+
if (!wu.version) {
|
|
108
|
+
wu.version = '1.0.2';
|
|
109
|
+
wu.info = {
|
|
110
|
+
name: 'Wu Framework',
|
|
111
|
+
description: 'Universal Microfrontends',
|
|
112
|
+
features: [
|
|
113
|
+
'Framework Agnostic',
|
|
114
|
+
'Zero Config',
|
|
115
|
+
'Shadow DOM Isolation',
|
|
116
|
+
'Runtime Loading',
|
|
117
|
+
'Component Sharing'
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
111
121
|
|
|
112
|
-
|
|
122
|
+
// 📡 Exponer Event Bus API globalmente para microfrontends
|
|
123
|
+
// Esto permite: window.wu.emit() Y import { emit } from 'wu-framework'
|
|
124
|
+
if (!wu.emit) {
|
|
125
|
+
wu.emit = (eventName, data, options) => wu.eventBus.emit(eventName, data, options);
|
|
126
|
+
wu.on = (eventName, callback) => wu.eventBus.on(eventName, callback);
|
|
127
|
+
wu.once = (eventName, callback) => wu.eventBus.once(eventName, callback);
|
|
128
|
+
wu.off = (eventName, callback) => wu.eventBus.off(eventName, callback);
|
|
129
|
+
}
|
|
113
130
|
}
|
|
114
131
|
|
|
115
132
|
// Exportar API principal
|