@adview/react 1.0.14 → 1.0.16
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 +288 -66
- package/dist/AdViewUnit/AdViewUnit.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.cjs +249 -43
- package/dist/AdViewUnit/AdViewUnit.client.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.js +228 -22
- 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 +263 -41
- package/dist/AdViewUnit/AdViewUnit.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.cjs +246 -42
- package/dist/AdViewUnit/AdViewUnit.server.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.d.cts +2 -2
- package/dist/AdViewUnit/AdViewUnit.server.d.ts +2 -2
- package/dist/AdViewUnit/AdViewUnit.server.js +233 -29
- package/dist/AdViewUnit/AdViewUnit.server.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.cjs +21 -2
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.cts +7 -2
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.ts +7 -2
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.js +21 -2
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs +21 -3
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.cts +3 -4
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.ts +3 -4
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js +21 -3
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.cjs +21 -2
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.cts +7 -2
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.ts +7 -2
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.js +21 -2
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.cjs +21 -2
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.cts +7 -2
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.ts +7 -2
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.js +21 -2
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs +24 -6
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.d.cts +2 -2
- package/dist/AdViewUnit/AdViewUnitTemplate.d.ts +2 -2
- package/dist/AdViewUnit/AdViewUnitTemplate.js +24 -6
- package/dist/AdViewUnit/AdViewUnitTemplate.js.map +1 -1
- package/dist/AdViewUnit/useAdViewController.cjs +0 -2
- package/dist/AdViewUnit/useAdViewController.cjs.map +1 -1
- package/dist/AdViewUnit/useAdViewController.d.cts +1 -1
- package/dist/AdViewUnit/useAdViewController.d.ts +1 -1
- package/dist/AdViewUnit/useAdViewController.js +0 -2
- 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 +278 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +257 -174
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +277 -196
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +264 -183
- package/dist/server.js.map +1 -1
- package/dist/{types-B65WDsgh.d.cts → types-E00UyX0q.d.cts} +15 -27
- package/dist/{types-B65WDsgh.d.ts → types-E00UyX0q.d.ts} +15 -27
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -60,37 +60,225 @@ var AdViewProvider = ({ children, ...props }) => {
|
|
|
60
60
|
var AdViewProvider_default = AdViewProvider;
|
|
61
61
|
|
|
62
62
|
// src/AdViewUnit/AdViewUnit.client.tsx
|
|
63
|
-
var
|
|
63
|
+
var import_react8 = __toESM(require("react"), 1);
|
|
64
64
|
|
|
65
|
-
// src/AdViewUnit/
|
|
65
|
+
// src/AdViewUnit/AdViewUnitBannerTemplate.tsx
|
|
66
|
+
var import_utils = require("@adview/core/utils");
|
|
66
67
|
var import_react2 = __toESM(require("react"), 1);
|
|
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 }
|
|
97
|
+
},
|
|
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
|
+
)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
AdViewUnitBannerTemplate.defaults = {
|
|
109
|
+
type: "banner"
|
|
110
|
+
};
|
|
111
|
+
var AdViewUnitBannerTemplate_default = AdViewUnitBannerTemplate;
|
|
112
|
+
|
|
113
|
+
// src/AdViewUnit/AdViewUnitNativeTemplate.tsx
|
|
114
|
+
var import_utils3 = require("@adview/core/utils");
|
|
115
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
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);
|
|
131
|
+
if (!url) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", { className: classNames?.container }, /* @__PURE__ */ import_react3.default.createElement(
|
|
135
|
+
"a",
|
|
136
|
+
{
|
|
137
|
+
target: "_blank",
|
|
138
|
+
rel: "noopener noreferrer",
|
|
139
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
140
|
+
className: classNames?.imageLink
|
|
141
|
+
},
|
|
142
|
+
asset && /* @__PURE__ */ import_react3.default.createElement(
|
|
143
|
+
"img",
|
|
144
|
+
{
|
|
145
|
+
alt: fields?.title,
|
|
146
|
+
title: fields?.title,
|
|
147
|
+
src: asset.path,
|
|
148
|
+
srcSet: asset.thumbs ? (0, import_utils3.getSrcSetCSSThumbs)(asset.thumbs) : void 0,
|
|
149
|
+
className: classNames?.image,
|
|
150
|
+
style: { objectFit: "cover", width: "100%", height: "100%" }
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
), /* @__PURE__ */ import_react3.default.createElement("div", { className: classNames?.label }, fields?.title && /* @__PURE__ */ import_react3.default.createElement(
|
|
154
|
+
"a",
|
|
155
|
+
{
|
|
156
|
+
target: "_blank",
|
|
157
|
+
rel: "noopener noreferrer",
|
|
158
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
159
|
+
"data-class": "titleLink",
|
|
160
|
+
className: classNames?.titleLink
|
|
161
|
+
},
|
|
162
|
+
fields.title
|
|
163
|
+
), fields?.description && /* @__PURE__ */ import_react3.default.createElement(
|
|
164
|
+
"a",
|
|
165
|
+
{
|
|
166
|
+
target: "_blank",
|
|
167
|
+
rel: "noopener noreferrer",
|
|
168
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
169
|
+
"data-class": "descriptionLink",
|
|
170
|
+
className: classNames?.descriptionLink
|
|
171
|
+
},
|
|
172
|
+
fields.description
|
|
173
|
+
), fields?.brandname && /* @__PURE__ */ import_react3.default.createElement(
|
|
174
|
+
"a",
|
|
175
|
+
{
|
|
176
|
+
target: "_blank",
|
|
177
|
+
rel: "noopener noreferrer",
|
|
178
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
179
|
+
"data-class": "brandNameLink",
|
|
180
|
+
className: classNames?.brandNameLink
|
|
181
|
+
},
|
|
182
|
+
fields.brandname
|
|
183
|
+
), fields?.phone && /* @__PURE__ */ import_react3.default.createElement(
|
|
184
|
+
"a",
|
|
185
|
+
{
|
|
186
|
+
target: "_blank",
|
|
187
|
+
rel: "noopener noreferrer",
|
|
188
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
189
|
+
"data-class": "phoneLink",
|
|
190
|
+
className: classNames?.phoneLink
|
|
191
|
+
},
|
|
192
|
+
fields.phone
|
|
193
|
+
), fields?.url && /* @__PURE__ */ import_react3.default.createElement(
|
|
194
|
+
"a",
|
|
195
|
+
{
|
|
196
|
+
target: "_blank",
|
|
197
|
+
rel: "noopener noreferrer",
|
|
198
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
199
|
+
"data-class": "urlLink",
|
|
200
|
+
className: classNames?.urlLink
|
|
201
|
+
},
|
|
202
|
+
fields?.url
|
|
203
|
+
)));
|
|
204
|
+
}
|
|
205
|
+
AdViewUnitNativeTemplate.defaults = {
|
|
206
|
+
type: "native"
|
|
207
|
+
};
|
|
208
|
+
var AdViewUnitNativeTemplate_default = AdViewUnitNativeTemplate;
|
|
209
|
+
|
|
210
|
+
// src/AdViewUnit/AdViewUnitProxyTemplate.tsx
|
|
211
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
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;
|
|
226
|
+
const iframeSrc = fields?.url || url;
|
|
227
|
+
if (!iframeSrc) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
231
|
+
"iframe",
|
|
232
|
+
{
|
|
233
|
+
className,
|
|
234
|
+
width: "100%",
|
|
235
|
+
height: "100%",
|
|
236
|
+
frameBorder: "0",
|
|
237
|
+
marginWidth: 0,
|
|
238
|
+
marginHeight: 0,
|
|
239
|
+
allowTransparency: true,
|
|
240
|
+
scrolling: "no",
|
|
241
|
+
allowFullScreen: true,
|
|
242
|
+
style: { width: "100%", height: "100%", border: "none", ...style },
|
|
243
|
+
src: iframeSrc
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
AdViewUnitProxyTemplate.defaults = {
|
|
248
|
+
type: "proxy"
|
|
249
|
+
};
|
|
250
|
+
var AdViewUnitProxyTemplate_default = AdViewUnitProxyTemplate;
|
|
251
|
+
|
|
252
|
+
// src/AdViewUnit/AdViewUnitTemplate.tsx
|
|
253
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
67
254
|
var templateFromListRender = (tmpls, data, wrap) => {
|
|
68
255
|
let renderedRemplates = tmpls.map((tmpl, index) => {
|
|
69
256
|
let tmp = renderTemplate(tmpl, data);
|
|
70
|
-
return !!tmp &&
|
|
257
|
+
return !!tmp && import_react5.default.isValidElement(tmp) ? /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
|
|
71
258
|
}).filter((it) => !!it);
|
|
72
259
|
if (!renderedRemplates.length) {
|
|
73
260
|
renderedRemplates = tmpls.map((tmpl, index) => {
|
|
74
261
|
let tmp = renderTemplate(tmpl, { ...data, type: "default" });
|
|
75
|
-
return !!tmp &&
|
|
262
|
+
return !!tmp && import_react5.default.isValidElement(tmp) ? /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
|
|
76
263
|
}).filter((it) => !!it);
|
|
77
264
|
}
|
|
78
|
-
return /* @__PURE__ */
|
|
265
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, renderedRemplates);
|
|
79
266
|
};
|
|
80
267
|
var renderTemplate = (tmpl, data) => {
|
|
81
268
|
const isFunction = typeof tmpl === "function";
|
|
82
|
-
const isReactElement =
|
|
269
|
+
const isReactElement = import_react5.default.isValidElement(tmpl);
|
|
83
270
|
if (isReactElement) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
271
|
+
let { type, children } = tmpl.props;
|
|
272
|
+
if (!type && typeof tmpl.type !== "string") {
|
|
273
|
+
type = tmpl.type?.defaults?.type;
|
|
274
|
+
}
|
|
275
|
+
if (!!type && type !== "*" && data.type !== type) {
|
|
87
276
|
return null;
|
|
88
277
|
}
|
|
89
278
|
if (typeof children === "function") {
|
|
90
279
|
return children(data);
|
|
91
280
|
}
|
|
92
|
-
|
|
93
|
-
return import_react2.default.cloneElement(tmpl, {
|
|
281
|
+
return import_react5.default.cloneElement(tmpl, {
|
|
94
282
|
...data,
|
|
95
283
|
children
|
|
96
284
|
});
|
|
@@ -113,29 +301,39 @@ var renderAnyTemplates = (tmpls, data, listRender) => {
|
|
|
113
301
|
if (typeof tmpls === "function") {
|
|
114
302
|
return tmpls(data);
|
|
115
303
|
}
|
|
116
|
-
if (
|
|
304
|
+
if (import_react5.default.isValidElement(tmpls)) {
|
|
117
305
|
return templateFromListRender([tmpls], data);
|
|
118
306
|
}
|
|
119
307
|
return null;
|
|
120
308
|
};
|
|
121
|
-
var AdViewUnitTemplate = ({ type, children, ...
|
|
309
|
+
var AdViewUnitTemplate = ({ type, state, children, ...props }) => {
|
|
122
310
|
const tmplProps = {
|
|
123
311
|
type,
|
|
124
|
-
|
|
312
|
+
state,
|
|
313
|
+
...props
|
|
125
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
|
+
}
|
|
126
324
|
if (typeof children === "function") {
|
|
127
325
|
return children(tmplProps);
|
|
128
326
|
}
|
|
129
|
-
if (
|
|
130
|
-
return
|
|
327
|
+
if (import_react5.default.isValidElement(children)) {
|
|
328
|
+
return import_react5.default.cloneElement(children, tmplProps);
|
|
131
329
|
}
|
|
132
|
-
return /* @__PURE__ */
|
|
330
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null);
|
|
133
331
|
};
|
|
134
332
|
var AdViewUnitTemplate_default = AdViewUnitTemplate;
|
|
135
333
|
|
|
136
334
|
// src/AdViewUnit/AdViewUnitTracking.tsx
|
|
137
|
-
var
|
|
138
|
-
var
|
|
335
|
+
var import_utils7 = require("@adview/core/utils");
|
|
336
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
139
337
|
function AdViewUnitTracking({
|
|
140
338
|
impressions,
|
|
141
339
|
views,
|
|
@@ -143,30 +341,30 @@ function AdViewUnitTracking({
|
|
|
143
341
|
children
|
|
144
342
|
}) {
|
|
145
343
|
const isServer = typeof window === "undefined";
|
|
146
|
-
const wrapperRef = (0,
|
|
147
|
-
const executeImpressionsTrackingHandler = (0,
|
|
148
|
-
() => (0,
|
|
344
|
+
const wrapperRef = (0, import_react6.useRef)(null);
|
|
345
|
+
const executeImpressionsTrackingHandler = (0, import_react6.useCallback)(
|
|
346
|
+
() => (0, import_utils7.executeImpressionsTracking)(impressions),
|
|
149
347
|
[impressions]
|
|
150
348
|
);
|
|
151
|
-
const trackingObserverInstanceHandler = (0,
|
|
349
|
+
const trackingObserverInstanceHandler = (0, import_react6.useCallback)(
|
|
152
350
|
(entries) => {
|
|
153
351
|
entries.forEach((entry) => {
|
|
154
352
|
if (entry.isIntersecting) {
|
|
155
|
-
(0,
|
|
353
|
+
(0, import_utils7.executeImpressionsTracking)(views);
|
|
156
354
|
trackingObserverInstance?.unobserve(wrapperRef.current);
|
|
157
355
|
}
|
|
158
356
|
});
|
|
159
357
|
},
|
|
160
358
|
[views]
|
|
161
359
|
);
|
|
162
|
-
const trackingObserverInstance = (0,
|
|
360
|
+
const trackingObserverInstance = (0, import_react6.useMemo)(() => {
|
|
163
361
|
return !isServer ? new IntersectionObserver(trackingObserverInstanceHandler) : null;
|
|
164
362
|
}, [isServer, trackingObserverInstanceHandler]);
|
|
165
|
-
const clickTrackerHandler = (0,
|
|
166
|
-
(0,
|
|
363
|
+
const clickTrackerHandler = (0, import_react6.useCallback)(() => {
|
|
364
|
+
(0, import_utils7.executeImpressionsTracking)(clicks);
|
|
167
365
|
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
168
366
|
}, [clicks]);
|
|
169
|
-
(0,
|
|
367
|
+
(0, import_react6.useEffect)(() => {
|
|
170
368
|
if (wrapperRef.current && trackingObserverInstance) {
|
|
171
369
|
executeImpressionsTrackingHandler();
|
|
172
370
|
wrapperRef.current?.addEventListener("click", clickTrackerHandler);
|
|
@@ -184,20 +382,20 @@ function AdViewUnitTracking({
|
|
|
184
382
|
executeImpressionsTrackingHandler,
|
|
185
383
|
clickTrackerHandler
|
|
186
384
|
]);
|
|
187
|
-
return /* @__PURE__ */
|
|
385
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", { ref: wrapperRef }, children);
|
|
188
386
|
}
|
|
189
387
|
var AdViewUnitTracking_default = AdViewUnitTracking;
|
|
190
388
|
|
|
191
389
|
// src/AdViewUnit/useAdViewController.ts
|
|
192
|
-
var
|
|
193
|
-
var
|
|
390
|
+
var import_utils8 = require("@adview/core/utils");
|
|
391
|
+
var import_react7 = require("react");
|
|
194
392
|
function useAdViewController(adUnitConfig, unitId, format) {
|
|
195
|
-
const [adLoadState, setAdLoadState] = (0,
|
|
196
|
-
const [adData, setAdData] = (0,
|
|
197
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
198
|
-
const globalConfig = (0,
|
|
199
|
-
const baseConfig = (0,
|
|
200
|
-
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)(
|
|
201
399
|
baseConfig,
|
|
202
400
|
unitId,
|
|
203
401
|
typeof format === "string" ? format : format?.join(",") || ""
|
|
@@ -205,9 +403,7 @@ function useAdViewController(adUnitConfig, unitId, format) {
|
|
|
205
403
|
const loadAd = async () => {
|
|
206
404
|
setAdLoadState("loading");
|
|
207
405
|
try {
|
|
208
|
-
|
|
209
|
-
const response = await (0, import_utils2.adViewFetcher)(requestUrl, baseConfig.defaultAdData);
|
|
210
|
-
console.log("AdViewController response:", response);
|
|
406
|
+
const response = await (0, import_utils8.adViewFetcher)(requestUrl, baseConfig.defaultAdData);
|
|
211
407
|
if (response instanceof Error) {
|
|
212
408
|
setAdLoadState("error");
|
|
213
409
|
setErrorMessage(response);
|
|
@@ -227,7 +423,7 @@ function useAdViewController(adUnitConfig, unitId, format) {
|
|
|
227
423
|
isComplete: adLoadState === "complete",
|
|
228
424
|
isError: adLoadState === "error"
|
|
229
425
|
};
|
|
230
|
-
(0,
|
|
426
|
+
(0, import_react7.useEffect)(() => {
|
|
231
427
|
loadAd();
|
|
232
428
|
}, []);
|
|
233
429
|
return [adData, errorMessage, loadState];
|
|
@@ -241,180 +437,67 @@ function AdViewUnitClient({
|
|
|
241
437
|
children,
|
|
242
438
|
...config
|
|
243
439
|
}) {
|
|
440
|
+
const checkFormat = (f) => {
|
|
441
|
+
if (!format) {
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
444
|
+
return Array.isArray(format) ? format.includes(f) : f === format;
|
|
445
|
+
};
|
|
244
446
|
const [response, error, loadState] = useAdViewController_default(
|
|
245
447
|
config,
|
|
246
448
|
unitId,
|
|
247
449
|
format
|
|
248
450
|
);
|
|
249
|
-
const responseGroup = error ? null :
|
|
250
|
-
|
|
251
|
-
|
|
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
|
+
}
|
|
252
468
|
if (groupItems && groupItems?.length > 0) {
|
|
253
469
|
return groupItems.map(({ tracker, ...data }) => {
|
|
254
|
-
return /* @__PURE__ */
|
|
470
|
+
return /* @__PURE__ */ import_react8.default.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state: loadState }));
|
|
255
471
|
});
|
|
256
472
|
}
|
|
257
|
-
return /* @__PURE__ */
|
|
473
|
+
return /* @__PURE__ */ import_react8.default.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state: loadState }));
|
|
258
474
|
}
|
|
259
475
|
var AdViewUnit_client_default = AdViewUnitClient;
|
|
260
476
|
|
|
261
|
-
// src/AdViewUnit/AdViewUnitBannerTemplate.tsx
|
|
262
|
-
var import_utils3 = require("@adview/core/utils");
|
|
263
|
-
var import_react6 = __toESM(require("react"), 1);
|
|
264
|
-
function AdViewUnitBannerTemplate({ className = "banner", style, data, state }) {
|
|
265
|
-
if (!data || !data.assets || !data.assets.length || !state?.isComplete) {
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
const asset = (0, import_utils3.getAssetByName)("main", data.assets);
|
|
269
|
-
return /* @__PURE__ */ import_react6.default.createElement(
|
|
270
|
-
"a",
|
|
271
|
-
{
|
|
272
|
-
target: "_blank",
|
|
273
|
-
rel: "noopener noreferrer",
|
|
274
|
-
href: (0, import_utils3.getPrepareURL)(data.url),
|
|
275
|
-
className,
|
|
276
|
-
style: { fontSize: 0, ...style }
|
|
277
|
-
},
|
|
278
|
-
asset && /* @__PURE__ */ import_react6.default.createElement(
|
|
279
|
-
"img",
|
|
280
|
-
{
|
|
281
|
-
alt: "main",
|
|
282
|
-
src: asset.path,
|
|
283
|
-
srcSet: asset.thumbs ? (0, import_utils3.getSrcSetCSSThumbs)(asset.thumbs) : ""
|
|
284
|
-
}
|
|
285
|
-
)
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
var AdViewUnitBannerTemplate_default = AdViewUnitBannerTemplate;
|
|
289
|
-
|
|
290
477
|
// src/AdViewUnit/AdViewUnitDefaultTemplate.tsx
|
|
291
|
-
var
|
|
478
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
292
479
|
function AdViewUnitDefaultTemplate({ type = "default", data, state, children, ...props }) {
|
|
293
|
-
if (
|
|
294
|
-
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, children({ data, state, ...props }));
|
|
295
|
-
}
|
|
296
|
-
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)));
|
|
297
|
-
}
|
|
298
|
-
AdViewUnitDefaultTemplate.defaultProps = {
|
|
299
|
-
type: "default",
|
|
300
|
-
children: null
|
|
301
|
-
};
|
|
302
|
-
var AdViewUnitDefaultTemplate_default = AdViewUnitDefaultTemplate;
|
|
303
|
-
|
|
304
|
-
// src/AdViewUnit/AdViewUnitNativeTemplate.tsx
|
|
305
|
-
var import_utils4 = require("@adview/core/utils");
|
|
306
|
-
var import_react8 = __toESM(require("react"), 1);
|
|
307
|
-
function AdViewUnitNativeTemplate({ classNames, data, state }) {
|
|
308
|
-
if (!data || !data.assets || !data.assets.length || !state?.isComplete) {
|
|
480
|
+
if (data) {
|
|
309
481
|
return null;
|
|
310
482
|
}
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
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)) {
|
|
314
490
|
return null;
|
|
315
491
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
{
|
|
319
|
-
target: "_blank",
|
|
320
|
-
rel: "noopener noreferrer",
|
|
321
|
-
href: (0, import_utils4.getPrepareURL)(url),
|
|
322
|
-
className: classNames?.imageLink
|
|
323
|
-
},
|
|
324
|
-
asset && /* @__PURE__ */ import_react8.default.createElement(
|
|
325
|
-
"img",
|
|
326
|
-
{
|
|
327
|
-
alt: fields?.title,
|
|
328
|
-
title: fields?.title,
|
|
329
|
-
src: asset.path,
|
|
330
|
-
srcSet: asset.thumbs ? (0, import_utils4.getSrcSetCSSThumbs)(asset.thumbs) : void 0,
|
|
331
|
-
className: classNames?.image,
|
|
332
|
-
style: { objectFit: "cover", width: "100%", height: "100%" }
|
|
333
|
-
}
|
|
334
|
-
)
|
|
335
|
-
), /* @__PURE__ */ import_react8.default.createElement("div", { className: classNames?.label }, fields?.title && /* @__PURE__ */ import_react8.default.createElement(
|
|
336
|
-
"a",
|
|
337
|
-
{
|
|
338
|
-
target: "_blank",
|
|
339
|
-
rel: "noopener noreferrer",
|
|
340
|
-
href: (0, import_utils4.getPrepareURL)(url),
|
|
341
|
-
"data-class": "titleLink",
|
|
342
|
-
className: classNames?.titleLink
|
|
343
|
-
},
|
|
344
|
-
fields.title
|
|
345
|
-
), fields?.description && /* @__PURE__ */ import_react8.default.createElement(
|
|
346
|
-
"a",
|
|
347
|
-
{
|
|
348
|
-
target: "_blank",
|
|
349
|
-
rel: "noopener noreferrer",
|
|
350
|
-
href: (0, import_utils4.getPrepareURL)(url),
|
|
351
|
-
"data-class": "descriptionLink",
|
|
352
|
-
className: classNames?.descriptionLink
|
|
353
|
-
},
|
|
354
|
-
fields.description
|
|
355
|
-
), fields?.brandname && /* @__PURE__ */ import_react8.default.createElement(
|
|
356
|
-
"a",
|
|
357
|
-
{
|
|
358
|
-
target: "_blank",
|
|
359
|
-
rel: "noopener noreferrer",
|
|
360
|
-
href: (0, import_utils4.getPrepareURL)(url),
|
|
361
|
-
"data-class": "brandNameLink",
|
|
362
|
-
className: classNames?.brandNameLink
|
|
363
|
-
},
|
|
364
|
-
fields.brandname
|
|
365
|
-
), fields?.phone && /* @__PURE__ */ import_react8.default.createElement(
|
|
366
|
-
"a",
|
|
367
|
-
{
|
|
368
|
-
target: "_blank",
|
|
369
|
-
rel: "noopener noreferrer",
|
|
370
|
-
href: (0, import_utils4.getPrepareURL)(url),
|
|
371
|
-
"data-class": "phoneLink",
|
|
372
|
-
className: classNames?.phoneLink
|
|
373
|
-
},
|
|
374
|
-
fields.phone
|
|
375
|
-
), fields?.url && /* @__PURE__ */ import_react8.default.createElement(
|
|
376
|
-
"a",
|
|
377
|
-
{
|
|
378
|
-
target: "_blank",
|
|
379
|
-
rel: "noopener noreferrer",
|
|
380
|
-
href: (0, import_utils4.getPrepareURL)(url),
|
|
381
|
-
"data-class": "urlLink",
|
|
382
|
-
className: classNames?.urlLink
|
|
383
|
-
},
|
|
384
|
-
fields?.url
|
|
385
|
-
)));
|
|
386
|
-
}
|
|
387
|
-
var AdViewUnitNativeTemplate_default = AdViewUnitNativeTemplate;
|
|
388
|
-
|
|
389
|
-
// src/AdViewUnit/AdViewUnitProxyTemplate.tsx
|
|
390
|
-
var import_react9 = __toESM(require("react"), 1);
|
|
391
|
-
function AdViewUnitProxyTemplate({ className, style, data, state }) {
|
|
392
|
-
if (!data || !state?.isComplete) {
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
const { url, fields } = data;
|
|
396
|
-
const iframeSrc = fields?.url || url;
|
|
397
|
-
if (!iframeSrc) {
|
|
398
|
-
return null;
|
|
492
|
+
if (typeof children === "function") {
|
|
493
|
+
return /* @__PURE__ */ import_react9.default.createElement(import_react9.default.Fragment, null, children({ data, state, ...props }));
|
|
399
494
|
}
|
|
400
|
-
return /* @__PURE__ */ import_react9.default.createElement(
|
|
401
|
-
"iframe",
|
|
402
|
-
{
|
|
403
|
-
className,
|
|
404
|
-
width: "100%",
|
|
405
|
-
height: "100%",
|
|
406
|
-
frameBorder: "0",
|
|
407
|
-
marginWidth: 0,
|
|
408
|
-
marginHeight: 0,
|
|
409
|
-
allowTransparency: true,
|
|
410
|
-
scrolling: "no",
|
|
411
|
-
allowFullScreen: true,
|
|
412
|
-
style: { width: "100%", height: "100%", border: "none", ...style },
|
|
413
|
-
src: iframeSrc
|
|
414
|
-
}
|
|
415
|
-
);
|
|
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)));
|
|
416
496
|
}
|
|
417
|
-
|
|
497
|
+
AdViewUnitDefaultTemplate.defaults = {
|
|
498
|
+
type: "default"
|
|
499
|
+
};
|
|
500
|
+
var AdViewUnitDefaultTemplate_default = AdViewUnitDefaultTemplate;
|
|
418
501
|
// Annotate the CommonJS export names for ESM import in node:
|
|
419
502
|
0 && (module.exports = {
|
|
420
503
|
AdViewProvider,
|