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