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