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