react-native-firework-sdk 1.7.0 → 2.0.0-beta.1
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/android/build.gradle +25 -43
- package/android/src/main/AndroidManifest.xml +4 -4
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +48 -194
- package/android/src/main/java/com/fireworksdk/bridge/constants/FWVideoPlayerConstant.kt +7 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWAdBadgeConfigModel.kt +2 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWAdBadgeConfigModelDeserializer.kt +24 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfiguration.kt +17 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfigurationDeserializer.kt +35 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModel.kt +12 -13
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModelDeserializer.kt +67 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedItemDetailsModel.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModel.kt +9 -10
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModelDeserializer.kt +67 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlaybackDetails.kt +0 -3
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +19 -11
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModelDeserializer.kt +74 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoShoppingProduct.kt +17 -15
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoShoppingProductDeserializer.kt +120 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +4 -130
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +48 -100
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWNavigatorInterface.kt +2 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWLiveStreamModule.kt +2 -50
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +17 -35
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +152 -108
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +87 -133
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/pages/FWContainerActivity.kt +1 -14
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/{FWDataUtils.kt → FWDataConvertUtils.kt} +1 -11
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +14 -5
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWCommonUtil.kt +23 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +312 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +14 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWLanguageUtil.kt +30 -14
- package/android/src/main/res/layout/fw_bridge_fragment_container.xml +2 -2
- package/android/src/main/res/values/colors.xml +2 -2
- package/android/src/main/res/values/styles.xml +0 -40
- package/ios/Components/StoryBlock.swift +1 -8
- package/ios/Components/StoryBlockManager.swift +4 -0
- package/ios/Components/VideoFeed.swift +9 -14
- package/ios/Components/VideoFeedConfiguration.swift +2 -0
- package/ios/Components/VideoFeedManager.m +2 -0
- package/ios/Components/VideoFeedManager.swift +4 -0
- package/ios/Components/VideoPlayerConfiguration.swift +1 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +12 -8
- package/ios/Models/Common/FontInfo.swift +57 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +2 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +295 -103
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +0 -2
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +12 -12
- package/ios/Modules/LiveStream/LiveStreamModule.swift +5 -3
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +7 -2
- package/ios/Modules/Shopping/ShoppingModule.m +1 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +72 -63
- package/ios/Utils/FWSwizzleLoader.m +0 -1
- package/lib/commonjs/FWNavigator.js +14 -16
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +5 -39
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/LiveStream.js +2 -2
- package/lib/commonjs/LiveStream.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +59 -39
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +3 -0
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +14 -5
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +1 -1
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/IOSFontInfo.js +2 -0
- package/lib/commonjs/modules/FWNavigatorModule.js.map +1 -1
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FWNavigator.js +15 -16
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +5 -37
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/LiveStream.js +2 -2
- package/lib/module/LiveStream.js.map +1 -1
- package/lib/module/VideoShopping.js +58 -38
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +3 -0
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +14 -5
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +1 -1
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/IOSFontInfo.js +2 -0
- package/lib/module/modules/FWNavigatorModule.js.map +1 -1
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FWNavigator.d.ts +11 -14
- package/lib/typescript/FireworkSDK.d.ts +5 -16
- package/lib/typescript/LiveStream.d.ts +2 -2
- package/lib/typescript/VideoShopping.d.ts +24 -19
- package/lib/typescript/components/StoryBlock.d.ts +4 -1
- package/lib/typescript/components/VideoFeed.d.ts +7 -3
- package/lib/typescript/index.d.ts +6 -5
- package/lib/typescript/models/FWEventName.d.ts +2 -2
- package/lib/typescript/models/FWEvents.d.ts +5 -6
- package/lib/typescript/models/IOSFontInfo.d.ts +19 -0
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +23 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +22 -4
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +18 -2
- package/lib/typescript/modules/FWNavigatorModule.d.ts +2 -3
- package/lib/typescript/modules/FireworkSDKModule.d.ts +0 -2
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -3
- package/package.json +1 -1
- package/react-native-firework-sdk.podspec +1 -1
- package/src/FWNavigator.ts +52 -0
- package/src/FireworkSDK.ts +5 -31
- package/src/LiveStream.ts +2 -2
- package/src/VideoShopping.ts +74 -54
- package/src/components/StoryBlock.tsx +4 -1
- package/src/components/VideoFeed.tsx +15 -5
- package/src/{index.tsx → index.ts} +17 -9
- package/src/models/FWEventName.ts +1 -1
- package/src/models/FWEvents.ts +6 -7
- package/src/models/IOSFontInfo.ts +29 -0
- package/src/models/ProductInfoViewConfiguration.ts +25 -0
- package/src/models/VideoFeedConfiguration.ts +23 -4
- package/src/models/VideoPlayerConfiguration.ts +19 -2
- package/src/modules/FWNavigatorModule.ts +2 -1
- package/src/modules/FireworkSDKModule.ts +0 -2
- package/src/modules/ShoppingModule.ts +2 -9
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWGsonUtil.kt +0 -38
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +0 -122
- package/android/src/main/res/layout/fw_bridge_fragment_playlistfeed.xml +0 -18
- package/android/src/main/res/layout/fw_bridge_fragment_shoppingcart.xml +0 -8
- package/android/src/main/res/layout/fw_bridge_fragment_videofeed.xml +0 -17
- package/ios/Utils/FWPiPManager.swift +0 -24
- package/ios/Utils/UIButton+FWSwizzle.swift +0 -33
- package/lib/commonjs/models/NewNativeContainerProps.js +0 -2
- package/lib/module/models/NewNativeContainerProps.js +0 -2
- package/lib/typescript/models/NewNativeContainerProps.d.ts +0 -6
- package/src/FWNavigator.tsx +0 -58
- package/src/models/NewNativeContainerProps.ts +0 -4
- /package/lib/commonjs/models/{NewNativeContainerProps.js.map → IOSFontInfo.js.map} +0 -0
- /package/lib/module/models/{NewNativeContainerProps.js.map → IOSFontInfo.js.map} +0 -0
|
@@ -1,9 +1,25 @@
|
|
|
1
|
+
import type IOSFontInfo from './IOSFontInfo';
|
|
1
2
|
export declare type VideoPlayerStyle = 'full' | 'fit';
|
|
2
3
|
export declare type VideoPlayerCompleteAction = 'loop' | 'advanceToNext';
|
|
3
4
|
export interface VideoPlayerCTAStyle {
|
|
5
|
+
/**
|
|
6
|
+
* The background color of CTA button.
|
|
7
|
+
*/
|
|
4
8
|
backgroundColor?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The text color of CTA button.
|
|
11
|
+
*/
|
|
5
12
|
textColor?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The font size of CTA button.
|
|
15
|
+
*/
|
|
6
16
|
fontSize?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The iOS font info of "Add to cart" button.
|
|
19
|
+
* The property is ignored when fontSize is not set.
|
|
20
|
+
* Only supported on iOS.
|
|
21
|
+
*/
|
|
22
|
+
iOSFontInfo?: IOSFontInfo;
|
|
7
23
|
}
|
|
8
24
|
export declare type VideoPlayerCTADelayType = 'constant' | 'percentage';
|
|
9
25
|
export interface VideoPlayerCTADelay {
|
|
@@ -43,7 +59,7 @@ export default interface VideoPlayerConfiguration {
|
|
|
43
59
|
*/
|
|
44
60
|
showMuteButton?: boolean;
|
|
45
61
|
/**
|
|
46
|
-
* Specifies the video player launch behavior.
|
|
62
|
+
* Specifies the video player launch behavior. Only supported on iOS.
|
|
47
63
|
*/
|
|
48
64
|
launchBehavior?: VideoLaunchBehavior;
|
|
49
65
|
/**
|
|
@@ -55,7 +71,7 @@ export default interface VideoPlayerConfiguration {
|
|
|
55
71
|
*/
|
|
56
72
|
ctaDelay?: VideoPlayerCTADelay;
|
|
57
73
|
/**
|
|
58
|
-
* Specifies the delay before the highlight animation occurs.
|
|
74
|
+
* Specifies the delay before the highlight animation occurs. Only supported on iOS.
|
|
59
75
|
*/
|
|
60
76
|
ctaHighlightDelay?: VideoPlayerCTADelay;
|
|
61
77
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { NativeEventEmitter, NativeModule } from 'react-native';
|
|
2
2
|
interface IFWNavigatorModule extends NativeModule {
|
|
3
|
-
pushNativeContainer(props: {
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}): Promise<boolean>;
|
|
6
3
|
popNativeContainer(): Promise<boolean>;
|
|
7
4
|
canPopNativeContainer(): Promise<boolean>;
|
|
5
|
+
startFloatingPlayer(): Promise<boolean>;
|
|
6
|
+
stopFloatingPlayer(): Promise<boolean>;
|
|
8
7
|
}
|
|
9
8
|
declare const FWNavigatorModuleEventEmitter: NativeEventEmitter;
|
|
10
9
|
export { FWNavigatorModuleEventEmitter };
|
|
@@ -6,11 +6,9 @@ interface IFireworkSDKModule extends NativeModule {
|
|
|
6
6
|
init(userId?: string): void;
|
|
7
7
|
openVideoPlayer(url: string, config?: VideoPlayerConfiguration): void;
|
|
8
8
|
setCustomCTAClickEnabled(enabled: boolean): void;
|
|
9
|
-
setCustomCTALinkContentPageRouteName(name?: string): Promise<any>;
|
|
10
9
|
setShareBaseURL(url?: string): Promise<any>;
|
|
11
10
|
setVideoPlaybackEventEnabled(enabled: boolean): void;
|
|
12
11
|
setAdBadgeConfiguration(config?: AdBadgeConfiguration): Promise<any>;
|
|
13
|
-
setAppComponentName(name?: string): Promise<any>;
|
|
14
12
|
trackPurchase(parameters: TrackPurchaseParameters): void;
|
|
15
13
|
changeAppLanguage(language: string): Promise<boolean>;
|
|
16
14
|
restart(): Promise<void>;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { NativeEventEmitter, NativeModule } from 'react-native';
|
|
2
|
-
import type { NewNativeContainerProps } from '../models/NewNativeContainerProps';
|
|
3
2
|
import type Product from '../models/Product';
|
|
4
3
|
import type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';
|
|
5
4
|
interface IShoppingModule extends NativeModule {
|
|
6
5
|
init(): void;
|
|
7
6
|
updateVideoProducts(products: Product[], callbackId: number | string): void;
|
|
8
|
-
updateProductViewConfig(config: ProductInfoViewConfiguration, callbackId: number | string): void;
|
|
9
7
|
updateAddToCartStatus(res: string, tips: string, callbackId: number | string): void;
|
|
10
|
-
jumpToCartPage(callbackId: number | string, props: NewNativeContainerProps): void;
|
|
11
8
|
setCartIconVisible(visible: boolean): void;
|
|
12
9
|
setCartItemCount(count: number): void;
|
|
13
10
|
setCustomClickCartIconEnabled(enabled: boolean): Promise<void>;
|
|
14
11
|
clearCallbackId(callbackId: number | string, eventName: string): void;
|
|
12
|
+
setProductInfoViewConfiguration(config: ProductInfoViewConfiguration): void;
|
|
13
|
+
setCustomClickLinkButtonEnabled(enabled: boolean): Promise<void>;
|
|
15
14
|
}
|
|
16
15
|
declare const ShoppingModuleEventEmitter: NativeEventEmitter;
|
|
17
16
|
export { ShoppingModuleEventEmitter };
|
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { FWEventName } from './models/FWEventName';
|
|
2
|
+
import FWNavigatorModule, {
|
|
3
|
+
FWNavigatorModuleEventEmitter,
|
|
4
|
+
} from './modules/FWNavigatorModule';
|
|
5
|
+
import FWLoggerUtil from './utils/FWLoggerUtil';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* You can use this class for pushing RN page from the native page.
|
|
9
|
+
*/
|
|
10
|
+
class FWNavigator {
|
|
11
|
+
private static _instance?: FWNavigator;
|
|
12
|
+
|
|
13
|
+
public static getInstance(): FWNavigator {
|
|
14
|
+
if (!FWNavigator._instance) {
|
|
15
|
+
FWNavigator._instance = new FWNavigator();
|
|
16
|
+
}
|
|
17
|
+
return FWNavigator._instance!;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private constructor() {
|
|
21
|
+
FWLoggerUtil.log('FWNavigator constructor');
|
|
22
|
+
FWNavigatorModuleEventEmitter.addListener(FWEventName.LogMessage, () => {});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Pop the native container. You could use the method to close the fullscreen player.
|
|
27
|
+
* But if the enablePictureInPicture of the associated video feed is true,
|
|
28
|
+
* we can't close the fullscreen player.
|
|
29
|
+
* @returns {Promise<boolean>} The result of popping the native container.
|
|
30
|
+
*/
|
|
31
|
+
public popNativeContainer(): Promise<boolean> {
|
|
32
|
+
return FWNavigatorModule.popNativeContainer();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Change current fullscreen player to floating player.
|
|
37
|
+
* @returns {Promise<boolean>} If the result is true, it means that the fullscreen
|
|
38
|
+
* player is changed to floating player.
|
|
39
|
+
*/
|
|
40
|
+
public async startFloatingPlayer(): Promise<boolean> {
|
|
41
|
+
return FWNavigatorModule.startFloatingPlayer();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Stop current floating player.
|
|
46
|
+
*/
|
|
47
|
+
public async stopFloatingPlayer(): Promise<void> {
|
|
48
|
+
await FWNavigatorModule.stopFloatingPlayer();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default FWNavigator;
|
package/src/FireworkSDK.ts
CHANGED
|
@@ -55,19 +55,7 @@ class FireworkSDK {
|
|
|
55
55
|
private _onCustomCTAClick: CustomCTAClickCallback | undefined;
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* The
|
|
59
|
-
*/
|
|
60
|
-
public get customCTALinkContentPageRouteName(): string | undefined {
|
|
61
|
-
return this._customCTALinkContentPageRouteName;
|
|
62
|
-
}
|
|
63
|
-
public set customCTALinkContentPageRouteName(value: string | undefined) {
|
|
64
|
-
this._customCTALinkContentPageRouteName = value;
|
|
65
|
-
FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');
|
|
66
|
-
}
|
|
67
|
-
private _customCTALinkContentPageRouteName: string | undefined;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The callback of video playback.
|
|
58
|
+
* The callback of video playback. Only supported on iOS.
|
|
71
59
|
*/
|
|
72
60
|
public get onVideoPlayback(): VideoPlaybackCallback | undefined {
|
|
73
61
|
return this._onVideoPlayback;
|
|
@@ -79,7 +67,7 @@ class FireworkSDK {
|
|
|
79
67
|
private _onVideoPlayback?: VideoPlaybackCallback | undefined;
|
|
80
68
|
|
|
81
69
|
/**
|
|
82
|
-
* The share base URL of videos.
|
|
70
|
+
* The share base URL of videos. Only supported on iOS.
|
|
83
71
|
*/
|
|
84
72
|
public get shareBaseURL(): string | undefined {
|
|
85
73
|
return this._shareBaseURL;
|
|
@@ -96,7 +84,7 @@ class FireworkSDK {
|
|
|
96
84
|
private _shareBaseURL: string | undefined;
|
|
97
85
|
|
|
98
86
|
/**
|
|
99
|
-
* The configuration for ad badges.
|
|
87
|
+
* The configuration for ad badges. Only supported on iOS.
|
|
100
88
|
*/
|
|
101
89
|
public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {
|
|
102
90
|
return this._adBadgeConfiguration;
|
|
@@ -116,19 +104,8 @@ class FireworkSDK {
|
|
|
116
104
|
private _adBadgeConfiguration: AdBadgeConfiguration | undefined;
|
|
117
105
|
|
|
118
106
|
/**
|
|
119
|
-
*
|
|
120
|
-
|
|
121
|
-
public get appComponentName(): string | undefined {
|
|
122
|
-
return this._appComponentName;
|
|
123
|
-
}
|
|
124
|
-
public set appComponentName(value: string | undefined) {
|
|
125
|
-
this._appComponentName = value;
|
|
126
|
-
FireworkSDKModule.setAppComponentName(value ?? '');
|
|
127
|
-
}
|
|
128
|
-
private _appComponentName: string | undefined;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
107
|
+
* Defaults to false.
|
|
108
|
+
* You can enable debug logs by setting this property to true.
|
|
132
109
|
*/
|
|
133
110
|
public get debugLogsEnabled(): boolean {
|
|
134
111
|
return FWLoggerUtil.enabled;
|
|
@@ -257,9 +234,6 @@ class FireworkSDK {
|
|
|
257
234
|
public async changeAppLanguage(language: string): Promise<boolean> {
|
|
258
235
|
if (Platform.OS === 'android') {
|
|
259
236
|
const result = await FireworkSDKModule.changeAppLanguage(language);
|
|
260
|
-
if (result) {
|
|
261
|
-
await FireworkSDKModule.restart();
|
|
262
|
-
}
|
|
263
237
|
return result;
|
|
264
238
|
}
|
|
265
239
|
|
package/src/LiveStream.ts
CHANGED
|
@@ -16,11 +16,11 @@ class LiveStream {
|
|
|
16
16
|
private static _instance?: LiveStream;
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* The callback of live stream event.
|
|
19
|
+
* The callback of live stream event. Only supported on iOS.
|
|
20
20
|
*/
|
|
21
21
|
public onLiveStreamEvent?: onLiveStreamEventCallback;
|
|
22
22
|
/**
|
|
23
|
-
* The callback of live stream chat event.
|
|
23
|
+
* The callback of live stream chat event. Only supported on iOS.
|
|
24
24
|
*/
|
|
25
25
|
public onLiveStreamChatEvent?: onLiveStreamChatEventCallback;
|
|
26
26
|
|
package/src/VideoShopping.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { NativeEventEmitter, Platform } from 'react-native';
|
|
|
3
3
|
import type AddToCartResult from './models/AddToCartResult';
|
|
4
4
|
import type {
|
|
5
5
|
AddToCartEvent,
|
|
6
|
+
CustomClickLinkButtonEvent,
|
|
6
7
|
UpdateProductDetailsEvent,
|
|
7
|
-
WillDisplayProductEvent,
|
|
8
8
|
} from './models/FWEvents';
|
|
9
9
|
import { FWEventName } from './models/FWEventName';
|
|
10
10
|
import type Product from './models/Product';
|
|
@@ -12,26 +12,21 @@ import type ProductInfoViewConfiguration from './models/ProductInfoViewConfigura
|
|
|
12
12
|
import ShoppingModule, {
|
|
13
13
|
ShoppingModuleEventEmitter,
|
|
14
14
|
} from './modules/ShoppingModule';
|
|
15
|
-
import type { NewNativeContainerProps } from './models/NewNativeContainerProps';
|
|
16
15
|
import FWLoggerUtil from './utils/FWLoggerUtil';
|
|
17
16
|
|
|
18
17
|
export type AddToCartCallback = (
|
|
19
18
|
event: AddToCartEvent
|
|
20
19
|
) => Promise<AddToCartResult | undefined | null>;
|
|
21
20
|
|
|
22
|
-
export type ClickCartIconCallback = () => Promise<
|
|
23
|
-
NewNativeContainerProps | undefined | null
|
|
24
|
-
>;
|
|
25
|
-
|
|
26
21
|
export type CustomClickCartIconCallback = () => Promise<void>;
|
|
27
22
|
|
|
28
23
|
export type UpdateProductDetailsCallback = (
|
|
29
24
|
event: UpdateProductDetailsEvent
|
|
30
25
|
) => Promise<Product[] | undefined | null>;
|
|
31
26
|
|
|
32
|
-
export type
|
|
33
|
-
event:
|
|
34
|
-
) => Promise<
|
|
27
|
+
export type CustomClickLinkButtonCallback = (
|
|
28
|
+
event: CustomClickLinkButtonEvent
|
|
29
|
+
) => Promise<void>;
|
|
35
30
|
|
|
36
31
|
type CallbackInfo = { callbackId?: number | string };
|
|
37
32
|
|
|
@@ -52,14 +47,8 @@ class VideoShopping {
|
|
|
52
47
|
/**
|
|
53
48
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
54
49
|
*
|
|
55
|
-
* The host app can
|
|
56
|
-
|
|
57
|
-
public onClickCartIcon?: ClickCartIconCallback;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* This callback is triggered when the user clicks the shopping cart icon.
|
|
61
|
-
*
|
|
62
|
-
* The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.
|
|
50
|
+
* The host app can customize the click event processing logic of
|
|
51
|
+
* the shopping cart icon by setting the callback.
|
|
63
52
|
*/
|
|
64
53
|
public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {
|
|
65
54
|
return this._onCustomClickCartIcon;
|
|
@@ -82,14 +71,8 @@ class VideoShopping {
|
|
|
82
71
|
public onUpdateProductDetails?: UpdateProductDetailsCallback;
|
|
83
72
|
|
|
84
73
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* The host app can return a ProductInfoViewConfiguration object to configure "Add to cart" button style and cart icon style.
|
|
88
|
-
*/
|
|
89
|
-
public onWillDisplayProduct?: WillDisplayProductCallback;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Defaults to true. You can hide the cart icon by setting this property to false.
|
|
74
|
+
* Defaults to true.
|
|
75
|
+
* You can hide the cart icon by setting this property to false.
|
|
93
76
|
*/
|
|
94
77
|
public get cartIconVisible(): boolean {
|
|
95
78
|
return this._cartIconVisible;
|
|
@@ -100,6 +83,51 @@ class VideoShopping {
|
|
|
100
83
|
}
|
|
101
84
|
private _cartIconVisible: boolean = true;
|
|
102
85
|
|
|
86
|
+
/**
|
|
87
|
+
* The host app can use this property to configure "Add to cart" button style
|
|
88
|
+
* and hide the link button next to "Add to cart" button. Only supported on iOS.
|
|
89
|
+
*/
|
|
90
|
+
public get productInfoViewConfiguration():
|
|
91
|
+
| ProductInfoViewConfiguration
|
|
92
|
+
| undefined {
|
|
93
|
+
return this._productInfoViewConfiguration;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public set productInfoViewConfiguration(
|
|
97
|
+
value: ProductInfoViewConfiguration | undefined
|
|
98
|
+
) {
|
|
99
|
+
this._productInfoViewConfiguration = value;
|
|
100
|
+
if (Platform.OS === 'ios') {
|
|
101
|
+
ShoppingModule.setProductInfoViewConfiguration(value ?? {});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private _productInfoViewConfiguration?:
|
|
106
|
+
| ProductInfoViewConfiguration
|
|
107
|
+
| undefined;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* This callback is triggered when the user clicks
|
|
111
|
+
* the link button next to Add to cart button. Only supported on Android.
|
|
112
|
+
*
|
|
113
|
+
* The host app can customize the click event processing logic of
|
|
114
|
+
* the link button by setting the callback.
|
|
115
|
+
*/
|
|
116
|
+
public get onCustomClickLinkButton():
|
|
117
|
+
| CustomClickLinkButtonCallback
|
|
118
|
+
| undefined {
|
|
119
|
+
return this._onCustomClickLinkButton;
|
|
120
|
+
}
|
|
121
|
+
public set onCustomClickLinkButton(
|
|
122
|
+
value: CustomClickLinkButtonCallback | undefined
|
|
123
|
+
) {
|
|
124
|
+
this._onCustomClickLinkButton = value;
|
|
125
|
+
if (Platform.OS === 'android') {
|
|
126
|
+
ShoppingModule.setCustomClickLinkButtonEnabled(!!value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;
|
|
130
|
+
|
|
103
131
|
private get eventEmitter(): NativeEventEmitter {
|
|
104
132
|
return ShoppingModuleEventEmitter;
|
|
105
133
|
}
|
|
@@ -116,30 +144,36 @@ class VideoShopping {
|
|
|
116
144
|
private constructor() {
|
|
117
145
|
this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {
|
|
118
146
|
FWLoggerUtil.log(
|
|
119
|
-
`Receive AddToCart event productId: ${event
|
|
147
|
+
`Receive AddToCart event productId: ${event?.productId} unitId: ${event?.unitId}`
|
|
120
148
|
);
|
|
121
149
|
this.handleAddToCartEvent(event);
|
|
122
150
|
});
|
|
123
151
|
|
|
124
|
-
this.eventEmitter.addListener(FWEventName.ClickCartIcon, (
|
|
152
|
+
this.eventEmitter.addListener(FWEventName.ClickCartIcon, () => {
|
|
125
153
|
FWLoggerUtil.log('Receive ClickCartIcon event');
|
|
126
|
-
this.handleClickCartIconEvent(
|
|
154
|
+
this.handleClickCartIconEvent();
|
|
127
155
|
});
|
|
128
156
|
|
|
129
157
|
this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {
|
|
130
158
|
FWLoggerUtil.log(
|
|
131
|
-
`Receive UpdateProductDetails event productIds: ${event
|
|
159
|
+
`Receive UpdateProductDetails event productIds: ${event?.productIds}`
|
|
132
160
|
);
|
|
133
161
|
this.handleUpdateProductDetailsEvent(event);
|
|
134
162
|
});
|
|
135
163
|
|
|
136
|
-
this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {
|
|
137
|
-
FWLoggerUtil.log(
|
|
138
|
-
`Receive WillDisplayProduct event videoId: ${event.videoId}`
|
|
139
|
-
);
|
|
140
|
-
this.handleWillDisplayProductEvent(event);
|
|
141
|
-
});
|
|
142
164
|
this.eventEmitter.addListener(FWEventName.LogMessage, () => {});
|
|
165
|
+
|
|
166
|
+
if (Platform.OS === 'android') {
|
|
167
|
+
this.eventEmitter.addListener(
|
|
168
|
+
FWEventName.CustomLinkButtonClick,
|
|
169
|
+
(event) => {
|
|
170
|
+
FWLoggerUtil.log(
|
|
171
|
+
`Receive CustomLinkButtonClick event url: ${event?.url}`
|
|
172
|
+
);
|
|
173
|
+
this.handleCustomLinkButtonClickEvent(event);
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
143
177
|
}
|
|
144
178
|
|
|
145
179
|
/**
|
|
@@ -183,16 +217,9 @@ class VideoShopping {
|
|
|
183
217
|
}
|
|
184
218
|
}
|
|
185
219
|
|
|
186
|
-
private async handleClickCartIconEvent(
|
|
220
|
+
private async handleClickCartIconEvent() {
|
|
187
221
|
if (this.onCustomClickCartIcon) {
|
|
188
222
|
this.onCustomClickCartIcon();
|
|
189
|
-
} else if (this.onClickCartIcon) {
|
|
190
|
-
const callbackId = event.callbackId;
|
|
191
|
-
delete event.callbackId;
|
|
192
|
-
const props = await this.onClickCartIcon();
|
|
193
|
-
if (callbackId) {
|
|
194
|
-
ShoppingModule.jumpToCartPage(callbackId, props ?? {});
|
|
195
|
-
}
|
|
196
223
|
}
|
|
197
224
|
}
|
|
198
225
|
|
|
@@ -246,18 +273,11 @@ class VideoShopping {
|
|
|
246
273
|
}
|
|
247
274
|
}
|
|
248
275
|
|
|
249
|
-
private async
|
|
250
|
-
event:
|
|
276
|
+
private async handleCustomLinkButtonClickEvent(
|
|
277
|
+
event: CustomClickLinkButtonEvent
|
|
251
278
|
) {
|
|
252
|
-
if (this.
|
|
253
|
-
|
|
254
|
-
delete event.callbackId;
|
|
255
|
-
const config = await this.onWillDisplayProduct(
|
|
256
|
-
event as WillDisplayProductEvent
|
|
257
|
-
);
|
|
258
|
-
if (config && callbackId) {
|
|
259
|
-
ShoppingModule.updateProductViewConfig(config, callbackId);
|
|
260
|
-
}
|
|
279
|
+
if (this.onCustomClickLinkButton) {
|
|
280
|
+
this.onCustomClickLinkButton(event);
|
|
261
281
|
}
|
|
262
282
|
}
|
|
263
283
|
}
|
|
@@ -52,7 +52,7 @@ export interface IStoryBlockProps {
|
|
|
52
52
|
*/
|
|
53
53
|
dynamicContentParameters?: { [key: string]: string[] };
|
|
54
54
|
/**
|
|
55
|
-
* Specifies if Picture in Picture is enabled.
|
|
55
|
+
* Specifies if Picture in Picture is enabled.
|
|
56
56
|
*/
|
|
57
57
|
enablePictureInPicture?: boolean;
|
|
58
58
|
/**
|
|
@@ -61,6 +61,9 @@ export interface IStoryBlockProps {
|
|
|
61
61
|
onStoryBlockLoadFinished?: (error?: FWError) => void;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Only supported on iOS.
|
|
66
|
+
*/
|
|
64
67
|
export default class StoryBlock extends React.Component<IStoryBlockProps> {
|
|
65
68
|
nativeComponentRef = React.createRef<any>();
|
|
66
69
|
|
|
@@ -29,7 +29,7 @@ export interface IVideoFeedProps {
|
|
|
29
29
|
*/
|
|
30
30
|
style?: StyleProp<ViewStyle>;
|
|
31
31
|
/**
|
|
32
|
-
* One of five available video feed sources.
|
|
32
|
+
* One of five available video feed sources.The playlistGroup is only supported on iOS
|
|
33
33
|
*/
|
|
34
34
|
source: VideoFeedSource;
|
|
35
35
|
/**
|
|
@@ -41,7 +41,7 @@ export interface IVideoFeedProps {
|
|
|
41
41
|
*/
|
|
42
42
|
playlist?: string;
|
|
43
43
|
/**
|
|
44
|
-
* PlaylistGroup id of the feed. Required when the source is set as playlistGroup.
|
|
44
|
+
* PlaylistGroup id of the feed. Required when the source is set as playlistGroup. Only supported on iOS.
|
|
45
45
|
*/
|
|
46
46
|
playlistGroup?: string;
|
|
47
47
|
/**
|
|
@@ -65,7 +65,11 @@ export interface IVideoFeedProps {
|
|
|
65
65
|
*/
|
|
66
66
|
adConfiguration?: AdConfiguration;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Specifies if Picture in Picture is enabled.
|
|
69
|
+
*/
|
|
70
|
+
enablePictureInPicture?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The feed loading result callback. It means loading successfully when error equals to undefined. Only supported on iOS.
|
|
69
73
|
*/
|
|
70
74
|
onVideoFeedLoadFinished?: (error?: FWError) => void;
|
|
71
75
|
}
|
|
@@ -171,6 +175,7 @@ export default class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
|
171
175
|
playlistGroup = '',
|
|
172
176
|
mode = 'row',
|
|
173
177
|
adConfiguration,
|
|
178
|
+
enablePictureInPicture = false,
|
|
174
179
|
} = this.props;
|
|
175
180
|
const videoFeedConfiguration = this._getVideoFeedConfiguration();
|
|
176
181
|
const titleHidden = videoFeedConfiguration?.title?.hidden ?? false;
|
|
@@ -185,8 +190,12 @@ export default class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
|
185
190
|
const dynamicContentParametersString =
|
|
186
191
|
this._generateDynamicContentParametersString();
|
|
187
192
|
const enableAutoplay = videoFeedConfiguration?.enableAutoplay ?? false;
|
|
188
|
-
|
|
189
|
-
|
|
193
|
+
|
|
194
|
+
let enablePictureInPictureLegacy = false;
|
|
195
|
+
if (videoFeedConfiguration) {
|
|
196
|
+
enablePictureInPictureLegacy =
|
|
197
|
+
(videoFeedConfiguration as any).enablePictureInPicture ?? false;
|
|
198
|
+
}
|
|
190
199
|
const gridColumns = videoFeedConfiguration?.gridColumns ?? 2;
|
|
191
200
|
const requiresAds = adConfiguration?.requiresAds ?? false;
|
|
192
201
|
const adsFetchTimeout = adConfiguration?.adsFetchTimeout ?? 10;
|
|
@@ -208,6 +217,7 @@ export default class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
|
208
217
|
key += `_dynamicContentParameters:${dynamicContentParametersString}`;
|
|
209
218
|
key += `_enableAutoplay:${enableAutoplay}`;
|
|
210
219
|
key += `_enablePictureInPicture:${enablePictureInPicture}`;
|
|
220
|
+
key += `_enablePictureInPictureLegacy:${enablePictureInPictureLegacy}`;
|
|
211
221
|
key += `_gridColumns:${gridColumns}`;
|
|
212
222
|
key += `_requiresAds:${requiresAds}`;
|
|
213
223
|
key += `_adsFetchTimeout:${adsFetchTimeout}`;
|
|
@@ -23,22 +23,29 @@ import type FeedItemDetails from './models/FeedItemDetails';
|
|
|
23
23
|
import type FWError from './models/FWError';
|
|
24
24
|
import type {
|
|
25
25
|
AddToCartEvent,
|
|
26
|
+
CustomClickLinkButtonEvent,
|
|
26
27
|
CustomCTAClickEvent,
|
|
27
28
|
LiveStreamChatEvent,
|
|
28
29
|
LiveStreamEvent,
|
|
29
30
|
SDKInitEvent,
|
|
30
31
|
UpdateProductDetailsEvent,
|
|
31
32
|
VideoPlaybackEvent,
|
|
32
|
-
WillDisplayProductEvent,
|
|
33
33
|
} from './models/FWEvents';
|
|
34
|
+
import type IOSFontInfo from './models/IOSFontInfo';
|
|
35
|
+
import type {
|
|
36
|
+
IOSSystemFontStyle,
|
|
37
|
+
IOSSystemFontWeight,
|
|
38
|
+
} from './models/IOSFontInfo';
|
|
34
39
|
import LiveStreamChatEventName from './models/LiveStreamChatEventName';
|
|
35
40
|
import type LiveStreamEventDetails from './models/LiveStreamEventDetails';
|
|
36
41
|
import LiveStreamEventName from './models/LiveStreamEventName';
|
|
37
42
|
import type LiveStreamMessageDetails from './models/LiveStreamMessageDetails';
|
|
38
|
-
import type { NewNativeContainerProps } from './models/NewNativeContainerProps';
|
|
39
43
|
import type Product from './models/Product';
|
|
40
44
|
import type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';
|
|
41
|
-
import type {
|
|
45
|
+
import type {
|
|
46
|
+
AddToCartButtonConfiguration,
|
|
47
|
+
LinkButtonConfiguration,
|
|
48
|
+
} from './models/ProductInfoViewConfiguration';
|
|
42
49
|
import type ProductUnit from './models/ProductUnit';
|
|
43
50
|
import type { ProductPrice, ProductUnitOption } from './models/ProductUnit';
|
|
44
51
|
import type { StoryBlockSource } from './models/StoryBlockSource';
|
|
@@ -65,10 +72,9 @@ import type {
|
|
|
65
72
|
} from './models/VideoPlayerConfiguration';
|
|
66
73
|
import type {
|
|
67
74
|
AddToCartCallback,
|
|
68
|
-
ClickCartIconCallback,
|
|
69
75
|
CustomClickCartIconCallback,
|
|
76
|
+
CustomClickLinkButtonCallback,
|
|
70
77
|
UpdateProductDetailsCallback,
|
|
71
|
-
WillDisplayProductCallback,
|
|
72
78
|
} from './VideoShopping';
|
|
73
79
|
import VideoShopping from './VideoShopping';
|
|
74
80
|
|
|
@@ -82,14 +88,19 @@ export {
|
|
|
82
88
|
AddToCartCallback,
|
|
83
89
|
AddToCartEvent,
|
|
84
90
|
AddToCartResult,
|
|
85
|
-
ClickCartIconCallback,
|
|
86
91
|
CustomClickCartIconCallback,
|
|
92
|
+
CustomClickLinkButtonCallback,
|
|
93
|
+
CustomClickLinkButtonEvent,
|
|
87
94
|
CustomCTAClickCallback,
|
|
88
95
|
CustomCTAClickEvent,
|
|
89
96
|
FeedItemDetails,
|
|
90
97
|
FWError,
|
|
91
98
|
FWNavigator,
|
|
99
|
+
IOSFontInfo,
|
|
100
|
+
IOSSystemFontStyle,
|
|
101
|
+
IOSSystemFontWeight,
|
|
92
102
|
IVideoFeedProps,
|
|
103
|
+
LinkButtonConfiguration,
|
|
93
104
|
LiveStream,
|
|
94
105
|
LiveStreamChatEvent,
|
|
95
106
|
LiveStreamChatEventName,
|
|
@@ -97,7 +108,6 @@ export {
|
|
|
97
108
|
LiveStreamEventDetails,
|
|
98
109
|
LiveStreamEventName,
|
|
99
110
|
LiveStreamMessageDetails,
|
|
100
|
-
NewNativeContainerProps,
|
|
101
111
|
onLiveStreamChatEventCallback,
|
|
102
112
|
onLiveStreamEventCallback,
|
|
103
113
|
Product,
|
|
@@ -135,6 +145,4 @@ export {
|
|
|
135
145
|
VideoPlayerSize,
|
|
136
146
|
VideoPlayerStyle,
|
|
137
147
|
VideoShopping,
|
|
138
|
-
WillDisplayProductCallback,
|
|
139
|
-
WillDisplayProductEvent,
|
|
140
148
|
};
|
|
@@ -6,10 +6,10 @@ export enum FWEventName {
|
|
|
6
6
|
AddToCart = 'fw:shopping:add-to-cart',
|
|
7
7
|
ClickCartIcon = 'fw:shopping:click-cart-icon',
|
|
8
8
|
UpdateProductDetails = 'fw:shopping:update-product-details',
|
|
9
|
-
WillDisplayProduct = 'fw:shopping:will-display-product',
|
|
10
9
|
LiveStream = 'fw:livestream',
|
|
11
10
|
LiveStreamChat = 'fw:livestream-chat',
|
|
12
11
|
ShareBaseURLUpdated = 'fw:share-base-url-updated',
|
|
13
12
|
AdBadgeConfigurationUpdated = 'fw:ad-badge-configuration-updated',
|
|
14
13
|
LogMessage = 'fw:log-message',
|
|
14
|
+
CustomLinkButtonClick = 'fw:shopping:custom-link-button-click',
|
|
15
15
|
}
|
package/src/models/FWEvents.ts
CHANGED
|
@@ -48,13 +48,6 @@ export interface UpdateProductDetailsEvent {
|
|
|
48
48
|
productIds: string[];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export interface WillDisplayProductEvent {
|
|
52
|
-
/**
|
|
53
|
-
* A unique identifier of the video.
|
|
54
|
-
*/
|
|
55
|
-
videoId: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
51
|
export interface LiveStreamEvent {
|
|
59
52
|
eventName: LiveStreamEventName;
|
|
60
53
|
info: LiveStreamEventDetails;
|
|
@@ -65,3 +58,9 @@ export interface LiveStreamChatEvent {
|
|
|
65
58
|
message: LiveStreamMessageDetails;
|
|
66
59
|
liveStream: LiveStreamEventDetails;
|
|
67
60
|
}
|
|
61
|
+
|
|
62
|
+
export interface CustomClickLinkButtonEvent {
|
|
63
|
+
url: string;
|
|
64
|
+
productId: string;
|
|
65
|
+
unitId: string;
|
|
66
|
+
}
|