react-native-firework-sdk 1.8.0 → 1.9.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/android/build.gradle +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWLanguageUtil.kt +47 -14
- package/ios/Components/StoryBlock.swift +33 -2
- package/ios/Components/StoryBlockManager.m +32 -0
- package/ios/Components/VideoFeed.swift +10 -29
- package/ios/Components/VideoFeedManager.m +11 -6
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +378 -204
- package/ios/Models/NativeToRN/FireworkEventName.swift +3 -1
- package/ios/Models/RNToNative/RCTConvert+Shopping.swift +21 -0
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +27 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +23 -5
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +31 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +13 -0
- package/ios/Modules/Shopping/ShoppingCTAResult.swift +16 -0
- package/ios/Modules/Shopping/ShoppingModule.m +2 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +103 -30
- package/ios/Support/MultiHostStreaming/FWMultiHostStreaming.podspec +24 -0
- package/ios/Support/MultiHostStreaming/src/MultiHostStreamingSDK.swift +17 -0
- package/ios/Utils/AppLanguage/Bundle+FWSwizzle.swift +58 -0
- package/ios/Utils/AppLanguage/FWAppLanguageManager.swift +139 -0
- package/ios/Utils/AppLanguage/FWLanguageUtil.swift +43 -0
- package/ios/Utils/AppLanguage/NumberFormatter+FWSwizzle.swift +25 -0
- package/ios/Utils/AppLanguage/UIImageView+FWSwizzle.swift +91 -0
- package/ios/Utils/AppLanguage/UILabel+FWSwizzle.swift +98 -0
- package/ios/Utils/AppLanguage/UITextField+FWSwizzle.swift +97 -0
- package/ios/Utils/AppLanguage/UITextView+FWSwizzle.swift +97 -0
- package/ios/Utils/AppLanguage/UIView+FWSwizzle.swift +38 -0
- package/ios/Utils/AppLanguage/UIViewController+FWSwizzle.swift +32 -0
- package/ios/Utils/AppLanguage/UIWindow+FWSwizzle.swift +26 -0
- package/ios/Utils/AppLanguage/URLSession+FWSwizzle.swift +69 -0
- package/ios/Utils/{DispatchQueue+FWOnce.swift → Extensions/DispatchQueue+FWOnce.swift} +3 -3
- package/ios/Utils/{UINavigationController+FWSwizzle.swift → Extensions/Swizzle/UINavigationController+FWSwizzle.swift} +6 -8
- package/ios/Utils/Extensions/UIView+FWUIHierarchy.swift +47 -0
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.h +25 -0
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.m +75 -0
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.h +21 -0
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.m +124 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.h +11 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.m +86 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.h +16 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.m +55 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.h +18 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.m +39 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.h +54 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.m +141 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.h +16 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.m +20 -0
- package/ios/Utils/FWRTL/Classes/Utils/FWRTLDefinitions.h +52 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.h +19 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.m +49 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.h +21 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.m +38 -0
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.h +18 -0
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.m +43 -0
- package/ios/Utils/FWSwizzleLoader.m +6 -1
- package/ios/Utils/FWSwizzleLoader.swift +13 -0
- package/ios/Utils/FWSwizzleUtil.swift +17 -9
- package/ios/react_native_firework_sdk.h +1 -0
- package/ios/scripts/react_native_firework_sdk_pods.rb +31 -0
- package/lib/commonjs/FWNavigator.js +2 -2
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +31 -6
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +71 -22
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +156 -106
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +37 -11
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +2 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/ShoppingCTAResult.js +2 -0
- package/lib/commonjs/models/ShoppingCTAResult.js.map +1 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FWNavigator.js +5 -2
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +31 -6
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +70 -23
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +146 -103
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +41 -10
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +2 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/ShoppingCTAResult.js +2 -0
- package/lib/module/models/ShoppingCTAResult.js.map +1 -0
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FWNavigator.d.ts +6 -3
- package/lib/typescript/FireworkSDK.d.ts +20 -7
- package/lib/typescript/LiveStream.d.ts +2 -2
- package/lib/typescript/VideoShopping.d.ts +32 -11
- package/lib/typescript/components/StoryBlock.d.ts +21 -11
- package/lib/typescript/components/VideoFeed.d.ts +21 -5
- package/lib/typescript/index.d.ts +7 -4
- package/lib/typescript/models/AdBadgeConfiguration.d.ts +1 -1
- package/lib/typescript/models/AddToCartResult.d.ts +4 -0
- package/lib/typescript/models/FWEventName.d.ts +2 -0
- package/lib/typescript/models/FWEvents.d.ts +27 -0
- package/lib/typescript/models/IOSFontInfo.d.ts +2 -2
- package/lib/typescript/models/NewNativeContainerProps.d.ts +1 -1
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +35 -0
- package/lib/typescript/models/ShoppingCTAResult.d.ts +11 -0
- package/lib/typescript/models/StoryBlockSource.d.ts +1 -1
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +4 -3
- package/lib/typescript/models/VideoFeedSource.d.ts +1 -1
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +7 -5
- package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -2
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -0
- package/package.json +10 -6
- package/react-native-firework-sdk.podspec +26 -24
- package/src/FWNavigator.ts +6 -3
- package/src/FireworkSDK.ts +27 -8
- package/src/VideoShopping.ts +110 -41
- package/src/components/StoryBlock.tsx +158 -84
- package/src/components/VideoFeed.tsx +38 -9
- package/src/index.ts +21 -0
- package/src/models/AddToCartResult.ts +4 -0
- package/src/models/FWEventName.ts +2 -0
- package/src/models/FWEvents.ts +28 -0
- package/src/models/ProductInfoViewConfiguration.ts +37 -0
- package/src/models/ShoppingCTAResult.ts +11 -0
- package/src/models/VideoFeedConfiguration.ts +3 -2
- package/src/models/VideoPlayerConfiguration.ts +3 -1
- package/src/modules/FireworkSDKModule.ts +1 -2
- package/src/modules/ShoppingModule.ts +6 -1
- package/ios/Utils/UIView+ParentViewController.swift +0 -21
- /package/ios/Utils/{String+Color.swift → Extensions/String+Color.swift} +0 -0
- /package/ios/Utils/{UIView+Constraints.swift → Extensions/UIView+Constraints.swift} +0 -0
- /package/ios/Utils/{UIViewController+AttachChild.swift → Extensions/UIViewController+AttachChild.swift} +0 -0
|
@@ -13,6 +13,7 @@ exports.FWEventName = FWEventName;
|
|
|
13
13
|
FWEventName["VideoPlayback"] = "fw:video-playback";
|
|
14
14
|
FWEventName["VideoFeedClick"] = "fw:video-feed-click";
|
|
15
15
|
FWEventName["AddToCart"] = "fw:shopping:add-to-cart";
|
|
16
|
+
FWEventName["ShoppingCTAButtonClick"] = "fw:shopping:cta-button-click";
|
|
16
17
|
FWEventName["ClickCartIcon"] = "fw:shopping:click-cart-icon";
|
|
17
18
|
FWEventName["UpdateProductDetails"] = "fw:shopping:update-product-details";
|
|
18
19
|
FWEventName["WillDisplayProduct"] = "fw:shopping:will-display-product";
|
|
@@ -20,6 +21,7 @@ exports.FWEventName = FWEventName;
|
|
|
20
21
|
FWEventName["LiveStreamChat"] = "fw:livestream-chat";
|
|
21
22
|
FWEventName["ShareBaseURLUpdated"] = "fw:share-base-url-updated";
|
|
22
23
|
FWEventName["AdBadgeConfigurationUpdated"] = "fw:ad-badge-configuration-updated";
|
|
24
|
+
FWEventName["AppLanguageUpdated"] = "fw:app-language-updated";
|
|
23
25
|
FWEventName["LogMessage"] = "fw:log-message";
|
|
24
26
|
FWEventName["CustomLinkButtonClick"] = "fw:shopping:custom-link-button-click";
|
|
25
27
|
})(FWEventName || (exports.FWEventName = FWEventName = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FWEventName.ts"],"names":["FWEventName"],"mappings":";;;;;;IAAYA,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["export enum FWEventName {\n SDKInit = 'fw:sdk-init',\n CustomCTAClick = 'fw:custom-cta-click',\n VideoPlayback = 'fw:video-playback',\n VideoFeedClick = 'fw:video-feed-click',\n AddToCart = 'fw:shopping:add-to-cart',\n ClickCartIcon = 'fw:shopping:click-cart-icon',\n UpdateProductDetails = 'fw:shopping:update-product-details',\n WillDisplayProduct = 'fw:shopping:will-display-product',\n LiveStream = 'fw:livestream',\n LiveStreamChat = 'fw:livestream-chat',\n ShareBaseURLUpdated = 'fw:share-base-url-updated',\n AdBadgeConfigurationUpdated = 'fw:ad-badge-configuration-updated',\n LogMessage = 'fw:log-message',\n CustomLinkButtonClick = 'fw:shopping:custom-link-button-click',\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["FWEventName.ts"],"names":["FWEventName"],"mappings":";;;;;;IAAYA,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["export enum FWEventName {\n SDKInit = 'fw:sdk-init',\n CustomCTAClick = 'fw:custom-cta-click',\n VideoPlayback = 'fw:video-playback',\n VideoFeedClick = 'fw:video-feed-click',\n AddToCart = 'fw:shopping:add-to-cart',\n ShoppingCTAButtonClick = 'fw:shopping:cta-button-click',\n ClickCartIcon = 'fw:shopping:click-cart-icon',\n UpdateProductDetails = 'fw:shopping:update-product-details',\n WillDisplayProduct = 'fw:shopping:will-display-product',\n LiveStream = 'fw:livestream',\n LiveStreamChat = 'fw:livestream-chat',\n ShareBaseURLUpdated = 'fw:share-base-url-updated',\n AdBadgeConfigurationUpdated = 'fw:ad-badge-configuration-updated',\n AppLanguageUpdated = 'fw:app-language-updated',\n LogMessage = 'fw:log-message',\n CustomLinkButtonClick = 'fw:shopping:custom-link-button-click',\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FireworkSDKModule.ts"],"names":["FireworkSDKModule","NativeModules","FireworkSDK","Proxy","get","Error","LINKING_ERROR","FireworkSDKModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAIA;;AAIA,MAAMA,iBAAiB,GAAGC,2BAAcC,WAAd,GACtBD,2BAAcC,WADQ,GAEtB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUC,6BAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;
|
|
1
|
+
{"version":3,"sources":["FireworkSDKModule.ts"],"names":["FireworkSDKModule","NativeModules","FireworkSDK","Proxy","get","Error","LINKING_ERROR","FireworkSDKModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAIA;;AAIA,MAAMA,iBAAiB,GAAGC,2BAAcC,WAAd,GACtBD,2BAAcC,WADQ,GAEtB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUC,6BAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAwBA,MAAMC,6BAA6B,GAAG,IAAIC,+BAAJ,CAAuBR,iBAAvB,CAAtC;;eAEeA,iB","sourcesContent":["import { NativeEventEmitter, NativeModule } from 'react-native';\nimport { NativeModules } from 'react-native';\nimport type AdBadgeConfiguration from '../models/AdBadgeConfiguration';\n\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\nimport type VideoPlayerConfiguration from '../models/VideoPlayerConfiguration';\nimport type TrackPurchaseParameters from '../models/TrackPurchaseParameters';\n\nconst FireworkSDKModule = NativeModules.FireworkSDK\n ? NativeModules.FireworkSDK\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\ninterface IFireworkSDKModule extends NativeModule {\n init(userId?: string): void;\n openVideoPlayer(url: string, config?: VideoPlayerConfiguration): void;\n setCustomCTAClickEnabled(enabled: boolean): void;\n setCustomCTALinkContentPageRouteName(name?: string): Promise<any>;\n setShareBaseURL(url?: string): Promise<any>;\n setVideoPlaybackEventEnabled(enabled: boolean): void;\n setAdBadgeConfiguration(config?: AdBadgeConfiguration): Promise<any>;\n setAppComponentName(name?: string): Promise<any>;\n trackPurchase(parameters: TrackPurchaseParameters): void;\n changeAppLanguage(language?: string | null): Promise<boolean>;\n}\n\nconst FireworkSDKModuleEventEmitter = new NativeEventEmitter(FireworkSDKModule);\nexport { FireworkSDKModuleEventEmitter };\nexport default FireworkSDKModule as IFireworkSDKModule;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ShoppingModule.ts"],"names":["ShoppingModule","NativeModules","Proxy","get","Error","LINKING_ERROR","ShoppingModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAEA;;
|
|
1
|
+
{"version":3,"sources":["ShoppingModule.ts"],"names":["ShoppingModule","NativeModules","Proxy","get","Error","LINKING_ERROR","ShoppingModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAEA;;AAMA,MAAMA,cAAc,GAAGC,2BAAcD,cAAd,GACnBC,2BAAcD,cADK,GAEnB,IAAIE,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUC,6BAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAmCA,MAAMC,0BAA0B,GAAG,IAAIC,+BAAJ,CAAuBP,cAAvB,CAAnC;;eAGeA,c","sourcesContent":["import { NativeEventEmitter, NativeModule, NativeModules } from 'react-native';\n\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\nimport type { NewNativeContainerProps } from '../models/NewNativeContainerProps';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport type ShoppingCTAResult from '../models/ShoppingCTAResult';\n\nconst ShoppingModule = NativeModules.ShoppingModule\n ? NativeModules.ShoppingModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\ninterface IShoppingModule extends NativeModule {\n init(): void;\n updateVideoProducts(products: Product[], callbackId: number | string): void;\n updateAddToCartStatus(\n res: string,\n tips: string,\n callbackId: number | string\n ): void;\n updateShoppingCTAResult(\n result: ShoppingCTAResult,\n callbackId: number | string\n ): void; // Only supported on iOS\n jumpToCartPage(\n callbackId: number | string,\n props: NewNativeContainerProps\n ): void;\n setCartIconVisible(visible: boolean): void;\n setCartItemCount(count: number): void;\n setCustomClickCartIconEnabled(enabled: boolean): Promise<void>; // Only supported on iOS\n clearCallbackId(callbackId: number | string, eventName: string): void; // Only supported on iOS\n setProductInfoViewConfiguration(config: ProductInfoViewConfiguration): void; // Only supported on iOS\n setCustomClickLinkButtonEnabled(enabled: boolean): Promise<void>;\n}\n\nconst ShoppingModuleEventEmitter = new NativeEventEmitter(ShoppingModule);\nexport { ShoppingModuleEventEmitter };\n\nexport default ShoppingModule as IShoppingModule;\n"]}
|
|
@@ -4,6 +4,9 @@ import { Platform } from 'react-native';
|
|
|
4
4
|
import { FWEventName } from './models/FWEventName';
|
|
5
5
|
import FWNavigatorModule, { FWNavigatorModuleEventEmitter } from './modules/FWNavigatorModule';
|
|
6
6
|
import FWLoggerUtil from './utils/FWLoggerUtil';
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated The type will be deprecated since RN SDK V2.0.
|
|
9
|
+
*/
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* You can use this class for pushing RN page from the native page.
|
|
@@ -27,7 +30,7 @@ class FWNavigator {
|
|
|
27
30
|
* @param {FWNativeContainerProps} props We will pass the props to your app component.
|
|
28
31
|
* @returns {Promise<boolean>} The result of pushing RN page from native page.
|
|
29
32
|
*
|
|
30
|
-
* @deprecated The
|
|
33
|
+
* @deprecated The method will be deprecated since RN SDK V2.0.
|
|
31
34
|
*/
|
|
32
35
|
|
|
33
36
|
|
|
@@ -49,7 +52,7 @@ class FWNavigator {
|
|
|
49
52
|
* @returns {Promise<boolean>} If the result is true,
|
|
50
53
|
* we could call popNativeContainer to pop top-most native container.
|
|
51
54
|
*
|
|
52
|
-
* @deprecated The
|
|
55
|
+
* @deprecated The method will be deprecated since RN SDK V2.0.
|
|
53
56
|
*/
|
|
54
57
|
|
|
55
58
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FWNavigator.ts"],"names":["Platform","FWEventName","FWNavigatorModule","FWNavigatorModuleEventEmitter","FWLoggerUtil","FWNavigator","getInstance","_instance","constructor","log","addListener","LogMessage","pushNativeContainer","props","popNativeContainer","canPopNativeContainer","startFloatingPlayer","OS","stopFloatingPlayer"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AACA,SAASC,WAAT,QAA4B,sBAA5B;AACA,OAAOC,iBAAP,IACEC,6BADF,QAEO,6BAFP;AAGA,OAAOC,YAAP,MAAyB,sBAAzB;;
|
|
1
|
+
{"version":3,"sources":["FWNavigator.ts"],"names":["Platform","FWEventName","FWNavigatorModule","FWNavigatorModuleEventEmitter","FWLoggerUtil","FWNavigator","getInstance","_instance","constructor","log","addListener","LogMessage","pushNativeContainer","props","popNativeContainer","canPopNativeContainer","startFloatingPlayer","OS","stopFloatingPlayer"],"mappings":";;AAAA,SAASA,QAAT,QAAyB,cAAzB;AACA,SAASC,WAAT,QAA4B,sBAA5B;AACA,OAAOC,iBAAP,IACEC,6BADF,QAEO,6BAFP;AAGA,OAAOC,YAAP,MAAyB,sBAAzB;AAEA;AACA;AACA;;AAKA;AACA;AACA;AACA,MAAMC,WAAN,CAAkB;AAGS,SAAXC,WAAW,GAAgB;AACvC,QAAI,CAACD,WAAW,CAACE,SAAjB,EAA4B;AAC1BF,MAAAA,WAAW,CAACE,SAAZ,GAAwB,IAAIF,WAAJ,EAAxB;AACD;;AACD,WAAOA,WAAW,CAACE,SAAnB;AACD;;AAEOC,EAAAA,WAAW,GAAG;AACpBJ,IAAAA,YAAY,CAACK,GAAb,CAAiB,yBAAjB;AACAN,IAAAA,6BAA6B,CAACO,WAA9B,CAA0CT,WAAW,CAACU,UAAtD,EAAkE,MAAM,CAAE,CAA1E;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;AACSC,EAAAA,mBAAmB,CAACC,KAAD,EAAkD;AAC1ET,IAAAA,YAAY,CAACK,GAAb,CAAkB,8BAAlB;AAEA,WAAOP,iBAAiB,CAACU,mBAAlB,CAAsCC,KAAtC,CAAP;AACD;AAED;AACF;AACA;AACA;;;AACSC,EAAAA,kBAAkB,GAAqB;AAC5C,WAAOZ,iBAAiB,CAACY,kBAAlB,EAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACSC,EAAAA,qBAAqB,GAAqB;AAC/C,WAAOb,iBAAiB,CAACa,qBAAlB,EAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACkC,QAAnBC,mBAAmB,GAAqB;AACnD,QAAIhB,QAAQ,CAACiB,EAAT,KAAgB,KAApB,EAA2B;AACzB,aAAOf,iBAAiB,CAACc,mBAAlB,EAAP;AACD;;AAED,WAAO,IAAP;AACD;AAED;AACF;AACA;;;AACiC,QAAlBE,kBAAkB,GAAkB;AAC/C,QAAIlB,QAAQ,CAACiB,EAAT,KAAgB,KAApB,EAA2B;AACzB,YAAMf,iBAAiB,CAACgB,kBAAlB,EAAN;AACD;AACF;;AApEe;;gBAAZb,W;;AAuEN,eAAeA,WAAf","sourcesContent":["import { Platform } from 'react-native';\nimport { FWEventName } from './models/FWEventName';\nimport FWNavigatorModule, {\n FWNavigatorModuleEventEmitter,\n} from './modules/FWNavigatorModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\n/**\n * @deprecated The type will be deprecated since RN SDK V2.0.\n */\nexport type FWNativeContainerProps = {\n [key: string]: any;\n};\n\n/**\n * You can use this class for pushing RN page from the native page.\n */\nclass FWNavigator {\n private static _instance?: FWNavigator;\n\n public static getInstance(): FWNavigator {\n if (!FWNavigator._instance) {\n FWNavigator._instance = new FWNavigator();\n }\n return FWNavigator._instance!;\n }\n\n private constructor() {\n FWLoggerUtil.log('FWNavigator constructor');\n FWNavigatorModuleEventEmitter.addListener(FWEventName.LogMessage, () => {});\n }\n\n /**\n * Push a new native container. We will render your app component in new native container.\n * Please set your app component name through FireworkSDK.getInstance().appComponentName before calling this method\n * @param {FWNativeContainerProps} props We will pass the props to your app component.\n * @returns {Promise<boolean>} The result of pushing RN page from native page.\n *\n * @deprecated The method will be deprecated since RN SDK V2.0.\n */\n public pushNativeContainer(props: FWNativeContainerProps): Promise<boolean> {\n FWLoggerUtil.log(`Enter pushNewNativeContainer`);\n\n return FWNavigatorModule.pushNativeContainer(props);\n }\n\n /**\n * Pop top-most native container.\n * @returns {Promise<boolean>} The result of poping top-most native container.\n */\n public popNativeContainer(): Promise<boolean> {\n return FWNavigatorModule.popNativeContainer();\n }\n\n /**\n * Indicate if we can pop top-most native container.\n * @returns {Promise<boolean>} If the result is true,\n * we could call popNativeContainer to pop top-most native container.\n *\n * @deprecated The method will be deprecated since RN SDK V2.0.\n */\n public canPopNativeContainer(): Promise<boolean> {\n return FWNavigatorModule.canPopNativeContainer();\n }\n\n /**\n * Change current fullscreen player to floating player.\n * @returns {Promise<boolean>} If the result is true, it means that the fullscreen\n * player is changed to floating player. Only supported on iOS.\n */\n public async startFloatingPlayer(): Promise<boolean> {\n if (Platform.OS === 'ios') {\n return FWNavigatorModule.startFloatingPlayer();\n }\n\n return true;\n }\n\n /**\n * Stop current floating player. Only supported on iOS.\n */\n public async stopFloatingPlayer(): Promise<void> {\n if (Platform.OS === 'ios') {\n await FWNavigatorModule.stopFloatingPlayer();\n }\n }\n}\n\nexport default FWNavigator;\n"]}
|
|
@@ -37,10 +37,16 @@ class FireworkSDK {
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* The custom CTA link content page route name.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated The get accessor will be deprecated since RN SDK V2.0.
|
|
40
42
|
*/
|
|
41
43
|
get customCTALinkContentPageRouteName() {
|
|
42
44
|
return this._customCTALinkContentPageRouteName;
|
|
43
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated The set accessor will be deprecated since RN SDK V2.0.
|
|
48
|
+
*/
|
|
49
|
+
|
|
44
50
|
|
|
45
51
|
set customCTALinkContentPageRouteName(value) {
|
|
46
52
|
this._customCTALinkContentPageRouteName = value;
|
|
@@ -101,16 +107,26 @@ class FireworkSDK {
|
|
|
101
107
|
|
|
102
108
|
/**
|
|
103
109
|
* The app component name.
|
|
110
|
+
*
|
|
111
|
+
* @deprecated The get accessor will be deprecated since RN SDK V2.0.
|
|
104
112
|
*/
|
|
105
113
|
get appComponentName() {
|
|
106
114
|
return this._appComponentName;
|
|
107
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* @deprecated The set accessor will be deprecated since RN SDK V2.0.
|
|
118
|
+
*/
|
|
119
|
+
|
|
108
120
|
|
|
109
121
|
set appComponentName(value) {
|
|
110
122
|
this._appComponentName = value;
|
|
111
123
|
FireworkSDKModule.setAppComponentName(value !== null && value !== void 0 ? value : '');
|
|
112
124
|
}
|
|
113
125
|
|
|
126
|
+
get appLanguage() {
|
|
127
|
+
return this._appLanguage;
|
|
128
|
+
}
|
|
129
|
+
|
|
114
130
|
/**
|
|
115
131
|
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
116
132
|
*/
|
|
@@ -177,6 +193,8 @@ class FireworkSDK {
|
|
|
177
193
|
|
|
178
194
|
_defineProperty(this, "_appComponentName", void 0);
|
|
179
195
|
|
|
196
|
+
_defineProperty(this, "_appLanguage", void 0);
|
|
197
|
+
|
|
180
198
|
_defineProperty(this, "_shopping", VideoShopping.getInstance());
|
|
181
199
|
|
|
182
200
|
_defineProperty(this, "_liveStream", LiveStream.getInstance());
|
|
@@ -250,19 +268,26 @@ class FireworkSDK {
|
|
|
250
268
|
}
|
|
251
269
|
}
|
|
252
270
|
/**
|
|
253
|
-
* Change App level language.
|
|
254
|
-
* @param {string} language Such as en, ar and en-US
|
|
271
|
+
* Change App level language.
|
|
272
|
+
* @param {string | undefined | null} language Such as en, ar and en-US
|
|
273
|
+
* If language is null or undefined or empty string, we will use system language.
|
|
255
274
|
* @returns
|
|
256
275
|
*/
|
|
257
276
|
|
|
258
277
|
|
|
259
278
|
async changeAppLanguage(language) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
279
|
+
const result = await FireworkSDKModule.changeAppLanguage(language);
|
|
280
|
+
|
|
281
|
+
if (result) {
|
|
282
|
+
const valueHasChanged = this._appLanguage !== language;
|
|
283
|
+
this._appLanguage = language;
|
|
284
|
+
|
|
285
|
+
if (valueHasChanged) {
|
|
286
|
+
this.eventEmitter.emit(FWEventName.AppLanguageUpdated);
|
|
287
|
+
}
|
|
263
288
|
}
|
|
264
289
|
|
|
265
|
-
return
|
|
290
|
+
return result;
|
|
266
291
|
}
|
|
267
292
|
|
|
268
293
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FireworkSDK.ts"],"names":["Platform","FWNavigator","LiveStream","FWEventName","FireworkSDKModule","FireworkSDKModuleEventEmitter","LiveStreamModule","ShoppingModule","FWLoggerUtil","VideoShopping","FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","log","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","valueHasChanged","eventEmitter","emit","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","badgeTextType","backgroundColor","textColor","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","debugLogsEnabled","enabled","shopping","_shopping","liveStream","_liveStream","navigator","_navigator","getInstance","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","openVideoPlayer","config","trackPurchase","parameters","OS","changeAppLanguage","language","result"],"mappings":";;AAAA,SAA6BA,QAA7B,QAA6C,cAA7C;AAEA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AASA,OAAOC,iBAAP,IACEC,6BADF,QAEO,6BAFP;AAGA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,YAAP,MAAyB,sBAAzB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;;AAOA;AACA;AACA;AACA,MAAMC,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AAC6B,MAAhBC,gBAAgB,GAAuC;AAChE,WAAO,KAAKC,iBAAZ;AACD;;AAC0B,MAA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AiD;AACrElE,IAAAA,iBAAiB,CAACiE,eAAlB,CAAkCT,GAAlC,EAAuCU,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;AAED;AACF;AACA;AACA;;;AACSC,EAAAA,aAAa,CAACC,UAAD,EAAsC;AACxD,QAAIxE,QAAQ,CAACyE,EAAT,KAAgB,KAApB,EAA2B;AACzBrE,MAAAA,iBAAiB,CAACmE,aAAlB,CAAgCC,UAAhC;AACD;AACF;AAED;AACF;AACA;AACA;AACA;;;AACgC,QAAjBE,iBAAiB,CAACC,QAAD,EAAqC;AACjE,QAAI3E,QAAQ,CAACyE,EAAT,KAAgB,SAApB,EAA+B;AAC7B,YAAMG,MAAM,GAAG,MAAMxE,iBAAiB,CAACsE,iBAAlB,CAAoCC,QAApC,CAArB;AACA,aAAOC,MAAP;AACD;;AAED,WAAO,KAAP;AACD;;AA5Oe;;gBAAZlE,W;;AA+ON,eAAeA,WAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport FWNavigator from './FWNavigator';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type TrackPurchaseParameters from './models/TrackPurchaseParameters';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport VideoShopping from './VideoShopping';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n * The set accessor is async.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n const valueHasChanged = this._shareBaseURL !== value;\n this._shareBaseURL = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n }\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n * The set accessor is async.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n const valueHasChanged =\n this._adBadgeConfiguration?.badgeTextType !== value?.badgeTextType ||\n this._adBadgeConfiguration?.backgroundColor !==\n value?.backgroundColor ||\n this._adBadgeConfiguration?.textColor !== value?.textColor;\n this._adBadgeConfiguration = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n }\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n /**\n * Defaults to false. You can enable debug logs by setting this property to true.\n */\n public get debugLogsEnabled(): boolean {\n return FWLoggerUtil.enabled;\n }\n public set debugLogsEnabled(value: boolean) {\n FWLoggerUtil.enabled = value;\n }\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return this._shopping;\n }\n private _shopping: VideoShopping = VideoShopping.getInstance();\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return this._liveStream;\n }\n private _liveStream: LiveStream = LiveStream.getInstance();\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return this._navigator;\n }\n private _navigator: FWNavigator = FWNavigator.getInstance();\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n FWLoggerUtil.log('FireworkSDK constructor');\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(\n `Receive VideoPlayback event eventName: ${event?.eventName}`\n );\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FWLoggerUtil.log('Call FireworkSDK init method');\n\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n\n /**\n * Records the user purchase. Only supported on iOS.\n * @param {TrackPurchaseParameters} parameters\n */\n public trackPurchase(parameters: TrackPurchaseParameters) {\n if (Platform.OS === 'ios') {\n FireworkSDKModule.trackPurchase(parameters);\n }\n }\n\n /**\n * Change App level language. Only supported on Android.\n * @param {string} language Such as en, ar and en-US\n * @returns\n */\n public async changeAppLanguage(language: string): Promise<boolean> {\n if (Platform.OS === 'android') {\n const result = await FireworkSDKModule.changeAppLanguage(language);\n return result;\n }\n\n return false;\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
1
|
+
{"version":3,"sources":["FireworkSDK.ts"],"names":["Platform","FWNavigator","LiveStream","FWEventName","FireworkSDKModule","FireworkSDKModuleEventEmitter","LiveStreamModule","ShoppingModule","FWLoggerUtil","VideoShopping","FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","log","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","valueHasChanged","eventEmitter","emit","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","badgeTextType","backgroundColor","textColor","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","appLanguage","_appLanguage","debugLogsEnabled","enabled","shopping","_shopping","liveStream","_liveStream","navigator","_navigator","getInstance","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","openVideoPlayer","config","trackPurchase","parameters","OS","changeAppLanguage","language","result","AppLanguageUpdated"],"mappings":";;AAAA,SAA6BA,QAA7B,QAA6C,cAA7C;AAEA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AASA,OAAOC,iBAAP,IACEC,6BADF,QAEO,6BAFP;AAGA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,YAAP,MAAyB,sBAAzB;AACA,OAAOC,aAAP,MAA0B,iBAA1B;;AAOA;AACA;AACA;AACA,MAAMC,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AAC6B,MAAhBC,gBAAgB,GAAuC;AAChE,WAA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AACA/D,IAAAA,cAAc,CAAC8D,IAAf;AACA/D,IAAAA,gBAAgB,CAAC+D,IAAjB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSE,EAAAA,eAAe,CAACT,GAAD,EAAcU,MAAd,EAAiD;AACrEpE,IAAAA,iBAAiB,CAACmE,eAAlB,CAAkCT,GAAlC,EAAuCU,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;AAED;AACF;AACA;AACA;;;AACSC,EAAAA,aAAa,CAACC,UAAD,EAAsC;AACxD,QAAI1E,QAAQ,CAAC2E,EAAT,KAAgB,KAApB,EAA2B;AACzBvE,MAAAA,iBAAiB,CAACqE,aAAlB,CAAgCC,UAAhC;AACD;AACF;AAED;AACF;AACA;AACA;AACA;AACA;;;AACgC,QAAjBE,iBAAiB,CAACC,QAAD,EAA6C;AACzE,UAAMC,MAAM,GAAG,MAAM1E,iBAAiB,CAACwE,iBAAlB,CAAoCC,QAApC,CAArB;;AACA,QAAIC,MAAJ,EAAY;AACV,YAAMpD,eAAe,GAAG,KAAKe,YAAL,KAAsBoC,QAA9C;AACA,WAAKpC,YAAL,GAAoBoC,QAApB;;AACA,UAAInD,eAAJ,EAAqB;AACnB,aAAKC,YAAL,CAAkBC,IAAlB,CAAuBzB,WAAW,CAAC4E,kBAAnC;AACD;AACF;;AACD,WAAOD,MAAP;AACD;;AA/Pe;;gBAAZpE,W;;AAkQN,eAAeA,WAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport FWNavigator from './FWNavigator';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type TrackPurchaseParameters from './models/TrackPurchaseParameters';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport VideoShopping from './VideoShopping';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n *\n * @deprecated The get accessor will be deprecated since RN SDK V2.0.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n /**\n * @deprecated The set accessor will be deprecated since RN SDK V2.0.\n */\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n * The set accessor is async.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n const valueHasChanged = this._shareBaseURL !== value;\n this._shareBaseURL = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n }\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n * The set accessor is async.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n const valueHasChanged =\n this._adBadgeConfiguration?.badgeTextType !== value?.badgeTextType ||\n this._adBadgeConfiguration?.backgroundColor !==\n value?.backgroundColor ||\n this._adBadgeConfiguration?.textColor !== value?.textColor;\n this._adBadgeConfiguration = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n }\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n *\n * @deprecated The get accessor will be deprecated since RN SDK V2.0.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n /**\n * @deprecated The set accessor will be deprecated since RN SDK V2.0.\n */\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n public get appLanguage(): string | undefined | null {\n return this._appLanguage;\n }\n private _appLanguage: string | undefined | null;\n\n /**\n * Defaults to false. You can enable debug logs by setting this property to true.\n */\n public get debugLogsEnabled(): boolean {\n return FWLoggerUtil.enabled;\n }\n public set debugLogsEnabled(value: boolean) {\n FWLoggerUtil.enabled = value;\n }\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return this._shopping;\n }\n private _shopping: VideoShopping = VideoShopping.getInstance();\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return this._liveStream;\n }\n private _liveStream: LiveStream = LiveStream.getInstance();\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return this._navigator;\n }\n private _navigator: FWNavigator = FWNavigator.getInstance();\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n FWLoggerUtil.log('FireworkSDK constructor');\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(\n `Receive VideoPlayback event eventName: ${event?.eventName}`\n );\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FWLoggerUtil.log('Call FireworkSDK init method');\n\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n\n /**\n * Records the user purchase. Only supported on iOS.\n * @param {TrackPurchaseParameters} parameters\n */\n public trackPurchase(parameters: TrackPurchaseParameters) {\n if (Platform.OS === 'ios') {\n FireworkSDKModule.trackPurchase(parameters);\n }\n }\n\n /**\n * Change App level language.\n * @param {string | undefined | null} language Such as en, ar and en-US\n * If language is null or undefined or empty string, we will use system language.\n * @returns\n */\n public async changeAppLanguage(language?: string | null): Promise<boolean> {\n const result = await FireworkSDKModule.changeAppLanguage(language);\n if (result) {\n const valueHasChanged = this._appLanguage !== language;\n this._appLanguage = language;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AppLanguageUpdated);\n }\n }\n return result;\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
@@ -14,6 +14,12 @@ class VideoShopping {
|
|
|
14
14
|
*
|
|
15
15
|
* The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.
|
|
16
16
|
* If the host apps want to customize the processing logic of clicking "Add to cart" button, they could return null or undefined in the callback.
|
|
17
|
+
* @deprecated The callback will be deprecated since RN SDK V2.1.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This callback is triggered when the user clicks the "Add to cart" or "Shop now" button.
|
|
22
|
+
* The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.
|
|
17
23
|
*/
|
|
18
24
|
|
|
19
25
|
/**
|
|
@@ -21,6 +27,8 @@ class VideoShopping {
|
|
|
21
27
|
*
|
|
22
28
|
* The host app can return NewNativeContainerProps object
|
|
23
29
|
* and we will push a new native container with the props.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated The property will be deprecated since RN SDK V2.0.
|
|
24
32
|
*/
|
|
25
33
|
|
|
26
34
|
/**
|
|
@@ -55,8 +63,9 @@ class VideoShopping {
|
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
/**
|
|
58
|
-
* The
|
|
59
|
-
*
|
|
66
|
+
* The configuration of product info view.
|
|
67
|
+
* Please refer to {@link ProductInfoViewConfiguration} for more details.
|
|
68
|
+
* Only supported on iOS.
|
|
60
69
|
*/
|
|
61
70
|
get productInfoViewConfiguration() {
|
|
62
71
|
return this._productInfoViewConfiguration;
|
|
@@ -83,10 +92,7 @@ class VideoShopping {
|
|
|
83
92
|
|
|
84
93
|
set onCustomClickLinkButton(value) {
|
|
85
94
|
this._onCustomClickLinkButton = value;
|
|
86
|
-
|
|
87
|
-
if (Platform.OS === 'android') {
|
|
88
|
-
ShoppingModule.setCustomClickLinkButtonEnabled(!!value);
|
|
89
|
-
}
|
|
95
|
+
ShoppingModule.setCustomClickLinkButtonEnabled(!!value);
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
get eventEmitter() {
|
|
@@ -106,6 +112,8 @@ class VideoShopping {
|
|
|
106
112
|
constructor() {
|
|
107
113
|
_defineProperty(this, "onAddToCart", void 0);
|
|
108
114
|
|
|
115
|
+
_defineProperty(this, "onShoppingCTA", void 0);
|
|
116
|
+
|
|
109
117
|
_defineProperty(this, "onClickCartIcon", void 0);
|
|
110
118
|
|
|
111
119
|
_defineProperty(this, "_onCustomClickCartIcon", void 0);
|
|
@@ -120,10 +128,20 @@ class VideoShopping {
|
|
|
120
128
|
|
|
121
129
|
_defineProperty(this, "_onCustomClickLinkButton", void 0);
|
|
122
130
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
if (Platform.OS === 'android') {
|
|
132
|
+
this.eventEmitter.addListener(FWEventName.AddToCart, event => {
|
|
133
|
+
FWLoggerUtil.log(`Receive AddToCart event productId: ${event === null || event === void 0 ? void 0 : event.productId} unitId: ${event === null || event === void 0 ? void 0 : event.unitId}`);
|
|
134
|
+
this.handleShoppingCTAEvent(event);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (Platform.OS === 'ios') {
|
|
139
|
+
this.eventEmitter.addListener(FWEventName.ShoppingCTAButtonClick, event => {
|
|
140
|
+
FWLoggerUtil.log(`Receive ShoppingCTA event productId: ${event === null || event === void 0 ? void 0 : event.productId} unitId: ${event === null || event === void 0 ? void 0 : event.unitId} url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
141
|
+
this.handleShoppingCTAEvent(event);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
127
145
|
this.eventEmitter.addListener(FWEventName.ClickCartIcon, event => {
|
|
128
146
|
FWLoggerUtil.log('Receive ClickCartIcon event');
|
|
129
147
|
this.handleClickCartIconEvent(event);
|
|
@@ -137,13 +155,10 @@ class VideoShopping {
|
|
|
137
155
|
this.handleWillDisplayProductEvent(event);
|
|
138
156
|
});
|
|
139
157
|
this.eventEmitter.addListener(FWEventName.LogMessage, () => {});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
143
|
-
|
|
144
|
-
this.handleCustomLinkButtonClickEvent(event);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
158
|
+
this.eventEmitter.addListener(FWEventName.CustomLinkButtonClick, event => {
|
|
159
|
+
FWLoggerUtil.log(`Receive CustomLinkButtonClick event url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
160
|
+
this.handleCustomLinkButtonClickEvent(event);
|
|
161
|
+
});
|
|
147
162
|
}
|
|
148
163
|
/**
|
|
149
164
|
*
|
|
@@ -159,28 +174,60 @@ class VideoShopping {
|
|
|
159
174
|
ShoppingModule.setCartItemCount(count);
|
|
160
175
|
}
|
|
161
176
|
|
|
162
|
-
async
|
|
177
|
+
async handleShoppingCTAEvent(event) {
|
|
178
|
+
var _this$productInfoView, _this$productInfoView2;
|
|
179
|
+
|
|
163
180
|
const callbackId = event.callbackId;
|
|
164
181
|
delete event.callbackId;
|
|
182
|
+
let isShopNowCTA = false;
|
|
183
|
+
|
|
184
|
+
if (Platform.OS === 'ios' && ((_this$productInfoView = this.productInfoViewConfiguration) === null || _this$productInfoView === void 0 ? void 0 : (_this$productInfoView2 = _this$productInfoView.ctaButton) === null || _this$productInfoView2 === void 0 ? void 0 : _this$productInfoView2.text) === 'shopNow') {
|
|
185
|
+
isShopNowCTA = true;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (this.onShoppingCTA) {
|
|
189
|
+
const result = await this.onShoppingCTA(event);
|
|
190
|
+
|
|
191
|
+
if (callbackId) {
|
|
192
|
+
if (Platform.OS === 'ios') {
|
|
193
|
+
ShoppingModule.updateShoppingCTAResult(result, callbackId);
|
|
194
|
+
} else {
|
|
195
|
+
if (result.tips) {
|
|
196
|
+
ShoppingModule.updateAddToCartStatus(result.res, result.tips, callbackId);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} else if (this.onAddToCart && !isShopNowCTA) {
|
|
201
|
+
if (event.url) {
|
|
202
|
+
delete event.url;
|
|
203
|
+
}
|
|
165
204
|
|
|
166
|
-
if (this.onAddToCart) {
|
|
167
205
|
const result = await this.onAddToCart(event);
|
|
168
206
|
|
|
169
207
|
if (result) {
|
|
170
208
|
if (callbackId) {
|
|
171
|
-
|
|
209
|
+
if (Platform.OS === 'ios') {
|
|
210
|
+
ShoppingModule.updateShoppingCTAResult({
|
|
211
|
+
res: result.res,
|
|
212
|
+
tips: result.tips
|
|
213
|
+
}, callbackId);
|
|
214
|
+
} else {
|
|
215
|
+
var _result$tips;
|
|
216
|
+
|
|
217
|
+
ShoppingModule.updateAddToCartStatus(result.res, (_result$tips = result.tips) !== null && _result$tips !== void 0 ? _result$tips : '', callbackId);
|
|
218
|
+
}
|
|
172
219
|
}
|
|
173
220
|
} else {
|
|
174
221
|
if (callbackId) {
|
|
175
222
|
if (Platform.OS === 'ios') {
|
|
176
|
-
ShoppingModule.clearCallbackId(callbackId, FWEventName.
|
|
223
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.ShoppingCTAButtonClick);
|
|
177
224
|
}
|
|
178
225
|
}
|
|
179
226
|
}
|
|
180
227
|
} else {
|
|
181
228
|
if (callbackId) {
|
|
182
229
|
if (Platform.OS === 'ios') {
|
|
183
|
-
ShoppingModule.clearCallbackId(callbackId, FWEventName.
|
|
230
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.ShoppingCTAButtonClick);
|
|
184
231
|
}
|
|
185
232
|
}
|
|
186
233
|
}
|
|
@@ -242,7 +289,7 @@ class VideoShopping {
|
|
|
242
289
|
const config = await this.onWillDisplayProduct(event);
|
|
243
290
|
|
|
244
291
|
if (config) {
|
|
245
|
-
|
|
292
|
+
this.productInfoViewConfiguration = config;
|
|
246
293
|
}
|
|
247
294
|
}
|
|
248
295
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["Platform","FWEventName","ShoppingModule","ShoppingModuleEventEmitter","FWLoggerUtil","VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","OS","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","productInfoViewConfiguration","_productInfoViewConfiguration","setProductInfoViewConfiguration","onCustomClickLinkButton","_onCustomClickLinkButton","setCustomClickLinkButtonEnabled","eventEmitter","getInstance","log","_instance","constructor","addListener","AddToCart","event","productId","unitId","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","WillDisplayProduct","videoId","handleWillDisplayProductEvent","LogMessage","CustomLinkButtonClick","url","handleCustomLinkButtonClickEvent","setCartItemCount","count","callbackId","onAddToCart","result","updateAddToCartStatus","res","tips","clearCallbackId","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","map","product","length","updateVideoProducts","onWillDisplayProduct","config"],"mappings":";;AAAA,SAA6B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,OADiB,CAAnB;AAIAxB,MAAAA,YAAY,CAACkB,GAAb,CACG,+DAA8DY,UAAW,uBACxE,CAACsB,WAAW,IAAI,EAAhB,EAAoBG,MACrB,EAHH;;AAMA,UAAIH,WAAJ,EAAiB;AACf,YAAIX,UAAJ,EAAgB;AACd3C,UAAAA,cAAc,CAAC0D,mBAAf,CAAmCJ,WAAnC,EAAgDX,UAAhD;AACD;AACF,OAJD,MAIO;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAI7C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,YAAAA,cAAc,CAACiD,eAAf,CACEN,UADF,EAEE5C,WAAW,CAACgC,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACL7B,MAAAA,YAAY,CAACkB,GAAb,CAAiB,6CAAjB;;AACA,UAAIuB,UAAJ,EAAgB;AACd,YAAI7C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,UAAAA,cAAc,CAACiD,eAAf,CACEN,UADF,EAEE5C,WAAW,CAACgC,oBAFd;AAID;AACF;AACF;AACF;;AAE0C,QAA7BK,6BAA6B,CACzCX,KADyC,EAEzC;AACA,QAAI,KAAKkC,oBAAT,EAA+B;AAC7B,aAAOlC,KAAK,CAACkB,UAAb;AACA,YAAMiB,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBlC,KADmB,CAArB;;AAGA,UAAImC,MAAJ,EAAY;AACV5D,QAAAA,cAAc,CAACc,+BAAf,CAA+C8C,MAA/C;AACD;AACF;AACF;;AAE6C,QAAhCpB,gCAAgC,CAC5Cf,KAD4C,EAE5C;AACA,QAAI,KAAKV,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6BU,KAA7B;AACD;AACF;;AAhSiB;;gBAAdtB,a;;AAmSN,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n CustomClickLinkButtonEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\nexport type CustomClickLinkButtonCallback = (\n event: CustomClickLinkButtonEvent\n) => Promise<void>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\n * If the host apps want to customize the processing logic of clicking \"Add to cart\" button, they could return null or undefined in the callback.\n */\n public onAddToCart?: AddToCartCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can return NewNativeContainerProps object\n * and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the click event processing logic of\n * the shopping cart icon by setting the callback.\n */\n public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {\n return this._onCustomClickCartIcon;\n }\n public set onCustomClickCartIcon(\n value: CustomClickCartIconCallback | undefined\n ) {\n this._onCustomClickCartIcon = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomClickCartIconEnabled(!!value);\n }\n }\n private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product list to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * Please use productInfoViewConfiguration property. Only supported on iOS.\n *\n * @deprecated The property will be deprecated since RN SDK V2.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n /**\n * Defaults to true.\n * You can hide the cart icon by setting this property to false.\n */\n public get cartIconVisible(): boolean {\n return this._cartIconVisible;\n }\n public set cartIconVisible(value: boolean) {\n this._cartIconVisible = value;\n ShoppingModule.setCartIconVisible(value);\n }\n private _cartIconVisible: boolean = true;\n\n /**\n * The host app can use this property to configure \"Add to cart\" button style\n * and hide the link button next to \"Add to cart\" button. Only supported on iOS.\n */\n public get productInfoViewConfiguration():\n | ProductInfoViewConfiguration\n | undefined {\n return this._productInfoViewConfiguration;\n }\n\n public set productInfoViewConfiguration(\n value: ProductInfoViewConfiguration | undefined\n ) {\n this._productInfoViewConfiguration = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n }\n }\n\n private _productInfoViewConfiguration?:\n | ProductInfoViewConfiguration\n | undefined;\n\n /**\n * This callback is triggered when the user clicks\n * the link button next to Add to cart button. Only supported on Android.\n *\n * The host app can customize the click event processing logic of\n * the link button by setting the callback.\n */\n public get onCustomClickLinkButton():\n | CustomClickLinkButtonCallback\n | undefined {\n return this._onCustomClickLinkButton;\n }\n public set onCustomClickLinkButton(\n value: CustomClickLinkButtonCallback | undefined\n ) {\n this._onCustomClickLinkButton = value;\n if (Platform.OS === 'android') {\n ShoppingModule.setCustomClickLinkButtonEnabled(!!value);\n }\n }\n private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n FWLoggerUtil.log(\n `Receive AddToCart event productId: ${event?.productId} unitId: ${event?.unitId}`\n );\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event?.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n FWLoggerUtil.log(\n `Receive WillDisplayProduct event videoId: ${event?.videoId}`\n );\n this.handleWillDisplayProductEvent(event);\n });\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n\n if (Platform.OS === 'android') {\n this.eventEmitter.addListener(\n FWEventName.CustomLinkButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive CustomLinkButtonClick event url: ${event?.url}`\n );\n this.handleCustomLinkButtonClickEvent(event);\n }\n );\n }\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart.\n * The count should be greater than or equal to 0.\n * We just use count to show or hide red indicator on the cart icon.\n * If cound > 0, we will show the red indicator on the cart icon.\n * Otherwise, we will hide the red indicator on the cart icon.\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onAddToCart) {\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n if (callbackId) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId\n );\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.setProductInfoViewConfiguration(config);\n }\n }\n }\n\n private async handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
|
1
|
+
{"version":3,"sources":["VideoShopping.ts"],"names":["Platform","FWEventName","ShoppingModule","ShoppingModuleEventEmitter","FWLoggerUtil","VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","OS","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","productInfoViewConfiguration","_productInfoViewConfiguration","setProductInfoViewConfiguration","onCustomClickLinkButton","_onCustomClickLinkButton","setCustomClickLinkButtonEnabled","eventEmitter","getInstance","log","_instance","constructor","addListener","AddToCart","event","productId","unitId","handleShoppingCTAEvent","ShoppingCTAButtonClick","url","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","WillDisplayProduct","videoId","handleWillDisplayProductEvent","LogMessage","CustomLinkButtonClick","handleCustomLinkButtonClickEvent","setCartItemCount","count","callbackId","isShopNowCTA","ctaButton","text","onShoppingCTA","result","updateShoppingCTAResult","tips","updateAddToCartStatus","res","onAddToCart","clearCallbackId","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","map","product","length","updateVideoProducts","onWillDisplayProduct","config"],"mappings":";;AAAA,SAA6BA,QAA7B,QAA6C,cAA7C;AAUA,SAASC,WAAT,QAA4B,sBAA5B;AAGA,OAAOC,cAAP,IACEC,0BADF,QAEO,0BAFP;AAIA,OAAOC,YAAP,MAAyB,sBAAzB;;AAsCA;AACA;AACA;AACA,MAAMC,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACkC,MAArBC,qBAAqB,GAA4C;AAC1E,WAAO,KAAKC,sBAAZ;AACD;;AAC+B,MAArBD,qBAAqB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;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAI9C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,YAAAA,cAAc,CAACuD,eAAf,CACEX,UADF,EAEE7C,WAAW,CAACkC,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACL/B,MAAAA,YAAY,CAACkB,GAAb,CAAiB,6CAAjB;;AACA,UAAIwB,UAAJ,EAAgB;AACd,YAAI9C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,UAAAA,cAAc,CAACuD,eAAf,CACEX,UADF,EAEE7C,WAAW,CAACkC,oBAFd;AAID;AACF;AACF;AACF;;AAE0C,QAA7BK,6BAA6B,CAACb,KAAD,EAAa;AACtD,QAAI,KAAKwC,oBAAT,EAA+B;AAC7B,aAAOxC,KAAK,CAACmB,UAAb;AACA,YAAMsB,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBxC,KADmB,CAArB;;AAGA,UAAIyC,MAAJ,EAAY;AACV,aAAKtD,4BAAL,GAAoCsD,MAApC;AACD;AACF;AACF;;AAE6C,QAAhCzB,gCAAgC,CAC5ChB,KAD4C,EAE5C;AACA,QAAI,KAAKV,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6BU,KAA7B;AACD;AACF;;AAxViB;;gBAAdtB,a;;AA2VN,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n CustomClickLinkButtonEvent,\n ShoppingCTAEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport type ShoppingCTAResult from './models/ShoppingCTAResult';\n\n/**\n * @deprecated The type will be deprecated since RN SDK V2.1.\n */\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ShoppingCTACallback = (\n event: ShoppingCTAEvent\n) => Promise<ShoppingCTAResult>;\n\n/**\n * @deprecated The type will be deprecated since RN SDK V2.0.\n */\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\n/**\n * @deprecated The type will be deprecated since RN SDK V2.0.\n */\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\nexport type CustomClickLinkButtonCallback = (\n event: CustomClickLinkButtonEvent\n) => Promise<void>;\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\n * If the host apps want to customize the processing logic of clicking \"Add to cart\" button, they could return null or undefined in the callback.\n * @deprecated The callback will be deprecated since RN SDK V2.1.\n */\n public onAddToCart?: AddToCartCallback;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" or \"Shop now\" button.\n * The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.\n */\n public onShoppingCTA?: ShoppingCTACallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can return NewNativeContainerProps object\n * and we will push a new native container with the props.\n *\n * @deprecated The property will be deprecated since RN SDK V2.0.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the click event processing logic of\n * the shopping cart icon by setting the callback.\n */\n public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {\n return this._onCustomClickCartIcon;\n }\n public set onCustomClickCartIcon(\n value: CustomClickCartIconCallback | undefined\n ) {\n this._onCustomClickCartIcon = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomClickCartIconEnabled(!!value);\n }\n }\n private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product list to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * Please use productInfoViewConfiguration property. Only supported on iOS.\n *\n * @deprecated The property will be deprecated since RN SDK V2.0.\n * Use {@link productInfoViewConfiguration} instead.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n /**\n * Defaults to true.\n * You can hide the cart icon by setting this property to false.\n */\n public get cartIconVisible(): boolean {\n return this._cartIconVisible;\n }\n public set cartIconVisible(value: boolean) {\n this._cartIconVisible = value;\n ShoppingModule.setCartIconVisible(value);\n }\n private _cartIconVisible: boolean = true;\n\n /**\n * The configuration of product info view.\n * Please refer to {@link ProductInfoViewConfiguration} for more details.\n * Only supported on iOS.\n */\n public get productInfoViewConfiguration():\n | ProductInfoViewConfiguration\n | undefined {\n return this._productInfoViewConfiguration;\n }\n\n public set productInfoViewConfiguration(\n value: ProductInfoViewConfiguration | undefined\n ) {\n this._productInfoViewConfiguration = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n }\n }\n\n private _productInfoViewConfiguration?:\n | ProductInfoViewConfiguration\n | undefined;\n\n /**\n * This callback is triggered when the user clicks\n * the link button next to Add to cart button. Only supported on Android.\n *\n * The host app can customize the click event processing logic of\n * the link button by setting the callback.\n */\n public get onCustomClickLinkButton():\n | CustomClickLinkButtonCallback\n | undefined {\n return this._onCustomClickLinkButton;\n }\n public set onCustomClickLinkButton(\n value: CustomClickLinkButtonCallback | undefined\n ) {\n this._onCustomClickLinkButton = value;\n ShoppingModule.setCustomClickLinkButtonEnabled(!!value);\n }\n private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n if (Platform.OS === 'android') {\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n FWLoggerUtil.log(\n `Receive AddToCart event productId: ${event?.productId} unitId: ${event?.unitId}`\n );\n this.handleShoppingCTAEvent(event);\n });\n }\n\n if (Platform.OS === 'ios') {\n this.eventEmitter.addListener(\n FWEventName.ShoppingCTAButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive ShoppingCTA event productId: ${event?.productId} unitId: ${event?.unitId} url: ${event?.url}`\n );\n this.handleShoppingCTAEvent(event);\n }\n );\n }\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event?.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n FWLoggerUtil.log(\n `Receive WillDisplayProduct event videoId: ${event?.videoId}`\n );\n this.handleWillDisplayProductEvent(event);\n });\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n\n this.eventEmitter.addListener(\n FWEventName.CustomLinkButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive CustomLinkButtonClick event url: ${event?.url}`\n );\n this.handleCustomLinkButtonClickEvent(event);\n }\n );\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart.\n * The count should be greater than or equal to 0.\n * We just use count to show or hide red indicator on the cart icon.\n * If cound > 0, we will show the red indicator on the cart icon.\n * Otherwise, we will hide the red indicator on the cart icon.\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleShoppingCTAEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n let isShopNowCTA = false;\n if (\n Platform.OS === 'ios' &&\n this.productInfoViewConfiguration?.ctaButton?.text === 'shopNow'\n ) {\n isShopNowCTA = true;\n }\n\n if (this.onShoppingCTA) {\n const result = await this.onShoppingCTA(event as ShoppingCTAEvent);\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.updateShoppingCTAResult(result, callbackId);\n } else {\n if (result.tips) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId\n );\n }\n }\n }\n } else if (this.onAddToCart && !isShopNowCTA) {\n if (event.url) {\n delete event.url;\n }\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.updateShoppingCTAResult(\n { res: result.res, tips: result.tips },\n callbackId\n );\n } else {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips ?? '',\n callbackId\n );\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.ShoppingCTAButtonClick\n );\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.ShoppingCTAButtonClick\n );\n }\n }\n }\n }\n\n private async handleClickCartIconEvent(event: any) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleWillDisplayProductEvent(event: any) {\n if (this.onWillDisplayProduct) {\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n this.productInfoViewConfiguration = config;\n }\n }\n }\n\n private async handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|