@surfside/ads-react 0.1.21 → 0.2.0
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/BuildInfo.js +6 -2
- package/lib/cjs/BuildInfo.js.map +1 -1
- package/lib/cjs/components/SurfsideBanner.js.map +1 -1
- package/lib/cjs/components/SurfsideBannerRenderer.js.map +1 -1
- package/lib/cjs/components/SurfsideBannerVideoRenderer.js.map +1 -1
- package/lib/cjs/components/SurfsideCarousel.js +49 -44
- package/lib/cjs/components/SurfsideCarousel.js.map +1 -1
- package/lib/cjs/components/SurfsideDynamicZone.js.map +1 -1
- package/lib/cjs/components/SurfsideProduct.js.map +1 -1
- package/lib/cjs/components/SurfsideVideo.js.map +1 -1
- package/lib/cjs/components/SurfsideVideoRenderer.js.map +1 -1
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/hooks/index.js.map +1 -1
- package/lib/cjs/hooks/useSurfsideBanner.js +42 -25
- package/lib/cjs/hooks/useSurfsideBanner.js.map +1 -1
- package/lib/cjs/hooks/useSurfsideDynamicZone.js.map +1 -1
- package/lib/cjs/hooks/useSurfsideProducts.js +21 -7
- package/lib/cjs/hooks/useSurfsideProducts.js.map +1 -1
- package/lib/cjs/hooks/useSurfsideVideo.js +2 -1
- package/lib/cjs/hooks/useSurfsideVideo.js.map +1 -1
- package/lib/cjs/index.js +26 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/provider/SurfsideContextProvider.js +417 -58
- package/lib/cjs/provider/SurfsideContextProvider.js.map +1 -1
- package/lib/cjs/provider/index.js +3 -1
- package/lib/cjs/provider/index.js.map +1 -1
- package/lib/cjs/utils/Analytics.js.map +1 -1
- package/lib/cjs/utils/index.js.map +1 -1
- package/lib/cjs/utils/useLog.js +8 -0
- package/lib/cjs/utils/useLog.js.map +1 -0
- package/lib/esm/BuildInfo.js +5 -1
- package/lib/esm/BuildInfo.js.map +1 -1
- package/lib/esm/components/SurfsideBanner.js.map +1 -1
- package/lib/esm/components/SurfsideBannerRenderer.js.map +1 -1
- package/lib/esm/components/SurfsideBannerVideoRenderer.js.map +1 -1
- package/lib/esm/components/SurfsideCarousel.js +49 -44
- package/lib/esm/components/SurfsideCarousel.js.map +1 -1
- package/lib/esm/components/SurfsideDynamicZone.js.map +1 -1
- package/lib/esm/components/SurfsideProduct.js.map +1 -1
- package/lib/esm/components/SurfsideVideo.js.map +1 -1
- package/lib/esm/components/SurfsideVideoRenderer.js.map +1 -1
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/hooks/index.js.map +1 -1
- package/lib/esm/hooks/useSurfsideBanner.js +44 -27
- package/lib/esm/hooks/useSurfsideBanner.js.map +1 -1
- package/lib/esm/hooks/useSurfsideDynamicZone.js.map +1 -1
- package/lib/esm/hooks/useSurfsideProducts.js +21 -7
- package/lib/esm/hooks/useSurfsideProducts.js.map +1 -1
- package/lib/esm/hooks/useSurfsideVideo.js +2 -1
- package/lib/esm/hooks/useSurfsideVideo.js.map +1 -1
- package/lib/esm/index.js +2 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/provider/SurfsideContextProvider.js +383 -59
- package/lib/esm/provider/SurfsideContextProvider.js.map +1 -1
- package/lib/esm/provider/index.js +1 -1
- package/lib/esm/provider/index.js.map +1 -1
- package/lib/esm/utils/Analytics.js.map +1 -1
- package/lib/esm/utils/index.js.map +1 -1
- package/lib/esm/utils/useLog.js +4 -0
- package/lib/esm/utils/useLog.js.map +1 -0
- package/lib/types/BuildInfo.d.ts +1 -1
- package/lib/types/components/SurfsideCarousel.d.ts +1 -1
- package/lib/types/components/SurfsideDynamicZone.d.ts +1 -1
- package/lib/types/components/SurfsideProduct.d.ts +1 -1
- package/lib/types/components/SurfsideVideo.d.ts +1 -1
- package/lib/types/hooks/useSurfsideBanner.d.ts +1 -1
- package/lib/types/hooks/useSurfsideProducts.d.ts +3 -3
- package/lib/types/hooks/useSurfsideVideo.d.ts +4 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/types/provider/SurfsideContextProvider.d.ts +37 -3
- package/lib/types/provider/index.d.ts +1 -1
- package/lib/types/utils/useLog.d.ts +2 -0
- package/package.json +13 -8
|
@@ -56,7 +56,7 @@ export interface IUseSurfsideBannerOptions {
|
|
|
56
56
|
* of the banner
|
|
57
57
|
*/
|
|
58
58
|
export interface IBannerAnalyticsCallbacks {
|
|
59
|
-
trackWin: () => void;
|
|
59
|
+
trackWin: (onError?: (err: any) => void) => void;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* The base return type for {@link useSurfsideBanner}. There are two child interfaces which represent the distinct
|
|
@@ -121,9 +121,9 @@ export interface IProductIDData extends IProductDataBase {
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
export interface IProductAnalyticsCallbacks {
|
|
124
|
-
trackClick: (product: IProductDataBase) => void;
|
|
125
|
-
trackImpression: (product: IProductDataBase) => void;
|
|
126
|
-
trackWin: (product: IProductDataBase) => void;
|
|
124
|
+
trackClick: (product: IProductDataBase, onError?: (err: any) => void) => void;
|
|
125
|
+
trackImpression: (product: IProductDataBase, onError?: (err: any) => void) => void;
|
|
126
|
+
trackWin: (product: IProductDataBase, onError?: (err: any) => void) => void;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
129
129
|
* The base return type for useSurfsideProducts. `products` may be either a set of IDs or a set of product info
|
|
@@ -88,6 +88,10 @@ export interface ISurfsideVideoAnalytics {
|
|
|
88
88
|
* This event should be called when the video is added to the page.
|
|
89
89
|
*/
|
|
90
90
|
win: ISurfsideVideoEventHandler;
|
|
91
|
+
/**
|
|
92
|
+
* This event should be called when the video is paused.
|
|
93
|
+
*/
|
|
94
|
+
pause: ISurfsideVideoEventHandler;
|
|
91
95
|
}
|
|
92
96
|
/**
|
|
93
97
|
* Return type for the {@link useSurfsideVideo} hook. The optional fields are narrowed by typescript when checking the
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ISurfsideProviderProps, ISurfsideContextValueBase, ISurfsideContextValueInitialized, ISurfsideContextValueUninitialized, ISurfsideContextValueHasError, ISurfsideContextValueNoError, SurfsideContextValue, useSurfsideContext, SurfsideProvider, InvalidStateError, NotInProviderError, } from './provider';
|
|
1
|
+
export { ISurfsideProviderProps, ISurfsideContextValueBase, ISurfsideContextValueInitialized, ISurfsideContextValueUninitialized, ISurfsideContextValueHasError, ISurfsideContextValueNoError, SurfsideContextValue, useSurfsideContext, SurfsideProvider, SurfsideProvider2, SurfsideHeadlessProvider, InvalidStateError, NotInProviderError, } from './provider';
|
|
2
2
|
export { IImpressionAnalytics, IClickAnalytics, trackProductClick, trackBannerClick, trackProductImpressions, trackBannerImpression, trackVideoImpression, trackVideoEvent, trackZoneEvent, } from './utils';
|
|
3
3
|
export { ISurfsideBannerProps, SurfsideBanner } from './components';
|
|
4
4
|
export { ISurfsideBannerRendererProps, SurfsideBannerRenderer, } from './components';
|
|
@@ -12,4 +12,4 @@ export { IBanner, IUseSurfsideBannerOptions, IBannerAnalyticsCallbacks, IUseSurf
|
|
|
12
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
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
14
|
export { IVideo, IUseSurfsideVideoOptions, ISurfsideVideoEventHandler, ISurfsideVideoAnalytics, IUseSurfsideVideoReturnBase, IUseSurfsideVideoReturnSuccess, IUseSurfsideVideoReturnError, IUseSurfsideVideoReturnLoading, UseSurfsideVideoReturn, useSurfsideVideo, UseSurfsideVideoResponseProps, useSurfsideVideoResponse, InvalidVideoStateError, } from './hooks';
|
|
15
|
-
export * from './BuildInfo';
|
|
15
|
+
export * as SurfsideAdsReactVersionInfo from './BuildInfo';
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
|
-
import { type ILogger, type ErrResult } from '@surfside/ads-core';
|
|
3
|
-
import { type ISurfsideWebApi } from '@surfside/ads-core-web';
|
|
4
|
-
|
|
2
|
+
import { type ILogger, type ErrResult, type INavigator, type IScreen, type INativeTemplateDelegateWindow, type IProductInformation } from '@surfside/ads-core';
|
|
3
|
+
import { type ILoadSurfAdsWebConfiguration, type ISurfAdsWebConfigurationOverrides, type ISurfAdsWebDependencies, type ISurfsideWebApi } from '@surfside/ads-core-web';
|
|
4
|
+
export interface IMockSurfsideProduct extends Partial<IProductInformation> {
|
|
5
|
+
id: string;
|
|
6
|
+
brand?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
ext?: {
|
|
9
|
+
category: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
13
|
* The arguments for initializing the Surfside ads context. user ID is optional because it is not always
|
|
7
14
|
* available at initialization time, but it can be set later via the context's `setIds` function.
|
|
@@ -25,6 +32,11 @@ export interface ISurfsideProviderProps {
|
|
|
25
32
|
config?: {
|
|
26
33
|
/** Whether or not to enable default logging */
|
|
27
34
|
debug?: boolean;
|
|
35
|
+
/** Whether or not to send performance timing to Surfside. Default false */
|
|
36
|
+
telemetry?: boolean;
|
|
37
|
+
/** The URL of the current page. Required for SSR users to populate telemetry logs correctly.
|
|
38
|
+
* Client-side users can omit this; window.location.href will be used automatically. */
|
|
39
|
+
url?: string;
|
|
28
40
|
/** Whether or not to use mock services. Default false */
|
|
29
41
|
mock?: boolean;
|
|
30
42
|
/** The % chance that the mock bidder will return No Bids, from 0-1. If 1, the mock bidder will always
|
|
@@ -69,6 +81,14 @@ export interface ISurfsideContextValueBase extends Partial<ISurfsideWebApi> {
|
|
|
69
81
|
userId?: string;
|
|
70
82
|
setLocationId: (id: string) => void;
|
|
71
83
|
setUserId: (id: string) => void;
|
|
84
|
+
setAccountId: (id: string) => void;
|
|
85
|
+
setSiteId: (id: string) => void;
|
|
86
|
+
setChannelId: (id: string) => void;
|
|
87
|
+
setIp: (id: string) => void;
|
|
88
|
+
setMobile: (mobile: boolean) => void;
|
|
89
|
+
setNavigator: (navigator: INavigator) => void;
|
|
90
|
+
setScreen: (screen: IScreen) => void;
|
|
91
|
+
setWindowInfo: (windowInfo: INativeTemplateDelegateWindow) => void;
|
|
72
92
|
}
|
|
73
93
|
/**
|
|
74
94
|
* This state describes the successful initialization of the Surfside context object. if `isReady` is true, Surfside
|
|
@@ -151,6 +171,20 @@ export declare const useSurfsideContext: () => SurfsideContextValue;
|
|
|
151
171
|
* @see {@link ISurfsideProviderProps}
|
|
152
172
|
*/
|
|
153
173
|
export declare const SurfsideProvider: React.FC<ISurfsideProviderProps>;
|
|
174
|
+
export declare const SurfsideProvider2: React.FC<React.PropsWithChildren<ILoadSurfAdsReactConfiguration>>;
|
|
175
|
+
export interface ILoadSurfAdsReactConfiguration {
|
|
176
|
+
logger?: ILogger;
|
|
177
|
+
default?: Partial<Omit<ILoadSurfAdsWebConfiguration, 'overrides' | 'logger' | 'locationId'>> & {
|
|
178
|
+
locationId?: string;
|
|
179
|
+
};
|
|
180
|
+
overrides?: {
|
|
181
|
+
services?: Partial<ISurfAdsWebConfigurationOverrides>;
|
|
182
|
+
dependencies?: Partial<ISurfAdsWebDependencies>;
|
|
183
|
+
};
|
|
184
|
+
onError?: (error: ErrResult) => void;
|
|
185
|
+
error?: ErrResult;
|
|
186
|
+
}
|
|
187
|
+
export declare const SurfsideHeadlessProvider: React.FC<React.PropsWithChildren<ILoadSurfAdsReactConfiguration>>;
|
|
154
188
|
export declare class InvalidStateError extends Error {
|
|
155
189
|
constructor();
|
|
156
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ISurfsideProviderProps, ISurfsideContextValueBase, ISurfsideContextValueInitialized, ISurfsideContextValueUninitialized, ISurfsideContextValueHasError, ISurfsideContextValueNoError, SurfsideContextValue, useSurfsideContext, SurfsideProvider, InvalidStateError, NotInProviderError, } from './SurfsideContextProvider';
|
|
1
|
+
export { ISurfsideProviderProps, ISurfsideContextValueBase, ISurfsideContextValueInitialized, ISurfsideContextValueUninitialized, ISurfsideContextValueHasError, ISurfsideContextValueNoError, SurfsideContextValue, useSurfsideContext, SurfsideProvider, SurfsideProvider2, SurfsideHeadlessProvider, InvalidStateError, NotInProviderError, } from './SurfsideContextProvider';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@surfside/ads-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React components for Surfside Ads",
|
|
5
5
|
"main": "./lib/cjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -20,25 +20,30 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"clean": "rm -rf ./lib",
|
|
23
|
-
"
|
|
24
|
-
"build": "bunx npm-run-all --parallel \"types\" \"esm\" \"cjs\"",
|
|
23
|
+
"build": "bun x npm-run-all --parallel \"types\" \"esm\" \"cjs\"",
|
|
25
24
|
"types": "tsc -p ./tsconfig.types.json",
|
|
26
25
|
"esm": "tsc -p ./tsconfig.esm.json",
|
|
27
26
|
"cjs": "tsc -p tsconfig.cjs.json",
|
|
28
|
-
"lint": "npx eslint"
|
|
27
|
+
"lint": "npx eslint",
|
|
28
|
+
"test": "bunx playwright test",
|
|
29
|
+
"test:ui": "bunx playwright test --ui"
|
|
29
30
|
},
|
|
30
31
|
"peerDependencies": {
|
|
31
32
|
"react": ">=17",
|
|
33
|
+
"react-dom": ">=17",
|
|
32
34
|
"typescript": "^5.8.3"
|
|
33
35
|
},
|
|
34
36
|
"dependencies": {
|
|
35
|
-
"@surfside/ads-core-web": "^0.
|
|
36
|
-
"@surfside/ads-core-mock": "^0.
|
|
37
|
+
"@surfside/ads-core-web": "^0.2.0",
|
|
38
|
+
"@surfside/ads-core-mock": "^0.2.0"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
41
|
+
"@playwright/test": "^1.60.0",
|
|
39
42
|
"@types/bun": "latest",
|
|
40
|
-
"@types/react": "^
|
|
41
|
-
"@types/react-dom": "^
|
|
43
|
+
"@types/react": "^19.0.0",
|
|
44
|
+
"@types/react-dom": "^19.0.0",
|
|
45
|
+
"react": "^19.0.0",
|
|
46
|
+
"react-dom": "^19.0.0",
|
|
42
47
|
"typedoc": "^0.28.5"
|
|
43
48
|
}
|
|
44
49
|
}
|