@adview/react 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AdViewUnit/AdViewUnit.cjs +3 -3
- package/dist/AdViewUnit/AdViewUnit.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.cjs +2 -2
- package/dist/AdViewUnit/AdViewUnit.client.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.js +2 -2
- package/dist/AdViewUnit/AdViewUnit.client.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnit.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnit.js +3 -3
- package/dist/AdViewUnit/AdViewUnit.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.cjs +2 -2
- package/dist/AdViewUnit/AdViewUnit.server.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.js +2 -2
- package/dist/AdViewUnit/AdViewUnit.server.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.js +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.js.map +1 -1
- package/dist/AdViewUnit/useAdViewController.d.cts +1 -1
- package/dist/AdViewUnit/useAdViewController.d.ts +1 -1
- package/dist/AdViewUnit/utils.d.cts +1 -1
- package/dist/AdViewUnit/utils.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +2 -2
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/{types-DHjNgnRW.d.cts → types-E00UyX0q.d.cts} +2 -2
- package/dist/{types-DHjNgnRW.d.ts → types-E00UyX0q.d.ts} +2 -2
- package/package.json +1 -1
|
@@ -250,7 +250,7 @@ var renderTemplate = (tmpl, data) => {
|
|
|
250
250
|
if (!type && typeof tmpl.type !== "string") {
|
|
251
251
|
type = tmpl.type?.defaults?.type;
|
|
252
252
|
}
|
|
253
|
-
if (data.type !== type) {
|
|
253
|
+
if (!!type && type !== "*" && data.type !== type) {
|
|
254
254
|
return null;
|
|
255
255
|
}
|
|
256
256
|
if (typeof children === "function") {
|
|
@@ -413,7 +413,7 @@ function AdViewUnitClient({
|
|
|
413
413
|
const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
|
|
414
414
|
for (let responseGroup of response?.groups || []) {
|
|
415
415
|
const customTracker2 = responseGroup?.custom_tracker ?? {};
|
|
416
|
-
const groupItems2 = responseGroup?.items.map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
416
|
+
const groupItems2 = (responseGroup?.items || []).map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
417
417
|
if (groupItems2 && groupItems2.length > 0) {
|
|
418
418
|
return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
|
|
419
419
|
}
|
|
@@ -465,7 +465,7 @@ async function AdViewUnitServer({
|
|
|
465
465
|
const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
|
|
466
466
|
for (let responseGroup of response?.groups || []) {
|
|
467
467
|
const customTracker2 = responseGroup?.custom_tracker ?? {};
|
|
468
|
-
const groupItems2 = responseGroup?.items.map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
468
|
+
const groupItems2 = (responseGroup?.items || []).map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
469
469
|
if (groupItems2 && groupItems2.length > 0) {
|
|
470
470
|
return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
|
|
471
471
|
}
|
|
@@ -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};\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 format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items.map(it => checkFormat(it.type) ? it : null).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 (groupItems && groupItems?.length > 0) {\n return (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state, ...props}: AdViewUnitBannerTemplateProps) {\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 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 />\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 { AdLoadState, AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } 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 = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n 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 (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 = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, state, children, ...props }: 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 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 // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 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 requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\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(() => {loadAd()}, []);\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 } from '@adview/core';\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 ...config\n}: AdViewUnitServerProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const baseConfig = getResolveConfig(config);\n const requestUrl = getAdRequestUrl(baseConfig, unitId, format);\n const response = await adViewFetcher(requestUrl);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const state = {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n };\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of (response as AdViewData)?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items.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(({ tracker, ...data }: AdViewGroupItem) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: state})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: state})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAAkB;;;ACGlB,IAAAC,gBAAkB;;;ACHlB,mBAAkE;AAClE,mBAAkB;;;ACCX,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;;;ADEA,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,OAAO,GAAG,MAAK,GAAkC;AACnH,QAAM,cACH,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAAc;AAAA,IAC9E,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB,IAAI,EAAC,YAAY,KAA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AAQ;;;AVpEf,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};\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 format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || []).map(it => checkFormat(it.type) ? it : null).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 (groupItems && groupItems?.length > 0) {\n return (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state, ...props}: AdViewUnitBannerTemplateProps) {\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 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 />\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 { AdLoadState, AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } 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 = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n 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 = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, state, children, ...props }: 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 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 // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 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 requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\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(() => {loadAd()}, []);\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 } from '@adview/core';\nimport { AdViewGroupItem } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 ...config\n}: AdViewUnitServerProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const baseConfig = getResolveConfig(config);\n const requestUrl = getAdRequestUrl(baseConfig, unitId, format);\n const response = await adViewFetcher(requestUrl);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const state = {\n isLoading: true,\n isComplete: true,\n isInitial: false,\n isError: isLoadingError,\n };\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of (response as AdViewData)?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || []).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(({ tracker, ...data }: AdViewGroupItem) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: state})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: state})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAAkB;;;ACGlB,IAAAC,gBAAkB;;;ACHlB,mBAAkE;AAClE,mBAAkB;;;ACCX,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;;;ADEA,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,OAAO,GAAG,MAAK,GAAkC;AACnH,QAAM,cACH,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAAc;AAAA,IAC9E,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB,IAAI,EAAC,YAAY,KAAI;AAEvB,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,KA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AQ;","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"]}
|
|
@@ -248,7 +248,7 @@ var renderTemplate = (tmpl, data) => {
|
|
|
248
248
|
if (!type && typeof tmpl.type !== "string") {
|
|
249
249
|
type = tmpl.type?.defaults?.type;
|
|
250
250
|
}
|
|
251
|
-
if (data.type !== type) {
|
|
251
|
+
if (!!type && type !== "*" && data.type !== type) {
|
|
252
252
|
return null;
|
|
253
253
|
}
|
|
254
254
|
if (typeof children === "function") {
|
|
@@ -411,7 +411,7 @@ function AdViewUnitClient({
|
|
|
411
411
|
const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
|
|
412
412
|
for (let responseGroup of response?.groups || []) {
|
|
413
413
|
const customTracker2 = responseGroup?.custom_tracker ?? {};
|
|
414
|
-
const groupItems2 = responseGroup?.items.map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
414
|
+
const groupItems2 = (responseGroup?.items || []).map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
415
415
|
if (groupItems2 && groupItems2.length > 0) {
|
|
416
416
|
return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
|
|
417
417
|
}
|
|
@@ -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};\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 format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items.map(it => checkFormat(it.type) ? it : null).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 (groupItems && groupItems?.length > 0) {\n return (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state, ...props}: AdViewUnitBannerTemplateProps) {\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 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 />\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 { AdLoadState, AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } 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 = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n 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 (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 = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, state, children, ...props }: 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 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 // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 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 requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\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(() => {loadAd()}, []);\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,mBAAkE;AAClE,mBAAkB;;;ACCX,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;;;ADEA,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,OAAO,GAAG,MAAK,GAAkC;AACnH,QAAM,cACH,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAAc;AAAA,IAC9E,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB,IAAI,EAAC,YAAY,KAAI;AAEvB,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,SACC,6BAAAA,QAAA;AAAA,M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AG,KAAK,MAAM;AACrE,aACE,8BAAAA,QAAA,cAAC,8BAAmB,KAAK,KAAK,IAAK,GAAG,WACnC,mBAAmB,UAAU,EAAC,MAAM,MAAM,KAAK,QAAQ,WAAW,OAAO,OAAO,UAAS,CAAC,CAC7F;AAAA,IAEJ,CAAC;AAAA,EACH;AAEA,SACE,8BAAAA,QAAA,cAAC,8BAAoB,GAAG,iBACrB,mBAAmB,UAAU,EAAC,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO,UAAS,CAAC,CACtF;AAEJ;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};\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 format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || []).map(it => checkFormat(it.type) ? it : null).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 (groupItems && groupItems?.length > 0) {\n return (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state, ...props}: AdViewUnitBannerTemplateProps) {\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 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 />\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 { AdLoadState, AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } 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 = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n 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 = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, state, children, ...props }: 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 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 // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 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 requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\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(() => {loadAd()}, []);\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,mBAAkE;AAClE,mBAAkB;;;ACCX,IAAM,qBAAqB,CAAC,aAA2B,UAAwB;AACpF,SAAO,CAAC,gBACL,YAAY,cAAc,UAAa,YAAY,cAAc,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O,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 { A as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-
|
|
2
|
+
import { A as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-E00UyX0q.cjs';
|
|
3
3
|
import '@adview/core/typings';
|
|
4
4
|
|
|
5
5
|
type AdViewUnitClientProps = AdViewUnitPropsBase & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { A as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-
|
|
2
|
+
import { A as AdViewUnitPropsBase, a as AdViewUnitClientChildren } from '../types-E00UyX0q.js';
|
|
3
3
|
import '@adview/core/typings';
|
|
4
4
|
|
|
5
5
|
type AdViewUnitClientProps = AdViewUnitPropsBase & {
|
|
@@ -215,7 +215,7 @@ var renderTemplate = (tmpl, data) => {
|
|
|
215
215
|
if (!type && typeof tmpl.type !== "string") {
|
|
216
216
|
type = tmpl.type?.defaults?.type;
|
|
217
217
|
}
|
|
218
|
-
if (data.type !== type) {
|
|
218
|
+
if (!!type && type !== "*" && data.type !== type) {
|
|
219
219
|
return null;
|
|
220
220
|
}
|
|
221
221
|
if (typeof children === "function") {
|
|
@@ -378,7 +378,7 @@ function AdViewUnitClient({
|
|
|
378
378
|
const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
|
|
379
379
|
for (let responseGroup of response?.groups || []) {
|
|
380
380
|
const customTracker2 = responseGroup?.custom_tracker ?? {};
|
|
381
|
-
const groupItems2 = responseGroup?.items.map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
381
|
+
const groupItems2 = (responseGroup?.items || []).map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
382
382
|
if (groupItems2 && groupItems2.length > 0) {
|
|
383
383
|
return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
|
|
384
384
|
}
|
|
@@ -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};\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 format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items.map(it => checkFormat(it.type) ? it : null).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 (groupItems && groupItems?.length > 0) {\n return (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state, ...props}: AdViewUnitBannerTemplateProps) {\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 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 />\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 { AdLoadState, AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } 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 = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n 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 (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 = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, state, children, ...props }: 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 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 // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 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 requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\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(() => {loadAd()}, []);\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":";;;AAGA,OAAOA,YAAW;;;ACHlB,SAAS,gBAAgB,eAAe,0BAA0B;AAClE,OAAO,WAAW;;;ACCX,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;;;ADEA,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,OAAO,GAAG,MAAK,GAAkC;AACnH,QAAM,cACH,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAAc;AAAA,IAC9E,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB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G,UAAIA,eAAcA,YAAW,SAAS,GAAG;AACvC,eAAO,EAAC,eAAe,eAAAD,gBAAe,YAAAC,YAAU;AAAA,MAClD;AAAA,IACF;AACA,WAAO,EAAC,eAAe,MAAM,eAAe,CAAC,GAAG,YAAY,CAAC,EAAC;AAAA,EAChE,GAAG;AAEH,MAAI,CAAC,UAAU;AACb,eAAW;AAAA,MACT,gBAAAC,OAAA,cAAC,sCAAyB;AAAA,MAC1B,gBAAAA,OAAA,cAAC,sCAAyB;AAAA,MAC1B,gBAAAA,OAAA,cAAC,qCAAwB;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,cAAc,YAAY,SAAS,GAAG;AACxC,WAAQ,WAAiC,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,MAAM;AACrE,aACE,gBAAAA,OAAA,cAAC,8BAAmB,KAAK,KAAK,IAAK,GAAG,WACnC,mBAAmB,UAAU,EAAC,MAAM,MAAM,KAAK,QAAQ,WAAW,OAAO,OAAO,UAAS,CAAC,CAC7F;AAAA,IAEJ,CAAC;AAAA,EACH;AAEA,SACE,gBAAAA,OAAA,cAAC,8BAAoB,GAAG,iBACrB,mBAAmB,UAAU,EAAC,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO,UAAS,CAAC,CACtF;AAEJ;AAEA,IAAO,4BAAQ;","names":["React","getAssetByName","getPrepareURL","getSrcSetCSSThumbs","React","getAssetByName","React","getPrepareURL","getSrcSetCSSThumbs","React","React","React","React","React","useEffect","React","useEffect","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};\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 format,\n children,\n ...config\n}: AdViewUnitClientProps) {\n const checkFormat = (f: string) => {\n if (!format) { return true; }\n return Array.isArray(format) ? format.includes(f) : f === format;\n };\n\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n\n const { responseGroup: _, customTracker, groupItems } = error ? {responseGroup: null, customTracker: {}, groupItems: []} : (() => {\n for (let responseGroup of response?.groups || []) {\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = (responseGroup?.items || []).map(it => checkFormat(it.type) ? it : null).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 (groupItems && groupItems?.length > 0) {\n return (groupItems as AdViewGroupItem[]).map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n {renderAnyTemplates(children, {data, type: data.type || 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n {renderAnyTemplates(children, {data: null, type: 'default', error, state: loadState})}\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdLoadState, AdViewUnitTemplateTypeProps } from '../types';\nimport { matchExpectedState } from './utils';\n\ntype AdViewUnitBannerTemplateProps = Omit<AdViewUnitTemplateTypeProps, 'type'> & {\n type?: 'banner';\n className?: string;\n style?: React.CSSProperties;\n};\n\nfunction AdViewUnitBannerTemplate({className=\"banner\", style, data, state, ...props}: AdViewUnitBannerTemplateProps) {\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 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 />\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 { AdLoadState, AdViewUnitClientChildrenProps, AdViewUnitTemplateProps, AdViewUnitTemplateTypeProps } 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 = (tmpls: TemplateElement[]) => React.ReactElement | JSX.Element;\n\n// TemplateType is a React component that can be used to render ad templates\nexport type TemplateType = React.Component<AdViewUnitTemplateProps>;\nexport type TemplateElement = React.ReactElement<AdViewUnitTemplateProps>;\n\n// TemplateTypeFunction is a function that takes AdViewUnitTemplateTypeProps and returns a React node or element\nexport type TemplateTypeFunction = (props: AdViewUnitTemplateTypeProps) => React.ReactNode | React.ReactElement;\n\n// templateFromListRender is a function that takes a list of TemplateType and returns a React element\nexport const templateFromListRender = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, wrap?: (children: React.ReactNode) => React.ReactNode): JSX.Element | React.ReactElement => {\n let renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, data);\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n\n if (!renderedRemplates.length) {\n renderedRemplates = tmpls.map((tmpl, index) => {\n let tmp = renderTemplate(tmpl, {...data, type: 'default'});\n return !!tmp && React.isValidElement(tmp)\n ? <React.Fragment key={index}>{!!wrap ? wrap(tmp) : tmp}</React.Fragment>\n : null;\n }).filter(it => !!it);\n }\n\n return (<>{renderedRemplates}</>);\n};\n\n// renderTemplate is a function that takes a TemplateType or a function and returns a React node\nexport const renderTemplate = (tmpl: TemplateElement | TemplateTypeFunction, data: AdViewUnitTemplateTypeProps): React.ReactNode => {\n const isFunction = typeof tmpl === 'function';\n const isReactElement = React.isValidElement(tmpl);\n\n if (isReactElement) {\n // Extract type and children from the React element\n 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 = (tmpls: TemplateElement[], data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element => {\n return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);\n};\n\nexport const renderAnyTemplates = (tmpls: any, data: AdViewUnitTemplateTypeProps, listRender?: TemplateListRender): React.ReactNode | React.ReactElement | JSX.Element | null => {\n if (!tmpls) {\n return null;\n }\n\n if (Array.isArray(tmpls)) {\n return renderTemplates(tmpls as TemplateElement[], data, listRender);\n }\n\n if (typeof tmpls === 'function') {\n return tmpls(data);\n }\n\n if (React.isValidElement(tmpls)) {\n return templateFromListRender([tmpls as TemplateElement], data);\n }\n\n return null;\n}\n\n// Template is a React component that renders a template based on the type and data provided\n// Example usage:\n// <AdView.Unit>\n// <AdView.Template type=\"banner\" data={{...}}>\n// </AdView.Unit>\nconst AdViewUnitTemplate = ({ type, state, children, ...props }: 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 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 // If children is a function, call it with the data\n if (typeof children === 'function') {\n return children(tmplProps as AdViewUnitClientChildrenProps) as React.ReactElement;\n }\n\n // If children is a React element, clone it with the new props\n if (React.isValidElement(children)) {\n return React.cloneElement(children, tmplProps);\n }\n\n // If no children are provided, return an empty fragment\n return <></>;\n}\n\nexport default AdViewUnitTemplate;\n","'use client';\n\nimport { executeImpressionsTracking } from '@adview/core/utils';\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\n\ntype AdViewUnitTrackingProps = {\n impressions?: string[];\n views?: string[];\n clicks?: string[];\n children: React.ReactNode;\n};\n\nfunction AdViewUnitTracking({\n impressions,\n views,\n clicks,\n children,\n}: AdViewUnitTrackingProps) {\n const isServer = typeof window === 'undefined';\n const wrapperRef = useRef<HTMLDivElement>(null);\n const executeImpressionsTrackingHandler = useCallback(\n () => executeImpressionsTracking(impressions),\n [impressions],\n );\n const trackingObserverInstanceHandler = useCallback(\n (entries: IntersectionObserverEntry[]) => {\n entries.forEach(entry => {\n if (entry.isIntersecting) {\n executeImpressionsTracking(views);\n trackingObserverInstance?.unobserve(wrapperRef.current!);\n }\n });\n },\n [views],\n );\n const trackingObserverInstance = useMemo<IntersectionObserver | null>(() => {\n return !isServer\n ? new IntersectionObserver(trackingObserverInstanceHandler)\n : null;\n }, [isServer, trackingObserverInstanceHandler]);\n const clickTrackerHandler = useCallback(() => {\n executeImpressionsTracking(clicks);\n\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n }, [clicks]);\n\n useEffect(() => {\n if (wrapperRef.current && trackingObserverInstance) {\n executeImpressionsTrackingHandler();\n wrapperRef.current?.addEventListener('click', clickTrackerHandler);\n trackingObserverInstance?.observe(wrapperRef.current);\n\n return () => {\n wrapperRef.current?.removeEventListener('click', clickTrackerHandler);\n if (wrapperRef.current)\n trackingObserverInstance?.unobserve(wrapperRef.current);\n };\n }\n\n return () => {};\n }, [\n trackingObserverInstance,\n executeImpressionsTrackingHandler,\n clickTrackerHandler,\n ]);\n\n return <div ref={wrapperRef}>{children}</div>;\n}\n\nexport default AdViewUnitTracking;\n","'use client';\n\nimport { AdViewData } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, 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 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 requestUrl = getAdRequestUrl(baseConfig, unitId,\n typeof format === 'string' ? format : format?.join(',') || '');\n\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\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(() => {loadAd()}, []);\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":";;;AAGA,OAAOA,YAAW;;;ACHlB,SAAS,gBAAgB,eAAe,0BAA0B;AAClE,OAAO,WAAW;;;ACCX,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;;;ADEA,SAAS,yBAAyB,EAAC,YAAU,UAAU,OAAO,MAAM,OAAO,GAAG,MAAK,GAAkC;AACnH,QAAM,cACH,OAAO,aAAa,OAAO,aAAa,OAAO,WAAW,OAAO,aAAc;AAAA,IAC9E,WAAW,OAAO;AAAA,IAClB,WAAW,OAAO;AAAA,IAClB,SAAS,OAAO;AAAA,IAChB,YAAY,OAAO;AAAA,EACrB,IAAI,EAAC,YAAY,KAAI;AAEvB,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,QAAQ,eAAe,QAAQ,KAAK,MAAM;AAEhD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,QAAO;AAAA,MACP,KAAI;AAAA,MACJ,MAAM,cAAc,KAAK,GAAG;AAAA,MAC5B;AAAA,MACA,OAAO,EAAE,UAAU,GAAG,GAAG,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C,qCAAwB;AAAA,IAC3B;AAAA,EACF;AAEA,MAAI,cAAc,YAAY,SAAS,GAAG;AACxC,WAAQ,WAAiC,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,MAAM;AACrE,aACE,gBAAAA,OAAA,cAAC,8BAAmB,KAAK,KAAK,IAAK,GAAG,WACnC,mBAAmB,UAAU,EAAC,MAAM,MAAM,KAAK,QAAQ,WAAW,OAAO,OAAO,UAAS,CAAC,CAC7F;AAAA,IAEJ,CAAC;AAAA,EACH;AAEA,SACE,gBAAAA,OAAA,cAAC,8BAAoB,GAAG,iBACrB,mBAAmB,UAAU,EAAC,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO,UAAS,CAAC,CACtF;AAEJ;AAEA,IAAO,4BAAQ;","names":["React","getAssetByName","getPrepareURL","getSrcSetCSSThumbs","React","getAssetByName","React","getPrepareURL","getSrcSetCSSThumbs","React","React","React","React","React","useEffect","React","useEffect","customTracker","groupItems","React"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AdViewUnitClientProps } from './AdViewUnit.client.cjs';
|
|
3
3
|
import { AdViewUnitServerProps } from './AdViewUnit.server.cjs';
|
|
4
|
-
import '../types-
|
|
4
|
+
import '../types-E00UyX0q.cjs';
|
|
5
5
|
import '@adview/core/typings';
|
|
6
6
|
|
|
7
7
|
type AdViewUnitProps = typeof window extends undefined ? AdViewUnitServerProps : AdViewUnitClientProps;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AdViewUnitClientProps } from './AdViewUnit.client.js';
|
|
3
3
|
import { AdViewUnitServerProps } from './AdViewUnit.server.js';
|
|
4
|
-
import '../types-
|
|
4
|
+
import '../types-E00UyX0q.js';
|
|
5
5
|
import '@adview/core/typings';
|
|
6
6
|
|
|
7
7
|
type AdViewUnitProps = typeof window extends undefined ? AdViewUnitServerProps : AdViewUnitClientProps;
|