@adview/react 1.0.13 → 1.0.14

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.
Files changed (101) hide show
  1. package/dist/AdViewUnit/AdViewUnit.cjs +106 -298
  2. package/dist/AdViewUnit/AdViewUnit.cjs.map +1 -1
  3. package/dist/AdViewUnit/AdViewUnit.client.cjs +86 -256
  4. package/dist/AdViewUnit/AdViewUnit.client.cjs.map +1 -1
  5. package/dist/AdViewUnit/AdViewUnit.client.d.cts +2 -2
  6. package/dist/AdViewUnit/AdViewUnit.client.d.ts +2 -2
  7. package/dist/AdViewUnit/AdViewUnit.client.js +69 -239
  8. package/dist/AdViewUnit/AdViewUnit.client.js.map +1 -1
  9. package/dist/AdViewUnit/AdViewUnit.d.cts +1 -1
  10. package/dist/AdViewUnit/AdViewUnit.d.ts +1 -1
  11. package/dist/AdViewUnit/AdViewUnit.js +85 -277
  12. package/dist/AdViewUnit/AdViewUnit.js.map +1 -1
  13. package/dist/AdViewUnit/AdViewUnit.server.cjs +82 -214
  14. package/dist/AdViewUnit/AdViewUnit.server.cjs.map +1 -1
  15. package/dist/AdViewUnit/AdViewUnit.server.d.cts +2 -2
  16. package/dist/AdViewUnit/AdViewUnit.server.d.ts +2 -2
  17. package/dist/AdViewUnit/AdViewUnit.server.js +72 -204
  18. package/dist/AdViewUnit/AdViewUnit.server.js.map +1 -1
  19. package/dist/AdViewUnit/{AdViewUnitBanner.cjs → AdViewUnitBannerTemplate.cjs} +17 -14
  20. package/dist/AdViewUnit/AdViewUnitBannerTemplate.cjs.map +1 -0
  21. package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.cts +12 -0
  22. package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.ts +12 -0
  23. package/dist/AdViewUnit/AdViewUnitBannerTemplate.js +32 -0
  24. package/dist/AdViewUnit/AdViewUnitBannerTemplate.js.map +1 -0
  25. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs +48 -0
  26. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs.map +1 -0
  27. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.cts +17 -0
  28. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.ts +17 -0
  29. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js +17 -0
  30. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js.map +1 -0
  31. package/dist/AdViewUnit/{AdViewUnitNative.cjs → AdViewUnitNativeTemplate.cjs} +12 -13
  32. package/dist/AdViewUnit/AdViewUnitNativeTemplate.cjs.map +1 -0
  33. package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.cts +11 -0
  34. package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.ts +11 -0
  35. package/dist/AdViewUnit/{AdViewUnitNative.js → AdViewUnitNativeTemplate.js} +9 -10
  36. package/dist/AdViewUnit/AdViewUnitNativeTemplate.js.map +1 -0
  37. package/dist/AdViewUnit/{AdViewUnitProxy.cjs → AdViewUnitProxyTemplate.cjs} +14 -13
  38. package/dist/AdViewUnit/AdViewUnitProxyTemplate.cjs.map +1 -0
  39. package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.cts +12 -0
  40. package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.ts +12 -0
  41. package/dist/AdViewUnit/AdViewUnitProxyTemplate.js +33 -0
  42. package/dist/AdViewUnit/AdViewUnitProxyTemplate.js.map +1 -0
  43. package/dist/AdViewUnit/AdViewUnitTemplate.cjs +114 -0
  44. package/dist/AdViewUnit/AdViewUnitTemplate.cjs.map +1 -1
  45. package/dist/AdViewUnit/AdViewUnitTemplate.d.cts +14 -1
  46. package/dist/AdViewUnit/AdViewUnitTemplate.d.ts +14 -1
  47. package/dist/AdViewUnit/AdViewUnitTemplate.js +77 -0
  48. package/dist/AdViewUnit/AdViewUnitTemplate.js.map +1 -1
  49. package/dist/AdViewUnit/useAdViewController.cjs +5 -1
  50. package/dist/AdViewUnit/useAdViewController.cjs.map +1 -1
  51. package/dist/AdViewUnit/useAdViewController.d.cts +2 -2
  52. package/dist/AdViewUnit/useAdViewController.d.ts +2 -2
  53. package/dist/AdViewUnit/useAdViewController.js +5 -1
  54. package/dist/AdViewUnit/useAdViewController.js.map +1 -1
  55. package/dist/index.cjs +250 -232
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +8 -7
  58. package/dist/index.d.ts +8 -7
  59. package/dist/index.js +232 -222
  60. package/dist/index.js.map +1 -1
  61. package/dist/server.cjs +216 -162
  62. package/dist/server.cjs.map +1 -1
  63. package/dist/server.d.cts +7 -6
  64. package/dist/server.d.ts +7 -6
  65. package/dist/server.js +196 -149
  66. package/dist/server.js.map +1 -1
  67. package/dist/{types-BaV07oMT.d.cts → types-B65WDsgh.d.cts} +29 -25
  68. package/dist/{types-BaV07oMT.d.ts → types-B65WDsgh.d.ts} +29 -25
  69. package/package.json +1 -1
  70. package/dist/AdViewUnit/AdViewUnitBanner.cjs.map +0 -1
  71. package/dist/AdViewUnit/AdViewUnitBanner.d.cts +0 -10
  72. package/dist/AdViewUnit/AdViewUnitBanner.d.ts +0 -10
  73. package/dist/AdViewUnit/AdViewUnitBanner.js +0 -29
  74. package/dist/AdViewUnit/AdViewUnitBanner.js.map +0 -1
  75. package/dist/AdViewUnit/AdViewUnitNative.cjs.map +0 -1
  76. package/dist/AdViewUnit/AdViewUnitNative.d.cts +0 -10
  77. package/dist/AdViewUnit/AdViewUnitNative.d.ts +0 -10
  78. package/dist/AdViewUnit/AdViewUnitNative.js.map +0 -1
  79. package/dist/AdViewUnit/AdViewUnitProxy.cjs.map +0 -1
  80. package/dist/AdViewUnit/AdViewUnitProxy.d.cts +0 -10
  81. package/dist/AdViewUnit/AdViewUnitProxy.d.ts +0 -10
  82. package/dist/AdViewUnit/AdViewUnitProxy.js +0 -32
  83. package/dist/AdViewUnit/AdViewUnitProxy.js.map +0 -1
  84. package/dist/AdViewUnit/AdViewUnitTypeSwitch.cjs +0 -203
  85. package/dist/AdViewUnit/AdViewUnitTypeSwitch.cjs.map +0 -1
  86. package/dist/AdViewUnit/AdViewUnitTypeSwitch.d.cts +0 -12
  87. package/dist/AdViewUnit/AdViewUnitTypeSwitch.d.ts +0 -12
  88. package/dist/AdViewUnit/AdViewUnitTypeSwitch.js +0 -170
  89. package/dist/AdViewUnit/AdViewUnitTypeSwitch.js.map +0 -1
  90. package/dist/AdViewUnit/AdViewUnitWrapper.client.cjs +0 -250
  91. package/dist/AdViewUnit/AdViewUnitWrapper.client.cjs.map +0 -1
  92. package/dist/AdViewUnit/AdViewUnitWrapper.client.d.cts +0 -11
  93. package/dist/AdViewUnit/AdViewUnitWrapper.client.d.ts +0 -11
  94. package/dist/AdViewUnit/AdViewUnitWrapper.client.js +0 -220
  95. package/dist/AdViewUnit/AdViewUnitWrapper.client.js.map +0 -1
  96. package/dist/AdViewUnit/AdViewUnitWrapper.server.cjs +0 -232
  97. package/dist/AdViewUnit/AdViewUnitWrapper.server.cjs.map +0 -1
  98. package/dist/AdViewUnit/AdViewUnitWrapper.server.d.cts +0 -11
  99. package/dist/AdViewUnit/AdViewUnitWrapper.server.d.ts +0 -11
  100. package/dist/AdViewUnit/AdViewUnitWrapper.server.js +0 -201
  101. package/dist/AdViewUnit/AdViewUnitWrapper.server.js.map +0 -1
@@ -1,12 +1,69 @@
1
1
  'use client';
2
2
 
3
3
  // src/AdViewUnit/AdViewUnit.server.tsx
4
- import React7 from "react";
4
+ import React3 from "react";
5
5
  import { adViewFetcher, getAdRequestUrl, getResolveConfig } from "@adview/core/utils";
6
6
 
7
+ // src/AdViewUnit/AdViewUnitTemplate.tsx
8
+ import React from "react";
9
+ var templateFromListRender = (tmpls, data, wrap) => {
10
+ let renderedRemplates = tmpls.map((tmpl, index) => {
11
+ let tmp = renderTemplate(tmpl, data);
12
+ return !!tmp && React.isValidElement(tmp) ? /* @__PURE__ */ React.createElement(React.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
13
+ }).filter((it) => !!it);
14
+ if (!renderedRemplates.length) {
15
+ renderedRemplates = tmpls.map((tmpl, index) => {
16
+ let tmp = renderTemplate(tmpl, { ...data, type: "default" });
17
+ return !!tmp && React.isValidElement(tmp) ? /* @__PURE__ */ React.createElement(React.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
18
+ }).filter((it) => !!it);
19
+ }
20
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, renderedRemplates);
21
+ };
22
+ var renderTemplate = (tmpl, data) => {
23
+ const isFunction = typeof tmpl === "function";
24
+ const isReactElement = React.isValidElement(tmpl);
25
+ if (isReactElement) {
26
+ const { type, children } = tmpl.props;
27
+ console.log("=====>\nrenderTemplate: React element detected, type:", type, "data:", data.type, data.type !== type);
28
+ if (data.type !== type) {
29
+ return null;
30
+ }
31
+ if (typeof children === "function") {
32
+ return children(data);
33
+ }
34
+ console.log("CLONE ELEMENT", tmpl);
35
+ return React.cloneElement(tmpl, {
36
+ ...data,
37
+ children
38
+ });
39
+ }
40
+ if (isFunction) {
41
+ return tmpl(data);
42
+ }
43
+ return null;
44
+ };
45
+ var renderTemplates = (tmpls, data, listRender) => {
46
+ return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);
47
+ };
48
+ var renderAnyTemplates = (tmpls, data, listRender) => {
49
+ if (!tmpls) {
50
+ return null;
51
+ }
52
+ if (Array.isArray(tmpls)) {
53
+ return renderTemplates(tmpls, data, listRender);
54
+ }
55
+ if (typeof tmpls === "function") {
56
+ return tmpls(data);
57
+ }
58
+ if (React.isValidElement(tmpls)) {
59
+ return templateFromListRender([tmpls], data);
60
+ }
61
+ return null;
62
+ };
63
+
7
64
  // src/AdViewUnit/AdViewUnitTracking.tsx
8
65
  import { executeImpressionsTracking } from "@adview/core/utils";
9
- import React, { useCallback, useEffect, useMemo, useRef } from "react";
66
+ import React2, { useCallback, useEffect, useMemo, useRef } from "react";
10
67
  function AdViewUnitTracking({
11
68
  impressions,
12
69
  views,
@@ -55,214 +112,15 @@ function AdViewUnitTracking({
55
112
  executeImpressionsTrackingHandler,
56
113
  clickTrackerHandler
57
114
  ]);
58
- return /* @__PURE__ */ React.createElement("div", { ref: wrapperRef }, children);
115
+ return /* @__PURE__ */ React2.createElement("div", { ref: wrapperRef }, children);
59
116
  }
60
117
  var AdViewUnitTracking_default = AdViewUnitTracking;
61
118
 
62
- // src/AdViewUnit/AdViewUnitWrapper.server.tsx
63
- import React6 from "react";
64
-
65
- // src/AdViewUnit/AdViewUnitNative.tsx
66
- import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from "@adview/core/utils";
67
- import React2 from "react";
68
- function AdViewUnitNative({
69
- assets,
70
- fields,
71
- url,
72
- classNames
73
- }) {
74
- const asset = getAssetByName("main", assets);
75
- if (!url) {
76
- return null;
77
- }
78
- return /* @__PURE__ */ React2.createElement("div", { className: classNames?.container }, /* @__PURE__ */ React2.createElement(
79
- "a",
80
- {
81
- target: "_blank",
82
- rel: "noopener noreferrer",
83
- href: getPrepareURL(url),
84
- className: classNames?.imageLink
85
- },
86
- asset && /* @__PURE__ */ React2.createElement(
87
- "img",
88
- {
89
- alt: fields?.title,
90
- title: fields?.title,
91
- src: asset.path,
92
- srcSet: asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : void 0,
93
- className: classNames?.image,
94
- style: { objectFit: "cover", width: "100%", height: "100%" }
95
- }
96
- )
97
- ), /* @__PURE__ */ React2.createElement("div", { className: classNames?.label }, fields?.title && /* @__PURE__ */ React2.createElement(
98
- "a",
99
- {
100
- target: "_blank",
101
- rel: "noopener noreferrer",
102
- href: getPrepareURL(url),
103
- "data-class": "titleLink",
104
- className: classNames?.titleLink
105
- },
106
- fields.title
107
- ), fields?.description && /* @__PURE__ */ React2.createElement(
108
- "a",
109
- {
110
- target: "_blank",
111
- rel: "noopener noreferrer",
112
- href: getPrepareURL(url),
113
- "data-class": "descriptionLink",
114
- className: classNames?.descriptionLink
115
- },
116
- fields.description
117
- ), fields?.brandname && /* @__PURE__ */ React2.createElement(
118
- "a",
119
- {
120
- target: "_blank",
121
- rel: "noopener noreferrer",
122
- href: getPrepareURL(url),
123
- "data-class": "brandNameLink",
124
- className: classNames?.brandNameLink
125
- },
126
- fields.brandname
127
- ), fields?.phone && /* @__PURE__ */ React2.createElement(
128
- "a",
129
- {
130
- target: "_blank",
131
- rel: "noopener noreferrer",
132
- href: getPrepareURL(url),
133
- "data-class": "phoneLink",
134
- className: classNames?.phoneLink
135
- },
136
- fields.phone
137
- ), fields?.url && /* @__PURE__ */ React2.createElement(
138
- "a",
139
- {
140
- target: "_blank",
141
- rel: "noopener noreferrer",
142
- href: getPrepareURL(url),
143
- "data-class": "urlLink",
144
- className: classNames?.urlLink
145
- },
146
- fields?.url
147
- )));
148
- }
149
- var AdViewUnitNative_default = AdViewUnitNative;
150
-
151
- // src/AdViewUnit/AdViewUnitProxy.tsx
152
- import React3 from "react";
153
- function AdViewUnitProxy({
154
- // assets,
155
- fields,
156
- url
157
- }) {
158
- const iframeSrc = fields?.url || url;
159
- if (!iframeSrc) {
160
- return null;
161
- }
162
- return /* @__PURE__ */ React3.createElement(
163
- "iframe",
164
- {
165
- width: "100%",
166
- height: "100%",
167
- frameBorder: "0",
168
- marginWidth: 0,
169
- marginHeight: 0,
170
- allowTransparency: true,
171
- scrolling: "no",
172
- allowFullScreen: true,
173
- style: { width: "100%", height: "100%" },
174
- src: iframeSrc
175
- }
176
- );
177
- }
178
- var AdViewUnitProxy_default = AdViewUnitProxy;
179
-
180
- // src/AdViewUnit/AdViewUnitBanner.tsx
181
- import { getAssetByName as getAssetByName2, getPrepareURL as getPrepareURL2, getSrcSetCSSThumbs as getSrcSetCSSThumbs2 } from "@adview/core/utils";
182
- import React4 from "react";
183
- function AdViewUnitBanner({ assets, url }) {
184
- const asset = getAssetByName2("main", assets);
185
- return /* @__PURE__ */ React4.createElement("center", null, /* @__PURE__ */ React4.createElement(
186
- "a",
187
- {
188
- target: "_blank",
189
- rel: "noopener noreferrer",
190
- href: getPrepareURL2(url),
191
- className: "banner",
192
- style: { fontSize: 0 }
193
- },
194
- asset && /* @__PURE__ */ React4.createElement(
195
- "img",
196
- {
197
- alt: "main",
198
- src: asset.path,
199
- srcSet: asset.thumbs ? getSrcSetCSSThumbs2(asset.thumbs) : ""
200
- }
201
- )
202
- ));
203
- }
204
- var AdViewUnitBanner_default = AdViewUnitBanner;
205
-
206
- // src/AdViewUnit/AdViewUnitTypeSwitch.tsx
207
- import React5 from "react";
208
- function AdViewUnitTypeSwitch({
209
- data,
210
- classNames,
211
- onDefault
212
- }) {
213
- switch (data?.type) {
214
- case "native":
215
- return /* @__PURE__ */ React5.createElement(AdViewUnitNative_default, { ...data, classNames: classNames?.native });
216
- case "proxy":
217
- return /* @__PURE__ */ React5.createElement(AdViewUnitProxy_default, { ...data, classNames: classNames?.proxy });
218
- case "banner":
219
- return /* @__PURE__ */ React5.createElement(AdViewUnitBanner_default, { ...data, classNames: classNames?.banner });
220
- default:
221
- if (React5.isValidElement(onDefault)) {
222
- return React5.cloneElement(onDefault);
223
- }
224
- if (typeof onDefault === "function") {
225
- return onDefault();
226
- }
227
- return null;
228
- }
229
- }
230
- var AdViewUnitTypeSwitch_default = AdViewUnitTypeSwitch;
231
-
232
- // src/AdViewUnit/AdViewUnitWrapper.server.tsx
233
- async function AdViewUnitWrapperServer({
234
- data,
235
- children,
236
- onDefault
237
- }) {
238
- const isChildrenReactNode = React6.isValidElement(children);
239
- const isChildrenFunction = typeof children === "function";
240
- const isLoadingError = data instanceof Error;
241
- if (isChildrenReactNode) {
242
- return React6.cloneElement(children, { data, onDefault });
243
- }
244
- if (isChildrenFunction) {
245
- return children({ data, onDefault });
246
- }
247
- if (!children && !isLoadingError) {
248
- return /* @__PURE__ */ React6.createElement(AdViewUnitTypeSwitch_default, { data, onDefault });
249
- }
250
- if (React6.isValidElement(onDefault)) {
251
- return React6.cloneElement(onDefault);
252
- }
253
- if (typeof onDefault === "function") {
254
- return onDefault();
255
- }
256
- return null;
257
- }
258
- var AdViewUnitWrapper_server_default = AdViewUnitWrapperServer;
259
-
260
119
  // src/AdViewUnit/AdViewUnit.server.tsx
261
120
  async function AdViewUnitServer({
262
121
  unitId,
263
122
  format,
264
123
  children,
265
- onDefault = () => null,
266
124
  ...config
267
125
  }) {
268
126
  const baseConfig = getResolveConfig(config);
@@ -275,10 +133,20 @@ async function AdViewUnitServer({
275
133
  const groupItems = responseGroup?.items;
276
134
  if (groupItems && groupItems.length) {
277
135
  return groupItems.map(({ tracker, ...data }) => {
278
- return /* @__PURE__ */ React7.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, /* @__PURE__ */ React7.createElement(AdViewUnitWrapper_server_default, { data, onDefault }, children));
136
+ return /* @__PURE__ */ React3.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state: {
137
+ isLoading: true,
138
+ isComplete: true,
139
+ isInitial: false,
140
+ isError: isLoadingError
141
+ } }));
279
142
  });
280
143
  }
281
- return /* @__PURE__ */ React7.createElement(AdViewUnitTracking_default, { ...customTracker }, /* @__PURE__ */ React7.createElement(AdViewUnitWrapper_server_default, { data: error, onDefault }, children));
144
+ return /* @__PURE__ */ React3.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state: {
145
+ isLoading: true,
146
+ isComplete: true,
147
+ isInitial: false,
148
+ isError: isLoadingError
149
+ } }));
282
150
  }
283
151
  var AdViewUnit_server_default = AdViewUnitServer;
284
152
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.server.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/AdViewUnitWrapper.server.tsx","../../src/AdViewUnit/AdViewUnitNative.tsx","../../src/AdViewUnit/AdViewUnitProxy.tsx","../../src/AdViewUnit/AdViewUnitBanner.tsx","../../src/AdViewUnit/AdViewUnitTypeSwitch.tsx"],"sourcesContent":["import React from 'react';\n\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, getResolveConfig } from '@adview/core/utils';\nimport { AdViewUnitPropsBase, AdViewUnitServerChildren } from '../types';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport AdViewUnitWrapperServer from './AdViewUnitWrapper.server';\n\nexport type AdViewUnitServerProps = AdViewUnitPropsBase & {\n children?: AdViewUnitServerChildren;\n};\n\nasync function AdViewUnitServer({\n unitId,\n format,\n children,\n onDefault = () => null,\n ...config\n}: AdViewUnitServerProps) {\n const baseConfig = getResolveConfig(config);\n const requestUrl = getAdRequestUrl(baseConfig, unitId, format);\n const response = await adViewFetcher(requestUrl);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const responseGroup =\n response instanceof Error ? null : response?.groups?.[0];\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items;\n\n if (groupItems && groupItems.length) {\n return groupItems.map(({ tracker, ...data }: AdViewGroupItem) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n <AdViewUnitWrapperServer data={data} onDefault={onDefault}>\n {children}\n </AdViewUnitWrapperServer>\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n <AdViewUnitWrapperServer data={error} onDefault={onDefault}>\n {children}\n </AdViewUnitWrapperServer>\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","import React from 'react';\nimport AdViewUnitTypeSwitch from './/AdViewUnitTypeSwitch';\n\nimport {\n AdViewUnitDefault,\n AdViewUnitServerChildren,\n AdViewUnitServerChildrenProps,\n} from '../types';\n\nexport type AdViewUnitWrapperServerProps = AdViewUnitServerChildrenProps & {\n children?: AdViewUnitServerChildren;\n onDefault?: AdViewUnitDefault;\n};\n\nasync function AdViewUnitWrapperServer({\n data,\n children,\n onDefault,\n}: AdViewUnitWrapperServerProps) {\n const isChildrenReactNode = React.isValidElement(children);\n const isChildrenFunction = typeof children === 'function';\n const isLoadingError = data instanceof Error;\n\n if (isChildrenReactNode) {\n return React.cloneElement(children, { data, onDefault });\n }\n\n if (isChildrenFunction) {\n return children({ data, onDefault });\n }\n\n if (!children && !isLoadingError) {\n return <AdViewUnitTypeSwitch data={data} onDefault={onDefault} />;\n }\n\n if (React.isValidElement(onDefault)) {\n return React.cloneElement(onDefault);\n }\n\n if (typeof onDefault === 'function') {\n return onDefault();\n }\n\n return null;\n}\n\nexport default AdViewUnitWrapperServer;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdViewDataClient, AdViewStyleTokensNative } from '../types';\n\ntype AdViewUnitNativeProps = AdViewDataClient & {\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitNative({\n assets,\n fields,\n url,\n classNames,\n}: AdViewUnitNativeProps) {\n const asset = getAssetByName('main', assets);\n\n if (!url) {\n return null;\n }\n\n return (\n <div className={classNames?.container}>\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n className={classNames?.imageLink}\n >\n {asset && (\n <img\n alt={fields?.title}\n title={fields?.title}\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : undefined}\n className={classNames?.image}\n style={{ objectFit: 'cover', width: '100%', height: '100%' }}\n />\n )}\n </a>\n <div className={classNames?.label}>\n {fields?.title && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"titleLink\"\n className={classNames?.titleLink}\n >\n {fields.title}\n </a>\n )}\n {fields?.description && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"descriptionLink\"\n className={classNames?.descriptionLink}\n >\n {fields.description}\n </a>\n )}\n {fields?.brandname && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"brandNameLink\"\n className={classNames?.brandNameLink}\n >\n {fields.brandname}\n </a>\n )}\n {fields?.phone && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"phoneLink\"\n className={classNames?.phoneLink}\n >\n {fields.phone}\n </a>\n )}\n {fields?.url && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"urlLink\"\n className={classNames?.urlLink}\n >\n {fields?.url}\n </a>\n )}\n </div>\n </div>\n );\n}\n\nexport default AdViewUnitNative;\n","import React from 'react';\nimport { AdViewDataClient, AdViewStyleTokensNative } from '../types';\n\ntype AdViewUnitProxyProps = AdViewDataClient & {\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitProxy({\n // assets,\n fields,\n url,\n}: AdViewUnitProxyProps) {\n const iframeSrc = fields?.url || url;\n\n if (!iframeSrc) {\n return null;\n }\n\n return (\n <iframe\n width=\"100%\"\n height=\"100%\"\n frameBorder=\"0\"\n marginWidth={0}\n marginHeight={0}\n allowTransparency={true}\n scrolling=\"no\"\n allowFullScreen={true}\n style={{ width: '100%', height: '100%' }}\n src={iframeSrc}\n ></iframe>\n );\n}\n\nexport default AdViewUnitProxy;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdViewDataClient, AdViewStyleTokensNative } from '../types';\n\ntype AdViewUnitBannerProps = AdViewDataClient & {\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitBanner({ assets, url }: AdViewUnitBannerProps) {\n const asset = getAssetByName('main', assets);\n\n return (\n <center>\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n className=\"banner\"\n style={{ fontSize: 0 }}\n >\n {asset && (\n <img\n alt=\"main\"\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : ''}\n />\n )}\n </a>\n </center>\n );\n}\n\nexport default AdViewUnitBanner;\n","import {\n AdViewDataClient,\n AdViewStyleTokens,\n AdViewUnitDefault,\n} from '../types';\nimport AdViewUnitNative from './AdViewUnitNative';\nimport AdViewUnitProxy from './AdViewUnitProxy';\nimport AdViewUnitBanner from './AdViewUnitBanner';\nimport React from 'react';\n\ntype AdViewUnitDefaultProps = {\n data?: AdViewDataClient;\n classNames?: AdViewStyleTokens;\n onDefault?: AdViewUnitDefault;\n};\n\nfunction AdViewUnitTypeSwitch({\n data,\n classNames,\n onDefault,\n}: AdViewUnitDefaultProps) {\n switch (data?.type) {\n case 'native':\n return <AdViewUnitNative {...data} classNames={classNames?.native} />;\n case 'proxy':\n return <AdViewUnitProxy {...data} classNames={classNames?.proxy} />;\n case 'banner':\n return <AdViewUnitBanner {...data} classNames={classNames?.banner} />;\n default:\n if (React.isValidElement(onDefault)) {\n return React.cloneElement(onDefault);\n }\n\n if (typeof onDefault === 'function') {\n return onDefault();\n }\n\n return null;\n }\n}\n\nexport default AdViewUnitTypeSwitch;\n"],"mappings":";AAAA,OAAOA,YAAW;AAGlB,SAAS,eAAe,iBAAiB,wBAAwB;;;ACDjE,SAAS,kCAAkC;AAC3C,OAAO,SAAS,aAAa,WAAW,SAAS,cAAc;AAS/D,SAAS,mBAAmB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,WAAW,OAAO,WAAW;AACnC,QAAM,aAAa,OAAuB,IAAI;AAC9C,QAAM,oCAAoC;AAAA,IACxC,MAAM,2BAA2B,WAAW;AAAA,IAC5C,CAAC,WAAW;AAAA,EACd;AACA,QAAM,kCAAkC;AAAA,IACtC,CAAC,YAAyC;AACxC,cAAQ,QAAQ,WAAS;AACvB,YAAI,MAAM,gBAAgB;AACxB,qCAA2B,KAAK;AAChC,oCAA0B,UAAU,WAAW,OAAQ;AAAA,QACzD;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AACA,QAAM,2BAA2B,QAAqC,MAAM;AAC1E,WAAO,CAAC,WACJ,IAAI,qBAAqB,+BAA+B,IACxD;AAAA,EACN,GAAG,CAAC,UAAU,+BAA+B,CAAC;AAC9C,QAAM,sBAAsB,YAAY,MAAM;AAC5C,+BAA2B,MAAM;AAEjC,eAAW,SAAS,oBAAoB,SAAS,mBA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W,QAAQ;AACnC,WAAO,WAAW,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,MAAuB;AAC/D,aACE,gBAAAC,OAAA,cAAC,8BAAmB,KAAK,KAAK,IAAK,GAAG,WACpC,gBAAAA,OAAA,cAAC,oCAAwB,MAAY,aAClC,QACH,CACF;AAAA,IAEJ,CAAC;AAAA,EACH;AAEA,SACE,gBAAAA,OAAA,cAAC,8BAAoB,GAAG,iBACtB,gBAAAA,OAAA,cAAC,oCAAwB,MAAM,OAAO,aACnC,QACH,CACF;AAEJ;AAEA,IAAO,4BAAQ;","names":["React","React","React","React","getAssetByName","getPrepareURL","getSrcSetCSSThumbs","React","React","React","React"]}
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.server.tsx","../../src/AdViewUnit/AdViewUnitTemplate.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx"],"sourcesContent":["import React from 'react';\n\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, getResolveConfig } from '@adview/core/utils';\nimport { AdViewUnitPropsBase, AdViewUnitServerChildren } from '../types';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\n\nexport type AdViewUnitServerProps = AdViewUnitPropsBase & {\n children?: AdViewUnitServerChildren;\n};\n\nasync function AdViewUnitServer({\n unitId,\n format,\n children,\n ...config\n}: AdViewUnitServerProps) {\n const baseConfig = getResolveConfig(config);\n const requestUrl = getAdRequestUrl(baseConfig, unitId, format);\n const response = await adViewFetcher(requestUrl);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const responseGroup =\n response instanceof Error ? null : response?.groups?.[0];\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items;\n\n if (groupItems && groupItems.length) {\n return groupItems.map(({ tracker, ...data }: AdViewGroupItem) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n }})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n }})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n","//\n// Example\n// <AdView.Unit>\n// <AdView.Template type=\"banner\">\n// <...>\n// </AdView.Template>\n// </AdView.Unit>\n//\n\nimport React, { JSX } from 'react';\nimport { AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } from '../types';\n\n// TemplateListRender is a function that takes a list of TemplateType and returns a React element\nexport type TemplateListRender = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n const { type, children } = (tmpl as TemplateElement).props;\n console.log('=====>\\nrenderTemplate: React element detected, type:', type, 'data:', data.type, data.type !== type);\n // If the type does not match, return null\n if (data.type !== type) {\n return null;\n }\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(data as AdViewUnitClientChildrenProps);\n }\n console.log('CLONE ELEMENT', tmpl);\n // If children is a React element, clone it with the new props\n return React.cloneElement((tmpl as TemplateElement), {\n ...data,\n children: children,\n });\n }\n\n if (isFunction) {\n return tmpl(data);\n }\n\n return null;\n}\n\n// renderTemplates is a function that takes a list of TemplateType and returns a React element\nexport const renderTemplates = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, children, ...data }: AdViewUnitTemplateProps) => {\n const tmplProps: AdViewUnitTemplateTypeProps = {\n type,\n ...data,\n };\n\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]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,mBAAmB,UAAU,EAAC,MAAM,MAAM,KAAK,QAAQ,WAAW,OAAO,OAAO;AAAA,QAC/E,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,WAAW;AAAA,QACX,SAAS;AAAA,MACX,EAAC,CAAC,CACJ;AAAA,IAEJ,CAAC;AAAA,EACH;AAEA,SACE,gBAAAA,OAAA,cAAC,8BAAoB,GAAG,iBACrB,mBAAmB,UAAU,EAAC,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AAAA,IACxE,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,SAAS;AAAA,EACX,EAAC,CAAC,CACJ;AAEJ;AAEA,IAAO,4BAAQ;","names":["React","React","React"]}
@@ -27,24 +27,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
- // src/AdViewUnit/AdViewUnitBanner.tsx
31
- var AdViewUnitBanner_exports = {};
32
- __export(AdViewUnitBanner_exports, {
33
- default: () => AdViewUnitBanner_default
30
+ // src/AdViewUnit/AdViewUnitBannerTemplate.tsx
31
+ var AdViewUnitBannerTemplate_exports = {};
32
+ __export(AdViewUnitBannerTemplate_exports, {
33
+ default: () => AdViewUnitBannerTemplate_default
34
34
  });
35
- module.exports = __toCommonJS(AdViewUnitBanner_exports);
35
+ module.exports = __toCommonJS(AdViewUnitBannerTemplate_exports);
36
36
  var import_utils = require("@adview/core/utils");
37
37
  var import_react = __toESM(require("react"), 1);
38
- function AdViewUnitBanner({ assets, url }) {
39
- const asset = (0, import_utils.getAssetByName)("main", assets);
40
- return /* @__PURE__ */ import_react.default.createElement("center", null, /* @__PURE__ */ import_react.default.createElement(
38
+ function AdViewUnitBannerTemplate({ className = "banner", style, data, state }) {
39
+ if (!data || !data.assets || !data.assets.length || !state?.isComplete) {
40
+ return null;
41
+ }
42
+ const asset = (0, import_utils.getAssetByName)("main", data.assets);
43
+ return /* @__PURE__ */ import_react.default.createElement(
41
44
  "a",
42
45
  {
43
46
  target: "_blank",
44
47
  rel: "noopener noreferrer",
45
- href: (0, import_utils.getPrepareURL)(url),
46
- className: "banner",
47
- style: { fontSize: 0 }
48
+ href: (0, import_utils.getPrepareURL)(data.url),
49
+ className,
50
+ style: { fontSize: 0, ...style }
48
51
  },
49
52
  asset && /* @__PURE__ */ import_react.default.createElement(
50
53
  "img",
@@ -54,7 +57,7 @@ function AdViewUnitBanner({ assets, url }) {
54
57
  srcSet: asset.thumbs ? (0, import_utils.getSrcSetCSSThumbs)(asset.thumbs) : ""
55
58
  }
56
59
  )
57
- ));
60
+ );
58
61
  }
59
- var AdViewUnitBanner_default = AdViewUnitBanner;
60
- //# sourceMappingURL=AdViewUnitBanner.cjs.map
62
+ var AdViewUnitBannerTemplate_default = AdViewUnitBannerTemplate;
63
+ //# sourceMappingURL=AdViewUnitBannerTemplate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnitBannerTemplate.tsx"],"sourcesContent":["import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdViewUnitTemplateTypeProps } from '../types';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state}: AdViewUnitBannerTemplateProps) {\n if (!data || !data.assets || !data.assets.length || !state?.isComplete) {\n return null;\n }\n const asset = getAssetByName('main', data.assets);\n\n return (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(data.url)}\n className={className}\n style={{ fontSize: 0, ...style }}\n >\n {asset && (\n <img\n alt=\"main\"\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : ''}\n />\n )}\n </a>\n );\n}\n\nexport default AdViewUnitBannerTemplate;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkE;AAClE,mBAAkB;AASlB,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,MAAK,GAAkC;AACzG,MAAI,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,UAAU,CAAC,OAAO,YAAY;AACtE,WAAO;AAAA,EACT;AACA,QAAM,YAAQ,6BAAe,QAAQ,KAAK,MAAM;AAEhD,SACE,6BAAAA,QAAA;AAAA,IAAC;AAAA;AAAA,MACC,QAAO;AAAA,MACP,KAAI;AAAA,MACJ,UAAM,4BAAc,KAAK,GAAG;AAAA,MAC5B;AAAA,MACA,OAAO,EAAE,UAAU,GAAG,GAAG,MAAM;AAAA;AAAA,IAE9B,SACC,6BAAAA,QAAA;AAAA,MAAC;AAAA;AAAA,QACC,KAAI;AAAA,QACJ,KAAK,MAAM;AAAA,QACX,QAAQ,MAAM,aAAS,iCAAmB,MAAM,MAAM,IAAI;AAAA;AAAA,IAC5D;AAAA,EAEJ;AAEJ;AAEA,IAAO,mCAAQ;","names":["React"]}
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { c as AdViewUnitTemplateTypeProps } from '../types-B65WDsgh.cjs';
3
+ import '@adview/core/typings';
4
+
5
+ type AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {
6
+ type?: 'banner';
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ };
10
+ declare function AdViewUnitBannerTemplate({ className, style, data, state }: AdViewUnitBannerTemplateProps): React.JSX.Element | null;
11
+
12
+ export { AdViewUnitBannerTemplate as default };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { c as AdViewUnitTemplateTypeProps } from '../types-B65WDsgh.js';
3
+ import '@adview/core/typings';
4
+
5
+ type AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {
6
+ type?: 'banner';
7
+ className?: string;
8
+ style?: React.CSSProperties;
9
+ };
10
+ declare function AdViewUnitBannerTemplate({ className, style, data, state }: AdViewUnitBannerTemplateProps): React.JSX.Element | null;
11
+
12
+ export { AdViewUnitBannerTemplate as default };
@@ -0,0 +1,32 @@
1
+ // src/AdViewUnit/AdViewUnitBannerTemplate.tsx
2
+ import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from "@adview/core/utils";
3
+ import React from "react";
4
+ function AdViewUnitBannerTemplate({ className = "banner", style, data, state }) {
5
+ if (!data || !data.assets || !data.assets.length || !state?.isComplete) {
6
+ return null;
7
+ }
8
+ const asset = getAssetByName("main", data.assets);
9
+ return /* @__PURE__ */ React.createElement(
10
+ "a",
11
+ {
12
+ target: "_blank",
13
+ rel: "noopener noreferrer",
14
+ href: getPrepareURL(data.url),
15
+ className,
16
+ style: { fontSize: 0, ...style }
17
+ },
18
+ asset && /* @__PURE__ */ React.createElement(
19
+ "img",
20
+ {
21
+ alt: "main",
22
+ src: asset.path,
23
+ srcSet: asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : ""
24
+ }
25
+ )
26
+ );
27
+ }
28
+ var AdViewUnitBannerTemplate_default = AdViewUnitBannerTemplate;
29
+ export {
30
+ AdViewUnitBannerTemplate_default as default
31
+ };
32
+ //# sourceMappingURL=AdViewUnitBannerTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnitBannerTemplate.tsx"],"sourcesContent":["import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdViewUnitTemplateTypeProps } from '../types';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state}: AdViewUnitBannerTemplateProps) {\n if (!data || !data.assets || !data.assets.length || !state?.isComplete) {\n return null;\n }\n const asset = getAssetByName('main', data.assets);\n\n return (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(data.url)}\n className={className}\n style={{ fontSize: 0, ...style }}\n >\n {asset && (\n <img\n alt=\"main\"\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : ''}\n />\n )}\n </a>\n );\n}\n\nexport default AdViewUnitBannerTemplate;\n"],"mappings":";AAAA,SAAS,gBAAgB,eAAe,0BAA0B;AAClE,OAAO,WAAW;AASlB,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,MAAK,GAAkC;AACzG,MAAI,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,UAAU,CAAC,OAAO,YAAY;AACtE,WAAO;AAAA,EACT;AACA,QAAM,QAAQ,eAAe,QAAQ,KAAK,MAAM;AAEhD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,QAAO;AAAA,MACP,KAAI;AAAA,MACJ,MAAM,cAAc,KAAK,GAAG;AAAA,MAC5B;AAAA,MACA,OAAO,EAAE,UAAU,GAAG,GAAG,MAAM;AAAA;AAAA,IAE9B,SACC;AAAA,MAAC;AAAA;AAAA,QACC,KAAI;AAAA,QACJ,KAAK,MAAM;AAAA,QACX,QAAQ,MAAM,SAAS,mBAAmB,MAAM,MAAM,IAAI;AAAA;AAAA,IAC5D;AAAA,EAEJ;AAEJ;AAEA,IAAO,mCAAQ;","names":[]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/AdViewUnit/AdViewUnitDefaultTemplate.tsx
31
+ var AdViewUnitDefaultTemplate_exports = {};
32
+ __export(AdViewUnitDefaultTemplate_exports, {
33
+ default: () => AdViewUnitDefaultTemplate_default
34
+ });
35
+ module.exports = __toCommonJS(AdViewUnitDefaultTemplate_exports);
36
+ var import_react = __toESM(require("react"), 1);
37
+ function AdViewUnitDefaultTemplate({ type = "default", data, state, children, ...props }) {
38
+ if (typeof children === "function") {
39
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, children({ data, state, ...props }));
40
+ }
41
+ return children ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, children) : /* @__PURE__ */ import_react.default.createElement("div", { style: { padding: "1rem", textAlign: "center", color: "#666" } }, /* @__PURE__ */ import_react.default.createElement("p", null, "\u{1F504} Default content for ad unit"), /* @__PURE__ */ import_react.default.createElement("p", null, "Data: ", JSON.stringify(data)), /* @__PURE__ */ import_react.default.createElement("p", null, "State: ", JSON.stringify(state)));
42
+ }
43
+ AdViewUnitDefaultTemplate.defaultProps = {
44
+ type: "default",
45
+ children: null
46
+ };
47
+ var AdViewUnitDefaultTemplate_default = AdViewUnitDefaultTemplate;
48
+ //# sourceMappingURL=AdViewUnitDefaultTemplate.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnitDefaultTemplate.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdViewOptionalDataProps, AdViewUnitTemplateTypeProps } from \"../types\";\n\ntype AdViewUnitDefaultTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'default';\n children?: React.ReactNode | ((props: AdViewOptionalDataProps) => React.ReactNode);\n};\n\nfunction AdViewUnitDefaultTemplate({ type='default', data, state, children, ...props }: AdViewUnitDefaultTemplateProps) {\n if (typeof children === 'function') {\n return <>{children({ data, state, ...props })}</>;\n }\n\n return (\n children ? <>{children}</> : (\n <div style={{ padding: '1rem', textAlign: 'center', color: '#666' }}>\n <p>🔄 Default content for ad unit</p>\n <p>Data: {JSON.stringify(data)}</p>\n <p>State: {JSON.stringify(state)}</p>\n </div>\n )\n );\n}\n\nAdViewUnitDefaultTemplate.defaultProps = {\n type: 'default',\n children: null,\n};\n\nexport default AdViewUnitDefaultTemplate;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAQlB,SAAS,0BAA0B,EAAE,OAAK,WAAW,MAAM,OAAO,UAAU,GAAG,MAAM,GAAmC;AACtH,MAAI,OAAO,aAAa,YAAY;AAClC,WAAO,6BAAAA,QAAA,2BAAAA,QAAA,gBAAG,SAAS,EAAE,MAAM,OAAO,GAAG,MAAM,CAAC,CAAE;AAAA,EAChD;AAEA,SACE,WAAW,6BAAAA,QAAA,2BAAAA,QAAA,gBAAG,QAAS,IACrB,6BAAAA,QAAA,cAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,WAAW,UAAU,OAAO,OAAO,KAChE,6BAAAA,QAAA,cAAC,WAAE,uCAA8B,GACjC,6BAAAA,QAAA,cAAC,WAAE,UAAO,KAAK,UAAU,IAAI,CAAE,GAC/B,6BAAAA,QAAA,cAAC,WAAE,WAAQ,KAAK,UAAU,KAAK,CAAE,CACnC;AAGN;AAEA,0BAA0B,eAAe;AAAA,EACvC,MAAM;AAAA,EACN,UAAU;AACZ;AAEA,IAAO,oCAAQ;","names":["React"]}
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { c as AdViewUnitTemplateTypeProps, d as AdViewOptionalDataProps } from '../types-B65WDsgh.cjs';
3
+ import '@adview/core/typings';
4
+
5
+ type AdViewUnitDefaultTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {
6
+ type?: 'default';
7
+ children?: React.ReactNode | ((props: AdViewOptionalDataProps) => React.ReactNode);
8
+ };
9
+ declare function AdViewUnitDefaultTemplate({ type, data, state, children, ...props }: AdViewUnitDefaultTemplateProps): React.JSX.Element;
10
+ declare namespace AdViewUnitDefaultTemplate {
11
+ var defaultProps: {
12
+ type: string;
13
+ children: null;
14
+ };
15
+ }
16
+
17
+ export { AdViewUnitDefaultTemplate as default };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { c as AdViewUnitTemplateTypeProps, d as AdViewOptionalDataProps } from '../types-B65WDsgh.js';
3
+ import '@adview/core/typings';
4
+
5
+ type AdViewUnitDefaultTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {
6
+ type?: 'default';
7
+ children?: React.ReactNode | ((props: AdViewOptionalDataProps) => React.ReactNode);
8
+ };
9
+ declare function AdViewUnitDefaultTemplate({ type, data, state, children, ...props }: AdViewUnitDefaultTemplateProps): React.JSX.Element;
10
+ declare namespace AdViewUnitDefaultTemplate {
11
+ var defaultProps: {
12
+ type: string;
13
+ children: null;
14
+ };
15
+ }
16
+
17
+ export { AdViewUnitDefaultTemplate as default };
@@ -0,0 +1,17 @@
1
+ // src/AdViewUnit/AdViewUnitDefaultTemplate.tsx
2
+ import React from "react";
3
+ function AdViewUnitDefaultTemplate({ type = "default", data, state, children, ...props }) {
4
+ if (typeof children === "function") {
5
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children({ data, state, ...props }));
6
+ }
7
+ return children ? /* @__PURE__ */ React.createElement(React.Fragment, null, children) : /* @__PURE__ */ React.createElement("div", { style: { padding: "1rem", textAlign: "center", color: "#666" } }, /* @__PURE__ */ React.createElement("p", null, "\u{1F504} Default content for ad unit"), /* @__PURE__ */ React.createElement("p", null, "Data: ", JSON.stringify(data)), /* @__PURE__ */ React.createElement("p", null, "State: ", JSON.stringify(state)));
8
+ }
9
+ AdViewUnitDefaultTemplate.defaultProps = {
10
+ type: "default",
11
+ children: null
12
+ };
13
+ var AdViewUnitDefaultTemplate_default = AdViewUnitDefaultTemplate;
14
+ export {
15
+ AdViewUnitDefaultTemplate_default as default
16
+ };
17
+ //# sourceMappingURL=AdViewUnitDefaultTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnitDefaultTemplate.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdViewOptionalDataProps, AdViewUnitTemplateTypeProps } from \"../types\";\n\ntype AdViewUnitDefaultTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'default';\n children?: React.ReactNode | ((props: AdViewOptionalDataProps) => React.ReactNode);\n};\n\nfunction AdViewUnitDefaultTemplate({ type='default', data, state, children, ...props }: AdViewUnitDefaultTemplateProps) {\n if (typeof children === 'function') {\n return <>{children({ data, state, ...props })}</>;\n }\n\n return (\n children ? <>{children}</> : (\n <div style={{ padding: '1rem', textAlign: 'center', color: '#666' }}>\n <p>🔄 Default content for ad unit</p>\n <p>Data: {JSON.stringify(data)}</p>\n <p>State: {JSON.stringify(state)}</p>\n </div>\n )\n );\n}\n\nAdViewUnitDefaultTemplate.defaultProps = {\n type: 'default',\n children: null,\n};\n\nexport default AdViewUnitDefaultTemplate;\n"],"mappings":";AAAA,OAAO,WAAW;AAQlB,SAAS,0BAA0B,EAAE,OAAK,WAAW,MAAM,OAAO,UAAU,GAAG,MAAM,GAAmC;AACtH,MAAI,OAAO,aAAa,YAAY;AAClC,WAAO,0DAAG,SAAS,EAAE,MAAM,OAAO,GAAG,MAAM,CAAC,CAAE;AAAA,EAChD;AAEA,SACE,WAAW,0DAAG,QAAS,IACrB,oCAAC,SAAI,OAAO,EAAE,SAAS,QAAQ,WAAW,UAAU,OAAO,OAAO,KAChE,oCAAC,WAAE,uCAA8B,GACjC,oCAAC,WAAE,UAAO,KAAK,UAAU,IAAI,CAAE,GAC/B,oCAAC,WAAE,WAAQ,KAAK,UAAU,KAAK,CAAE,CACnC;AAGN;AAEA,0BAA0B,eAAe;AAAA,EACvC,MAAM;AAAA,EACN,UAAU;AACZ;AAEA,IAAO,oCAAQ;","names":[]}