@upeex/ads-sdk 1.1.15 → 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.
Files changed (3) hide show
  1. package/README.md +0 -1
  2. package/dist/index.js +49 -54
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -13,5 +13,4 @@ import AdBanner from '@upeex/ads-sdk';
13
13
  <AdBanner
14
14
  client="SEU_CLIENTE"
15
15
  slot="SEU_SLOT"
16
- typeAds="banner" // banner ou popup
17
16
  /
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useEffect } from 'react';
3
- import { Platform, Dimensions, StyleSheet, View, Text, Modal, TouchableOpacity, Image, ActivityIndicator, Linking } from 'react-native';
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,21 +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
82
  function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme = 'light', typeAds, typeads, // Receive alias
84
83
  style = {}, debug = false, }) {
85
84
  var _a;
86
85
  const [ad, setAd] = useState(null);
87
86
  const [error, setError] = useState(null);
88
87
  const [modalVisible, setModalVisible] = useState(false);
89
- const [canClose, setCanClose] = useState(false);
90
- // Normalize typeAds: prefer typeAds, fallback to typeads, default undefined.
91
- // Ensure lowercase for backend compatibility (POPUP -> popup)
92
- const effectiveTypeAds = (_a = (typeAds || typeads)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
93
88
  const log = (...args) => {
94
89
  if (debug)
95
90
  console.log('[UPEEX ADS]', ...args);
96
91
  };
92
+ const effectiveTypeAds = (_a = (typeAds || typeads)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
93
+ const isPopup = effectiveTypeAds === 'popup';
97
94
  useEffect(() => {
98
95
  let refreshTimer;
99
96
  const load = async () => {
@@ -114,13 +111,8 @@ style = {}, debug = false, }) {
114
111
  }
115
112
  setAd(data);
116
113
  setError(null);
117
- if (effectiveTypeAds === 'popup') {
114
+ if (isPopup) {
118
115
  setModalVisible(true);
119
- setCanClose(false);
120
- // Timer to enable close button
121
- setTimeout(() => {
122
- setCanClose(true);
123
- }, 2000);
124
116
  }
125
117
  if (data.refresh && data.refresh > 0) {
126
118
  log(`Refresh ativo: ${data.refresh}s`);
@@ -144,14 +136,11 @@ style = {}, debug = false, }) {
144
136
  clearTimeout(refreshTimer);
145
137
  };
146
138
  }, [client, slot, baseUrl, effectiveTypeAds]);
147
- if (error) {
148
- return debug ? (jsx(View, { style: [styles.container, styles.debug], children: jsx(Text, { style: styles.debugText, children: error }) })) : null;
149
- }
150
- if (!ad) {
151
- return debug ? (jsx(View, { style: [styles.container, styles.loading], children: jsx(Text, { style: styles.loadingText, children: "Carregando an\u00FAncio\u2026" }) })) : null;
152
- }
153
139
  const handlePress = () => {
154
140
  log('Clique no anúncio', ad.clickUrl);
141
+ if (isPopup) {
142
+ setModalVisible(false);
143
+ }
155
144
  if (!ad.clickUrl)
156
145
  return;
157
146
  if (Platform.OS === 'web') {
@@ -161,15 +150,25 @@ style = {}, debug = false, }) {
161
150
  Linking.openURL(ad.clickUrl);
162
151
  }
163
152
  };
164
- if (effectiveTypeAds === 'popup') {
165
- return (jsx(Modal, { visible: modalVisible, transparent: true, animationType: "fade", onRequestClose: () => {
166
- if (canClose)
167
- setModalVisible(false);
168
- }, children: jsxs(View, { style: styles.modalBackground, children: [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
+ } }) })] }) }) }));
169
168
  }
170
169
  return (jsx(TouchableOpacity, { activeOpacity: 0.9, style: [
171
- styles.container,
172
- theme === 'dark' && styles.dark,
170
+ styles.upeexContainer,
171
+ theme === 'dark' && styles.upeexDark,
173
172
  style,
174
173
  ], onPress: handlePress, children: jsx(Image, { source: { uri: ad.image }, style: {
175
174
  width: ad.width || 320,
@@ -178,62 +177,58 @@ style = {}, debug = false, }) {
178
177
  } }) }));
179
178
  }
180
179
  const styles = StyleSheet.create({
181
- container: {
180
+ upeexContainer: {
182
181
  backgroundColor: '#f2f2f2',
183
182
  padding: 8,
184
183
  alignItems: 'center',
185
184
  justifyContent: 'center',
186
185
  },
187
- dark: {
186
+ upeexDark: {
188
187
  backgroundColor: '#121212',
189
188
  },
190
- loading: {
189
+ upeexLoading: {
191
190
  backgroundColor: '#fafafa',
192
191
  },
193
- loadingText: {
192
+ upeexLoadingText: {
194
193
  fontSize: 11,
195
194
  color: '#999',
196
195
  },
197
- debug: {
196
+ upeexDebug: {
198
197
  backgroundColor: '#ffecec',
199
198
  },
200
- debugText: {
199
+ upeexDebugText: {
201
200
  fontSize: 11,
202
201
  color: '#c00',
203
202
  },
204
- modalBackground: {
203
+ upeexOverlay: {
205
204
  flex: 1,
206
- backgroundColor: 'rgba(0,0,0,0.9)',
205
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
207
206
  justifyContent: 'center',
208
207
  alignItems: 'center',
209
208
  },
210
- fullScreenTouch: {
211
- flex: 1,
212
- width: '100%',
213
- height: '100%',
214
- justifyContent: 'center',
209
+ upeexPopupContainer: {
210
+ backgroundColor: '#fff',
211
+ padding: 20,
212
+ borderRadius: 10,
215
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,
216
220
  },
217
- fullScreenImage: {
218
- width: '90%',
219
- height: '90%',
220
- },
221
- closeButton: {
221
+ upeexCloseButton: {
222
222
  position: 'absolute',
223
- top: 40,
224
- right: 20,
225
- backgroundColor: 'rgba(255, 255, 255, 0.3)',
226
- width: 40,
227
- height: 40,
228
- borderRadius: 20,
229
- justifyContent: 'center',
230
- alignItems: 'center',
231
- zIndex: 999,
223
+ top: 5,
224
+ right: 5,
225
+ zIndex: 1,
226
+ padding: 5,
232
227
  },
233
- closeButtonText: {
234
- color: '#fff',
228
+ upeexCloseText: {
235
229
  fontSize: 18,
236
230
  fontWeight: 'bold',
231
+ color: '#333',
237
232
  },
238
233
  });
239
234
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upeex/ads-sdk",
3
- "version": "1.1.15",
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",
@@ -36,4 +36,4 @@
36
36
  "tslib": "^2.8.1",
37
37
  "typescript": "^5.9.3"
38
38
  }
39
- }
39
+ }