forked from prebid/Prebid.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnativeRendering.js
27 lines (25 loc) · 890 Bytes
/
nativeRendering.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {getRenderingData} from '../src/adRendering.js';
import {getNativeRenderingData, isNativeResponse} from '../src/native.js';
import {auctionManager} from '../src/auctionManager.js';
import {RENDERER} from '../libraries/creative-renderer-native/renderer.js';
import {getCreativeRendererSource} from '../src/creativeRenderers.js';
function getRenderingDataHook(next, bidResponse, options) {
if (isNativeResponse(bidResponse)) {
next.bail({
native: getNativeRenderingData(bidResponse, auctionManager.index.getAdUnit(bidResponse))
})
} else {
next(bidResponse, options)
}
}
function getRendererSourceHook(next, bidResponse) {
if (isNativeResponse(bidResponse)) {
next.bail(RENDERER);
} else {
next(bidResponse);
}
}
if (FEATURES.NATIVE) {
getRenderingData.before(getRenderingDataHook)
getCreativeRendererSource.before(getRendererSourceHook);
}