react-native-firework-sdk 1.0.0-beta → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,4 +10,6 @@ interface FWVideoShoppingInterface {
10
10
  fun updateAddToCartStatus(res: String?, tip: String?, callbackId: Int?)
11
11
  fun jumpToCartPage(callbackId: Int?)
12
12
  fun exitCartPage()
13
+ fun setCartIconVisible(visible: Boolean?)
14
+ fun setCartItemCount(count: Int?)
13
15
  }
@@ -116,6 +116,20 @@ class FWVideoShoppingModule(
116
116
  }
117
117
  }
118
118
 
119
+ @ReactMethod
120
+ override fun setCartIconVisible(visible: Boolean?) {
121
+ UiThreadUtil.runOnUiThread {
122
+ Baya.willUseCustomCart(visible?:true)
123
+ }
124
+ }
125
+
126
+ @ReactMethod
127
+ override fun setCartItemCount(count: Int?) {
128
+ UiThreadUtil.runOnUiThread {
129
+ Baya.itemCount.value = count?:0
130
+ }
131
+ }
132
+
119
133
  private fun cartListener() {
120
134
  Baya.cartInterface = object: Baya.CartInterface {
121
135
 
@@ -30,10 +30,10 @@ extension RCTConvert {
30
30
  }
31
31
 
32
32
  static func videoPlayerStyle(_ style: String?) -> VideoPlayerContentConfiguration.VideoPlayerStyle? {
33
- guard let style = style else {
33
+ guard let rStyle = style else {
34
34
  return nil
35
35
  }
36
- if style == "fit" {
36
+ if rStyle == "fit" {
37
37
  return .fit
38
38
  } else {
39
39
  return .fullBleed
@@ -52,17 +52,17 @@ extension RCTConvert {
52
52
  }
53
53
 
54
54
  static func ctaButtonStyle(_ style: [String: AnyObject]?) -> ButtonContentConfiguration? {
55
- guard let style = style else {
55
+ guard let rStyle = style else {
56
56
  return nil
57
57
  }
58
58
  var btnContentConfig = ButtonContentConfiguration()
59
- if let backgroundColor = style["backgroundColor"] as? String {
59
+ if let backgroundColor = rStyle["backgroundColor"] as? String {
60
60
  btnContentConfig.backgroundColor = backgroundColor.uicolor()
61
61
  }
62
- if let textColor = style["textColor"] as? String {
62
+ if let textColor = rStyle["textColor"] as? String {
63
63
  btnContentConfig.textColor = textColor.uicolor()
64
64
  }
65
- if let fontSize = style["fontSize"] as? Float {
65
+ if let fontSize = rStyle["fontSize"] as? Float {
66
66
  btnContentConfig.font = UIFont.systemFont(ofSize: CGFloat(fontSize))
67
67
  }
68
68
 
@@ -70,18 +70,18 @@ extension RCTConvert {
70
70
  }
71
71
 
72
72
  static func mobileADConfiguration(_ config: [String: AnyObject]?) -> MobileADConfiguration? {
73
- guard let config = config else {
73
+ guard let rConfig = config else {
74
74
  return nil
75
75
  }
76
76
 
77
- let jsonData = try? JSONSerialization.data(withJSONObject: config, options: .prettyPrinted)
78
- guard let jsonData = jsonData else {
77
+ let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
78
+ guard let rJsonData = jsonData else {
79
79
  return nil
80
80
  }
81
81
 
82
82
  var result: MobileADConfiguration?
83
83
  do {
84
- result = try JSONDecoder().decode(MobileADConfiguration.self, from: jsonData)
84
+ result = try JSONDecoder().decode(MobileADConfiguration.self, from: rJsonData)
85
85
  } catch let error {
86
86
  print(error.localizedDescription)
87
87
  }
@@ -9,18 +9,18 @@ import Foundation
9
9
 
10
10
  extension RCTConvert {
11
11
  static func buildProduct(_ product: [String: Any]?) -> Product? {
12
- guard let product = product else {
12
+ guard let rProduct = product else {
13
13
  return nil
14
14
  }
15
15
 
16
- let jsonData = try? JSONSerialization.data(withJSONObject: product, options: .prettyPrinted)
17
- guard let jsonData = jsonData else {
16
+ let jsonData = try? JSONSerialization.data(withJSONObject: rProduct, options: .prettyPrinted)
17
+ guard let rJsonData = jsonData else {
18
18
  return nil
19
19
  }
20
20
 
21
21
  var result: Product?
22
22
  do {
23
- result = try JSONDecoder().decode(Product.self, from: jsonData)
23
+ result = try JSONDecoder().decode(Product.self, from: rJsonData)
24
24
  } catch let error {
25
25
  print(error.localizedDescription)
26
26
  }
@@ -28,18 +28,18 @@ extension RCTConvert {
28
28
  }
29
29
 
30
30
  static func buildProductInfoViewConfiguration(_ config: [String: Any]?) -> ProductInfoViewConfiguration? {
31
- guard let config = config else {
31
+ guard let rConfig = config else {
32
32
  return nil
33
33
  }
34
34
 
35
- let jsonData = try? JSONSerialization.data(withJSONObject: config, options: .prettyPrinted)
36
- guard let jsonData = jsonData else {
35
+ let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
36
+ guard let rJsonData = jsonData else {
37
37
  return nil
38
38
  }
39
39
 
40
40
  var result: ProductInfoViewConfiguration?
41
41
  do {
42
- result = try JSONDecoder().decode(ProductInfoViewConfiguration.self, from: jsonData)
42
+ result = try JSONDecoder().decode(ProductInfoViewConfiguration.self, from: rJsonData)
43
43
  } catch let error {
44
44
  print(error.localizedDescription)
45
45
  }
@@ -26,44 +26,44 @@ extension VideoFeedMode {
26
26
  @objc
27
27
  public extension RCTConvert {
28
28
  static func videoFeedSourceType(_ type: String?) -> VideFeedSourceType {
29
- guard let type = type else {
29
+ guard let rType = type else {
30
30
  return .discover
31
31
  }
32
32
 
33
- return .feedTypeMapper[type] ?? .discover
33
+ return VideFeedSourceType.feedTypeMapper[rType] ?? .discover
34
34
  }
35
35
 
36
36
  static func videoFeedMode(_ type: String?) -> VideoFeedMode {
37
- guard let type = type else {
37
+ guard let rType = type else {
38
38
  return .row
39
39
  }
40
40
 
41
- return .feedModeMapper[type] ?? .row
41
+ return VideoFeedMode.feedModeMapper[rType] ?? .row
42
42
  }
43
43
 
44
44
  static func videoFeedConfiguration(_ config: [String: AnyObject]?) -> VideoFeedConfiguration? {
45
- guard let config = config else {
45
+ guard let rConfig = config else {
46
46
  return nil
47
47
  }
48
48
 
49
- let jsonData = try? JSONSerialization.data(withJSONObject: config, options: .prettyPrinted)
50
- guard let jsonData = jsonData else {
49
+ let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
50
+ guard let rJsonData = jsonData else {
51
51
  return nil
52
52
  }
53
53
 
54
- return try? JSONDecoder().decode(VideoFeedConfiguration.self, from: jsonData)
54
+ return try? JSONDecoder().decode(VideoFeedConfiguration.self, from: rJsonData)
55
55
  }
56
56
 
57
57
  static func videoPlayerConfiguration(_ config: [String: AnyObject]?) -> VideoPlayerConfiguration? {
58
- guard let config = config else {
58
+ guard let rConfig = config else {
59
59
  return nil
60
60
  }
61
61
 
62
- let jsonData = try? JSONSerialization.data(withJSONObject: config, options: .prettyPrinted)
63
- guard let jsonData = jsonData else {
62
+ let jsonData = try? JSONSerialization.data(withJSONObject: rConfig, options: .prettyPrinted)
63
+ guard let rJsonData = jsonData else {
64
64
  return nil
65
65
  }
66
66
 
67
- return try? JSONDecoder().decode(VideoPlayerConfiguration.self, from: jsonData)
67
+ return try? JSONDecoder().decode(VideoPlayerConfiguration.self, from: rJsonData)
68
68
  }
69
69
  }
@@ -10,6 +10,8 @@
10
10
  @interface RCT_EXTERN_REMAP_MODULE(ShoppingModule, ShoppingModule, NSObject)
11
11
 
12
12
  _RCT_EXTERN_REMAP_METHOD(init, initialize, NO)
13
+ RCT_EXTERN_METHOD(setCartIconVisible:(BOOL)visible)
14
+ RCT_EXTERN_METHOD(setCartItemCount:(int)itemCounts)
13
15
  RCT_EXTERN_METHOD(updateVideoProduct:(NSDictionary *)product cbId:(nonnull NSNumber *)cbid)
14
16
  RCT_EXTERN_METHOD(updateProductViewConfig:(NSDictionary *)config cbId:(nonnull NSNumber *)cbid)
15
17
  RCT_EXTERN_METHOD(updateAddToCartStatus:(NSString *)res tips:(nullable NSString *)tips cbId:(nonnull NSNumber *)cbid)
@@ -15,6 +15,8 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
15
15
  private var addToCartHandler: (Int, AddToCartHandler)?
16
16
  private var productHydrating: (Int, ProductHydrating)?
17
17
  private var cartViewController: CartViewController?
18
+ private var cartIconVisible = true
19
+ private var itemCounts = 0
18
20
 
19
21
  override func supportedEvents() -> [String]! {
20
22
  ShoppingEventName.allCases.map { $0.rawValue }
@@ -41,16 +43,35 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
41
43
  }
42
44
  }
43
45
 
46
+ @objc
47
+ func setCartIconVisible(_ visible: Bool) {
48
+ cartIconVisible = visible
49
+ }
50
+
51
+ @objc
52
+ func setCartItemCount(_ itemCounts: Int) {
53
+ self.itemCounts = itemCounts
54
+
55
+ guard let rProductInfoViewConfigurator = productInfoViewConfigurator else {
56
+ return
57
+ }
58
+ DispatchQueue.main.async {
59
+ var shoppingCartIconConfiguration = rProductInfoViewConfigurator.1.shoppingCartIconConfiguration
60
+ shoppingCartIconConfiguration.indicator.isHidden = itemCounts == 0
61
+ rProductInfoViewConfigurator.1.shoppingCartIconConfiguration = shoppingCartIconConfiguration
62
+ }
63
+ }
64
+
44
65
  @objc
45
66
  func updateVideoProduct(_ product: [String: Any]?, cbId: NSNumber) {
46
67
  let product = RCTConvert.buildProduct(product)
47
- guard let product = product, let productHydrating = productHydrating, productHydrating.0 == Int(truncating: cbId) else {
68
+ guard let rProduct = product, let productHydrating = productHydrating, productHydrating.0 == Int(truncating: cbId) else {
48
69
  return
49
70
  }
50
71
 
51
72
  DispatchQueue.main.async {
52
- productHydrating.1.hydrateProduct(product.productId, { build in
53
- return ShoppingModule.hydrateProduct(product, build)
73
+ productHydrating.1.hydrateProduct(rProduct.productId, { build in
74
+ return ShoppingModule.hydrateProduct(rProduct, build)
54
75
  })
55
76
  }
56
77
  }
@@ -58,12 +79,16 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
58
79
  @objc
59
80
  func updateProductViewConfig(_ config: [String: Any]?, cbId: NSNumber) {
60
81
  let config = RCTConvert.buildProductInfoViewConfiguration(config)
61
- guard let config = config, let productInfoViewConfigurator = productInfoViewConfigurator, productInfoViewConfigurator.0 == Int(truncating: cbId) else {
82
+ guard let rConfig = config, let rProductInfoViewConfigurator = productInfoViewConfigurator, rProductInfoViewConfigurator.0 == Int(truncating: cbId) else {
62
83
  return
63
84
  }
64
85
 
65
86
  DispatchQueue.main.async {
66
- ShoppingModule.hydrateProductViewConfig(config, productInfoViewConfigurator.1)
87
+ //The configuration of CartIcon'visible determined by global cartIconVisible
88
+ rProductInfoViewConfigurator.1.shoppingCartIconConfiguration.isHidden = !self.cartIconVisible
89
+ //The configuration of CartIcon'indicator'visible determined by global itemCounts
90
+ rProductInfoViewConfigurator.1.shoppingCartIconConfiguration.indicator.isHidden = self.itemCounts == 0
91
+ ShoppingModule.hydrateProductViewConfig(rConfig, rProductInfoViewConfigurator.1)
67
92
  }
68
93
  }
69
94
 
@@ -74,6 +99,7 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
74
99
  }
75
100
 
76
101
  DispatchQueue.main.async {
102
+ // config.indicator.isHidden = itemCounts == 0
77
103
  if res == "success" {
78
104
  handler.1(.feedbackOnly(.success(message: tips ?? "success")))
79
105
  } else {
@@ -42,6 +42,20 @@ class VideoShopping {
42
42
  *
43
43
  * The host app can return a ProductInfoViewConfiguration object to configure "Add to cart" button style and cart icon style.
44
44
  */
45
+
46
+ /**
47
+ * Defaults to true. You can hide the cart icon by setting this property to false.
48
+ */
49
+ get cartIconVisible() {
50
+ return this._cartIconVisible;
51
+ }
52
+
53
+ set cartIconVisible(value) {
54
+ this._cartIconVisible = value;
55
+
56
+ _ShoppingModule.default.setCartIconVisible(value);
57
+ }
58
+
45
59
  static getInstance() {
46
60
  if (!VideoShopping._instance) {
47
61
  VideoShopping._instance = new VideoShopping();
@@ -51,6 +65,8 @@ class VideoShopping {
51
65
  }
52
66
 
53
67
  constructor() {
68
+ _defineProperty(this, "_cartIconVisible", true);
69
+
54
70
  _defineProperty(this, "onAddToCart", void 0);
55
71
 
56
72
  _defineProperty(this, "onClickCartIcon", void 0);
@@ -87,6 +103,15 @@ class VideoShopping {
87
103
  exitCartPage() {
88
104
  _ShoppingModule.default.exitCartPage();
89
105
  }
106
+ /**
107
+ *
108
+ * @param {number} count The number of items in the host app cart
109
+ */
110
+
111
+
112
+ setCartItemCount(count) {
113
+ _ShoppingModule.default.setCartItemCount(count);
114
+ }
90
115
 
91
116
  async handleAddToCartEvent(event) {
92
117
  if (this.onAddToCart) {
@@ -1 +1 @@
1
- {"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","getInstance","_instance","constructor","eventEmitter","NativeEventEmitter","ShoppingModule","addListener","FWEventName","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","exitCartPage","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","cartPage","currentCartPage","jumpToCartPage","onUpdateProductDetails","product","updateVideoProduct","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;;;;;;AAAA;;AAGA;;AAQA;;;;;;AAoBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AAO2B,SAAXC,WAAW,GAAG;AAC1B,QAAI,CAACD,aAAa,CAACE,SAAnB,EAA8B;AAC5BF,MAAAA,aAAa,CAACE,SAAd,GAA0B,IAAIF,aAAJ,EAA1B;AACD;;AAED,WAAOA,aAAa,CAACE,SAArB;AACD;;AAEOC,EAAAA,WAAW,GAAG;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACpB,SAAKC,YAAL,GAAoB,IAAIC,+BAAJ,CAAuBC,uBAAvB,CAApB;AACA,SAAKF,YAAL,CAAkBG,WAAlB,CAA8BC,sBAAYC,SAA1C,EAAsDC,KAAD,IAAW;AAC9D,WAAKC,oBAAL,CAA0BD,KAA1B;AACD,KAFD;AAIA,SAAKN,YAAL,CAAkBG,WAAlB,CAA8BC,sBAAYI,aAA1C,EAA0DF,KAAD,IAAW;AAClE,WAAKG,wBAAL,CAA8BH,KAA9B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CAAtB;;AAGA,UAAIoB,OAAJ,EAAa;AACXxB,gCAAeyB,kBAAf,CAAkCD,OAAlC,EAA2CV,UAA3C;AACD;AACF;AACF;;AAE0C,QAA7BH,6BAA6B,CACzCP,KADyC,EAEzC;AACA,QAAI,KAAKsB,oBAAT,EAA+B;AAC7B,YAAMZ,UAAU,GAAGV,KAAK,CAACU,UAAzB;AACA,aAAOV,KAAK,CAACU,UAAb;AACA,YAAMa,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBtB,KADmB,CAArB;;AAGA,UAAIuB,MAAJ,EAAY;AACV3B,gCAAe4B,uBAAf,CAAuCD,MAAvC,EAA+Cb,UAA/C;AACD;AACF;AACF;;AA/HiB;;gBAAdpB,a;;eAkISA,a","sourcesContent":["import { NativeEventEmitter } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport {\n AddToCartEvent,\n FWEventName,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule from './modules/ShoppingModule';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n React.ReactNode | undefined | null\n>;\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\ntype CallbackInfo = { callbackId?: number };\n\n/**\n * 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 app can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\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 a React.Node to integrate custom cart page to shopping flow.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product object to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * This callback is triggered when the product will be shown.\n *\n * The host app can return a ProductInfoViewConfiguration object to configure \"Add to cart\" button style and cart icon style.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n public currentCartPage?: React.ReactNode;\n\n private eventEmitter: NativeEventEmitter;\n\n public static getInstance() {\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter = new NativeEventEmitter(ShoppingModule);\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\n }\n\n /**\n * Exit Cart Page.\n *\n * The host app can call this method to exit their cart page.\n */\n public exitCartPage() {\n ShoppingModule.exitCartPage();\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n if (this.onAddToCart) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId!\n );\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const cartPage = await this.onClickCartIcon();\n this.currentCartPage = cartPage;\n\n if (cartPage) {\n ShoppingModule.jumpToCartPage(callbackId!);\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const product = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (product) {\n ShoppingModule.updateVideoProduct(product, callbackId!);\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.updateProductViewConfig(config, callbackId!);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
1
+ {"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","cartIconVisible","_cartIconVisible","value","ShoppingModule","setCartIconVisible","getInstance","_instance","constructor","eventEmitter","NativeEventEmitter","addListener","FWEventName","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","exitCartPage","setCartItemCount","count","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","cartPage","currentCartPage","jumpToCartPage","onUpdateProductDetails","product","updateVideoProduct","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;;;;;;AAAA;;AAGA;;AAQA;;;;;;AAoBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAIlB;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AAC4B,MAAfC,eAAe,GAAY;AACpC,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACE,KAAD,EAAiB;AACzC,SAAKD,gBAAL,GAAwBC,KAAxB;;AACAC,4BAAeC,kBAAf,CAAkCF,KAAlC;AACD;;AAMwB,SAAXG,WAAW,GAAG;AAC1B,QAAI,CAACN,aA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;AACVvB,gCAAewB,qBAAf,CACED,MAAM,CAACE,GADT,EAEEF,MAAM,CAACG,IAFT,EAGEJ,UAHF;AAKD;AACF;AACF;;AAEqC,QAAxBT,wBAAwB,CAACH,KAAD,EAAsB;AAC1D,QAAI,KAAKiB,eAAT,EAA0B;AACxB,YAAML,UAAU,GAAGZ,KAAK,CAACY,UAAzB;AACA,aAAOZ,KAAK,CAACY,UAAb;AACA,YAAMM,QAAQ,GAAG,MAAM,KAAKD,eAAL,EAAvB;AACA,WAAKE,eAAL,GAAuBD,QAAvB;;AAEA,UAAIA,QAAJ,EAAc;AACZ5B,gCAAe8B,cAAf,CAA8BR,UAA9B;AACD;AACF;AACF;;AAE4C,QAA/BP,+BAA+B,CAC3CL,KAD2C,EAE3C;AACA,QAAI,KAAKqB,sBAAT,EAAiC;AAC/B,YAAMT,UAAU,GAAGZ,KAAK,CAACY,UAAzB;AACA,aAAOZ,KAAK,CAACY,UAAb;AACA,YAAMU,OAAO,GAAG,MAAM,KAAKD,sBAAL,CACpBrB,KADoB,CAAtB;;AAGA,UAAIsB,OAAJ,EAAa;AACXhC,gCAAeiC,kBAAf,CAAkCD,OAAlC,EAA2CV,UAA3C;AACD;AACF;AACF;;AAE0C,QAA7BL,6BAA6B,CACzCP,KADyC,EAEzC;AACA,QAAI,KAAKwB,oBAAT,EAA+B;AAC7B,YAAMZ,UAAU,GAAGZ,KAAK,CAACY,UAAzB;AACA,aAAOZ,KAAK,CAACY,UAAb;AACA,YAAMa,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBxB,KADmB,CAArB;;AAGA,UAAIyB,MAAJ,EAAY;AACVnC,gCAAeoC,uBAAf,CAAuCD,MAAvC,EAA+Cb,UAA/C;AACD;AACF;AACF;;AAnJiB;;gBAAd1B,a;;eAsJSA,a","sourcesContent":["import { NativeEventEmitter } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport {\n AddToCartEvent,\n FWEventName,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule from './modules/ShoppingModule';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n React.ReactNode | undefined | null\n>;\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\ntype CallbackInfo = { callbackId?: number };\n\n/**\n * Entry class of Video Shopping\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n private _cartIconVisible: boolean = true;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host app can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\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 a React.Node to integrate custom cart page to shopping flow.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product object to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * This callback is triggered when the product will be shown.\n *\n * The host app can return a ProductInfoViewConfiguration object to configure \"Add to cart\" button style and cart icon style.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n /**\n * Defaults to true. 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\n public currentCartPage?: React.ReactNode;\n\n private eventEmitter: NativeEventEmitter;\n\n public static getInstance() {\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter = new NativeEventEmitter(ShoppingModule);\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\n }\n\n /**\n * Exit Cart Page.\n *\n * The host app can call this method to exit their cart page.\n */\n public exitCartPage() {\n ShoppingModule.exitCartPage();\n }\n\n /**\n * \n * @param {number} count The number of items in the host app cart\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n if (this.onAddToCart) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId!,\n );\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const cartPage = await this.onClickCartIcon();\n this.currentCartPage = cartPage;\n\n if (cartPage) {\n ShoppingModule.jumpToCartPage(callbackId!);\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const product = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (product) {\n ShoppingModule.updateVideoProduct(product, callbackId!);\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.updateProductViewConfig(config, callbackId!);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["AppRegistry","registerComponent","CartContainer","FireworkSDK"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAMA;;AAOA;;AAgCA;;AAaA;;;;AAEAA,yBAAYC,iBAAZ,CAA8B,oBAA9B,EAAoD,MAAMC,sBAA1D;;eAEeC,oB","sourcesContent":["import { AppRegistry } from 'react-native';\n\nimport CartContainer from './components/CartContainer';\nimport type {\n IVideoFeedProps,\n VideoFeedMode,\n VideoFeedSource,\n} from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport type ADConfig from './models/ADConfig';\nimport type AddToCartResult from './models/AddToCartResult';\nimport type FeedItemDetails from './models/FeedItemDetails';\nimport type FWError from './models/FWError';\nimport type {\n AddToCartEvent,\n CustomCTAClickEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type {\n AddToCartButtonConfiguration,\n CartIconConfiguration,\n} from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type {\n VideoBadge,\n VideoPlayerSize,\n} from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nAppRegistry.registerComponent('FWShoppingCartPage', () => CartContainer);\n\nexport default FireworkSDK;\n\nexport {\n ADConfig,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n CartIconConfiguration,\n ClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n FeedItemDetails,\n FWError,\n IVideoFeedProps,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoBadge,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoPlaybackCallback,\n VideoPlaybackDetails,\n VideoPlaybackEvent,\n VideoPlaybackEventName,\n VideoPlayerCompleteAction,\n VideoPlayerConfiguration,\n VideoPlayerCTAStyle,\n VideoPlayerSize,\n VideoPlayerStyle,\n VideoShopping,\n WillDisplayProductCallback,\n WillDisplayProductEvent,\n};\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["AppRegistry","registerComponent","CartContainer","FireworkSDK"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;AAMA;;AAOA;;AA+BA;;AAaA;;;;AAEAA,yBAAYC,iBAAZ,CAA8B,oBAA9B,EAAoD,MAAMC,sBAA1D;;eAEeC,oB","sourcesContent":["import { AppRegistry } from 'react-native';\n\nimport CartContainer from './components/CartContainer';\nimport type {\n IVideoFeedProps,\n VideoFeedMode,\n VideoFeedSource,\n} from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport type ADConfig from './models/ADConfig';\nimport type AddToCartResult from './models/AddToCartResult';\nimport type FeedItemDetails from './models/FeedItemDetails';\nimport type FWError from './models/FWError';\nimport type {\n AddToCartEvent,\n CustomCTAClickEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type {\n AddToCartButtonConfiguration,\n} from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type {\n VideoBadge,\n VideoPlayerSize,\n} from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nAppRegistry.registerComponent('FWShoppingCartPage', () => CartContainer);\n\nexport default FireworkSDK;\n\nexport {\n ADConfig,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n ClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n FeedItemDetails,\n FWError,\n IVideoFeedProps,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoBadge,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoPlaybackCallback,\n VideoPlaybackDetails,\n VideoPlaybackEvent,\n VideoPlaybackEventName,\n VideoPlayerCompleteAction,\n VideoPlayerConfiguration,\n VideoPlayerCTAStyle,\n VideoPlayerSize,\n VideoPlayerStyle,\n VideoShopping,\n WillDisplayProductCallback,\n WillDisplayProductEvent,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["ShoppingModule.ts"],"names":["ShoppingModule","NativeModules","Proxy","get","Error","LINKING_ERROR"],"mappings":";;;;;;;AAAA;;AAMA;;AAEA,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;eAoBeL,c","sourcesContent":["import {\n NativeModule,\n NativeModules,\n} from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\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 updateVideoProduct(production: Product, callbackId: number): void;\n updateProductViewConfig(config: ProductInfoViewConfiguration, callbackId: number): void;\n updateAddToCartStatus(res: string, tips: string, callbackId: number): void;\n jumpToCartPage(callbackId: number): void;\n exitCartPage(): void;\n}\n\nexport default ShoppingModule as IShoppingModule;\n"]}
1
+ {"version":3,"sources":["ShoppingModule.ts"],"names":["ShoppingModule","NativeModules","Proxy","get","Error","LINKING_ERROR"],"mappings":";;;;;;;AAAA;;AAMA;;AAEA,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;eAsBeL,c","sourcesContent":["import {\n NativeModule,\n NativeModules,\n} from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\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 updateVideoProduct(production: Product, callbackId: number): void;\n updateProductViewConfig(config: ProductInfoViewConfiguration, callbackId: number): void;\n updateAddToCartStatus(res: string, tips: string, callbackId: number): void;\n jumpToCartPage(callbackId: number): void;\n exitCartPage(): void;\n setCartIconVisible(visible: boolean): void;\n setCartItemCount(count: number): void;\n}\n\nexport default ShoppingModule as IShoppingModule;\n"]}
@@ -31,6 +31,19 @@ class VideoShopping {
31
31
  *
32
32
  * The host app can return a ProductInfoViewConfiguration object to configure "Add to cart" button style and cart icon style.
33
33
  */
34
+
35
+ /**
36
+ * Defaults to true. You can hide the cart icon by setting this property to false.
37
+ */
38
+ get cartIconVisible() {
39
+ return this._cartIconVisible;
40
+ }
41
+
42
+ set cartIconVisible(value) {
43
+ this._cartIconVisible = value;
44
+ ShoppingModule.setCartIconVisible(value);
45
+ }
46
+
34
47
  static getInstance() {
35
48
  if (!VideoShopping._instance) {
36
49
  VideoShopping._instance = new VideoShopping();
@@ -40,6 +53,8 @@ class VideoShopping {
40
53
  }
41
54
 
42
55
  constructor() {
56
+ _defineProperty(this, "_cartIconVisible", true);
57
+
43
58
  _defineProperty(this, "onAddToCart", void 0);
44
59
 
45
60
  _defineProperty(this, "onClickCartIcon", void 0);
@@ -76,6 +91,15 @@ class VideoShopping {
76
91
  exitCartPage() {
77
92
  ShoppingModule.exitCartPage();
78
93
  }
94
+ /**
95
+ *
96
+ * @param {number} count The number of items in the host app cart
97
+ */
98
+
99
+
100
+ setCartItemCount(count) {
101
+ ShoppingModule.setCartItemCount(count);
102
+ }
79
103
 
80
104
  async handleAddToCartEvent(event) {
81
105
  if (this.onAddToCart) {
@@ -1 +1 @@
1
- {"version":3,"sources":["VideoShopping.ts"],"names":["NativeEventEmitter","FWEventName","ShoppingModule","VideoShopping","getInstance","_instance","constructor","eventEmitter","addListener","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","exitCartPage","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","cartPage","currentCartPage","jumpToCartPage","onUpdateProductDetails","product","updateVideoProduct","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;AAAA,SAASA,kBAAT,QAAmC,cAAnC;AAGA,SAEEC,WAFF,QAKO,mBALP;AAQA,OAAOC,cAAP,MAA2B,0BAA3B;;AAoBA;AACA;AACA;AACA,MAAMC,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AAO2B,SAAXC,WAAW,GAAG;AAC1B,QAAI,CAACD,aAAa,CAACE,SAAnB,EAA8B;AAC5BF,MAAAA,aAAa,CAACE,SAAd,GAA0B,IAAIF,aAAJ,EAA1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;AACxB,YAAML,UAAU,GAAGV,KAAK,CAACU,UAAzB;AACA,aAAOV,KAAK,CAACU,UAAb;AACA,YAAMM,QAAQ,GAAG,MAAM,KAAKD,eAAL,EAAvB;AACA,WAAKE,eAAL,GAAuBD,QAAvB;;AAEA,UAAIA,QAAJ,EAAc;AACZxB,QAAAA,cAAc,CAAC0B,cAAf,CAA8BR,UAA9B;AACD;AACF;AACF;;AAE4C,QAA/BL,+BAA+B,CAC3CL,KAD2C,EAE3C;AACA,QAAI,KAAKmB,sBAAT,EAAiC;AAC/B,YAAMT,UAAU,GAAGV,KAAK,CAACU,UAAzB;AACA,aAAOV,KAAK,CAACU,UAAb;AACA,YAAMU,OAAO,GAAG,MAAM,KAAKD,sBAAL,CACpBnB,KADoB,CAAtB;;AAGA,UAAIoB,OAAJ,EAAa;AACX5B,QAAAA,cAAc,CAAC6B,kBAAf,CAAkCD,OAAlC,EAA2CV,UAA3C;AACD;AACF;AACF;;AAE0C,QAA7BH,6BAA6B,CACzCP,KADyC,EAEzC;AACA,QAAI,KAAKsB,oBAAT,EAA+B;AAC7B,YAAMZ,UAAU,GAAGV,KAAK,CAACU,UAAzB;AACA,aAAOV,KAAK,CAACU,UAAb;AACA,YAAMa,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBtB,KADmB,CAArB;;AAGA,UAAIuB,MAAJ,EAAY;AACV/B,QAAAA,cAAc,CAACgC,uBAAf,CAAuCD,MAAvC,EAA+Cb,UAA/C;AACD;AACF;AACF;;AA/HiB;;gBAAdjB,a;;AAkIN,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport {\n AddToCartEvent,\n FWEventName,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule from './modules/ShoppingModule';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n React.ReactNode | undefined | null\n>;\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\ntype CallbackInfo = { callbackId?: number };\n\n/**\n * 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 app can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\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 a React.Node to integrate custom cart page to shopping flow.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product object to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * This callback is triggered when the product will be shown.\n *\n * The host app can return a ProductInfoViewConfiguration object to configure \"Add to cart\" button style and cart icon style.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n public currentCartPage?: React.ReactNode;\n\n private eventEmitter: NativeEventEmitter;\n\n public static getInstance() {\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter = new NativeEventEmitter(ShoppingModule);\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\n }\n\n /**\n * Exit Cart Page.\n *\n * The host app can call this method to exit their cart page.\n */\n public exitCartPage() {\n ShoppingModule.exitCartPage();\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n if (this.onAddToCart) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId!\n );\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const cartPage = await this.onClickCartIcon();\n this.currentCartPage = cartPage;\n\n if (cartPage) {\n ShoppingModule.jumpToCartPage(callbackId!);\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const product = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (product) {\n ShoppingModule.updateVideoProduct(product, callbackId!);\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.updateProductViewConfig(config, callbackId!);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
1
+ {"version":3,"sources":["VideoShopping.ts"],"names":["NativeEventEmitter","FWEventName","ShoppingModule","VideoShopping","cartIconVisible","_cartIconVisible","value","setCartIconVisible","getInstance","_instance","constructor","eventEmitter","addListener","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","exitCartPage","setCartItemCount","count","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","cartPage","currentCartPage","jumpToCartPage","onUpdateProductDetails","product","updateVideoProduct","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;AAAA,SAASA,kBAAT,QAAmC,cAAnC;AAGA,SAEEC,WAFF,QAKO,mBALP;AAQA,OAAOC,cAAP,MAA2B,0BAA3B;;AAoBA;AACA;AACA;AACA,MAAMC,aAAN,CAAoB;AAIlB;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AAC4B,MAAfC,eAAe,GAAY;AACpC,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACE,KAAD,EAAiB;AACzC,SAAKD,gBAAL,GAAwBC,KAAxB;AACAJ,IAAAA,cAAc,CAACK,kBAAf,CAAkCD,KAAlC;AACD;;AAMwB,SAAXE,WAAW,GAAG;AAC1B,QAAI,CAACL,aAAa,CAACM,SAAnB,EAA8B;AAC5BN,MAAAA,aAAa,CAACM,SAAd,GAA0B,IAAIN,aAAJ,EAA1B;AACD;;AAED,WAAOA,aAAa,CAACM,SAArB;AACD;;AAEOC,EAAAA,WAAW,GAAG;AAAA,8CArDc,IAqDd;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACpB,SAAKC,YAAL,GAAoB,IAAIX,kBAAJ,CAAuBE,cAAvB,CAApB;AACA,SAAKS,YAAL,CAAkBC,WAAlB,CAA8BX,WAAW,CAACY,SAA1C,EAAsDC,KAAD,IAAW;AAC9D,WAAKC,oBAAL,CAA0BD,KAA1B;AACD,KAFD;AAIA,SAAKH,YAAL,CAAkBC,WAAlB,CAA8BX,WAAW,CAACe,aAA1C,EAA0DF,KAAD,IAAW;AAClE,WAAKG,wBAAL,CAA8BH,KAA9B;AACD,KAFD;AAIA,SAAKH,YAAL,CAAkBC,WAAlB,CAA8BX,WAAW,CAACiB,oBAA1C,EAAiEJ,KAAD,IAAW;AACzE,WAAKK,+BA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;AACA,YAAMU,OAAO,GAAG,MAAM,KAAKD,sBAAL,CACpBrB,KADoB,CAAtB;;AAGA,UAAIsB,OAAJ,EAAa;AACXlC,QAAAA,cAAc,CAACmC,kBAAf,CAAkCD,OAAlC,EAA2CV,UAA3C;AACD;AACF;AACF;;AAE0C,QAA7BL,6BAA6B,CACzCP,KADyC,EAEzC;AACA,QAAI,KAAKwB,oBAAT,EAA+B;AAC7B,YAAMZ,UAAU,GAAGZ,KAAK,CAACY,UAAzB;AACA,aAAOZ,KAAK,CAACY,UAAb;AACA,YAAMa,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBxB,KADmB,CAArB;;AAGA,UAAIyB,MAAJ,EAAY;AACVrC,QAAAA,cAAc,CAACsC,uBAAf,CAAuCD,MAAvC,EAA+Cb,UAA/C;AACD;AACF;AACF;;AAnJiB;;gBAAdvB,a;;AAsJN,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport {\n AddToCartEvent,\n FWEventName,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule from './modules/ShoppingModule';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n React.ReactNode | undefined | null\n>;\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\ntype CallbackInfo = { callbackId?: number };\n\n/**\n * Entry class of Video Shopping\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n private _cartIconVisible: boolean = true;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host app can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\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 a React.Node to integrate custom cart page to shopping flow.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product object to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * This callback is triggered when the product will be shown.\n *\n * The host app can return a ProductInfoViewConfiguration object to configure \"Add to cart\" button style and cart icon style.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n /**\n * Defaults to true. 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\n public currentCartPage?: React.ReactNode;\n\n private eventEmitter: NativeEventEmitter;\n\n public static getInstance() {\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter = new NativeEventEmitter(ShoppingModule);\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\n }\n\n /**\n * Exit Cart Page.\n *\n * The host app can call this method to exit their cart page.\n */\n public exitCartPage() {\n ShoppingModule.exitCartPage();\n }\n\n /**\n * \n * @param {number} count The number of items in the host app cart\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n if (this.onAddToCart) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId!,\n );\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const cartPage = await this.onClickCartIcon();\n this.currentCartPage = cartPage;\n\n if (cartPage) {\n ShoppingModule.jumpToCartPage(callbackId!);\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const product = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (product) {\n ShoppingModule.updateVideoProduct(product, callbackId!);\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.updateProductViewConfig(config, callbackId!);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["AppRegistry","CartContainer","VideoFeed","FireworkSDK","VideoPlaybackEventName","VideoShopping","registerComponent"],"mappings":"AAAA,SAASA,WAAT,QAA4B,cAA5B;AAEA,OAAOC,aAAP,MAA0B,4BAA1B;AAMA,OAAOC,SAAP,MAAsB,wBAAtB;AAOA,OAAOC,WAAP,MAAwB,eAAxB;AAgCA,OAAOC,sBAAP,MAAmC,iCAAnC;AAaA,OAAOC,aAAP,MAA0B,iBAA1B;AAEAL,WAAW,CAACM,iBAAZ,CAA8B,oBAA9B,EAAoD,MAAML,aAA1D;AAEA,eAAeE,WAAf;AAEA,SAsBED,SAtBF,EAiCEE,sBAjCF,EAuCEC,aAvCF","sourcesContent":["import { AppRegistry } from 'react-native';\n\nimport CartContainer from './components/CartContainer';\nimport type {\n IVideoFeedProps,\n VideoFeedMode,\n VideoFeedSource,\n} from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport type ADConfig from './models/ADConfig';\nimport type AddToCartResult from './models/AddToCartResult';\nimport type FeedItemDetails from './models/FeedItemDetails';\nimport type FWError from './models/FWError';\nimport type {\n AddToCartEvent,\n CustomCTAClickEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type {\n AddToCartButtonConfiguration,\n CartIconConfiguration,\n} from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type {\n VideoBadge,\n VideoPlayerSize,\n} from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nAppRegistry.registerComponent('FWShoppingCartPage', () => CartContainer);\n\nexport default FireworkSDK;\n\nexport {\n ADConfig,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n CartIconConfiguration,\n ClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n FeedItemDetails,\n FWError,\n IVideoFeedProps,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoBadge,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoPlaybackCallback,\n VideoPlaybackDetails,\n VideoPlaybackEvent,\n VideoPlaybackEventName,\n VideoPlayerCompleteAction,\n VideoPlayerConfiguration,\n VideoPlayerCTAStyle,\n VideoPlayerSize,\n VideoPlayerStyle,\n VideoShopping,\n WillDisplayProductCallback,\n WillDisplayProductEvent,\n};\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["AppRegistry","CartContainer","VideoFeed","FireworkSDK","VideoPlaybackEventName","VideoShopping","registerComponent"],"mappings":"AAAA,SAASA,WAAT,QAA4B,cAA5B;AAEA,OAAOC,aAAP,MAA0B,4BAA1B;AAMA,OAAOC,SAAP,MAAsB,wBAAtB;AAOA,OAAOC,WAAP,MAAwB,eAAxB;AA+BA,OAAOC,sBAAP,MAAmC,iCAAnC;AAaA,OAAOC,aAAP,MAA0B,iBAA1B;AAEAL,WAAW,CAACM,iBAAZ,CAA8B,oBAA9B,EAAoD,MAAML,aAA1D;AAEA,eAAeE,WAAf;AAEA,SAqBED,SArBF,EAgCEE,sBAhCF,EAsCEC,aAtCF","sourcesContent":["import { AppRegistry } from 'react-native';\n\nimport CartContainer from './components/CartContainer';\nimport type {\n IVideoFeedProps,\n VideoFeedMode,\n VideoFeedSource,\n} from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport type ADConfig from './models/ADConfig';\nimport type AddToCartResult from './models/AddToCartResult';\nimport type FeedItemDetails from './models/FeedItemDetails';\nimport type FWError from './models/FWError';\nimport type {\n AddToCartEvent,\n CustomCTAClickEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type {\n AddToCartButtonConfiguration,\n} from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type {\n VideoBadge,\n VideoPlayerSize,\n} from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nAppRegistry.registerComponent('FWShoppingCartPage', () => CartContainer);\n\nexport default FireworkSDK;\n\nexport {\n ADConfig,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n ClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n FeedItemDetails,\n FWError,\n IVideoFeedProps,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoBadge,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoPlaybackCallback,\n VideoPlaybackDetails,\n VideoPlaybackEvent,\n VideoPlaybackEventName,\n VideoPlayerCompleteAction,\n VideoPlayerConfiguration,\n VideoPlayerCTAStyle,\n VideoPlayerSize,\n VideoPlayerStyle,\n VideoShopping,\n WillDisplayProductCallback,\n WillDisplayProductEvent,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["ShoppingModule.ts"],"names":["NativeModules","LINKING_ERROR","ShoppingModule","Proxy","get","Error"],"mappings":"AAAA,SAEEA,aAFF,QAGO,cAHP;AAMA,SAASC,aAAT,QAA8B,6BAA9B;AAEA,MAAMC,cAAc,GAAGF,aAAa,CAACE,cAAd,GACnBF,aAAa,CAACE,cADK,GAEnB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUJ,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAoBA,eAAeC,cAAf","sourcesContent":["import {\n NativeModule,\n NativeModules,\n} from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\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 updateVideoProduct(production: Product, callbackId: number): void;\n updateProductViewConfig(config: ProductInfoViewConfiguration, callbackId: number): void;\n updateAddToCartStatus(res: string, tips: string, callbackId: number): void;\n jumpToCartPage(callbackId: number): void;\n exitCartPage(): void;\n}\n\nexport default ShoppingModule as IShoppingModule;\n"]}
1
+ {"version":3,"sources":["ShoppingModule.ts"],"names":["NativeModules","LINKING_ERROR","ShoppingModule","Proxy","get","Error"],"mappings":"AAAA,SAEEA,aAFF,QAGO,cAHP;AAMA,SAASC,aAAT,QAA8B,6BAA9B;AAEA,MAAMC,cAAc,GAAGF,aAAa,CAACE,cAAd,GACnBF,aAAa,CAACE,cADK,GAEnB,IAAIC,KAAJ,CACE,EADF,EAEE;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUJ,aAAV,CAAN;AACD;;AAHH,CAFF,CAFJ;AAsBA,eAAeC,cAAf","sourcesContent":["import {\n NativeModule,\n NativeModules,\n} from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\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 updateVideoProduct(production: Product, callbackId: number): void;\n updateProductViewConfig(config: ProductInfoViewConfiguration, callbackId: number): void;\n updateAddToCartStatus(res: string, tips: string, callbackId: number): void;\n jumpToCartPage(callbackId: number): void;\n exitCartPage(): void;\n setCartIconVisible(visible: boolean): void;\n setCartItemCount(count: number): void;\n}\n\nexport default ShoppingModule as IShoppingModule;\n"]}
@@ -12,6 +12,7 @@ export declare type WillDisplayProductCallback = (event: WillDisplayProductEvent
12
12
  */
13
13
  declare class VideoShopping {
14
14
  private static _instance?;
15
+ private _cartIconVisible;
15
16
  /**
16
17
  * This callback is triggered when the user clicks the "Add to cart" button.
17
18
  *
@@ -36,6 +37,11 @@ declare class VideoShopping {
36
37
  * The host app can return a ProductInfoViewConfiguration object to configure "Add to cart" button style and cart icon style.
37
38
  */
38
39
  onWillDisplayProduct?: WillDisplayProductCallback;
40
+ /**
41
+ * Defaults to true. You can hide the cart icon by setting this property to false.
42
+ */
43
+ get cartIconVisible(): boolean;
44
+ set cartIconVisible(value: boolean);
39
45
  currentCartPage?: React.ReactNode;
40
46
  private eventEmitter;
41
47
  static getInstance(): VideoShopping;
@@ -46,6 +52,11 @@ declare class VideoShopping {
46
52
  * The host app can call this method to exit their cart page.
47
53
  */
48
54
  exitCartPage(): void;
55
+ /**
56
+ *
57
+ * @param {number} count The number of items in the host app cart
58
+ */
59
+ setCartItemCount(count: number): void;
49
60
  private handleAddToCartEvent;
50
61
  private handleClickCartIconEvent;
51
62
  private handleUpdateProductDetailsEvent;
@@ -9,7 +9,7 @@ import type FWError from './models/FWError';
9
9
  import type { AddToCartEvent, CustomCTAClickEvent, SDKInitEvent, UpdateProductDetailsEvent, VideoPlaybackEvent, WillDisplayProductEvent } from './models/FWEvents';
10
10
  import type Product from './models/Product';
11
11
  import type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';
12
- import type { AddToCartButtonConfiguration, CartIconConfiguration } from './models/ProductInfoViewConfiguration';
12
+ import type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';
13
13
  import type ProductUnit from './models/ProductUnit';
14
14
  import type { ProductPrice } from './models/ProductUnit';
15
15
  import type VideoFeedConfiguration from './models/VideoFeedConfiguration';
@@ -22,4 +22,4 @@ import type { VideoPlayerCompleteAction, VideoPlayerCTAStyle, VideoPlayerStyle }
22
22
  import type { AddToCartCallback, ClickCartIconCallback, UpdateProductDetailsCallback, WillDisplayProductCallback } from './VideoShopping';
23
23
  import VideoShopping from './VideoShopping';
24
24
  export default FireworkSDK;
25
- export { ADConfig, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, CartIconConfiguration, ClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, FeedItemDetails, FWError, IVideoFeedProps, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, SDKInitCallback, SDKInitEvent, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoBadge, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
25
+ export { ADConfig, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, ClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, FeedItemDetails, FWError, IVideoFeedProps, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, SDKInitCallback, SDKInitEvent, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoBadge, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
@@ -1,16 +1,9 @@
1
- export interface CartIconConfiguration {
2
- isHidden?: boolean;
3
- }
4
1
  export interface AddToCartButtonConfiguration {
5
2
  backgroundColor?: string;
6
3
  textColor?: string;
7
4
  fontSize?: number;
8
5
  }
9
6
  export default interface ProductInfoViewConfiguration {
10
- /**
11
- * Configuration of cart icon.
12
- */
13
- cartIcon?: CartIconConfiguration;
14
7
  /**
15
8
  * Configuration of "Add to cart" button.
16
9
  */
@@ -8,6 +8,8 @@ interface IShoppingModule extends NativeModule {
8
8
  updateAddToCartStatus(res: string, tips: string, callbackId: number): void;
9
9
  jumpToCartPage(callbackId: number): void;
10
10
  exitCartPage(): void;
11
+ setCartIconVisible(visible: boolean): void;
12
+ setCartItemCount(count: number): void;
11
13
  }
12
14
  declare const _default: IShoppingModule;
13
15
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-firework-sdk",
3
- "version": "1.0.0-beta",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "Firework React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -42,7 +42,7 @@
42
42
  "bugs": {
43
43
  "url": ""
44
44
  },
45
- "homepage": "https://github.com/loopsocial/bogano",
45
+ "homepage": "https://github.com/loopsocial/react-native-firework-sdk",
46
46
  "publishConfig": {
47
47
  "registry": "https://registry.npmjs.org/"
48
48
  },
@@ -34,6 +34,7 @@ type CallbackInfo = { callbackId?: number };
34
34
  */
35
35
  class VideoShopping {
36
36
  private static _instance?: VideoShopping;
37
+ private _cartIconVisible: boolean = true;
37
38
 
38
39
  /**
39
40
  * This callback is triggered when the user clicks the "Add to cart" button.
@@ -63,6 +64,17 @@ class VideoShopping {
63
64
  */
64
65
  public onWillDisplayProduct?: WillDisplayProductCallback;
65
66
 
67
+ /**
68
+ * Defaults to true. You can hide the cart icon by setting this property to false.
69
+ */
70
+ public get cartIconVisible(): boolean {
71
+ return this._cartIconVisible;
72
+ }
73
+ public set cartIconVisible(value: boolean) {
74
+ this._cartIconVisible = value;
75
+ ShoppingModule.setCartIconVisible(value);
76
+ }
77
+
66
78
  public currentCartPage?: React.ReactNode;
67
79
 
68
80
  private eventEmitter: NativeEventEmitter;
@@ -103,6 +115,14 @@ class VideoShopping {
103
115
  ShoppingModule.exitCartPage();
104
116
  }
105
117
 
118
+ /**
119
+ *
120
+ * @param {number} count The number of items in the host app cart
121
+ */
122
+ public setCartItemCount(count: number) {
123
+ ShoppingModule.setCartItemCount(count);
124
+ }
125
+
106
126
  private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {
107
127
  if (this.onAddToCart) {
108
128
  const callbackId = event.callbackId;
@@ -112,7 +132,7 @@ class VideoShopping {
112
132
  ShoppingModule.updateAddToCartStatus(
113
133
  result.res,
114
134
  result.tips,
115
- callbackId!
135
+ callbackId!,
116
136
  );
117
137
  }
118
138
  }
package/src/index.tsx CHANGED
@@ -30,7 +30,6 @@ import type Product from './models/Product';
30
30
  import type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';
31
31
  import type {
32
32
  AddToCartButtonConfiguration,
33
- CartIconConfiguration,
34
33
  } from './models/ProductInfoViewConfiguration';
35
34
  import type ProductUnit from './models/ProductUnit';
36
35
  import type { ProductPrice } from './models/ProductUnit';
@@ -70,7 +69,6 @@ export {
70
69
  AddToCartCallback,
71
70
  AddToCartEvent,
72
71
  AddToCartResult,
73
- CartIconConfiguration,
74
72
  ClickCartIconCallback,
75
73
  CustomCTAClickCallback,
76
74
  CustomCTAClickEvent,
@@ -1,7 +1,3 @@
1
- export interface CartIconConfiguration {
2
- isHidden?: boolean;
3
- }
4
-
5
1
  export interface AddToCartButtonConfiguration {
6
2
  backgroundColor?: string;
7
3
  textColor?: string;
@@ -9,10 +5,6 @@ export interface AddToCartButtonConfiguration {
9
5
  }
10
6
 
11
7
  export default interface ProductInfoViewConfiguration {
12
- /**
13
- * Configuration of cart icon.
14
- */
15
- cartIcon?: CartIconConfiguration;
16
8
  /**
17
9
  * Configuration of "Add to cart" button.
18
10
  */
@@ -24,6 +24,8 @@ interface IShoppingModule extends NativeModule {
24
24
  updateAddToCartStatus(res: string, tips: string, callbackId: number): void;
25
25
  jumpToCartPage(callbackId: number): void;
26
26
  exitCartPage(): void;
27
+ setCartIconVisible(visible: boolean): void;
28
+ setCartItemCount(count: number): void;
27
29
  }
28
30
 
29
31
  export default ShoppingModule as IShoppingModule;