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