@adview/react 1.1.9 → 1.1.10

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 (51) hide show
  1. package/dist/AdViewUnit/AdViewUnit.cjs +17 -4
  2. package/dist/AdViewUnit/AdViewUnit.cjs.map +1 -1
  3. package/dist/AdViewUnit/AdViewUnit.client.cjs +10 -3
  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 +10 -3
  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 +17 -4
  12. package/dist/AdViewUnit/AdViewUnit.js.map +1 -1
  13. package/dist/AdViewUnit/AdViewUnit.server.cjs +7 -1
  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 +7 -1
  18. package/dist/AdViewUnit/AdViewUnit.server.js.map +1 -1
  19. package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.cts +1 -1
  20. package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.ts +1 -1
  21. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.cts +1 -1
  22. package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.ts +1 -1
  23. package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.cts +1 -1
  24. package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.ts +1 -1
  25. package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.cts +1 -1
  26. package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.ts +1 -1
  27. package/dist/AdViewUnit/AdViewUnitTemplate.d.cts +1 -1
  28. package/dist/AdViewUnit/AdViewUnitTemplate.d.ts +1 -1
  29. package/dist/AdViewUnit/useAdViewController.cjs +7 -2
  30. package/dist/AdViewUnit/useAdViewController.cjs.map +1 -1
  31. package/dist/AdViewUnit/useAdViewController.d.cts +4 -2
  32. package/dist/AdViewUnit/useAdViewController.d.ts +4 -2
  33. package/dist/AdViewUnit/useAdViewController.js +7 -2
  34. package/dist/AdViewUnit/useAdViewController.js.map +1 -1
  35. package/dist/AdViewUnit/utils.d.cts +1 -1
  36. package/dist/AdViewUnit/utils.d.ts +1 -1
  37. package/dist/index.cjs +10 -3
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +10 -3
  42. package/dist/index.js.map +1 -1
  43. package/dist/server.cjs +7 -1
  44. package/dist/server.cjs.map +1 -1
  45. package/dist/server.d.cts +1 -1
  46. package/dist/server.d.ts +1 -1
  47. package/dist/server.js +7 -1
  48. package/dist/server.js.map +1 -1
  49. package/dist/{types-BocWXLhL.d.cts → types-Bc2HTUyk.d.cts} +4 -0
  50. package/dist/{types-BocWXLhL.d.ts → types-Bc2HTUyk.d.ts} +4 -0
  51. package/package.json +2 -2
@@ -369,7 +369,7 @@ var AdViewProviderContext = (0, import_react6.createContext)(
369
369
  );
370
370
 
371
371
  // src/AdViewUnit/useAdViewController.ts
372
- function useAdViewController(adUnitConfig, unitId, limit = 1, format) {
372
+ function useAdViewController(adUnitConfig, unitId, limit = 1, format, query) {
373
373
  const [adLoadState, setAdLoadState] = (0, import_react7.useState)("initial");
374
374
  const [adData, setAdData] = (0, import_react7.useState)(null);
375
375
  const [errorMessage, setErrorMessage] = (0, import_react7.useState)(null);
@@ -379,7 +379,12 @@ function useAdViewController(adUnitConfig, unitId, limit = 1, format) {
379
379
  const loadAd = async () => {
380
380
  setAdLoadState("loading");
381
381
  try {
382
- const response = await dataLoader.fetchAdData(unitId, limit || 1, format);
382
+ const response = await dataLoader.fetchAdData(
383
+ unitId,
384
+ limit || 1,
385
+ format,
386
+ query
387
+ );
383
388
  if (response instanceof Error) {
384
389
  setAdLoadState("error");
385
390
  setErrorMessage(response);
@@ -411,6 +416,7 @@ function AdViewUnitClient({
411
416
  unitId,
412
417
  limit = 1,
413
418
  format,
419
+ query,
414
420
  children,
415
421
  wrapper,
416
422
  trackingWrapperClassName,
@@ -426,7 +432,8 @@ function AdViewUnitClient({
426
432
  config,
427
433
  unitId,
428
434
  limit || 1,
429
- format
435
+ format,
436
+ query
430
437
  );
431
438
  const {
432
439
  responseGroup: _,
@@ -495,6 +502,7 @@ async function AdViewUnitServer({
495
502
  format,
496
503
  children,
497
504
  limit,
505
+ query,
498
506
  ...config
499
507
  }) {
500
508
  const checkFormat = (f) => {
@@ -505,7 +513,12 @@ async function AdViewUnitServer({
505
513
  };
506
514
  const baseConfig = (0, import_utils9.getResolveConfig)(config);
507
515
  const dataLoader = (0, import_utils9.getDataLoaderFromConfig)(baseConfig);
508
- const response = await dataLoader.fetchAdData(unitId, limit || 1, format);
516
+ const response = await dataLoader.fetchAdData(
517
+ unitId,
518
+ limit || 1,
519
+ format,
520
+ query
521
+ );
509
522
  const isLoadingError = response instanceof Error;
510
523
  const error = isLoadingError ? response : void 0;
511
524
  const state = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.tsx","../../src/AdViewUnit/AdViewUnit.client.tsx","../../src/AdViewUnit/AdViewUnitBannerTemplate.tsx","../../src/AdViewUnit/utils.ts","../../src/AdViewUnit/AdViewUnitNativeTemplate.tsx","../../src/AdViewUnit/AdViewUnitProxyTemplate.tsx","../../src/AdViewUnit/AdViewUnitTemplate.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/useAdViewController.ts","../../src/AdViewUnit/AdViewProvider.tsx","../../src/AdViewUnit/AdViewUnit.server.tsx"],"sourcesContent":["import React from 'react';\nimport AdViewUnitClient, { AdViewUnitClientProps } from './AdViewUnit.client';\nimport AdViewUnitServer, { AdViewUnitServerProps } from './AdViewUnit.server';\n\nexport type AdViewUnitProps = typeof window extends undefined\n ? AdViewUnitServerProps\n : AdViewUnitClientProps;\n\nfunction AdViewUnit(props: AdViewUnitProps) {\n const isServer = typeof window === 'undefined';\n\n if (isServer) {\n return <AdViewUnitServer {...(props as AdViewUnitServerProps)} />;\n }\n\n return <AdViewUnitClient {...(props as AdViewUnitClientProps)} />;\n}\n\nexport default AdViewUnit;\n","'use client';\n\nimport { AdViewGroupItem } from '@adview/core';\nimport React from 'react';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport useAdViewController from './useAdViewController';\n\nexport type AdViewUnitClientProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n wrapper?: (elms: React.ReactNode[]) => React.ReactNode;\n trackingWrapperClassName?: string;\n};\n\n// AdViewUnitClient is a client-side component that fetches ad data and renders it\n// using the provided children function. It handles loading, error states, and\n// tracks ad interactions.\n//\n// Example usage:\n// <AdView.Unit unitId=\"my-unit\" format=\"banner\" srcURL=\"https://api.example.com/ads/{<id>}\">\n// {({ data, state, error }) => (\n// <div>\n// {state.isLoading && <span>Loading...</span>}\n// {error && <span>Error: {error.message}</span>}\n// {data && <img src={data.imageUrl} alt={data.title} />\n// </div>\n// )}\n// </AdView.Unit>\n//\n// Note: This component is designed to be used in a client-side environment where\n// ad data can be fetched dynamically. It is not suitable for server-side rendering.\n// It uses the AdViewUnitTracking component to handle ad tracking and interactions.\nfunction AdViewUnitClient({\n unitId,\n limit = 1,\n format,\n children,\n wrapper,\n trackingWrapperClassName,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) {\n return true;\n }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n limit || 1,\n format,\n );\n\n const {\n responseGroup: _,\n customTracker,\n groupItems,\n } = error\n ? { responseGroup: null, customTracker: {}, groupItems: [] }\n : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || [])\n .map(it => (checkFormat(it.type) ? it : null))\n .filter(Boolean);\n if (groupItems && groupItems.length > 0) {\n return { responseGroup, customTracker, groupItems };\n }\n }\n return { responseGroup: null, customTracker: {}, groupItems: [] };\n })();\n\n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />,\n ];\n }\n\n if (!wrapper) {\n wrapper = (elms: React.ReactNode[]) => <>{elms}</>;\n }\n\n if (groupItems && groupItems?.length > 0) {\n return wrapper(\n (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }, index) => {\n return (\n <AdViewUnitTracking\n key={data.id}\n {...tracker}\n className={trackingWrapperClassName}\n >\n {renderAnyTemplates(children, {\n unitId,\n index,\n data,\n type: data.type || 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>\n );\n }),\n );\n }\n\n return wrapper([\n <AdViewUnitTracking {...customTracker} className={trackingWrapperClassName}>\n {renderAnyTemplates(children, {\n unitId,\n index: -1,\n data: null,\n type: 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>,\n ]);\n}\n\nexport default AdViewUnitClient;\n","import {\n getAssetByName,\n getPrepareURL,\n getSrcSetCSSThumbs,\n} from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<\n AdViewUnitTemplateTypeProps,\n 'type'\n> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({\n className = 'banner',\n style,\n data,\n state,\n ...props\n}: AdViewUnitBannerTemplateProps) {\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\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 style={{ maxWidth: '100%' }}\n />\n )}\n </a>\n );\n}\n\nAdViewUnitBannerTemplate.defaults = {\n type: 'banner',\n};\n\nexport default AdViewUnitBannerTemplate;\n","import { AdLoadState } from \"../types\";\n\nexport const matchExpectedState = (expectState?: AdLoadState, state?: AdLoadState) => {\n return !expectState || (\n (expectState.isInitial === undefined || expectState.isInitial === state?.isInitial) &&\n (expectState.isLoading === undefined || expectState.isLoading === state?.isLoading) &&\n (expectState.isError === undefined || expectState.isError === state?.isError) &&\n (expectState.isComplete === undefined || expectState.isComplete === state?.isComplete)\n );\n};\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewStyleTokensNative, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitNativeTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'native';\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitNativeTemplate({classNames, data, state, ...props}: AdViewUnitNativeTemplateProps) {\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { assets, url, fields } = data;\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\nAdViewUnitNativeTemplate.defaults = {\n type: 'native',\n};\n\nexport default AdViewUnitNativeTemplate;\n","import React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitProxyTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'proxy';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitProxyTemplate({className, style, data, state, ...props}: AdViewUnitProxyTemplateProps) {\n if (!data) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { url, fields } = data;\n const iframeSrc = fields?.url || url;\n\n if (!iframeSrc) {\n return null;\n }\n\n return (\n <iframe\n className={className}\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%', border: 'none', ...style }}\n src={iframeSrc}\n ></iframe>\n );\n}\n\nAdViewUnitProxyTemplate.defaults = {\n type: 'proxy',\n};\n\nexport default AdViewUnitProxyTemplate;\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 {\n AdLoadState,\n AdViewUnitClientChildrenProps,\n AdViewUnitTemplateProps,\n AdViewUnitTemplateTypeProps,\n} from '../types';\nimport { matchExpectedState } from './utils';\n\n// TemplateListRender is a function that takes a list of TemplateType and returns a React element\nexport type TemplateListRender = (\n tmpls: TemplateElement[],\n) => 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 = (\n props: AdViewUnitTemplateTypeProps,\n) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n wrap?: (children: React.ReactNode) => React.ReactNode,\n): JSX.Element | React.ReactElement => {\n if (!wrap) {\n wrap = (children: React.ReactNode) => children;\n }\n\n let renderedTemplate = null;\n\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, data);\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n\n if (!renderedTemplate) {\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, { ...data, type: 'default' });\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n }\n\n return <>{renderedTemplate}</>;\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (\n tmpl: TemplateElement | TemplateTypeFunction,\n data: AdViewUnitTemplateTypeProps,\n): 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 let { type, children } = tmpl.props;\n if (!type && typeof tmpl.type !== 'string') {\n type = (tmpl.type as any)?.defaults?.type;\n }\n // If the type does not match, return null\n if (!!type && type !== '*' && 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 // 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 = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (\n tmpls: any,\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): 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 = ({\n type,\n state,\n children,\n ...props\n}: AdViewUnitTemplateProps) => {\n const tmplProps: AdViewUnitTemplateTypeProps = {\n type,\n state,\n ...props,\n };\n\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(\n tmplProps as AdViewUnitClientChildrenProps,\n ) 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 className?: string;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n className,\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 (\n <div ref={wrapperRef} className={className}>\n {children}\n </div>\n );\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData, AdViewDataLoader } from '@adview/core/typings';\nimport { getDataLoaderFromConfig, getResolveConfig } from '@adview/core/utils';\nimport { useContext, useEffect, useState } from 'react';\nimport { AdLoadState, AdViewConfig } from '../types';\nimport { AdViewProviderContext } from './AdViewProvider';\n\ntype UseAdViewControllerProps = [AdViewData | null, Error | null, AdLoadState];\n\nfunction useAdViewController(\n adUnitConfig: AdViewConfig,\n unitId: string,\n limit: number = 1,\n format?: string | string[],\n): UseAdViewControllerProps {\n const [adLoadState, setAdLoadState] = useState<string>('initial');\n const [adData, setAdData] = useState<AdViewData | null>(null);\n const [errorMessage, setErrorMessage] = useState<Error | null>(null);\n const globalConfig = useContext(AdViewProviderContext);\n const baseConfig = getResolveConfig({ ...adUnitConfig, ...globalConfig });\n const dataLoader: AdViewDataLoader = getDataLoaderFromConfig(baseConfig);\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await dataLoader.fetchAdData(unitId, limit || 1, format);\n\n if (response instanceof Error) {\n setAdLoadState('error');\n setErrorMessage(response);\n } else {\n setAdData(response);\n }\n setAdLoadState('complete');\n } catch (error) {\n setAdLoadState('error');\n setAdLoadState('complete');\n setErrorMessage(error as Error);\n }\n };\n\n const loadState = {\n isInitial: adLoadState === 'initial',\n isLoading: adLoadState === 'loading',\n isComplete: adLoadState === 'complete',\n isError: adLoadState === 'error',\n };\n\n useEffect(() => {\n loadAd();\n }, [unitId, limit, format]);\n\n return [adData, errorMessage, loadState];\n}\n\nexport default useAdViewController;\n","'use client';\n\nimport React, { createContext } from 'react';\nimport { type AdViewConfig } from '../types';\n\ntype AdViewProviderContextProps = AdViewConfig;\n\nexport const AdViewProviderContext = createContext<AdViewProviderContextProps>(\n {} as AdViewProviderContextProps,\n);\n\ntype AdViewProviderProps = {\n children: React.ReactNode;\n} & AdViewProviderContextProps;\n\nconst AdViewProvider = ({ children, ...props }: AdViewProviderProps) => {\n return (\n <AdViewProviderContext.Provider value={props}>\n {children}\n </AdViewProviderContext.Provider>\n );\n};\n\nexport default AdViewProvider;\n","import React from 'react';\n\nimport { AdViewData, AdViewDataLoader } from '@adview/core';\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { getDataLoaderFromConfig, getResolveConfig } from '@adview/core/utils';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\n\nexport type AdViewUnitServerProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n};\n\nasync function AdViewUnitServer({\n unitId,\n format,\n children,\n limit,\n ...config\n}: AdViewUnitServerProps) {\n const checkFormat = (f: string) => {\n if (!format) {\n return true;\n }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const baseConfig = getResolveConfig(config);\n const dataLoader: AdViewDataLoader = getDataLoaderFromConfig(baseConfig);\n const response = await dataLoader.fetchAdData(unitId, limit || 1, format);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const state = {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n };\n\n const {\n responseGroup: _,\n customTracker,\n groupItems,\n } = error\n ? { responseGroup: null, customTracker: {}, groupItems: [] }\n : (() => {\n for (let responseGroup of (response as AdViewData)?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || [])\n .map(it => (checkFormat(it.type) ? it : null))\n .filter(Boolean) as AdViewGroupItem[];\n if (groupItems && groupItems.length > 0) {\n return { responseGroup, customTracker, groupItems };\n }\n }\n return { responseGroup: null, customTracker: {}, groupItems: [] };\n })();\n\n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />,\n ];\n }\n\n if (groupItems && groupItems.length) {\n return groupItems.map(\n ({ tracker, ...data }: AdViewGroupItem, index: number) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {\n unitId,\n index,\n data,\n type: data.type || 'default',\n error,\n state: state,\n })}\n </AdViewUnitTracking>\n );\n },\n );\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {\n unitId,\n index: -1,\n data: null,\n type: 'default',\n error,\n state: state,\n })}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAAkB;;;ACGlB,IAAAC,gBAAkB;;;ACHlB,mBAIO;AACP,mBAAkB;;;ACHX,IAAM,qBAAqB,CAAC,aAA2B,UAAwB;AACpF,SAAO,CAAC,gBACL,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,YAAY,UAAa,YAAY,YAAY,OAAO,aACpE,YAAY,eAAe,UAAa,YAAY,eAAe,OAAO;AAE/E;;;ADSA,SAAS,yBAAyB;AAAA,EAChC,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,cACJ,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAC7D;AAAA,IACE,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB,IACA,EAAE,YAAY,KAAK;AAEzB,MAAI,CAAC,QAAQ,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,QAAQ;AAChD,WAAO;AAAA,EACT;AAGA,MAAI,CAAC,mBAAmB,aAAa,KAAK,GAAG;AAC3C,WAAO;AAAA,EACT;AAEA,QAAM,YAAQ,6BAAe,QAAQ,KAAK,MAAM;AAEhD,SACE,6BAAAC,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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;;;AV9Ff,SAAS,WAAW,OAAwB;AAC1C,QAAM,WAAW,OAAO,WAAW;AAEnC,MAAI,UAAU;AACZ,WAAO,+BAAAC,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AAAA,EACjE;AAEA,SAAO,+BAAAA,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AACjE;AAEA,IAAO,qBAAQ;","names":["import_react","import_react","React","import_utils","import_react","React","import_react","React","import_react","React","import_utils","import_react","React","import_utils","import_react","import_react","customTracker","groupItems","React","import_react","import_utils","customTracker","groupItems","React","React"]}
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.tsx","../../src/AdViewUnit/AdViewUnit.client.tsx","../../src/AdViewUnit/AdViewUnitBannerTemplate.tsx","../../src/AdViewUnit/utils.ts","../../src/AdViewUnit/AdViewUnitNativeTemplate.tsx","../../src/AdViewUnit/AdViewUnitProxyTemplate.tsx","../../src/AdViewUnit/AdViewUnitTemplate.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/useAdViewController.ts","../../src/AdViewUnit/AdViewProvider.tsx","../../src/AdViewUnit/AdViewUnit.server.tsx"],"sourcesContent":["import React from 'react';\nimport AdViewUnitClient, { AdViewUnitClientProps } from './AdViewUnit.client';\nimport AdViewUnitServer, { AdViewUnitServerProps } from './AdViewUnit.server';\n\nexport type AdViewUnitProps = typeof window extends undefined\n ? AdViewUnitServerProps\n : AdViewUnitClientProps;\n\nfunction AdViewUnit(props: AdViewUnitProps) {\n const isServer = typeof window === 'undefined';\n\n if (isServer) {\n return <AdViewUnitServer {...(props as AdViewUnitServerProps)} />;\n }\n\n return <AdViewUnitClient {...(props as AdViewUnitClientProps)} />;\n}\n\nexport default AdViewUnit;\n","'use client';\n\nimport { AdViewGroupItem } from '@adview/core';\nimport React from 'react';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport useAdViewController from './useAdViewController';\n\nexport type AdViewUnitClientProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n wrapper?: (elms: React.ReactNode[]) => React.ReactNode;\n trackingWrapperClassName?: string;\n};\n\n// AdViewUnitClient is a client-side component that fetches ad data and renders it\n// using the provided children function. It handles loading, error states, and\n// tracks ad interactions.\n//\n// Example usage:\n// <AdView.Unit unitId=\"my-unit\" format=\"banner\" srcURL=\"https://api.example.com/ads/{<id>}\">\n// {({ data, state, error }) => (\n// <div>\n// {state.isLoading && <span>Loading...</span>}\n// {error && <span>Error: {error.message}</span>}\n// {data && <img src={data.imageUrl} alt={data.title} />\n// </div>\n// )}\n// </AdView.Unit>\n//\n// Note: This component is designed to be used in a client-side environment where\n// ad data can be fetched dynamically. It is not suitable for server-side rendering.\n// It uses the AdViewUnitTracking component to handle ad tracking and interactions.\nfunction AdViewUnitClient({\n unitId,\n limit = 1,\n format,\n query,\n children,\n wrapper,\n trackingWrapperClassName,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) {\n return true;\n }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n limit || 1,\n format,\n query,\n );\n\n const {\n responseGroup: _,\n customTracker,\n groupItems,\n } = error\n ? { responseGroup: null, customTracker: {}, groupItems: [] }\n : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || [])\n .map(it => (checkFormat(it.type) ? it : null))\n .filter(Boolean);\n if (groupItems && groupItems.length > 0) {\n return { responseGroup, customTracker, groupItems };\n }\n }\n return { responseGroup: null, customTracker: {}, groupItems: [] };\n })();\n\n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />,\n ];\n }\n\n if (!wrapper) {\n wrapper = (elms: React.ReactNode[]) => <>{elms}</>;\n }\n\n if (groupItems && groupItems?.length > 0) {\n return wrapper(\n (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }, index) => {\n return (\n <AdViewUnitTracking\n key={data.id}\n {...tracker}\n className={trackingWrapperClassName}\n >\n {renderAnyTemplates(children, {\n unitId,\n index,\n data,\n type: data.type || 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>\n );\n }),\n );\n }\n\n return wrapper([\n <AdViewUnitTracking {...customTracker} className={trackingWrapperClassName}>\n {renderAnyTemplates(children, {\n unitId,\n index: -1,\n data: null,\n type: 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>,\n ]);\n}\n\nexport default AdViewUnitClient;\n","import {\n getAssetByName,\n getPrepareURL,\n getSrcSetCSSThumbs,\n} from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<\n AdViewUnitTemplateTypeProps,\n 'type'\n> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({\n className = 'banner',\n style,\n data,\n state,\n ...props\n}: AdViewUnitBannerTemplateProps) {\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\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 style={{ maxWidth: '100%' }}\n />\n )}\n </a>\n );\n}\n\nAdViewUnitBannerTemplate.defaults = {\n type: 'banner',\n};\n\nexport default AdViewUnitBannerTemplate;\n","import { AdLoadState } from \"../types\";\n\nexport const matchExpectedState = (expectState?: AdLoadState, state?: AdLoadState) => {\n return !expectState || (\n (expectState.isInitial === undefined || expectState.isInitial === state?.isInitial) &&\n (expectState.isLoading === undefined || expectState.isLoading === state?.isLoading) &&\n (expectState.isError === undefined || expectState.isError === state?.isError) &&\n (expectState.isComplete === undefined || expectState.isComplete === state?.isComplete)\n );\n};\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewStyleTokensNative, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitNativeTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'native';\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitNativeTemplate({classNames, data, state, ...props}: AdViewUnitNativeTemplateProps) {\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { assets, url, fields } = data;\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\nAdViewUnitNativeTemplate.defaults = {\n type: 'native',\n};\n\nexport default AdViewUnitNativeTemplate;\n","import React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitProxyTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'proxy';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitProxyTemplate({className, style, data, state, ...props}: AdViewUnitProxyTemplateProps) {\n if (!data) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { url, fields } = data;\n const iframeSrc = fields?.url || url;\n\n if (!iframeSrc) {\n return null;\n }\n\n return (\n <iframe\n className={className}\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%', border: 'none', ...style }}\n src={iframeSrc}\n ></iframe>\n );\n}\n\nAdViewUnitProxyTemplate.defaults = {\n type: 'proxy',\n};\n\nexport default AdViewUnitProxyTemplate;\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 {\n AdLoadState,\n AdViewUnitClientChildrenProps,\n AdViewUnitTemplateProps,\n AdViewUnitTemplateTypeProps,\n} from '../types';\nimport { matchExpectedState } from './utils';\n\n// TemplateListRender is a function that takes a list of TemplateType and returns a React element\nexport type TemplateListRender = (\n tmpls: TemplateElement[],\n) => 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 = (\n props: AdViewUnitTemplateTypeProps,\n) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n wrap?: (children: React.ReactNode) => React.ReactNode,\n): JSX.Element | React.ReactElement => {\n if (!wrap) {\n wrap = (children: React.ReactNode) => children;\n }\n\n let renderedTemplate = null;\n\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, data);\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n\n if (!renderedTemplate) {\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, { ...data, type: 'default' });\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n }\n\n return <>{renderedTemplate}</>;\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (\n tmpl: TemplateElement | TemplateTypeFunction,\n data: AdViewUnitTemplateTypeProps,\n): 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 let { type, children } = tmpl.props;\n if (!type && typeof tmpl.type !== 'string') {\n type = (tmpl.type as any)?.defaults?.type;\n }\n // If the type does not match, return null\n if (!!type && type !== '*' && 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 // 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 = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (\n tmpls: any,\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): 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 = ({\n type,\n state,\n children,\n ...props\n}: AdViewUnitTemplateProps) => {\n const tmplProps: AdViewUnitTemplateTypeProps = {\n type,\n state,\n ...props,\n };\n\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(\n tmplProps as AdViewUnitClientChildrenProps,\n ) 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 className?: string;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n className,\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 (\n <div ref={wrapperRef} className={className}>\n {children}\n </div>\n );\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData, AdViewDataLoader } from '@adview/core/typings';\nimport { getDataLoaderFromConfig, getResolveConfig } from '@adview/core/utils';\nimport { useContext, useEffect, useState } from 'react';\nimport { AdLoadState, AdViewConfig } from '../types';\nimport { AdViewProviderContext } from './AdViewProvider';\n\ntype UseAdViewControllerProps = [AdViewData | null, Error | null, AdLoadState];\n\nfunction useAdViewController(\n adUnitConfig: AdViewConfig,\n unitId: string,\n limit: number = 1,\n format?: string | string[],\n query?: { [key: string]: any },\n): UseAdViewControllerProps {\n const [adLoadState, setAdLoadState] = useState<string>('initial');\n const [adData, setAdData] = useState<AdViewData | null>(null);\n const [errorMessage, setErrorMessage] = useState<Error | null>(null);\n const globalConfig = useContext(AdViewProviderContext);\n const baseConfig = getResolveConfig({ ...adUnitConfig, ...globalConfig });\n const dataLoader: AdViewDataLoader = getDataLoaderFromConfig(baseConfig);\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await dataLoader.fetchAdData(\n unitId,\n limit || 1,\n format,\n query,\n );\n\n if (response instanceof Error) {\n setAdLoadState('error');\n setErrorMessage(response);\n } else {\n setAdData(response);\n }\n setAdLoadState('complete');\n } catch (error) {\n setAdLoadState('error');\n setAdLoadState('complete');\n setErrorMessage(error as Error);\n }\n };\n\n const loadState = {\n isInitial: adLoadState === 'initial',\n isLoading: adLoadState === 'loading',\n isComplete: adLoadState === 'complete',\n isError: adLoadState === 'error',\n };\n\n useEffect(() => {\n loadAd();\n }, [unitId, limit, format]);\n\n return [adData, errorMessage, loadState];\n}\n\nexport default useAdViewController;\n","'use client';\n\nimport React, { createContext } from 'react';\nimport { type AdViewConfig } from '../types';\n\ntype AdViewProviderContextProps = AdViewConfig;\n\nexport const AdViewProviderContext = createContext<AdViewProviderContextProps>(\n {} as AdViewProviderContextProps,\n);\n\ntype AdViewProviderProps = {\n children: React.ReactNode;\n} & AdViewProviderContextProps;\n\nconst AdViewProvider = ({ children, ...props }: AdViewProviderProps) => {\n return (\n <AdViewProviderContext.Provider value={props}>\n {children}\n </AdViewProviderContext.Provider>\n );\n};\n\nexport default AdViewProvider;\n","import React from 'react';\n\nimport { AdViewData, AdViewDataLoader } from '@adview/core';\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { getDataLoaderFromConfig, getResolveConfig } from '@adview/core/utils';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\n\nexport type AdViewUnitServerProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n};\n\nasync function AdViewUnitServer({\n unitId,\n format,\n children,\n limit,\n query,\n ...config\n}: AdViewUnitServerProps) {\n const checkFormat = (f: string) => {\n if (!format) {\n return true;\n }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const baseConfig = getResolveConfig(config);\n const dataLoader: AdViewDataLoader = getDataLoaderFromConfig(baseConfig);\n const response = await dataLoader.fetchAdData(\n unitId,\n limit || 1,\n format,\n query,\n );\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const state = {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n };\n\n const {\n responseGroup: _,\n customTracker,\n groupItems,\n } = error\n ? { responseGroup: null, customTracker: {}, groupItems: [] }\n : (() => {\n for (let responseGroup of (response as AdViewData)?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || [])\n .map(it => (checkFormat(it.type) ? it : null))\n .filter(Boolean) as AdViewGroupItem[];\n if (groupItems && groupItems.length > 0) {\n return { responseGroup, customTracker, groupItems };\n }\n }\n return { responseGroup: null, customTracker: {}, groupItems: [] };\n })();\n\n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />,\n ];\n }\n\n if (groupItems && groupItems.length) {\n return groupItems.map(\n ({ tracker, ...data }: AdViewGroupItem, index: number) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {\n unitId,\n index,\n data,\n type: data.type || 'default',\n error,\n state: state,\n })}\n </AdViewUnitTracking>\n );\n },\n );\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {\n unitId,\n index: -1,\n data: null,\n type: 'default',\n error,\n state: state,\n })}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAAkB;;;ACGlB,IAAAC,gBAAkB;;;ACHlB,mBAIO;AACP,mBAAkB;;;ACHX,IAAM,qBAAqB,CAAC,aAA2B,UAAwB;AACpF,SAAO,CAAC,gBACL,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,YAAY,UAAa,YAAY,Y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E,eAAe,eAAAD,gBAAe,YAAAC,YAAW;AAAA,MACpD;AAAA,IACF;AACA,WAAO,EAAE,eAAe,MAAM,eAAe,CAAC,GAAG,YAAY,CAAC,EAAE;AAAA,EAClE,GAAG;AAEP,MAAI,CAAC,UAAU;AACb,eAAW;AAAA,MACT,8BAAAC,QAAA,cAAC,sCAAyB;AAAA,MAC1B,8BAAAA,QAAA,cAAC,sCAAyB;AAAA,MAC1B,8BAAAA,QAAA,cAAC,qCAAwB;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,cAAc,WAAW,QAAQ;AACnC,WAAO,WAAW;AAAA,MAChB,CAAC,EAAE,SAAS,GAAG,KAAK,GAAoB,UAAkB;AACxD,eACE,8BAAAA,QAAA,cAAC,8BAAmB,KAAK,KAAK,IAAK,GAAG,WACnC,mBAAmB,UAAU;AAAA,UAC5B;AAAA,UACA;AAAA,UACA;AAAA,UACA,MAAM,KAAK,QAAQ;AAAA,UACnB;AAAA,UACA;AAAA,QACF,CAAC,CACH;AAAA,MAEJ;AAAA,IACF;AAAA,EACF;AAEA,SACE,8BAAAA,QAAA,cAAC,8BAAoB,GAAG,iBACrB,mBAAmB,UAAU;AAAA,IAC5B;AAAA,IACA,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,EACF,CAAC,CACH;AAEJ;AAEA,IAAO,4BAAQ;;;AVpGf,SAAS,WAAW,OAAwB;AAC1C,QAAM,WAAW,OAAO,WAAW;AAEnC,MAAI,UAAU;AACZ,WAAO,+BAAAC,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AAAA,EACjE;AAEA,SAAO,+BAAAA,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AACjE;AAEA,IAAO,qBAAQ;","names":["import_react","import_react","React","import_utils","import_react","React","import_react","React","import_react","React","import_utils","import_react","React","import_utils","import_react","import_react","customTracker","groupItems","React","import_react","import_utils","customTracker","groupItems","React","React"]}
@@ -367,7 +367,7 @@ var AdViewProviderContext = (0, import_react6.createContext)(
367
367
  );
368
368
 
369
369
  // src/AdViewUnit/useAdViewController.ts
370
- function useAdViewController(adUnitConfig, unitId, limit = 1, format) {
370
+ function useAdViewController(adUnitConfig, unitId, limit = 1, format, query) {
371
371
  const [adLoadState, setAdLoadState] = (0, import_react7.useState)("initial");
372
372
  const [adData, setAdData] = (0, import_react7.useState)(null);
373
373
  const [errorMessage, setErrorMessage] = (0, import_react7.useState)(null);
@@ -377,7 +377,12 @@ function useAdViewController(adUnitConfig, unitId, limit = 1, format) {
377
377
  const loadAd = async () => {
378
378
  setAdLoadState("loading");
379
379
  try {
380
- const response = await dataLoader.fetchAdData(unitId, limit || 1, format);
380
+ const response = await dataLoader.fetchAdData(
381
+ unitId,
382
+ limit || 1,
383
+ format,
384
+ query
385
+ );
381
386
  if (response instanceof Error) {
382
387
  setAdLoadState("error");
383
388
  setErrorMessage(response);
@@ -409,6 +414,7 @@ function AdViewUnitClient({
409
414
  unitId,
410
415
  limit = 1,
411
416
  format,
417
+ query,
412
418
  children,
413
419
  wrapper,
414
420
  trackingWrapperClassName,
@@ -424,7 +430,8 @@ function AdViewUnitClient({
424
430
  config,
425
431
  unitId,
426
432
  limit || 1,
427
- format
433
+ format,
434
+ query
428
435
  );
429
436
  const {
430
437
  responseGroup: _,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.client.tsx","../../src/AdViewUnit/AdViewUnitBannerTemplate.tsx","../../src/AdViewUnit/utils.ts","../../src/AdViewUnit/AdViewUnitNativeTemplate.tsx","../../src/AdViewUnit/AdViewUnitProxyTemplate.tsx","../../src/AdViewUnit/AdViewUnitTemplate.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/useAdViewController.ts","../../src/AdViewUnit/AdViewProvider.tsx"],"sourcesContent":["'use client';\n\nimport { AdViewGroupItem } from '@adview/core';\nimport React from 'react';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport useAdViewController from './useAdViewController';\n\nexport type AdViewUnitClientProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n wrapper?: (elms: React.ReactNode[]) => React.ReactNode;\n trackingWrapperClassName?: string;\n};\n\n// AdViewUnitClient is a client-side component that fetches ad data and renders it\n// using the provided children function. It handles loading, error states, and\n// tracks ad interactions.\n//\n// Example usage:\n// <AdView.Unit unitId=\"my-unit\" format=\"banner\" srcURL=\"https://api.example.com/ads/{<id>}\">\n// {({ data, state, error }) => (\n// <div>\n// {state.isLoading && <span>Loading...</span>}\n// {error && <span>Error: {error.message}</span>}\n// {data && <img src={data.imageUrl} alt={data.title} />\n// </div>\n// )}\n// </AdView.Unit>\n//\n// Note: This component is designed to be used in a client-side environment where\n// ad data can be fetched dynamically. It is not suitable for server-side rendering.\n// It uses the AdViewUnitTracking component to handle ad tracking and interactions.\nfunction AdViewUnitClient({\n unitId,\n limit = 1,\n format,\n children,\n wrapper,\n trackingWrapperClassName,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) {\n return true;\n }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n limit || 1,\n format,\n );\n\n const {\n responseGroup: _,\n customTracker,\n groupItems,\n } = error\n ? { responseGroup: null, customTracker: {}, groupItems: [] }\n : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || [])\n .map(it => (checkFormat(it.type) ? it : null))\n .filter(Boolean);\n if (groupItems && groupItems.length > 0) {\n return { responseGroup, customTracker, groupItems };\n }\n }\n return { responseGroup: null, customTracker: {}, groupItems: [] };\n })();\n\n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />,\n ];\n }\n\n if (!wrapper) {\n wrapper = (elms: React.ReactNode[]) => <>{elms}</>;\n }\n\n if (groupItems && groupItems?.length > 0) {\n return wrapper(\n (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }, index) => {\n return (\n <AdViewUnitTracking\n key={data.id}\n {...tracker}\n className={trackingWrapperClassName}\n >\n {renderAnyTemplates(children, {\n unitId,\n index,\n data,\n type: data.type || 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>\n );\n }),\n );\n }\n\n return wrapper([\n <AdViewUnitTracking {...customTracker} className={trackingWrapperClassName}>\n {renderAnyTemplates(children, {\n unitId,\n index: -1,\n data: null,\n type: 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>,\n ]);\n}\n\nexport default AdViewUnitClient;\n","import {\n getAssetByName,\n getPrepareURL,\n getSrcSetCSSThumbs,\n} from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<\n AdViewUnitTemplateTypeProps,\n 'type'\n> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({\n className = 'banner',\n style,\n data,\n state,\n ...props\n}: AdViewUnitBannerTemplateProps) {\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\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 style={{ maxWidth: '100%' }}\n />\n )}\n </a>\n );\n}\n\nAdViewUnitBannerTemplate.defaults = {\n type: 'banner',\n};\n\nexport default AdViewUnitBannerTemplate;\n","import { AdLoadState } from \"../types\";\n\nexport const matchExpectedState = (expectState?: AdLoadState, state?: AdLoadState) => {\n return !expectState || (\n (expectState.isInitial === undefined || expectState.isInitial === state?.isInitial) &&\n (expectState.isLoading === undefined || expectState.isLoading === state?.isLoading) &&\n (expectState.isError === undefined || expectState.isError === state?.isError) &&\n (expectState.isComplete === undefined || expectState.isComplete === state?.isComplete)\n );\n};\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewStyleTokensNative, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitNativeTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'native';\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitNativeTemplate({classNames, data, state, ...props}: AdViewUnitNativeTemplateProps) {\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { assets, url, fields } = data;\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\nAdViewUnitNativeTemplate.defaults = {\n type: 'native',\n};\n\nexport default AdViewUnitNativeTemplate;\n","import React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitProxyTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'proxy';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitProxyTemplate({className, style, data, state, ...props}: AdViewUnitProxyTemplateProps) {\n if (!data) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { url, fields } = data;\n const iframeSrc = fields?.url || url;\n\n if (!iframeSrc) {\n return null;\n }\n\n return (\n <iframe\n className={className}\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%', border: 'none', ...style }}\n src={iframeSrc}\n ></iframe>\n );\n}\n\nAdViewUnitProxyTemplate.defaults = {\n type: 'proxy',\n};\n\nexport default AdViewUnitProxyTemplate;\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 {\n AdLoadState,\n AdViewUnitClientChildrenProps,\n AdViewUnitTemplateProps,\n AdViewUnitTemplateTypeProps,\n} from '../types';\nimport { matchExpectedState } from './utils';\n\n// TemplateListRender is a function that takes a list of TemplateType and returns a React element\nexport type TemplateListRender = (\n tmpls: TemplateElement[],\n) => 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 = (\n props: AdViewUnitTemplateTypeProps,\n) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n wrap?: (children: React.ReactNode) => React.ReactNode,\n): JSX.Element | React.ReactElement => {\n if (!wrap) {\n wrap = (children: React.ReactNode) => children;\n }\n\n let renderedTemplate = null;\n\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, data);\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n\n if (!renderedTemplate) {\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, { ...data, type: 'default' });\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n }\n\n return <>{renderedTemplate}</>;\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (\n tmpl: TemplateElement | TemplateTypeFunction,\n data: AdViewUnitTemplateTypeProps,\n): 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 let { type, children } = tmpl.props;\n if (!type && typeof tmpl.type !== 'string') {\n type = (tmpl.type as any)?.defaults?.type;\n }\n // If the type does not match, return null\n if (!!type && type !== '*' && 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 // 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 = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (\n tmpls: any,\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): 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 = ({\n type,\n state,\n children,\n ...props\n}: AdViewUnitTemplateProps) => {\n const tmplProps: AdViewUnitTemplateTypeProps = {\n type,\n state,\n ...props,\n };\n\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(\n tmplProps as AdViewUnitClientChildrenProps,\n ) 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 className?: string;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n className,\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 (\n <div ref={wrapperRef} className={className}>\n {children}\n </div>\n );\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData, AdViewDataLoader } from '@adview/core/typings';\nimport { getDataLoaderFromConfig, getResolveConfig } from '@adview/core/utils';\nimport { useContext, useEffect, useState } from 'react';\nimport { AdLoadState, AdViewConfig } from '../types';\nimport { AdViewProviderContext } from './AdViewProvider';\n\ntype UseAdViewControllerProps = [AdViewData | null, Error | null, AdLoadState];\n\nfunction useAdViewController(\n adUnitConfig: AdViewConfig,\n unitId: string,\n limit: number = 1,\n format?: string | string[],\n): UseAdViewControllerProps {\n const [adLoadState, setAdLoadState] = useState<string>('initial');\n const [adData, setAdData] = useState<AdViewData | null>(null);\n const [errorMessage, setErrorMessage] = useState<Error | null>(null);\n const globalConfig = useContext(AdViewProviderContext);\n const baseConfig = getResolveConfig({ ...adUnitConfig, ...globalConfig });\n const dataLoader: AdViewDataLoader = getDataLoaderFromConfig(baseConfig);\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await dataLoader.fetchAdData(unitId, limit || 1, format);\n\n if (response instanceof Error) {\n setAdLoadState('error');\n setErrorMessage(response);\n } else {\n setAdData(response);\n }\n setAdLoadState('complete');\n } catch (error) {\n setAdLoadState('error');\n setAdLoadState('complete');\n setErrorMessage(error as Error);\n }\n };\n\n const loadState = {\n isInitial: adLoadState === 'initial',\n isLoading: adLoadState === 'loading',\n isComplete: adLoadState === 'complete',\n isError: adLoadState === 'error',\n };\n\n useEffect(() => {\n loadAd();\n }, [unitId, limit, format]);\n\n return [adData, errorMessage, loadState];\n}\n\nexport default useAdViewController;\n","'use client';\n\nimport React, { createContext } from 'react';\nimport { type AdViewConfig } from '../types';\n\ntype AdViewProviderContextProps = AdViewConfig;\n\nexport const AdViewProviderContext = createContext<AdViewProviderContextProps>(\n {} as AdViewProviderContextProps,\n);\n\ntype AdViewProviderProps = {\n children: React.ReactNode;\n} & AdViewProviderContextProps;\n\nconst AdViewProvider = ({ children, ...props }: AdViewProviderProps) => {\n return (\n <AdViewProviderContext.Provider value={props}>\n {children}\n </AdViewProviderContext.Provider>\n );\n};\n\nexport default AdViewProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,gBAAkB;;;ACHlB,mBAIO;AACP,mBAAkB;;;ACHX,IAAM,qBAAqB,CAAC,aAA2B,UAAwB;AACpF,SAAO,CAAC,gBACL,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,YAAY,UAAa,YAAY,YAAY,OAAO,aACpE,YAAY,eAAe,UAAa,YAAY,eAAe,OAAO;AAE/E;;;ADSA,SAAS,yBAAyB;AAAA,EAChC,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAChC,QAAM,cACJ,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAC7D;AAAA,IACE,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB,IACA,EA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WAAO,EAAE,eAAe,MAAM,eAAe,CAAC,GAAG,YAAY,CAAC,EAAE;AAAA,EAClE,GAAG;AAEP,MAAI,CAAC,UAAU;AACb,eAAW;AAAA,MACT,8BAAAC,QAAA,cAAC,sCAAyB;AAAA,MAC1B,8BAAAA,QAAA,cAAC,sCAAyB;AAAA,MAC1B,8BAAAA,QAAA,cAAC,qCAAwB;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,CAAC,SAAS;AACZ,cAAU,CAAC,SAA4B,8BAAAA,QAAA,4BAAAA,QAAA,gBAAG,IAAK;AAAA,EACjD;AAEA,MAAI,cAAc,YAAY,SAAS,GAAG;AACxC,WAAO;AAAA,MACJ,WAAiC,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,UAAU;AACrE,eACE,8BAAAA,QAAA;AAAA,UAAC;AAAA;AAAA,YACC,KAAK,KAAK;AAAA,YACT,GAAG;AAAA,YACJ,WAAW;AAAA;AAAA,UAEV,mBAAmB,UAAU;AAAA,YAC5B;AAAA,YACA;AAAA,YACA;AAAA,YACA,MAAM,KAAK,QAAQ;AAAA,YACnB;AAAA,YACA,OAAO;AAAA,UACT,CAAC;AAAA,QACH;AAAA,MAEJ,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO,QAAQ;AAAA,IACb,8BAAAA,QAAA,cAAC,8BAAoB,GAAG,eAAe,WAAW,4BAC/C,mBAAmB,UAAU;AAAA,MAC5B;AAAA,MACA,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,OAAO;AAAA,IACT,CAAC,CACH;AAAA,EACF,CAAC;AACH;AAEA,IAAO,4BAAQ;","names":["import_react","React","import_utils","import_react","React","import_react","React","import_react","React","import_utils","import_react","React","import_utils","import_react","import_react","customTracker","groupItems","React"]}
1
+ {"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.client.tsx","../../src/AdViewUnit/AdViewUnitBannerTemplate.tsx","../../src/AdViewUnit/utils.ts","../../src/AdViewUnit/AdViewUnitNativeTemplate.tsx","../../src/AdViewUnit/AdViewUnitProxyTemplate.tsx","../../src/AdViewUnit/AdViewUnitTemplate.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/useAdViewController.ts","../../src/AdViewUnit/AdViewProvider.tsx"],"sourcesContent":["'use client';\n\nimport { AdViewGroupItem } from '@adview/core';\nimport React from 'react';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitBannerTemplate from './AdViewUnitBannerTemplate';\nimport AdViewUnitNativeTemplate from './AdViewUnitNativeTemplate';\nimport AdViewUnitProxyTemplate from './AdViewUnitProxyTemplate';\nimport { renderAnyTemplates } from './AdViewUnitTemplate';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport useAdViewController from './useAdViewController';\n\nexport type AdViewUnitClientProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n wrapper?: (elms: React.ReactNode[]) => React.ReactNode;\n trackingWrapperClassName?: string;\n};\n\n// AdViewUnitClient is a client-side component that fetches ad data and renders it\n// using the provided children function. It handles loading, error states, and\n// tracks ad interactions.\n//\n// Example usage:\n// <AdView.Unit unitId=\"my-unit\" format=\"banner\" srcURL=\"https://api.example.com/ads/{<id>}\">\n// {({ data, state, error }) => (\n// <div>\n// {state.isLoading && <span>Loading...</span>}\n// {error && <span>Error: {error.message}</span>}\n// {data && <img src={data.imageUrl} alt={data.title} />\n// </div>\n// )}\n// </AdView.Unit>\n//\n// Note: This component is designed to be used in a client-side environment where\n// ad data can be fetched dynamically. It is not suitable for server-side rendering.\n// It uses the AdViewUnitTracking component to handle ad tracking and interactions.\nfunction AdViewUnitClient({\n unitId,\n limit = 1,\n format,\n query,\n children,\n wrapper,\n trackingWrapperClassName,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) {\n return true;\n }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n limit || 1,\n format,\n query,\n );\n\n const {\n responseGroup: _,\n customTracker,\n groupItems,\n } = error\n ? { responseGroup: null, customTracker: {}, groupItems: [] }\n : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || [])\n .map(it => (checkFormat(it.type) ? it : null))\n .filter(Boolean);\n if (groupItems && groupItems.length > 0) {\n return { responseGroup, customTracker, groupItems };\n }\n }\n return { responseGroup: null, customTracker: {}, groupItems: [] };\n })();\n\n if (!children) {\n children = [\n <AdViewUnitBannerTemplate />,\n <AdViewUnitNativeTemplate />,\n <AdViewUnitProxyTemplate />,\n ];\n }\n\n if (!wrapper) {\n wrapper = (elms: React.ReactNode[]) => <>{elms}</>;\n }\n\n if (groupItems && groupItems?.length > 0) {\n return wrapper(\n (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }, index) => {\n return (\n <AdViewUnitTracking\n key={data.id}\n {...tracker}\n className={trackingWrapperClassName}\n >\n {renderAnyTemplates(children, {\n unitId,\n index,\n data,\n type: data.type || 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>\n );\n }),\n );\n }\n\n return wrapper([\n <AdViewUnitTracking {...customTracker} className={trackingWrapperClassName}>\n {renderAnyTemplates(children, {\n unitId,\n index: -1,\n data: null,\n type: 'default',\n error,\n state: loadState,\n })}\n </AdViewUnitTracking>,\n ]);\n}\n\nexport default AdViewUnitClient;\n","import {\n getAssetByName,\n getPrepareURL,\n getSrcSetCSSThumbs,\n} from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<\n AdViewUnitTemplateTypeProps,\n 'type'\n> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({\n className = 'banner',\n style,\n data,\n state,\n ...props\n}: AdViewUnitBannerTemplateProps) {\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\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 style={{ maxWidth: '100%' }}\n />\n )}\n </a>\n );\n}\n\nAdViewUnitBannerTemplate.defaults = {\n type: 'banner',\n};\n\nexport default AdViewUnitBannerTemplate;\n","import { AdLoadState } from \"../types\";\n\nexport const matchExpectedState = (expectState?: AdLoadState, state?: AdLoadState) => {\n return !expectState || (\n (expectState.isInitial === undefined || expectState.isInitial === state?.isInitial) &&\n (expectState.isLoading === undefined || expectState.isLoading === state?.isLoading) &&\n (expectState.isError === undefined || expectState.isError === state?.isError) &&\n (expectState.isComplete === undefined || expectState.isComplete === state?.isComplete)\n );\n};\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewStyleTokensNative, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitNativeTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'native';\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitNativeTemplate({classNames, data, state, ...props}: AdViewUnitNativeTemplateProps) {\n if (!data || !data.assets || !data.assets.length) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { assets, url, fields } = data;\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\nAdViewUnitNativeTemplate.defaults = {\n type: 'native',\n};\n\nexport default AdViewUnitNativeTemplate;\n","import React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitProxyTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'proxy';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitProxyTemplate({className, style, data, state, ...props}: AdViewUnitProxyTemplateProps) {\n if (!data) {\n return null;\n }\n\n const expectState: AdLoadState =\n (props?.isInitial || props?.isLoading || props?.isError || props?.isComplete) ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete\n } : {isComplete: true};\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n const { url, fields } = data;\n const iframeSrc = fields?.url || url;\n\n if (!iframeSrc) {\n return null;\n }\n\n return (\n <iframe\n className={className}\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%', border: 'none', ...style }}\n src={iframeSrc}\n ></iframe>\n );\n}\n\nAdViewUnitProxyTemplate.defaults = {\n type: 'proxy',\n};\n\nexport default AdViewUnitProxyTemplate;\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 {\n AdLoadState,\n AdViewUnitClientChildrenProps,\n AdViewUnitTemplateProps,\n AdViewUnitTemplateTypeProps,\n} from '../types';\nimport { matchExpectedState } from './utils';\n\n// TemplateListRender is a function that takes a list of TemplateType and returns a React element\nexport type TemplateListRender = (\n tmpls: TemplateElement[],\n) => 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 = (\n props: AdViewUnitTemplateTypeProps,\n) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n wrap?: (children: React.ReactNode) => React.ReactNode,\n): JSX.Element | React.ReactElement => {\n if (!wrap) {\n wrap = (children: React.ReactNode) => children;\n }\n\n let renderedTemplate = null;\n\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, data);\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n\n if (!renderedTemplate) {\n for (let tpl of tmpls) {\n let tmp = renderTemplate(tpl, { ...data, type: 'default' });\n if (tmp && React.isValidElement(tmp)) {\n renderedTemplate = wrap(tmp);\n break;\n }\n }\n }\n\n return <>{renderedTemplate}</>;\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (\n tmpl: TemplateElement | TemplateTypeFunction,\n data: AdViewUnitTemplateTypeProps,\n): 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 let { type, children } = tmpl.props;\n if (!type && typeof tmpl.type !== 'string') {\n type = (tmpl.type as any)?.defaults?.type;\n }\n // If the type does not match, return null\n if (!!type && type !== '*' && 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 // 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 = (\n tmpls: TemplateElement[],\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (\n tmpls: any,\n data: AdViewUnitTemplateTypeProps,\n listRender?: TemplateListRender,\n): 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 = ({\n type,\n state,\n children,\n ...props\n}: AdViewUnitTemplateProps) => {\n const tmplProps: AdViewUnitTemplateTypeProps = {\n type,\n state,\n ...props,\n };\n\n const expectState: AdLoadState =\n props?.isInitial || props?.isLoading || props?.isError || props?.isComplete\n ? {\n isInitial: props?.isInitial,\n isLoading: props?.isLoading,\n isError: props?.isError,\n isComplete: props?.isComplete,\n }\n : { isComplete: true };\n\n // Check if the expected state matches the current state\n if (!matchExpectedState(expectState, state)) {\n return null;\n }\n\n // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(\n tmplProps as AdViewUnitClientChildrenProps,\n ) 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 className?: string;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n className,\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 (\n <div ref={wrapperRef} className={className}>\n {children}\n </div>\n );\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData, AdViewDataLoader } from '@adview/core/typings';\nimport { getDataLoaderFromConfig, getResolveConfig } from '@adview/core/utils';\nimport { useContext, useEffect, useState } from 'react';\nimport { AdLoadState, AdViewConfig } from '../types';\nimport { AdViewProviderContext } from './AdViewProvider';\n\ntype UseAdViewControllerProps = [AdViewData | null, Error | null, AdLoadState];\n\nfunction useAdViewController(\n adUnitConfig: AdViewConfig,\n unitId: string,\n limit: number = 1,\n format?: string | string[],\n query?: { [key: string]: any },\n): UseAdViewControllerProps {\n const [adLoadState, setAdLoadState] = useState<string>('initial');\n const [adData, setAdData] = useState<AdViewData | null>(null);\n const [errorMessage, setErrorMessage] = useState<Error | null>(null);\n const globalConfig = useContext(AdViewProviderContext);\n const baseConfig = getResolveConfig({ ...adUnitConfig, ...globalConfig });\n const dataLoader: AdViewDataLoader = getDataLoaderFromConfig(baseConfig);\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await dataLoader.fetchAdData(\n unitId,\n limit || 1,\n format,\n query,\n );\n\n if (response instanceof Error) {\n setAdLoadState('error');\n setErrorMessage(response);\n } else {\n setAdData(response);\n }\n setAdLoadState('complete');\n } catch (error) {\n setAdLoadState('error');\n setAdLoadState('complete');\n setErrorMessage(error as Error);\n }\n };\n\n const loadState = {\n isInitial: adLoadState === 'initial',\n isLoading: adLoadState === 'loading',\n isComplete: adLoadState === 'complete',\n isError: adLoadState === 'error',\n };\n\n useEffect(() => {\n loadAd();\n }, [unitId, limit, format]);\n\n return [adData, errorMessage, loadState];\n}\n\nexport default useAdViewController;\n","'use client';\n\nimport React, { createContext } from 'react';\nimport { type AdViewConfig } from '../types';\n\ntype AdViewProviderContextProps = AdViewConfig;\n\nexport const AdViewProviderContext = createContext<AdViewProviderContextProps>(\n {} as AdViewProviderContextProps,\n);\n\ntype AdViewProviderProps = {\n children: React.ReactNode;\n} & AdViewProviderContextProps;\n\nconst AdViewProvider = ({ children, ...props }: AdViewProviderProps) => {\n return (\n <AdViewProviderContext.Provider value={props}>\n {children}\n </AdViewProviderContext.Provider>\n );\n};\n\nexport default AdViewProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAA,gBAAkB;;;ACHlB,mBAIO;AACP,mBAAkB;;;ACHX,IAAM,qBAAqB,CAAC,aAA2B,UAAwB;AACpF,SAAO,CAAC,gBACL,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,cAAc,UAAa,YAAY,cAAc,OAAO,eACxE,YAAY,YAAY,UAAa,YAAY,YAAY,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B,GAAG,eAAe,WAAW,4BAC/C,mBAAmB,UAAU;AAAA,MAC5B;AAAA,MACA,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,MACA,OAAO;AAAA,IACT,CAAC,CACH;AAAA,EACF,CAAC;AACH;AAEA,IAAO,4BAAQ;","names":["import_react","React","import_utils","import_react","React","import_react","React","import_react","React","import_utils","import_react","React","import_utils","import_react","import_react","customTracker","groupItems","React"]}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { d as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-BocWXLhL.cjs';
2
+ import { d as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-Bc2HTUyk.cjs';
3
3
  import '@adview/core/typings';
4
4
 
5
5
  type AdViewUnitClientProps = AdViewUnitPropsBase & {
@@ -7,6 +7,6 @@ type AdViewUnitClientProps = AdViewUnitPropsBase & {
7
7
  wrapper?: (elms: React.ReactNode[]) => React.ReactNode;
8
8
  trackingWrapperClassName?: string;
9
9
  };
10
- declare function AdViewUnitClient({ unitId, limit, format, children, wrapper, trackingWrapperClassName, ...config }: AdViewUnitClientProps): React.ReactNode;
10
+ declare function AdViewUnitClient({ unitId, limit, format, query, children, wrapper, trackingWrapperClassName, ...config }: AdViewUnitClientProps): React.ReactNode;
11
11
 
12
12
  export { type AdViewUnitClientProps, AdViewUnitClient as default };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { d as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-BocWXLhL.js';
2
+ import { d as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-Bc2HTUyk.js';
3
3
  import '@adview/core/typings';
4
4
 
5
5
  type AdViewUnitClientProps = AdViewUnitPropsBase & {
@@ -7,6 +7,6 @@ type AdViewUnitClientProps = AdViewUnitPropsBase & {
7
7
  wrapper?: (elms: React.ReactNode[]) => React.ReactNode;
8
8
  trackingWrapperClassName?: string;
9
9
  };
10
- declare function AdViewUnitClient({ unitId, limit, format, children, wrapper, trackingWrapperClassName, ...config }: AdViewUnitClientProps): React.ReactNode;
10
+ declare function AdViewUnitClient({ unitId, limit, format, query, children, wrapper, trackingWrapperClassName, ...config }: AdViewUnitClientProps): React.ReactNode;
11
11
 
12
12
  export { type AdViewUnitClientProps, AdViewUnitClient as default };
@@ -338,7 +338,7 @@ var AdViewProviderContext = createContext(
338
338
  );
339
339
 
340
340
  // src/AdViewUnit/useAdViewController.ts
341
- function useAdViewController(adUnitConfig, unitId, limit = 1, format) {
341
+ function useAdViewController(adUnitConfig, unitId, limit = 1, format, query) {
342
342
  const [adLoadState, setAdLoadState] = useState("initial");
343
343
  const [adData, setAdData] = useState(null);
344
344
  const [errorMessage, setErrorMessage] = useState(null);
@@ -348,7 +348,12 @@ function useAdViewController(adUnitConfig, unitId, limit = 1, format) {
348
348
  const loadAd = async () => {
349
349
  setAdLoadState("loading");
350
350
  try {
351
- const response = await dataLoader.fetchAdData(unitId, limit || 1, format);
351
+ const response = await dataLoader.fetchAdData(
352
+ unitId,
353
+ limit || 1,
354
+ format,
355
+ query
356
+ );
352
357
  if (response instanceof Error) {
353
358
  setAdLoadState("error");
354
359
  setErrorMessage(response);
@@ -380,6 +385,7 @@ function AdViewUnitClient({
380
385
  unitId,
381
386
  limit = 1,
382
387
  format,
388
+ query,
383
389
  children,
384
390
  wrapper,
385
391
  trackingWrapperClassName,
@@ -395,7 +401,8 @@ function AdViewUnitClient({
395
401
  config,
396
402
  unitId,
397
403
  limit || 1,
398
- format
404
+ format,
405
+ query
399
406
  );
400
407
  const {
401
408
  responseGroup: _,