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