@adview/react 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AdViewUnit/AdViewUnit.cjs +273 -243
- package/dist/AdViewUnit/AdViewUnit.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.cjs +234 -198
- package/dist/AdViewUnit/AdViewUnit.client.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.client.d.cts +2 -2
- package/dist/AdViewUnit/AdViewUnit.client.d.ts +2 -2
- package/dist/AdViewUnit/AdViewUnit.client.js +226 -190
- package/dist/AdViewUnit/AdViewUnit.client.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.d.cts +1 -1
- package/dist/AdViewUnit/AdViewUnit.d.ts +1 -1
- package/dist/AdViewUnit/AdViewUnit.js +261 -231
- package/dist/AdViewUnit/AdViewUnit.js.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.cjs +229 -157
- package/dist/AdViewUnit/AdViewUnit.server.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnit.server.d.cts +3 -3
- package/dist/AdViewUnit/AdViewUnit.server.d.ts +3 -3
- package/dist/AdViewUnit/AdViewUnit.server.js +227 -155
- package/dist/AdViewUnit/AdViewUnit.server.js.map +1 -1
- package/dist/AdViewUnit/{AdViewUnitBanner.cjs → AdViewUnitBannerTemplate.cjs} +36 -14
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.cts +17 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.d.ts +17 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.js +51 -0
- package/dist/AdViewUnit/AdViewUnitBannerTemplate.js.map +1 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs +66 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.cts +16 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.d.ts +16 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js +35 -0
- package/dist/AdViewUnit/AdViewUnitDefaultTemplate.js.map +1 -0
- package/dist/AdViewUnit/{AdViewUnitNative.cjs → AdViewUnitNativeTemplate.cjs} +31 -13
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.cts +16 -0
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.d.ts +16 -0
- package/dist/AdViewUnit/{AdViewUnitNative.js → AdViewUnitNativeTemplate.js} +28 -10
- package/dist/AdViewUnit/AdViewUnitNativeTemplate.js.map +1 -0
- package/dist/AdViewUnit/{AdViewUnitProxy.cjs → AdViewUnitProxyTemplate.cjs} +33 -13
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.cjs.map +1 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.cts +17 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.d.ts +17 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.js +52 -0
- package/dist/AdViewUnit/AdViewUnitProxyTemplate.js.map +1 -0
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs +132 -0
- package/dist/AdViewUnit/AdViewUnitTemplate.cjs.map +1 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.d.cts +14 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.d.ts +14 -1
- package/dist/AdViewUnit/AdViewUnitTemplate.js +95 -0
- package/dist/AdViewUnit/AdViewUnitTemplate.js.map +1 -1
- package/dist/AdViewUnit/useAdViewController.cjs +5 -3
- package/dist/AdViewUnit/useAdViewController.cjs.map +1 -1
- package/dist/AdViewUnit/useAdViewController.d.cts +2 -2
- package/dist/AdViewUnit/useAdViewController.d.ts +2 -2
- package/dist/AdViewUnit/useAdViewController.js +5 -3
- package/dist/AdViewUnit/useAdViewController.js.map +1 -1
- package/dist/AdViewUnit/utils.cjs +33 -0
- package/dist/AdViewUnit/utils.cjs.map +1 -0
- package/dist/AdViewUnit/utils.d.cts +7 -0
- package/dist/AdViewUnit/utils.d.ts +7 -0
- package/dist/AdViewUnit/utils.js +8 -0
- package/dist/AdViewUnit/utils.js.map +1 -0
- package/dist/index.cjs +305 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +286 -193
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +302 -167
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +7 -6
- package/dist/server.d.ts +7 -6
- package/dist/server.js +288 -160
- package/dist/server.js.map +1 -1
- package/dist/{types-BaV07oMT.d.cts → types-DHjNgnRW.d.cts} +35 -43
- package/dist/{types-BaV07oMT.d.ts → types-DHjNgnRW.d.ts} +35 -43
- package/package.json +1 -1
- package/dist/AdViewUnit/AdViewUnitBanner.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitBanner.d.cts +0 -10
- package/dist/AdViewUnit/AdViewUnitBanner.d.ts +0 -10
- package/dist/AdViewUnit/AdViewUnitBanner.js +0 -29
- package/dist/AdViewUnit/AdViewUnitBanner.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitNative.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitNative.d.cts +0 -10
- package/dist/AdViewUnit/AdViewUnitNative.d.ts +0 -10
- package/dist/AdViewUnit/AdViewUnitNative.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitProxy.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitProxy.d.cts +0 -10
- package/dist/AdViewUnit/AdViewUnitProxy.d.ts +0 -10
- package/dist/AdViewUnit/AdViewUnitProxy.js +0 -32
- package/dist/AdViewUnit/AdViewUnitProxy.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.cjs +0 -203
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.d.cts +0 -12
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.d.ts +0 -12
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.js +0 -170
- package/dist/AdViewUnit/AdViewUnitTypeSwitch.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.client.cjs +0 -250
- package/dist/AdViewUnit/AdViewUnitWrapper.client.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.client.d.cts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.client.d.ts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.client.js +0 -220
- package/dist/AdViewUnit/AdViewUnitWrapper.client.js.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.server.cjs +0 -232
- package/dist/AdViewUnit/AdViewUnitWrapper.server.cjs.map +0 -1
- package/dist/AdViewUnit/AdViewUnitWrapper.server.d.cts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.server.d.ts +0 -11
- package/dist/AdViewUnit/AdViewUnitWrapper.server.js +0 -201
- package/dist/AdViewUnit/AdViewUnitWrapper.server.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/AdViewUnit/AdViewUnit.tsx","../../src/AdViewUnit/AdViewUnit.client.tsx","../../src/AdViewUnit/AdViewUnitTracking.tsx","../../src/AdViewUnit/AdViewUnitWrapper.client.tsx","../../src/AdViewUnit/AdViewUnitNative.tsx","../../src/AdViewUnit/AdViewUnitProxy.tsx","../../src/AdViewUnit/AdViewUnitBanner.tsx","../../src/AdViewUnit/AdViewUnitTypeSwitch.tsx","../../src/AdViewUnit/useAdViewController.ts","../../src/AdViewUnit/AdViewProvider.tsx","../../src/AdViewUnit/AdViewUnit.server.tsx","../../src/AdViewUnit/AdViewUnitWrapper.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 React from 'react';\nimport { AdViewUnitClientChildren, AdViewUnitPropsBase } from '../types';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport AdViewUnitWrapperClient from './AdViewUnitWrapper.client';\nimport useAdViewController from './useAdViewController';\n\nexport type AdViewUnitClientProps = AdViewUnitPropsBase & {\n children?: AdViewUnitClientChildren;\n};\n\nfunction AdViewUnitClient({\n unitId,\n format,\n children,\n onDefault = () => null,\n ...config\n}: AdViewUnitClientProps) {\n const [response, error, loadState] = useAdViewController(\n config,\n unitId,\n format,\n );\n const responseGroup = error ? null : response?.groups?.[0];\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items;\n\n if (groupItems && groupItems?.length) {\n return groupItems.map(({ tracker, ...data }) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n <AdViewUnitWrapperClient\n state={loadState}\n error={error}\n data={data}\n onDefault={onDefault}\n >\n {children}\n </AdViewUnitWrapperClient>\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n <AdViewUnitWrapperClient\n state={loadState}\n error={error}\n onDefault={onDefault}\n >\n {children}\n </AdViewUnitWrapperClient>\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitClient;\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 React from 'react';\nimport AdViewUnitTypeSwitch from './AdViewUnitTypeSwitch';\nimport {\n AdViewUnitClientChildren,\n AdViewUnitClientChildrenProps,\n AdViewUnitDefault,\n} from '../types';\n\nexport type AdViewUnitWrapperClientProps = AdViewUnitClientChildrenProps & {\n children?: AdViewUnitClientChildren;\n onDefault: AdViewUnitDefault;\n};\n\nfunction AdViewUnitWrapperClient({\n data,\n state,\n error,\n children,\n onDefault,\n}: AdViewUnitWrapperClientProps) {\n const { isLoading, isError } = state;\n const isChildrenReactNode = React.isValidElement(children);\n const isChildrenFunction = typeof children === 'function';\n\n if (isChildrenReactNode) {\n return React.cloneElement(children, {\n data,\n state,\n error,\n onDefault,\n });\n }\n\n if (isChildrenFunction) {\n return children({\n data,\n state,\n error,\n onDefault,\n });\n }\n\n if (isLoading) {\n return null;\n }\n\n if (!children && !isError && data) {\n return <AdViewUnitTypeSwitch data={data} onDefault={onDefault} />;\n }\n\n if (React.isValidElement(onDefault)) {\n return React.cloneElement(onDefault);\n }\n\n if (typeof onDefault === 'function') {\n return onDefault();\n }\n\n return null;\n}\n\nexport default AdViewUnitWrapperClient;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdViewDataClient, AdViewStyleTokensNative } from '../types';\n\ntype AdViewUnitNativeProps = AdViewDataClient & {\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitNative({\n assets,\n fields,\n url,\n classNames,\n}: AdViewUnitNativeProps) {\n const asset = getAssetByName('main', assets);\n\n if (!url) {\n return null;\n }\n\n return (\n <div className={classNames?.container}>\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n className={classNames?.imageLink}\n >\n {asset && (\n <img\n alt={fields?.title}\n title={fields?.title}\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : undefined}\n className={classNames?.image}\n style={{ objectFit: 'cover', width: '100%', height: '100%' }}\n />\n )}\n </a>\n <div className={classNames?.label}>\n {fields?.title && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"titleLink\"\n className={classNames?.titleLink}\n >\n {fields.title}\n </a>\n )}\n {fields?.description && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"descriptionLink\"\n className={classNames?.descriptionLink}\n >\n {fields.description}\n </a>\n )}\n {fields?.brandname && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"brandNameLink\"\n className={classNames?.brandNameLink}\n >\n {fields.brandname}\n </a>\n )}\n {fields?.phone && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"phoneLink\"\n className={classNames?.phoneLink}\n >\n {fields.phone}\n </a>\n )}\n {fields?.url && (\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n data-class=\"urlLink\"\n className={classNames?.urlLink}\n >\n {fields?.url}\n </a>\n )}\n </div>\n </div>\n );\n}\n\nexport default AdViewUnitNative;\n","import React from 'react';\nimport { AdViewDataClient, AdViewStyleTokensNative } from '../types';\n\ntype AdViewUnitProxyProps = AdViewDataClient & {\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitProxy({\n // assets,\n fields,\n url,\n}: AdViewUnitProxyProps) {\n const iframeSrc = fields?.url || url;\n\n if (!iframeSrc) {\n return null;\n }\n\n return (\n <iframe\n width=\"100%\"\n height=\"100%\"\n frameBorder=\"0\"\n marginWidth={0}\n marginHeight={0}\n allowTransparency={true}\n scrolling=\"no\"\n allowFullScreen={true}\n style={{ width: '100%', height: '100%' }}\n src={iframeSrc}\n ></iframe>\n );\n}\n\nexport default AdViewUnitProxy;\n","import { getAssetByName, getPrepareURL, getSrcSetCSSThumbs } from '@adview/core/utils';\nimport React from 'react';\nimport { AdViewDataClient, AdViewStyleTokensNative } from '../types';\n\ntype AdViewUnitBannerProps = AdViewDataClient & {\n classNames?: AdViewStyleTokensNative;\n};\n\nfunction AdViewUnitBanner({ assets, url }: AdViewUnitBannerProps) {\n const asset = getAssetByName('main', assets);\n\n return (\n <center>\n <a\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n href={getPrepareURL(url)}\n className=\"banner\"\n style={{ fontSize: 0 }}\n >\n {asset && (\n <img\n alt=\"main\"\n src={asset.path}\n srcSet={asset.thumbs ? getSrcSetCSSThumbs(asset.thumbs) : ''}\n />\n )}\n </a>\n </center>\n );\n}\n\nexport default AdViewUnitBanner;\n","import {\n AdViewDataClient,\n AdViewStyleTokens,\n AdViewUnitDefault,\n} from '../types';\nimport AdViewUnitNative from './AdViewUnitNative';\nimport AdViewUnitProxy from './AdViewUnitProxy';\nimport AdViewUnitBanner from './AdViewUnitBanner';\nimport React from 'react';\n\ntype AdViewUnitDefaultProps = {\n data?: AdViewDataClient;\n classNames?: AdViewStyleTokens;\n onDefault?: AdViewUnitDefault;\n};\n\nfunction AdViewUnitTypeSwitch({\n data,\n classNames,\n onDefault,\n}: AdViewUnitDefaultProps) {\n switch (data?.type) {\n case 'native':\n return <AdViewUnitNative {...data} classNames={classNames?.native} />;\n case 'proxy':\n return <AdViewUnitProxy {...data} classNames={classNames?.proxy} />;\n case 'banner':\n return <AdViewUnitBanner {...data} classNames={classNames?.banner} />;\n default:\n if (React.isValidElement(onDefault)) {\n return React.cloneElement(onDefault);\n }\n\n if (typeof onDefault === 'function') {\n return onDefault();\n }\n\n return null;\n }\n}\n\nexport default AdViewUnitTypeSwitch;\n","'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,\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, format);\n const loadAd = async () => {\n setAdLoadState('loading');\n\n try {\n console.log('Requesting ad data from:', adViewFetcher, 'with URL:', requestUrl);\n const response = await adViewFetcher(requestUrl, baseConfig.defaultAdData);\n console.log('AdViewController response:', response);\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 const loadState = {\n isInitial: adLoadState === 'initial',\n isLoading: adLoadState === 'loading',\n isComplete: adLoadState === 'complete',\n isError: adLoadState === 'error',\n };\n\n useEffect(() => {\n loadAd();\n }, []);\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 { AdViewGroupItem } from '@adview/core/typings';\nimport { adViewFetcher, getAdRequestUrl, getResolveConfig } from '@adview/core/utils';\nimport { AdViewUnitPropsBase, AdViewUnitServerChildren } from '../types';\nimport AdViewUnitTracking from './AdViewUnitTracking';\nimport AdViewUnitWrapperServer from './AdViewUnitWrapper.server';\n\nexport type AdViewUnitServerProps = AdViewUnitPropsBase & {\n children?: AdViewUnitServerChildren;\n};\n\nasync function AdViewUnitServer({\n unitId,\n format,\n children,\n onDefault = () => null,\n ...config\n}: AdViewUnitServerProps) {\n const baseConfig = getResolveConfig(config);\n const requestUrl = getAdRequestUrl(baseConfig, unitId, format);\n const response = await adViewFetcher(requestUrl);\n const isLoadingError = response instanceof Error;\n const error = isLoadingError ? response : undefined;\n const responseGroup =\n response instanceof Error ? null : response?.groups?.[0];\n const customTracker = responseGroup?.custom_tracker ?? {};\n const groupItems = responseGroup?.items;\n\n if (groupItems && groupItems.length) {\n return groupItems.map(({ tracker, ...data }: AdViewGroupItem) => {\n return (\n <AdViewUnitTracking key={data.id} {...tracker}>\n <AdViewUnitWrapperServer data={data} onDefault={onDefault}>\n {children}\n </AdViewUnitWrapperServer>\n </AdViewUnitTracking>\n );\n });\n }\n\n return (\n <AdViewUnitTracking {...customTracker}>\n <AdViewUnitWrapperServer data={error} onDefault={onDefault}>\n {children}\n </AdViewUnitWrapperServer>\n </AdViewUnitTracking>\n );\n}\n\nexport default AdViewUnitServer;\n","import React from 'react';\nimport AdViewUnitTypeSwitch from './/AdViewUnitTypeSwitch';\n\nimport {\n AdViewUnitDefault,\n AdViewUnitServerChildren,\n AdViewUnitServerChildrenProps,\n} from '../types';\n\nexport type AdViewUnitWrapperServerProps = AdViewUnitServerChildrenProps & {\n children?: AdViewUnitServerChildren;\n onDefault?: AdViewUnitDefault;\n};\n\nasync function AdViewUnitWrapperServer({\n data,\n children,\n onDefault,\n}: AdViewUnitWrapperServerProps) {\n const isChildrenReactNode = React.isValidElement(children);\n const isChildrenFunction = typeof children === 'function';\n const isLoadingError = data instanceof Error;\n\n if (isChildrenReactNode) {\n return React.cloneElement(children, { data, onDefault });\n }\n\n if (isChildrenFunction) {\n return children({ data, onDefault });\n }\n\n if (!children && !isLoadingError) {\n return <AdViewUnitTypeSwitch data={data} onDefault={onDefault} />;\n }\n\n if (React.isValidElement(onDefault)) {\n return React.cloneElement(onDefault);\n }\n\n if (typeof onDefault === 'function') {\n return onDefault();\n }\n\n return null;\n}\n\nexport default AdViewUnitWrapperServer;\n"],"mappings":";AAAA,OAAOA,aAAW;;;ACElB,OAAOC,YAAW;;;ACAlB,SAAS,kCAAkC;AAC3C,OAAO,SAAS,aAAa,WAAW,SAAS,cAAc;AAS/D,SAAS,mBAAmB;AAAA,EAC1B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CACF;AAAA,IAEJ,CAAC;AAAA,EACH;AAEA,SACE,gBAAAA,QAAA,cAAC,8BAAoB,GAAG,iBACtB,gBAAAA,QAAA,cAAC,oCAAwB,MAAM,OAAO,aACnC,QACH,CACF;AAEJ;AAEA,IAAO,4BAAQ;;;AV1Cf,SAAS,WAAW,OAAwB;AAC1C,QAAM,WAAW,OAAO,WAAW;AAEnC,MAAI,UAAU;AACZ,WAAO,gBAAAC,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AAAA,EACjE;AAEA,SAAO,gBAAAA,QAAA,cAAC,6BAAkB,GAAI,OAAiC;AACjE;AAEA,IAAO,qBAAQ;","names":["React","React","React","React","React","getAssetByName","getPrepareURL","getSrcSetCSSThumbs","React","React","React","useEffect","React","useEffect","React","React","adViewFetcher","getAdRequestUrl","getResolveConfig","React","React","getResolveConfig","getAdRequestUrl","adViewFetcher","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 (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,OAAOA,YAAW;;;ACGlB,OAAOC,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,W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OAAA,cAAC,6BAAkB,GAAI,OAAiC;AAAA,EACjE;AAEA,SAAO,gBAAAA,OAAA,cAAC,6BAAkB,GAAI,OAAiC;AACjE;AAEA,IAAO,qBAAQ;","names":["React","React","getAssetByName","getPrepareURL","getSrcSetCSSThumbs","React","getAssetByName","React","getPrepareURL","getSrcSetCSSThumbs","React","React","React","React","React","useEffect","React","useEffect","customTracker","groupItems","React","React","adViewFetcher","getAdRequestUrl","getResolveConfig","getResolveConfig","getAdRequestUrl","adViewFetcher","customTracker","groupItems","React","React"]}
|
|
@@ -35,77 +35,75 @@ __export(AdViewUnit_server_exports, {
|
|
|
35
35
|
default: () => AdViewUnit_server_default
|
|
36
36
|
});
|
|
37
37
|
module.exports = __toCommonJS(AdViewUnit_server_exports);
|
|
38
|
-
var
|
|
39
|
-
var
|
|
38
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
39
|
+
var import_utils8 = require("@adview/core/utils");
|
|
40
40
|
|
|
41
|
-
// src/AdViewUnit/
|
|
41
|
+
// src/AdViewUnit/AdViewUnitBannerTemplate.tsx
|
|
42
42
|
var import_utils = require("@adview/core/utils");
|
|
43
43
|
var import_react = __toESM(require("react"), 1);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
44
|
+
|
|
45
|
+
// src/AdViewUnit/utils.ts
|
|
46
|
+
var matchExpectedState = (expectState, state) => {
|
|
47
|
+
return !expectState || (expectState.isInitial === void 0 || expectState.isInitial === state?.isInitial) && (expectState.isLoading === void 0 || expectState.isLoading === state?.isLoading) && (expectState.isError === void 0 || expectState.isError === state?.isError) && (expectState.isComplete === void 0 || expectState.isComplete === state?.isComplete);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/AdViewUnit/AdViewUnitBannerTemplate.tsx
|
|
51
|
+
function AdViewUnitBannerTemplate({ className = "banner", style, data, state, ...props }) {
|
|
52
|
+
const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
|
|
53
|
+
isInitial: props?.isInitial,
|
|
54
|
+
isLoading: props?.isLoading,
|
|
55
|
+
isError: props?.isError,
|
|
56
|
+
isComplete: props?.isComplete
|
|
57
|
+
} : { isComplete: true };
|
|
58
|
+
if (!data || !data.assets || !data.assets.length) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
if (!matchExpectedState(expectState, state)) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const asset = (0, import_utils.getAssetByName)("main", data.assets);
|
|
65
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
66
|
+
"a",
|
|
67
|
+
{
|
|
68
|
+
target: "_blank",
|
|
69
|
+
rel: "noopener noreferrer",
|
|
70
|
+
href: (0, import_utils.getPrepareURL)(data.url),
|
|
71
|
+
className,
|
|
72
|
+
style: { fontSize: 0, ...style }
|
|
64
73
|
},
|
|
65
|
-
|
|
74
|
+
asset && /* @__PURE__ */ import_react.default.createElement(
|
|
75
|
+
"img",
|
|
76
|
+
{
|
|
77
|
+
alt: "main",
|
|
78
|
+
src: asset.path,
|
|
79
|
+
srcSet: asset.thumbs ? (0, import_utils.getSrcSetCSSThumbs)(asset.thumbs) : ""
|
|
80
|
+
}
|
|
81
|
+
)
|
|
66
82
|
);
|
|
67
|
-
const trackingObserverInstance = (0, import_react.useMemo)(() => {
|
|
68
|
-
return !isServer ? new IntersectionObserver(trackingObserverInstanceHandler) : null;
|
|
69
|
-
}, [isServer, trackingObserverInstanceHandler]);
|
|
70
|
-
const clickTrackerHandler = (0, import_react.useCallback)(() => {
|
|
71
|
-
(0, import_utils.executeImpressionsTracking)(clicks);
|
|
72
|
-
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
73
|
-
}, [clicks]);
|
|
74
|
-
(0, import_react.useEffect)(() => {
|
|
75
|
-
if (wrapperRef.current && trackingObserverInstance) {
|
|
76
|
-
executeImpressionsTrackingHandler();
|
|
77
|
-
wrapperRef.current?.addEventListener("click", clickTrackerHandler);
|
|
78
|
-
trackingObserverInstance?.observe(wrapperRef.current);
|
|
79
|
-
return () => {
|
|
80
|
-
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
81
|
-
if (wrapperRef.current)
|
|
82
|
-
trackingObserverInstance?.unobserve(wrapperRef.current);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
return () => {
|
|
86
|
-
};
|
|
87
|
-
}, [
|
|
88
|
-
trackingObserverInstance,
|
|
89
|
-
executeImpressionsTrackingHandler,
|
|
90
|
-
clickTrackerHandler
|
|
91
|
-
]);
|
|
92
|
-
return /* @__PURE__ */ import_react.default.createElement("div", { ref: wrapperRef }, children);
|
|
93
83
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
var
|
|
84
|
+
AdViewUnitBannerTemplate.defaults = {
|
|
85
|
+
type: "banner"
|
|
86
|
+
};
|
|
87
|
+
var AdViewUnitBannerTemplate_default = AdViewUnitBannerTemplate;
|
|
98
88
|
|
|
99
|
-
// src/AdViewUnit/
|
|
100
|
-
var
|
|
89
|
+
// src/AdViewUnit/AdViewUnitNativeTemplate.tsx
|
|
90
|
+
var import_utils3 = require("@adview/core/utils");
|
|
101
91
|
var import_react2 = __toESM(require("react"), 1);
|
|
102
|
-
function
|
|
103
|
-
assets
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
function AdViewUnitNativeTemplate({ classNames, data, state, ...props }) {
|
|
93
|
+
if (!data || !data.assets || !data.assets.length) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
|
|
97
|
+
isInitial: props?.isInitial,
|
|
98
|
+
isLoading: props?.isLoading,
|
|
99
|
+
isError: props?.isError,
|
|
100
|
+
isComplete: props?.isComplete
|
|
101
|
+
} : { isComplete: true };
|
|
102
|
+
if (!matchExpectedState(expectState, state)) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const { assets, url, fields } = data;
|
|
106
|
+
const asset = (0, import_utils3.getAssetByName)("main", assets);
|
|
109
107
|
if (!url) {
|
|
110
108
|
return null;
|
|
111
109
|
}
|
|
@@ -114,7 +112,7 @@ function AdViewUnitNative({
|
|
|
114
112
|
{
|
|
115
113
|
target: "_blank",
|
|
116
114
|
rel: "noopener noreferrer",
|
|
117
|
-
href: (0,
|
|
115
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
118
116
|
className: classNames?.imageLink
|
|
119
117
|
},
|
|
120
118
|
asset && /* @__PURE__ */ import_react2.default.createElement(
|
|
@@ -123,7 +121,7 @@ function AdViewUnitNative({
|
|
|
123
121
|
alt: fields?.title,
|
|
124
122
|
title: fields?.title,
|
|
125
123
|
src: asset.path,
|
|
126
|
-
srcSet: asset.thumbs ? (0,
|
|
124
|
+
srcSet: asset.thumbs ? (0, import_utils3.getSrcSetCSSThumbs)(asset.thumbs) : void 0,
|
|
127
125
|
className: classNames?.image,
|
|
128
126
|
style: { objectFit: "cover", width: "100%", height: "100%" }
|
|
129
127
|
}
|
|
@@ -133,7 +131,7 @@ function AdViewUnitNative({
|
|
|
133
131
|
{
|
|
134
132
|
target: "_blank",
|
|
135
133
|
rel: "noopener noreferrer",
|
|
136
|
-
href: (0,
|
|
134
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
137
135
|
"data-class": "titleLink",
|
|
138
136
|
className: classNames?.titleLink
|
|
139
137
|
},
|
|
@@ -143,7 +141,7 @@ function AdViewUnitNative({
|
|
|
143
141
|
{
|
|
144
142
|
target: "_blank",
|
|
145
143
|
rel: "noopener noreferrer",
|
|
146
|
-
href: (0,
|
|
144
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
147
145
|
"data-class": "descriptionLink",
|
|
148
146
|
className: classNames?.descriptionLink
|
|
149
147
|
},
|
|
@@ -153,7 +151,7 @@ function AdViewUnitNative({
|
|
|
153
151
|
{
|
|
154
152
|
target: "_blank",
|
|
155
153
|
rel: "noopener noreferrer",
|
|
156
|
-
href: (0,
|
|
154
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
157
155
|
"data-class": "brandNameLink",
|
|
158
156
|
className: classNames?.brandNameLink
|
|
159
157
|
},
|
|
@@ -163,7 +161,7 @@ function AdViewUnitNative({
|
|
|
163
161
|
{
|
|
164
162
|
target: "_blank",
|
|
165
163
|
rel: "noopener noreferrer",
|
|
166
|
-
href: (0,
|
|
164
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
167
165
|
"data-class": "phoneLink",
|
|
168
166
|
className: classNames?.phoneLink
|
|
169
167
|
},
|
|
@@ -173,22 +171,34 @@ function AdViewUnitNative({
|
|
|
173
171
|
{
|
|
174
172
|
target: "_blank",
|
|
175
173
|
rel: "noopener noreferrer",
|
|
176
|
-
href: (0,
|
|
174
|
+
href: (0, import_utils3.getPrepareURL)(url),
|
|
177
175
|
"data-class": "urlLink",
|
|
178
176
|
className: classNames?.urlLink
|
|
179
177
|
},
|
|
180
178
|
fields?.url
|
|
181
179
|
)));
|
|
182
180
|
}
|
|
183
|
-
|
|
181
|
+
AdViewUnitNativeTemplate.defaults = {
|
|
182
|
+
type: "native"
|
|
183
|
+
};
|
|
184
|
+
var AdViewUnitNativeTemplate_default = AdViewUnitNativeTemplate;
|
|
184
185
|
|
|
185
|
-
// src/AdViewUnit/
|
|
186
|
+
// src/AdViewUnit/AdViewUnitProxyTemplate.tsx
|
|
186
187
|
var import_react3 = __toESM(require("react"), 1);
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
function AdViewUnitProxyTemplate({ className, style, data, state, ...props }) {
|
|
189
|
+
if (!data) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
const expectState = props?.isInitial || props?.isLoading || props?.isError || props?.isComplete ? {
|
|
193
|
+
isInitial: props?.isInitial,
|
|
194
|
+
isLoading: props?.isLoading,
|
|
195
|
+
isError: props?.isError,
|
|
196
|
+
isComplete: props?.isComplete
|
|
197
|
+
} : { isComplete: true };
|
|
198
|
+
if (!matchExpectedState(expectState, state)) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
const { url, fields } = data;
|
|
192
202
|
const iframeSrc = fields?.url || url;
|
|
193
203
|
if (!iframeSrc) {
|
|
194
204
|
return null;
|
|
@@ -196,6 +206,7 @@ function AdViewUnitProxy({
|
|
|
196
206
|
return /* @__PURE__ */ import_react3.default.createElement(
|
|
197
207
|
"iframe",
|
|
198
208
|
{
|
|
209
|
+
className,
|
|
199
210
|
width: "100%",
|
|
200
211
|
height: "100%",
|
|
201
212
|
frameBorder: "0",
|
|
@@ -204,115 +215,176 @@ function AdViewUnitProxy({
|
|
|
204
215
|
allowTransparency: true,
|
|
205
216
|
scrolling: "no",
|
|
206
217
|
allowFullScreen: true,
|
|
207
|
-
style: { width: "100%", height: "100%" },
|
|
218
|
+
style: { width: "100%", height: "100%", border: "none", ...style },
|
|
208
219
|
src: iframeSrc
|
|
209
220
|
}
|
|
210
221
|
);
|
|
211
222
|
}
|
|
212
|
-
|
|
223
|
+
AdViewUnitProxyTemplate.defaults = {
|
|
224
|
+
type: "proxy"
|
|
225
|
+
};
|
|
226
|
+
var AdViewUnitProxyTemplate_default = AdViewUnitProxyTemplate;
|
|
213
227
|
|
|
214
|
-
// src/AdViewUnit/
|
|
215
|
-
var import_utils3 = require("@adview/core/utils");
|
|
228
|
+
// src/AdViewUnit/AdViewUnitTemplate.tsx
|
|
216
229
|
var import_react4 = __toESM(require("react"), 1);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
// src/AdViewUnit/AdViewUnitTypeSwitch.tsx
|
|
241
|
-
var import_react5 = __toESM(require("react"), 1);
|
|
242
|
-
function AdViewUnitTypeSwitch({
|
|
243
|
-
data,
|
|
244
|
-
classNames,
|
|
245
|
-
onDefault
|
|
246
|
-
}) {
|
|
247
|
-
switch (data?.type) {
|
|
248
|
-
case "native":
|
|
249
|
-
return /* @__PURE__ */ import_react5.default.createElement(AdViewUnitNative_default, { ...data, classNames: classNames?.native });
|
|
250
|
-
case "proxy":
|
|
251
|
-
return /* @__PURE__ */ import_react5.default.createElement(AdViewUnitProxy_default, { ...data, classNames: classNames?.proxy });
|
|
252
|
-
case "banner":
|
|
253
|
-
return /* @__PURE__ */ import_react5.default.createElement(AdViewUnitBanner_default, { ...data, classNames: classNames?.banner });
|
|
254
|
-
default:
|
|
255
|
-
if (import_react5.default.isValidElement(onDefault)) {
|
|
256
|
-
return import_react5.default.cloneElement(onDefault);
|
|
257
|
-
}
|
|
258
|
-
if (typeof onDefault === "function") {
|
|
259
|
-
return onDefault();
|
|
260
|
-
}
|
|
230
|
+
var templateFromListRender = (tmpls, data, wrap) => {
|
|
231
|
+
let renderedRemplates = tmpls.map((tmpl, index) => {
|
|
232
|
+
let tmp = renderTemplate(tmpl, data);
|
|
233
|
+
return !!tmp && import_react4.default.isValidElement(tmp) ? /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
|
|
234
|
+
}).filter((it) => !!it);
|
|
235
|
+
if (!renderedRemplates.length) {
|
|
236
|
+
renderedRemplates = tmpls.map((tmpl, index) => {
|
|
237
|
+
let tmp = renderTemplate(tmpl, { ...data, type: "default" });
|
|
238
|
+
return !!tmp && import_react4.default.isValidElement(tmp) ? /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, { key: index }, !!wrap ? wrap(tmp) : tmp) : null;
|
|
239
|
+
}).filter((it) => !!it);
|
|
240
|
+
}
|
|
241
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, renderedRemplates);
|
|
242
|
+
};
|
|
243
|
+
var renderTemplate = (tmpl, data) => {
|
|
244
|
+
const isFunction = typeof tmpl === "function";
|
|
245
|
+
const isReactElement = import_react4.default.isValidElement(tmpl);
|
|
246
|
+
if (isReactElement) {
|
|
247
|
+
let { type, children } = tmpl.props;
|
|
248
|
+
if (!type && typeof tmpl.type !== "string") {
|
|
249
|
+
type = tmpl.type?.defaults?.type;
|
|
250
|
+
}
|
|
251
|
+
if (data.type !== type) {
|
|
261
252
|
return null;
|
|
253
|
+
}
|
|
254
|
+
if (typeof children === "function") {
|
|
255
|
+
return children(data);
|
|
256
|
+
}
|
|
257
|
+
return import_react4.default.cloneElement(tmpl, {
|
|
258
|
+
...data,
|
|
259
|
+
children
|
|
260
|
+
});
|
|
262
261
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
// src/AdViewUnit/AdViewUnitWrapper.server.tsx
|
|
267
|
-
async function AdViewUnitWrapperServer({
|
|
268
|
-
data,
|
|
269
|
-
children,
|
|
270
|
-
onDefault
|
|
271
|
-
}) {
|
|
272
|
-
const isChildrenReactNode = import_react6.default.isValidElement(children);
|
|
273
|
-
const isChildrenFunction = typeof children === "function";
|
|
274
|
-
const isLoadingError = data instanceof Error;
|
|
275
|
-
if (isChildrenReactNode) {
|
|
276
|
-
return import_react6.default.cloneElement(children, { data, onDefault });
|
|
262
|
+
if (isFunction) {
|
|
263
|
+
return tmpl(data);
|
|
277
264
|
}
|
|
278
|
-
|
|
279
|
-
|
|
265
|
+
return null;
|
|
266
|
+
};
|
|
267
|
+
var renderTemplates = (tmpls, data, listRender) => {
|
|
268
|
+
return listRender ? listRender(tmpls) : templateFromListRender(tmpls, data);
|
|
269
|
+
};
|
|
270
|
+
var renderAnyTemplates = (tmpls, data, listRender) => {
|
|
271
|
+
if (!tmpls) {
|
|
272
|
+
return null;
|
|
280
273
|
}
|
|
281
|
-
if (
|
|
282
|
-
return
|
|
274
|
+
if (Array.isArray(tmpls)) {
|
|
275
|
+
return renderTemplates(tmpls, data, listRender);
|
|
283
276
|
}
|
|
284
|
-
if (
|
|
285
|
-
return
|
|
277
|
+
if (typeof tmpls === "function") {
|
|
278
|
+
return tmpls(data);
|
|
286
279
|
}
|
|
287
|
-
if (
|
|
288
|
-
return
|
|
280
|
+
if (import_react4.default.isValidElement(tmpls)) {
|
|
281
|
+
return templateFromListRender([tmpls], data);
|
|
289
282
|
}
|
|
290
283
|
return null;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// src/AdViewUnit/AdViewUnitTracking.tsx
|
|
287
|
+
var import_utils7 = require("@adview/core/utils");
|
|
288
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
289
|
+
function AdViewUnitTracking({
|
|
290
|
+
impressions,
|
|
291
|
+
views,
|
|
292
|
+
clicks,
|
|
293
|
+
children
|
|
294
|
+
}) {
|
|
295
|
+
const isServer = typeof window === "undefined";
|
|
296
|
+
const wrapperRef = (0, import_react5.useRef)(null);
|
|
297
|
+
const executeImpressionsTrackingHandler = (0, import_react5.useCallback)(
|
|
298
|
+
() => (0, import_utils7.executeImpressionsTracking)(impressions),
|
|
299
|
+
[impressions]
|
|
300
|
+
);
|
|
301
|
+
const trackingObserverInstanceHandler = (0, import_react5.useCallback)(
|
|
302
|
+
(entries) => {
|
|
303
|
+
entries.forEach((entry) => {
|
|
304
|
+
if (entry.isIntersecting) {
|
|
305
|
+
(0, import_utils7.executeImpressionsTracking)(views);
|
|
306
|
+
trackingObserverInstance?.unobserve(wrapperRef.current);
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
[views]
|
|
311
|
+
);
|
|
312
|
+
const trackingObserverInstance = (0, import_react5.useMemo)(() => {
|
|
313
|
+
return !isServer ? new IntersectionObserver(trackingObserverInstanceHandler) : null;
|
|
314
|
+
}, [isServer, trackingObserverInstanceHandler]);
|
|
315
|
+
const clickTrackerHandler = (0, import_react5.useCallback)(() => {
|
|
316
|
+
(0, import_utils7.executeImpressionsTracking)(clicks);
|
|
317
|
+
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
318
|
+
}, [clicks]);
|
|
319
|
+
(0, import_react5.useEffect)(() => {
|
|
320
|
+
if (wrapperRef.current && trackingObserverInstance) {
|
|
321
|
+
executeImpressionsTrackingHandler();
|
|
322
|
+
wrapperRef.current?.addEventListener("click", clickTrackerHandler);
|
|
323
|
+
trackingObserverInstance?.observe(wrapperRef.current);
|
|
324
|
+
return () => {
|
|
325
|
+
wrapperRef.current?.removeEventListener("click", clickTrackerHandler);
|
|
326
|
+
if (wrapperRef.current)
|
|
327
|
+
trackingObserverInstance?.unobserve(wrapperRef.current);
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return () => {
|
|
331
|
+
};
|
|
332
|
+
}, [
|
|
333
|
+
trackingObserverInstance,
|
|
334
|
+
executeImpressionsTrackingHandler,
|
|
335
|
+
clickTrackerHandler
|
|
336
|
+
]);
|
|
337
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { ref: wrapperRef }, children);
|
|
291
338
|
}
|
|
292
|
-
var
|
|
339
|
+
var AdViewUnitTracking_default = AdViewUnitTracking;
|
|
293
340
|
|
|
294
341
|
// src/AdViewUnit/AdViewUnit.server.tsx
|
|
295
342
|
async function AdViewUnitServer({
|
|
296
343
|
unitId,
|
|
297
344
|
format,
|
|
298
345
|
children,
|
|
299
|
-
onDefault = () => null,
|
|
300
346
|
...config
|
|
301
347
|
}) {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
348
|
+
const checkFormat = (f) => {
|
|
349
|
+
if (!format) {
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
return Array.isArray(format) ? format.includes(f) : f === format;
|
|
353
|
+
};
|
|
354
|
+
const baseConfig = (0, import_utils8.getResolveConfig)(config);
|
|
355
|
+
const requestUrl = (0, import_utils8.getAdRequestUrl)(baseConfig, unitId, format);
|
|
356
|
+
const response = await (0, import_utils8.adViewFetcher)(requestUrl);
|
|
305
357
|
const isLoadingError = response instanceof Error;
|
|
306
358
|
const error = isLoadingError ? response : void 0;
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
359
|
+
const state = {
|
|
360
|
+
isLoading: true,
|
|
361
|
+
isComplete: true,
|
|
362
|
+
isInitial: false,
|
|
363
|
+
isError: isLoadingError
|
|
364
|
+
};
|
|
365
|
+
const { responseGroup: _, customTracker, groupItems } = error ? { responseGroup: null, customTracker: {}, groupItems: [] } : (() => {
|
|
366
|
+
for (let responseGroup of response?.groups || []) {
|
|
367
|
+
const customTracker2 = responseGroup?.custom_tracker ?? {};
|
|
368
|
+
const groupItems2 = responseGroup?.items.map((it) => checkFormat(it.type) ? it : null).filter(Boolean);
|
|
369
|
+
if (groupItems2 && groupItems2.length > 0) {
|
|
370
|
+
return { responseGroup, customTracker: customTracker2, groupItems: groupItems2 };
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return { responseGroup: null, customTracker: {}, groupItems: [] };
|
|
374
|
+
})();
|
|
375
|
+
if (!children) {
|
|
376
|
+
children = [
|
|
377
|
+
/* @__PURE__ */ import_react6.default.createElement(AdViewUnitBannerTemplate_default, null),
|
|
378
|
+
/* @__PURE__ */ import_react6.default.createElement(AdViewUnitNativeTemplate_default, null),
|
|
379
|
+
/* @__PURE__ */ import_react6.default.createElement(AdViewUnitProxyTemplate_default, null)
|
|
380
|
+
];
|
|
381
|
+
}
|
|
310
382
|
if (groupItems && groupItems.length) {
|
|
311
383
|
return groupItems.map(({ tracker, ...data }) => {
|
|
312
|
-
return /* @__PURE__ */
|
|
384
|
+
return /* @__PURE__ */ import_react6.default.createElement(AdViewUnitTracking_default, { key: data.id, ...tracker }, renderAnyTemplates(children, { data, type: data.type || "default", error, state }));
|
|
313
385
|
});
|
|
314
386
|
}
|
|
315
|
-
return /* @__PURE__ */
|
|
387
|
+
return /* @__PURE__ */ import_react6.default.createElement(AdViewUnitTracking_default, { ...customTracker }, renderAnyTemplates(children, { data: null, type: "default", error, state }));
|
|
316
388
|
}
|
|
317
389
|
var AdViewUnit_server_default = AdViewUnitServer;
|
|
318
390
|
//# sourceMappingURL=AdViewUnit.server.cjs.map
|