react-native-firework-sdk 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +0 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +11 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +3 -3
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +9 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWLanguageUtil.kt +20 -2
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWVideoPlayerUtils.kt +1 -0
- package/ios/Components/StoryBlock.swift +1 -8
- package/ios/Components/StoryBlockManager.swift +4 -0
- package/ios/Components/VideoFeed.swift +9 -14
- package/ios/Components/VideoFeedConfiguration.swift +2 -0
- package/ios/Components/VideoFeedManager.m +2 -0
- package/ios/Components/VideoFeedManager.swift +4 -0
- package/ios/Components/VideoPlayerConfiguration.swift +1 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +12 -8
- package/ios/Models/Common/FontInfo.swift +57 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.m +2 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +249 -103
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +0 -2
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +12 -12
- package/ios/Modules/LiveStream/LiveStreamModule.swift +5 -3
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +7 -2
- package/ios/Modules/Shopping/ShoppingModule.m +1 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +72 -63
- package/ios/Utils/FWSwizzleLoader.m +0 -1
- package/lib/commonjs/FWNavigator.js +32 -1
- package/lib/commonjs/FWNavigator.js.map +1 -1
- package/lib/commonjs/FireworkSDK.js +9 -12
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +64 -9
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +14 -5
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +1 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/IOSFontInfo.js +2 -0
- package/lib/commonjs/models/IOSFontInfo.js.map +1 -0
- package/lib/commonjs/modules/FWNavigatorModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FWNavigator.js +31 -1
- package/lib/module/FWNavigator.js.map +1 -1
- package/lib/module/FireworkSDK.js +10 -11
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +63 -9
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/VideoFeed.js +14 -5
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +1 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/IOSFontInfo.js +2 -0
- package/lib/module/models/IOSFontInfo.js.map +1 -0
- package/lib/module/modules/FWNavigatorModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FWNavigator.d.ts +16 -1
- package/lib/typescript/FireworkSDK.d.ts +2 -0
- package/lib/typescript/VideoShopping.d.ts +28 -6
- package/lib/typescript/components/VideoFeed.d.ts +4 -0
- package/lib/typescript/index.d.ts +6 -4
- package/lib/typescript/models/FWEventName.d.ts +2 -1
- package/lib/typescript/models/FWEvents.d.ts +5 -0
- package/lib/typescript/models/IOSFontInfo.d.ts +19 -0
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +23 -0
- package/lib/typescript/models/VideoFeedConfiguration.d.ts +19 -1
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +16 -0
- package/lib/typescript/modules/FWNavigatorModule.d.ts +2 -0
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -1
- package/package.json +1 -1
- package/react-native-firework-sdk.podspec +1 -1
- package/src/{FWNavigator.tsx → FWNavigator.ts} +29 -1
- package/src/FireworkSDK.ts +10 -10
- package/src/VideoShopping.ts +83 -11
- package/src/components/VideoFeed.tsx +12 -2
- package/src/{index.tsx → index.ts} +17 -1
- package/src/models/FWEventName.ts +1 -0
- package/src/models/FWEvents.ts +6 -0
- package/src/models/IOSFontInfo.ts +29 -0
- package/src/models/ProductInfoViewConfiguration.ts +25 -0
- package/src/models/VideoFeedConfiguration.ts +20 -1
- package/src/models/VideoPlayerConfiguration.ts +17 -0
- package/src/modules/FWNavigatorModule.ts +2 -0
- package/src/modules/ShoppingModule.ts +2 -4
- package/ios/Utils/FWPiPManager.swift +0 -24
- package/ios/Utils/UIButton+FWSwizzle.swift +0 -33
|
@@ -21,6 +21,7 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
21
21
|
private var cartIconVisible = true
|
|
22
22
|
private var itemCounts = 0
|
|
23
23
|
private var customClickCartIconEnabled = false
|
|
24
|
+
private var productInfoViewConfiguration: ProductInfoViewConfiguration?
|
|
24
25
|
|
|
25
26
|
override func supportedEvents() -> [String]! {
|
|
26
27
|
ShoppingEventName.allCases.map { $0.rawValue }
|
|
@@ -30,6 +31,10 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
30
31
|
return true
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
override var methodQueue: DispatchQueue {
|
|
35
|
+
return DispatchQueue.main
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
private static func generateCallbackId() -> Int {
|
|
34
39
|
struct CBIdIncreasingFactor {
|
|
35
40
|
static var callbackId = 0
|
|
@@ -41,15 +46,18 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
41
46
|
|
|
42
47
|
@objc
|
|
43
48
|
func initialize() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
FireworkVideoSDK.shopping.cartViewControllerProvider = self
|
|
47
|
-
}
|
|
49
|
+
FireworkVideoSDK.shopping.shoppingDelegate = self
|
|
50
|
+
FireworkVideoSDK.shopping.cartViewControllerProvider = self
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
@objc
|
|
51
54
|
func setCartIconVisible(_ visible: Bool) {
|
|
52
55
|
cartIconVisible = visible
|
|
56
|
+
guard let rProductInfoViewConfigurator = productInfoViewConfigurator else {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
rProductInfoViewConfigurator.1.shoppingCartIconConfiguration.isHidden = !visible
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
@objc
|
|
@@ -59,13 +67,8 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
59
67
|
guard let rProductInfoViewConfigurator = productInfoViewConfigurator else {
|
|
60
68
|
return
|
|
61
69
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.shoppingCartIconConfiguration
|
|
65
|
-
shoppingCartIconConfiguration.indicator.isHidden = itemCounts == 0
|
|
66
|
-
rProductInfoViewConfigurator.1.shoppingCartIconConfiguration =
|
|
67
|
-
shoppingCartIconConfiguration
|
|
68
|
-
}
|
|
70
|
+
|
|
71
|
+
rProductInfoViewConfigurator.1.shoppingCartIconConfiguration.indicator.isHidden = itemCounts == 0
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
@objc
|
|
@@ -119,33 +122,11 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
119
122
|
])
|
|
120
123
|
#endif
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
product
|
|
126
|
-
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@objc
|
|
133
|
-
func updateProductViewConfig(_ config: [String: Any]?, cbId: NSNumber) {
|
|
134
|
-
let config = RCTConvert.buildProductInfoViewConfiguration(config)
|
|
135
|
-
guard let rConfig = config, let rProductInfoViewConfigurator = productInfoViewConfigurator,
|
|
136
|
-
rProductInfoViewConfigurator.0 == Int(truncating: cbId)
|
|
137
|
-
else {
|
|
138
|
-
return
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
DispatchQueue.main.async {
|
|
142
|
-
// The configuration of CartIcon'visible determined by global cartIconVisible
|
|
143
|
-
rProductInfoViewConfigurator.1.shoppingCartIconConfiguration.isHidden = !self
|
|
144
|
-
.cartIconVisible
|
|
145
|
-
// The configuration of CartIcon'indicator'visible determined by global itemCounts
|
|
146
|
-
rProductInfoViewConfigurator.1.shoppingCartIconConfiguration.indicator.isHidden =
|
|
147
|
-
self.itemCounts == 0
|
|
148
|
-
ShoppingModule.hydrateProductViewConfig(rConfig, rProductInfoViewConfigurator.1)
|
|
125
|
+
for product in rProducts {
|
|
126
|
+
productHydrating.hydrateProduct(
|
|
127
|
+
product.productId, { build in
|
|
128
|
+
return ShoppingModule.hydrateProduct(product, build)
|
|
129
|
+
})
|
|
149
130
|
}
|
|
150
131
|
}
|
|
151
132
|
|
|
@@ -157,27 +138,23 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
157
138
|
|
|
158
139
|
addToCartHandlerMap.removeValue(forKey: Int(truncating: cbId))
|
|
159
140
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
handler(.feedbackOnly(.failure(message: tips ?? "failure")))
|
|
165
|
-
}
|
|
141
|
+
if res == "success" {
|
|
142
|
+
handler(.feedbackOnly(.success(message: tips ?? "success")))
|
|
143
|
+
} else {
|
|
144
|
+
handler(.feedbackOnly(.failure(message: tips ?? "failure")))
|
|
166
145
|
}
|
|
167
146
|
}
|
|
168
147
|
|
|
169
148
|
@objc
|
|
170
149
|
func jumpToCartPage(_ cbId: NSNumber, props: NSDictionary) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
NotificationCenter.default.post(noti)
|
|
180
|
-
}
|
|
150
|
+
let properties: [String: Any] = (props as? [String: Any]) ?? [:]
|
|
151
|
+
let noti = Notification(
|
|
152
|
+
name: Notification.Name(rawValue: "showCustomCartView"), object: nil,
|
|
153
|
+
userInfo: [
|
|
154
|
+
"cbId": Int(truncating: cbId),
|
|
155
|
+
"properties": properties
|
|
156
|
+
])
|
|
157
|
+
NotificationCenter.default.post(noti)
|
|
181
158
|
}
|
|
182
159
|
|
|
183
160
|
@objc
|
|
@@ -189,6 +166,22 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
189
166
|
resolver([:])
|
|
190
167
|
}
|
|
191
168
|
|
|
169
|
+
@objc
|
|
170
|
+
func setProductInfoViewConfiguration(_ config: [String: Any]?) {
|
|
171
|
+
let config = RCTConvert.buildProductInfoViewConfiguration(config)
|
|
172
|
+
guard let rConfig = config else {
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
productInfoViewConfiguration = rConfig
|
|
177
|
+
|
|
178
|
+
guard let rProductInfoViewConfigurator = productInfoViewConfigurator else {
|
|
179
|
+
return
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
ShoppingModule.hydrateProductViewConfig(rConfig, rProductInfoViewConfigurator.1)
|
|
183
|
+
}
|
|
184
|
+
|
|
192
185
|
@objc
|
|
193
186
|
func clearCallbackId(_ cbId: NSNumber, eventName: String) {
|
|
194
187
|
if eventName == ShoppingEventName.updateProductDetails.rawValue {
|
|
@@ -207,6 +200,11 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate, CartViewCo
|
|
|
207
200
|
let callbackId = ShoppingModule.generateCallbackId()
|
|
208
201
|
self.productInfoViewConfigurator = (callbackId, productInfoViewConfigurator)
|
|
209
202
|
productInfoViewConfigurator.shoppingCartIconConfiguration.isHidden = !self.cartIconVisible
|
|
203
|
+
productInfoViewConfigurator.shoppingCartIconConfiguration.indicator.isHidden = itemCounts == 0
|
|
204
|
+
|
|
205
|
+
if let productInfoViewConfiguration = productInfoViewConfiguration {
|
|
206
|
+
ShoppingModule.hydrateProductViewConfig(productInfoViewConfiguration, productInfoViewConfigurator)
|
|
207
|
+
}
|
|
210
208
|
|
|
211
209
|
#if DEBUG
|
|
212
210
|
let formatter = DateFormatter()
|
|
@@ -290,21 +288,32 @@ extension ShoppingModule {
|
|
|
290
288
|
_ config: ProductInfoViewConfiguration,
|
|
291
289
|
_ productInfoViewConfigurator: ProductInfoViewConfigurable
|
|
292
290
|
) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
291
|
+
var productDetailsConfiguration = productInfoViewConfigurator.productDetailsConfiguration
|
|
292
|
+
|
|
293
|
+
if let addToCartButtonConfiguration = config.addToCartButton {
|
|
294
|
+
if let backgroundColor = addToCartButtonConfiguration.backgroundColor,
|
|
296
295
|
backgroundColor.count > 0 {
|
|
297
|
-
|
|
296
|
+
productDetailsConfiguration.addToCartButton.backgroundColor = backgroundColor.uicolor()
|
|
298
297
|
}
|
|
299
|
-
|
|
298
|
+
|
|
299
|
+
if let textColor = addToCartButtonConfiguration.textColor,
|
|
300
300
|
textColor.count > 0 {
|
|
301
|
-
|
|
301
|
+
productDetailsConfiguration.addToCartButton.textColor = textColor.uicolor()
|
|
302
302
|
}
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
|
|
304
|
+
if let fontSize = addToCartButtonConfiguration.fontSize {
|
|
305
|
+
let iOSFontInfo = addToCartButtonConfiguration.iOSFontInfo ?? FontInfo()
|
|
306
|
+
productDetailsConfiguration.addToCartButton.font = iOSFontInfo.getFont(fontSize)
|
|
305
307
|
}
|
|
306
|
-
productInfoViewConfigurator.productDetailsConfiguration = config
|
|
307
308
|
}
|
|
309
|
+
|
|
310
|
+
if let linkButtonConfiguration = config.linkButton {
|
|
311
|
+
if let isHidden = linkButtonConfiguration.isHidden {
|
|
312
|
+
productDetailsConfiguration.linkButtonConfiguration.isHidden = isHidden
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
productInfoViewConfigurator.productDetailsConfiguration = productDetailsConfiguration
|
|
308
317
|
}
|
|
309
318
|
|
|
310
319
|
}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
8
10
|
var _FWEventName = require("./models/FWEventName");
|
|
9
11
|
|
|
10
12
|
var _FWNavigatorModule = _interopRequireWildcard(require("./modules/FWNavigatorModule"));
|
|
@@ -41,6 +43,8 @@ class FWNavigator {
|
|
|
41
43
|
* Please set your app component name through FireworkSDK.getInstance().appComponentName before calling this method
|
|
42
44
|
* @param {FWNativeContainerProps} props We will pass the props to your app component.
|
|
43
45
|
* @returns {Promise<boolean>} The result of pushing RN page from native page.
|
|
46
|
+
*
|
|
47
|
+
* @deprecated The property will be deprecated since RN SDK V2.
|
|
44
48
|
*/
|
|
45
49
|
|
|
46
50
|
|
|
@@ -60,13 +64,40 @@ class FWNavigator {
|
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
62
66
|
* Indicate if we can pop top-most native container.
|
|
63
|
-
* @returns {Promise<boolean>} If the result is true,
|
|
67
|
+
* @returns {Promise<boolean>} If the result is true,
|
|
68
|
+
* we could call popNativeContainer to pop top-most native container.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated The property will be deprecated since RN SDK V2.
|
|
64
71
|
*/
|
|
65
72
|
|
|
66
73
|
|
|
67
74
|
canPopNativeContainer() {
|
|
68
75
|
return _FWNavigatorModule.default.canPopNativeContainer();
|
|
69
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Change current fullscreen player to floating player.
|
|
79
|
+
* @returns {Promise<boolean>} If the result is true, it means that the fullscreen
|
|
80
|
+
* player is changed to floating player. Only supported on iOS.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
async startFloatingPlayer() {
|
|
85
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
86
|
+
return _FWNavigatorModule.default.startFloatingPlayer();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Stop current floating player. Only supported on iOS.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
async stopFloatingPlayer() {
|
|
97
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
98
|
+
await _FWNavigatorModule.default.stopFloatingPlayer();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
70
101
|
|
|
71
102
|
}
|
|
72
103
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FWNavigator.
|
|
1
|
+
{"version":3,"sources":["FWNavigator.ts"],"names":["FWNavigator","getInstance","_instance","constructor","FWLoggerUtil","log","FWNavigatorModuleEventEmitter","addListener","FWEventName","LogMessage","pushNativeContainer","props","FWNavigatorModule","popNativeContainer","canPopNativeContainer","startFloatingPlayer","Platform","OS","stopFloatingPlayer"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAGA;;;;;;;;;;AAMA;AACA;AACA;AACA,MAAMA,WAAN,CAAkB;AAGS,SAAXC,WAAW,GAAgB;AACvC,QAAI,CAACD,WAAW,CAACE,SAAjB,EAA4B;AAC1BF,MAAAA,WAAW,CAACE,SAAZ,GAAwB,IAAIF,WAAJ,EAAxB;AACD;;AACD,WAAOA,WAAW,CAACE,SAAnB;AACD;;AAEOC,EAAAA,WAAW,GAAG;AACpBC,0BAAaC,GAAb,CAAiB,yBAAjB;;AACAC,qDAA8BC,WAA9B,CAA0CC,yBAAYC,UAAtD,EAAkE,MAAM,CAAE,CAA1E;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;;AACSC,EAAAA,mBAAmB,CAACC,KAAD,EAAkD;AAC1EP,0BAAaC,GAAb,CAAkB,8BAAlB;;AAEA,WAAOO,2BAAkBF,mBAAlB,CAAsCC,KAAtC,CAAP;AACD;AAED;AACF;AACA;AACA;;;AACSE,EAAAA,kBAAkB,GAAqB;AAC5C,WAAOD,2BAAkBC,kBAAlB,EAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACSC,EAAAA,qBAAqB,GAAqB;AAC/C,WAAOF,2BAAkBE,qBAAlB,EAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACkC,QAAnBC,mBAAmB,GAAqB;AACnD,QAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,aAAOL,2BAAkBG,mBAAlB,EAAP;AACD;;AAED,WAAO,IAAP;AACD;AAED;AACF;AACA;;;AACiC,QAAlBG,kBAAkB,GAAkB;AAC/C,QAAIF,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,YAAML,2BAAkBM,kBAAlB,EAAN;AACD;AACF;;AApEe;;gBAAZlB,W;;eAuESA,W","sourcesContent":["import { Platform } from 'react-native';\nimport { FWEventName } from './models/FWEventName';\nimport FWNavigatorModule, {\n FWNavigatorModuleEventEmitter,\n} from './modules/FWNavigatorModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\ntype FWNativeContainerProps = {\n [key: string]: any;\n};\n\n/**\n * You can use this class for pushing RN page from the native page.\n */\nclass FWNavigator {\n private static _instance?: FWNavigator;\n\n public static getInstance(): FWNavigator {\n if (!FWNavigator._instance) {\n FWNavigator._instance = new FWNavigator();\n }\n return FWNavigator._instance!;\n }\n\n private constructor() {\n FWLoggerUtil.log('FWNavigator constructor');\n FWNavigatorModuleEventEmitter.addListener(FWEventName.LogMessage, () => {});\n }\n\n /**\n * Push a new native container. We will render your app component in new native container.\n * Please set your app component name through FireworkSDK.getInstance().appComponentName before calling this method\n * @param {FWNativeContainerProps} props We will pass the props to your app component.\n * @returns {Promise<boolean>} The result of pushing RN page from native page.\n *\n * @deprecated The property will be deprecated since RN SDK V2.\n */\n public pushNativeContainer(props: FWNativeContainerProps): Promise<boolean> {\n FWLoggerUtil.log(`Enter pushNewNativeContainer`);\n\n return FWNavigatorModule.pushNativeContainer(props);\n }\n\n /**\n * Pop top-most native container.\n * @returns {Promise<boolean>} The result of poping top-most native container.\n */\n public popNativeContainer(): Promise<boolean> {\n return FWNavigatorModule.popNativeContainer();\n }\n\n /**\n * Indicate if we can pop top-most native container.\n * @returns {Promise<boolean>} If the result is true,\n * we could call popNativeContainer to pop top-most native container.\n *\n * @deprecated The property will be deprecated since RN SDK V2.\n */\n public canPopNativeContainer(): Promise<boolean> {\n return FWNavigatorModule.canPopNativeContainer();\n }\n\n /**\n * Change current fullscreen player to floating player.\n * @returns {Promise<boolean>} If the result is true, it means that the fullscreen\n * player is changed to floating player. Only supported on iOS.\n */\n public async startFloatingPlayer(): Promise<boolean> {\n if (Platform.OS === 'ios') {\n return FWNavigatorModule.startFloatingPlayer();\n }\n\n return true;\n }\n\n /**\n * Stop current floating player. Only supported on iOS.\n */\n public async stopFloatingPlayer(): Promise<void> {\n if (Platform.OS === 'ios') {\n await FWNavigatorModule.stopFloatingPlayer();\n }\n }\n}\n\nexport default FWNavigator;\n"]}
|
|
@@ -86,16 +86,17 @@ class FireworkSDK {
|
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* The share base URL of videos.
|
|
89
|
+
* The set accessor is async.
|
|
89
90
|
*/
|
|
90
91
|
get shareBaseURL() {
|
|
91
92
|
return this._shareBaseURL;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
set shareBaseURL(value) {
|
|
95
|
-
const valueHasChanged = this._shareBaseURL !== value;
|
|
96
|
-
this._shareBaseURL = value;
|
|
97
|
-
|
|
98
96
|
_FireworkSDKModule.default.setShareBaseURL(value !== null && value !== void 0 ? value : '').then(() => {
|
|
97
|
+
const valueHasChanged = this._shareBaseURL !== value;
|
|
98
|
+
this._shareBaseURL = value;
|
|
99
|
+
|
|
99
100
|
if (valueHasChanged) {
|
|
100
101
|
this.eventEmitter.emit(_FWEventName.FWEventName.ShareBaseURLUpdated);
|
|
101
102
|
}
|
|
@@ -104,18 +105,19 @@ class FireworkSDK {
|
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
107
|
* The configuration for ad badges.
|
|
108
|
+
* The set accessor is async.
|
|
107
109
|
*/
|
|
108
110
|
get adBadgeConfiguration() {
|
|
109
111
|
return this._adBadgeConfiguration;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
set adBadgeConfiguration(value) {
|
|
113
|
-
|
|
115
|
+
_FireworkSDKModule.default.setAdBadgeConfiguration(value !== null && value !== void 0 ? value : {}).then(() => {
|
|
116
|
+
var _this$_adBadgeConfigu, _this$_adBadgeConfigu2, _this$_adBadgeConfigu3;
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
const valueHasChanged = ((_this$_adBadgeConfigu = this._adBadgeConfiguration) === null || _this$_adBadgeConfigu === void 0 ? void 0 : _this$_adBadgeConfigu.badgeTextType) !== (value === null || value === void 0 ? void 0 : value.badgeTextType) || ((_this$_adBadgeConfigu2 = this._adBadgeConfiguration) === null || _this$_adBadgeConfigu2 === void 0 ? void 0 : _this$_adBadgeConfigu2.backgroundColor) !== (value === null || value === void 0 ? void 0 : value.backgroundColor) || ((_this$_adBadgeConfigu3 = this._adBadgeConfiguration) === null || _this$_adBadgeConfigu3 === void 0 ? void 0 : _this$_adBadgeConfigu3.textColor) !== (value === null || value === void 0 ? void 0 : value.textColor);
|
|
119
|
+
this._adBadgeConfiguration = value;
|
|
117
120
|
|
|
118
|
-
_FireworkSDKModule.default.setAdBadgeConfiguration(value !== null && value !== void 0 ? value : {}).then(() => {
|
|
119
121
|
if (valueHasChanged) {
|
|
120
122
|
this.eventEmitter.emit(_FWEventName.FWEventName.AdBadgeConfigurationUpdated);
|
|
121
123
|
}
|
|
@@ -287,11 +289,6 @@ class FireworkSDK {
|
|
|
287
289
|
async changeAppLanguage(language) {
|
|
288
290
|
if (_reactNative.Platform.OS === 'android') {
|
|
289
291
|
const result = await _FireworkSDKModule.default.changeAppLanguage(language);
|
|
290
|
-
|
|
291
|
-
if (result) {
|
|
292
|
-
await _FireworkSDKModule.default.restart();
|
|
293
|
-
}
|
|
294
|
-
|
|
295
292
|
return result;
|
|
296
293
|
}
|
|
297
294
|
|
|
@@ -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","valueHasChanged","setShareBaseURL","then","eventEmitter","emit","FWEventName","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","badgeTextType","backgroundColor","textColor","setAdBadgeConfiguration","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","debugLogsEnabled","enabled","FireworkSDKModuleEventEmitter","shopping","_shopping","liveStream","_liveStream","navigator","_navigator","getInstance","_instance","constructor","VideoShopping","LiveStream","FWNavigator","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","ShoppingModule","LiveStreamModule","openVideoPlayer","config","trackPurchase","parameters","Platform","OS","changeAppLanguage","language","result","restart"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AA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B,CAAkCX,GAAlC,EAAuCY,MAAvC,aAAuCA,MAAvC,cAAuCA,MAAvC,GAAiD,EAAjD;AACD;AAED;AACF;AACA;AACA;;;AACSC,EAAAA,aAAa,CAACC,UAAD,EAAsC;AACxD,QAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBnE,iCAAkBgE,aAAlB,CAAgCC,UAAhC;AACD;AACF;AAED;AACF;AACA;AACA;AACA;;;AACgC,QAAjBG,iBAAiB,CAACC,QAAD,EAAqC;AACjE,QAAIH,sBAASC,EAAT,KAAgB,SAApB,EAA+B;AAC7B,YAAMG,MAAM,GAAG,MAAMtE,2BAAkBoE,iBAAlB,CAAoCC,QAApC,CAArB;;AACA,UAAIC,MAAJ,EAAY;AACV,cAAMtE,2BAAkBuE,OAAlB,EAAN;AACD;;AACD,aAAOD,MAAP;AACD;;AAED,WAAO,KAAP;AACD;;AA5Oe;;gBAAZ5E,W;;eA+OSA,W","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport FWNavigator from './FWNavigator';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type TrackPurchaseParameters from './models/TrackPurchaseParameters';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport VideoShopping from './VideoShopping';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n const valueHasChanged = this._shareBaseURL !== value;\n this._shareBaseURL = value;\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n }\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n const valueHasChanged =\n this._adBadgeConfiguration?.badgeTextType !== value?.badgeTextType ||\n this._adBadgeConfiguration?.backgroundColor !== value?.backgroundColor ||\n this._adBadgeConfiguration?.textColor !== value?.textColor;\n this._adBadgeConfiguration = value;\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n }\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n /**\n * Defaults to false. You can enable debug logs by setting this property to true.\n */\n public get debugLogsEnabled(): boolean {\n return FWLoggerUtil.enabled;\n }\n public set debugLogsEnabled(value: boolean) {\n FWLoggerUtil.enabled = value;\n }\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return this._shopping;\n }\n private _shopping: VideoShopping = VideoShopping.getInstance();\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return this._liveStream;\n }\n private _liveStream: LiveStream = LiveStream.getInstance();\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return this._navigator;\n }\n private _navigator: FWNavigator = FWNavigator.getInstance();\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n FWLoggerUtil.log('FireworkSDK constructor');\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(\n `Receive VideoPlayback event eventName: ${event?.eventName}`\n );\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FWLoggerUtil.log('Call FireworkSDK init method');\n\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n\n /**\n * Records the user purchase. Only supported on iOS.\n * @param {TrackPurchaseParameters} parameters\n */\n public trackPurchase(parameters: TrackPurchaseParameters) {\n if (Platform.OS === 'ios') {\n FireworkSDKModule.trackPurchase(parameters);\n }\n }\n\n /**\n * Change App level language. Only supported on Android.\n * @param {string} language Such as en, ar and en-US\n * @returns\n */\n public async changeAppLanguage(language: string): Promise<boolean> {\n if (Platform.OS === 'android') {\n const result = await FireworkSDKModule.changeAppLanguage(language);\n if (result) {\n await FireworkSDKModule.restart();\n }\n return result;\n }\n\n return false;\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","valueHasChanged","eventEmitter","emit","FWEventName","ShareBaseURLUpdated","adBadgeConfiguration","_adBadgeConfiguration","setAdBadgeConfiguration","badgeTextType","backgroundColor","textColor","AdBadgeConfigurationUpdated","appComponentName","_appComponentName","setAppComponentName","debugLogsEnabled","enabled","FireworkSDKModuleEventEmitter","shopping","_shopping","liveStream","_liveStream","navigator","_navigator","getInstance","_instance","constructor","VideoShopping","LiveStream","FWNavigator","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","VideoPlayback","eventName","VideoFeedClick","info","id","onVideoFeedClick","init","userId","ShoppingModule","LiveStreamModule","openVideoPlayer","config","trackPurchase","parameters","Platform","OS","changeAppLanguage","language","result"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;AASA;;AAGA;;AACA;;AACA;;AACA;;;;;;;;;;AAOA;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,GAAu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KAAP;AACD;;AA5Oe;;gBAAZ5E,W;;eA+OSA,W","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport FWNavigator from './FWNavigator';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomCTAClickEvent,\n SDKInitEvent,\n VideoFeedClickEvent,\n VideoPlaybackEvent,\n} from './models/FWEvents';\nimport type TrackPurchaseParameters from './models/TrackPurchaseParameters';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport FireworkSDKModule, {\n FireworkSDKModuleEventEmitter,\n} from './modules/FireworkSDKModule';\nimport LiveStreamModule from './modules/LiveStreamModule';\nimport ShoppingModule from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport VideoShopping from './VideoShopping';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => void;\nexport type CustomCTAClickCallback = (event: CustomCTAClickEvent) => void;\nexport type VideoPlaybackCallback = (event: VideoPlaybackEvent) => void;\nexport type VideoFeedClickCallback = (event: VideoFeedClickEvent) => void;\n\n/**\n * Entry class of Firework SDK, which supports the sdk initialization and global configuration.\n */\nclass FireworkSDK {\n private static _instance?: FireworkSDK;\n\n /**\n * The callback of SDK initialization.\n */\n public onSDKInit?: SDKInitCallback;\n\n /**\n * the callback of clicking Video Feed.\n */\n public onVideoFeedClick?: VideoFeedClickCallback;\n\n /**\n * The callback of clicking custom CTA.\n */\n public get onCustomCTAClick(): CustomCTAClickCallback | undefined {\n return this._onCustomCTAClick;\n }\n public set onCustomCTAClick(value: CustomCTAClickCallback | undefined) {\n FWLoggerUtil.log(`Set onCustomCTAClick callback ${!!value}`);\n this._onCustomCTAClick = value;\n FireworkSDKModule.setCustomCTAClickEnabled(value ? true : false);\n }\n private _onCustomCTAClick: CustomCTAClickCallback | undefined;\n\n /**\n * The custom CTA link content page route name.\n */\n public get customCTALinkContentPageRouteName(): string | undefined {\n return this._customCTALinkContentPageRouteName;\n }\n public set customCTALinkContentPageRouteName(value: string | undefined) {\n this._customCTALinkContentPageRouteName = value;\n FireworkSDKModule.setCustomCTALinkContentPageRouteName(value ?? '');\n }\n private _customCTALinkContentPageRouteName: string | undefined;\n\n /**\n * The callback of video playback.\n */\n public get onVideoPlayback(): VideoPlaybackCallback | undefined {\n return this._onVideoPlayback;\n }\n public set onVideoPlayback(value: VideoPlaybackCallback | undefined) {\n this._onVideoPlayback = value;\n FireworkSDKModule.setVideoPlaybackEventEnabled(value ? true : false);\n }\n private _onVideoPlayback?: VideoPlaybackCallback | undefined;\n\n /**\n * The share base URL of videos.\n * The set accessor is async.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n FireworkSDKModule.setShareBaseURL(value ?? '').then(() => {\n const valueHasChanged = this._shareBaseURL !== value;\n this._shareBaseURL = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n }\n });\n }\n private _shareBaseURL: string | undefined;\n\n /**\n * The configuration for ad badges.\n * The set accessor is async.\n */\n public get adBadgeConfiguration(): AdBadgeConfiguration | undefined {\n return this._adBadgeConfiguration;\n }\n public set adBadgeConfiguration(value: AdBadgeConfiguration | undefined) {\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {}).then(() => {\n const valueHasChanged =\n this._adBadgeConfiguration?.badgeTextType !== value?.badgeTextType ||\n this._adBadgeConfiguration?.backgroundColor !==\n value?.backgroundColor ||\n this._adBadgeConfiguration?.textColor !== value?.textColor;\n this._adBadgeConfiguration = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n }\n });\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n /**\n * The app component name.\n */\n public get appComponentName(): string | undefined {\n return this._appComponentName;\n }\n public set appComponentName(value: string | undefined) {\n this._appComponentName = value;\n FireworkSDKModule.setAppComponentName(value ?? '');\n }\n private _appComponentName: string | undefined;\n\n /**\n * Defaults to false. You can enable debug logs by setting this property to true.\n */\n public get debugLogsEnabled(): boolean {\n return FWLoggerUtil.enabled;\n }\n public set debugLogsEnabled(value: boolean) {\n FWLoggerUtil.enabled = value;\n }\n\n private get eventEmitter(): NativeEventEmitter {\n return FireworkSDKModuleEventEmitter;\n }\n\n /**\n * Get VideoShopping object.\n */\n public get shopping(): VideoShopping {\n return this._shopping;\n }\n private _shopping: VideoShopping = VideoShopping.getInstance();\n\n /**\n * Get LiveStream object.\n */\n public get liveStream(): LiveStream {\n return this._liveStream;\n }\n private _liveStream: LiveStream = LiveStream.getInstance();\n\n /**\n * Get FWNavigator object.\n */\n public get navigator(): FWNavigator {\n return this._navigator;\n }\n private _navigator: FWNavigator = FWNavigator.getInstance();\n\n /**\n * Get global single instance of FireworkSDK class.\n * @returns FireworkSDK\n */\n public static getInstance() {\n if (!FireworkSDK._instance) {\n FireworkSDK._instance = new FireworkSDK();\n }\n\n return FireworkSDK._instance!;\n }\n\n private constructor() {\n FWLoggerUtil.log('FireworkSDK constructor');\n this.eventEmitter.addListener(FWEventName.SDKInit, (event) => {\n FWLoggerUtil.log(`Receive SDKInit event ${event?.error}`);\n\n if (this.onSDKInit) {\n this.onSDKInit(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, (event) => {\n FWLoggerUtil.logNativeMessage(event.message);\n });\n\n this.eventEmitter.addListener(FWEventName.CustomCTAClick, (event) => {\n FWLoggerUtil.log(`Receive CustomCTAClick url: ${event?.url}`);\n\n if (this.onCustomCTAClick) {\n this.onCustomCTAClick(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoPlayback, (event) => {\n FWLoggerUtil.log(\n `Receive VideoPlayback event eventName: ${event?.eventName}`\n );\n\n if (this.onVideoPlayback) {\n this.onVideoPlayback(event ?? {});\n }\n });\n\n this.eventEmitter.addListener(FWEventName.VideoFeedClick, (event) => {\n FWLoggerUtil.log(`Receive VideoFeedClick event id: ${event?.info.id}`);\n\n if (this.onVideoFeedClick) {\n this.onVideoFeedClick(event ?? {});\n }\n });\n }\n\n /**\n * Initializes Firework SDK.\n * @param {string?} userId An id to uniquely identify device or user.\n */\n public init(userId?: string) {\n FWLoggerUtil.log('Call FireworkSDK init method');\n\n FireworkSDKModule.init(userId);\n ShoppingModule.init();\n LiveStreamModule.init();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public openVideoPlayer(url: string, config?: VideoPlayerConfiguration) {\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n\n /**\n * Records the user purchase. Only supported on iOS.\n * @param {TrackPurchaseParameters} parameters\n */\n public trackPurchase(parameters: TrackPurchaseParameters) {\n if (Platform.OS === 'ios') {\n FireworkSDKModule.trackPurchase(parameters);\n }\n }\n\n /**\n * Change App level language. Only supported on Android.\n * @param {string} language Such as en, ar and en-US\n * @returns\n */\n public async changeAppLanguage(language: string): Promise<boolean> {\n if (Platform.OS === 'android') {\n const result = await FireworkSDKModule.changeAppLanguage(language);\n return result;\n }\n\n return false;\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
@@ -35,13 +35,15 @@ class VideoShopping {
|
|
|
35
35
|
/**
|
|
36
36
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
37
37
|
*
|
|
38
|
-
* The host app can return NewNativeContainerProps object
|
|
38
|
+
* The host app can return NewNativeContainerProps object
|
|
39
|
+
* and we will push a new native container with the props.
|
|
39
40
|
*/
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* This callback is triggered when the user clicks the shopping cart icon.
|
|
43
44
|
*
|
|
44
|
-
* The host app can customize the processing logic of
|
|
45
|
+
* The host app can customize the click event processing logic of
|
|
46
|
+
* the shopping cart icon by setting the callback.
|
|
45
47
|
*/
|
|
46
48
|
get onCustomClickCartIcon() {
|
|
47
49
|
return this._onCustomClickCartIcon;
|
|
@@ -56,7 +58,8 @@ class VideoShopping {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
/**
|
|
59
|
-
* Defaults to true.
|
|
61
|
+
* Defaults to true.
|
|
62
|
+
* You can hide the cart icon by setting this property to false.
|
|
60
63
|
*/
|
|
61
64
|
get cartIconVisible() {
|
|
62
65
|
return this._cartIconVisible;
|
|
@@ -68,6 +71,41 @@ class VideoShopping {
|
|
|
68
71
|
_ShoppingModule.default.setCartIconVisible(value);
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
/**
|
|
75
|
+
* The host app can use this property to configure "Add to cart" button style
|
|
76
|
+
* and hide the link button next to "Add to cart" button. Only supported on iOS.
|
|
77
|
+
*/
|
|
78
|
+
get productInfoViewConfiguration() {
|
|
79
|
+
return this._productInfoViewConfiguration;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
set productInfoViewConfiguration(value) {
|
|
83
|
+
this._productInfoViewConfiguration = value;
|
|
84
|
+
|
|
85
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
86
|
+
_ShoppingModule.default.setProductInfoViewConfiguration(value !== null && value !== void 0 ? value : {});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* This callback is triggered when the user clicks
|
|
92
|
+
* the link button next to Add to cart button. Only supported on Android.
|
|
93
|
+
*
|
|
94
|
+
* The host app can customize the click event processing logic of
|
|
95
|
+
* the link button by setting the callback.
|
|
96
|
+
*/
|
|
97
|
+
get onCustomClickLinkButton() {
|
|
98
|
+
return this._onCustomClickLinkButton;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
set onCustomClickLinkButton(value) {
|
|
102
|
+
this._onCustomClickLinkButton = value;
|
|
103
|
+
|
|
104
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
105
|
+
_ShoppingModule.default.setCustomClickLinkButtonEnabled(!!value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
71
109
|
get eventEmitter() {
|
|
72
110
|
return _ShoppingModule.ShoppingModuleEventEmitter;
|
|
73
111
|
}
|
|
@@ -95,8 +133,12 @@ class VideoShopping {
|
|
|
95
133
|
|
|
96
134
|
_defineProperty(this, "_cartIconVisible", true);
|
|
97
135
|
|
|
136
|
+
_defineProperty(this, "_productInfoViewConfiguration", void 0);
|
|
137
|
+
|
|
138
|
+
_defineProperty(this, "_onCustomClickLinkButton", void 0);
|
|
139
|
+
|
|
98
140
|
this.eventEmitter.addListener(_FWEventName.FWEventName.AddToCart, event => {
|
|
99
|
-
_FWLoggerUtil.default.log(`Receive AddToCart event productId: ${event.productId} unitId: ${event.unitId}`);
|
|
141
|
+
_FWLoggerUtil.default.log(`Receive AddToCart event productId: ${event === null || event === void 0 ? void 0 : event.productId} unitId: ${event === null || event === void 0 ? void 0 : event.unitId}`);
|
|
100
142
|
|
|
101
143
|
this.handleAddToCartEvent(event);
|
|
102
144
|
});
|
|
@@ -106,16 +148,24 @@ class VideoShopping {
|
|
|
106
148
|
this.handleClickCartIconEvent(event);
|
|
107
149
|
});
|
|
108
150
|
this.eventEmitter.addListener(_FWEventName.FWEventName.UpdateProductDetails, event => {
|
|
109
|
-
_FWLoggerUtil.default.log(`Receive UpdateProductDetails event productIds: ${event.productIds}`);
|
|
151
|
+
_FWLoggerUtil.default.log(`Receive UpdateProductDetails event productIds: ${event === null || event === void 0 ? void 0 : event.productIds}`);
|
|
110
152
|
|
|
111
153
|
this.handleUpdateProductDetailsEvent(event);
|
|
112
154
|
});
|
|
113
155
|
this.eventEmitter.addListener(_FWEventName.FWEventName.WillDisplayProduct, event => {
|
|
114
|
-
_FWLoggerUtil.default.log(`Receive WillDisplayProduct event videoId: ${event.videoId}`);
|
|
156
|
+
_FWLoggerUtil.default.log(`Receive WillDisplayProduct event videoId: ${event === null || event === void 0 ? void 0 : event.videoId}`);
|
|
115
157
|
|
|
116
158
|
this.handleWillDisplayProductEvent(event);
|
|
117
159
|
});
|
|
118
160
|
this.eventEmitter.addListener(_FWEventName.FWEventName.LogMessage, () => {});
|
|
161
|
+
|
|
162
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
163
|
+
this.eventEmitter.addListener(_FWEventName.FWEventName.CustomLinkButtonClick, event => {
|
|
164
|
+
_FWLoggerUtil.default.log(`Receive CustomLinkButtonClick event url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
165
|
+
|
|
166
|
+
this.handleCustomLinkButtonClickEvent(event);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
119
169
|
}
|
|
120
170
|
/**
|
|
121
171
|
*
|
|
@@ -212,16 +262,21 @@ class VideoShopping {
|
|
|
212
262
|
|
|
213
263
|
async handleWillDisplayProductEvent(event) {
|
|
214
264
|
if (this.onWillDisplayProduct) {
|
|
215
|
-
const callbackId = event.callbackId;
|
|
216
265
|
delete event.callbackId;
|
|
217
266
|
const config = await this.onWillDisplayProduct(event);
|
|
218
267
|
|
|
219
|
-
if (config
|
|
220
|
-
_ShoppingModule.default.
|
|
268
|
+
if (config) {
|
|
269
|
+
_ShoppingModule.default.setProductInfoViewConfiguration(config);
|
|
221
270
|
}
|
|
222
271
|
}
|
|
223
272
|
}
|
|
224
273
|
|
|
274
|
+
async handleCustomLinkButtonClickEvent(event) {
|
|
275
|
+
if (this.onCustomClickLinkButton) {
|
|
276
|
+
this.onCustomClickLinkButton(event);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
225
280
|
}
|
|
226
281
|
|
|
227
282
|
_defineProperty(VideoShopping, "_instance", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","Platform","OS","ShoppingModule","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","eventEmitter","ShoppingModuleEventEmitter","getInstance","FWLoggerUtil","log","_instance","constructor","addListener","FWEventName","AddToCart","event","productId","unitId","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","WillDisplayProduct","videoId","handleWillDisplayProductEvent","LogMessage","setCartItemCount","count","callbackId","onAddToCart","result","updateAddToCartStatus","res","tips","clearCallbackId","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","map","product","length","updateVideoProducts","onWillDisplayProduct","config","updateProductViewConfig"],"mappings":";;;;;;;AAAA;;AAQA;;AAGA;;AAIA;;;;;;;;;;AAsBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;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;AAC1BC,0BAAaC,GAAb,CAAiB,2BAAjB;;AACA,QAAI,CAACf,aAAa,CAACgB,SAAnB,EAA8B;AAC5BhB,MAAAA,aAAa,CAACgB,SAAd,GAA0B,IAAIhB,aAAJ,EAA1B;AACD;;AAED,WAAOA,aAAa,CAACgB,SAArB;AACD;;AAEOC,EAAAA,WAAW,GAAG;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,8CAfc,IAed;;AACpB,SAAKN,YAAL,CAAkBO,WAAlB,CAA8B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AAO,CAAC3B,SAArB,mEAAkC,EAAlC;AAAA,OADiB,CAAnB;;AAIAR,4BAAaC,GAAb,CACG,+DAA8Da,UAAW,uBACxE,CAACmB,WAAW,IAAI,EAAhB,EAAoBG,MACrB,EAHH;;AAMA,UAAIH,WAAJ,EAAiB;AACf,YAAIX,UAAJ,EAAgB;AACd9B,kCAAe6C,mBAAf,CAAmCJ,WAAnC,EAAgDX,UAAhD;AACD;AACF,OAJD,MAIO;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAIhC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,oCAAeoC,eAAf,CACEN,UADF,EAEEjB,yBAAYQ,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACLb,4BAAaC,GAAb,CAAiB,6CAAjB;;AACA,UAAIqB,UAAJ,EAAgB;AACd,YAAIhC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,kCAAeoC,eAAf,CACEN,UADF,EAEEjB,yBAAYQ,oBAFd;AAID;AACF;AACF;AACF;;AAE0C,QAA7BK,6BAA6B,CACzCX,KADyC,EAEzC;AACA,QAAI,KAAK+B,oBAAT,EAA+B;AAC7B,YAAMhB,UAAU,GAAGf,KAAK,CAACe,UAAzB;AACA,aAAOf,KAAK,CAACe,UAAb;AACA,YAAMiB,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnB/B,KADmB,CAArB;;AAGA,UAAIgC,MAAM,IAAIjB,UAAd,EAA0B;AACxB9B,gCAAegD,uBAAf,CAAuCD,MAAvC,EAA+CjB,UAA/C;AACD;AACF;AACF;;AA7NiB;;gBAAdpC,a;;eAgOSA,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 apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\n * If the host apps want to customize the processing logic of clicking \"Add to cart\" button, they could return null or undefined in the callback.\n */\n public onAddToCart?: AddToCartCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can return NewNativeContainerProps object 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 */\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. Only supported on iOS.\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 FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n FWLoggerUtil.log(\n `Receive AddToCart event productId: ${event.productId} unitId: ${event.unitId}`\n );\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n FWLoggerUtil.log(\n `Receive WillDisplayProduct event videoId: ${event.videoId}`\n );\n this.handleWillDisplayProductEvent(event);\n });\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart.\n * The count should be greater than or equal to 0.\n * We just use count to show or hide red indicator on the cart icon.\n * If cound > 0, we will show the red indicator on the cart icon.\n * Otherwise, we will hide the red indicator on the cart icon.\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onAddToCart) {\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n if (callbackId) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId\n );\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n 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
|
+
{"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","Platform","OS","ShoppingModule","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","productInfoViewConfiguration","_productInfoViewConfiguration","setProductInfoViewConfiguration","onCustomClickLinkButton","_onCustomClickLinkButton","setCustomClickLinkButtonEnabled","eventEmitter","ShoppingModuleEventEmitter","getInstance","FWLoggerUtil","log","_instance","constructor","addListener","FWEventName","AddToCart","event","productId","unitId","handleAddToCartEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","WillDisplayProduct","videoId","handleWillDisplayProductEvent","LogMessage","CustomLinkButtonClick","url","handleCustomLinkButtonClickEvent","setCartItemCount","count","callbackId","onAddToCart","result","updateAddToCartStatus","res","tips","clearCallbackId","onClickCartIcon","props","jumpToCartPage","onUpdateProductDetails","productList","map","product","length","updateVideoProducts","onWillDisplayProduct","config"],"mappings":";;;;;;;AAAA;;AASA;;AAGA;;AAIA;;;;;;;;;;AA0BA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;;AAGE;AACF;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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B,MAAM,GAAG,MAAM,KAAKD,oBAAL,CACnBlC,KADmB,CAArB;;AAGA,UAAImC,MAAJ,EAAY;AACVxD,gCAAeO,+BAAf,CAA+CiD,MAA/C;AACD;AACF;AACF;;AAE6C,QAAhCpB,gCAAgC,CAC5Cf,KAD4C,EAE5C;AACA,QAAI,KAAKb,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6Ba,KAA7B;AACD;AACF;;AAhSiB;;gBAAd3B,a;;eAmSSA,a","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport type {\n AddToCartEvent,\n CustomClickLinkButtonEvent,\n UpdateProductDetailsEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport { FWEventName } from './models/FWEventName';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type ClickCartIconCallback = () => Promise<\n NewNativeContainerProps | undefined | null\n>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type WillDisplayProductCallback = (\n event: WillDisplayProductEvent\n) => Promise<ProductInfoViewConfiguration | undefined | null>;\n\nexport type CustomClickLinkButtonCallback = (\n event: CustomClickLinkButtonEvent\n) => Promise<void>;\n\ntype CallbackInfo = { callbackId?: number | string };\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\n * If the host apps want to customize the processing logic of clicking \"Add to cart\" button, they could return null or undefined in the callback.\n */\n public onAddToCart?: AddToCartCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can return NewNativeContainerProps object\n * and we will push a new native container with the props.\n */\n public onClickCartIcon?: ClickCartIconCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the click event processing logic of\n * the shopping cart icon by setting the callback.\n */\n public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {\n return this._onCustomClickCartIcon;\n }\n public set onCustomClickCartIcon(\n value: CustomClickCartIconCallback | undefined\n ) {\n this._onCustomClickCartIcon = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomClickCartIconEnabled(!!value);\n }\n }\n private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product list to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * Please use productInfoViewConfiguration property. Only supported on iOS.\n *\n * @deprecated The property will be deprecated since RN SDK V2.\n */\n public onWillDisplayProduct?: WillDisplayProductCallback;\n\n /**\n * Defaults to true.\n * You can hide the cart icon by setting this property to false.\n */\n public get cartIconVisible(): boolean {\n return this._cartIconVisible;\n }\n public set cartIconVisible(value: boolean) {\n this._cartIconVisible = value;\n ShoppingModule.setCartIconVisible(value);\n }\n private _cartIconVisible: boolean = true;\n\n /**\n * The host app can use this property to configure \"Add to cart\" button style\n * and hide the link button next to \"Add to cart\" button. Only supported on iOS.\n */\n public get productInfoViewConfiguration():\n | ProductInfoViewConfiguration\n | undefined {\n return this._productInfoViewConfiguration;\n }\n\n public set productInfoViewConfiguration(\n value: ProductInfoViewConfiguration | undefined\n ) {\n this._productInfoViewConfiguration = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n }\n }\n\n private _productInfoViewConfiguration?:\n | ProductInfoViewConfiguration\n | undefined;\n\n /**\n * This callback is triggered when the user clicks\n * the link button next to Add to cart button. Only supported on Android.\n *\n * The host app can customize the click event processing logic of\n * the link button by setting the callback.\n */\n public get onCustomClickLinkButton():\n | CustomClickLinkButtonCallback\n | undefined {\n return this._onCustomClickLinkButton;\n }\n public set onCustomClickLinkButton(\n value: CustomClickLinkButtonCallback | undefined\n ) {\n this._onCustomClickLinkButton = value;\n if (Platform.OS === 'android') {\n ShoppingModule.setCustomClickLinkButtonEnabled(!!value);\n }\n }\n private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n FWLoggerUtil.log(\n `Receive AddToCart event productId: ${event?.productId} unitId: ${event?.unitId}`\n );\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, (event) => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event?.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.WillDisplayProduct, (event) => {\n FWLoggerUtil.log(\n `Receive WillDisplayProduct event videoId: ${event?.videoId}`\n );\n this.handleWillDisplayProductEvent(event);\n });\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n\n if (Platform.OS === 'android') {\n this.eventEmitter.addListener(\n FWEventName.CustomLinkButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive CustomLinkButtonClick event url: ${event?.url}`\n );\n this.handleCustomLinkButtonClickEvent(event);\n }\n );\n }\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart.\n * The count should be greater than or equal to 0.\n * We just use count to show or hide red indicator on the cart icon.\n * If cound > 0, we will show the red indicator on the cart icon.\n * Otherwise, we will hide the red indicator on the cart icon.\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: AddToCartEvent & CallbackInfo) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onAddToCart) {\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n if (callbackId) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId\n );\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n }\n\n private async handleClickCartIconEvent(event: CallbackInfo) {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n } else if (this.onClickCartIcon) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n const props = await this.onClickCartIcon();\n if (callbackId) {\n ShoppingModule.jumpToCartPage(callbackId, props ?? {});\n }\n }\n }\n\n private async handleUpdateProductDetailsEvent(\n event: UpdateProductDetailsEvent & CallbackInfo\n ) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleWillDisplayProductEvent(\n event: WillDisplayProductEvent & CallbackInfo\n ) {\n if (this.onWillDisplayProduct) {\n delete event.callbackId;\n const config = await this.onWillDisplayProduct(\n event as WillDisplayProductEvent\n );\n if (config) {\n ShoppingModule.setProductInfoViewConfiguration(config);\n }\n }\n }\n\n private async handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|