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