@upeex/ads-sdk 1.1.19 → 1.1.22

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.
Files changed (3) hide show
  1. package/README.md +42 -8
  2. package/dist/index.js +13 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -36,15 +36,46 @@ Exibe um anúncio em tela cheia (modal) sobrepondo o conteúdo.
36
36
  - **Bloqueio de 5 segundos:** O usuário deve aguardar 5 segundos antes de fechar.
37
37
  - **Spinner:** Um indicador de carregamento aparece durante o bloqueio.
38
38
  - **Sem Auto-Refresh:** O popup carrega apenas uma vez.
39
+ - **Visual:** Ocupa toda a tela (transparente na StatusBar) e a imagem é redimensionada para 90% da largura.
40
+
41
+ #### ⚠️ Onde Colocar o Popup (Importante!)
42
+
43
+ Para garantir que o popup abra corretamente e não sobreponha outros Modals de forma errada, **coloque o componente no final do seu container principal**, logo antes de fechar a view da tela.
44
+
45
+ **Exemplo Correto:**
39
46
 
40
47
  ```javascript
41
- <AdBanner
42
- client="SEU_ID_CLIENTE"
43
- slot="SEU_ID_SLOT"
44
- typeads="popup"
45
- />
48
+ return (
49
+ <View style={{ flex: 1 }}> {/* Seu Container Principal (View, SafeAreaView, etc) */}
50
+ <Header />
51
+ <Conteudo />
52
+
53
+ {/* Outros Modals do seu App */}
54
+ <Modal visible={isLoading}>...</Modal>
55
+
56
+ {/* ✅ COLOCAR AQUI, NO FINAL: */}
57
+ <AdBanner
58
+ client="SEU_ID_CLIENTE"
59
+ slot="SEU_ID_SLOT"
60
+ typeads="popup"
61
+ />
62
+ </View>
63
+ );
46
64
  ```
47
65
 
66
+ ```
67
+
68
+ **Evite colocar dentro de:**
69
+ - Componentes que são desmontados condicionalmente (`{show && <AdBanner />}`).
70
+ - Headers ou Footers com `position: absolute` ou `zIndex` restritivo.
71
+
72
+ #### ⚠️ Conflito com Outros Modals (Loading, Alertas)
73
+
74
+ O React Native pode ter problemas ao tentar exibir **dois Modals ao mesmo tempo** (ex: um Loading Spinner e o Anúncio Popup).
75
+ - Se o seu app abre um Modal de "Carregando..." ao entrar na tela, aguarde ele fechar antes de renderizar o anúncio, ou use o anúncio como o próprio loading inicial.
76
+ - O SDK possui `zIndex` alto (9999), mas o sistema operacional (especialmente Android) pode priorizar o último Modal aberto na árvore de componentes.
77
+
78
+
48
79
  ### Props Disponíveis
49
80
 
50
81
  | Prop | Tipo | Descrição |
@@ -54,10 +85,13 @@ Exibe um anúncio em tela cheia (modal) sobrepondo o conteúdo.
54
85
  | `typeads` | `'banner' \| 'popup'` | Define o formato. Padrão é `'banner'`. |
55
86
  | `theme` | `'light' \| 'dark'` | Define o tema (cores de fundo). Padrão `'light'`. |
56
87
  | `baseUrl` | `string` | URL base da API (opcional). |
57
- | `debug` | `boolean` | Ativa logs no console para depuração. Padrão `false`. |
88
+ | `debug` | `boolean` | Ativa logs no console (avisa se o componente foi desmontado erradamente). |
58
89
 
59
90
  ## Solução de Problemas
60
91
 
61
92
  - **Erro "Cannot find module 'react-native'"**: Certifique-se de que `react` e `react-native` estão instalados no seu projeto.
62
- - **Popup não abre**: Verifique se `typeads="popup"` foi passado e se o console mostra logs de "Nenhum anúncio disponível" (use `debug={true}`).
63
- - **Sobreposição**: O popup possui `zIndex: 9999` e `elevation: 11`. Se ainda estiver atrás de algum elemento, verifique se o componente pai não tem um `zIndex` maior ou se está dentro de um Modal nativo do OS.
93
+ - **Popup não abre**:
94
+ 1. Verifique se `typeads="popup"`.
95
+ 2. Ative `debug={true}` e olhe o console. Se aparecer "Nenhum anúncio disponível", é normal.
96
+ 3. Se aparecer o aviso "O componente foi desmontado...", mova o `<AdBanner />` para a raiz da tela.
97
+ - **Sobreposição**: O popup possui `zIndex: 9999` e `elevation: 11`. Se ainda estiver atrás de algum elemento, verifique se o pai não tem um `zIndex` maior.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useState, useEffect } from 'react';
2
+ import React, { useState, useEffect } from 'react';
3
3
  import { Platform, Dimensions, StyleSheet, View, Text, Modal, TouchableWithoutFeedback, TouchableOpacity, ActivityIndicator, Image, Linking } from 'react-native';
4
4
 
5
5
  async function getSignals() {
@@ -91,6 +91,11 @@ style = {}, debug = false, }) {
91
91
  };
92
92
  const effectiveTypeAds = (_a = (typeAds || typeads)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
93
93
  const isPopup = effectiveTypeAds === 'popup';
94
+ // Track visibility with ref to avoid dependency loops in useEffect
95
+ const isVisibleRef = React.useRef(false);
96
+ useEffect(() => {
97
+ isVisibleRef.current = modalVisible;
98
+ }, [modalVisible]);
94
99
  useEffect(() => {
95
100
  let refreshTimer;
96
101
  const load = async () => {
@@ -135,8 +140,11 @@ style = {}, debug = false, }) {
135
140
  return () => {
136
141
  if (refreshTimer)
137
142
  clearTimeout(refreshTimer);
143
+ if (isPopup && isVisibleRef.current && debug) {
144
+ console.warn('[UPEEX ADS] Aviso: O componente AdBanner (Popup) foi desmontado enquanto estava visível. Verifique se ele não está dentro de uma View que foi ocultada ou removida da tela.');
145
+ }
138
146
  };
139
- }, [client, slot, baseUrl, effectiveTypeAds]);
147
+ }, [client, slot, baseUrl, effectiveTypeAds]); // Removed modalVisible to prevent loops
140
148
  // Popup close delay logic
141
149
  const [canClose, setCanClose] = useState(false);
142
150
  useEffect(() => {
@@ -176,12 +184,12 @@ style = {}, debug = false, }) {
176
184
  return debug ? (jsx(View, { style: [styles.upeexContainer, styles.upeexLoading], children: jsx(Text, { style: styles.upeexLoadingText, children: "Carregando an\u00FAncio\u2026" }) })) : null;
177
185
  }
178
186
  if (isPopup) {
179
- return (jsx(Modal, { transparent: true, visible: modalVisible, onRequestClose: handleClose, animationType: "fade", children: jsx(TouchableWithoutFeedback, { onPress: handleClose, children: jsx(View, { style: styles.upeexOverlay, children: jsx(TouchableWithoutFeedback, { onPress: () => { }, children: jsxs(View, { style: [
187
+ return (jsx(Modal, { transparent: true, visible: modalVisible, onRequestClose: handleClose, animationType: "fade", statusBarTranslucent: true, hardwareAccelerated: true, children: jsx(TouchableWithoutFeedback, { onPress: handleClose, children: jsx(View, { style: styles.upeexOverlay, children: jsx(TouchableWithoutFeedback, { onPress: () => { }, children: jsxs(View, { style: [
180
188
  styles.upeexPopupContainer,
181
189
  theme === 'dark' && styles.upeexDark,
182
190
  ], children: [canClose ? (jsx(TouchableOpacity, { onPress: handleClose, style: styles.upeexCloseButton, children: jsx(Text, { style: styles.upeexCloseText, children: "\u2715" }) })) : (jsx(View, { style: styles.upeexCloseButton, children: jsx(ActivityIndicator, { size: "small", color: "#999" }) })), jsx(TouchableOpacity, { activeOpacity: 0.9, onPress: handlePress, children: jsx(Image, { source: { uri: ad.image }, style: {
183
- width: ad.width || 300,
184
- height: ad.height || 300,
191
+ width: Dimensions.get('window').width * 0.9,
192
+ height: Dimensions.get('window').height * 0.8,
185
193
  resizeMode: 'contain',
186
194
  } }) })] }) }) }) }) }));
187
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upeex/ads-sdk",
3
- "version": "1.1.19",
3
+ "version": "1.1.22",
4
4
  "description": "Upeex Ads SDK for React Native and universal apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",