@adview/react 1.0.13 → 1.0.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/dist/AdViewUnit/AdViewUnit.cjs +273 -243
- package/dist/AdViewUnit/AdViewUnit.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.cjs +234 -198
- package/dist/AdViewUnit/AdViewUnit.client.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.d.cts +2 -2
- package/dist/AdViewUnit/AdViewUnit.client.d.ts +2 -2
- package/dist/AdViewUnit/AdViewUnit.client.js +226 -190
- package/dist/AdViewUnit/AdViewUnit.client.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnit.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnit.js +261 -231
- package/dist/AdViewUnit/AdViewUnit.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.cjs +229 -157
- package/dist/AdViewUnit/AdViewUnit.server.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.d.cts +3 -3
- package/dist/AdViewUnit/AdViewUnit.server.d.ts +3 -3
- package/dist/AdViewUnit/AdViewUnit.server.js +227 -155
- package/dist/AdViewUnit/AdViewUnit.server.js.map +1 -1
- package/dist/AdViewUnit/{AdViewUnitBanner.cjs → AdViewUnitBannerTemplate.cjs} +36 -14
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.cts +17 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.ts +17 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.js +51 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.js.map +1 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs +66 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.cts +16 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.ts +16 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js +35 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js.map +1 -0
- package/dist/AdViewUnit/{AdViewUnitNative.cjs → AdViewUnitNativeTemplate.cjs} +31 -13
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.cts +16 -0
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.ts +16 -0
- package/dist/AdViewUnit/{AdViewUnitNative.js → AdViewUnitNativeTemplate.js} +28 -10
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.js.map +1 -0
- package/dist/AdViewUnit/{AdViewUnitProxy.cjs → AdViewUnitProxyTemplate.cjs} +33 -13
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.cts +17 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.ts +17 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.js +52 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.js.map +1 -0
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs +132 -0
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.d.cts +14 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.d.ts +14 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.js +95 -0
- package/dist/AdViewUnit/AdViewUnitTemplate.js.map +1 -1
- package/dist/AdViewUnit/useAdViewController.cjs +5 -3
- package/dist/AdViewUnit/useAdViewController.cjs.map +1 -1
- package/dist/AdViewUnit/useAdViewController.d.cts +2 -2
- package/dist/AdViewUnit/useAdViewController.d.ts +2 -2
- package/dist/AdViewUnit/useAdViewController.js +5 -3
- package/dist/AdViewUnit/useAdViewController.js.map +1 -1
- package/dist/AdViewUnit/utils.cjs +33 -0
- package/dist/AdViewUnit/utils.cjs.map +1 -0
- package/dist/AdViewUnit/utils.d.cts +7 -0
- package/dist/AdViewUnit/utils.d.ts +7 -0
- package/dist/AdViewUnit/utils.js +8 -0
- package/dist/AdViewUnit/utils.js.map +1 -0
- package/dist/index.cjs +305 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +286 -193
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +302 -167
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -6
- package/dist/server.d.ts +7 -6
- package/dist/server.js +288 -160
- package/dist/server.js.map +1 -1
- package/dist/{types-BaV07oMT.d.cts → types-DHjNgnRW.d.cts} +35 -43
- package/dist/{types-BaV07oMT.d.ts → types-DHjNgnRW.d.ts} +35 -43
- package/package.json +1 -1
- package/dist/AdViewUnit/AdViewUnitBanner.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitBanner.d.cts +0 -10
- package/dist/AdViewUnit/AdViewUnitBanner.d.ts +0 -10
- package/dist/AdViewUnit/AdViewUnitBanner.js +0 -29
- package/dist/AdViewUnit/AdViewUnitBanner.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitNative.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitNative.d.cts +0 -10
- package/dist/AdViewUnit/AdViewUnitNative.d.ts +0 -10
- package/dist/AdViewUnit/AdViewUnitNative.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitProxy.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitProxy.d.cts +0 -10
- package/dist/AdViewUnit/AdViewUnitProxy.d.ts +0 -10
- package/dist/AdViewUnit/AdViewUnitProxy.js +0 -32
- package/dist/AdViewUnit/AdViewUnitProxy.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.cjs +0 -203
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.d.cts +0 -12
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.d.ts +0 -12
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.js +0 -170
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.client.cjs +0 -250
- package/dist/AdViewUnit/AdViewUnitWrapper.client.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.client.d.cts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.client.d.ts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.client.js +0 -220
- package/dist/AdViewUnit/AdViewUnitWrapper.client.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.server.cjs +0 -232
- package/dist/AdViewUnit/AdViewUnitWrapper.server.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.server.d.cts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.server.d.ts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.server.js +0 -201
- package/dist/AdViewUnit/AdViewUnitWrapper.server.js.map +0 -1
|
@@ -3,76 +3,74 @@
|
|
|
3
3
|
"use client";
|
|
4
4
|
|
|
5
5
|
// src/AdViewUnit/AdViewUnit.client.tsx
|
|
6
|
-
import
|
|
6
|
+
import React7 from "react";
|
|
7
7
|
|
|
8
|
-
// src/AdViewUnit/
|
|
9
|
-
import {
|
|
10
|
-
import React
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
// src/AdViewUnit/AdViewUnitBannerTemplate.tsx
|
|
9
|
+
import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from "@adview/core/utils";
|
|
10
|
+
import React from "react";
|
|
11
|
+
|
|
12
|
+
// src/AdViewUnit/utils.ts
|
|
13
|
+
var matchExpectedState = (expectState, state) => {
|
|
14
|
+
return !expectState || (expectState.isInitial === void 0 || expectState.isInitial === state?.isInitial) && (expectState.isLoading === void 0 || expectState.isLoading === state?.isLoading) && (expectState.isError === void 0 || expectState.isError === state?.isError) && (expectState.isComplete === void 0 || expectState.isComplete === state?.isComplete);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/AdViewUnit/AdViewUnitBannerTemplate.tsx
|
|
18
|
+
function AdViewUnitBannerTemplate({ className = "banner", style, data, state, ...props }) {
|
|
19
|
+
const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
|
|
20
|
+
isInitial: props?.isInitial,
|
|
21
|
+
isLoading: props?.isLoading,
|
|
22
|
+
isError: props?.isError,
|
|
23
|
+
isComplete: props?.isComplete
|
|
24
|
+
} : { isComplete: true };
|
|
25
|
+
if (!data || !data.assets || !data.assets.length) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (!matchExpectedState(expectState, state)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const asset = getAssetByName("main", data.assets);
|
|
32
|
+
return /* @__PURE__ */ React.createElement(
|
|
33
|
+
"a",
|
|
34
|
+
{
|
|
35
|
+
target: "_blank",
|
|
36
|
+
rel: "noopener noreferrer",
|
|
37
|
+
href: getPrepareURL(data.url),
|
|
38
|
+
className,
|
|
39
|
+
style: { fontSize: 0, ...style }
|
|
31
40
|
},
|
|
32
|
-
|
|
41
|
+
asset && /* @__PURE__ */ React.createElement(
|
|
42
|
+
"img",
|
|
43
|
+
{
|
|
44
|
+
alt: "main",
|
|
45
|
+
src: asset.path,
|
|
46
|
+
srcSet: asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : ""
|
|
47
|
+
}
|
|
48
|
+
)
|
|
33
49
|
);
|
|
34
|
-
const trackingObserverInstance = useMemo(() => {
|
|
35
|
-
return !isServer ? new IntersectionObserver(trackingObserverInstanceHandler) : null;
|
|
36
|
-
}, [isServer, trackingObserverInstanceHandler]);
|
|
37
|
-
const clickTrackerHandler = useCallback(() => {
|
|
38
|
-
executeImpressionsTracking(clicks);
|
|
39
|
-
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
40
|
-
}, [clicks]);
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (wrapperRef.current && trackingObserverInstance) {
|
|
43
|
-
executeImpressionsTrackingHandler();
|
|
44
|
-
wrapperRef.current?.addEventListener("click", clickTrackerHandler);
|
|
45
|
-
trackingObserverInstance?.observe(wrapperRef.current);
|
|
46
|
-
return () => {
|
|
47
|
-
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
48
|
-
if (wrapperRef.current)
|
|
49
|
-
trackingObserverInstance?.unobserve(wrapperRef.current);
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return () => {
|
|
53
|
-
};
|
|
54
|
-
}, [
|
|
55
|
-
trackingObserverInstance,
|
|
56
|
-
executeImpressionsTrackingHandler,
|
|
57
|
-
clickTrackerHandler
|
|
58
|
-
]);
|
|
59
|
-
return /* @__PURE__ */ React.createElement("div", { ref: wrapperRef }, children);
|
|
60
50
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
AdViewUnitBannerTemplate.defaults = {
|
|
52
|
+
type: "banner"
|
|
53
|
+
};
|
|
54
|
+
var AdViewUnitBannerTemplate_default = AdViewUnitBannerTemplate;
|
|
65
55
|
|
|
66
|
-
// src/AdViewUnit/
|
|
67
|
-
import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from "@adview/core/utils";
|
|
56
|
+
// src/AdViewUnit/AdViewUnitNativeTemplate.tsx
|
|
57
|
+
import { getAssetByName as getAssetByName2, getPrepareURL as getPrepareURL2, getSrcSetCSSThumbs as getSrcSetCSSThumbs2 } from "@adview/core/utils";
|
|
68
58
|
import React2 from "react";
|
|
69
|
-
function
|
|
70
|
-
assets
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
59
|
+
function AdViewUnitNativeTemplate({ classNames, data, state, ...props }) {
|
|
60
|
+
if (!data || !data.assets || !data.assets.length) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
|
|
64
|
+
isInitial: props?.isInitial,
|
|
65
|
+
isLoading: props?.isLoading,
|
|
66
|
+
isError: props?.isError,
|
|
67
|
+
isComplete: props?.isComplete
|
|
68
|
+
} : { isComplete: true };
|
|
69
|
+
if (!matchExpectedState(expectState, state)) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const { assets, url, fields } = data;
|
|
73
|
+
const asset = getAssetByName2("main", assets);
|
|
76
74
|
if (!url) {
|
|
77
75
|
return null;
|
|
78
76
|
}
|
|
@@ -81,7 +79,7 @@ function AdViewUnitNative({
|
|
|
81
79
|
{
|
|
82
80
|
target: "_blank",
|
|
83
81
|
rel: "noopener noreferrer",
|
|
84
|
-
href:
|
|
82
|
+
href: getPrepareURL2(url),
|
|
85
83
|
className: classNames?.imageLink
|
|
86
84
|
},
|
|
87
85
|
asset && /* @__PURE__ */ React2.createElement(
|
|
@@ -90,7 +88,7 @@ function AdViewUnitNative({
|
|
|
90
88
|
alt: fields?.title,
|
|
91
89
|
title: fields?.title,
|
|
92
90
|
src: asset.path,
|
|
93
|
-
srcSet: asset.thumbs ?
|
|
91
|
+
srcSet: asset.thumbs ? getSrcSetCSSThumbs2(asset.thumbs) : void 0,
|
|
94
92
|
className: classNames?.image,
|
|
95
93
|
style: { objectFit: "cover", width: "100%", height: "100%" }
|
|
96
94
|
}
|
|
@@ -100,7 +98,7 @@ function AdViewUnitNative({
|
|
|
100
98
|
{
|
|
101
99
|
target: "_blank",
|
|
102
100
|
rel: "noopener noreferrer",
|
|
103
|
-
href:
|
|
101
|
+
href: getPrepareURL2(url),
|
|
104
102
|
"data-class": "titleLink",
|
|
105
103
|
className: classNames?.titleLink
|
|
106
104
|
},
|
|
@@ -110,7 +108,7 @@ function AdViewUnitNative({
|
|
|
110
108
|
{
|
|
111
109
|
target: "_blank",
|
|
112
110
|
rel: "noopener noreferrer",
|
|
113
|
-
href:
|
|
111
|
+
href: getPrepareURL2(url),
|
|
114
112
|
"data-class": "descriptionLink",
|
|
115
113
|
className: classNames?.descriptionLink
|
|
116
114
|
},
|
|
@@ -120,7 +118,7 @@ function AdViewUnitNative({
|
|
|
120
118
|
{
|
|
121
119
|
target: "_blank",
|
|
122
120
|
rel: "noopener noreferrer",
|
|
123
|
-
href:
|
|
121
|
+
href: getPrepareURL2(url),
|
|
124
122
|
"data-class": "brandNameLink",
|
|
125
123
|
className: classNames?.brandNameLink
|
|
126
124
|
},
|
|
@@ -130,7 +128,7 @@ function AdViewUnitNative({
|
|
|
130
128
|
{
|
|
131
129
|
target: "_blank",
|
|
132
130
|
rel: "noopener noreferrer",
|
|
133
|
-
href:
|
|
131
|
+
href: getPrepareURL2(url),
|
|
134
132
|
"data-class": "phoneLink",
|
|
135
133
|
className: classNames?.phoneLink
|
|
136
134
|
},
|
|
@@ -140,22 +138,34 @@ function AdViewUnitNative({
|
|
|
140
138
|
{
|
|
141
139
|
target: "_blank",
|
|
142
140
|
rel: "noopener noreferrer",
|
|
143
|
-
href:
|
|
141
|
+
href: getPrepareURL2(url),
|
|
144
142
|
"data-class": "urlLink",
|
|
145
143
|
className: classNames?.urlLink
|
|
146
144
|
},
|
|
147
145
|
fields?.url
|
|
148
146
|
)));
|
|
149
147
|
}
|
|
150
|
-
|
|
148
|
+
AdViewUnitNativeTemplate.defaults = {
|
|
149
|
+
type: "native"
|
|
150
|
+
};
|
|
151
|
+
var AdViewUnitNativeTemplate_default = AdViewUnitNativeTemplate;
|
|
151
152
|
|
|
152
|
-
// src/AdViewUnit/
|
|
153
|
+
// src/AdViewUnit/AdViewUnitProxyTemplate.tsx
|
|
153
154
|
import React3 from "react";
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
function AdViewUnitProxyTemplate({ className, style, data, state, ...props }) {
|
|
156
|
+
if (!data) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
|
|
160
|
+
isInitial: props?.isInitial,
|
|
161
|
+
isLoading: props?.isLoading,
|
|
162
|
+
isError: props?.isError,
|
|
163
|
+
isComplete: props?.isComplete
|
|
164
|
+
} : { isComplete: true };
|
|
165
|
+
if (!matchExpectedState(expectState, state)) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
const { url, fields } = data;
|
|
159
169
|
const iframeSrc = fields?.url || url;
|
|
160
170
|
if (!iframeSrc) {
|
|
161
171
|
return null;
|
|
@@ -163,6 +173,7 @@ function AdViewUnitProxy({
|
|
|
163
173
|
return /* @__PURE__ */ React3.createElement(
|
|
164
174
|
"iframe",
|
|
165
175
|
{
|
|
176
|
+
className,
|
|
166
177
|
width: "100%",
|
|
167
178
|
height: "100%",
|
|
168
179
|
frameBorder: "0",
|
|
@@ -171,114 +182,135 @@ function AdViewUnitProxy({
|
|
|
171
182
|
allowTransparency: true,
|
|
172
183
|
scrolling: "no",
|
|
173
184
|
allowFullScreen: true,
|
|
174
|
-
style: { width: "100%", height: "100%" },
|
|
185
|
+
style: { width: "100%", height: "100%", border: "none", ...style },
|
|
175
186
|
src: iframeSrc
|
|
176
187
|
}
|
|
177
188
|
);
|
|
178
189
|
}
|
|
179
|
-
|
|
190
|
+
AdViewUnitProxyTemplate.defaults = {
|
|
191
|
+
type: "proxy"
|
|
192
|
+
};
|
|
193
|
+
var AdViewUnitProxyTemplate_default = AdViewUnitProxyTemplate;
|
|
180
194
|
|
|
181
|
-
// src/AdViewUnit/
|
|
182
|
-
import { getAssetByName as getAssetByName2, getPrepareURL as getPrepareURL2, getSrcSetCSSThumbs as getSrcSetCSSThumbs2 } from "@adview/core/utils";
|
|
195
|
+
// src/AdViewUnit/AdViewUnitTemplate.tsx
|
|
183
196
|
import React4 from "react";
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
asset && /* @__PURE__ */ React4.createElement(
|
|
196
|
-
"img",
|
|
197
|
-
{
|
|
198
|
-
alt: "main",
|
|
199
|
-
src: asset.path,
|
|
200
|
-
srcSet: asset.thumbs ? getSrcSetCSSThumbs2(asset.thumbs) : ""
|
|
201
|
-
}
|
|
202
|
-
)
|
|
203
|
-
));
|
|
204
|
-
}
|
|
205
|
-
var AdViewUnitBanner_default = AdViewUnitBanner;
|
|
206
|
-
|
|
207
|
-
// src/AdViewUnit/AdViewUnitTypeSwitch.tsx
|
|
208
|
-
import React5 from "react";
|
|
209
|
-
function AdViewUnitTypeSwitch({
|
|
210
|
-
data,
|
|
211
|
-
classNames,
|
|
212
|
-
onDefault
|
|
213
|
-
}) {
|
|
214
|
-
switch (data?.type) {
|
|
215
|
-
case "native":
|
|
216
|
-
return /* @__PURE__ */ React5.createElement(AdViewUnitNative_default, { ...data, classNames: classNames?.native });
|
|
217
|
-
case "proxy":
|
|
218
|
-
return /* @__PURE__ */ React5.createElement(AdViewUnitProxy_default, { ...data, classNames: classNames?.proxy });
|
|
219
|
-
case "banner":
|
|
220
|
-
return /* @__PURE__ */ React5.createElement(AdViewUnitBanner_default, { ...data, classNames: classNames?.banner });
|
|
221
|
-
default:
|
|
222
|
-
if (React5.isValidElement(onDefault)) {
|
|
223
|
-
return React5.cloneElement(onDefault);
|
|
224
|
-
}
|
|
225
|
-
if (typeof onDefault === "function") {
|
|
226
|
-
return onDefault();
|
|
227
|
-
}
|
|
228
|
-
return null;
|
|
197
|
+
var templateFromListRender = (tmpls, data, wrap) => {
|
|
198
|
+
let renderedRemplates = tmpls.map((tmpl, index) => {
|
|
199
|
+
let tmp = renderTemplate(tmpl, data);
|
|
200
|
+
return !!tmp && React4.isValidElement(tmp) ? /* @__PURE__ */ React4.createElement(React4.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
|
|
201
|
+
}).filter((it) => !!it);
|
|
202
|
+
if (!renderedRemplates.length) {
|
|
203
|
+
renderedRemplates = tmpls.map((tmpl, index) => {
|
|
204
|
+
let tmp = renderTemplate(tmpl, { ...data, type: "default" });
|
|
205
|
+
return !!tmp && React4.isValidElement(tmp) ? /* @__PURE__ */ React4.createElement(React4.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
|
|
206
|
+
}).filter((it) => !!it);
|
|
229
207
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
onDefault
|
|
208
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, renderedRemplates);
|
|
209
|
+
};
|
|
210
|
+
var renderTemplate = (tmpl, data) => {
|
|
211
|
+
const isFunction = typeof tmpl === "function";
|
|
212
|
+
const isReactElement = React4.isValidElement(tmpl);
|
|
213
|
+
if (isReactElement) {
|
|
214
|
+
let { type, children } = tmpl.props;
|
|
215
|
+
if (!type && typeof tmpl.type !== "string") {
|
|
216
|
+
type = tmpl.type?.defaults?.type;
|
|
217
|
+
}
|
|
218
|
+
if (data.type !== type) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
if (typeof children === "function") {
|
|
222
|
+
return children(data);
|
|
223
|
+
}
|
|
224
|
+
return React4.cloneElement(tmpl, {
|
|
225
|
+
...data,
|
|
226
|
+
children
|
|
250
227
|
});
|
|
251
228
|
}
|
|
252
|
-
if (
|
|
253
|
-
return
|
|
254
|
-
data,
|
|
255
|
-
state,
|
|
256
|
-
error,
|
|
257
|
-
onDefault
|
|
258
|
-
});
|
|
229
|
+
if (isFunction) {
|
|
230
|
+
return tmpl(data);
|
|
259
231
|
}
|
|
260
|
-
|
|
232
|
+
return null;
|
|
233
|
+
};
|
|
234
|
+
var renderTemplates = (tmpls, data, listRender) => {
|
|
235
|
+
return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);
|
|
236
|
+
};
|
|
237
|
+
var renderAnyTemplates = (tmpls, data, listRender) => {
|
|
238
|
+
if (!tmpls) {
|
|
261
239
|
return null;
|
|
262
240
|
}
|
|
263
|
-
if (
|
|
264
|
-
return
|
|
241
|
+
if (Array.isArray(tmpls)) {
|
|
242
|
+
return renderTemplates(tmpls, data, listRender);
|
|
265
243
|
}
|
|
266
|
-
if (
|
|
267
|
-
return
|
|
244
|
+
if (typeof tmpls === "function") {
|
|
245
|
+
return tmpls(data);
|
|
268
246
|
}
|
|
269
|
-
if (
|
|
270
|
-
return
|
|
247
|
+
if (React4.isValidElement(tmpls)) {
|
|
248
|
+
return templateFromListRender([tmpls], data);
|
|
271
249
|
}
|
|
272
250
|
return null;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// src/AdViewUnit/AdViewUnitTracking.tsx
|
|
254
|
+
import { executeImpressionsTracking } from "@adview/core/utils";
|
|
255
|
+
import React5, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
256
|
+
function AdViewUnitTracking({
|
|
257
|
+
impressions,
|
|
258
|
+
views,
|
|
259
|
+
clicks,
|
|
260
|
+
children
|
|
261
|
+
}) {
|
|
262
|
+
const isServer = typeof window === "undefined";
|
|
263
|
+
const wrapperRef = useRef(null);
|
|
264
|
+
const executeImpressionsTrackingHandler = useCallback(
|
|
265
|
+
() => executeImpressionsTracking(impressions),
|
|
266
|
+
[impressions]
|
|
267
|
+
);
|
|
268
|
+
const trackingObserverInstanceHandler = useCallback(
|
|
269
|
+
(entries) => {
|
|
270
|
+
entries.forEach((entry) => {
|
|
271
|
+
if (entry.isIntersecting) {
|
|
272
|
+
executeImpressionsTracking(views);
|
|
273
|
+
trackingObserverInstance?.unobserve(wrapperRef.current);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
[views]
|
|
278
|
+
);
|
|
279
|
+
const trackingObserverInstance = useMemo(() => {
|
|
280
|
+
return !isServer ? new IntersectionObserver(trackingObserverInstanceHandler) : null;
|
|
281
|
+
}, [isServer, trackingObserverInstanceHandler]);
|
|
282
|
+
const clickTrackerHandler = useCallback(() => {
|
|
283
|
+
executeImpressionsTracking(clicks);
|
|
284
|
+
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
285
|
+
}, [clicks]);
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (wrapperRef.current && trackingObserverInstance) {
|
|
288
|
+
executeImpressionsTrackingHandler();
|
|
289
|
+
wrapperRef.current?.addEventListener("click", clickTrackerHandler);
|
|
290
|
+
trackingObserverInstance?.observe(wrapperRef.current);
|
|
291
|
+
return () => {
|
|
292
|
+
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
293
|
+
if (wrapperRef.current)
|
|
294
|
+
trackingObserverInstance?.unobserve(wrapperRef.current);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
return () => {
|
|
298
|
+
};
|
|
299
|
+
}, [
|
|
300
|
+
trackingObserverInstance,
|
|
301
|
+
executeImpressionsTrackingHandler,
|
|
302
|
+
clickTrackerHandler
|
|
303
|
+
]);
|
|
304
|
+
return /* @__PURE__ */ React5.createElement("div", { ref: wrapperRef }, children);
|
|
273
305
|
}
|
|
274
|
-
var
|
|
306
|
+
var AdViewUnitTracking_default = AdViewUnitTracking;
|
|
275
307
|
|
|
276
308
|
// src/AdViewUnit/useAdViewController.ts
|
|
277
309
|
import { adViewFetcher, getAdRequestUrl, getResolveConfig } from "@adview/core/utils";
|
|
278
310
|
import { useContext, useEffect as useEffect2, useState } from "react";
|
|
279
311
|
|
|
280
312
|
// src/AdViewUnit/AdViewProvider.tsx
|
|
281
|
-
import
|
|
313
|
+
import React6, { createContext } from "react";
|
|
282
314
|
var AdViewProviderContext = createContext(
|
|
283
315
|
{}
|
|
284
316
|
);
|
|
@@ -290,13 +322,15 @@ function useAdViewController(adUnitConfig, unitId, format) {
|
|
|
290
322
|
const [errorMessage, setErrorMessage] = useState(null);
|
|
291
323
|
const globalConfig = useContext(AdViewProviderContext);
|
|
292
324
|
const baseConfig = getResolveConfig({ ...adUnitConfig, ...globalConfig });
|
|
293
|
-
const requestUrl = getAdRequestUrl(
|
|
325
|
+
const requestUrl = getAdRequestUrl(
|
|
326
|
+
baseConfig,
|
|
327
|
+
unitId,
|
|
328
|
+
typeof format === "string" ? format : format?.join(",") || ""
|
|
329
|
+
);
|
|
294
330
|
const loadAd = async () => {
|
|
295
331
|
setAdLoadState("loading");
|
|
296
332
|
try {
|
|
297
|
-
console.log("Requesting ad data from:", adViewFetcher, "with URL:", requestUrl);
|
|
298
333
|
const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);
|
|
299
|
-
console.log("AdViewController response:", response);
|
|
300
334
|
if (response instanceof Error) {
|
|
301
335
|
setAdLoadState("error");
|
|
302
336
|
setErrorMessage(response);
|
|
@@ -328,40 +362,42 @@ function AdViewUnitClient({
|
|
|
328
362
|
unitId,
|
|
329
363
|
format,
|
|
330
364
|
children,
|
|
331
|
-
onDefault = () => null,
|
|
332
365
|
...config
|
|
333
366
|
}) {
|
|
367
|
+
const checkFormat = (f) => {
|
|
368
|
+
if (!format) {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
return Array.isArray(format) ? format.includes(f) : f === format;
|
|
372
|
+
};
|
|
334
373
|
const [response, error, loadState] = useAdViewController_default(
|
|
335
374
|
config,
|
|
336
375
|
unitId,
|
|
337
376
|
format
|
|
338
377
|
);
|
|
339
|
-
const responseGroup = error ? null :
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
378
|
+
const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
|
|
379
|
+
for (let responseGroup of response?.groups || []) {
|
|
380
|
+
const customTracker2 = responseGroup?.custom_tracker ?? {};
|
|
381
|
+
const groupItems2 = responseGroup?.items.map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
382
|
+
if (groupItems2 && groupItems2.length > 0) {
|
|
383
|
+
return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return { responseGroup: null, customTracker: {}, groupItems: [] };
|
|
387
|
+
})();
|
|
388
|
+
if (!children) {
|
|
389
|
+
children = [
|
|
390
|
+
/* @__PURE__ */ React7.createElement(AdViewUnitBannerTemplate_default, null),
|
|
391
|
+
/* @__PURE__ */ React7.createElement(AdViewUnitNativeTemplate_default, null),
|
|
392
|
+
/* @__PURE__ */ React7.createElement(AdViewUnitProxyTemplate_default, null)
|
|
393
|
+
];
|
|
394
|
+
}
|
|
395
|
+
if (groupItems && groupItems?.length > 0) {
|
|
343
396
|
return groupItems.map(({ tracker, ...data }) => {
|
|
344
|
-
return /* @__PURE__ */
|
|
345
|
-
AdViewUnitWrapper_client_default,
|
|
346
|
-
{
|
|
347
|
-
state: loadState,
|
|
348
|
-
error,
|
|
349
|
-
data,
|
|
350
|
-
onDefault
|
|
351
|
-
},
|
|
352
|
-
children
|
|
353
|
-
));
|
|
397
|
+
return /* @__PURE__ */ React7.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state: loadState }));
|
|
354
398
|
});
|
|
355
399
|
}
|
|
356
|
-
return /* @__PURE__ */
|
|
357
|
-
AdViewUnitWrapper_client_default,
|
|
358
|
-
{
|
|
359
|
-
state: loadState,
|
|
360
|
-
error,
|
|
361
|
-
onDefault
|
|
362
|
-
},
|
|
363
|
-
children
|
|
364
|
-
));
|
|
400
|
+
return /* @__PURE__ */ React7.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state: loadState }));
|
|
365
401
|
}
|
|
366
402
|
var AdViewUnit_client_default = AdViewUnitClient;
|
|
367
403
|
export {
|