react-native-firework-sdk 1.3.0 → 1.3.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +25 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +5 -0
- package/ios/Components/VideoFeedManager.m +1 -0
- package/ios/Models/NativeToRN/FireworkEventName.swift +1 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +6 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +18 -0
- package/ios/Modules/Shopping/CartViewController.swift +1 -1
- package/ios/Modules/Shopping/ShoppingModule.m +5 -4
- package/ios/Modules/Shopping/ShoppingModule.swift +61 -15
- package/lib/commonjs/FireworkSDK.js +16 -3
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +52 -7
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +15 -3
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +46 -7
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +5 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/modules/ShoppingModule.d.ts +1 -0
- package/package.json +1 -1
- package/src/FireworkSDK.ts +17 -3
- package/src/VideoShopping.ts +64 -12
- package/src/index.tsx +2 -0
- package/src/modules/ShoppingModule.ts +1 -0
package/android/build.gradle
CHANGED
|
@@ -168,7 +168,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
|
168
168
|
dependencies {
|
|
169
169
|
|
|
170
170
|
// optional 1: firework sdk release verison
|
|
171
|
-
def firework_sdk_version = '
|
|
171
|
+
def firework_sdk_version = 'debug~landmark-SNAPSHOT'
|
|
172
172
|
implementation "com.github.loopsocial:firework_sdk:$firework_sdk_version"
|
|
173
173
|
|
|
174
174
|
// optional 2: firework sdk local version,
|
package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt
CHANGED
|
@@ -5,12 +5,15 @@ import com.facebook.react.bridge.*
|
|
|
5
5
|
import com.fireworksdk.bridge.models.FWVideoShoppingProduct
|
|
6
6
|
import com.fireworksdk.bridge.reactnative.models.FWVideoShoppingInterface
|
|
7
7
|
import com.fireworksdk.bridge.reactnative.utils.FWEventUtils
|
|
8
|
+
import com.fireworksdk.bridge.utils.FWDateUtils
|
|
8
9
|
import com.fireworksdk.bridge.utils.FWGsonUtil
|
|
9
10
|
import com.fireworksdk.bridge.utils.FWLogUtils
|
|
10
11
|
import com.google.gson.reflect.TypeToken
|
|
11
12
|
import com.loopnow.fireworklibrary.baya.Baya
|
|
12
13
|
import com.loopnow.fireworklibrary.baya.UpdateCartStatus
|
|
13
14
|
import com.loopnow.fireworklibrary.data.ProductBuilder
|
|
15
|
+
import java.util.*
|
|
16
|
+
import kotlin.collections.HashMap
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
class FWVideoShoppingModule(
|
|
@@ -30,6 +33,14 @@ class FWVideoShoppingModule(
|
|
|
30
33
|
@ReactMethod
|
|
31
34
|
override fun updateVideoProducts(productArray: ReadableArray?, videoId: String?) {
|
|
32
35
|
FWLogUtils.d { "FWVideoShoppingModule updateVideoProduct: $videoId" }
|
|
36
|
+
|
|
37
|
+
FWEventUtils.sendLogMessageEvent(
|
|
38
|
+
reactApplicationContext,
|
|
39
|
+
"[Android] Send updateVideoProducts 1 video $videoId ${
|
|
40
|
+
FWDateUtils.getDateString(Date())
|
|
41
|
+
}"
|
|
42
|
+
)
|
|
43
|
+
|
|
33
44
|
if (videoId.isNullOrBlank()) {
|
|
34
45
|
return
|
|
35
46
|
}
|
|
@@ -88,8 +99,22 @@ class FWVideoShoppingModule(
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
|
|
102
|
+
FWEventUtils.sendLogMessageEvent(
|
|
103
|
+
reactApplicationContext,
|
|
104
|
+
"[Android] Send updateVideoProducts 2 video $videoId ${
|
|
105
|
+
FWDateUtils.getDateString(Date())
|
|
106
|
+
}"
|
|
107
|
+
)
|
|
108
|
+
|
|
91
109
|
UiThreadUtil.runOnUiThread {
|
|
92
110
|
Baya.updateProductsComplete(videoId, newProducts)
|
|
111
|
+
|
|
112
|
+
FWEventUtils.sendLogMessageEvent(
|
|
113
|
+
reactApplicationContext,
|
|
114
|
+
"[Android] Send updateVideoProducts 3 video $videoId ${
|
|
115
|
+
FWDateUtils.getDateString(Date())
|
|
116
|
+
}"
|
|
117
|
+
)
|
|
93
118
|
}
|
|
94
119
|
updateProductHandler.remove(videoId)
|
|
95
120
|
}
|
|
@@ -89,6 +89,8 @@ object FWEventUtils {
|
|
|
89
89
|
|
|
90
90
|
eventMap.putMap("info", contentMap)
|
|
91
91
|
|
|
92
|
+
sendLogMessageEvent(reactContext, "[Android] Send VideoFeedClick event ${info.id} ${FWDateUtils.getDateString(Date())}")
|
|
93
|
+
|
|
92
94
|
sendEvent(reactContext, FWEventName.VideoFeedClick.rawValue, eventMap)
|
|
93
95
|
}
|
|
94
96
|
|
|
@@ -159,6 +161,9 @@ object FWEventUtils {
|
|
|
159
161
|
|
|
160
162
|
eventMap.putArray("productIds", productArray)
|
|
161
163
|
eventMap.putString("callbackId", videoId)
|
|
164
|
+
|
|
165
|
+
sendLogMessageEvent(reactContext, "[Android] Send UpdateProductDetails event video $videoId ${FWDateUtils.getDateString(Date())}")
|
|
166
|
+
|
|
162
167
|
sendEvent(reactContext, FWVideoShoppingEventName.UpdateProductDetails.rawValue, eventMap)
|
|
163
168
|
}
|
|
164
169
|
|
|
@@ -36,6 +36,7 @@ enum ShoppingEventName: String, CaseIterable {
|
|
|
36
36
|
case WillDisplayProduct = "fw:shopping:will-display-product"
|
|
37
37
|
case AddToCart = "fw:shopping:add-to-cart"
|
|
38
38
|
case ClickCartIcon = "fw:shopping:click-cart-icon"
|
|
39
|
+
case LogMessage = "fw:log-message"
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/// Live stream event
|
|
@@ -69,6 +69,12 @@ extension FireworkSDKModule: FireworkVideoPlaybackDelegate {
|
|
|
69
69
|
|
|
70
70
|
extension FireworkSDKModule: FireworkVideoFeedDelegate {
|
|
71
71
|
func fireworkVideoDidTapThumbnail(_ eventDetails: FeedEventDetails) {
|
|
72
|
+
#if DEBUG
|
|
73
|
+
let formatter = DateFormatter()
|
|
74
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
75
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": "[iOS] Send VideoFeedClick event id: \(eventDetails.id) \(formatter.string(from: Date()))"])
|
|
76
|
+
#endif
|
|
77
|
+
|
|
72
78
|
sendEvent(withName: FWEventName.VideoFeedClick.rawValue, body: ["info": eventDetails.jsObject])
|
|
73
79
|
}
|
|
74
80
|
}
|
|
@@ -33,6 +33,12 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
|
|
|
33
33
|
|
|
34
34
|
@objc(initializeSDK:)
|
|
35
35
|
func initializeSDK(_ userId: String? = nil) {
|
|
36
|
+
#if DEBUG
|
|
37
|
+
let formatter = DateFormatter()
|
|
38
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
39
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": "[iOS] Call initializeSDK"])
|
|
40
|
+
#endif
|
|
41
|
+
|
|
36
42
|
DispatchQueue.main.async {
|
|
37
43
|
FireworkVideoSDK.initializeSDK(delegate: self, userID: userId)
|
|
38
44
|
FireworkVideoSDK.ctaDelegate = self
|
|
@@ -105,10 +111,22 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
|
|
|
105
111
|
|
|
106
112
|
// MARK: - FireworkVideoSDKDelegate
|
|
107
113
|
func fireworkVideoDidLoadSuccessfully() {
|
|
114
|
+
#if DEBUG
|
|
115
|
+
let formatter = DateFormatter()
|
|
116
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
117
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": "[iOS] Send SDK initialization successful event"])
|
|
118
|
+
#endif
|
|
119
|
+
|
|
108
120
|
sendEvent(withName: FWEventName.SDKInit.rawValue, body: [:])
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
func fireworkVideoDidLoadWith(error: FireworkVideoSDKError) {
|
|
124
|
+
#if DEBUG
|
|
125
|
+
let formatter = DateFormatter()
|
|
126
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
127
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: ["message": "[iOS] Send SDK initialization failure event"])
|
|
128
|
+
#endif
|
|
129
|
+
|
|
112
130
|
sendEvent(withName: FWEventName.SDKInit.rawValue, body: ["error": ["name": error.jsErrorName, "reason": error.recoverySuggestion ?? "default"]])
|
|
113
131
|
}
|
|
114
132
|
}
|
|
@@ -50,7 +50,7 @@ class CartViewController: UIViewController, CartViewRepresentable {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
@objc func showCustomCartView(_ noti: NSNotification) {
|
|
53
|
-
guard let cbId = noti.userInfo?["
|
|
53
|
+
guard let cbId = noti.userInfo?["cbId"] as? Int, callbackId == cbId else {
|
|
54
54
|
return
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
_RCT_EXTERN_REMAP_METHOD(init, initialize, NO)
|
|
13
13
|
RCT_EXTERN_METHOD(setCartIconVisible:(BOOL)visible)
|
|
14
14
|
RCT_EXTERN_METHOD(setCartItemCount:(int)itemCounts)
|
|
15
|
-
RCT_EXTERN_METHOD(updateVideoProducts:(NSArray *)products cbId:(nonnull NSNumber *)
|
|
16
|
-
RCT_EXTERN_METHOD(updateProductViewConfig:(NSDictionary *)config cbId:(nonnull NSNumber *)
|
|
17
|
-
RCT_EXTERN_METHOD(updateAddToCartStatus:(NSString *)res tips:(nullable NSString *)tips cbId:(nonnull NSNumber *)
|
|
18
|
-
RCT_EXTERN_METHOD(jumpToCartPage:(nonnull NSNumber *)
|
|
15
|
+
RCT_EXTERN_METHOD(updateVideoProducts:(NSArray *)products cbId:(nonnull NSNumber *)cbId)
|
|
16
|
+
RCT_EXTERN_METHOD(updateProductViewConfig:(NSDictionary *)config cbId:(nonnull NSNumber *)cbId)
|
|
17
|
+
RCT_EXTERN_METHOD(updateAddToCartStatus:(NSString *)res tips:(nullable NSString *)tips cbId:(nonnull NSNumber *)cbId)
|
|
18
|
+
RCT_EXTERN_METHOD(jumpToCartPage:(nonnull NSNumber *)cbId props:(NSDictionary *)props)
|
|
19
19
|
RCT_EXTERN_METHOD(setCustomClickCartIconEnabled:(BOOL)enabled resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
20
|
+
RCT_EXTERN_METHOD(clearCallbackId:(nonnull NSNumber *)cbId eventName:(nonnull NSString *)name)
|
|
20
21
|
|
|
21
22
|
@end
|
|
@@ -14,8 +14,9 @@ weak var gCartViewController: CartViewController?;
|
|
|
14
14
|
class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewControllerProviding {
|
|
15
15
|
|
|
16
16
|
private var productInfoViewConfigurator: (Int, ProductInfoViewConfigurable)?
|
|
17
|
-
private var
|
|
18
|
-
private var
|
|
17
|
+
private var addToCartHandlerMap: Dictionary<Int, AddToCartHandler> = [:]
|
|
18
|
+
private var productHydratingMap: Dictionary<Int, ProductHydrating> = [:]
|
|
19
|
+
|
|
19
20
|
private var cartViewController: CartViewController?
|
|
20
21
|
private var cartIconVisible = true
|
|
21
22
|
private var itemCounts = 0
|
|
@@ -67,15 +68,42 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
67
68
|
|
|
68
69
|
@objc
|
|
69
70
|
func updateVideoProducts(_ products: [AnyObject]?, cbId: NSNumber) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
#if DEBUG
|
|
72
|
+
let formatter = DateFormatter()
|
|
73
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
74
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: [
|
|
75
|
+
"message": "[iOS] Call updateVideoProducts 1 \(formatter.string(from: Date()))"
|
|
76
|
+
])
|
|
77
|
+
#endif
|
|
78
|
+
|
|
79
|
+
guard let productHydrating = productHydratingMap[Int(truncating: cbId)] else {
|
|
73
80
|
return
|
|
74
81
|
}
|
|
82
|
+
|
|
83
|
+
productHydratingMap.removeValue(forKey: Int(truncating: cbId))
|
|
84
|
+
|
|
85
|
+
#if DEBUG
|
|
86
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: [
|
|
87
|
+
"message": "[iOS] Call updateVideoProducts 2 \(formatter.string(from: Date()))"
|
|
88
|
+
])
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
guard let rProducts = RCTConvert.buildProducts(products) else {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#if DEBUG
|
|
96
|
+
let productIds = rProducts.map({ product in
|
|
97
|
+
return product.productId
|
|
98
|
+
}).joined(separator: ",")
|
|
99
|
+
sendEvent(withName: FWEventName.LogMessage.rawValue, body: [
|
|
100
|
+
"message": "[iOS] Call updateVideoProducts 3 productIds: \(productIds) \(formatter.string(from: Date()))"
|
|
101
|
+
])
|
|
102
|
+
#endif
|
|
75
103
|
|
|
76
104
|
DispatchQueue.main.async {
|
|
77
105
|
for product in rProducts {
|
|
78
|
-
productHydrating.
|
|
106
|
+
productHydrating.hydrateProduct(product.productId, { build in
|
|
79
107
|
return ShoppingModule.hydrateProduct(product, build)
|
|
80
108
|
})
|
|
81
109
|
}
|
|
@@ -100,16 +128,17 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
100
128
|
|
|
101
129
|
@objc
|
|
102
130
|
func updateAddToCartStatus(_ res: String, tips: String?, cbId: NSNumber) {
|
|
103
|
-
guard let handler =
|
|
131
|
+
guard let handler = addToCartHandlerMap[Int(truncating: cbId)] else {
|
|
104
132
|
return
|
|
105
133
|
}
|
|
106
|
-
|
|
134
|
+
|
|
135
|
+
addToCartHandlerMap.removeValue(forKey: Int(truncating: cbId))
|
|
136
|
+
|
|
107
137
|
DispatchQueue.main.async {
|
|
108
|
-
// config.indicator.isHidden = itemCounts == 0
|
|
109
138
|
if res == "success" {
|
|
110
|
-
handler
|
|
139
|
+
handler(.feedbackOnly(.success(message: tips ?? "success")))
|
|
111
140
|
} else {
|
|
112
|
-
handler
|
|
141
|
+
handler(.feedbackOnly(.failure(message: tips ?? "failure")))
|
|
113
142
|
}
|
|
114
143
|
}
|
|
115
144
|
}
|
|
@@ -119,7 +148,7 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
119
148
|
DispatchQueue.main.async {
|
|
120
149
|
let properties: [String: Any] = (props as? [String: Any]) ?? [:]
|
|
121
150
|
let noti = Notification(name: Notification.Name(rawValue: "showCustomCartView"), object: nil, userInfo: [
|
|
122
|
-
"
|
|
151
|
+
"cbId": Int(truncating: cbId),
|
|
123
152
|
"properties": properties
|
|
124
153
|
])
|
|
125
154
|
NotificationCenter.default.post(noti)
|
|
@@ -131,6 +160,15 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
131
160
|
customClickCartIconEnabled = enabled
|
|
132
161
|
resolver([:])
|
|
133
162
|
}
|
|
163
|
+
|
|
164
|
+
@objc
|
|
165
|
+
func clearCallbackId(_ cbId: NSNumber, eventName: String) {
|
|
166
|
+
if eventName == ShoppingEventName.UpdateProductDetails.rawValue {
|
|
167
|
+
productHydratingMap.removeValue(forKey: Int(truncating: cbId))
|
|
168
|
+
} else if eventName == ShoppingEventName.AddToCart.rawValue {
|
|
169
|
+
addToCartHandlerMap.removeValue(forKey: Int(truncating: cbId))
|
|
170
|
+
}
|
|
171
|
+
}
|
|
134
172
|
|
|
135
173
|
// MARK: - FireworkVideoShoppingDelegate
|
|
136
174
|
func fireworkShopping(_ fireworkShopping: FireworkVideoShopping, willDisplayProductInfo productInfoViewConfigurator: ProductInfoViewConfigurable, forVideo video: VideoDetails) {
|
|
@@ -142,15 +180,23 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
142
180
|
|
|
143
181
|
func fireworkShopping(_ fireworkShopping: FireworkVideoShopping, updateDetailsForProducts products: [ProductID], forVideo video: VideoDetails, _ productHydrator: ProductHydrating) {
|
|
144
182
|
let callbackId = ShoppingModule.generateCallbackId()
|
|
145
|
-
self.
|
|
183
|
+
self.productHydratingMap[callbackId] = productHydrator
|
|
184
|
+
|
|
185
|
+
#if DEBUG
|
|
186
|
+
let formatter = DateFormatter()
|
|
187
|
+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
|
|
188
|
+
sendEvent(
|
|
189
|
+
withName: FWEventName.LogMessage.rawValue,
|
|
190
|
+
body: ["message": "[iOS] Send UpdateProductDetails event productIds: \(products) and videoId: \(video.videoID) \(formatter.string(from: Date()))"])
|
|
191
|
+
#endif
|
|
146
192
|
|
|
147
193
|
sendEvent(withName: ShoppingEventName.UpdateProductDetails.rawValue, body: ["productIds": products, "callbackId": callbackId])
|
|
148
194
|
}
|
|
149
195
|
|
|
150
196
|
func fireworkShopping(_ fireworkShopping: FireworkVideoShopping, addProductVariantToCart item: SelectedProductVariant, fromVideo video: VideoDetails, _ addToCartCompletionHandler: @escaping AddToCartHandler) {
|
|
151
197
|
let callbackId = ShoppingModule.generateCallbackId()
|
|
152
|
-
self.
|
|
153
|
-
|
|
198
|
+
self.addToCartHandlerMap[callbackId] = addToCartCompletionHandler
|
|
199
|
+
|
|
154
200
|
sendEvent(withName: ShoppingEventName.AddToCart.rawValue, body: ["productId": item.productID, "unitId": item.unitID, "callbackId": callbackId])
|
|
155
201
|
}
|
|
156
202
|
|
|
@@ -125,6 +125,17 @@ class FireworkSDK {
|
|
|
125
125
|
_FireworkSDKModule.default.setAppComponentName(value !== null && value !== void 0 ? value : '');
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
130
|
+
*/
|
|
131
|
+
get debugLogsEnabled() {
|
|
132
|
+
return _FWLoggerUtil.default.enabled;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
set debugLogsEnabled(value) {
|
|
136
|
+
_FWLoggerUtil.default.enabled = value;
|
|
137
|
+
}
|
|
138
|
+
|
|
128
139
|
get eventEmitter() {
|
|
129
140
|
return _FireworkSDKModule.FireworkSDKModuleEventEmitter;
|
|
130
141
|
}
|
|
@@ -194,21 +205,21 @@ class FireworkSDK {
|
|
|
194
205
|
_FWLoggerUtil.default.logNativeMessage(event.message);
|
|
195
206
|
});
|
|
196
207
|
this.eventEmitter.addListener(_FWEventName.FWEventName.CustomCTAClick, event => {
|
|
197
|
-
_FWLoggerUtil.default.log(`Receive CustomCTAClick url ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
208
|
+
_FWLoggerUtil.default.log(`Receive CustomCTAClick url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
198
209
|
|
|
199
210
|
if (this.onCustomCTAClick) {
|
|
200
211
|
this.onCustomCTAClick(event !== null && event !== void 0 ? event : {});
|
|
201
212
|
}
|
|
202
213
|
});
|
|
203
214
|
this.eventEmitter.addListener(_FWEventName.FWEventName.VideoPlayback, event => {
|
|
204
|
-
_FWLoggerUtil.default.log(`Receive VideoPlayback event ${event === null || event === void 0 ? void 0 : event.eventName}`);
|
|
215
|
+
_FWLoggerUtil.default.log(`Receive VideoPlayback event eventName: ${event === null || event === void 0 ? void 0 : event.eventName}`);
|
|
205
216
|
|
|
206
217
|
if (this.onVideoPlayback) {
|
|
207
218
|
this.onVideoPlayback(event !== null && event !== void 0 ? event : {});
|
|
208
219
|
}
|
|
209
220
|
});
|
|
210
221
|
this.eventEmitter.addListener(_FWEventName.FWEventName.VideoFeedClick, event => {
|
|
211
|
-
_FWLoggerUtil.default.log(`Receive VideoFeedClick event ${event === null || event === void 0 ? void 0 : event.info.id}`);
|
|
222
|
+
_FWLoggerUtil.default.log(`Receive VideoFeedClick event id: ${event === null || event === void 0 ? void 0 : event.info.id}`);
|
|
212
223
|
|
|
213
224
|
if (this.onVideoFeedClick) {
|
|
214
225
|
this.onVideoFeedClick(event !== null && event !== void 0 ? event : {});
|
|
@@ -222,6 +233,8 @@ class FireworkSDK {
|
|
|
222
233
|
|
|
223
234
|
|
|
224
235
|
init(userId) {
|
|
236
|
+
_FWLoggerUtil.default.log('Call FireworkSDK init method');
|
|
237
|
+
|
|
225
238
|
_FireworkSDKModule.default.init(userId);
|
|
226
239
|
|
|
227
240
|
_ShoppingModule.default.init();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FireworkSDK.ts"],"names":["FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","FWLoggerUtil","log","FireworkSDKModule","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","eventEmitter","emit","FWEventName","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","FireworkSDKModuleEventEmitter","shopping","VideoShopping","getInstance","liveStream","LiveStream","navigator","FWNavigator","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","ShoppingModule","LiveStreamModule","openVideoPlayer","config"],"mappings":";;;;;;;AACA;;AAGA;;AAQA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAUA;AACA;AACA;AACA,MAAMA,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AAC6B,MAAhBC,gBAAgB,GAAuC;AAChE,WAAO,KAAKC,iBAAZ;AACD;;AAC0B,MAAhBD,gBAAgB,CAACE,KAAD,EAA4C;AACrEC,0BAAaC,GAAb,CAAkB,iCAAgC,CAAC,CAACF,KAAM,EAA1D;;AACA,SAAKD,iBAAL,GAAyBC,KAAzB;;AACAG,+BAAkBC,wBAAlB,CAA2CJ,KAAK,GAAG,IAAH,GAAU,KAA1D;AACD;;AAGD;AACF;AACA;AAC8C,MAAjCK,iCAAiC,GAAuB;AACjE,WAAO,KAAKC,kCAAZ;AACD;;AAC2C,MAAjCD,iCAAiC,CAACL,KAAD,EAA4B;AACtE,SAAKM,kCAAL,GAA0CN,KAA1C;;AACAG,+BAAkBI,oCAAlB,CAAuDP,KAAvD,aAAuDA,KAAvD,cAAuDA,KAAvD,GAAgE,EAAhE;AACD;;AAGD;AACF;AACA;AAC4B,MAAfQ,eAAe,GAAsC;AAC9D,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACR,KAAD,EAA2C;AACnE,SAAKS,gBAAL,GAAwBT,KAAxB;;AACAG,+BAAkBO,4BAAlB,CAA+CV,KAAK,GAAG,IAAH,GAAU,KAA9D;AACD;;AAGD;AACF;AACA;AACyB,MAAZW,YAAY,GAAuB;AAC5C,WAAO,KAAKC,aAAZ;AACD;;AACsB,MAAZD,YAAY,CAACX,KAAD,EAA4B;AACjD,SAAKY,aAAL,GAAqBZ,KAArB;;AACAG,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AACF,KAND;AAQA,SAAKvB,YAAL,CAAkBqB,WAAlB,CAA8BnB,yBAAY+B,cAA1C,EAA2DV,KAAD,IAAW;AACnErC,4BAAaC,GAAb,CAAkB,gCAA+BoC,KAAhC,aAAgCA,KAAhC,uBAAgCA,KAAK,CAAEW,IAAP,CAAYC,EAAG,EAAhE;;AAEA,UAAI,KAAKC,gBAAT,EAA2B;AACzB,aAAKA,gBAAL,CAAsBb,KAAtB,aAAsBA,KAAtB,cAAsBA,KAAtB,GAA+B,EAA/B;AACD;AACF,KAND;AAOD;AAED;AACF;AACA;AACA;;;AACSc,EAAAA,IAAI,CAACC,MAAD,EAAkB;AAC3BlD,+BAAkBiD,IAAlB,CAAuBC,MAAvB;;AACAC,4BAAeF,IAAf;;AACAG,8BAAiBH,IAAjB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSI,EAAAA,eAAe,CAACX,GAAD,EAAcY,MAAd,EAAiD;AACrEtD,+BAAkBqD,eAAlB,CAAkCX,GAAlC,EAAuCY,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;;AAtLe;;gBAAZ5D,W;;eAyLSA,W","sourcesContent":["import type { NativeEventEmitter } from 'react-native';\nimport LiveStream from './LiveStream';\n\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport VideoShopping from './VideoShopping';\nimport FWNavigator from './FWNavigator';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type CustomCTALinkContentRender = (\n event: CustomCTAClickEvent\n) => React.ReactNode | null;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this._shareBaseURL = value;\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n this._adBadgeConfiguration = value;\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return VideoShopping.getInstance();\n }\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return LiveStream.getInstance();\n }\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return FWNavigator.getInstance();\n }\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(`Receive VideoPlayback event ${event?.eventName}`);\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
1
|
+
{"version":3,"sources":["FireworkSDK.ts"],"names":["FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","FWLoggerUtil","log","FireworkSDKModule","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","eventEmitter","emit","FWEventName","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","debugLogsEnabled","enabled","FireworkSDKModuleEventEmitter","shopping","VideoShopping","getInstance","liveStream","LiveStream","navigator","FWNavigator","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","ShoppingModule","LiveStreamModule","openVideoPlayer","config"],"mappings":";;;;;;;AACA;;AAGA;;AAQA;;AAGA;;A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AKzB,YAAL,CAAkBuB,WAAlB,CAA8BrB,yBAAYiC,cAA1C,EAA2DV,KAAD,IAAW;AACnEvC,4BAAaC,GAAb,CAAkB,oCAAmCsC,KAApC,aAAoCA,KAApC,uBAAoCA,KAAK,CAAEW,IAAP,CAAYC,EAAG,EAApE;;AAEA,UAAI,KAAKC,gBAAT,EAA2B;AACzB,aAAKA,gBAAL,CAAsBb,KAAtB,aAAsBA,KAAtB,cAAsBA,KAAtB,GAA+B,EAA/B;AACD;AACF,KAND;AAOD;AAED;AACF;AACA;AACA;;;AACSc,EAAAA,IAAI,CAACC,MAAD,EAAkB;AAC3BtD,0BAAaC,GAAb,CAAiB,8BAAjB;;AAEAC,+BAAkBmD,IAAlB,CAAuBC,MAAvB;;AACAC,4BAAeF,IAAf;;AACAG,8BAAiBH,IAAjB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSI,EAAAA,eAAe,CAACX,GAAD,EAAcY,MAAd,EAAiD;AACrExD,+BAAkBuD,eAAlB,CAAkCX,GAAlC,EAAuCY,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;;AApMe;;gBAAZ9D,W;;eAuMSA,W","sourcesContent":["import type { NativeEventEmitter } from 'react-native';\nimport LiveStream from './LiveStream';\n\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport VideoShopping from './VideoShopping';\nimport FWNavigator from './FWNavigator';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type CustomCTALinkContentRender = (\n event: CustomCTAClickEvent\n) => React.ReactNode | null;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this._shareBaseURL = value;\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n this._adBadgeConfiguration = value;\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n /**\n * Defaults to false. You can enable debug logs by setting this property to true.\n */\n public get debugLogsEnabled(): boolean {\n return FWLoggerUtil.enabled;\n }\n public set debugLogsEnabled(value: boolean) {\n FWLoggerUtil.enabled = value;\n }\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return VideoShopping.getInstance();\n }\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return LiveStream.getInstance();\n }\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return FWNavigator.getInstance();\n }\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(\n `Receive VideoPlayback event eventName: ${event?.eventName}`\n );\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FWLoggerUtil.log('Call FireworkSDK init method');\n\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
@@ -11,6 +11,10 @@ var _FWEventName = require("./models/FWEventName");
|
|
|
11
11
|
|
|
12
12
|
var _ShoppingModule = _interopRequireWildcard(require("./modules/ShoppingModule"));
|
|
13
13
|
|
|
14
|
+
var _FWLoggerUtil = _interopRequireDefault(require("./utils/FWLoggerUtil"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
14
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
19
|
|
|
16
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -100,6 +104,8 @@ class VideoShopping {
|
|
|
100
104
|
this.handleClickCartIconEvent(event);
|
|
101
105
|
});
|
|
102
106
|
this.eventEmitter.addListener(_FWEventName.FWEventName.UpdateProductDetails, event => {
|
|
107
|
+
_FWLoggerUtil.default.log(`Receive UpdateProductDetails event productIds: ${event.productIds}`);
|
|
108
|
+
|
|
103
109
|
this.handleUpdateProductDetailsEvent(event);
|
|
104
110
|
});
|
|
105
111
|
this.eventEmitter.addListener(_FWEventName.FWEventName.WillDisplayProduct, event => {
|
|
@@ -117,13 +123,28 @@ class VideoShopping {
|
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
async handleAddToCartEvent(event) {
|
|
126
|
+
const callbackId = event.callbackId;
|
|
127
|
+
delete event.callbackId;
|
|
128
|
+
|
|
120
129
|
if (this.onAddToCart) {
|
|
121
|
-
const callbackId = event.callbackId;
|
|
122
|
-
delete event.callbackId;
|
|
123
130
|
const result = await this.onAddToCart(event);
|
|
124
131
|
|
|
125
132
|
if (result) {
|
|
126
|
-
|
|
133
|
+
if (callbackId) {
|
|
134
|
+
_ShoppingModule.default.updateAddToCartStatus(result.res, result.tips, callbackId);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
if (callbackId) {
|
|
138
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
139
|
+
_ShoppingModule.default.clearCallbackId(callbackId, _FWEventName.FWEventName.AddToCart);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
} else {
|
|
144
|
+
if (callbackId) {
|
|
145
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
146
|
+
_ShoppingModule.default.clearCallbackId(callbackId, _FWEventName.FWEventName.AddToCart);
|
|
147
|
+
}
|
|
127
148
|
}
|
|
128
149
|
}
|
|
129
150
|
}
|
|
@@ -143,13 +164,37 @@ class VideoShopping {
|
|
|
143
164
|
}
|
|
144
165
|
|
|
145
166
|
async handleUpdateProductDetailsEvent(event) {
|
|
167
|
+
const callbackId = event.callbackId;
|
|
168
|
+
delete event.callbackId;
|
|
169
|
+
|
|
146
170
|
if (this.onUpdateProductDetails) {
|
|
147
|
-
|
|
148
|
-
|
|
171
|
+
_FWLoggerUtil.default.log(`Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`);
|
|
172
|
+
|
|
149
173
|
const productList = await this.onUpdateProductDetails(event);
|
|
174
|
+
const productIds = (productList || []).map(product => {
|
|
175
|
+
var _product$productId;
|
|
176
|
+
|
|
177
|
+
return (_product$productId = product.productId) !== null && _product$productId !== void 0 ? _product$productId : '';
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
_FWLoggerUtil.default.log(`Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${(productList || []).length}`);
|
|
150
181
|
|
|
151
182
|
if (productList) {
|
|
152
|
-
|
|
183
|
+
if (callbackId) {
|
|
184
|
+
_ShoppingModule.default.updateVideoProducts(productList, callbackId);
|
|
185
|
+
}
|
|
186
|
+
} else {
|
|
187
|
+
if (callbackId) {
|
|
188
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
189
|
+
_ShoppingModule.default.clearCallbackId(callbackId, _FWEventName.FWEventName.UpdateProductDetails);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
if (callbackId) {
|
|
195
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
196
|
+
_ShoppingModule.default.clearCallbackId(callbackId, _FWEventName.FWEventName.UpdateProductDetails);
|
|
197
|
+
}
|
|
153
198
|
}
|
|
154
199
|
}
|
|
155
200
|
}
|
|
@@ -160,7 +205,7 @@ class VideoShopping {
|
|
|
160
205
|
delete event.callbackId;
|
|
161
206
|
const config = await this.onWillDisplayProduct(event);
|
|
162
207
|
|
|
163
|
-
if (config) {
|
|
208
|
+
if (config && callbackId) {
|
|
164
209
|
_ShoppingModule.default.updateProductViewConfig(config, callbackId);
|
|
165
210
|
}
|
|
166
211
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","Platform","OS","ShoppingModule","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","eventEmitter","ShoppingModuleEventEmitter","getInstance","_instance","constructor","addListener","FWEventName","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","setCartItemCount","count","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","updateVideoProducts","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;;;;;;AAAA;;AAQA;;AAGA;;;;;;;;AAyBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACkC,MAArBC,qBAAqB,GAA4C;AAC1E,WAAO,KAAKC,sBAAZ;AACD;;AAC+B,MAArBD,qBAAqB,CAC9BE,KAD8B,EAE9B;AACA,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AGX,KAAK,CAACW,UAAzB;AACA,aAAOX,KAAK,CAACW,UAAb;AACA,YAAMY,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBtB,KADmB,CAArB;;AAGA,UAAIuB,MAAJ,EAAY;AACVpC,gCAAeqC,uBAAf,CAAuCD,MAAvC,EAA+CZ,UAA/C;AACD;AACF;AACF;;AAhKiB;;gBAAd9B,a;;eAmKSA,a","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host 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 NewNativeContainerProps object and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.\n * In the callack, you could call FireworkSDK.getInstance().navigator.popNativeContainer to close the player\n * and call navigation.navigate to push the RN cart page.\n * Currently, there is a limitation on the iOS side when you set the callback.\n * That is, if you set the callback, you need to call FireworkSDK.getInstance().navigator.popNativeContainer in the callback.\n * Otherwise there will be bugs on the iOS side.\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 * 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 private _cartIconVisible: boolean = true;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\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.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 *\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.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (productList) {\n ShoppingModule.updateVideoProducts(productList, 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","onCustomClickCartIcon","_onCustomClickCartIcon","value","Platform","OS","ShoppingModule","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","eventEmitter","ShoppingModuleEventEmitter","getInstance","_instance","constructor","addListener","FWEventName","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","FWLoggerUtil","log","productIds","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","setCartItemCount","count","callbackId","onAddToCart","result","updateAddToCartStatus","res","tips","clearCallbackId","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","map","product","productId","length","updateVideoProducts","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;;;;;;AAAA;;AAQA;;AAGA;;AAIA;;;;;;;;;;AAsBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACkC,MAArBC,qBAAqB,GAA4C;AAC1E,WAAO,KAAKC,sBAAZ;AACD;;AAC+B,MAArBD,qBAAqB,CAC9BE,KAD8B,EAE9B;AACA,SAAKD,sBAAL,GAA8BC,KAA9B;;AACA,QAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,8BAAeC,6BAAf,CAA6C,CAAC,CAACJ,KAA/C;AACD;AACF;;AAiBD;AACF;AACA;AAC4B,MAAfK,eAAe,GAAY;AACpC,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACL,KAAD,EAAiB;AACzC,SAAKM,gBAAL,GAAwBN,KAAxB;;AACAG,4BAAeI,kBAAf,CAAkCP,KAAlC;AACD;;AAGuB,MAAZQ,YAAY,GAAuB;AAC7C,WAAOC,0CAAP;AACD;;AAEwB,SAAXC,WAAW,GAAG;AAC1B,QAAI,CAACb,aAAa,CAACc,SAAnB,EAA8B;AAC5Bd,MAAAA,aAAa,CAACc,SAAd,GAA0B,IAAId,aAAJ,EAA1B;AACD;;AAED,WAAOA,aAAa,CAACc,SAArB;AACD;;AAEOC,EAAAA,WAAW,GAAG;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,8CAdc,IAcd;;AACpB,SAAKJ,Y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AJD,MAIO;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAI5B,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,oCAAegC,eAAf,CACEN,UADF,EAEEf,yBAAYM,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACL,UAAIS,UAAJ,EAAgB;AACd,YAAI5B,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,kCAAegC,eAAf,CACEN,UADF,EAEEf,yBAAYM,oBAFd;AAID;AACF;AACF;AACF;;AAE0C,QAA7BM,6BAA6B,CACzCV,KADyC,EAEzC;AACA,QAAI,KAAK8B,oBAAT,EAA+B;AAC7B,YAAMjB,UAAU,GAAGb,KAAK,CAACa,UAAzB;AACA,aAAOb,KAAK,CAACa,UAAb;AACA,YAAMkB,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnB9B,KADmB,CAArB;;AAGA,UAAI+B,MAAM,IAAIlB,UAAd,EAA0B;AACxB1B,gCAAe6C,uBAAf,CAAuCD,MAAvC,EAA+ClB,UAA/C;AACD;AACF;AACF;;AAnNiB;;gBAAdhC,a;;eAsNSA,a","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host 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 NewNativeContainerProps object and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.\n * In the callack, you could call FireworkSDK.getInstance().navigator.popNativeContainer to close the player\n * and call navigation.navigate to push the RN cart page.\n * Currently, there is a limitation on the iOS side when you set the callback.\n * That is, if you set the callback, you need to call FireworkSDK.getInstance().navigator.popNativeContainer in the callback.\n * Otherwise there will be bugs on the iOS side.\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 * 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 private _cartIconVisible: boolean = true;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\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.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 FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\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 const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onAddToCart) {\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n if (callbackId) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId\n );\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config && callbackId) {\n ShoppingModule.updateProductViewConfig(config, callbackId);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["FireworkSDK"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAQA;;AACA;;AAKA;;AAgBA;;AAEA;;AAkBA;;
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["FireworkSDK"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAQA;;AACA;;AAKA;;AAgBA;;AAEA;;AAkBA;;AAeA;;;;eAEeA,oB","sourcesContent":["import type { IVideoFeedProps, VideoFeedMode } from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n CustomCTALinkContentRender,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport FWNavigator from './FWNavigator';\nimport type {\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n} from './LiveStream';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport type { AdBadgeTextType } from './models/AdBadgeConfiguration';\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 LiveStreamChatEvent,\n LiveStreamEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport LiveStreamChatEventName from './models/LiveStreamChatEventName';\nimport type LiveStreamEventDetails from './models/LiveStreamEventDetails';\nimport LiveStreamEventName from './models/LiveStreamEventName';\nimport type LiveStreamMessageDetails from './models/LiveStreamMessageDetails';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice, ProductUnitOption } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedContentPadding,\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type { VideoFeedSource } from './models/VideoFeedSource';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type { VideoPlayerSize } from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoLaunchBehavior,\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n CustomClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nexport default FireworkSDK;\n\nexport {\n AdBadgeConfiguration,\n AdBadgeTextType,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n ClickCartIconCallback,\n CustomClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n CustomCTALinkContentRender,\n FeedItemDetails,\n FWError,\n FWNavigator,\n IVideoFeedProps,\n LiveStream,\n LiveStreamChatEvent,\n LiveStreamChatEventName,\n LiveStreamEvent,\n LiveStreamEventDetails,\n LiveStreamEventName,\n LiveStreamMessageDetails,\n NewNativeContainerProps,\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n ProductUnitOption,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedContentPadding,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoLaunchBehavior,\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","ShoppingModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA,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;
|
|
1
|
+
{"version":3,"sources":["ShoppingModule.ts"],"names":["ShoppingModule","NativeModules","Proxy","get","Error","LINKING_ERROR","ShoppingModuleEventEmitter","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA,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;AAiCA,MAAMC,0BAA0B,GAAG,IAAIC,+BAAJ,CAAuBP,cAAvB,CAAnC;;eAGeA,c","sourcesContent":["import { NativeEventEmitter, NativeModule, NativeModules } from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\nimport type { NewNativeContainerProps } from 'src/models/NewNativeContainerProps';\n\nconst ShoppingModule = NativeModules.ShoppingModule\n ? NativeModules.ShoppingModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\ninterface IShoppingModule extends NativeModule {\n init(): void;\n updateVideoProducts(products: Product[], callbackId: number | string): void;\n updateProductViewConfig(\n config: ProductInfoViewConfiguration,\n callbackId: number | string\n ): void;\n updateAddToCartStatus(\n res: string,\n tips: string,\n callbackId: number | string\n ): void;\n jumpToCartPage(\n callbackId: number | string,\n props: NewNativeContainerProps\n ): void;\n setCartIconVisible(visible: boolean): void;\n setCartItemCount(count: number): void;\n setCustomClickCartIconEnabled(enabled: boolean): Promise<void>; // Only supported on iOS\n clearCallbackId(callbackId: number | string, eventName: string): void; // Only supported on iOS\n}\n\nconst ShoppingModuleEventEmitter = new NativeEventEmitter(ShoppingModule);\nexport { ShoppingModuleEventEmitter };\n\nexport default ShoppingModule as IShoppingModule;\n"]}
|
|
@@ -98,6 +98,17 @@ class FireworkSDK {
|
|
|
98
98
|
FireworkSDKModule.setAppComponentName(value !== null && value !== void 0 ? value : '');
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
103
|
+
*/
|
|
104
|
+
get debugLogsEnabled() {
|
|
105
|
+
return FWLoggerUtil.enabled;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
set debugLogsEnabled(value) {
|
|
109
|
+
FWLoggerUtil.enabled = value;
|
|
110
|
+
}
|
|
111
|
+
|
|
101
112
|
get eventEmitter() {
|
|
102
113
|
return FireworkSDKModuleEventEmitter;
|
|
103
114
|
}
|
|
@@ -167,21 +178,21 @@ class FireworkSDK {
|
|
|
167
178
|
FWLoggerUtil.logNativeMessage(event.message);
|
|
168
179
|
});
|
|
169
180
|
this.eventEmitter.addListener(FWEventName.CustomCTAClick, event => {
|
|
170
|
-
FWLoggerUtil.log(`Receive CustomCTAClick url ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
181
|
+
FWLoggerUtil.log(`Receive CustomCTAClick url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
171
182
|
|
|
172
183
|
if (this.onCustomCTAClick) {
|
|
173
184
|
this.onCustomCTAClick(event !== null && event !== void 0 ? event : {});
|
|
174
185
|
}
|
|
175
186
|
});
|
|
176
187
|
this.eventEmitter.addListener(FWEventName.VideoPlayback, event => {
|
|
177
|
-
FWLoggerUtil.log(`Receive VideoPlayback event ${event === null || event === void 0 ? void 0 : event.eventName}`);
|
|
188
|
+
FWLoggerUtil.log(`Receive VideoPlayback event eventName: ${event === null || event === void 0 ? void 0 : event.eventName}`);
|
|
178
189
|
|
|
179
190
|
if (this.onVideoPlayback) {
|
|
180
191
|
this.onVideoPlayback(event !== null && event !== void 0 ? event : {});
|
|
181
192
|
}
|
|
182
193
|
});
|
|
183
194
|
this.eventEmitter.addListener(FWEventName.VideoFeedClick, event => {
|
|
184
|
-
FWLoggerUtil.log(`Receive VideoFeedClick event ${event === null || event === void 0 ? void 0 : event.info.id}`);
|
|
195
|
+
FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event === null || event === void 0 ? void 0 : event.info.id}`);
|
|
185
196
|
|
|
186
197
|
if (this.onVideoFeedClick) {
|
|
187
198
|
this.onVideoFeedClick(event !== null && event !== void 0 ? event : {});
|
|
@@ -195,6 +206,7 @@ class FireworkSDK {
|
|
|
195
206
|
|
|
196
207
|
|
|
197
208
|
init(userId) {
|
|
209
|
+
FWLoggerUtil.log('Call FireworkSDK init method');
|
|
198
210
|
FireworkSDKModule.init(userId);
|
|
199
211
|
ShoppingModule.init();
|
|
200
212
|
LiveStreamModule.init();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FireworkSDK.ts"],"names":["LiveStream","FWEventName","FireworkSDKModule","FireworkSDKModuleEventEmitter","LiveStreamModule","ShoppingModule","VideoShopping","FWNavigator","FWLoggerUtil","FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","log","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","eventEmitter","emit","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","shopping","getInstance","liveStream","navigator","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","openVideoPlayer","config"],"mappings":";;AACA,OAAOA,UAAP,MAAuB,cAAvB;AAGA,SAASC,WAAT,QAA4B,sBAA5B;AAQA,OAAOC,iBAAP,IACEC,6BADF,QAEO,6BAFP;AAGA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,YAAP,MAAyB,sBAAzB;;AAUA;AACA;AACA;AACA,MAAMC,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AAC6B,MAAhBC,gBAAgB,GAAuC;AAChE,WAAO,KAAKC,iBAAZ;AACD;;AAC0B,MAAhBD,gBAAgB,CAACE,KAAD,EAA4C;AACrEJ,IAAAA,YAAY,CAACK,GAAb,CAAkB,iCAAgC,CAAC,CAACD,KAAM,EAA1D;AACA,SAAKD,iBAAL,GAAyBC,KAAzB;AACAV,IAAAA,iBAAiB,CAACY,wBAAlB,CAA2CF,KAAK,GAAG,IAAH,GAAU,KAA1D;AACD;;AAGD;AACF;AACA;AAC8C,MAAjCG,iCAAiC,GAAuB;AACjE,WAAO,KAAKC,kCAAZ;AACD;;AAC2C,MAAjCD,iCAAiC,CAACH,KAAD,EAA4B;AACtE,SAAKI,kCAAL,GAA0CJ,KAA1C;AACAV,IAAAA,iBAAiB,CAACe,oCAAlB,CAAuDL,KAAvD,aAAuDA,KAAvD,cAAuDA,KAAvD,GAAgE,EAAhE;AACD;;AAGD;AACF;AACA;AAC4B,MAAfM,eAAe,GAAsC;AAC9D,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,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["import type { NativeEventEmitter } from 'react-native';\nimport LiveStream from './LiveStream';\n\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport VideoShopping from './VideoShopping';\nimport FWNavigator from './FWNavigator';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type CustomCTALinkContentRender = (\n event: CustomCTAClickEvent\n) => React.ReactNode | null;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this._shareBaseURL = value;\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n this._adBadgeConfiguration = value;\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return VideoShopping.getInstance();\n }\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return LiveStream.getInstance();\n }\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return FWNavigator.getInstance();\n }\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(`Receive VideoPlayback event ${event?.eventName}`);\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
1
|
+
{"version":3,"sources":["FireworkSDK.ts"],"names":["LiveStream","FWEventName","FireworkSDKModule","FireworkSDKModuleEventEmitter","LiveStreamModule","ShoppingModule","VideoShopping","FWNavigator","FWLoggerUtil","FireworkSDK","onCustomCTAClick","_onCustomCTAClick","value","log","setCustomCTAClickEnabled","customCTALinkContentPageRouteName","_customCTALinkContentPageRouteName","setCustomCTALinkContentPageRouteName","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","setShareBaseURL","then","eventEmitter","emit","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","debugLogsEnabled","enabled","shopping","getInstance","liveStream","navigator","_instance","constructor","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","openVideoPlayer","config"],"mappings":";;AACA,OAAOA,UAAP,MAAuB,cAAvB;AAGA,SAASC,WAAT,QAA4B,sBAA5B;AAQA,OAAOC,iBAAP,IACEC,6BADF,QAEO,6BAFP;AAGA,OAAOC,gBAAP,MAA6B,4BAA7B;AACA,OAAOC,cAAP,MAA2B,0BAA3B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,YAAP,MAAyB,sBAAzB;;AAUA;AACA;AACA;AACA,MAAMC,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;AACA;;AAGE;AACF;AACA;AAC6B,MAAhBC,gBAAgB,GAAuC;AAChE,WAAO,KAAKC,iBAAZ;AACD;;AAC0B,MAAhBD,gBAAgB,CAACE,KAAD,EAA4C;AACrEJ,IAAAA,YAAY,CAACK,GAAb,CAAkB,iCAAgC,CAAC,CAACD,KAAM,EAA1D;AACA,SAAKD,iBAAL,GAAyBC,KAAzB;AACAV,IAAAA,iBAAiB,CAACY,wBAAlB,CAA2CF,KAAK,GAAG,IAAH,GAAU,KAA1D;AACD;;AAGD;AACF;AACA;AAC8C,MAAjCG,iCAAiC,GAAuB;AACjE,WAAO,KAAKC,kCAAZ;AACD;;AAC2C,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KAND;AAOD;AAED;AACF;AACA;AACA;;;AACSc,EAAAA,IAAI,CAACC,MAAD,EAAkB;AAC3BpD,IAAAA,YAAY,CAACK,GAAb,CAAiB,8BAAjB;AAEAX,IAAAA,iBAAiB,CAACyD,IAAlB,CAAuBC,MAAvB;AACAvD,IAAAA,cAAc,CAACsD,IAAf;AACAvD,IAAAA,gBAAgB,CAACuD,IAAjB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACSE,EAAAA,eAAe,CAACT,GAAD,EAAcU,MAAd,EAAiD;AACrE5D,IAAAA,iBAAiB,CAAC2D,eAAlB,CAAkCT,GAAlC,EAAuCU,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;;AApMe;;gBAAZrD,W;;AAuMN,eAAeA,WAAf","sourcesContent":["import type { NativeEventEmitter } from 'react-native';\nimport LiveStream from './LiveStream';\n\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport VideoShopping from './VideoShopping';\nimport FWNavigator from './FWNavigator';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type CustomCTALinkContentRender = (\n event: CustomCTAClickEvent\n) => React.ReactNode | null;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this._shareBaseURL = value;\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n this._adBadgeConfiguration = value;\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n /**\n * Defaults to false. You can enable debug logs by setting this property to true.\n */\n public get debugLogsEnabled(): boolean {\n return FWLoggerUtil.enabled;\n }\n public set debugLogsEnabled(value: boolean) {\n FWLoggerUtil.enabled = value;\n }\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return VideoShopping.getInstance();\n }\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return LiveStream.getInstance();\n }\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return FWNavigator.getInstance();\n }\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(\n `Receive VideoPlayback event eventName: ${event?.eventName}`\n );\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FWLoggerUtil.log('Call FireworkSDK init method');\n\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
@@ -3,6 +3,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
4
|
import { FWEventName } from './models/FWEventName';
|
|
5
5
|
import ShoppingModule, { ShoppingModuleEventEmitter } from './modules/ShoppingModule';
|
|
6
|
+
import FWLoggerUtil from './utils/FWLoggerUtil';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* The entry class of video shopping.
|
|
@@ -86,6 +87,7 @@ class VideoShopping {
|
|
|
86
87
|
this.handleClickCartIconEvent(event);
|
|
87
88
|
});
|
|
88
89
|
this.eventEmitter.addListener(FWEventName.UpdateProductDetails, event => {
|
|
90
|
+
FWLoggerUtil.log(`Receive UpdateProductDetails event productIds: ${event.productIds}`);
|
|
89
91
|
this.handleUpdateProductDetailsEvent(event);
|
|
90
92
|
});
|
|
91
93
|
this.eventEmitter.addListener(FWEventName.WillDisplayProduct, event => {
|
|
@@ -103,13 +105,28 @@ class VideoShopping {
|
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
async handleAddToCartEvent(event) {
|
|
108
|
+
const callbackId = event.callbackId;
|
|
109
|
+
delete event.callbackId;
|
|
110
|
+
|
|
106
111
|
if (this.onAddToCart) {
|
|
107
|
-
const callbackId = event.callbackId;
|
|
108
|
-
delete event.callbackId;
|
|
109
112
|
const result = await this.onAddToCart(event);
|
|
110
113
|
|
|
111
114
|
if (result) {
|
|
112
|
-
|
|
115
|
+
if (callbackId) {
|
|
116
|
+
ShoppingModule.updateAddToCartStatus(result.res, result.tips, callbackId);
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
if (callbackId) {
|
|
120
|
+
if (Platform.OS === 'ios') {
|
|
121
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
if (callbackId) {
|
|
127
|
+
if (Platform.OS === 'ios') {
|
|
128
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);
|
|
129
|
+
}
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
}
|
|
@@ -129,13 +146,35 @@ class VideoShopping {
|
|
|
129
146
|
}
|
|
130
147
|
|
|
131
148
|
async handleUpdateProductDetailsEvent(event) {
|
|
149
|
+
const callbackId = event.callbackId;
|
|
150
|
+
delete event.callbackId;
|
|
151
|
+
|
|
132
152
|
if (this.onUpdateProductDetails) {
|
|
133
|
-
|
|
134
|
-
delete event.callbackId;
|
|
153
|
+
FWLoggerUtil.log(`Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`);
|
|
135
154
|
const productList = await this.onUpdateProductDetails(event);
|
|
155
|
+
const productIds = (productList || []).map(product => {
|
|
156
|
+
var _product$productId;
|
|
157
|
+
|
|
158
|
+
return (_product$productId = product.productId) !== null && _product$productId !== void 0 ? _product$productId : '';
|
|
159
|
+
});
|
|
160
|
+
FWLoggerUtil.log(`Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${(productList || []).length}`);
|
|
136
161
|
|
|
137
162
|
if (productList) {
|
|
138
|
-
|
|
163
|
+
if (callbackId) {
|
|
164
|
+
ShoppingModule.updateVideoProducts(productList, callbackId);
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
if (callbackId) {
|
|
168
|
+
if (Platform.OS === 'ios') {
|
|
169
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.UpdateProductDetails);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
if (callbackId) {
|
|
175
|
+
if (Platform.OS === 'ios') {
|
|
176
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.UpdateProductDetails);
|
|
177
|
+
}
|
|
139
178
|
}
|
|
140
179
|
}
|
|
141
180
|
}
|
|
@@ -146,7 +185,7 @@ class VideoShopping {
|
|
|
146
185
|
delete event.callbackId;
|
|
147
186
|
const config = await this.onWillDisplayProduct(event);
|
|
148
187
|
|
|
149
|
-
if (config) {
|
|
188
|
+
if (config && callbackId) {
|
|
150
189
|
ShoppingModule.updateProductViewConfig(config, callbackId);
|
|
151
190
|
}
|
|
152
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["Platform","FWEventName","ShoppingModule","ShoppingModuleEventEmitter","VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","OS","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","eventEmitter","getInstance","_instance","constructor","addListener","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","setCartItemCount","count","onAddToCart","callbackId","result","updateAddToCartStatus","res","tips","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","updateVideoProducts","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;AAAA,SAA6BA,QAA7B,QAA6C,cAA7C;AAQA,SAASC,WAAT,QAA4B,sBAA5B;A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AE3C;AACA,QAAI,KAAKmB,sBAAT,EAAiC;AAC/B,YAAMR,UAAU,GAAGX,KAAK,CAACW,UAAzB;AACA,aAAOX,KAAK,CAACW,UAAb;AACA,YAAMS,WAAW,GAAG,MAAM,KAAKD,sBAAL,CACxBnB,KADwB,CAA1B;;AAGA,UAAIoB,WAAJ,EAAiB;AACfrC,QAAAA,cAAc,CAACsC,mBAAf,CAAmCD,WAAnC,EAAgDT,UAAhD;AACD;AACF;AACF;;AAE0C,QAA7BJ,6BAA6B,CACzCP,KADyC,EAEzC;AACA,QAAI,KAAKsB,oBAAT,EAA+B;AAC7B,YAAMX,UAAU,GAAGX,KAAK,CAACW,UAAzB;AACA,aAAOX,KAAK,CAACW,UAAb;AACA,YAAMY,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBtB,KADmB,CAArB;;AAGA,UAAIuB,MAAJ,EAAY;AACVxC,QAAAA,cAAc,CAACyC,uBAAf,CAAuCD,MAAvC,EAA+CZ,UAA/C;AACD;AACF;AACF;;AAhKiB;;gBAAd1B,a;;AAmKN,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host 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 NewNativeContainerProps object and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.\n * In the callack, you could call FireworkSDK.getInstance().navigator.popNativeContainer to close the player\n * and call navigation.navigate to push the RN cart page.\n * Currently, there is a limitation on the iOS side when you set the callback.\n * That is, if you set the callback, you need to call FireworkSDK.getInstance().navigator.popNativeContainer in the callback.\n * Otherwise there will be bugs on the iOS side.\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 * 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 private _cartIconVisible: boolean = true;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\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.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 *\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.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n if (this.onUpdateProductDetails) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n if (productList) {\n ShoppingModule.updateVideoProducts(productList, 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":["Platform","FWEventName","ShoppingModule","ShoppingModuleEventEmitter","FWLoggerUtil","VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","OS","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","eventEmitter","getInstance","_instance","constructor","addListener","AddToCart","event","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","log","productIds","handleUpdateProductDetailsEvent","WillDisplayProduct","handleWillDisplayProductEvent","setCartItemCount","count","callbackId","onAddToCart","result","updateAddToCartStatus","res","tips","clearCallbackId","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","map","product","productId","length","updateVideoProducts","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;AAAA,SAA6BA,QAA7B,QAA6C,cAA7C;AAQA,SAASC,WAAT,QAA4B,sBAA5B;AAGA,OAAOC,cAAP,IACEC,0BADF,QAEO,0BAFP;AAIA,OAAOC,YAAP,MAAyB,sBAAzB;;AAsBA;AACA;AACA;AACA,MAAMC,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACkC,MAArBC,qBAAqB,GAA4C;AAC1E,WAAO,KAAKC,sBAAZ;AACD;;AAC+B,MAArBD,qBAAqB,CAC9BE,KAD8B,EAE9B;AACA,SAAKD,sBAAL,GAA8BC,KAA9B;;AACA,QAAIR,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,MAAAA,cAAc,CAACQ,6BAAf,CAA6C,CAAC,CAACF,KAA/C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UAAb;AACA,YAAMkB,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnB7B,KADmB,CAArB;;AAGA,UAAI8B,MAAM,IAAIlB,UAAd,EAA0B;AACxB9B,QAAAA,cAAc,CAACiD,uBAAf,CAAuCD,MAAvC,EAA+ClB,UAA/C;AACD;AACF;AACF;;AAnNiB;;gBAAd3B,a;;AAsNN,eAAeA,aAAf","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host 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 NewNativeContainerProps object and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the processing logic of clicking the shopping cart icon by setting the callback.\n * In the callack, you could call FireworkSDK.getInstance().navigator.popNativeContainer to close the player\n * and call navigation.navigate to push the RN cart page.\n * Currently, there is a limitation on the iOS side when you set the callback.\n * That is, if you set the callback, you need to call FireworkSDK.getInstance().navigator.popNativeContainer in the callback.\n * Otherwise there will be bugs on the iOS side.\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 * 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 private _cartIconVisible: boolean = true;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\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.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 FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n this.handleWillDisplayProductEvent(event);\n });\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 const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onAddToCart) {\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n if (callbackId) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId\n );\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config && callbackId) {\n ShoppingModule.updateProductViewConfig(config, callbackId);\n }\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["VideoFeed","FireworkSDK","FWNavigator","LiveStream","LiveStreamChatEventName","LiveStreamEventName","VideoPlaybackEventName","VideoShopping"],"mappings":"AACA,OAAOA,SAAP,MAAsB,wBAAtB;AAQA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AAKA,OAAOC,UAAP,MAAuB,cAAvB;AAgBA,OAAOC,uBAAP,MAAoC,kCAApC;AAEA,OAAOC,mBAAP,MAAgC,8BAAhC;AAkBA,OAAOC,sBAAP,MAAmC,iCAAnC;
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["VideoFeed","FireworkSDK","FWNavigator","LiveStream","LiveStreamChatEventName","LiveStreamEventName","VideoPlaybackEventName","VideoShopping"],"mappings":"AACA,OAAOA,SAAP,MAAsB,wBAAtB;AAQA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AAKA,OAAOC,UAAP,MAAuB,cAAvB;AAgBA,OAAOC,uBAAP,MAAoC,kCAApC;AAEA,OAAOC,mBAAP,MAAgC,8BAAhC;AAkBA,OAAOC,sBAAP,MAAmC,iCAAnC;AAeA,OAAOC,aAAP,MAA0B,iBAA1B;AAEA,eAAeN,WAAf;AAEA,SAcEC,WAdF,EAgBEC,UAhBF,EAkBEC,uBAlBF,EAqBEC,mBArBF,EAmCEL,SAnCF,EAgDEM,sBAhDF,EAsDEC,aAtDF","sourcesContent":["import type { IVideoFeedProps, VideoFeedMode } from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n CustomCTALinkContentRender,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport FWNavigator from './FWNavigator';\nimport type {\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n} from './LiveStream';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport type { AdBadgeTextType } from './models/AdBadgeConfiguration';\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 LiveStreamChatEvent,\n LiveStreamEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport LiveStreamChatEventName from './models/LiveStreamChatEventName';\nimport type LiveStreamEventDetails from './models/LiveStreamEventDetails';\nimport LiveStreamEventName from './models/LiveStreamEventName';\nimport type LiveStreamMessageDetails from './models/LiveStreamMessageDetails';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice, ProductUnitOption } from './models/ProductUnit';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedContentPadding,\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type { VideoFeedSource } from './models/VideoFeedSource';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type { VideoPlayerSize } from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoLaunchBehavior,\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n CustomClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nexport default FireworkSDK;\n\nexport {\n AdBadgeConfiguration,\n AdBadgeTextType,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n ClickCartIconCallback,\n CustomClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n CustomCTALinkContentRender,\n FeedItemDetails,\n FWError,\n FWNavigator,\n IVideoFeedProps,\n LiveStream,\n LiveStreamChatEvent,\n LiveStreamChatEventName,\n LiveStreamEvent,\n LiveStreamEventDetails,\n LiveStreamEventName,\n LiveStreamMessageDetails,\n NewNativeContainerProps,\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n ProductUnitOption,\n SDKInitCallback,\n SDKInitEvent,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedContentPadding,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoLaunchBehavior,\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":["NativeEventEmitter","NativeModules","LINKING_ERROR","ShoppingModule","Proxy","get","Error","ShoppingModuleEventEmitter"],"mappings":"AAAA,SAASA,kBAAT,EAA2CC,aAA3C,QAAgE,cAAhE;AAGA,SAASC,aAAT,QAA8B,6BAA9B;AAGA,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;
|
|
1
|
+
{"version":3,"sources":["ShoppingModule.ts"],"names":["NativeEventEmitter","NativeModules","LINKING_ERROR","ShoppingModule","Proxy","get","Error","ShoppingModuleEventEmitter"],"mappings":"AAAA,SAASA,kBAAT,EAA2CC,aAA3C,QAAgE,cAAhE;AAGA,SAASC,aAAT,QAA8B,6BAA9B;AAGA,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;AAiCA,MAAMK,0BAA0B,GAAG,IAAIP,kBAAJ,CAAuBG,cAAvB,CAAnC;AACA,SAASI,0BAAT;AAEA,eAAeJ,cAAf","sourcesContent":["import { NativeEventEmitter, NativeModule, NativeModules } from 'react-native';\nimport type Product from '../models/Product';\nimport type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';\nimport { LINKING_ERROR } from '../constants/FWErrorMessage';\nimport type { NewNativeContainerProps } from 'src/models/NewNativeContainerProps';\n\nconst ShoppingModule = NativeModules.ShoppingModule\n ? NativeModules.ShoppingModule\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\ninterface IShoppingModule extends NativeModule {\n init(): void;\n updateVideoProducts(products: Product[], callbackId: number | string): void;\n updateProductViewConfig(\n config: ProductInfoViewConfiguration,\n callbackId: number | string\n ): void;\n updateAddToCartStatus(\n res: string,\n tips: string,\n callbackId: number | string\n ): void;\n jumpToCartPage(\n callbackId: number | string,\n props: NewNativeContainerProps\n ): void;\n setCartIconVisible(visible: boolean): void;\n setCartItemCount(count: number): void;\n setCustomClickCartIconEnabled(enabled: boolean): Promise<void>; // Only supported on iOS\n clearCallbackId(callbackId: number | string, eventName: string): void; // Only supported on iOS\n}\n\nconst ShoppingModuleEventEmitter = new NativeEventEmitter(ShoppingModule);\nexport { ShoppingModuleEventEmitter };\n\nexport default ShoppingModule as IShoppingModule;\n"]}
|
|
@@ -59,6 +59,11 @@ declare class FireworkSDK {
|
|
|
59
59
|
get appComponentName(): string | undefined;
|
|
60
60
|
set appComponentName(value: string | undefined);
|
|
61
61
|
private _appComponentName;
|
|
62
|
+
/**
|
|
63
|
+
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
64
|
+
*/
|
|
65
|
+
get debugLogsEnabled(): boolean;
|
|
66
|
+
set debugLogsEnabled(value: boolean);
|
|
62
67
|
private get eventEmitter();
|
|
63
68
|
/**
|
|
64
69
|
* Get VideoShopping object.
|
|
@@ -29,7 +29,7 @@ import type { VideoPlayerSize } from './models/VideoPlaybackDetails';
|
|
|
29
29
|
import VideoPlaybackEventName from './models/VideoPlaybackEventName';
|
|
30
30
|
import type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';
|
|
31
31
|
import type { VideoLaunchBehavior, VideoPlayerCompleteAction, VideoPlayerCTAStyle, VideoPlayerStyle } from './models/VideoPlayerConfiguration';
|
|
32
|
-
import type { AddToCartCallback, ClickCartIconCallback, UpdateProductDetailsCallback, WillDisplayProductCallback } from './VideoShopping';
|
|
32
|
+
import type { AddToCartCallback, ClickCartIconCallback, CustomClickCartIconCallback, UpdateProductDetailsCallback, WillDisplayProductCallback } from './VideoShopping';
|
|
33
33
|
import VideoShopping from './VideoShopping';
|
|
34
34
|
export default FireworkSDK;
|
|
35
|
-
export { AdBadgeConfiguration, AdBadgeTextType, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, ClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, CustomCTALinkContentRender, FeedItemDetails, FWError, FWNavigator, IVideoFeedProps, LiveStream, LiveStreamChatEvent, LiveStreamChatEventName, LiveStreamEvent, LiveStreamEventDetails, LiveStreamEventName, LiveStreamMessageDetails, NewNativeContainerProps, onLiveStreamChatEventCallback, onLiveStreamEventCallback, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, ProductUnitOption, SDKInitCallback, SDKInitEvent, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedContentPadding, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoLaunchBehavior, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
|
|
35
|
+
export { AdBadgeConfiguration, AdBadgeTextType, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, ClickCartIconCallback, CustomClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, CustomCTALinkContentRender, FeedItemDetails, FWError, FWNavigator, IVideoFeedProps, LiveStream, LiveStreamChatEvent, LiveStreamChatEventName, LiveStreamEvent, LiveStreamEventDetails, LiveStreamEventName, LiveStreamMessageDetails, NewNativeContainerProps, onLiveStreamChatEventCallback, onLiveStreamEventCallback, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, ProductUnitOption, SDKInitCallback, SDKInitEvent, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedContentPadding, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoLaunchBehavior, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
|
|
@@ -11,6 +11,7 @@ interface IShoppingModule extends NativeModule {
|
|
|
11
11
|
setCartIconVisible(visible: boolean): void;
|
|
12
12
|
setCartItemCount(count: number): void;
|
|
13
13
|
setCustomClickCartIconEnabled(enabled: boolean): Promise<void>;
|
|
14
|
+
clearCallbackId(callbackId: number | string, eventName: string): void;
|
|
14
15
|
}
|
|
15
16
|
declare const ShoppingModuleEventEmitter: NativeEventEmitter;
|
|
16
17
|
export { ShoppingModuleEventEmitter };
|
package/package.json
CHANGED
package/src/FireworkSDK.ts
CHANGED
|
@@ -120,6 +120,16 @@ class FireworkSDK {
|
|
|
120
120
|
}
|
|
121
121
|
private _appComponentName: string | undefined;
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Defaults to false. You can enable debug logs by setting this property to true.
|
|
125
|
+
*/
|
|
126
|
+
public get debugLogsEnabled(): boolean {
|
|
127
|
+
return FWLoggerUtil.enabled;
|
|
128
|
+
}
|
|
129
|
+
public set debugLogsEnabled(value: boolean) {
|
|
130
|
+
FWLoggerUtil.enabled = value;
|
|
131
|
+
}
|
|
132
|
+
|
|
123
133
|
private get eventEmitter(): NativeEventEmitter {
|
|
124
134
|
return FireworkSDKModuleEventEmitter;
|
|
125
135
|
}
|
|
@@ -171,7 +181,7 @@ class FireworkSDK {
|
|
|
171
181
|
});
|
|
172
182
|
|
|
173
183
|
this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {
|
|
174
|
-
FWLoggerUtil.log(`Receive CustomCTAClick url ${event?.url}`);
|
|
184
|
+
FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);
|
|
175
185
|
|
|
176
186
|
if (this.onCustomCTAClick) {
|
|
177
187
|
this.onCustomCTAClick(event ?? {});
|
|
@@ -179,7 +189,9 @@ class FireworkSDK {
|
|
|
179
189
|
});
|
|
180
190
|
|
|
181
191
|
this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {
|
|
182
|
-
FWLoggerUtil.log(
|
|
192
|
+
FWLoggerUtil.log(
|
|
193
|
+
`Receive VideoPlayback event eventName: ${event?.eventName}`
|
|
194
|
+
);
|
|
183
195
|
|
|
184
196
|
if (this.onVideoPlayback) {
|
|
185
197
|
this.onVideoPlayback(event ?? {});
|
|
@@ -187,7 +199,7 @@ class FireworkSDK {
|
|
|
187
199
|
});
|
|
188
200
|
|
|
189
201
|
this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {
|
|
190
|
-
FWLoggerUtil.log(`Receive VideoFeedClick event ${event?.info.id}`);
|
|
202
|
+
FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);
|
|
191
203
|
|
|
192
204
|
if (this.onVideoFeedClick) {
|
|
193
205
|
this.onVideoFeedClick(event ?? {});
|
|
@@ -200,6 +212,8 @@ class FireworkSDK {
|
|
|
200
212
|
* @param {string?} userId An id to uniquely identify device or user.
|
|
201
213
|
*/
|
|
202
214
|
public init(userId?: string) {
|
|
215
|
+
FWLoggerUtil.log('Call FireworkSDK init method');
|
|
216
|
+
|
|
203
217
|
FireworkSDKModule.init(userId);
|
|
204
218
|
ShoppingModule.init();
|
|
205
219
|
LiveStreamModule.init();
|
package/src/VideoShopping.ts
CHANGED
|
@@ -13,6 +13,7 @@ import ShoppingModule, {
|
|
|
13
13
|
ShoppingModuleEventEmitter,
|
|
14
14
|
} from './modules/ShoppingModule';
|
|
15
15
|
import type { NewNativeContainerProps } from './models/NewNativeContainerProps';
|
|
16
|
+
import FWLoggerUtil from './utils/FWLoggerUtil';
|
|
16
17
|
|
|
17
18
|
export type AddToCartCallback = (
|
|
18
19
|
event: AddToCartEvent
|
|
@@ -125,6 +126,9 @@ class VideoShopping {
|
|
|
125
126
|
});
|
|
126
127
|
|
|
127
128
|
this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {
|
|
129
|
+
FWLoggerUtil.log(
|
|
130
|
+
`Receive UpdateProductDetails event productIds: ${event.productIds}`
|
|
131
|
+
);
|
|
128
132
|
this.handleUpdateProductDetailsEvent(event);
|
|
129
133
|
});
|
|
130
134
|
|
|
@@ -142,16 +146,30 @@ class VideoShopping {
|
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {
|
|
149
|
+
const callbackId = event.callbackId;
|
|
150
|
+
delete event.callbackId;
|
|
145
151
|
if (this.onAddToCart) {
|
|
146
|
-
const callbackId = event.callbackId;
|
|
147
|
-
delete event.callbackId;
|
|
148
152
|
const result = await this.onAddToCart(event as AddToCartEvent);
|
|
149
153
|
if (result) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
if (callbackId) {
|
|
155
|
+
ShoppingModule.updateAddToCartStatus(
|
|
156
|
+
result.res,
|
|
157
|
+
result.tips,
|
|
158
|
+
callbackId
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
if (callbackId) {
|
|
163
|
+
if (Platform.OS === 'ios') {
|
|
164
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
if (callbackId) {
|
|
170
|
+
if (Platform.OS === 'ios') {
|
|
171
|
+
ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);
|
|
172
|
+
}
|
|
155
173
|
}
|
|
156
174
|
}
|
|
157
175
|
}
|
|
@@ -172,14 +190,48 @@ class VideoShopping {
|
|
|
172
190
|
private async handleUpdateProductDetailsEvent(
|
|
173
191
|
event: UpdateProductDetailsEvent & CallbackInfo
|
|
174
192
|
) {
|
|
193
|
+
const callbackId = event.callbackId;
|
|
194
|
+
delete event.callbackId;
|
|
175
195
|
if (this.onUpdateProductDetails) {
|
|
176
|
-
|
|
177
|
-
|
|
196
|
+
FWLoggerUtil.log(
|
|
197
|
+
`Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`
|
|
198
|
+
);
|
|
178
199
|
const productList = await this.onUpdateProductDetails(
|
|
179
200
|
event as UpdateProductDetailsEvent
|
|
180
201
|
);
|
|
202
|
+
|
|
203
|
+
const productIds = (productList || []).map(
|
|
204
|
+
(product) => product.productId ?? ''
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
FWLoggerUtil.log(
|
|
208
|
+
`Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${
|
|
209
|
+
(productList || []).length
|
|
210
|
+
}`
|
|
211
|
+
);
|
|
212
|
+
|
|
181
213
|
if (productList) {
|
|
182
|
-
|
|
214
|
+
if (callbackId) {
|
|
215
|
+
ShoppingModule.updateVideoProducts(productList, callbackId);
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
if (callbackId) {
|
|
219
|
+
if (Platform.OS === 'ios') {
|
|
220
|
+
ShoppingModule.clearCallbackId(
|
|
221
|
+
callbackId,
|
|
222
|
+
FWEventName.UpdateProductDetails
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
if (callbackId) {
|
|
229
|
+
if (Platform.OS === 'ios') {
|
|
230
|
+
ShoppingModule.clearCallbackId(
|
|
231
|
+
callbackId,
|
|
232
|
+
FWEventName.UpdateProductDetails
|
|
233
|
+
);
|
|
234
|
+
}
|
|
183
235
|
}
|
|
184
236
|
}
|
|
185
237
|
}
|
|
@@ -193,8 +245,8 @@ class VideoShopping {
|
|
|
193
245
|
const config = await this.onWillDisplayProduct(
|
|
194
246
|
event as WillDisplayProductEvent
|
|
195
247
|
);
|
|
196
|
-
if (config) {
|
|
197
|
-
ShoppingModule.updateProductViewConfig(config, callbackId
|
|
248
|
+
if (config && callbackId) {
|
|
249
|
+
ShoppingModule.updateProductViewConfig(config, callbackId);
|
|
198
250
|
}
|
|
199
251
|
}
|
|
200
252
|
}
|
package/src/index.tsx
CHANGED
|
@@ -60,6 +60,7 @@ import type {
|
|
|
60
60
|
import type {
|
|
61
61
|
AddToCartCallback,
|
|
62
62
|
ClickCartIconCallback,
|
|
63
|
+
CustomClickCartIconCallback,
|
|
63
64
|
UpdateProductDetailsCallback,
|
|
64
65
|
WillDisplayProductCallback,
|
|
65
66
|
} from './VideoShopping';
|
|
@@ -75,6 +76,7 @@ export {
|
|
|
75
76
|
AddToCartEvent,
|
|
76
77
|
AddToCartResult,
|
|
77
78
|
ClickCartIconCallback,
|
|
79
|
+
CustomClickCartIconCallback,
|
|
78
80
|
CustomCTAClickCallback,
|
|
79
81
|
CustomCTAClickEvent,
|
|
80
82
|
CustomCTALinkContentRender,
|
|
@@ -34,6 +34,7 @@ interface IShoppingModule extends NativeModule {
|
|
|
34
34
|
setCartIconVisible(visible: boolean): void;
|
|
35
35
|
setCartItemCount(count: number): void;
|
|
36
36
|
setCustomClickCartIconEnabled(enabled: boolean): Promise<void>; // Only supported on iOS
|
|
37
|
+
clearCallbackId(callbackId: number | string, eventName: string): void; // Only supported on iOS
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
const ShoppingModuleEventEmitter = new NativeEventEmitter(ShoppingModule);
|