@upeex/ads-sdk 1.1.15 → 1.1.16

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,14 +4,38 @@ 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 importar
7
+ ## Como usar
8
8
 
9
- ```js
9
+ ### Importação
10
+
11
+ ```javascript
10
12
  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
11
40
 
12
- // Carregar anúncio
13
- <AdBanner
14
- client="SEU_CLIENTE"
15
- slot="SEU_SLOT"
16
- typeAds="banner" // banner ou popup
17
- /
41
+ | `debug` | `boolean` | Ativa logs no console |
@@ -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): any;
12
+ style, debug, }: Props): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useState, useEffect } from 'react';
3
- import { Platform, Dimensions, StyleSheet, View, Text, Modal, TouchableOpacity, Image, ActivityIndicator, Linking } from 'react-native';
2
+ import { useState, useRef, useEffect } from 'react';
3
+ import { Platform, Dimensions, Animated, 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;
@@ -80,6 +80,8 @@ async function fetchAd({ baseUrl, client, slot, debug = false, typeAds, }) {
80
80
  }
81
81
 
82
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;
83
85
  function AdBanner({ client, slot, baseUrl = 'https://app.upeex.com.br/ad', theme = 'light', typeAds, typeads, // Receive alias
84
86
  style = {}, debug = false, }) {
85
87
  var _a;
@@ -87,6 +89,7 @@ style = {}, debug = false, }) {
87
89
  const [error, setError] = useState(null);
88
90
  const [modalVisible, setModalVisible] = useState(false);
89
91
  const [canClose, setCanClose] = useState(false);
92
+ const progressAnim = useRef(new Animated.Value(0)).current;
90
93
  // Normalize typeAds: prefer typeAds, fallback to typeads, default undefined.
91
94
  // Ensure lowercase for backend compatibility (POPUP -> popup)
92
95
  const effectiveTypeAds = (_a = (typeAds || typeads)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
@@ -117,17 +120,26 @@ style = {}, debug = false, }) {
117
120
  if (effectiveTypeAds === 'popup') {
118
121
  setModalVisible(true);
119
122
  setCanClose(false);
120
- // Timer to enable close button
121
- setTimeout(() => {
122
- setCanClose(true);
123
- }, 2000);
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
+ });
124
133
  }
125
- if (data.refresh && data.refresh > 0) {
126
- log(`Refresh ativo: ${data.refresh}s`);
127
- refreshTimer = setTimeout(() => {
128
- log('Refazendo request do anúncio');
129
- load();
130
- }, data.refresh * 1000);
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
+ }
131
143
  }
132
144
  }
133
145
  catch (err) {
@@ -165,7 +177,15 @@ style = {}, debug = false, }) {
165
177
  return (jsx(Modal, { visible: modalVisible, transparent: true, animationType: "fade", onRequestClose: () => {
166
178
  if (canClose)
167
179
  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" })) })] }) }));
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" })) })] }) }));
169
189
  }
170
190
  return (jsx(TouchableOpacity, { activeOpacity: 0.9, style: [
171
191
  styles.container,
@@ -220,9 +240,9 @@ const styles = StyleSheet.create({
220
240
  },
221
241
  closeButton: {
222
242
  position: 'absolute',
223
- top: 40,
243
+ top: 50,
224
244
  right: 20,
225
- backgroundColor: 'rgba(255, 255, 255, 0.3)',
245
+ backgroundColor: 'rgba(0,0,0,0.6)',
226
246
  width: 40,
227
247
  height: 40,
228
248
  borderRadius: 20,
@@ -235,6 +255,18 @@ const styles = StyleSheet.create({
235
255
  fontSize: 18,
236
256
  fontWeight: 'bold',
237
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%',
269
+ },
238
270
  });
239
271
 
240
272
  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.15",
3
+ "version": "1.1.16",
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,13 +27,14 @@
27
27
  "author": "Upeex",
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
- "@upeex/ads-sdk": "^1.1.10",
31
30
  "expo-localization": "^17.0.8"
32
31
  },
33
32
  "devDependencies": {
33
+ "@types/react": "^19.2.13",
34
+ "@types/react-native": "^0.73.0",
34
35
  "rollup": "^4.57.0",
35
36
  "rollup-plugin-typescript2": "^0.36.0",
36
37
  "tslib": "^2.8.1",
37
38
  "typescript": "^5.9.3"
38
39
  }
39
- }
40
+ }