@upeex/ads-sdk 1.1.16 → 1.1.17

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 CHANGED
@@ -4,38 +4,13 @@ SDK para aplicaçõe React Native rodarem anúncios:
4
4
  # Comando para inciar
5
5
  npm i @upeex/ads-sdk
6
6
 
7
- ## Como usar
7
+ ### Como importar
8
8
 
9
- ### Importação
10
-
11
- ```javascript
9
+ ```js
12
10
  import AdBanner from '@upeex/ads-sdk';
13
- ```
14
-
15
- ### 1. Anúncio Tipo Banner (Padrão)
16
- Exibe um banner na posição onde o componente é colocado.
17
-
18
- ```javascript
19
- <AdBanner
20
- client="CLIENT_ID"
21
- slot="SLOT_ID"
22
- typeAds="banner" // Opcional (padrão é banner)
23
- />
24
- ```
25
-
26
- ### 2. Anúncio Tipo Popup (Tela Cheia)
27
- Exibe um modal em tela cheia sobrepondo o conteúdo.
28
- - O botão de fechar aparece após **5 segundos**.
29
- - Não possui refresh automático.
30
-
31
- ```javascript
32
- <AdBanner
33
- client="CLIENT_ID"
34
- slot="SLOT_ID"
35
- typeAds="popup"
36
- />
37
- ```
38
-
39
- ### Props Disponíveis
40
11
 
41
- | `debug` | `boolean` | Ativa logs no console |
12
+ // Carregar anúncio
13
+ <AdBanner
14
+ client="SEU_CLIENTE"
15
+ slot="SEU_SLOT"
16
+ /
@@ -9,5 +9,5 @@ type Props = {
9
9
  debug?: boolean;
10
10
  };
11
11
  export default function AdBanner({ client, slot, baseUrl, theme, typeAds, typeads, // Receive alias
12
- style, debug, }: Props): import("react/jsx-runtime").JSX.Element;
12
+ style, debug, }: Props): any;
13
13
  export {};
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useState, useRef, useEffect } from 'react';
3
- import { Platform, Dimensions, Animated, StyleSheet, View, Text, Modal, TouchableOpacity, Image, ActivityIndicator, Linking } from 'react-native';
2
+ import { useState, useEffect } from 'react';
3
+ import { Platform, Dimensions, StyleSheet, View, Text, Modal, TouchableOpacity, Image, Linking } from 'react-native';
4
4
 
5
5
  async function getSignals() {
6
6
  var _a, _b, _c, _d, _e, _f;
@@ -79,24 +79,18 @@ async function fetchAd({ baseUrl, client, slot, debug = false, typeAds, }) {
79
79
  return ad;
80
80
  }
81
81
 
82
- const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
83
- // Workaround for TS2604: JSX element type 'Animated.View' does not have any construct or call signatures.
84
- const AnimatedView = Animated.View;
85
82
  function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme = 'light', typeAds, typeads, // Receive alias
86
83
  style = {}, debug = false, }) {
87
84
  var _a;
88
85
  const [ad, setAd] = useState(null);
89
86
  const [error, setError] = useState(null);
90
87
  const [modalVisible, setModalVisible] = useState(false);
91
- const [canClose, setCanClose] = useState(false);
92
- const progressAnim = useRef(new Animated.Value(0)).current;
93
- // Normalize typeAds: prefer typeAds, fallback to typeads, default undefined.
94
- // Ensure lowercase for backend compatibility (POPUP -> popup)
95
- const effectiveTypeAds = (_a = (typeAds || typeads)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
96
88
  const log = (...args) => {
97
89
  if (debug)
98
90
  console.log('[UPEEX ADS]', ...args);
99
91
  };
92
+ const effectiveTypeAds = (_a = (typeAds || typeads)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
93
+ const isPopup = effectiveTypeAds === 'popup';
100
94
  useEffect(() => {
101
95
  let refreshTimer;
102
96
  const load = async () => {
@@ -117,29 +111,15 @@ style = {}, debug = false, }) {
117
111
  }
118
112
  setAd(data);
119
113
  setError(null);
120
- if (effectiveTypeAds === 'popup') {
114
+ if (isPopup) {
121
115
  setModalVisible(true);
122
- setCanClose(false);
123
- progressAnim.setValue(0);
124
- Animated.timing(progressAnim, {
125
- toValue: 1,
126
- duration: 5000,
127
- useNativeDriver: false,
128
- }).start(({ finished }) => {
129
- if (finished) {
130
- setCanClose(true);
131
- }
132
- });
133
116
  }
134
- // Only enable refresh if it's NOT a popup
135
- if (effectiveTypeAds !== 'popup') {
136
- if (data.refresh && data.refresh > 0) {
137
- log(`Refresh ativo: ${data.refresh}s`);
138
- refreshTimer = setTimeout(() => {
139
- log('Refazendo request do anúncio');
140
- load();
141
- }, data.refresh * 1000);
142
- }
117
+ if (data.refresh && data.refresh > 0) {
118
+ log(`Refresh ativo: ${data.refresh}s`);
119
+ refreshTimer = setTimeout(() => {
120
+ log('Refazendo request do anúncio');
121
+ load();
122
+ }, data.refresh * 1000);
143
123
  }
144
124
  }
145
125
  catch (err) {
@@ -156,14 +136,11 @@ style = {}, debug = false, }) {
156
136
  clearTimeout(refreshTimer);
157
137
  };
158
138
  }, [client, slot, baseUrl, effectiveTypeAds]);
159
- if (error) {
160
- return debug ? (jsx(View, { style: [styles.container, styles.debug], children: jsx(Text, { style: styles.debugText, children: error }) })) : null;
161
- }
162
- if (!ad) {
163
- return debug ? (jsx(View, { style: [styles.container, styles.loading], children: jsx(Text, { style: styles.loadingText, children: "Carregando an\u00FAncio\u2026" }) })) : null;
164
- }
165
139
  const handlePress = () => {
166
140
  log('Clique no anúncio', ad.clickUrl);
141
+ if (isPopup) {
142
+ setModalVisible(false);
143
+ }
167
144
  if (!ad.clickUrl)
168
145
  return;
169
146
  if (Platform.OS === 'web') {
@@ -173,23 +150,25 @@ style = {}, debug = false, }) {
173
150
  Linking.openURL(ad.clickUrl);
174
151
  }
175
152
  };
176
- if (effectiveTypeAds === 'popup') {
177
- return (jsx(Modal, { visible: modalVisible, transparent: true, animationType: "fade", onRequestClose: () => {
178
- if (canClose)
179
- setModalVisible(false);
180
- }, children: jsxs(View, { style: styles.modalBackground, children: [!canClose && (jsx(View, { style: styles.progressBarContainer, children: jsx(AnimatedView, { style: [
181
- styles.progressBar,
182
- {
183
- width: progressAnim.interpolate({
184
- inputRange: [0, 1],
185
- outputRange: ['0%', '100%'],
186
- }),
187
- },
188
- ] }) })), jsx(TouchableOpacity, { style: styles.fullScreenTouch, activeOpacity: 1, onPress: handlePress, children: jsx(Image, { source: { uri: ad.image }, style: styles.fullScreenImage, resizeMode: "contain" }) }), jsx(TouchableOpacity, { style: styles.closeButton, onPress: () => setModalVisible(false), disabled: !canClose, children: !canClose ? (jsx(ActivityIndicator, { size: "small", color: "#fff" })) : (jsx(Text, { style: styles.closeButtonText, children: "X" })) })] }) }));
153
+ const handleClose = () => {
154
+ setModalVisible(false);
155
+ };
156
+ if (error) {
157
+ return debug ? (jsx(View, { style: [styles.upeexContainer, styles.upeexDebug], children: jsx(Text, { style: styles.upeexDebugText, children: error }) })) : null;
158
+ }
159
+ if (!ad) {
160
+ return debug ? (jsx(View, { style: [styles.upeexContainer, styles.upeexLoading], children: jsx(Text, { style: styles.upeexLoadingText, children: "Carregando an\u00FAncio\u2026" }) })) : null;
161
+ }
162
+ if (isPopup) {
163
+ return (jsx(Modal, { transparent: true, visible: modalVisible, onRequestClose: handleClose, animationType: "fade", children: jsx(View, { style: styles.upeexOverlay, children: jsxs(View, { style: [styles.upeexPopupContainer, theme === 'dark' && styles.upeexDark], children: [jsx(TouchableOpacity, { onPress: handleClose, style: styles.upeexCloseButton, children: jsx(Text, { style: styles.upeexCloseText, children: "\u2715" }) }), jsx(TouchableOpacity, { activeOpacity: 0.9, onPress: handlePress, children: jsx(Image, { source: { uri: ad.image }, style: {
164
+ width: ad.width || 300,
165
+ height: ad.height || 300,
166
+ resizeMode: 'contain',
167
+ } }) })] }) }) }));
189
168
  }
190
169
  return (jsx(TouchableOpacity, { activeOpacity: 0.9, style: [
191
- styles.container,
192
- theme === 'dark' && styles.dark,
170
+ styles.upeexContainer,
171
+ theme === 'dark' && styles.upeexDark,
193
172
  style,
194
173
  ], onPress: handlePress, children: jsx(Image, { source: { uri: ad.image }, style: {
195
174
  width: ad.width || 320,
@@ -198,74 +177,58 @@ style = {}, debug = false, }) {
198
177
  } }) }));
199
178
  }
200
179
  const styles = StyleSheet.create({
201
- container: {
180
+ upeexContainer: {
202
181
  backgroundColor: '#f2f2f2',
203
182
  padding: 8,
204
183
  alignItems: 'center',
205
184
  justifyContent: 'center',
206
185
  },
207
- dark: {
186
+ upeexDark: {
208
187
  backgroundColor: '#121212',
209
188
  },
210
- loading: {
189
+ upeexLoading: {
211
190
  backgroundColor: '#fafafa',
212
191
  },
213
- loadingText: {
192
+ upeexLoadingText: {
214
193
  fontSize: 11,
215
194
  color: '#999',
216
195
  },
217
- debug: {
196
+ upeexDebug: {
218
197
  backgroundColor: '#ffecec',
219
198
  },
220
- debugText: {
199
+ upeexDebugText: {
221
200
  fontSize: 11,
222
201
  color: '#c00',
223
202
  },
224
- modalBackground: {
203
+ upeexOverlay: {
225
204
  flex: 1,
226
- backgroundColor: 'rgba(0,0,0,0.9)',
205
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
227
206
  justifyContent: 'center',
228
207
  alignItems: 'center',
229
208
  },
230
- fullScreenTouch: {
231
- flex: 1,
232
- width: '100%',
233
- height: '100%',
234
- justifyContent: 'center',
209
+ upeexPopupContainer: {
210
+ backgroundColor: '#fff',
211
+ padding: 20,
212
+ borderRadius: 10,
235
213
  alignItems: 'center',
214
+ position: 'relative',
215
+ elevation: 5,
216
+ shadowColor: '#000',
217
+ shadowOffset: { width: 0, height: 2 },
218
+ shadowOpacity: 0.25,
219
+ shadowRadius: 3.84,
236
220
  },
237
- fullScreenImage: {
238
- width: '90%',
239
- height: '90%',
240
- },
241
- closeButton: {
221
+ upeexCloseButton: {
242
222
  position: 'absolute',
243
- top: 50,
244
- right: 20,
245
- backgroundColor: 'rgba(0,0,0,0.6)',
246
- width: 40,
247
- height: 40,
248
- borderRadius: 20,
249
- justifyContent: 'center',
250
- alignItems: 'center',
251
- zIndex: 999,
223
+ top: 5,
224
+ right: 5,
225
+ zIndex: 1,
226
+ padding: 5,
252
227
  },
253
- closeButtonText: {
254
- color: '#fff',
228
+ upeexCloseText: {
255
229
  fontSize: 18,
256
230
  fontWeight: 'bold',
257
- },
258
- progressBarContainer: {
259
- position: 'absolute',
260
- top: 0,
261
- left: 0,
262
- width: '100%',
263
- height: 5,
264
- backgroundColor: 'rgba(255,255,255,0.3)',
265
- zIndex: 1000,
266
- },
267
- progressBar: {
268
- height: '100%',
231
+ color: '#333',
269
232
  },
270
233
  });
271
234
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upeex/ads-sdk",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
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",
@@ -27,11 +27,10 @@
27
27
  "author": "Upeex",
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
+ "@upeex/ads-sdk": "^1.1.10",
30
31
  "expo-localization": "^17.0.8"
31
32
  },
32
33
  "devDependencies": {
33
- "@types/react": "^19.2.13",
34
- "@types/react-native": "^0.73.0",
35
34
  "rollup": "^4.57.0",
36
35
  "rollup-plugin-typescript2": "^0.36.0",
37
36
  "tslib": "^2.8.1",