react-native-firework-sdk 2.0.0 → 2.2.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.
Files changed (202) hide show
  1. package/FireworkVideoUI.xcframework/Info.plist +40 -0
  2. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/FireworkVideoUI +0 -0
  3. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +280 -0
  4. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +18 -0
  5. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Info.plist +0 -0
  6. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.abi.json +1327 -0
  7. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.private.swiftinterface +41 -0
  8. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  9. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftinterface +41 -0
  10. package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/module.modulemap +11 -0
  11. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/FireworkVideoUI +0 -0
  12. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +556 -0
  13. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +18 -0
  14. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Info.plist +0 -0
  15. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.abi.json +1327 -0
  16. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +41 -0
  17. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  18. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +41 -0
  19. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.abi.json +1327 -0
  20. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +41 -0
  21. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  22. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +41 -0
  23. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/module.modulemap +11 -0
  24. package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/_CodeSignature/CodeResources +245 -0
  25. package/README.md +1 -1
  26. package/android/build.gradle +5 -4
  27. package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +6 -0
  28. package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/StoryBlockFragment.kt +129 -0
  29. package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/StoryBlockFrameLayout.kt +90 -0
  30. package/android/src/main/java/com/fireworksdk/bridge/models/FWAdBadgeConfigModelDeserializer.kt +3 -3
  31. package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +5 -1
  32. package/android/src/main/java/com/fireworksdk/bridge/models/FWFontInfoModelDeserializer.kt +1 -1
  33. package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfiguration.kt +18 -5
  34. package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfigurationDeserializer.kt +36 -8
  35. package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModelDeserializer.kt +3 -3
  36. package/android/src/main/java/com/fireworksdk/bridge/models/FWShoppingCtaResult.kt +17 -0
  37. package/android/src/main/java/com/fireworksdk/bridge/models/FWShoppingCtaResultDeserializer.kt +33 -0
  38. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModelDeserializer.kt +14 -12
  39. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModel.kt +1 -0
  40. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModelDeserializer.kt +11 -7
  41. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedSource.kt +1 -0
  42. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlaybackDetails.kt +8 -8
  43. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +1 -0
  44. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModelDeserializer.kt +19 -12
  45. package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoShoppingProductDeserializer.kt +11 -11
  46. package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +131 -45
  47. package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +11 -3
  48. package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -2
  49. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWLiveStreamModule.kt +45 -4
  50. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +9 -1
  51. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +83 -50
  52. package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +112 -36
  53. package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +16 -6
  54. package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +26 -32
  55. package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +10 -0
  56. package/android/src/main/java/com/fireworksdk/bridge/utils/FWLanguageUtil.kt +48 -16
  57. package/android/src/main/res/layout/fw_bridge_story_block.xml +24 -0
  58. package/ios/Components/StoryBlock.swift +32 -2
  59. package/ios/Components/StoryBlockManager.m +33 -0
  60. package/ios/Components/StoryBlockManager.swift +4 -0
  61. package/ios/Components/VideoFeed.swift +16 -32
  62. package/ios/Components/VideoFeedManager.m +12 -6
  63. package/ios/Components/VideoFeedManager.swift +4 -0
  64. package/ios/Components/VideoPlayerConfiguration.swift +1 -0
  65. package/ios/FireworkSdk.xcodeproj/project.pbxproj +276 -212
  66. package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.docc/FireworkVideoUI.md +13 -0
  67. package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.h +18 -0
  68. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/AppLanguageManager.swift +147 -0
  69. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/Bundle+AppLanguage.swift +58 -0
  70. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/NumberFormatter+AppLanguage.swift +25 -0
  71. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/URLSession+AppLanguage.swift +69 -0
  72. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIImageView+AppLanguage.swift +91 -0
  73. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UILabel+AppLanguage.swift +98 -0
  74. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextField+AppLanguage.swift +97 -0
  75. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextView+AppLanguage.swift +97 -0
  76. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift +38 -0
  77. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIViewController+AppLanguage.swift +46 -0
  78. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIWindow+AppLanguage.swift +26 -0
  79. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/LanguageUtil.swift +43 -0
  80. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/Foundation/NSObject+LayoutFlip.swift +42 -0
  81. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/CALayer+LayoutFlip.swift +160 -0
  82. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UILabel+LayoutFlip.swift +35 -0
  83. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift +199 -0
  84. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/LayoutFlipManager.swift +59 -0
  85. package/ios/{Utils/DispatchQueue+FWOnce.swift → FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/DispatchQueue+Once.swift} +5 -5
  86. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/String+Base64.swift +18 -0
  87. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/UIKit/UIView+UIHierarchy.swift +46 -0
  88. package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Swizzle.swift +37 -0
  89. package/ios/FireworkVideoUI/FireworkVideoUI.xcodeproj/project.pbxproj +766 -0
  90. package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/contents.xcworkspacedata +10 -0
  91. package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  92. package/ios/FireworkVideoUI/FireworkVideoUITests/FireworkVideoUITests.swift +37 -0
  93. package/ios/FireworkVideoUI/Podfile +15 -0
  94. package/ios/FireworkVideoUI/Podfile.lock +16 -0
  95. package/ios/Models/NativeToRN/FireworkEventName.swift +7 -1
  96. package/ios/Models/NativeToRN/FireworkSDK+Json.swift +5 -1
  97. package/ios/Models/RNToNative/RCTConvert+Shopping.swift +21 -0
  98. package/ios/Models/RNToNative/RCTConvert+StoryBlock.swift +2 -1
  99. package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +29 -1
  100. package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +13 -101
  101. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +34 -16
  102. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
  103. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +48 -2
  104. package/ios/Modules/FireworkSDKModule/SDKInitOptions.swift +0 -1
  105. package/ios/Modules/LiveStream/LiveStreamModule.swift +1 -0
  106. package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +7 -2
  107. package/ios/Modules/Shopping/ShoppingCTAResult.swift +16 -0
  108. package/ios/Modules/Shopping/ShoppingModule.m +2 -1
  109. package/ios/Modules/Shopping/ShoppingModule.swift +92 -34
  110. package/ios/Support/MultiHostStreaming/FWMultiHostStreaming.podspec +22 -0
  111. package/ios/Support/MultiHostStreaming/Sources/MultiHostStreamingSDK.swift +17 -0
  112. package/ios/Utils/{UINavigationController+FWSwizzle.swift → Extensions/Swizzle/UINavigationController+FWSwizzle.swift} +9 -8
  113. package/ios/Utils/FWSwizzleLoader.m +6 -1
  114. package/ios/Utils/FWSwizzleLoader.swift +13 -0
  115. package/ios/react_native_firework_sdk.h +1 -0
  116. package/ios/scripts/react_native_firework_sdk_pods.rb +27 -0
  117. package/lib/commonjs/FireworkSDK.js +55 -15
  118. package/lib/commonjs/FireworkSDK.js.map +1 -1
  119. package/lib/commonjs/LiveStream.js +2 -2
  120. package/lib/commonjs/LiveStream.js.map +1 -1
  121. package/lib/commonjs/VideoShopping.js +21 -38
  122. package/lib/commonjs/VideoShopping.js.map +1 -1
  123. package/lib/commonjs/components/StoryBlock.js +193 -128
  124. package/lib/commonjs/components/StoryBlock.js.map +1 -1
  125. package/lib/commonjs/components/VideoFeed.js +17 -5
  126. package/lib/commonjs/components/VideoFeed.js.map +1 -1
  127. package/lib/commonjs/index.js.map +1 -1
  128. package/lib/commonjs/models/FWEventName.js +3 -0
  129. package/lib/commonjs/models/FWEventName.js.map +1 -1
  130. package/lib/commonjs/models/ShoppingCTAResult.js +2 -0
  131. package/lib/commonjs/models/VideoPlaybackEventName.js +3 -0
  132. package/lib/commonjs/models/VideoPlaybackEventName.js.map +1 -1
  133. package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
  134. package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
  135. package/lib/module/FireworkSDK.js +54 -15
  136. package/lib/module/FireworkSDK.js.map +1 -1
  137. package/lib/module/LiveStream.js +2 -2
  138. package/lib/module/LiveStream.js.map +1 -1
  139. package/lib/module/VideoShopping.js +21 -40
  140. package/lib/module/VideoShopping.js.map +1 -1
  141. package/lib/module/components/StoryBlock.js +183 -133
  142. package/lib/module/components/StoryBlock.js.map +1 -1
  143. package/lib/module/components/VideoFeed.js +16 -5
  144. package/lib/module/components/VideoFeed.js.map +1 -1
  145. package/lib/module/index.js.map +1 -1
  146. package/lib/module/models/FWEventName.js +3 -0
  147. package/lib/module/models/FWEventName.js.map +1 -1
  148. package/lib/module/models/ShoppingCTAResult.js +2 -0
  149. package/lib/module/models/VideoPlaybackEventName.js +3 -0
  150. package/lib/module/models/VideoPlaybackEventName.js.map +1 -1
  151. package/lib/module/modules/FireworkSDKModule.js.map +1 -1
  152. package/lib/module/modules/ShoppingModule.js.map +1 -1
  153. package/lib/typescript/FireworkSDK.d.ts +15 -8
  154. package/lib/typescript/LiveStream.d.ts +2 -2
  155. package/lib/typescript/VideoShopping.d.ts +10 -12
  156. package/lib/typescript/components/StoryBlock.d.ts +25 -24
  157. package/lib/typescript/components/VideoFeed.d.ts +7 -0
  158. package/lib/typescript/index.d.ts +6 -6
  159. package/lib/typescript/models/FWEventName.d.ts +3 -0
  160. package/lib/typescript/models/FWEvents.d.ts +14 -1
  161. package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +12 -8
  162. package/lib/typescript/models/SDKInitOptions.d.ts +6 -1
  163. package/lib/typescript/models/ShoppingCTAResult.d.ts +11 -0
  164. package/lib/typescript/models/StoryBlockSource.d.ts +1 -1
  165. package/lib/typescript/models/VideoFeedSource.d.ts +1 -1
  166. package/lib/typescript/models/VideoPlaybackDetails.d.ts +16 -0
  167. package/lib/typescript/models/VideoPlaybackEventName.d.ts +13 -1
  168. package/lib/typescript/models/VideoPlayerConfiguration.d.ts +4 -0
  169. package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -2
  170. package/lib/typescript/modules/ShoppingModule.d.ts +2 -1
  171. package/package.json +8 -3
  172. package/react-native-firework-sdk.podspec +31 -24
  173. package/src/FireworkSDK.ts +54 -15
  174. package/src/LiveStream.ts +2 -2
  175. package/src/VideoShopping.ts +41 -54
  176. package/src/components/StoryBlock.tsx +210 -98
  177. package/src/components/VideoFeed.tsx +23 -4
  178. package/src/index.ts +15 -9
  179. package/src/models/FWEventName.ts +3 -0
  180. package/src/models/FWEvents.ts +14 -1
  181. package/src/models/ProductInfoViewConfiguration.ts +13 -8
  182. package/src/models/SDKInitOptions.ts +6 -1
  183. package/src/models/ShoppingCTAResult.ts +11 -0
  184. package/src/models/StoryBlockSource.ts +2 -1
  185. package/src/models/VideoFeedSource.ts +2 -1
  186. package/src/models/VideoPlaybackDetails.ts +16 -0
  187. package/src/models/VideoPlaybackEventName.ts +13 -1
  188. package/src/models/VideoPlayerConfiguration.ts +4 -0
  189. package/src/modules/FireworkSDKModule.ts +1 -2
  190. package/src/modules/ShoppingModule.ts +5 -5
  191. package/android/src/main/java/com/fireworksdk/bridge/constants/FWCommandConstant.kt +0 -6
  192. package/ios/Utils/FWSwizzleUtil.swift +0 -29
  193. package/ios/Utils/UIView+ParentViewController.swift +0 -21
  194. package/lib/commonjs/models/AddToCartResult.js +0 -2
  195. package/lib/module/models/AddToCartResult.js +0 -2
  196. package/lib/typescript/models/AddToCartResult.d.ts +0 -10
  197. package/src/models/AddToCartResult.ts +0 -10
  198. /package/ios/Utils/{String+Color.swift → Extensions/String+Color.swift} +0 -0
  199. /package/ios/Utils/{UIView+Constraints.swift → Extensions/UIView+Constraints.swift} +0 -0
  200. /package/ios/Utils/{UIViewController+AttachChild.swift → Extensions/UIViewController+AttachChild.swift} +0 -0
  201. /package/lib/commonjs/models/{AddToCartResult.js.map → ShoppingCTAResult.js.map} +0 -0
  202. /package/lib/module/models/{AddToCartResult.js.map → ShoppingCTAResult.js.map} +0 -0
@@ -10,10 +10,8 @@ import FWLoggerUtil from './utils/FWLoggerUtil';
10
10
  */
11
11
  class VideoShopping {
12
12
  /**
13
- * This callback is triggered when the user clicks the "Add to cart" button.
14
- *
15
- * The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.
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.
13
+ * This callback is triggered when the user clicks the "Add to cart" or "Shop now" button.
14
+ * The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.
17
15
  */
18
16
 
19
17
  /**
@@ -48,8 +46,8 @@ class VideoShopping {
48
46
  }
49
47
 
50
48
  /**
51
- * The host app can use this property to configure "Add to cart" button style
52
- * and hide the link button next to "Add to cart" button. Only supported on iOS.
49
+ * The configuration of product info view.
50
+ * Please refer to {@link ProductInfoViewConfiguration} for more details.
53
51
  */
54
52
  get productInfoViewConfiguration() {
55
53
  return this._productInfoViewConfiguration;
@@ -57,15 +55,12 @@ class VideoShopping {
57
55
 
58
56
  set productInfoViewConfiguration(value) {
59
57
  this._productInfoViewConfiguration = value;
60
-
61
- if (Platform.OS === 'ios') {
62
- ShoppingModule.setProductInfoViewConfiguration(value !== null && value !== void 0 ? value : {});
63
- }
58
+ ShoppingModule.setProductInfoViewConfiguration(value !== null && value !== void 0 ? value : {});
64
59
  }
65
60
 
66
61
  /**
67
62
  * This callback is triggered when the user clicks
68
- * the link button next to Add to cart button. Only supported on Android.
63
+ * the link button next to Add to cart button.
69
64
  *
70
65
  * The host app can customize the click event processing logic of
71
66
  * the link button by setting the callback.
@@ -76,10 +71,7 @@ class VideoShopping {
76
71
 
77
72
  set onCustomClickLinkButton(value) {
78
73
  this._onCustomClickLinkButton = value;
79
-
80
- if (Platform.OS === 'android') {
81
- ShoppingModule.setCustomClickLinkButtonEnabled(!!value);
82
- }
74
+ ShoppingModule.setCustomClickLinkButtonEnabled(!!value);
83
75
  }
84
76
 
85
77
  get eventEmitter() {
@@ -97,7 +89,7 @@ class VideoShopping {
97
89
  }
98
90
 
99
91
  constructor() {
100
- _defineProperty(this, "onAddToCart", void 0);
92
+ _defineProperty(this, "onShoppingCTA", void 0);
101
93
 
102
94
  _defineProperty(this, "_onCustomClickCartIcon", void 0);
103
95
 
@@ -109,9 +101,9 @@ class VideoShopping {
109
101
 
110
102
  _defineProperty(this, "_onCustomClickLinkButton", void 0);
111
103
 
112
- this.eventEmitter.addListener(FWEventName.AddToCart, event => {
113
- 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}`);
114
- this.handleAddToCartEvent(event);
104
+ this.eventEmitter.addListener(FWEventName.ShoppingCTAButtonClick, event => {
105
+ 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}`);
106
+ this.handleShoppingCTAEvent(event);
115
107
  });
116
108
  this.eventEmitter.addListener(FWEventName.ClickCartIcon, () => {
117
109
  FWLoggerUtil.log('Receive ClickCartIcon event');
@@ -122,13 +114,10 @@ class VideoShopping {
122
114
  this.handleUpdateProductDetailsEvent(event);
123
115
  });
124
116
  this.eventEmitter.addListener(FWEventName.LogMessage, () => {});
125
-
126
- if (Platform.OS === 'android') {
127
- this.eventEmitter.addListener(FWEventName.CustomLinkButtonClick, event => {
128
- FWLoggerUtil.log(`Receive CustomLinkButtonClick event url: ${event === null || event === void 0 ? void 0 : event.url}`);
129
- this.handleCustomLinkButtonClickEvent(event);
130
- });
131
- }
117
+ this.eventEmitter.addListener(FWEventName.CustomLinkButtonClick, event => {
118
+ FWLoggerUtil.log(`Receive CustomLinkButtonClick event url: ${event === null || event === void 0 ? void 0 : event.url}`);
119
+ this.handleCustomLinkButtonClickEvent(event);
120
+ });
132
121
  }
133
122
  /**
134
123
  *
@@ -144,28 +133,20 @@ class VideoShopping {
144
133
  ShoppingModule.setCartItemCount(count);
145
134
  }
146
135
 
147
- async handleAddToCartEvent(event) {
136
+ async handleShoppingCTAEvent(event) {
148
137
  const callbackId = event.callbackId;
149
138
  delete event.callbackId;
150
139
 
151
- if (this.onAddToCart) {
152
- const result = await this.onAddToCart(event);
140
+ if (this.onShoppingCTA) {
141
+ const result = await this.onShoppingCTA(event);
153
142
 
154
- if (result) {
155
- if (callbackId) {
156
- ShoppingModule.updateAddToCartStatus(result.res, result.tips, callbackId);
157
- }
158
- } else {
159
- if (callbackId) {
160
- if (Platform.OS === 'ios') {
161
- ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);
162
- }
163
- }
143
+ if (callbackId) {
144
+ ShoppingModule.updateShoppingCTAResult(result, callbackId);
164
145
  }
165
146
  } else {
166
147
  if (callbackId) {
167
148
  if (Platform.OS === 'ios') {
168
- ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);
149
+ ShoppingModule.clearCallbackId(callbackId, FWEventName.ShoppingCTAButtonClick);
169
150
  }
170
151
  }
171
152
  }
@@ -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","LogMessage","CustomLinkButtonClick","url","handleCustomLinkButtonClickEvent","setCartItemCount","count","callbackId","onAddToCart","result","updateAddToCartStatus","res","tips","clearCallbackId","onUpdateProductDetails","productList","map","product","length","updateVideoProducts"],"mappings":";;AAAA,SAA6BA,QAA7B,QAA6C,cAA7C;AAGA,SAASC,WAAT,QAA4B,sBAA5B;AAQA,OAAOC,cAAP,IACEC,0BADF,QAEO,0BAFP;AAGA,OAAOC,YAAP,MAAyB,sBAAzB;;AAgBA;AACA;AACA;AACA,MAAMC,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACkC,MAArBC,qBAAqB,GAA4C;AAC1E,WAAO,KAAKC,sBAAZ;AACD;;AAC+B,MAArBD,q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mDK,KAAK,CAACO,UAAW,gBAAeQ,UAAW,EADjG;AAGA,YAAMQ,WAAW,GAAG,MAAM,KAAKD,sBAAL,CACxBtB,KADwB,CAA1B;AAIA,YAAMO,UAAU,GAAG,CAACgB,WAAW,IAAI,EAAhB,EAAoBC,GAApB,CAChBC,OAAD;AAAA;;AAAA,qCAAaA,OAAO,CAACxB,SAArB,mEAAkC,EAAlC;AAAA,OADiB,CAAnB;AAIAxB,MAAAA,YAAY,CAACkB,GAAb,CACG,+DAA8DY,UAAW,uBACxE,CAACgB,WAAW,IAAI,EAAhB,EAAoBG,MACrB,EAHH;;AAMA,UAAIH,WAAJ,EAAiB;AACf,YAAIR,UAAJ,EAAgB;AACdxC,UAAAA,cAAc,CAACoD,mBAAf,CAAmCJ,WAAnC,EAAgDR,UAAhD;AACD;AACF,OAJD,MAIO;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAI1C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,YAAAA,cAAc,CAAC8C,eAAf,CACEN,UADF,EAEEzC,WAAW,CAACgC,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACL7B,MAAAA,YAAY,CAACkB,GAAb,CAAiB,6CAAjB;;AACA,UAAIoB,UAAJ,EAAgB;AACd,YAAI1C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,UAAAA,cAAc,CAAC8C,eAAf,CACEN,UADF,EAEEzC,WAAW,CAACgC,oBAFd;AAID;AACF;AACF;AACF;;AAE6C,QAAhCM,gCAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAKV,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6BU,KAA7B;AACD;AACF;;AApPiB;;gBAAdtB,a;;AAuPN,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n AddToCartEvent,\n CustomClickLinkButtonEvent,\n UpdateProductDetailsEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | 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 */\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 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 * 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, () => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent();\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.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: any) {\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() {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\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 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","ShoppingCTAButtonClick","event","productId","unitId","url","handleShoppingCTAEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","LogMessage","CustomLinkButtonClick","handleCustomLinkButtonClickEvent","setCartItemCount","count","callbackId","onShoppingCTA","result","updateShoppingCTAResult","clearCallbackId","onUpdateProductDetails","productList","map","product","length","updateVideoProducts"],"mappings":";;AAAA,SAA6BA,QAA7B,QAA6C,cAA7C;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AAQA,OAAOC,cAAP,IACEC,0BADF,QAEO,0BAFP;AAGA,OAAOC,YAAP,MAAyB,sBAAzB;;AAiBA;AACA;AACA;AACA,MAAMC,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACkC,MAArBC,qBAAqB,GAA4C;AAC1E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W,IAAI,EAAhB,EAAoBG,MACrB,EAHH;;AAMA,UAAIH,WAAJ,EAAiB;AACf,YAAIN,UAAJ,EAAgB;AACdxC,UAAAA,cAAc,CAACkD,mBAAf,CAAmCJ,WAAnC,EAAgDN,UAAhD;AACD;AACF,OAJD,MAIO;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAI1C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,YAAAA,cAAc,CAAC4C,eAAf,CACEJ,UADF,EAEEzC,WAAW,CAACiC,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACL9B,MAAAA,YAAY,CAACkB,GAAb,CAAiB,6CAAjB;;AACA,UAAIoB,UAAJ,EAAgB;AACd,YAAI1C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,UAAAA,cAAc,CAAC4C,eAAf,CACEJ,UADF,EAEEzC,WAAW,CAACiC,oBAFd;AAID;AACF;AACF;AACF;;AAE6C,QAAhCK,gCAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAKV,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6BU,KAA7B;AACD;AACF;;AAvOiB;;gBAAdtB,a;;AA0ON,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomClickLinkButtonEvent,\n ShoppingCTAEvent,\n UpdateProductDetailsEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport type ShoppingCTAResult from './models/ShoppingCTAResult';\n\nexport type ShoppingCTACallback = (\n event: ShoppingCTAEvent\n) => Promise<ShoppingCTAResult>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | 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\" 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 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 * 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 */\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 ShoppingModule.setProductInfoViewConfiguration(value ?? {});\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.\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 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 this.eventEmitter.addListener(FWEventName.ClickCartIcon, () => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent();\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.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\n if (this.onShoppingCTA) {\n const result = await this.onShoppingCTA(event as ShoppingCTAEvent);\n if (callbackId) {\n ShoppingModule.updateShoppingCTAResult(result, callbackId);\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() {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\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 handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
@@ -1,9 +1,7 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
-
5
- import React from 'react';
6
- import { findNodeHandle, Platform, UIManager } from 'react-native';
3
+ import React, { forwardRef, useEffect, useImperativeHandle, useReducer, useRef, useState } from 'react';
4
+ import { BackHandler, findNodeHandle, Platform, UIManager } from 'react-native';
7
5
  import FireworkSDK from '../FireworkSDK';
8
6
  import { FWEventName } from '../models/FWEventName';
9
7
  import { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';
@@ -11,152 +9,105 @@ import FWLoggerUtil from '../utils/FWLoggerUtil';
11
9
  import FWStoryBlock from './FWStoryBlock';
12
10
  const NativeComponentName = 'FWStoryBlock';
13
11
 
14
- const createFragment = viewId => {
15
- if (Platform.OS === 'android') {
16
- UIManager.dispatchViewManagerCommand(viewId, UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
17
- }
18
- };
19
- /**
20
- * The props type of StoryBlock component.
21
- */
22
-
23
-
24
- /**
25
- * StoryBlock component. Only supported on iOS.
26
- */
27
- class StoryBlock extends React.Component {
28
- constructor() {
29
- super(...arguments);
30
-
31
- _defineProperty(this, "_nativeComponentRef", /*#__PURE__*/React.createRef());
32
-
33
- _defineProperty(this, "_subscriptions", []);
34
-
35
- _defineProperty(this, "_onStoryBlockLoadFinished", event => {
36
- FWLoggerUtil.log(`StoryBlock _onStoryBlockLoadFinished ${event.nativeEvent.name}`);
37
- const {
38
- onStoryBlockLoadFinished
39
- } = this.props;
40
- const {
41
- name,
42
- reason
43
- } = event.nativeEvent;
44
-
45
- if (onStoryBlockLoadFinished) {
46
- if (name) {
47
- if (reason) {
48
- onStoryBlockLoadFinished({
49
- name,
50
- reason
51
- });
52
- } else {
53
- onStoryBlockLoadFinished({
54
- name
55
- });
56
- }
57
- } else {
58
- onStoryBlockLoadFinished();
59
- }
12
+ const StoryBlock = (props, forwardedRef) => {
13
+ const nativeComponentRef = useRef(null);
14
+ const [isFullscreenState, setIsFullscreenState] = useState(false);
15
+ const [, forceUpdate] = useReducer(x => x + 1, 0);
16
+ useImperativeHandle(forwardedRef, () => {
17
+ const sendCommand = command => {
18
+ const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);
19
+ let commandId = UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
20
+
21
+ if (Platform.OS === 'android') {
22
+ commandId = commandId.toString();
60
23
  }
61
- });
62
- }
63
24
 
64
- /**
65
- * @ignore
66
- */
67
- componentDidMount() {
25
+ UIManager.dispatchViewManagerCommand(findNodeHandle(nativeNodeHandle), commandId, []);
26
+ };
27
+
28
+ return {
29
+ play: () => {
30
+ sendCommand('play');
31
+ },
32
+ pause: () => {
33
+ sendCommand('pause');
34
+ }
35
+ };
36
+ }, []);
37
+ useEffect(() => {
68
38
  const subscriptionOfShareBaseURLUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.ShareBaseURLUpdated, () => {
69
- this.setState({});
39
+ FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');
40
+ forceUpdate();
70
41
  });
71
-
72
- this._subscriptions.push(subscriptionOfShareBaseURLUpdated);
73
-
74
42
  const subscriptionOfAdBadgeConfigurationUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AdBadgeConfigurationUpdated, () => {
75
- this.setState({});
43
+ FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');
44
+ forceUpdate();
76
45
  });
77
-
78
- this._subscriptions.push(subscriptionOfAdBadgeConfigurationUpdated);
79
-
80
46
  const subscriptionOfVideoLaunchBehaviorUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.VideoLaunchBehaviorUpdated, () => {
81
47
  FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
82
- this.setState({});
48
+ forceUpdate();
49
+ });
50
+ const subscriptionOfAppLanguageUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AppLanguageUpdated, () => {
51
+ FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');
52
+ forceUpdate();
83
53
  });
84
-
85
- this._subscriptions.push(subscriptionOfVideoLaunchBehaviorUpdated);
86
54
 
87
55
  if (Platform.OS === 'android') {
88
- const viewId = findNodeHandle(this._nativeComponentRef.current);
89
- FWLoggerUtil.log(`StoryBlock componentDidMount createFragment viewId: ${viewId}`);
90
- createFragment(viewId);
56
+ setTimeout(() => {
57
+ const viewId = findNodeHandle(nativeComponentRef.current);
58
+ FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);
59
+ UIManager.dispatchViewManagerCommand(viewId, UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
60
+ }, 500);
91
61
  }
92
- }
93
- /**
94
- * @ignore
95
- */
96
-
97
-
98
- componentWillUnmount() {
99
- this._subscriptions.forEach(value => {
100
- value.remove();
101
- });
102
62
 
103
- this._subscriptions = [];
104
- }
105
- /**
106
- * @ignore
107
- */
63
+ return () => {
64
+ subscriptionOfShareBaseURLUpdated.remove();
65
+ subscriptionOfAdBadgeConfigurationUpdated.remove();
66
+ subscriptionOfVideoLaunchBehaviorUpdated.remove();
67
+ subscriptionOfAppLanguageUpdated.remove();
68
+ };
69
+ }, []);
108
70
 
109
-
110
- render() {
71
+ const handleStoryBlockLoadFinished = event => {
72
+ FWLoggerUtil.log(`StoryBlock handleStoryBlockLoadFinished ${event.nativeEvent.name}`);
111
73
  const {
112
- style
113
- } = this.props;
114
- return /*#__PURE__*/React.createElement(FWStoryBlock, _extends({
115
- ref: this._nativeComponentRef,
116
- key: this._generateKey()
117
- }, this.props, {
118
- onStoryBlockLoadFinished: this._onStoryBlockLoadFinished,
119
- style: Object.assign({}, style, {
120
- zIndex: -1
121
- })
122
- }));
123
- }
124
-
125
- _generateKey() {
126
- var _FireworkSDK$getInsta, _FireworkSDK$getInsta2, _adBadgeConfiguration, _adBadgeConfiguration2, _adBadgeConfiguration3, _FireworkSDK$getInsta3;
127
-
74
+ onStoryBlockLoadFinished
75
+ } = props;
128
76
  const {
129
- source,
130
- channel = '',
131
- playlist = '',
132
- enablePictureInPicture = false
133
- } = this.props;
134
- const shareBaseURL = (_FireworkSDK$getInsta = FireworkSDK.getInstance().getShareBaseURL()) !== null && _FireworkSDK$getInsta !== void 0 ? _FireworkSDK$getInsta : '';
135
- const adBadgeConfiguration = (_FireworkSDK$getInsta2 = FireworkSDK.getInstance().getAdBadgeConfiguration()) !== null && _FireworkSDK$getInsta2 !== void 0 ? _FireworkSDK$getInsta2 : {};
136
- const adBadgeTextType = (_adBadgeConfiguration = adBadgeConfiguration.badgeTextType) !== null && _adBadgeConfiguration !== void 0 ? _adBadgeConfiguration : '';
137
- const backgroundColorOfAdBadge = (_adBadgeConfiguration2 = adBadgeConfiguration.backgroundColor) !== null && _adBadgeConfiguration2 !== void 0 ? _adBadgeConfiguration2 : '';
138
- const textColorOfAdBadge = (_adBadgeConfiguration3 = adBadgeConfiguration.textColor) !== null && _adBadgeConfiguration3 !== void 0 ? _adBadgeConfiguration3 : '';
139
-
140
- const dynamicContentParametersString = this._generateDynamicContentParametersString();
77
+ name,
78
+ reason
79
+ } = event.nativeEvent;
80
+
81
+ if (onStoryBlockLoadFinished) {
82
+ if (name) {
83
+ if (reason) {
84
+ onStoryBlockLoadFinished({
85
+ name,
86
+ reason
87
+ });
88
+ } else {
89
+ onStoryBlockLoadFinished({
90
+ name
91
+ });
92
+ }
93
+ } else {
94
+ onStoryBlockLoadFinished();
95
+ }
96
+ }
97
+ };
141
98
 
142
- const videoLaunchBehavior = (_FireworkSDK$getInsta3 = FireworkSDK.getInstance().getVideoLaunchBehavior()) !== null && _FireworkSDK$getInsta3 !== void 0 ? _FireworkSDK$getInsta3 : 'default';
143
- let key = `source:${source}`;
144
- key += `_channel:${channel}`;
145
- key += `_playlist:${playlist}`;
146
- key += `_shareBaseURL:${shareBaseURL}`;
147
- key += `_adBadgeTextType:${adBadgeTextType}`;
148
- key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;
149
- key += `_textColorOfAdBadge:${textColorOfAdBadge}`;
150
- key += `_dynamicContentParameters:${dynamicContentParametersString}`;
151
- key += `_enablePictureInPicture:${enablePictureInPicture}`;
152
- key += `_videoLaunchBehavior:${videoLaunchBehavior}`;
153
- return key;
154
- }
99
+ const handleStoryBlockFullscreenStateChanged = event => {
100
+ FWLoggerUtil.log(`StoryBlock handleStoryBlockFullscreenStateChanged ${event.nativeEvent.isFullScreen}`);
101
+ const {
102
+ isFullScreen
103
+ } = event.nativeEvent;
104
+ setIsFullscreenState(isFullScreen);
105
+ };
155
106
 
156
- _generateDynamicContentParametersString() {
107
+ const generateDynamicContentParametersString = () => {
157
108
  const {
158
109
  dynamicContentParameters
159
- } = this.props;
110
+ } = props;
160
111
 
161
112
  if (!dynamicContentParameters) {
162
113
  return '';
@@ -177,9 +128,108 @@ class StoryBlock extends React.Component {
177
128
  }
178
129
 
179
130
  return resultString;
180
- }
131
+ };
181
132
 
182
- }
133
+ const generateVastAttributesString = () => {
134
+ var _adConfiguration$vast;
135
+
136
+ const {
137
+ adConfiguration
138
+ } = props;
139
+ const vastAttributes = (_adConfiguration$vast = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.vastAttributes) !== null && _adConfiguration$vast !== void 0 ? _adConfiguration$vast : '';
140
+
141
+ if (!vastAttributes) {
142
+ return '';
143
+ }
144
+
145
+ let resultString = '';
146
+
147
+ for (const attribute of vastAttributes) {
148
+ var _attribute$name;
149
+
150
+ if (resultString.length > 0) {
151
+ resultString += '_';
152
+ }
153
+
154
+ resultString += `${(_attribute$name = attribute.name) !== null && _attribute$name !== void 0 ? _attribute$name : ''}:${attribute.value}`;
155
+ }
156
+
157
+ return resultString;
158
+ };
159
+
160
+ const generateKey = () => {
161
+ var _FireworkSDK$getInsta, _FireworkSDK$getInsta2, _FireworkSDK$getInsta3, _adBadgeConfiguration, _adBadgeConfiguration2, _adBadgeConfiguration3, _FireworkSDK$getInsta4, _adConfiguration$requ, _adConfiguration$adsF;
162
+
163
+ const {
164
+ source,
165
+ channel = '',
166
+ playlist = '',
167
+ enablePictureInPicture = false,
168
+ adConfiguration,
169
+ hashtagFilterExpression = ''
170
+ } = props;
171
+ const gShareBaseURL = (_FireworkSDK$getInsta = FireworkSDK.getInstance().shareBaseURL) !== null && _FireworkSDK$getInsta !== void 0 ? _FireworkSDK$getInsta : '';
172
+ const videoLaunchBehavior = (_FireworkSDK$getInsta2 = FireworkSDK.getInstance().videoLaunchBehavior) !== null && _FireworkSDK$getInsta2 !== void 0 ? _FireworkSDK$getInsta2 : 'default';
173
+ const adBadgeConfiguration = (_FireworkSDK$getInsta3 = FireworkSDK.getInstance().getAdBadgeConfiguration()) !== null && _FireworkSDK$getInsta3 !== void 0 ? _FireworkSDK$getInsta3 : {};
174
+ const adBadgeTextType = (_adBadgeConfiguration = adBadgeConfiguration.badgeTextType) !== null && _adBadgeConfiguration !== void 0 ? _adBadgeConfiguration : '';
175
+ const backgroundColorOfAdBadge = (_adBadgeConfiguration2 = adBadgeConfiguration.backgroundColor) !== null && _adBadgeConfiguration2 !== void 0 ? _adBadgeConfiguration2 : '';
176
+ const textColorOfAdBadge = (_adBadgeConfiguration3 = adBadgeConfiguration.textColor) !== null && _adBadgeConfiguration3 !== void 0 ? _adBadgeConfiguration3 : '';
177
+ const dynamicContentParametersString = generateDynamicContentParametersString();
178
+ const appLanguage = (_FireworkSDK$getInsta4 = FireworkSDK.getInstance().appLanguage) !== null && _FireworkSDK$getInsta4 !== void 0 ? _FireworkSDK$getInsta4 : '';
179
+ const requiresAds = (_adConfiguration$requ = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.requiresAds) !== null && _adConfiguration$requ !== void 0 ? _adConfiguration$requ : false;
180
+ const adsFetchTimeout = (_adConfiguration$adsF = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.adsFetchTimeout) !== null && _adConfiguration$adsF !== void 0 ? _adConfiguration$adsF : 10;
181
+ const vastAttributesString = generateVastAttributesString();
182
+ let key = `source:${source}`;
183
+ key += `_channel:${channel}`;
184
+ key += `_playlist:${playlist}`;
185
+ key += `_gShareBaseURL:${gShareBaseURL}`;
186
+ key += `_videoLaunchBehavior:${videoLaunchBehavior}`;
187
+ key += `_adBadgeTextType:${adBadgeTextType}`;
188
+ key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;
189
+ key += `_textColorOfAdBadge:${textColorOfAdBadge}`;
190
+ key += `_dynamicContentParameters:${dynamicContentParametersString}`;
191
+ key += `_enablePictureInPicture:${enablePictureInPicture}`;
192
+ key += `_appLanguage:${appLanguage}`;
193
+ key += `_requiresAds:${requiresAds}`;
194
+ key += `_adsFetchTimeout:${adsFetchTimeout}`;
195
+ key += `_vastAttributes:${vastAttributesString}`;
196
+ key += `_hashtagFilterExpression:${hashtagFilterExpression}`;
197
+ return key;
198
+ };
199
+
200
+ useEffect(() => {
201
+ if (Platform.OS === 'android') {
202
+ const onBackPress = () => {
203
+ if (isFullscreenState) {
204
+ FireworkSDK.getInstance().navigator.popNativeContainer();
205
+ return true;
206
+ }
207
+
208
+ return false;
209
+ };
210
+
211
+ const subscription = BackHandler.addEventListener('hardwareBackPress', onBackPress);
212
+ return () => {
213
+ subscription.remove();
214
+ };
215
+ }
216
+
217
+ return;
218
+ }, [isFullscreenState]);
219
+ const {
220
+ style
221
+ } = props;
222
+ return /*#__PURE__*/React.createElement(FWStoryBlock, _extends({
223
+ ref: nativeComponentRef,
224
+ key: generateKey()
225
+ }, props, {
226
+ onStoryBlockLoadFinished: handleStoryBlockLoadFinished,
227
+ onStoryBlockFullScreenStateChanged: handleStoryBlockFullscreenStateChanged,
228
+ style: Object.assign({}, style, {
229
+ zIndex: -1
230
+ })
231
+ }));
232
+ };
183
233
 
184
- export default StoryBlock;
234
+ export default /*#__PURE__*/forwardRef(StoryBlock);
185
235
  //# sourceMappingURL=StoryBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["StoryBlock.tsx"],"names":["React","findNodeHandle","Platform","UIManager","FireworkSDK","FWEventName","FireworkSDKModuleEventEmitter","FWLoggerUtil","FWStoryBlock","NativeComponentName","createFragment","viewId","OS","dispatchViewManagerCommand","getViewManagerConfig","Commands","create","toString","StoryBlock","Component","createRef","event","log","nativeEvent","name","onStoryBlockLoadFinished","props","reason","componentDidMount","subscriptionOfShareBaseURLUpdated","addListener","ShareBaseURLUpdated","setState","_subscriptions","push","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","subscriptionOfVideoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","_nativeComponentRef","current","componentWillUnmount","forEach","value","remove","render","style","_generateKey","_onStoryBlockLoadFinished","Object","assign","zIndex","source","channel","playlist","enablePictureInPicture","shareBaseURL","getInstance","getShareBaseURL","adBadgeConfiguration","getAdBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","dynamicContentParametersString","_generateDynamicContentParametersString","videoLaunchBehavior","getVideoLaunchBehavior","key","dynamicContentParameters","resultString","sortedKeyList","keys","sort","valueString","join","length"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAQA,SAASC,cAAT,EAAyBC,QAAzB,EAAmCC,SAAnC,QAAoD,cAApD;AAEA,OAAOC,WAAP,MAAwB,gBAAxB;AAEA,SAASC,WAAT,QAA4B,uBAA5B;AAEA,SAASC,6BAAT,QAA8C,8BAA9C;AACA,OAAOC,YAAP,MAAyB,uBAAzB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,MAAMC,mBAAmB,GAAG,cAA5B;;AAEA,MAAMC,cAAc,GAAIC,MAAD,IAAiB;AACtC,MAAIT,QAAQ,CAACU,EAAT,KAAgB,SAApB,EAA+B;AAC7BT,IAAAA,SAAS,CAACU,0BAAV,CACEF,MADF,EAEER,SAAS,CAACW,oBAAV,CACEL,mBADF,EAEEM,Q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AAG,EAAnB;AACA,UAAMC,aAAa,GAAGzB,MAAM,CAAC0B,IAAP,CAAYH,wBAAZ,EAAsCI,IAAtC,EAAtB;;AACA,SAAK,MAAML,GAAX,IAAkBG,aAAlB,EAAiC;AAC/B,YAAM/B,KAAK,GAAG6B,wBAAwB,CAACD,GAAD,CAAtC;AACA,YAAMM,WAAW,GAAGlC,KAAK,CAACmC,IAAN,CAAW,GAAX,CAApB;;AACA,UAAIL,YAAY,CAACM,MAAb,GAAsB,CAA1B,EAA6B;AAC3BN,QAAAA,YAAY,IAAI,GAAhB;AACD;;AAEDA,MAAAA,YAAY,IAAK,GAAEF,GAAI,IAAGM,WAAY,EAAtC;AACD;;AAED,WAAOJ,YAAP;AACD;;AApJwD;;AAuJ3D,eAAevD,UAAf","sourcesContent":["import React from 'react';\n\nimport type {\n EmitterSubscription,\n NativeSyntheticEvent,\n StyleProp,\n ViewStyle,\n} from 'react-native';\nimport { findNodeHandle, Platform, UIManager } from 'react-native';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type { StoryBlockSource } from '../models/StoryBlockSource';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\nimport FWStoryBlock from './FWStoryBlock';\n\nconst NativeComponentName = 'FWStoryBlock';\n\nconst createFragment = (viewId: any) => {\n if (Platform.OS === 'android') {\n UIManager.dispatchViewManagerCommand(\n viewId,\n UIManager.getViewManagerConfig(\n NativeComponentName\n ).Commands.create.toString(),\n [viewId]\n );\n }\n};\n\n/**\n * The props type of StoryBlock component.\n */\nexport interface IStoryBlockProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of four available story block sources.\n */\n source: StoryBlockSource;\n /**\n * Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * The dynamic content parameters of the story block. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * Specifies if Picture in Picture is enabled.\n */\n enablePictureInPicture?: boolean;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\n/**\n * StoryBlock component. Only supported on iOS.\n */\nclass StoryBlock extends React.Component<IStoryBlockProps> {\n private _nativeComponentRef = React.createRef<any>();\n\n private _subscriptions: EmitterSubscription[] = [];\n\n /**\n * @ignore\n */\n componentDidMount() {\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n this.setState({});\n }\n );\n this._subscriptions.push(subscriptionOfShareBaseURLUpdated);\n\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n this.setState({});\n }\n );\n this._subscriptions.push(subscriptionOfAdBadgeConfigurationUpdated);\n\n const subscriptionOfVideoLaunchBehaviorUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.VideoLaunchBehaviorUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');\n this.setState({});\n }\n );\n this._subscriptions.push(subscriptionOfVideoLaunchBehaviorUpdated);\n\n if (Platform.OS === 'android') {\n const viewId = findNodeHandle(this._nativeComponentRef.current);\n FWLoggerUtil.log(\n `StoryBlock componentDidMount createFragment viewId: ${viewId}`\n );\n createFragment(viewId);\n }\n }\n\n /**\n * @ignore\n */\n componentWillUnmount() {\n this._subscriptions.forEach((value) => {\n value.remove();\n });\n\n this._subscriptions = [];\n }\n\n /**\n * @ignore\n */\n render() {\n const { style } = this.props;\n\n return (\n <FWStoryBlock\n ref={this._nativeComponentRef}\n key={this._generateKey()}\n {...this.props}\n onStoryBlockLoadFinished={this._onStoryBlockLoadFinished}\n style={Object.assign({}, style, { zIndex: -1 })}\n />\n );\n }\n\n private _onStoryBlockLoadFinished = (event: NativeSyntheticEvent<any>) => {\n FWLoggerUtil.log(\n `StoryBlock _onStoryBlockLoadFinished ${event.nativeEvent.name}`\n );\n\n const { onStoryBlockLoadFinished } = this.props;\n const { name, reason } = event.nativeEvent;\n\n if (onStoryBlockLoadFinished) {\n if (name) {\n if (reason) {\n onStoryBlockLoadFinished({ name, reason });\n } else {\n onStoryBlockLoadFinished({ name });\n }\n } else {\n onStoryBlockLoadFinished();\n }\n }\n };\n\n private _generateKey(): string {\n const {\n source,\n channel = '',\n playlist = '',\n enablePictureInPicture = false,\n } = this.props;\n\n const shareBaseURL = FireworkSDK.getInstance().getShareBaseURL() ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().getAdBadgeConfiguration() ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const dynamicContentParametersString =\n this._generateDynamicContentParametersString();\n const videoLaunchBehavior =\n FireworkSDK.getInstance().getVideoLaunchBehavior() ?? 'default';\n\n let key = `source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_shareBaseURL:${shareBaseURL}`;\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n\n return key;\n }\n\n private _generateDynamicContentParametersString(): string {\n const { dynamicContentParameters } = this.props;\n\n if (!dynamicContentParameters) {\n return '';\n }\n\n let resultString = '';\n const sortedKeyList = Object.keys(dynamicContentParameters).sort();\n for (const key of sortedKeyList) {\n const value = dynamicContentParameters[key];\n const valueString = value.join(',');\n if (resultString.length > 0) {\n resultString += '_';\n }\n\n resultString += `${key}:${valueString}`;\n }\n\n return resultString;\n }\n}\n\nexport default StoryBlock;\n"]}
1
+ {"version":3,"sources":["StoryBlock.tsx"],"names":["React","forwardRef","useEffect","useImperativeHandle","useReducer","useRef","useState","BackHandler","findNodeHandle","Platform","UIManager","FireworkSDK","FWEventName","FireworkSDKModuleEventEmitter","FWLoggerUtil","FWStoryBlock","NativeComponentName","StoryBlock","props","forwardedRef","nativeComponentRef","isFullscreenState","setIsFullscreenState","forceUpdate","x","sendCommand","command","nativeNodeHandle","current","commandId","getViewManagerConfig","Commands","OS","toString","dispatchViewManagerCommand","play","pause","subscriptionOfShareBaseURLUpdated","addListener","ShareBaseURLUpdated","log","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","subscriptionOfVideoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","subscriptionOfAppLanguageUpdated","AppLanguageUpdated","setTimeout","viewId","create","remove","handleStoryBlockLoadFinished","event","nativeEvent","name","onStoryBlockLoadFinished","reason","handleStoryBlockFullscreenStateChanged","isFullScreen","generateDynamicContentParametersString","dynamicContentParameters","resultString","sortedKeyList","Object","keys","sort","key","value","valueString","join","length","generateVastAttributesString","adConfiguration","vastAttributes","attribute","generateKey","source","channel","playlist","enablePictureInPicture","hashtagFilterExpression","gShareBaseURL","getInstance","shareBaseURL","videoLaunchBehavior","adBadgeConfiguration","getAdBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","dynamicContentParametersString","appLanguage","requiresAds","adsFetchTimeout","vastAttributesString","onBackPress","navigator","popNativeContainer","subscription","addEventListener","style","assign","zIndex"],"mappings":";;AACA,OAAOA,KAAP,IACEC,UADF,EAEEC,SAFF,EAGEC,mBAHF,EAIEC,UAJF,EAKEC,MALF,EAMEC,QANF,QAOO,OAPP;AASA,SACEC,WADF,EAE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Ref,\n useEffect,\n useImperativeHandle,\n useReducer,\n useRef,\n useState,\n} from 'react';\n\nimport {\n BackHandler,\n findNodeHandle,\n NativeSyntheticEvent,\n Platform,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type AdConfiguration from '../models/AdConfiguration';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type { StoryBlockSource } from '../models/StoryBlockSource';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\nimport FWStoryBlock from './FWStoryBlock';\n\nconst NativeComponentName = 'FWStoryBlock';\n\nexport interface IStoryBlockMethods {\n /**\n * Play the story block.\n */\n play: () => void;\n /**\n * Pause the story block.\n */\n pause: () => void;\n}\n\n/**\n * The props type of StoryBlock component.\n */\nexport interface IStoryBlockProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of four available story block sources.\n */\n source: StoryBlockSource;\n /**\n * Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * The dynamic content parameters of the story block. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * Hashtag filter expression is an s-expression used to provide feeds filtered by hashtags with specified criteria.\n * Queries are specified with boolean predicates on what hashtags are there on the video.\n * For instance, (and sport food) (or sport food) (and sport (or food comedy)) sport are all valid expressions.\n * Non-UTF-8 characters are not allowed. If using boolean predicates, the expression needs to be wrapped with parenthesis.\n */\n hashtagFilterExpression?: string;\n /**\n * Specifies if Picture in Picture is enabled. Only supported on iOS.\n */\n enablePictureInPicture?: boolean;\n /**\n * Ad configuration of the feed. Only supported on iOS.\n */\n adConfiguration?: AdConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\nconst StoryBlock: ForwardRefRenderFunction<\n IStoryBlockMethods,\n IStoryBlockProps\n> = (props: IStoryBlockProps, forwardedRef) => {\n const nativeComponentRef = useRef(null);\n const [isFullscreenState, setIsFullscreenState] = useState<boolean>(false);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n useImperativeHandle(\n forwardedRef,\n () => {\n const sendCommand = (command: string) => {\n const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);\n\n let commandId: string | number =\n UIManager.getViewManagerConfig(NativeComponentName).Commands[command];\n if (Platform.OS === 'android') {\n commandId = commandId.toString();\n }\n\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(nativeNodeHandle),\n commandId,\n []\n );\n };\n return {\n play: () => {\n sendCommand('play');\n },\n pause: () => {\n sendCommand('pause');\n },\n };\n },\n []\n );\n useEffect(() => {\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');\n forceUpdate();\n }\n );\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfVideoLaunchBehaviorUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.VideoLaunchBehaviorUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfAppLanguageUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AppLanguageUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');\n forceUpdate();\n }\n );\n\n if (Platform.OS === 'android') {\n setTimeout(() => {\n const viewId = findNodeHandle(nativeComponentRef.current);\n FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);\n UIManager.dispatchViewManagerCommand(\n viewId,\n UIManager.getViewManagerConfig(\n NativeComponentName\n ).Commands.create.toString(),\n [viewId]\n );\n }, 500);\n }\n\n return () => {\n subscriptionOfShareBaseURLUpdated.remove();\n subscriptionOfAdBadgeConfigurationUpdated.remove();\n subscriptionOfVideoLaunchBehaviorUpdated.remove();\n subscriptionOfAppLanguageUpdated.remove();\n };\n }, []);\n\n const handleStoryBlockLoadFinished = (event: NativeSyntheticEvent<any>) => {\n FWLoggerUtil.log(\n `StoryBlock handleStoryBlockLoadFinished ${event.nativeEvent.name}`\n );\n\n const { onStoryBlockLoadFinished } = props;\n const { name, reason } = event.nativeEvent;\n\n if (onStoryBlockLoadFinished) {\n if (name) {\n if (reason) {\n onStoryBlockLoadFinished({ name, reason });\n } else {\n onStoryBlockLoadFinished({ name });\n }\n } else {\n onStoryBlockLoadFinished();\n }\n }\n };\n\n const handleStoryBlockFullscreenStateChanged = (\n event: NativeSyntheticEvent<any>\n ) => {\n FWLoggerUtil.log(\n `StoryBlock handleStoryBlockFullscreenStateChanged ${event.nativeEvent.isFullScreen}`\n );\n const { isFullScreen } = event.nativeEvent;\n setIsFullscreenState(isFullScreen);\n };\n\n const generateDynamicContentParametersString = (): string => {\n const { dynamicContentParameters } = props;\n\n if (!dynamicContentParameters) {\n return '';\n }\n\n let resultString = '';\n const sortedKeyList = Object.keys(dynamicContentParameters).sort();\n for (const key of sortedKeyList) {\n const value = dynamicContentParameters[key];\n const valueString = value.join(',');\n if (resultString.length > 0) {\n resultString += '_';\n }\n\n resultString += `${key}:${valueString}`;\n }\n\n return resultString;\n };\n\n const generateVastAttributesString = () => {\n const { adConfiguration } = props;\n const vastAttributes = adConfiguration?.vastAttributes ?? '';\n if (!vastAttributes) {\n return '';\n }\n\n let resultString = '';\n for (const attribute of vastAttributes) {\n if (resultString.length > 0) {\n resultString += '_';\n }\n resultString += `${attribute.name ?? ''}:${attribute.value}`;\n }\n\n return resultString;\n };\n\n const generateKey = (): string => {\n const {\n source,\n channel = '',\n playlist = '',\n enablePictureInPicture = false,\n adConfiguration,\n hashtagFilterExpression = '',\n } = props;\n\n const gShareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const videoLaunchBehavior =\n FireworkSDK.getInstance().videoLaunchBehavior ?? 'default';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().getAdBadgeConfiguration() ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const dynamicContentParametersString =\n generateDynamicContentParametersString();\n const appLanguage = FireworkSDK.getInstance().appLanguage ?? '';\n const requiresAds = adConfiguration?.requiresAds ?? false;\n const adsFetchTimeout = adConfiguration?.adsFetchTimeout ?? 10;\n const vastAttributesString = generateVastAttributesString();\n\n let key = `source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_gShareBaseURL:${gShareBaseURL}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n key += `_appLanguage:${appLanguage}`;\n key += `_requiresAds:${requiresAds}`;\n key += `_adsFetchTimeout:${adsFetchTimeout}`;\n key += `_vastAttributes:${vastAttributesString}`;\n key += `_hashtagFilterExpression:${hashtagFilterExpression}`;\n\n return key;\n };\n\n useEffect(() => {\n if (Platform.OS === 'android') {\n const onBackPress = () => {\n if (isFullscreenState) {\n FireworkSDK.getInstance().navigator.popNativeContainer();\n return true;\n }\n return false;\n };\n const subscription = BackHandler.addEventListener(\n 'hardwareBackPress',\n onBackPress\n );\n return () => {\n subscription.remove();\n };\n }\n\n return;\n }, [isFullscreenState]);\n\n const { style } = props;\n return (\n <FWStoryBlock\n ref={nativeComponentRef}\n key={generateKey()}\n {...props}\n onStoryBlockLoadFinished={handleStoryBlockLoadFinished}\n onStoryBlockFullScreenStateChanged={\n handleStoryBlockFullscreenStateChanged\n }\n style={Object.assign({}, style, { zIndex: -1 })}\n />\n );\n};\n\nexport default forwardRef(StoryBlock);\n"]}