@surfside/ads-react 0.1.14 → 0.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/lib/cjs/BuildInfo.js +5 -0
  2. package/lib/cjs/BuildInfo.js.map +1 -0
  3. package/lib/esm/BuildInfo.js +2 -0
  4. package/lib/esm/BuildInfo.js.map +1 -0
  5. package/lib/esm/components/SurfsideBanner.js +4 -3
  6. package/lib/esm/components/SurfsideBanner.js.map +1 -1
  7. package/lib/esm/components/SurfsideCarousel.js +16 -4
  8. package/lib/esm/components/SurfsideCarousel.js.map +1 -1
  9. package/lib/esm/components/SurfsideDynamicZone.js +6 -4
  10. package/lib/esm/components/SurfsideDynamicZone.js.map +1 -1
  11. package/lib/esm/components/SurfsideProduct.js +9 -6
  12. package/lib/esm/components/SurfsideProduct.js.map +1 -1
  13. package/lib/esm/components/SurfsideVideo.js +7 -4
  14. package/lib/esm/components/SurfsideVideo.js.map +1 -1
  15. package/lib/esm/hooks/useSurfsideBanner.js +7 -4
  16. package/lib/esm/hooks/useSurfsideBanner.js.map +1 -1
  17. package/lib/esm/hooks/useSurfsideDynamicZone.js +48 -9
  18. package/lib/esm/hooks/useSurfsideDynamicZone.js.map +1 -1
  19. package/lib/esm/hooks/useSurfsideProducts.js +55 -18
  20. package/lib/esm/hooks/useSurfsideProducts.js.map +1 -1
  21. package/lib/esm/hooks/useSurfsideVideo.js +8 -4
  22. package/lib/esm/hooks/useSurfsideVideo.js.map +1 -1
  23. package/lib/esm/index.js +1 -0
  24. package/lib/esm/index.js.map +1 -1
  25. package/lib/types/BuildInfo.d.ts +5 -0
  26. package/lib/types/components/SurfsideBanner.d.ts +4 -0
  27. package/lib/types/components/SurfsideCarousel.d.ts +2 -1
  28. package/lib/types/components/SurfsideDynamicZone.d.ts +2 -1
  29. package/lib/types/components/SurfsideProduct.d.ts +2 -1
  30. package/lib/types/components/SurfsideVideo.d.ts +6 -1
  31. package/lib/types/hooks/useSurfsideBanner.d.ts +5 -1
  32. package/lib/types/hooks/useSurfsideDynamicZone.d.ts +1 -0
  33. package/lib/types/hooks/useSurfsideProducts.d.ts +4 -0
  34. package/lib/types/hooks/useSurfsideVideo.d.ts +5 -1
  35. package/lib/types/index.d.ts +1 -0
  36. package/package.json +8 -4
  37. package/lib/cjs/components/SurfsideBanner.js +0 -46
  38. package/lib/cjs/components/SurfsideBanner.js.map +0 -1
  39. package/lib/cjs/components/SurfsideBannerRenderer.js +0 -45
  40. package/lib/cjs/components/SurfsideBannerRenderer.js.map +0 -1
  41. package/lib/cjs/components/SurfsideBannerVideoRenderer.js +0 -25
  42. package/lib/cjs/components/SurfsideBannerVideoRenderer.js.map +0 -1
  43. package/lib/cjs/components/SurfsideCarousel.js +0 -104
  44. package/lib/cjs/components/SurfsideCarousel.js.map +0 -1
  45. package/lib/cjs/components/SurfsideDynamicZone.js +0 -131
  46. package/lib/cjs/components/SurfsideDynamicZone.js.map +0 -1
  47. package/lib/cjs/components/SurfsideProduct.js +0 -116
  48. package/lib/cjs/components/SurfsideProduct.js.map +0 -1
  49. package/lib/cjs/components/SurfsideVideo.js +0 -82
  50. package/lib/cjs/components/SurfsideVideo.js.map +0 -1
  51. package/lib/cjs/components/SurfsideVideoRenderer.js +0 -42
  52. package/lib/cjs/components/SurfsideVideoRenderer.js.map +0 -1
  53. package/lib/cjs/components/index.js +0 -23
  54. package/lib/cjs/components/index.js.map +0 -1
  55. package/lib/cjs/hooks/index.js +0 -20
  56. package/lib/cjs/hooks/index.js.map +0 -1
  57. package/lib/cjs/hooks/useSurfsideBanner.js +0 -212
  58. package/lib/cjs/hooks/useSurfsideBanner.js.map +0 -1
  59. package/lib/cjs/hooks/useSurfsideDynamicZone.js +0 -244
  60. package/lib/cjs/hooks/useSurfsideDynamicZone.js.map +0 -1
  61. package/lib/cjs/hooks/useSurfsideProducts.js +0 -397
  62. package/lib/cjs/hooks/useSurfsideProducts.js.map +0 -1
  63. package/lib/cjs/hooks/useSurfsideVideo.js +0 -295
  64. package/lib/cjs/hooks/useSurfsideVideo.js.map +0 -1
  65. package/lib/cjs/index.js +0 -56
  66. package/lib/cjs/index.js.map +0 -1
  67. package/lib/cjs/provider/SurfsideContextProvider.js +0 -159
  68. package/lib/cjs/provider/SurfsideContextProvider.js.map +0 -1
  69. package/lib/cjs/provider/index.js +0 -9
  70. package/lib/cjs/provider/index.js.map +0 -1
  71. package/lib/cjs/utils/Analytics.js +0 -181
  72. package/lib/cjs/utils/Analytics.js.map +0 -1
  73. package/lib/cjs/utils/index.js +0 -12
  74. package/lib/cjs/utils/index.js.map +0 -1
@@ -1,104 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SurfsideCarousel = void 0;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const ads_core_1 = require("@surfside/ads-core");
7
- const provider_1 = require("../provider");
8
- const react_1 = require("react");
9
- ;
10
- const SurfsideCarousel = ({ zoneId, cardMinWidth, carouselLimits, nextType, recommender, requestBuilder, nativeRequestBuilder, enabled = true, strategy }) => {
11
- const { isReady, error: apiError, hasError, startRequest, defaultNative, buildHybridCarousel, buildSponsoredCarousel, buildRecommendedCarousel, renderCarousel, logger } = (0, provider_1.useSurfsideContext)();
12
- const log = (0, ads_core_1.Ctx)(logger)?.with('SurfsideCarousel');
13
- const [error, setError] = (0, react_1.useState)();
14
- const [renderedCarousel, setRenderedCarousel] = (0, react_1.useState)();
15
- const ref = (0, react_1.useRef)(null);
16
- (0, react_1.useEffect)(() => {
17
- let cancelled = false;
18
- if (!isReady || !enabled) {
19
- if (hasError) {
20
- setErrorState(apiError);
21
- }
22
- else {
23
- setLoadingState();
24
- }
25
- return;
26
- }
27
- const request = (requestBuilder ?? startRequest(zoneId))
28
- .withNative((nativeRequestBuilder ?? defaultNative())
29
- .withMetaBrand(80, false)
30
- .withMetaProduct(80, false)
31
- .build());
32
- const builtCarousel = (0, ads_core_1.TryDoFlat)(() => {
33
- switch (strategy) {
34
- case 'hybrid': {
35
- return buildHybridCarousel({
36
- type: recommender,
37
- }, request.build());
38
- }
39
- case 'recommended': {
40
- return buildRecommendedCarousel({
41
- type: recommender
42
- });
43
- }
44
- case 'sponsored': {
45
- return buildSponsoredCarousel(request.build());
46
- }
47
- }
48
- });
49
- if (!builtCarousel.ok) {
50
- setErrorState(builtCarousel);
51
- return;
52
- }
53
- const builtCarouselValue = builtCarousel.value;
54
- renderCarousel(builtCarouselValue, cardMinWidth, carouselLimits, nextType)
55
- .then(renderedCarouselResult => {
56
- if (cancelled) {
57
- return;
58
- }
59
- if (!renderedCarouselResult.ok) {
60
- setErrorState(renderedCarouselResult);
61
- return;
62
- }
63
- else {
64
- setSuccessState(renderedCarouselResult.value);
65
- }
66
- });
67
- return () => void (cancelled = true);
68
- }, [isReady, apiError, hasError, strategy, recommender, cardMinWidth, carouselLimits, nextType]);
69
- (0, react_1.useEffect)(() => {
70
- if (ref.current === null || renderedCarousel === undefined) {
71
- return;
72
- }
73
- ref.current.innerHTML = '';
74
- ref.current.appendChild(renderedCarousel.element);
75
- renderedCarousel.init()
76
- .then(initResult => {
77
- if (!initResult.ok) {
78
- setErrorState(initResult);
79
- if (ref.current !== null) {
80
- log?.error('First page was null');
81
- ref.current.innerHTML = '';
82
- }
83
- }
84
- });
85
- ;
86
- }, [renderedCarousel]);
87
- const setErrorState = (error) => {
88
- setError(error);
89
- setRenderedCarousel(undefined);
90
- };
91
- const setLoadingState = () => {
92
- setError(undefined);
93
- };
94
- const setSuccessState = (renderedCarousel) => {
95
- setRenderedCarousel(renderedCarousel);
96
- setError(undefined);
97
- };
98
- if (error !== undefined) {
99
- log?.error(error.error);
100
- }
101
- return (0, jsx_runtime_1.jsx)("div", { ref: ref });
102
- };
103
- exports.SurfsideCarousel = SurfsideCarousel;
104
- //# sourceMappingURL=SurfsideCarousel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SurfsideCarousel.js","sourceRoot":"src/","sources":["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AC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,gCAAK,GAAG,EAAE,GAAG,GAAQ,CAAC;AACjC,CAAC,CAAC;AA/HW,QAAA,gBAAgB,oBA+H3B"}
@@ -1,131 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.DynamicZoneUnmountedError = exports.SurfsideDynamicZone = void 0;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const ads_core_1 = require("@surfside/ads-core");
7
- const react_1 = require("react");
8
- const provider_1 = require("../provider");
9
- const SurfsideDynamicZone = ({ zoneId, carousel, enabled = true, onError }) => {
10
- const { isReady: apiIsReady, hasError: apiHasError, error: apiError, getDynamicZone, buildDynamicZoneRequest, buildDynamicResponse, renderBanner, renderVideo, renderCarousel, logger } = (0, provider_1.useSurfsideContext)();
11
- const log = (0, react_1.useMemo)(() => (0, ads_core_1.Ctx)(logger)?.with('SurfsideDynamicZone'), [logger]);
12
- log?.info('Rendering SurfsideDynamicZone component');
13
- const [error, setError] = (0, react_1.useState)();
14
- const [dynamicResponse, setDynamicResponse] = (0, react_1.useState)();
15
- const ref = (0, react_1.useRef)(null);
16
- (0, react_1.useEffect)(() => {
17
- let cancelled = false;
18
- if (!apiIsReady || !enabled) {
19
- if (apiHasError) {
20
- setErrorState(apiError);
21
- }
22
- return;
23
- }
24
- (0, ads_core_1.AsyncPipe)(getDynamicZone(zoneId))
25
- .then(buildDynamicZoneRequest.bind(undefined, zoneId))
26
- .then(buildDynamicResponse)
27
- .result()
28
- .then(dynamicResponse => {
29
- if (cancelled) {
30
- return;
31
- }
32
- if (!dynamicResponse.ok) {
33
- setErrorState(dynamicResponse);
34
- return;
35
- }
36
- setSuccessState(dynamicResponse.value);
37
- });
38
- return () => void (cancelled = true);
39
- }, [
40
- apiIsReady,
41
- apiError,
42
- apiHasError,
43
- getDynamicZone,
44
- buildDynamicZoneRequest,
45
- buildDynamicResponse,
46
- log,
47
- zoneId,
48
- enabled
49
- ]);
50
- (0, react_1.useEffect)(() => {
51
- let cancelled = false;
52
- if (!apiIsReady || !enabled ||
53
- dynamicResponse === undefined ||
54
- ref.current === null) {
55
- return;
56
- }
57
- switch (dynamicResponse.type) {
58
- case 'banner': {
59
- const bannerResult = renderBanner(dynamicResponse);
60
- if (!bannerResult.ok) {
61
- setErrorState(bannerResult);
62
- return;
63
- }
64
- ref.current.appendChild(bannerResult.value);
65
- break;
66
- }
67
- case 'video': {
68
- const videoResult = renderVideo(dynamicResponse);
69
- if (!videoResult.ok) {
70
- setErrorState(videoResult);
71
- return;
72
- }
73
- ref.current.appendChild(videoResult.value);
74
- break;
75
- }
76
- case 'carousel': {
77
- renderCarousel(dynamicResponse, carousel.cardMinWidth, carousel.carouselLimits, carousel.nextType).then(carouselResponse => {
78
- if (cancelled) {
79
- return;
80
- }
81
- if (!carouselResponse.ok) {
82
- setErrorState(carouselResponse);
83
- return;
84
- }
85
- // Have to check ref again since we're in a promise.then
86
- if (ref.current === null) {
87
- setErrorState((0, ads_core_1.Err)(new DynamicZoneUnmountedError));
88
- return;
89
- }
90
- ref.current.appendChild(carouselResponse.value.element);
91
- carouselResponse.value.init()
92
- .then(initResult => {
93
- if (!initResult.ok) {
94
- setErrorState(initResult);
95
- if (ref.current !== null) {
96
- ref.current.innerHTML = '';
97
- }
98
- }
99
- });
100
- });
101
- }
102
- }
103
- return () => {
104
- cancelled = true;
105
- if (ref.current !== null) {
106
- ref.current.innerHTML = '';
107
- }
108
- };
109
- }, [dynamicResponse, renderBanner, renderVideo, renderCarousel, enabled]);
110
- const setErrorState = (error) => {
111
- setError(error);
112
- setDynamicResponse(undefined);
113
- };
114
- const setSuccessState = (response) => {
115
- setError(undefined);
116
- setDynamicResponse(response);
117
- };
118
- if (error !== undefined) {
119
- log?.error(error.error);
120
- onError?.(error);
121
- }
122
- return (0, jsx_runtime_1.jsx)("div", { ref: ref });
123
- };
124
- exports.SurfsideDynamicZone = SurfsideDynamicZone;
125
- class DynamicZoneUnmountedError extends Error {
126
- constructor() {
127
- super('Dynamic zone container unmounted while processing carousel');
128
- }
129
- }
130
- exports.DynamicZoneUnmountedError = DynamicZoneUnmountedError;
131
- //# sourceMappingURL=SurfsideDynamicZone.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SurfsideDynamicZone.js","sourceRoot":"src/","sources":["components/SurfsideDynamicZone.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;AAEb,iDAAyE;AAEzE,iCAA6D;AAC7D,0CAAiD;AAU1C,MAAM,mBAAmB,GAAG,CAAC,EAChC,MAAM,EACN,QAAQ,EACR,OAAO,GAAG,IAAI,EACd,OAAO,EAC0B,EAAE,EAAE;IACrC,MAAM,EACF,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,QAAQ,EAEf,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EAEpB,YAAY,EACZ,WAAW,EACX,cAAc,EAEd,MAAM,EACT,GAAG,IAAA,6BAAkB,GAAE,CAAC;IAEzB,MAAM,GAAG,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,cAAG,EAAC,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9E,GAAG,EAAE,IAAI,CAAC,yCAAyC,CAAC,CAAC;IAErD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,GAAa,CAAC;IAChD,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,GAAyB,CAAC;IAChF,MAAM,GAAG,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAEzC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,SAAS,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1B,IAAI,WAAW,EA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,GAAG,EAAE,CAAC;4BAC/B,CAAC;wBACL,CAAC;oBACL,CAAC,CAAC,CAAC;gBACX,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QAED,OAAO,GAAG,EAAE;YACR,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;gBACvB,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;YAC/B,CAAC;QACL,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;IAE1E,MAAM,aAAa,GAAG,CAAC,KAAgB,EAAE,EAAE;QACvC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAChB,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,CAAC,QAA+B,EAAE,EAAE;QACxD,QAAQ,CAAC,SAAS,CAAC,CAAC;QACpB,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,gCAAK,GAAG,EAAE,GAAG,GAAQ,CAAC;AACjC,CAAC,CAAC;AAxJW,QAAA,mBAAmB,uBAwJ9B;AAEF,MAAa,yBAA0B,SAAQ,KAAK;IAChD;QACI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACxE,CAAC;CACJ;AAJD,8DAIC"}
@@ -1,116 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProductCardUnmountedError = exports.NoProductsReturnedError = void 0;
4
- exports.SurfsideProductCard = SurfsideProductCard;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const ads_core_1 = require("@surfside/ads-core");
7
- const react_1 = require("react");
8
- const provider_1 = require("../provider");
9
- ;
10
- ;
11
- function SurfsideProductCard({ zoneId, strategy, recommender, requestBuilder, nativeRequestBuilder, enabled }) {
12
- const { isReady, hasError, error: apiError, startRequest, defaultNative, renderProductCard, buildHybridCarousel, buildSponsoredCarousel, buildRecommendedCarousel, logger } = (0, provider_1.useSurfsideContext)();
13
- const log = (0, ads_core_1.Ctx)(logger)?.with('SurfsideProductCard');
14
- const [error, setError] = (0, react_1.useState)();
15
- const ref = (0, react_1.useRef)(null);
16
- (0, react_1.useEffect)(() => {
17
- log?.info('Getting product card');
18
- let cancelled = false;
19
- if (!isReady || enabled === false) {
20
- log?.info('API not ready');
21
- if (hasError) {
22
- setErrorState(apiError);
23
- }
24
- return;
25
- }
26
- const request = (requestBuilder ?? startRequest(zoneId))
27
- .withNative((nativeRequestBuilder ?? defaultNative())
28
- .withMetaBrand(80, false)
29
- .withMetaProduct(80, false)
30
- .build());
31
- log?.debug(request);
32
- const builtCarousel = (0, ads_core_1.TryDoFlat)(() => {
33
- switch (strategy) {
34
- case 'hybrid': {
35
- log?.debug('Using hybrid product card');
36
- return buildHybridCarousel({
37
- type: recommender,
38
- }, request.build());
39
- }
40
- case 'recommended': {
41
- log?.debug('Using hybrid product card');
42
- return buildRecommendedCarousel({
43
- type: recommender
44
- });
45
- }
46
- case 'sponsored': {
47
- log?.debug('Using sponsored product card');
48
- return buildSponsoredCarousel(request.build());
49
- }
50
- }
51
- });
52
- if (!builtCarousel.ok) {
53
- log?.warn('Product card carousel failed');
54
- return void (setErrorState(builtCarousel));
55
- }
56
- const builtCarouselValue = builtCarousel.value;
57
- (0, ads_core_1.ConsumeNAsync)(builtCarouselValue.getProduct(), 1)
58
- .then(([[card]]) => {
59
- if (cancelled) {
60
- log?.debug('Cancelled');
61
- return;
62
- }
63
- else if (card === undefined) {
64
- log?.debug('No products returned by carousel');
65
- return void (setErrorState((0, ads_core_1.Err)(new NoProductsReturnedError)));
66
- }
67
- else if (ref.current === null) {
68
- log?.debug('Product card unmounted');
69
- return void (setErrorState((0, ads_core_1.Err)(new ProductCardUnmountedError)));
70
- }
71
- log?.debug('Rendering product card');
72
- const productCard = renderProductCard(card);
73
- if (!productCard.ok) {
74
- log?.debug('Product card failed to render');
75
- return void (setErrorState(productCard));
76
- }
77
- log?.debug('Product card successfully rendered');
78
- ref.current.innerHTML = '';
79
- ref.current.appendChild(productCard.value);
80
- });
81
- return () => void (cancelled = true);
82
- }, [
83
- isReady,
84
- hasError,
85
- enabled,
86
- requestBuilder,
87
- startRequest,
88
- nativeRequestBuilder,
89
- defaultNative,
90
- buildHybridCarousel,
91
- buildSponsoredCarousel,
92
- buildRecommendedCarousel,
93
- renderProductCard
94
- ]);
95
- (0, react_1.useEffect)(() => {
96
- if (error !== undefined) {
97
- log?.error(error);
98
- }
99
- }, [error]);
100
- const setErrorState = setError;
101
- return (0, jsx_runtime_1.jsx)("div", { ref: ref });
102
- }
103
- ;
104
- class NoProductsReturnedError extends Error {
105
- constructor() {
106
- super('No product cards returned from recommender');
107
- }
108
- }
109
- exports.NoProductsReturnedError = NoProductsReturnedError;
110
- class ProductCardUnmountedError extends Error {
111
- constructor() {
112
- super('Product card unmounted while rendering');
113
- }
114
- }
115
- exports.ProductCardUnmountedError = ProductCardUnmountedError;
116
- //# sourceMappingURL=SurfsideProduct.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SurfsideProduct.js","sourceRoot":"src/","sources":["components/SurfsideProduct.tsx"],"names":[],"mappings":";;;AAkCA,kDA6HC;;AA/JD,iDAQ4B;AAC5B,iCAAoD;AACpD,0CAAiD;AAOhD,CAAC;AAKD,CAAC;AAYF,SAAgB,mBAAmB,CAAC,EAChC,MAAM,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,OAAO,EACgB;IAEvB,MAAM,EACF,OAAO,EACP,QAAQ,EACR,KAAK,EAAE,QAAQ,EACf,YAAY,EACZ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,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACpD,CAAC;CACJ;AAJD,8DAIC"}
@@ -1,82 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SurfsideVideo = void 0;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const SurfsideContextProvider_1 = require("../provider/SurfsideContextProvider");
8
- const ads_core_client_1 = require("@surfside/ads-core-client");
9
- /**
10
- * SurfsideVideo renders a video ad using the `useSurfsideVideo` hook. It automatically
11
- * manages video fetching, win tracking, and optional UI fallback states.
12
- *
13
- * Customize the video lifecycle using callbacks and optionally inject custom styles
14
- * or loading/error content.
15
- *
16
- * @param {ISurfsideVideoProps} props Props used to configure the video rendering behavior
17
- * @returns A responsive ad container that manages display and state transitions
18
- */
19
- const SurfsideVideo = ({ zoneId, size, minDuration = 0, maxDuration, mimes, enabled = true, requestBuilder, onError }) => {
20
- const { isReady: apiIsReady, error: apiError, hasError: apiHasError, startRequest, requestBids, buildVideoResponse, renderVideo, logger } = (0, SurfsideContextProvider_1.useSurfsideContext)();
21
- const log = (0, react_1.useMemo)(() => (0, ads_core_client_1.Ctx)(logger)?.with('SurfsideVideo'), [logger]);
22
- const [error, setError] = (0, react_1.useState)();
23
- const ref = (0, react_1.useRef)(null);
24
- (0, react_1.useEffect)(() => {
25
- log?.info('Requesting video');
26
- let cancelled = false;
27
- if (!enabled || !apiIsReady) {
28
- if (apiHasError) {
29
- log?.info('Surfside provider failed to initialize');
30
- return setError(apiError);
31
- }
32
- log?.info('Not ready yet');
33
- return;
34
- }
35
- const request = (requestBuilder ?? startRequest(zoneId))
36
- .withVideo(size[0], size[1], minDuration, maxDuration, mimes)
37
- .build();
38
- log?.debug('request', request);
39
- (0, ads_core_client_1.AsyncPipe)(requestBids(request))
40
- .then(response => (0, ads_core_client_1.WrapValue)(response.seatbid?.[0]?.bid?.[0]))
41
- .then(buildVideoResponse)
42
- .then(renderVideo)
43
- .result()
44
- .then(video => {
45
- log?.debug('Got video response', video);
46
- if (cancelled) {
47
- log?.info('Cancelled');
48
- return;
49
- }
50
- if (!video.ok) {
51
- log?.debug('Got error');
52
- return setError(video);
53
- }
54
- log?.info('Successful response. Appending video player');
55
- ref.current.appendChild(video.value);
56
- });
57
- return () => void (cancelled = true);
58
- }, [
59
- apiIsReady,
60
- apiError,
61
- apiHasError,
62
- zoneId,
63
- size,
64
- minDuration,
65
- maxDuration,
66
- mimes,
67
- enabled,
68
- size[0],
69
- size[1],
70
- requestBuilder,
71
- startRequest
72
- ]);
73
- (0, react_1.useEffect)(() => {
74
- if (error !== undefined) {
75
- log?.error(error.error);
76
- onError?.(error);
77
- }
78
- }, [error]);
79
- return (0, jsx_runtime_1.jsx)("div", { ref: ref });
80
- };
81
- exports.SurfsideVideo = SurfsideVideo;
82
- //# sourceMappingURL=SurfsideVideo.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SurfsideVideo.js","sourceRoot":"src/","sources":["components/SurfsideVideo.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;AAGb,iCAA6D;AAC7D,iFAAyE;AACzE,+DAMmC;AAqEnC;;;;;;;;;GASG;AACI,MAAM,aAAa,GAAG,CAAC,EAC1B,MAAM,EACN,IAAI,EACJ,WAAW,GAAG,CAAC,EACf,WAAW,EACX,KAAK,EACL,OAAO,GAAG,IAAI,EACd,cAAc,EACd,OAAO,EACW,EAAE,EAAE;IACtB,MAAM,EACF,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,WAAW,EAErB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,MAAM,EACT,GAAG,IAAA,4CAAkB,GAAE,CAAC;IAEzB,MAAM,GAAG,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,IAAA,qBAAG,EAAC,MAAM,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,CAAC,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ACZ,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;gBACvB,OAAO;YACX,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBACZ,GAAG,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;gBACxB,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YACD,GAAG,EAAE,IAAI,CAAC,6CAA6C,CAAC,CAAC;YACzD,GAAG,CAAC,OAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEP,OAAO,GAAG,EAAE,CAAC,KAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IACxC,CAAC,EAAE;QACC,UAAU;QACV,QAAQ;QACR,WAAW;QACX,MAAM;QACN,IAAI;QACJ,WAAW;QACX,WAAW;QACX,KAAK;QACL,OAAO;QACP,IAAI,CAAC,CAAC,CAAC;QACP,IAAI,CAAC,CAAC,CAAC;QACP,cAAc;QACd,YAAY;KACf,CAAC,CAAC;IAEH,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxB,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,gCAAK,GAAG,EAAE,GAAG,GAAQ,CAAC;AACjC,CAAC,CAAC;AAxFW,QAAA,aAAa,iBAwFxB"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.SurfsideVideoRenderer = void 0;
5
- const jsx_runtime_1 = require("react/jsx-runtime");
6
- const react_1 = require("react");
7
- const ads_core_client_1 = require("@surfside/ads-core-client");
8
- const SurfsideContextProvider_1 = require("../provider/SurfsideContextProvider");
9
- /**
10
- * SurfsideVideoRenderer renders a pre-fetched video creative into the DOM.
11
- * This component assumes the video has already been processed and only handles injection.
12
- *
13
- * @param props `ISurfsideVideoRendererProps`
14
- * @returns The video container element
15
- */
16
- const SurfsideVideoRenderer = ({ video, onRender, onError, }) => {
17
- const { logger, renderVideo, error: apiError } = (0, SurfsideContextProvider_1.useSurfsideContext)();
18
- const log = (0, ads_core_client_1.Ctx)(logger)?.with('SurfsideVideoRenderer');
19
- const ref = (0, react_1.useRef)(null);
20
- (0, react_1.useEffect)(() => {
21
- const container = ref.current;
22
- if (container === null || renderVideo === undefined) {
23
- if (apiError !== undefined) {
24
- onError?.(apiError);
25
- }
26
- return;
27
- }
28
- const result = renderVideo(video);
29
- if (!result.ok) {
30
- log?.error('Video render error', result);
31
- onError?.(result);
32
- return;
33
- }
34
- container.innerHTML = '';
35
- container.appendChild(result.value);
36
- log?.info('Video rendered');
37
- onRender?.(video.id);
38
- }, [video, renderVideo, apiError]);
39
- return (0, jsx_runtime_1.jsx)("div", { ref: ref });
40
- };
41
- exports.SurfsideVideoRenderer = SurfsideVideoRenderer;
42
- //# sourceMappingURL=SurfsideVideoRenderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SurfsideVideoRenderer.js","sourceRoot":"src/","sources":["components/SurfsideVideoRenderer.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;AAEb,iCAAiD;AACjD,+DAAgE;AAChE,iFAAyE;AAiCzE;;;;;;GAMG;AACI,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,IAAA,4CAAkB,GAAE,CAAC;IACtE,MAAM,GAAG,GAAG,IAAA,qBAAG,EAAC,MAAM,CAAC,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAEzC,IAAA,iBAAS,EAAC,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,gCAAK,GAAG,EAAE,GAAG,GAAI,CAAC;AAC7B,CAAC,CAAC;AAhCW,QAAA,qBAAqB,yBAgChC"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SurfsideBannerVideoRenderer = exports.SurfsideVideoRenderer = exports.SurfsideVideo = exports.ProductCardUnmountedError = exports.NoProductsReturnedError = exports.SurfsideProductCard = exports.DynamicZoneUnmountedError = exports.SurfsideDynamicZone = exports.SurfsideCarousel = exports.SurfsideBannerRenderer = exports.SurfsideBanner = void 0;
4
- var SurfsideBanner_1 = require("./SurfsideBanner");
5
- Object.defineProperty(exports, "SurfsideBanner", { enumerable: true, get: function () { return SurfsideBanner_1.SurfsideBanner; } });
6
- var SurfsideBannerRenderer_1 = require("./SurfsideBannerRenderer");
7
- Object.defineProperty(exports, "SurfsideBannerRenderer", { enumerable: true, get: function () { return SurfsideBannerRenderer_1.SurfsideBannerRenderer; } });
8
- var SurfsideCarousel_1 = require("./SurfsideCarousel");
9
- Object.defineProperty(exports, "SurfsideCarousel", { enumerable: true, get: function () { return SurfsideCarousel_1.SurfsideCarousel; } });
10
- var SurfsideDynamicZone_1 = require("./SurfsideDynamicZone");
11
- Object.defineProperty(exports, "SurfsideDynamicZone", { enumerable: true, get: function () { return SurfsideDynamicZone_1.SurfsideDynamicZone; } });
12
- Object.defineProperty(exports, "DynamicZoneUnmountedError", { enumerable: true, get: function () { return SurfsideDynamicZone_1.DynamicZoneUnmountedError; } });
13
- var SurfsideProduct_1 = require("./SurfsideProduct");
14
- Object.defineProperty(exports, "SurfsideProductCard", { enumerable: true, get: function () { return SurfsideProduct_1.SurfsideProductCard; } });
15
- Object.defineProperty(exports, "NoProductsReturnedError", { enumerable: true, get: function () { return SurfsideProduct_1.NoProductsReturnedError; } });
16
- Object.defineProperty(exports, "ProductCardUnmountedError", { enumerable: true, get: function () { return SurfsideProduct_1.ProductCardUnmountedError; } });
17
- var SurfsideVideo_1 = require("./SurfsideVideo");
18
- Object.defineProperty(exports, "SurfsideVideo", { enumerable: true, get: function () { return SurfsideVideo_1.SurfsideVideo; } });
19
- var SurfsideVideoRenderer_1 = require("./SurfsideVideoRenderer");
20
- Object.defineProperty(exports, "SurfsideVideoRenderer", { enumerable: true, get: function () { return SurfsideVideoRenderer_1.SurfsideVideoRenderer; } });
21
- var SurfsideBannerVideoRenderer_1 = require("./SurfsideBannerVideoRenderer");
22
- Object.defineProperty(exports, "SurfsideBannerVideoRenderer", { enumerable: true, get: function () { return SurfsideBannerVideoRenderer_1.SurfsideBannerVideoRenderer; } });
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["components/index.ts"],"names":[],"mappings":";;;AAAA,mDAG0B;AADtB,gHAAA,cAAc,OAAA;AAGlB,mEAGkC;AAD9B,gIAAA,sBAAsB,OAAA;AAG1B,uDAO4B;AADxB,oHAAA,gBAAgB,OAAA;AAGpB,6DAI+B;AAF3B,0HAAA,mBAAmB,OAAA;AACnB,gIAAA,yBAAyB,OAAA;AAG7B,qDAQ2B;AAHvB,sHAAA,mBAAmB,OAAA;AACnB,0HAAA,uBAAuB,OAAA;AACvB,4HAAA,yBAAyB,OAAA;AAG7B,iDAGyB;AADrB,8GAAA,aAAa,OAAA;AAGjB,iEAGiC;AAD7B,8HAAA,qBAAqB,OAAA;AAGzB,6EAIuC;AADnC,0IAAA,2BAA2B,OAAA"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidVideoStateError = exports.useSurfsideVideoResponse = exports.useSurfsideVideo = exports.InvalidProductsStateError = exports.InvalidStrategyError = exports.useSurfsideProductsResponse = exports.useSurfsideProducts = exports.InvalidDynamicZoneState = exports.useSurfsideDynamicZone = exports.InvalidBannerStateError = exports.useSurfsideBannerResponse = exports.useSurfsideBanner = void 0;
4
- var useSurfsideBanner_1 = require("./useSurfsideBanner");
5
- Object.defineProperty(exports, "useSurfsideBanner", { enumerable: true, get: function () { return useSurfsideBanner_1.useSurfsideBanner; } });
6
- Object.defineProperty(exports, "useSurfsideBannerResponse", { enumerable: true, get: function () { return useSurfsideBanner_1.useSurfsideBannerResponse; } });
7
- Object.defineProperty(exports, "InvalidBannerStateError", { enumerable: true, get: function () { return useSurfsideBanner_1.InvalidBannerStateError; } });
8
- var useSurfsideDynamicZone_1 = require("./useSurfsideDynamicZone");
9
- Object.defineProperty(exports, "useSurfsideDynamicZone", { enumerable: true, get: function () { return useSurfsideDynamicZone_1.useSurfsideDynamicZone; } });
10
- Object.defineProperty(exports, "InvalidDynamicZoneState", { enumerable: true, get: function () { return useSurfsideDynamicZone_1.InvalidDynamicZoneState; } });
11
- var useSurfsideProducts_1 = require("./useSurfsideProducts");
12
- Object.defineProperty(exports, "useSurfsideProducts", { enumerable: true, get: function () { return useSurfsideProducts_1.useSurfsideProducts; } });
13
- Object.defineProperty(exports, "useSurfsideProductsResponse", { enumerable: true, get: function () { return useSurfsideProducts_1.useSurfsideProductsResponse; } });
14
- Object.defineProperty(exports, "InvalidStrategyError", { enumerable: true, get: function () { return useSurfsideProducts_1.InvalidStrategyError; } });
15
- Object.defineProperty(exports, "InvalidProductsStateError", { enumerable: true, get: function () { return useSurfsideProducts_1.InvalidProductsStateError; } });
16
- var useSurfsideVideo_1 = require("./useSurfsideVideo");
17
- Object.defineProperty(exports, "useSurfsideVideo", { enumerable: true, get: function () { return useSurfsideVideo_1.useSurfsideVideo; } });
18
- Object.defineProperty(exports, "useSurfsideVideoResponse", { enumerable: true, get: function () { return useSurfsideVideo_1.useSurfsideVideoResponse; } });
19
- Object.defineProperty(exports, "InvalidVideoStateError", { enumerable: true, get: function () { return useSurfsideVideo_1.InvalidVideoStateError; } });
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["hooks/index.ts"],"names":[],"mappings":";;;AAAA,yDAa6B;AAJzB,sHAAA,iBAAiB,OAAA;AAEjB,8HAAA,yBAAyB,OAAA;AACzB,4HAAA,uBAAuB,OAAA;AAG3B,mEAqBkC;AAF9B,gIAAA,sBAAsB,OAAA;AACtB,iIAAA,uBAAuB,OAAA;AAG3B,6DAuB+B;AAJ3B,0HAAA,mBAAmB,OAAA;AACnB,kIAAA,2BAA2B,OAAA;AAC3B,2HAAA,oBAAoB,OAAA;AACpB,gIAAA,yBAAyB,OAAA;AAG7B,uDAc4B;AAJxB,oHAAA,gBAAgB,OAAA;AAEhB,4HAAA,wBAAwB,OAAA;AACxB,0HAAA,sBAAsB,OAAA"}