@fluwa-tool/sdk 1.0.52 → 1.0.53
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/index.js +1 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,47 +52,6 @@ let xmlHttpRequestInterceptor;
|
|
|
52
52
|
let mockResolver;
|
|
53
53
|
let urlFilter = null; // URL filter para evitar loops infinitos
|
|
54
54
|
// ============================================
|
|
55
|
-
// CONFIGURAÇÃO DE AXIOS
|
|
56
|
-
// ============================================
|
|
57
|
-
/**
|
|
58
|
-
* Forçar axios a usar fetch em vez de XMLHttpRequest
|
|
59
|
-
* Permite que FetchInterceptor mocke requisições de axios
|
|
60
|
-
*/
|
|
61
|
-
function configureAxiosToUseFetch(logger) {
|
|
62
|
-
try {
|
|
63
|
-
// Verificar se axios está disponível globalmente
|
|
64
|
-
const globalObj = typeof window !== 'undefined' ? window : globalThis;
|
|
65
|
-
const axios = globalObj.axios;
|
|
66
|
-
if (!axios) {
|
|
67
|
-
logger.debug('axios não encontrado globalmente - vai ser necessário importar manualmente');
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
// Configurar axios para usar fetch adapter
|
|
71
|
-
// Isso faz com que axios use fetch internamente, que é interceptado por FetchInterceptor
|
|
72
|
-
axios.defaults.adapter = async (config) => {
|
|
73
|
-
logger.debug(`📡 [axios -> fetch] Usando fetch para: ${config.method?.toUpperCase()} ${config.url}`);
|
|
74
|
-
const fetchConfig = {
|
|
75
|
-
method: config.method?.toUpperCase() || 'GET',
|
|
76
|
-
headers: config.headers || {},
|
|
77
|
-
body: config.data,
|
|
78
|
-
};
|
|
79
|
-
const response = await fetch(config.url, fetchConfig);
|
|
80
|
-
return {
|
|
81
|
-
data: await response.json(),
|
|
82
|
-
status: response.status,
|
|
83
|
-
statusText: response.statusText,
|
|
84
|
-
headers: response.headers,
|
|
85
|
-
config,
|
|
86
|
-
request: {},
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
logger.success('✅ axios configurado para usar fetch (FetchInterceptor ativo)');
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
logger.debug('Erro ao configurar axios para fetch:', error);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// ============================================
|
|
96
55
|
// INICIALIZAÇÃO
|
|
97
56
|
// ============================================
|
|
98
57
|
/**
|
|
@@ -137,7 +96,7 @@ async function initFluwaTool(partialConfig = {}) {
|
|
|
137
96
|
xmlHttpRequestInterceptor = new XMLHttpRequestInterceptor_1.XMLHttpRequestInterceptor(logger, requestLogger, mockResolver, sessionId, config.getAppName(), urlFilter);
|
|
138
97
|
// 8. Instalar interceptadores
|
|
139
98
|
fetchInterceptor.install();
|
|
140
|
-
|
|
99
|
+
xmlHttpRequestInterceptor.install(); // ✅ Re-ativado - axios em React Native usa XMLHttpRequest
|
|
141
100
|
// 9. Conectar WebSocket
|
|
142
101
|
logger.debug('Conectando ao WebSocket...');
|
|
143
102
|
try {
|
|
@@ -155,9 +114,6 @@ async function initFluwaTool(partialConfig = {}) {
|
|
|
155
114
|
});
|
|
156
115
|
isInitialized = true;
|
|
157
116
|
logger.success('Fluwa-Tool inicializado com sucesso!');
|
|
158
|
-
// ✅ FORÇA AXIOS USAR FETCH EM VEZ DE XMLHttpRequest
|
|
159
|
-
// Isso permite que FetchInterceptor mocke requisições de axios
|
|
160
|
-
configureAxiosToUseFetch(logger);
|
|
161
117
|
}
|
|
162
118
|
catch (error) {
|
|
163
119
|
logger.error('Erro ao inicializar Fluwa', error);
|