wu-framework 1.1.9 → 1.1.11
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/wu-framework.cjs.js +1 -1
- package/dist/wu-framework.cjs.js.map +1 -1
- package/dist/wu-framework.dev.js +1 -1
- package/dist/wu-framework.dev.js.map +1 -1
- package/dist/wu-framework.esm.js +1 -1
- package/dist/wu-framework.esm.js.map +1 -1
- package/dist/wu-framework.umd.js +1 -1
- package/dist/wu-framework.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/react/index.js +29 -14
- package/src/core/wu-performance.js +1 -1
package/package.json
CHANGED
|
@@ -35,25 +35,38 @@ async function ensureReact() {
|
|
|
35
35
|
|
|
36
36
|
try {
|
|
37
37
|
// Intentar obtener de window (común en microfrontends)
|
|
38
|
-
if (typeof window !== 'undefined') {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
if (typeof window !== 'undefined' && window.React && window.ReactDOM) {
|
|
39
|
+
adapterState.React = window.React;
|
|
40
|
+
adapterState.ReactDOM = window.ReactDOM;
|
|
41
|
+
|
|
42
|
+
// createRoot puede estar en window.ReactDOM (si importaron de react-dom/client)
|
|
43
|
+
// o no existir (si importaron de react-dom). Intentar ambos caminos.
|
|
44
|
+
if (window.ReactDOM.createRoot) {
|
|
42
45
|
adapterState.createRoot = window.ReactDOM.createRoot;
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
} else {
|
|
47
|
+
// Fallback: importar react-dom/client para obtener createRoot
|
|
48
|
+
try {
|
|
49
|
+
const clientModule = await import('react-dom/client');
|
|
50
|
+
adapterState.createRoot = (clientModule.default || clientModule).createRoot;
|
|
51
|
+
} catch {
|
|
52
|
+
console.error('[WuReact] createRoot not found. Expose window.ReactDOM from "react-dom/client", not "react-dom".');
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
45
55
|
}
|
|
56
|
+
|
|
57
|
+
adapterState.initialized = true;
|
|
58
|
+
return true;
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
// Intentar import dinámico
|
|
49
|
-
const [React,
|
|
62
|
+
const [React, ReactDOMClient] = await Promise.all([
|
|
50
63
|
import('react'),
|
|
51
64
|
import('react-dom/client')
|
|
52
65
|
]);
|
|
53
66
|
|
|
54
67
|
adapterState.React = React.default || React;
|
|
55
|
-
adapterState.ReactDOM =
|
|
56
|
-
adapterState.createRoot =
|
|
68
|
+
adapterState.ReactDOM = ReactDOMClient.default || ReactDOMClient;
|
|
69
|
+
adapterState.createRoot = (ReactDOMClient.default || ReactDOMClient).createRoot;
|
|
57
70
|
adapterState.initialized = true;
|
|
58
71
|
return true;
|
|
59
72
|
|
|
@@ -161,9 +174,13 @@ async function register(appName, Component, options = {}) {
|
|
|
161
174
|
return;
|
|
162
175
|
}
|
|
163
176
|
|
|
164
|
-
//
|
|
165
|
-
|
|
166
|
-
|
|
177
|
+
// Si ya está montado en el MISMO container, ignorar (StrictMode double-mount)
|
|
178
|
+
const existing = adapterState.roots.get(appName);
|
|
179
|
+
if (existing) {
|
|
180
|
+
if (existing.container === container) {
|
|
181
|
+
return; // Ya montado aquí, nada que hacer
|
|
182
|
+
}
|
|
183
|
+
// Diferente container → desmontar primero
|
|
167
184
|
unmountApp();
|
|
168
185
|
}
|
|
169
186
|
|
|
@@ -179,8 +196,6 @@ async function register(appName, Component, options = {}) {
|
|
|
179
196
|
root.render(element);
|
|
180
197
|
adapterState.roots.set(appName, { root, container });
|
|
181
198
|
|
|
182
|
-
console.log(`[WuReact] ✅ ${appName} mounted successfully`);
|
|
183
|
-
|
|
184
199
|
if (onMount) {
|
|
185
200
|
onMount(container);
|
|
186
201
|
}
|
|
@@ -50,7 +50,7 @@ export class WuPerformance {
|
|
|
50
50
|
const startTime = this.marks.get(markName);
|
|
51
51
|
|
|
52
52
|
if (!startTime) {
|
|
53
|
-
|
|
53
|
+
// Puede ocurrir en React StrictMode (doble mount) — no es un error
|
|
54
54
|
return 0;
|
|
55
55
|
}
|
|
56
56
|
|