@surfside/ads-react 0.1.4 → 0.1.6
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/lib/cjs/components/SurfsideBanner.js +2 -27
- package/lib/cjs/components/SurfsideBanner.js.map +1 -1
- package/lib/cjs/components/SurfsideBannerRenderer.js +45 -0
- package/lib/cjs/components/SurfsideBannerRenderer.js.map +1 -0
- package/lib/cjs/components/SurfsideBannerVideoRenderer.js +25 -0
- package/lib/cjs/components/SurfsideBannerVideoRenderer.js.map +1 -0
- package/lib/cjs/components/SurfsideVideo.js +1 -1
- package/lib/cjs/components/SurfsideVideoRenderer.js +42 -0
- package/lib/cjs/components/SurfsideVideoRenderer.js.map +1 -0
- package/lib/cjs/components/index.js +20 -20
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/hooks/index.js +17 -19
- package/lib/cjs/hooks/index.js.map +1 -1
- package/lib/cjs/hooks/useSurfsideProducts.js +14 -5
- package/lib/cjs/hooks/useSurfsideProducts.js.map +1 -1
- package/lib/cjs/index.js +53 -17
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/provider/SurfsideContextProvider.js +2 -1
- package/lib/cjs/provider/SurfsideContextProvider.js.map +1 -1
- package/lib/cjs/provider/index.js +6 -16
- package/lib/cjs/provider/index.js.map +1 -1
- package/lib/cjs/utils/index.js +9 -15
- package/lib/cjs/utils/index.js.map +1 -1
- package/lib/esm/components/SurfsideBanner.js +3 -28
- package/lib/esm/components/SurfsideBanner.js.map +1 -1
- package/lib/esm/components/SurfsideBannerRenderer.js +41 -0
- package/lib/esm/components/SurfsideBannerRenderer.js.map +1 -0
- package/lib/esm/components/SurfsideBannerVideoRenderer.js +21 -0
- package/lib/esm/components/SurfsideBannerVideoRenderer.js.map +1 -0
- package/lib/esm/components/SurfsideVideo.js +1 -1
- package/lib/esm/components/SurfsideVideoRenderer.js +38 -0
- package/lib/esm/components/SurfsideVideoRenderer.js.map +1 -0
- package/lib/esm/components/index.js +8 -6
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/hooks/index.js +4 -5
- package/lib/esm/hooks/index.js.map +1 -1
- package/lib/esm/hooks/useSurfsideProducts.js +14 -5
- package/lib/esm/hooks/useSurfsideProducts.js.map +1 -1
- package/lib/esm/index.js +18 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/provider/SurfsideContextProvider.js +2 -1
- package/lib/esm/provider/SurfsideContextProvider.js.map +1 -1
- package/lib/esm/provider/index.js +1 -2
- package/lib/esm/provider/index.js.map +1 -1
- package/lib/esm/utils/index.js +1 -1
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/types/components/SurfsideBannerRenderer.d.ts +40 -0
- package/lib/types/components/SurfsideBannerVideoRenderer.d.ts +49 -0
- package/lib/types/components/SurfsideVideoRenderer.d.ts +38 -0
- package/lib/types/components/index.d.ts +8 -5
- package/lib/types/hooks/index.d.ts +4 -4
- package/lib/types/hooks/useSurfsideProducts.d.ts +6 -2
- package/lib/types/index.d.ts +14 -3
- package/lib/types/provider/SurfsideContextProvider.d.ts +19 -0
- package/lib/types/provider/index.d.ts +1 -1
- package/lib/types/utils/index.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
4
|
import { useSurfsideBanner } from '../hooks';
|
|
5
5
|
import { useSurfsideContext } from '../provider';
|
|
6
6
|
import { Ctx } from '@surfside/ads-core';
|
|
7
|
-
import {
|
|
7
|
+
import { SurfsideBannerRenderer } from '.';
|
|
8
8
|
/**
|
|
9
9
|
* SurfsideBanner renders a banner ad using the `useSurfsideBanner` hook. It automatically
|
|
10
10
|
* manages banner fetching, win tracking, and optional UI fallback states.
|
|
@@ -21,7 +21,6 @@ export const SurfsideBanner = ({ zoneId, size, enabled = true, renderLoading, re
|
|
|
21
21
|
size,
|
|
22
22
|
enabled,
|
|
23
23
|
});
|
|
24
|
-
const [renderedBanner, setRenderedBanner] = useState();
|
|
25
24
|
const { logger } = useSurfsideContext();
|
|
26
25
|
const log = Ctx(logger)?.with('SurfsideBanner');
|
|
27
26
|
// call user callback
|
|
@@ -31,13 +30,6 @@ export const SurfsideBanner = ({ zoneId, size, enabled = true, renderLoading, re
|
|
|
31
30
|
onWin?.(banner.id);
|
|
32
31
|
}
|
|
33
32
|
}, [banner]);
|
|
34
|
-
// Call render callback
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (banner !== undefined) {
|
|
37
|
-
log?.info('SurfsideBanner: banner rendered', banner.id);
|
|
38
|
-
onRender?.(banner.id);
|
|
39
|
-
}
|
|
40
|
-
}, [banner]);
|
|
41
33
|
// Handle error callback
|
|
42
34
|
useEffect(() => {
|
|
43
35
|
if (error !== undefined) {
|
|
@@ -45,23 +37,6 @@ export const SurfsideBanner = ({ zoneId, size, enabled = true, renderLoading, re
|
|
|
45
37
|
onError?.(error);
|
|
46
38
|
}
|
|
47
39
|
}, [error]);
|
|
48
|
-
|
|
49
|
-
if (banner != undefined) {
|
|
50
|
-
const rendered = RenderBanner(logger, banner);
|
|
51
|
-
if (rendered.ok) {
|
|
52
|
-
setRenderedBanner(rendered.value);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
setRenderedBanner(undefined);
|
|
57
|
-
}
|
|
58
|
-
}, [banner]);
|
|
59
|
-
return (_jsxs("div", { children: [loading && renderLoading?.(), error !== undefined && renderError?.(), banner !== undefined &&
|
|
60
|
-
renderedBanner !== undefined && (_jsx("div", { ref: (ref) => {
|
|
61
|
-
if (ref != undefined) {
|
|
62
|
-
ref.innerHTML = '';
|
|
63
|
-
ref.appendChild(renderedBanner);
|
|
64
|
-
}
|
|
65
|
-
} }))] }));
|
|
40
|
+
return (_jsxs("div", { children: [loading && renderLoading?.(), error !== undefined && renderError?.(), banner !== undefined && (_jsx(SurfsideBannerRenderer, { banner: banner, onRender: onRender }))] }));
|
|
66
41
|
};
|
|
67
42
|
//# sourceMappingURL=SurfsideBanner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurfsideBanner.js","sourceRoot":"src/","sources":["components/SurfsideBanner.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"SurfsideBanner.js","sourceRoot":"src/","sources":["components/SurfsideBanner.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAkB,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,GAAG,CAAC;AA+D3C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAmC,CAAC,EAC3D,MAAM,EACN,IAAI,EACJ,OAAO,GAAG,IAAI,EACd,aAAa,EACb,WAAW,EACX,QAAQ,EACR,KAAK,EACL,OAAO,GACV,EAAE,EAAE;IACD,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,iBAAiB,CAAC;QACjD,MAAM;QACN,IAAI;QACJ,OAAO;KACV,CAAC,CAAC;IACH,MAAM,EAAE,MAAM,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACxC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAEhD,qBAAqB;IACrB,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,GAAG,EAAE,IAAI,CAAC,6BAA6B,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;YACpD,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACvB,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,wBAAwB;IACxB,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,GAAG,EAAE,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;YAC3C,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACH,0BACK,OAAO,IAAI,aAAa,EAAE,EAAE,EAE5B,KAAK,KAAK,SAAS,IAAI,WAAW,EAAE,EAAE,EAEtC,MAAM,KAAK,SAAS,IAAI,CACrB,KAAC,sBAAsB,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAI,CACjE,IACC,CACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { Ctx } from '@surfside/ads-core-client';
|
|
5
|
+
import { useSurfsideContext } from '../provider';
|
|
6
|
+
/**
|
|
7
|
+
* SurfsideBannerRenderer renders a pre-fetched IBanner using internal RenderBanner logic.
|
|
8
|
+
* It handles win tracking, DOM injection, and lifecycle callbacks, but does not perform any banner fetching.
|
|
9
|
+
*
|
|
10
|
+
* Use this component if you already have an IBanner and want to render it directly.
|
|
11
|
+
*
|
|
12
|
+
* @param {ISurfsideBannerRendererProps} props Props used to configure the rendering behavior
|
|
13
|
+
* @returns A responsive ad container rendering the given banner
|
|
14
|
+
*/
|
|
15
|
+
export const SurfsideBannerRenderer = ({ banner, onRender, onError, }) => {
|
|
16
|
+
// const [renderedBanner, setRenderedBanner] = useState<HTMLElement | undefined>();
|
|
17
|
+
const { logger, renderBanner, error: apiError } = useSurfsideContext();
|
|
18
|
+
const log = Ctx(logger)?.with('SurfsideBanner');
|
|
19
|
+
const ref = useRef(null);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const container = ref.current;
|
|
22
|
+
if (container === null || renderBanner === undefined) {
|
|
23
|
+
if (apiError !== undefined) {
|
|
24
|
+
onError?.(apiError);
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const result = renderBanner(banner);
|
|
29
|
+
if (!result.ok) {
|
|
30
|
+
log?.error('Banner render error', result.error);
|
|
31
|
+
onError?.(result);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
container.innerHTML = '';
|
|
35
|
+
container.appendChild(result.value);
|
|
36
|
+
log?.info('Banner rendered');
|
|
37
|
+
onRender?.(banner.id);
|
|
38
|
+
}, [banner, renderBanner, apiError]);
|
|
39
|
+
return _jsx("div", { ref: ref });
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=SurfsideBannerRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SurfsideBannerRenderer.js","sourceRoot":"src/","sources":["components/SurfsideBannerRenderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,GAAG,EAAkB,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAgCjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA2C,CAAC,EAC3E,MAAM,EACN,QAAQ,EACR,OAAO,GACV,EAAE,EAAE;IACD,mFAAmF;IACnF,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACvE,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;QAC9B,IAAI,SAAS,KAAK,IAAI,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YACnD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;YACxB,CAAC;YACD,OAAO;QACX,CAAC;QAED,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACb,GAAG,EAAE,KAAK,CAAC,qBAAqB,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YAChD,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;YAClB,OAAO;QACX,CAAC;QAED,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;QACzB,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpC,GAAG,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC7B,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC;IAErC,OAAO,cAAK,GAAG,EAAE,GAAG,GAAI,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { SurfsideBannerRenderer } from './SurfsideBannerRenderer';
|
|
4
|
+
import { SurfsideVideoRenderer } from './SurfsideVideoRenderer';
|
|
5
|
+
/**
|
|
6
|
+
* SurfsideBannerVideoRenderer renders a banner or video ad based on which prop is provided.
|
|
7
|
+
* It assumes the creative has already been fetched and is ready for rendering.
|
|
8
|
+
*
|
|
9
|
+
* @param props A banner or video object with optional lifecycle callbacks
|
|
10
|
+
* @returns A rendered ad element or null if input is invalid
|
|
11
|
+
*/
|
|
12
|
+
export const SurfsideBannerVideoRenderer = ({ banner, video, onRender, onError }) => {
|
|
13
|
+
if (banner !== undefined) {
|
|
14
|
+
return (_jsx(SurfsideBannerRenderer, { banner: banner, onRender: onRender, onError: onError }));
|
|
15
|
+
}
|
|
16
|
+
if (video !== undefined) {
|
|
17
|
+
return (_jsx(SurfsideVideoRenderer, { video: video, onRender: onRender, onError: onError }));
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=SurfsideBannerVideoRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SurfsideBannerVideoRenderer.js","sourceRoot":"src/","sources":["components/SurfsideBannerVideoRenderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAKb,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAuChE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAEpC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;IACzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CACH,KAAC,sBAAsB,IACnB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,GAClB,CACL,CAAC;IACN,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,CACH,KAAC,qBAAqB,IAClB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,GAClB,CACL,CAAC;IACN,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -29,7 +29,7 @@ export const SurfsideVideo = ({ zoneId, size, minDuration = 0, maxDuration, mime
|
|
|
29
29
|
log?.info('Not ready yet');
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const request = (requestBuilder ?? startRequest(
|
|
32
|
+
const request = (requestBuilder ?? startRequest(zoneId))
|
|
33
33
|
.withVideo(size[0], size[1], minDuration, maxDuration, mimes)
|
|
34
34
|
.build();
|
|
35
35
|
log?.debug('request', request);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { Ctx } from '@surfside/ads-core-client';
|
|
5
|
+
import { useSurfsideContext } from '../provider/SurfsideContextProvider';
|
|
6
|
+
/**
|
|
7
|
+
* SurfsideVideoRenderer renders a pre-fetched video creative into the DOM.
|
|
8
|
+
* This component assumes the video has already been processed and only handles injection.
|
|
9
|
+
*
|
|
10
|
+
* @param props `ISurfsideVideoRendererProps`
|
|
11
|
+
* @returns The video container element
|
|
12
|
+
*/
|
|
13
|
+
export const SurfsideVideoRenderer = ({ video, onRender, onError, }) => {
|
|
14
|
+
const { logger, renderVideo, error: apiError } = useSurfsideContext();
|
|
15
|
+
const log = Ctx(logger)?.with('SurfsideVideoRenderer');
|
|
16
|
+
const ref = useRef(null);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const container = ref.current;
|
|
19
|
+
if (container === null || renderVideo === undefined) {
|
|
20
|
+
if (apiError !== undefined) {
|
|
21
|
+
onError?.(apiError);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const result = renderVideo(video);
|
|
26
|
+
if (!result.ok) {
|
|
27
|
+
log?.error('Video render error', result);
|
|
28
|
+
onError?.(result);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
container.innerHTML = '';
|
|
32
|
+
container.appendChild(result.value);
|
|
33
|
+
log?.info('Video rendered');
|
|
34
|
+
onRender?.(video.id);
|
|
35
|
+
}, [video, renderVideo, apiError]);
|
|
36
|
+
return _jsx("div", { ref: ref });
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=SurfsideVideoRenderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SurfsideVideoRenderer.js","sourceRoot":"src/","sources":["components/SurfsideVideoRenderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,GAAG,EAAkB,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAiCzE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0C,CAAC,EACzE,KAAK,EACL,QAAQ,EACR,OAAO,GACV,EAAE,EAAE;IACD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,kBAAkB,EAAE,CAAC;IACtE,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC;QAC9B,IAAI,SAAS,KAAK,IAAI,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAClD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACzB,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;YACxB,CAAC;YACD,OAAO;QACX,CAAC;QAED,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACb,GAAG,EAAE,KAAK,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;YACzC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;YAClB,OAAO;QACX,CAAC;QAED,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;QACzB,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpC,GAAG,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC5B,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEnC,OAAO,cAAK,GAAG,EAAE,GAAG,GAAI,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export { SurfsideBanner } from './SurfsideBanner';
|
|
2
|
+
export { SurfsideBannerRenderer } from './SurfsideBannerRenderer';
|
|
3
|
+
export { SurfsideCarousel } from './SurfsideCarousel';
|
|
4
|
+
export { SurfsideDynamicZone, DynamicZoneUnmountedError } from './SurfsideDynamicZone';
|
|
5
|
+
export { SurfsideProductCard, NoProductsReturnedError, ProductCardUnmountedError } from './SurfsideProduct';
|
|
6
|
+
export { SurfsideVideo } from './SurfsideVideo';
|
|
7
|
+
export { SurfsideVideoRenderer } from './SurfsideVideoRenderer';
|
|
8
|
+
export { SurfsideBannerVideoRenderer } from './SurfsideBannerVideoRenderer';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["components/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,cAAc,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAEH,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAMH,gBAAgB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAEH,mBAAmB,EACnB,yBAAyB,EAC5B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAKH,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,EAC5B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAEH,aAAa,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEH,qBAAqB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGH,2BAA2B,EAC9B,MAAM,+BAA+B,CAAC"}
|
package/lib/esm/hooks/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export * from './useSurfsideVideo';
|
|
1
|
+
export { useSurfsideBanner, useSurfsideBannerResponse, InvalidBannerStateError, } from './useSurfsideBanner';
|
|
2
|
+
export { useSurfsideDynamicZone, InvalidDynamicZoneState, } from './useSurfsideDynamicZone';
|
|
3
|
+
export { useSurfsideProducts, useSurfsideProductsResponse, InvalidStrategyError, InvalidProductsStateError, } from './useSurfsideProducts';
|
|
4
|
+
export { useSurfsideVideo, useSurfsideVideoResponse, InvalidVideoStateError, } from './useSurfsideVideo';
|
|
6
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["hooks/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EASH,iBAAiB,EAEjB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAmBH,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAmBH,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,yBAAyB,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAUH,gBAAgB,EAEhB,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,oBAAoB,CAAC"}
|
|
@@ -265,9 +265,13 @@ export function useSurfsideProductsResponse(props) {
|
|
|
265
265
|
.then(([data, finished]) => setSuccessState([...products, ...data], !finished));
|
|
266
266
|
}
|
|
267
267
|
}, [dataSource, props?.maxProducts, props?.pageSize, props, products]);
|
|
268
|
-
const mappedProducts =
|
|
269
|
-
|
|
270
|
-
|
|
268
|
+
const mappedProducts = useMemo(() => {
|
|
269
|
+
// safe assumption that product feed and recommender returns products with ids
|
|
270
|
+
const validProducts = products.filter((p) => typeof p.product.id === 'string' && p.product.id.trim() !== '');
|
|
271
|
+
return props?.withProductInfo === true
|
|
272
|
+
? validProducts.map(mapProductToData)
|
|
273
|
+
: validProducts.map(mapProductToIds);
|
|
274
|
+
}, [props?.withProductInfo, products]);
|
|
271
275
|
log?.debug('Final State', loading, productsError, products, apiError);
|
|
272
276
|
if (!loading && productsError === undefined) { /* Handle Success State */
|
|
273
277
|
return {
|
|
@@ -329,12 +333,17 @@ export function useSurfsideProductsResponse(props) {
|
|
|
329
333
|
}
|
|
330
334
|
;
|
|
331
335
|
const mapProductToData = (product) => ({
|
|
332
|
-
data:
|
|
336
|
+
data: {
|
|
337
|
+
...product.product,
|
|
338
|
+
id: product.product.id !== undefined ? product.product.id : ''
|
|
339
|
+
},
|
|
333
340
|
type: product.sponsored ? 'sponsored' : 'recommended',
|
|
334
341
|
productCardResponse: product,
|
|
335
342
|
});
|
|
336
343
|
const mapProductToIds = (product) => ({
|
|
337
|
-
|
|
344
|
+
data: {
|
|
345
|
+
id: product.product.id
|
|
346
|
+
},
|
|
338
347
|
type: product.sponsored ? 'sponsored' : 'recommended',
|
|
339
348
|
productCardResponse: product
|
|
340
349
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSurfsideProducts.js","sourceRoot":"src/","sources":["hooks/useSurfsideProducts.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAOH,aAAa,EACb,GAAG,EACH,GAAG,EACH,eAAe,EACf,KAAK,EACR,MAAM,2BAA2B,CAAC;AAmClC,CAAC;AAkED,CAAC;AAgBD,CAAC;
|
|
1
|
+
{"version":3,"file":"useSurfsideProducts.js","sourceRoot":"src/","sources":["hooks/useSurfsideProducts.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAOH,aAAa,EACb,GAAG,EACH,GAAG,EACH,eAAe,EACf,KAAK,EACR,MAAM,2BAA2B,CAAC;AAmClC,CAAC;AAkED,CAAC;AAgBD,CAAC;AAyHF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgHG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAA+B;IAC/D,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAChC;QACI,QAAQ,EAAE,SAAS;QACnB,GAAG,KAAK;KACX,CACJ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,aAAa,GAAG,2BAA2B,CAAC,aAAa,CAAC,CAAC;IAEjE,SAAS,CAAC,GAAG,EAAE;QACX,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC;IAC9B,CAAC,EAAE,CAAC,aAAa,CAAC,OAAO,C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AAA,CAAC"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
// Provider
|
|
2
|
+
export { useSurfsideContext, SurfsideProvider, InvalidStateError, NotInProviderError, } from './provider';
|
|
3
|
+
// Analytics
|
|
4
|
+
export { trackProductClick, trackBannerClick, trackProductImpressions, trackBannerImpression, trackVideoImpression, trackVideoEvent, trackZoneEvent, } from './utils';
|
|
5
|
+
// Components
|
|
6
|
+
export { SurfsideBanner } from './components';
|
|
7
|
+
export { SurfsideBannerRenderer, } from './components';
|
|
8
|
+
export { SurfsideCarousel, } from './components';
|
|
9
|
+
export { SurfsideDynamicZone, DynamicZoneUnmountedError, } from './components';
|
|
10
|
+
export { SurfsideProductCard, NoProductsReturnedError, ProductCardUnmountedError, } from './components';
|
|
11
|
+
export { SurfsideVideo } from './components';
|
|
12
|
+
export { SurfsideVideoRenderer, } from './components';
|
|
13
|
+
export { SurfsideBannerVideoRenderer, } from './components';
|
|
14
|
+
// Hooks
|
|
15
|
+
export { useSurfsideBanner, useSurfsideBannerResponse, InvalidBannerStateError, } from './hooks';
|
|
16
|
+
export { useSurfsideDynamicZone, InvalidDynamicZoneState, } from './hooks';
|
|
17
|
+
export { useSurfsideProducts, useSurfsideProductsResponse, InvalidStrategyError, InvalidProductsStateError, } from './hooks';
|
|
18
|
+
export { useSurfsideVideo, useSurfsideVideoResponse, InvalidVideoStateError, } from './hooks';
|
|
4
19
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EAQH,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACrB,MAAO,YAAY,CAAC;AAErB,YAAY;AACZ,OAAO,EAGH,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,cAAc,GACjB,MAAM,SAAS,CAAC;AAEjB,aAAa;AACb,OAAO,EAEH,cAAc,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,sBAAsB,GACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAMH,gBAAgB,GACnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,mBAAmB,EACnB,yBAAyB,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAKH,mBAAmB,EACnB,uBAAuB,EACvB,yBAAyB,GAC5B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,aAAa,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEH,qBAAqB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGH,2BAA2B,GAC9B,MAAM,cAAc,CAAC;AAEtB,QAAQ;AACR,OAAO,EASH,iBAAiB,EAEjB,yBAAyB,EACzB,uBAAuB,GAC1B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAmBH,sBAAsB,EACtB,uBAAuB,GAC1B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAmBH,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,yBAAyB,GAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAUH,gBAAgB,EAEhB,wBAAwB,EACxB,sBAAsB,GACzB,MAAM,SAAS,CAAC"}
|
|
@@ -44,6 +44,7 @@ export const SurfsideProvider = ({ accountId, channelId, siteId, locationId: cfg
|
|
|
44
44
|
const [userId, setUserId] = useState(cfgUserId);
|
|
45
45
|
const debug = config?.debug ?? searchHasString('surf_debug=true');
|
|
46
46
|
const mock = config?.mock ?? searchHasString('surf_mock=true');
|
|
47
|
+
const { mockRecommendedProducts, mockSponsoredProducts } = config?.customMockData ?? {};
|
|
47
48
|
const logger = useMemo(() => Ctx(userLogger ?? (debug ? InitLogger() : undefined)), [userLogger]);
|
|
48
49
|
const log = Ctx(logger)?.with('SurfsideProvider');
|
|
49
50
|
log?.info('Initializing Surfside provider');
|
|
@@ -56,7 +57,7 @@ export const SurfsideProvider = ({ accountId, channelId, siteId, locationId: cfg
|
|
|
56
57
|
}
|
|
57
58
|
const initializerPromise = !mock
|
|
58
59
|
? InitSurfAdsWeb(accountId, siteId, channelId, locationId, userId, logger)
|
|
59
|
-
: InitSurfAdsWebInternal(InitSurfAdsCoreMock(accountId, channelId, siteId, locationId, userId, InitLogger()));
|
|
60
|
+
: InitSurfAdsWebInternal(InitSurfAdsCoreMock(accountId, channelId, siteId, locationId, userId, InitLogger(), mockSponsoredProducts, mockRecommendedProducts, config?.simulateNoResponse, config?.simulateTimeout));
|
|
60
61
|
initializerPromise.then(web => {
|
|
61
62
|
if (cancel) {
|
|
62
63
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurfsideContextProvider.js","sourceRoot":"src/","sources":["provider/SurfsideContextProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAGV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,SAAS,EACT,OAAO,GACV,MAAM,OAAO,CAAC;AAEf,OAAO,EAIH,UAAU,EACV,GAAG,EACH,KAAK,EACL,GAAG,EACH,eAAe,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAwB,cAAc,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"SurfsideContextProvider.js","sourceRoot":"src/","sources":["provider/SurfsideContextProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAc,EAGV,aAAa,EACb,UAAU,EACV,QAAQ,EACR,SAAS,EACT,OAAO,GACV,MAAM,OAAO,CAAC;AAEf,OAAO,EAIH,U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O,iBAAkB,SAAQ,KAAK;IACxC;QACI,KAAK,CAAC,4EAA4E,CAAC,CAAC;IACxF,CAAC;CACJ;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACzC;QACI,KAAK,CAAC,wGAAwG;YAC1G,gBAAgB,CACnB,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["provider/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["provider/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,2BAA2B,CAAC"}
|
package/lib/esm/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { trackProductClick, trackBannerClick, trackProductImpressions, trackBannerImpression, trackVideoImpression, trackVideoEvent, trackZoneEvent, } from './Analytics';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,cAAc,GACjB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ErrResult } from '@surfside/ads-core-client';
|
|
3
|
+
import { type IBanner } from '..';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the `SurfsideBannerRenderer` component. This component handles rendering of an already-fetched IBanner,
|
|
6
|
+
* and manages rendering, logging, and lifecycle callbacks without performing any fetching logic.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <SurfsideBannerRenderer
|
|
11
|
+
* banner={myBanner}
|
|
12
|
+
* onRender={(id) => console.log(`Rendered banner: ${id}`)}
|
|
13
|
+
* onWin={(id) => console.log(`Win tracked: ${id}`)}
|
|
14
|
+
* />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface ISurfsideBannerRendererProps {
|
|
18
|
+
/**
|
|
19
|
+
* A fully-formed IBanner to be rendered
|
|
20
|
+
*/
|
|
21
|
+
banner: IBanner;
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked when a banner is successfully rendered
|
|
24
|
+
*/
|
|
25
|
+
onRender?: (bannerId: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Callback invoked when an error occurs during rendering
|
|
28
|
+
*/
|
|
29
|
+
onError?: (error: ErrResult) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* SurfsideBannerRenderer renders a pre-fetched IBanner using internal RenderBanner logic.
|
|
33
|
+
* It handles win tracking, DOM injection, and lifecycle callbacks, but does not perform any banner fetching.
|
|
34
|
+
*
|
|
35
|
+
* Use this component if you already have an IBanner and want to render it directly.
|
|
36
|
+
*
|
|
37
|
+
* @param {ISurfsideBannerRendererProps} props Props used to configure the rendering behavior
|
|
38
|
+
* @returns A responsive ad container rendering the given banner
|
|
39
|
+
*/
|
|
40
|
+
export declare const SurfsideBannerRenderer: React.FC<ISurfsideBannerRendererProps>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IBanner, IVideo } from '..';
|
|
3
|
+
import type { ErrResult } from '@surfside/ads-core-client';
|
|
4
|
+
/**
|
|
5
|
+
* Shared optional props for video/banner renderer components.
|
|
6
|
+
*/
|
|
7
|
+
export interface ISurfsideBannerVideoRendererBase {
|
|
8
|
+
/**
|
|
9
|
+
* Callback invoked after a creative is successfully rendered
|
|
10
|
+
*/
|
|
11
|
+
onRender?: (id: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Callback invoked when an error occurs during rendering
|
|
14
|
+
*/
|
|
15
|
+
onError?: (err: ErrResult) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Props for rendering either a banner or video creative.
|
|
19
|
+
* You must pass exactly one of `banner` or `video`.
|
|
20
|
+
*
|
|
21
|
+
* @example Render a banner:
|
|
22
|
+
* ```tsx
|
|
23
|
+
* <SurfsideBannerVideoRenderer
|
|
24
|
+
* banner={myBanner}
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example Render a video:
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <SurfsideBannerVideoRenderer
|
|
31
|
+
* video={myVideo}
|
|
32
|
+
* />
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export type ISurfsideBannerVideoRendererProps = ({
|
|
36
|
+
banner: IBanner;
|
|
37
|
+
video?: undefined;
|
|
38
|
+
} & ISurfsideBannerVideoRendererBase) | ({
|
|
39
|
+
video: IVideo;
|
|
40
|
+
banner?: undefined;
|
|
41
|
+
} & ISurfsideBannerVideoRendererBase);
|
|
42
|
+
/**
|
|
43
|
+
* SurfsideBannerVideoRenderer renders a banner or video ad based on which prop is provided.
|
|
44
|
+
* It assumes the creative has already been fetched and is ready for rendering.
|
|
45
|
+
*
|
|
46
|
+
* @param props A banner or video object with optional lifecycle callbacks
|
|
47
|
+
* @returns A rendered ad element or null if input is invalid
|
|
48
|
+
*/
|
|
49
|
+
export declare const SurfsideBannerVideoRenderer: React.FC<ISurfsideBannerVideoRendererProps>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ErrResult } from '@surfside/ads-core-client';
|
|
3
|
+
import { type IVideo } from '..';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the `SurfsideVideoRenderer` component. This component handles rendering of
|
|
6
|
+
* an already-fetched `IVideo` object into a container element.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <SurfsideVideoRenderer
|
|
11
|
+
* video={video}
|
|
12
|
+
* onRender={(id) => console.log(`Rendered video: ${id}`)}
|
|
13
|
+
* onError={(err) => console.error(err)}
|
|
14
|
+
* />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface ISurfsideVideoRendererProps {
|
|
18
|
+
/**
|
|
19
|
+
* A fully-formed `IVideo` object to render
|
|
20
|
+
*/
|
|
21
|
+
video: IVideo;
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked after successful render
|
|
24
|
+
*/
|
|
25
|
+
onRender?: (videoId: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Callback invoked when an error occurs during rendering
|
|
28
|
+
*/
|
|
29
|
+
onError?: (error: ErrResult) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* SurfsideVideoRenderer renders a pre-fetched video creative into the DOM.
|
|
33
|
+
* This component assumes the video has already been processed and only handles injection.
|
|
34
|
+
*
|
|
35
|
+
* @param props `ISurfsideVideoRendererProps`
|
|
36
|
+
* @returns The video container element
|
|
37
|
+
*/
|
|
38
|
+
export declare const SurfsideVideoRenderer: React.FC<ISurfsideVideoRendererProps>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
1
|
+
export { ISurfsideBannerProps, SurfsideBanner } from './SurfsideBanner';
|
|
2
|
+
export { ISurfsideBannerRendererProps, SurfsideBannerRenderer } from './SurfsideBannerRenderer';
|
|
3
|
+
export { ISurfsideCarouselRenderProps, ISurfsideCarouselPropsBase, ISurfsideCarouselPropsRecommended, ISurfsideCarouselPropsSponsored, SurfsideCarouselProps, SurfsideCarousel } from './SurfsideCarousel';
|
|
4
|
+
export { ISurfsideDynamicZoneComponentProps, SurfsideDynamicZone, DynamicZoneUnmountedError } from './SurfsideDynamicZone';
|
|
5
|
+
export { ISurfsideProductCardPropsBase, ISurfsideSponsoredProductCard, ISurfsideRecommendedProductCard, SurfsideProductCardProps, SurfsideProductCard, NoProductsReturnedError, ProductCardUnmountedError } from './SurfsideProduct';
|
|
6
|
+
export { ISurfsideVideoProps, SurfsideVideo } from './SurfsideVideo';
|
|
7
|
+
export { ISurfsideVideoRendererProps, SurfsideVideoRenderer } from './SurfsideVideoRenderer';
|
|
8
|
+
export { ISurfsideBannerVideoRendererBase, ISurfsideBannerVideoRendererProps, SurfsideBannerVideoRenderer } from './SurfsideBannerVideoRenderer';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
export { IBanner, IUseSurfsideBannerOptions, IBannerAnalyticsCallbacks, IUseSurfsideBannerReturn, IUseSurfsideBannerReturnSuccess, IUseSurfsideBannerReturnError, IUseSurfsideBannerReturnLoading, UseSurfsideBannerReturn, useSurfsideBanner, IUseSurfsideBannerResponseProps, useSurfsideBannerResponse, InvalidBannerStateError, } from './useSurfsideBanner';
|
|
2
|
+
export { IUseSurfsideDynamicZoneOptionsConfigProductOptions, IUseSurfsideDynamicZoneOptionsConfigWithProductInfo, IUseSurfsideDynamicZoneOptionsConfigWithProductIDs, UseSurfsideDynamicZoneOptionsConfigProductInfo, UseSurfDynamicZoneOptionsBase, UseSurfDynamicZoneOptionsWithProductInfo, UseSurfDynamicZoneOptionsWithProductIDs, UseSurfDynamicZoneOptions, IUseDynamicZoneReturnBase, IUseDynamicZoneReturnSuccess, IUseDynamicZoneReturnError, IUseDynamicZoneReturnLoading, IUseDynamicZoneReturnBanner, IUseDynamicZoneReturnVideo, IUseDynamicZoneReturnProducts, IUseDynamicZoneReturnProductsIndeterminate, UseSurfDynamicZoneReturnGeneric, UseSurfDynamicZoneReturn, useSurfsideDynamicZone, InvalidDynamicZoneState, } from './useSurfsideDynamicZone';
|
|
3
|
+
export { IUseSurfsideProductsPropsBase, UseSurfsideProductsPropsWithProductData, UseSurfsideProductsPropsWithProductIDs, UseSurfsideProductsProps, IUseSurfsideProductsResponsePropsBase, UseSurfsideProductsResponsePropsWithProductIDs, UseSurfsideProductsResponsePropsWithProductData, UseSurfsideProductsResponseProps, IProductDataBase, IProductInfoData, IProductIDData, IProductAnalyticsCallbacks, IUseSurfsideProductsReturnGeneric, IUseSurfsideProductsReturnGenericSuccess, IUseSurfsideProductsReturnGenericError, IUseSurfsideProductsReturnGenericLoading, UseSurfsideProductsReturnGeneric, UseSurfsideProductsReturn, useSurfsideProducts, useSurfsideProductsResponse, InvalidStrategyError, InvalidProductsStateError, } from './useSurfsideProducts';
|
|
4
|
+
export { IVideo, IUseSurfsideVideoOptions, ISurfsideVideoEventHandler, ISurfsideVideoAnalytics, IUseSurfsideVideoReturnBase, IUseSurfsideVideoReturnSuccess, IUseSurfsideVideoReturnError, IUseSurfsideVideoReturnLoading, UseSurfsideVideoReturn, useSurfsideVideo, UseSurfsideVideoResponseProps, useSurfsideVideoResponse, InvalidVideoStateError, } from './useSurfsideVideo';
|
|
@@ -106,11 +106,15 @@ export interface IProductDataBase {
|
|
|
106
106
|
* (defaults to true)
|
|
107
107
|
*/
|
|
108
108
|
export interface IProductInfoData extends IProductDataBase {
|
|
109
|
-
data: IProductInformation
|
|
109
|
+
data: IProductInformation & {
|
|
110
|
+
id: string;
|
|
111
|
+
};
|
|
110
112
|
}
|
|
111
113
|
/** This type is returned if useSurfsideProducts is passed { withProductInfo: false } */
|
|
112
114
|
export interface IProductIDData extends IProductDataBase {
|
|
113
|
-
|
|
115
|
+
data: {
|
|
116
|
+
id: string;
|
|
117
|
+
};
|
|
114
118
|
}
|
|
115
119
|
export interface IProductAnalyticsCallbacks {
|
|
116
120
|
trackClick: (product: IProductDataBase) => void;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { ISurfsideProviderProps, ISurfsideContextValueBase, ISurfsideContextValueInitialized, ISurfsideContextValueUninitialized, ISurfsideContextValueHasError, ISurfsideContextValueNoError, SurfsideContextValue, useSurfsideContext, SurfsideProvider, InvalidStateError, NotInProviderError, } from './provider';
|
|
2
|
+
export { IImpressionAnalytics, IClickAnalytics, trackProductClick, trackBannerClick, trackProductImpressions, trackBannerImpression, trackVideoImpression, trackVideoEvent, trackZoneEvent, } from './utils';
|
|
3
|
+
export { ISurfsideBannerProps, SurfsideBanner } from './components';
|
|
4
|
+
export { ISurfsideBannerRendererProps, SurfsideBannerRenderer, } from './components';
|
|
5
|
+
export { ISurfsideCarouselRenderProps, ISurfsideCarouselPropsBase, ISurfsideCarouselPropsRecommended, ISurfsideCarouselPropsSponsored, SurfsideCarouselProps, SurfsideCarousel, } from './components';
|
|
6
|
+
export { ISurfsideDynamicZoneComponentProps, SurfsideDynamicZone, DynamicZoneUnmountedError, } from './components';
|
|
7
|
+
export { ISurfsideProductCardPropsBase, ISurfsideSponsoredProductCard, ISurfsideRecommendedProductCard, SurfsideProductCardProps, SurfsideProductCard, NoProductsReturnedError, ProductCardUnmountedError, } from './components';
|
|
8
|
+
export { ISurfsideVideoProps, SurfsideVideo } from './components';
|
|
9
|
+
export { ISurfsideVideoRendererProps, SurfsideVideoRenderer, } from './components';
|
|
10
|
+
export { ISurfsideBannerVideoRendererBase, ISurfsideBannerVideoRendererProps, SurfsideBannerVideoRenderer, } from './components';
|
|
11
|
+
export { IBanner, IUseSurfsideBannerOptions, IBannerAnalyticsCallbacks, IUseSurfsideBannerReturn, IUseSurfsideBannerReturnSuccess, IUseSurfsideBannerReturnError, IUseSurfsideBannerReturnLoading, UseSurfsideBannerReturn, useSurfsideBanner, IUseSurfsideBannerResponseProps, useSurfsideBannerResponse, InvalidBannerStateError, } from './hooks';
|
|
12
|
+
export { IUseSurfsideDynamicZoneOptionsConfigProductOptions, IUseSurfsideDynamicZoneOptionsConfigWithProductInfo, IUseSurfsideDynamicZoneOptionsConfigWithProductIDs, UseSurfsideDynamicZoneOptionsConfigProductInfo, UseSurfDynamicZoneOptionsBase, UseSurfDynamicZoneOptionsWithProductInfo, UseSurfDynamicZoneOptionsWithProductIDs, UseSurfDynamicZoneOptions, IUseDynamicZoneReturnBase, IUseDynamicZoneReturnSuccess, IUseDynamicZoneReturnError, IUseDynamicZoneReturnLoading, IUseDynamicZoneReturnBanner, IUseDynamicZoneReturnVideo, IUseDynamicZoneReturnProducts, IUseDynamicZoneReturnProductsIndeterminate, UseSurfDynamicZoneReturnGeneric, UseSurfDynamicZoneReturn, useSurfsideDynamicZone, InvalidDynamicZoneState, } from './hooks';
|
|
13
|
+
export { IUseSurfsideProductsPropsBase, UseSurfsideProductsPropsWithProductData, UseSurfsideProductsPropsWithProductIDs, UseSurfsideProductsProps, IUseSurfsideProductsResponsePropsBase, UseSurfsideProductsResponsePropsWithProductIDs, UseSurfsideProductsResponsePropsWithProductData, UseSurfsideProductsResponseProps, IProductDataBase, IProductInfoData, IProductIDData, IProductAnalyticsCallbacks, IUseSurfsideProductsReturnGeneric, IUseSurfsideProductsReturnGenericSuccess, IUseSurfsideProductsReturnGenericError, IUseSurfsideProductsReturnGenericLoading, UseSurfsideProductsReturnGeneric, UseSurfsideProductsReturn, useSurfsideProducts, useSurfsideProductsResponse, InvalidStrategyError, InvalidProductsStateError, } from './hooks';
|
|
14
|
+
export { IVideo, IUseSurfsideVideoOptions, ISurfsideVideoEventHandler, ISurfsideVideoAnalytics, IUseSurfsideVideoReturnBase, IUseSurfsideVideoReturnSuccess, IUseSurfsideVideoReturnError, IUseSurfsideVideoReturnLoading, UseSurfsideVideoReturn, useSurfsideVideo, UseSurfsideVideoResponseProps, useSurfsideVideoResponse, InvalidVideoStateError, } from './hooks';
|