@thead-vantage/react 2.7.0 → 2.8.0
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/package.json +1 -1
- package/src/components/AdBanner.tsx +1 -1
- package/src/lib/ads.ts +23 -3
package/package.json
CHANGED
package/src/lib/ads.ts
CHANGED
|
@@ -183,6 +183,14 @@ export async function fetchAdBanner(params: FetchAdBannerParams): Promise<AdBann
|
|
|
183
183
|
};
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
+
// Helper to normalize ad type - "standard" should be treated as "image"
|
|
187
|
+
const normalizeAdType = (ad: Ad): Ad => {
|
|
188
|
+
if (ad.type === 'standard' && ad.contentUrl) {
|
|
189
|
+
return { ...ad, type: 'image' };
|
|
190
|
+
}
|
|
191
|
+
return ad;
|
|
192
|
+
};
|
|
193
|
+
|
|
186
194
|
// Handle both single ad and array of ads
|
|
187
195
|
if (data.ads && Array.isArray(data.ads) && data.ads.length > 0) {
|
|
188
196
|
// If we get an array, use the first ad and ensure it's Ad type
|
|
@@ -190,10 +198,13 @@ export async function fetchAdBanner(params: FetchAdBannerParams): Promise<AdBann
|
|
|
190
198
|
console.log('[AdBanner] Processing ads array, first ad:', JSON.stringify(firstAd, null, 2));
|
|
191
199
|
|
|
192
200
|
// Check if it's already an Ad, otherwise convert from AdData
|
|
193
|
-
|
|
201
|
+
let ad: Ad = isAd(firstAd)
|
|
194
202
|
? firstAd
|
|
195
203
|
: convertToAd(firstAd as AdData);
|
|
196
204
|
|
|
205
|
+
// Normalize the type (standard -> image)
|
|
206
|
+
ad = normalizeAdType(ad);
|
|
207
|
+
|
|
197
208
|
console.log('[AdBanner] Converted ad:', JSON.stringify(ad, null, 2));
|
|
198
209
|
|
|
199
210
|
return {
|
|
@@ -206,10 +217,19 @@ export async function fetchAdBanner(params: FetchAdBannerParams): Promise<AdBann
|
|
|
206
217
|
}
|
|
207
218
|
|
|
208
219
|
// Handle single ad response - convert AdData to Ad
|
|
209
|
-
// Since data.ad is typed as AdData, we always convert it
|
|
210
220
|
if (data.ad) {
|
|
211
221
|
console.log('[AdBanner] Processing single ad:', JSON.stringify(data.ad, null, 2));
|
|
212
|
-
|
|
222
|
+
|
|
223
|
+
// Check if it's already in Ad format or needs conversion
|
|
224
|
+
let ad: Ad;
|
|
225
|
+
if (isAd(data.ad)) {
|
|
226
|
+
// Already in Ad format, normalize the type
|
|
227
|
+
ad = normalizeAdType(data.ad);
|
|
228
|
+
} else {
|
|
229
|
+
// Convert from AdData format
|
|
230
|
+
ad = convertToAd(data.ad);
|
|
231
|
+
}
|
|
232
|
+
|
|
213
233
|
console.log('[AdBanner] Converted ad:', JSON.stringify(ad, null, 2));
|
|
214
234
|
|
|
215
235
|
return {
|