@upeex/ads-sdk 1.1.13 → 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
  /
@@ -4,8 +4,10 @@ type Props = {
4
4
  baseUrl?: string;
5
5
  theme?: 'light' | 'dark';
6
6
  typeAds?: 'banner' | 'popup';
7
+ typeads?: string;
7
8
  style?: object;
8
9
  debug?: boolean;
9
10
  };
10
- export default function AdBanner({ client, slot, baseUrl, theme, typeAds, style, debug, }: Props): any;
11
+ export default function AdBanner({ client, slot, baseUrl, theme, typeAds, typeads, // Receive alias
12
+ style, debug, }: Props): any;
11
13
  export {};
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,9 +79,17 @@ async function fetchAd({ baseUrl, client, slot, debug = false, typeAds, }) {
79
79
  return ad;
80
80
  }
81
81
 
82
- function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme = 'light', typeAds, style = {}, debug = false, }) {
82
+ const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
83
+ function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme = 'light', typeAds, typeads, // Receive alias
84
+ style = {}, debug = false, }) {
85
+ var _a;
83
86
  const [ad, setAd] = useState(null);
84
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();
85
93
  const log = (...args) => {
86
94
  if (debug)
87
95
  console.log('[UPEEX ADS]', ...args);
@@ -91,7 +99,13 @@ function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme
91
99
  const load = async () => {
92
100
  try {
93
101
  log('Buscando anúncio', { client, slot });
94
- const data = await fetchAd({ baseUrl, client, slot, debug, typeAds });
102
+ const data = await fetchAd({
103
+ baseUrl,
104
+ client,
105
+ slot,
106
+ debug,
107
+ typeAds: effectiveTypeAds,
108
+ });
95
109
  log('Resposta do servidor', data);
96
110
  if (!data || !data.image) {
97
111
  setError('Nenhum anúncio disponível');
@@ -100,6 +114,14 @@ function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme
100
114
  }
101
115
  setAd(data);
102
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
+ }
103
125
  if (data.refresh && data.refresh > 0) {
104
126
  log(`Refresh ativo: ${data.refresh}s`);
105
127
  refreshTimer = setTimeout(() => {
@@ -121,7 +143,7 @@ function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme
121
143
  if (refreshTimer)
122
144
  clearTimeout(refreshTimer);
123
145
  };
124
- }, [client, slot, baseUrl]);
146
+ }, [client, slot, baseUrl, effectiveTypeAds]);
125
147
  if (error) {
126
148
  return debug ? (jsx(View, { style: [styles.container, styles.debug], children: jsx(Text, { style: styles.debugText, children: error }) })) : null;
127
149
  }
@@ -139,6 +161,12 @@ function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme
139
161
  Linking.openURL(ad.clickUrl);
140
162
  }
141
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
+ }
142
170
  return (jsx(TouchableOpacity, { activeOpacity: 0.9, style: [
143
171
  styles.container,
144
172
  theme === 'dark' && styles.dark,
@@ -173,6 +201,40 @@ const styles = StyleSheet.create({
173
201
  fontSize: 11,
174
202
  color: '#c00',
175
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
+ },
176
238
  });
177
239
 
178
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.13",
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",