@upeex/ads-sdk 1.1.14 → 1.1.15

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
@@ -13,4 +13,5 @@ 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
16
17
  /
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsx } from 'react/jsx-runtime';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useEffect } from 'react';
3
- import { Platform, Dimensions, StyleSheet, View, Text, TouchableOpacity, Image, Linking } from 'react-native';
3
+ import { Platform, Dimensions, StyleSheet, View, Text, Modal, TouchableOpacity, Image, ActivityIndicator, Linking } from 'react-native';
4
4
 
5
5
  async function getSignals() {
6
6
  var _a, _b, _c, _d, _e, _f;
@@ -79,10 +79,17 @@ 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');
82
83
  function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme = 'light', typeAds, typeads, // Receive alias
83
84
  style = {}, debug = false, }) {
85
+ var _a;
84
86
  const [ad, setAd] = useState(null);
85
87
  const [error, setError] = useState(null);
88
+ 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();
86
93
  const log = (...args) => {
87
94
  if (debug)
88
95
  console.log('[UPEEX ADS]', ...args);
@@ -90,12 +97,8 @@ style = {}, debug = false, }) {
90
97
  useEffect(() => {
91
98
  let refreshTimer;
92
99
  const load = async () => {
93
- var _a;
94
100
  try {
95
101
  log('Buscando anúncio', { client, slot });
96
- // Normalize typeAds: prefer typeAds, fallback to typeads, default undefined.
97
- // Ensure lowercase for backend compatibility (POPUP -> popup)
98
- const effectiveTypeAds = (_a = (typeAds || typeads)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
99
102
  const data = await fetchAd({
100
103
  baseUrl,
101
104
  client,
@@ -111,6 +114,14 @@ style = {}, debug = false, }) {
111
114
  }
112
115
  setAd(data);
113
116
  setError(null);
117
+ if (effectiveTypeAds === 'popup') {
118
+ setModalVisible(true);
119
+ setCanClose(false);
120
+ // Timer to enable close button
121
+ setTimeout(() => {
122
+ setCanClose(true);
123
+ }, 2000);
124
+ }
114
125
  if (data.refresh && data.refresh > 0) {
115
126
  log(`Refresh ativo: ${data.refresh}s`);
116
127
  refreshTimer = setTimeout(() => {
@@ -132,7 +143,7 @@ style = {}, debug = false, }) {
132
143
  if (refreshTimer)
133
144
  clearTimeout(refreshTimer);
134
145
  };
135
- }, [client, slot, baseUrl]);
146
+ }, [client, slot, baseUrl, effectiveTypeAds]);
136
147
  if (error) {
137
148
  return debug ? (jsx(View, { style: [styles.container, styles.debug], children: jsx(Text, { style: styles.debugText, children: error }) })) : null;
138
149
  }
@@ -150,6 +161,12 @@ style = {}, debug = false, }) {
150
161
  Linking.openURL(ad.clickUrl);
151
162
  }
152
163
  };
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" })) })] }) }));
169
+ }
153
170
  return (jsx(TouchableOpacity, { activeOpacity: 0.9, style: [
154
171
  styles.container,
155
172
  theme === 'dark' && styles.dark,
@@ -184,6 +201,40 @@ const styles = StyleSheet.create({
184
201
  fontSize: 11,
185
202
  color: '#c00',
186
203
  },
204
+ modalBackground: {
205
+ flex: 1,
206
+ backgroundColor: 'rgba(0,0,0,0.9)',
207
+ justifyContent: 'center',
208
+ alignItems: 'center',
209
+ },
210
+ fullScreenTouch: {
211
+ flex: 1,
212
+ width: '100%',
213
+ height: '100%',
214
+ justifyContent: 'center',
215
+ alignItems: 'center',
216
+ },
217
+ fullScreenImage: {
218
+ width: '90%',
219
+ height: '90%',
220
+ },
221
+ closeButton: {
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,
232
+ },
233
+ closeButtonText: {
234
+ color: '#fff',
235
+ fontSize: 18,
236
+ fontWeight: 'bold',
237
+ },
187
238
  });
188
239
 
189
240
  export { AdBanner, AdBanner as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upeex/ads-sdk",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
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",