@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.
- package/README.md +0 -1
- package/dist/index.js +49 -54
- package/package.json +2 -2
package/README.md
CHANGED
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,
|
|
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 (
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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.
|
|
172
|
-
theme === 'dark' && styles.
|
|
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
|
-
|
|
180
|
+
upeexContainer: {
|
|
182
181
|
backgroundColor: '#f2f2f2',
|
|
183
182
|
padding: 8,
|
|
184
183
|
alignItems: 'center',
|
|
185
184
|
justifyContent: 'center',
|
|
186
185
|
},
|
|
187
|
-
|
|
186
|
+
upeexDark: {
|
|
188
187
|
backgroundColor: '#121212',
|
|
189
188
|
},
|
|
190
|
-
|
|
189
|
+
upeexLoading: {
|
|
191
190
|
backgroundColor: '#fafafa',
|
|
192
191
|
},
|
|
193
|
-
|
|
192
|
+
upeexLoadingText: {
|
|
194
193
|
fontSize: 11,
|
|
195
194
|
color: '#999',
|
|
196
195
|
},
|
|
197
|
-
|
|
196
|
+
upeexDebug: {
|
|
198
197
|
backgroundColor: '#ffecec',
|
|
199
198
|
},
|
|
200
|
-
|
|
199
|
+
upeexDebugText: {
|
|
201
200
|
fontSize: 11,
|
|
202
201
|
color: '#c00',
|
|
203
202
|
},
|
|
204
|
-
|
|
203
|
+
upeexOverlay: {
|
|
205
204
|
flex: 1,
|
|
206
|
-
backgroundColor: 'rgba(0,0,0,0.
|
|
205
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
207
206
|
justifyContent: 'center',
|
|
208
207
|
alignItems: 'center',
|
|
209
208
|
},
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
218
|
-
width: '90%',
|
|
219
|
-
height: '90%',
|
|
220
|
-
},
|
|
221
|
-
closeButton: {
|
|
221
|
+
upeexCloseButton: {
|
|
222
222
|
position: 'absolute',
|
|
223
|
-
top:
|
|
224
|
-
right:
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
+
}
|