react-native-firework-sdk 2.7.1 → 2.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/FireworkVideoUI.xcframework/Info.plist +5 -5
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Info.plist +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Info.plist +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/_CodeSignature/CodeResources +1 -1
- package/ios/Components/StoryBlock.swift +86 -6
- package/ios/Components/StoryBlockConfiguration.swift +1 -0
- package/ios/Components/StoryBlockManager.m +4 -0
- package/ios/Components/VideoFeed.swift +90 -13
- package/ios/Components/VideoFeedManager.m +4 -0
- package/ios/Components/VideoPlayerConfiguration.swift +1 -0
- package/ios/Components/VideoPlayerLogoConfiguration.swift +18 -0
- package/ios/FireworkVideoUI/Podfile +1 -1
- package/ios/FireworkVideoUI/Podfile.lock +4 -4
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +71 -8
- package/ios/Modules/FWNavigatorModule/FWRNPresentContainerViewController.swift +30 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +23 -2
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +2 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +3 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +41 -8
- package/ios/Modules/Shopping/ShoppingModule.m +2 -0
- package/ios/Modules/Shopping/ShoppingModule.swift +163 -2
- package/lib/commonjs/FireworkSDK.js +16 -0
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +21 -1
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +71 -0
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +76 -1
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/VideoPlayerLogoConfiguration.js +2 -0
- package/lib/commonjs/models/VideoPlayerLogoConfiguration.js.map +1 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +15 -0
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +22 -1
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +69 -0
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +74 -1
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/VideoPlayerLogoConfiguration.js +2 -0
- package/lib/module/models/VideoPlayerLogoConfiguration.js.map +1 -0
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/components/StoryBlock.d.ts +12 -1
- package/lib/typescript/components/VideoFeed.d.ts +12 -1
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/models/FWEvents.d.ts +21 -0
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +110 -5
- package/lib/typescript/models/StoryBlockConfiguration.d.ts +7 -0
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +7 -0
- package/lib/typescript/models/VideoPlayerLogoConfiguration.d.ts +15 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +2 -0
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -0
- package/package.json +1 -1
- package/react-native-firework-sdk.podspec +1 -1
- package/src/FireworkSDK.ts +16 -0
- package/src/VideoShopping.ts +18 -1
- package/src/components/StoryBlock.tsx +92 -3
- package/src/components/VideoFeed.tsx +93 -2
- package/src/index.ts +14 -0
- package/src/models/FWEvents.ts +24 -0
- package/src/models/ProductInfoViewConfiguration.ts +114 -5
- package/src/models/StoryBlockConfiguration.ts +7 -0
- package/src/models/VideoPlayerConfiguration.ts +7 -0
- package/src/models/VideoPlayerLogoConfiguration.ts +23 -0
- package/src/modules/FireworkSDKModule.ts +2 -0
- package/src/modules/ShoppingModule.ts +2 -0
|
@@ -23,6 +23,9 @@ class FireworkSDKModule: RCTEventEmitter, FireworkVideoSDKDelegate {
|
|
|
23
23
|
/// Decide whether to send video playback event to RN.
|
|
24
24
|
var enableVideoPlayBackEvent: Bool = false
|
|
25
25
|
|
|
26
|
+
// player view controller
|
|
27
|
+
var playerMap: NSMapTable<NSString, UIViewController> = NSMapTable.strongToWeakObjects()
|
|
28
|
+
|
|
26
29
|
override init() {
|
|
27
30
|
super.init()
|
|
28
31
|
_ = AppLanguageManager.shared
|
|
@@ -28,14 +28,6 @@ struct ProductInfoViewConfiguration: Codable {
|
|
|
28
28
|
var isHidden: Bool?
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
struct ProductCardConfiguration: Codable {
|
|
32
|
-
var theme: ProductCardTheme?
|
|
33
|
-
var ctaButtonText: ProductCardCTAButtonText?
|
|
34
|
-
var cornerRadius: CGFloat?
|
|
35
|
-
var priceConfiguration: ProductCardPriceConfiguration?
|
|
36
|
-
var isCtaButtonHidden: Bool?
|
|
37
|
-
}
|
|
38
|
-
|
|
39
31
|
enum ProductCardTheme: String, Codable {
|
|
40
32
|
case light
|
|
41
33
|
case dark
|
|
@@ -46,7 +38,48 @@ struct ProductInfoViewConfiguration: Codable {
|
|
|
46
38
|
case buyNow
|
|
47
39
|
}
|
|
48
40
|
|
|
41
|
+
enum ProductCardPriceLabelAxis: String, Codable {
|
|
42
|
+
case horizontal
|
|
43
|
+
case vertical
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
struct ProductCardLabelConfiguration: Codable {
|
|
47
|
+
var textColor: String?
|
|
48
|
+
var fontSize: Double?
|
|
49
|
+
var numberOfLines: Int?
|
|
50
|
+
var iOSFontInfo: FontInfo?
|
|
51
|
+
}
|
|
52
|
+
|
|
49
53
|
struct ProductCardPriceConfiguration: Codable {
|
|
54
|
+
@available(*, deprecated, message: "This property has no effect.")
|
|
50
55
|
var isHidden: Bool?
|
|
56
|
+
var axis: ProductCardPriceLabelAxis?
|
|
57
|
+
var priceLabel: ProductCardLabelConfiguration?
|
|
58
|
+
var originalPriceLabel: ProductCardLabelConfiguration?
|
|
59
|
+
var isPriceFirst: Bool?
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
struct ProductCardIconConfiguration: Codable {
|
|
63
|
+
var cornerRadius: CGFloat?
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
struct ProductCardCTAButtonStyle: Codable {
|
|
67
|
+
var textColor: String?
|
|
68
|
+
var fontSize: Double?
|
|
69
|
+
var iOSFontInfo: FontInfo?
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
struct ProductCardConfiguration: Codable {
|
|
73
|
+
var theme: ProductCardTheme?
|
|
74
|
+
var cornerRadius: CGFloat?
|
|
75
|
+
var ctaButtonText: ProductCardCTAButtonText?
|
|
76
|
+
var isCtaButtonHidden: Bool?
|
|
77
|
+
var ctaButtonStyle: ProductCardCTAButtonStyle?
|
|
78
|
+
var priceConfiguration: ProductCardPriceConfiguration?
|
|
79
|
+
var width: CGFloat?
|
|
80
|
+
var height: CGFloat?
|
|
81
|
+
var backgroundColor: String?
|
|
82
|
+
var iconConfiguration: ProductCardIconConfiguration?
|
|
83
|
+
var nameLabel: ProductCardLabelConfiguration?
|
|
51
84
|
}
|
|
52
85
|
}
|
|
@@ -18,5 +18,7 @@ RCT_EXTERN_METHOD(clearCallbackId:(nonnull NSNumber *)cbId eventName:(nonnull NS
|
|
|
18
18
|
RCT_EXTERN_METHOD(setCustomClickLinkButtonEnabled:(BOOL)enabled resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
19
19
|
RCT_EXTERN_METHOD(updateShoppingCTAResult:(NSDictionary *)result cbId:(nonnull NSNumber *)cbId)
|
|
20
20
|
RCT_EXTERN_METHOD(setCustomTapProductCardEnabled:(BOOL)enabled resolver: (RCTPromiseResolveBlock)resolver rejecter:(RCTPromiseRejectBlock)rejecter)
|
|
21
|
+
RCT_EXTERN_METHOD(pausePlayer:(NSNumber *)callbackId)
|
|
22
|
+
RCT_EXTERN_METHOD(resumePlayer:(NSNumber *)callbackId)
|
|
21
23
|
|
|
22
24
|
@end
|
|
@@ -21,6 +21,7 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate {
|
|
|
21
21
|
private var productInfoViewConfiguration: ProductInfoViewConfiguration?
|
|
22
22
|
private var customClickLinkButtonEnabled = false
|
|
23
23
|
private var customTapProductCardEnabled = false
|
|
24
|
+
private var playerMap: NSMapTable<NSNumber, UIViewController> = NSMapTable.strongToWeakObjects()
|
|
24
25
|
|
|
25
26
|
override func supportedEvents() -> [String]! {
|
|
26
27
|
ShoppingEventName.allCases.map { $0.rawValue }
|
|
@@ -207,6 +208,22 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate {
|
|
|
207
208
|
shoppingCTAHandlerMap.removeValue(forKey: Int(truncating: cbId))
|
|
208
209
|
}
|
|
209
210
|
|
|
211
|
+
@objc(pausePlayer:)
|
|
212
|
+
func pausePlayer(_ callbackId: NSNumber) {
|
|
213
|
+
if let playerViewController = playerMap.object(forKey: callbackId),
|
|
214
|
+
let playerViewController = playerViewController as? PlayerViewController {
|
|
215
|
+
playerViewController.pause()
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
@objc(resumePlayer:)
|
|
220
|
+
func resumePlayer(_ callbackId: NSNumber) {
|
|
221
|
+
if let playerViewController = playerMap.object(forKey: callbackId),
|
|
222
|
+
let playerViewController = playerViewController as? PlayerViewController {
|
|
223
|
+
playerViewController.resume()
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
210
227
|
// MARK: - FireworkVideoShoppingDelegate
|
|
211
228
|
func fireworkShopping(
|
|
212
229
|
_ fireworkShopping: FireworkVideoShopping,
|
|
@@ -307,8 +324,14 @@ class ShoppingModule: RCTEventEmitter, FireworkVideoShoppingDelegate {
|
|
|
307
324
|
forVideo video: VideoDetails
|
|
308
325
|
) -> Bool {
|
|
309
326
|
if customTapProductCardEnabled {
|
|
327
|
+
let callbackId = ShoppingModule.generateCallbackId()
|
|
310
328
|
var body = item.jsObject
|
|
311
329
|
body["video"] = video.jsObject
|
|
330
|
+
body["callbackId"] = callbackId as NSNumber
|
|
331
|
+
if let presentedVC = RCTPresentedViewController(),
|
|
332
|
+
let playerViewController = ShoppingModule.getTopPlayerViewController(presentedVC) {
|
|
333
|
+
playerMap.setObject(playerViewController, forKey: callbackId as NSNumber)
|
|
334
|
+
}
|
|
312
335
|
sendEvent(
|
|
313
336
|
withName: ShoppingEventName.customProductCardTap.rawValue,
|
|
314
337
|
body: body)
|
|
@@ -384,14 +407,136 @@ extension ShoppingModule {
|
|
|
384
407
|
}
|
|
385
408
|
|
|
386
409
|
if let priceConfiguration = productCardConfiguration.priceConfiguration {
|
|
387
|
-
if let isPriceHidden = priceConfiguration.isHidden {
|
|
388
|
-
productInfoViewConfigurator.productCardConfiguration.priceConfiguration.isHidden = isPriceHidden
|
|
410
|
+
// if let isPriceHidden = priceConfiguration.isHidden {
|
|
411
|
+
// productInfoViewConfigurator.productCardConfiguration.priceConfiguration.isHidden = isPriceHidden
|
|
412
|
+
// }
|
|
413
|
+
if let axis = priceConfiguration.axis {
|
|
414
|
+
switch axis {
|
|
415
|
+
case .horizontal:
|
|
416
|
+
productInfoViewConfigurator.productCardConfiguration.priceConfiguration.axis = .horizontal
|
|
417
|
+
case .vertical:
|
|
418
|
+
productInfoViewConfigurator.productCardConfiguration.priceConfiguration.axis = .vertical
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if let priceLabel = priceConfiguration.priceLabel {
|
|
423
|
+
if let textColor = priceLabel.textColor,
|
|
424
|
+
textColor.count > 0,
|
|
425
|
+
let color = textColor.uicolor() {
|
|
426
|
+
productInfoViewConfigurator.productCardConfiguration.priceConfiguration.priceLabel.textColor = color
|
|
427
|
+
}
|
|
428
|
+
if let fontSize = priceLabel.fontSize {
|
|
429
|
+
let iOSFontInfo = priceLabel.iOSFontInfo ?? FontInfo()
|
|
430
|
+
productInfoViewConfigurator
|
|
431
|
+
.productCardConfiguration
|
|
432
|
+
.priceConfiguration
|
|
433
|
+
.priceLabel
|
|
434
|
+
.font = iOSFontInfo.getFont(fontSize)
|
|
435
|
+
}
|
|
436
|
+
if let numberOfLines = priceLabel.numberOfLines {
|
|
437
|
+
productInfoViewConfigurator
|
|
438
|
+
.productCardConfiguration
|
|
439
|
+
.priceConfiguration
|
|
440
|
+
.priceLabel
|
|
441
|
+
.numberOfLines = numberOfLines
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if let originalPriceLabel = priceConfiguration.originalPriceLabel {
|
|
446
|
+
if let textColor = originalPriceLabel.textColor,
|
|
447
|
+
textColor.count > 0,
|
|
448
|
+
let color = textColor.uicolor() {
|
|
449
|
+
productInfoViewConfigurator
|
|
450
|
+
.productCardConfiguration
|
|
451
|
+
.priceConfiguration
|
|
452
|
+
.originalPriceLabel
|
|
453
|
+
.textColor = color
|
|
454
|
+
}
|
|
455
|
+
if let fontSize = originalPriceLabel.fontSize {
|
|
456
|
+
let iOSFontInfo = originalPriceLabel.iOSFontInfo ?? FontInfo()
|
|
457
|
+
productInfoViewConfigurator
|
|
458
|
+
.productCardConfiguration
|
|
459
|
+
.priceConfiguration
|
|
460
|
+
.originalPriceLabel
|
|
461
|
+
.font = iOSFontInfo.getFont(fontSize)
|
|
462
|
+
}
|
|
463
|
+
if let numberOfLines = originalPriceLabel.numberOfLines {
|
|
464
|
+
productInfoViewConfigurator
|
|
465
|
+
.productCardConfiguration
|
|
466
|
+
.priceConfiguration
|
|
467
|
+
.originalPriceLabel
|
|
468
|
+
.numberOfLines = numberOfLines
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if let isPriceFirst = priceConfiguration.isPriceFirst {
|
|
473
|
+
productInfoViewConfigurator.productCardConfiguration.priceConfiguration.isPriceFirst = isPriceFirst
|
|
389
474
|
}
|
|
390
475
|
}
|
|
391
476
|
|
|
392
477
|
if let isCtaButtonHidden = productCardConfiguration.isCtaButtonHidden {
|
|
393
478
|
productInfoViewConfigurator.productCardConfiguration.ctaConfig.isHidden = isCtaButtonHidden
|
|
394
479
|
}
|
|
480
|
+
|
|
481
|
+
if let ctaButtonStyle = productCardConfiguration.ctaButtonStyle {
|
|
482
|
+
if let textColor = ctaButtonStyle.textColor,
|
|
483
|
+
textColor.count > 0,
|
|
484
|
+
let color = textColor.uicolor() {
|
|
485
|
+
productInfoViewConfigurator.productCardConfiguration.ctaConfig.textColor = color
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if let fontSize = ctaButtonStyle.fontSize {
|
|
489
|
+
let iOSFontInfo = ctaButtonStyle.iOSFontInfo ?? FontInfo()
|
|
490
|
+
productInfoViewConfigurator.productCardConfiguration.ctaConfig.font = iOSFontInfo.getFont(fontSize)
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if let width = productCardConfiguration.width, let height = productCardConfiguration.height {
|
|
495
|
+
productInfoViewConfigurator.productCardConfiguration.size = CGSize(
|
|
496
|
+
width: width,
|
|
497
|
+
height: height
|
|
498
|
+
)
|
|
499
|
+
} else if let width = productCardConfiguration.width {
|
|
500
|
+
let originalSize = productInfoViewConfigurator.productCardConfiguration.size
|
|
501
|
+
productInfoViewConfigurator.productCardConfiguration.size = CGSize(
|
|
502
|
+
width: width,
|
|
503
|
+
height: originalSize.height
|
|
504
|
+
)
|
|
505
|
+
} else if let height = productCardConfiguration.height {
|
|
506
|
+
let originalSize = productInfoViewConfigurator.productCardConfiguration.size
|
|
507
|
+
productInfoViewConfigurator.productCardConfiguration.size = CGSize(
|
|
508
|
+
width: originalSize.width,
|
|
509
|
+
height: height
|
|
510
|
+
)
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if let backgroundColor = productCardConfiguration.backgroundColor,
|
|
514
|
+
backgroundColor.count > 0,
|
|
515
|
+
let color = backgroundColor.uicolor() {
|
|
516
|
+
productInfoViewConfigurator.productCardConfiguration.backgroundColor = color
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if let iconConfiguration = productCardConfiguration.iconConfiguration {
|
|
520
|
+
if let cornerRadius = iconConfiguration.cornerRadius {
|
|
521
|
+
productInfoViewConfigurator.productCardConfiguration.productIcon.cornerRadius = cornerRadius
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if let nameLabel = productCardConfiguration.nameLabel {
|
|
526
|
+
if let textColor = nameLabel.textColor,
|
|
527
|
+
textColor.count > 0,
|
|
528
|
+
let color = textColor.uicolor() {
|
|
529
|
+
productInfoViewConfigurator.productCardConfiguration.nameLabel.textColor = color
|
|
530
|
+
}
|
|
531
|
+
if let fontSize = nameLabel.fontSize {
|
|
532
|
+
let iOSFontInfo = nameLabel.iOSFontInfo ?? FontInfo()
|
|
533
|
+
productInfoViewConfigurator.productCardConfiguration.nameLabel.font = iOSFontInfo.getFont(fontSize)
|
|
534
|
+
}
|
|
535
|
+
if let numberOfLines = nameLabel.numberOfLines {
|
|
536
|
+
productInfoViewConfigurator.productCardConfiguration.nameLabel.numberOfLines = numberOfLines
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
395
540
|
}
|
|
396
541
|
|
|
397
542
|
productInfoViewConfigurator.productDetailsConfiguration = productDetailsConfiguration
|
|
@@ -464,4 +609,20 @@ extension ShoppingModule {
|
|
|
464
609
|
return result
|
|
465
610
|
}
|
|
466
611
|
}
|
|
612
|
+
|
|
613
|
+
extension ShoppingModule {
|
|
614
|
+
static func getTopPlayerViewController(_ viewController: UIViewController) -> UIViewController? {
|
|
615
|
+
if viewController is PlayerViewController {
|
|
616
|
+
return viewController
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
for childVC in viewController.children {
|
|
620
|
+
if let result = getTopPlayerViewController(childVC) {
|
|
621
|
+
return result
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
return nil
|
|
626
|
+
}
|
|
627
|
+
}
|
|
467
628
|
// swiftlint:enable file_length type_body_length
|
|
@@ -218,7 +218,23 @@ class FireworkSDK {
|
|
|
218
218
|
this.eventEmitter.addListener(_FWEventName.FWEventName.CustomCTAClick, event => {
|
|
219
219
|
_FWLoggerUtil.default.log(`Receive CustomCTAClick url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
220
220
|
|
|
221
|
+
_FWLoggerUtil.default.log(`Receive CustomCTAClick callbackId: ${event === null || event === void 0 ? void 0 : event.callbackId}`);
|
|
222
|
+
|
|
221
223
|
if (this.onCustomCTAClick) {
|
|
224
|
+
if (event) {
|
|
225
|
+
if (event.callbackId) {
|
|
226
|
+
const callbackId = event.callbackId;
|
|
227
|
+
delete event.callbackId;
|
|
228
|
+
|
|
229
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
230
|
+
event.playerHandler = {
|
|
231
|
+
pause: () => _FireworkSDKModule.default.pausePlayer(callbackId),
|
|
232
|
+
resume: () => _FireworkSDKModule.default.resumePlayer(callbackId)
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
222
238
|
this.onCustomCTAClick(event !== null && event !== void 0 ? event : {});
|
|
223
239
|
}
|
|
224
240
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FireworkSDK.ts"],"names":["FireworkSDK","onVideoFeedClick","_onVideoFeedClick","value","Platform","OS","FireworkSDKModule","setVideoFeedClickCallbackEnabled","onCustomCTAClick","_onCustomCTAClick","FWLoggerUtil","log","setCustomCTAClickEnabled","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","updateInternalShareBaseURL","setShareBaseURL","adBadgeConfiguration","_adBadgeConfiguration","valueHasChanged","badgeTextType","backgroundColor","textColor","androidFontInfo","isCustom","typefaceName","eventEmitter","emit","FWEventName","AdBadgeConfigurationUpdated","setAdBadgeConfiguration","appLanguage","_appLanguage","debugLogsEnabled","enabled","videoLaunchBehavior","_videoLaunchBehavior","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","NativeAppLanguageUpdated","language","updateInternalAppLanguage","init","options","videoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","ShoppingModule","LiveStreamModule","FWGlobalState","resolveSdkInitCalled","markInitCalled","openVideoPlayer","config","sdkInitCalled","sdkInitCalledPromise","trackPurchase","parameters","changeAppLanguage","result","languageChanged","stopFloatingPlayer","AppLanguageUpdated","shareBaseURLChanged","ShareBaseURLUpdated"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;AAUA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAcA;AACA;AACA;AACA,MAAMA,WAAN,CAAkB;AAGhB;AACF;AACA;;AAGE;AACF;AACA;AAC6B,MAAhBC,gBAAgB,GAAuC;AAChE,WAAO,KAAKC,iBAAZ;AACD;;AAC0B,MAAhBD,gBAAgB,CAACE,KAAD,EAA4C;AACrE,SAAKD,iBAAL,GAAyBC,KAAzB;;AACA,QAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,iCAAkBC,gCAAlB,CAAmD,CAAC,CAACJ,KAArD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,kBAAf,EAAN;AACD;;AACD,WAAKnB,yBAAL,CAA+BD,QAA/B;AACD;;AACD,WAAOkB,MAAP;AACD;;AAEOjB,EAAAA,yBAAyB,CAACD,QAAD,EAA2B;AAC1D,UAAM/C,eAAe,GAAG,KAAKa,YAAL,KAAsBkC,QAA9C;AACA,SAAKlC,YAAL,GAAoBkC,QAApB;;AACA,QAAI/C,eAAJ,EAAqB;AACnB,WAAKO,YAAL,CAAkBC,IAAlB,CAAuBC,yBAAY2D,kBAAnC;AACD;AACF;;AAEOxE,EAAAA,0BAA0B,CAACF,YAAD,EAAwB;AACxD,UAAM2E,mBAAmB,GAAG,KAAK1E,aAAL,KAAuBD,YAAnD;AACA,SAAKC,aAAL,GAAqBD,YAArB;;AACA,QAAI2E,mBAAJ,EAAyB;AACvB,WAAK9D,YAAL,CAAkBC,IAAlB,CAAuBC,yBAAY6D,mBAAnC;AACD;AACF;;AAtSe;;gBAAZ5F,W;;eAySSA,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 SDKInitOptions from './models/SDKInitOptions';\nimport type { VideoLaunchBehavior } from './models/SDKInitOptions';\nimport type TrackPurchaseParameters from './models/TrackPurchaseParameters';\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';\nimport FWGlobalState from './utils/FWGlobalState';\nimport type OpenVideoPlayerConfiguration from './models/OpenVideoPlayerConfiguration';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => Promise<void> | void;\nexport type CustomCTAClickCallback = (\n event: CustomCTAClickEvent\n) => Promise<void> | void;\nexport type VideoPlaybackCallback = (\n event: VideoPlaybackEvent\n) => Promise<void> | void;\nexport type VideoFeedClickCallback = (\n event: VideoFeedClickEvent\n) => Promise<void> | void;\n\n/**\n * Firework SDK.\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 get onVideoFeedClick(): VideoFeedClickCallback | undefined {\n return this._onVideoFeedClick;\n }\n public set onVideoFeedClick(value: VideoFeedClickCallback | undefined) {\n this._onVideoFeedClick = value;\n if (Platform.OS === 'ios') {\n FireworkSDKModule.setVideoFeedClickCallbackEnabled(!!value);\n }\n }\n private _onVideoFeedClick?: VideoFeedClickCallback | undefined;\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 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 global share base URL of the video.\n * The {@link VideoPlayerConfiguration.shareBaseURL} in {@link VideoPlayerConfiguration} will override this.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this.updateInternalShareBaseURL(value);\n FireworkSDKModule.setShareBaseURL(value ?? '');\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?.androidFontInfo?.isCustom !==\n value?.androidFontInfo?.isCustom ||\n this._adBadgeConfiguration?.androidFontInfo?.typefaceName !==\n value?.androidFontInfo?.typefaceName;\n this._adBadgeConfiguration = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n }\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {});\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n public get appLanguage(): string | undefined | null {\n return this._appLanguage;\n }\n private _appLanguage: string | undefined | null;\n\n /**\n * Defaults to false.\n * 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 /**\n * Get video launch behavior.\n */\n public get videoLaunchBehavior(): VideoLaunchBehavior | undefined {\n return this._videoLaunchBehavior;\n }\n private _videoLaunchBehavior: VideoLaunchBehavior | 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 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\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 if (Platform.OS === 'ios') {\n this.eventEmitter.addListener(\n FWEventName.NativeAppLanguageUpdated,\n (event) => {\n FWLoggerUtil.log(\n `Receive NativeAppLanguageUpdated event appLanguage: ${event.appLanguage}`\n );\n const language = event.appLanguage;\n this.updateInternalAppLanguage(language);\n }\n );\n }\n }\n\n /**\n * Initializes Firework SDK.\n * @param {SDKInitOptions?} options\n */\n public async init(options?: SDKInitOptions): Promise<void> {\n FWLoggerUtil.log('Call FireworkSDK init method');\n const videoLaunchBehaviorUpdated =\n this._videoLaunchBehavior !== options?.videoLaunchBehavior;\n this._videoLaunchBehavior = options?.videoLaunchBehavior;\n if (videoLaunchBehaviorUpdated) {\n this.eventEmitter.emit(FWEventName.VideoLaunchBehaviorUpdated);\n }\n await FireworkSDKModule.init(options);\n await ShoppingModule.init();\n await LiveStreamModule.init();\n\n FWGlobalState.getInstance().resolveSdkInitCalled();\n }\n\n /**\n * You only need to call this method when you call init method in native side instead of JS side.\n */\n public async markInitCalled(): Promise<void> {\n FWGlobalState.getInstance().resolveSdkInitCalled();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public async openVideoPlayer(\n url: string,\n config?: OpenVideoPlayerConfiguration\n ): Promise<void> {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n\n /**\n * Records the user purchase. Only supported on iOS.\n * @param {TrackPurchaseParameters} parameters\n */\n public async trackPurchase(\n parameters: TrackPurchaseParameters\n ): Promise<void> {\n if (Platform.OS === 'ios') {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n FireworkSDKModule.trackPurchase(parameters);\n }\n }\n\n /**\n * Change App level language.\n * @param {string | undefined | null} language Such as en, ar and en-US. If language is undefined or null or empty string, SDK will use system language.\n * @returns {Promise<boolean>} The result of changing app language.\n */\n public async changeAppLanguage(language?: string | null): Promise<boolean> {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n\n const result = await FireworkSDKModule.changeAppLanguage(language);\n\n if (result) {\n const languageChanged = this._appLanguage !== language;\n if (Platform.OS === 'ios' && languageChanged) {\n await this.navigator.stopFloatingPlayer();\n }\n this.updateInternalAppLanguage(language);\n }\n return result;\n }\n\n private updateInternalAppLanguage(language?: string | null) {\n const valueHasChanged = this._appLanguage !== language;\n this._appLanguage = language;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AppLanguageUpdated);\n }\n }\n\n private updateInternalShareBaseURL(shareBaseURL?: string) {\n const shareBaseURLChanged = this._shareBaseURL !== shareBaseURL;\n this._shareBaseURL = shareBaseURL;\n if (shareBaseURLChanged) {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n }\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
1
|
+
{"version":3,"sources":["FireworkSDK.ts"],"names":["FireworkSDK","onVideoFeedClick","_onVideoFeedClick","value","Platform","OS","FireworkSDKModule","setVideoFeedClickCallbackEnabled","onCustomCTAClick","_onCustomCTAClick","FWLoggerUtil","log","setCustomCTAClickEnabled","onVideoPlayback","_onVideoPlayback","setVideoPlaybackEventEnabled","shareBaseURL","_shareBaseURL","updateInternalShareBaseURL","setShareBaseURL","adBadgeConfiguration","_adBadgeConfiguration","valueHasChanged","badgeTextType","backgroundColor","textColor","androidFontInfo","isCustom","typefaceName","eventEmitter","emit","FWEventName","AdBadgeConfigurationUpdated","setAdBadgeConfiguration","appLanguage","_appLanguage","debugLogsEnabled","enabled","videoLaunchBehavior","_videoLaunchBehavior","FireworkSDKModuleEventEmitter","shopping","_shopping","liveStream","_liveStream","navigator","_navigator","getInstance","_instance","constructor","VideoShopping","LiveStream","FWNavigator","addListener","SDKInit","event","error","onSDKInit","LogMessage","logNativeMessage","message","CustomCTAClick","url","callbackId","playerHandler","pause","pausePlayer","resume","resumePlayer","VideoPlayback","eventName","VideoFeedClick","info","id","NativeAppLanguageUpdated","language","updateInternalAppLanguage","init","options","videoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","ShoppingModule","LiveStreamModule","FWGlobalState","resolveSdkInitCalled","markInitCalled","openVideoPlayer","config","sdkInitCalled","sdkInitCalledPromise","trackPurchase","parameters","changeAppLanguage","result","languageChanged","stopFloatingPlayer","AppLanguageUpdated","shareBaseURLChanged","ShareBaseURLUpdated"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;AAUA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAcA;AACA;AACA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L,KAAuBD,YAAnD;AACA,SAAKC,aAAL,GAAqBD,YAArB;;AACA,QAAIiF,mBAAJ,EAAyB;AACvB,WAAKpE,YAAL,CAAkBC,IAAlB,CAAuBC,yBAAYmE,mBAAnC;AACD;AACF;;AAtTe;;gBAAZlG,W;;eAyTSA,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 SDKInitOptions from './models/SDKInitOptions';\nimport type { VideoLaunchBehavior } from './models/SDKInitOptions';\nimport type TrackPurchaseParameters from './models/TrackPurchaseParameters';\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';\nimport FWGlobalState from './utils/FWGlobalState';\nimport type OpenVideoPlayerConfiguration from './models/OpenVideoPlayerConfiguration';\n\nexport type SDKInitCallback = (event: SDKInitEvent) => Promise<void> | void;\nexport type CustomCTAClickCallback = (\n event: CustomCTAClickEvent\n) => Promise<void> | void;\nexport type VideoPlaybackCallback = (\n event: VideoPlaybackEvent\n) => Promise<void> | void;\nexport type VideoFeedClickCallback = (\n event: VideoFeedClickEvent\n) => Promise<void> | void;\n\n/**\n * Firework SDK.\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 get onVideoFeedClick(): VideoFeedClickCallback | undefined {\n return this._onVideoFeedClick;\n }\n public set onVideoFeedClick(value: VideoFeedClickCallback | undefined) {\n this._onVideoFeedClick = value;\n if (Platform.OS === 'ios') {\n FireworkSDKModule.setVideoFeedClickCallbackEnabled(!!value);\n }\n }\n private _onVideoFeedClick?: VideoFeedClickCallback | undefined;\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 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 global share base URL of the video.\n * The {@link VideoPlayerConfiguration.shareBaseURL} in {@link VideoPlayerConfiguration} will override this.\n */\n public get shareBaseURL(): string | undefined {\n return this._shareBaseURL;\n }\n public set shareBaseURL(value: string | undefined) {\n this.updateInternalShareBaseURL(value);\n FireworkSDKModule.setShareBaseURL(value ?? '');\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?.androidFontInfo?.isCustom !==\n value?.androidFontInfo?.isCustom ||\n this._adBadgeConfiguration?.androidFontInfo?.typefaceName !==\n value?.androidFontInfo?.typefaceName;\n this._adBadgeConfiguration = value;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AdBadgeConfigurationUpdated);\n }\n FireworkSDKModule.setAdBadgeConfiguration(value ?? {});\n }\n private _adBadgeConfiguration: AdBadgeConfiguration | undefined;\n\n public get appLanguage(): string | undefined | null {\n return this._appLanguage;\n }\n private _appLanguage: string | undefined | null;\n\n /**\n * Defaults to false.\n * 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 /**\n * Get video launch behavior.\n */\n public get videoLaunchBehavior(): VideoLaunchBehavior | undefined {\n return this._videoLaunchBehavior;\n }\n private _videoLaunchBehavior: VideoLaunchBehavior | 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 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\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 FWLoggerUtil.log(\n `Receive CustomCTAClick callbackId: ${event?.callbackId}`\n );\n\n if (this.onCustomCTAClick) {\n if (event) {\n if (event.callbackId) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (Platform.OS === 'ios') {\n event.playerHandler = {\n pause: () => FireworkSDKModule.pausePlayer(callbackId),\n resume: () => FireworkSDKModule.resumePlayer(callbackId),\n };\n }\n }\n }\n\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 if (Platform.OS === 'ios') {\n this.eventEmitter.addListener(\n FWEventName.NativeAppLanguageUpdated,\n (event) => {\n FWLoggerUtil.log(\n `Receive NativeAppLanguageUpdated event appLanguage: ${event.appLanguage}`\n );\n const language = event.appLanguage;\n this.updateInternalAppLanguage(language);\n }\n );\n }\n }\n\n /**\n * Initializes Firework SDK.\n * @param {SDKInitOptions?} options\n */\n public async init(options?: SDKInitOptions): Promise<void> {\n FWLoggerUtil.log('Call FireworkSDK init method');\n const videoLaunchBehaviorUpdated =\n this._videoLaunchBehavior !== options?.videoLaunchBehavior;\n this._videoLaunchBehavior = options?.videoLaunchBehavior;\n if (videoLaunchBehaviorUpdated) {\n this.eventEmitter.emit(FWEventName.VideoLaunchBehaviorUpdated);\n }\n await FireworkSDKModule.init(options);\n await ShoppingModule.init();\n await LiveStreamModule.init();\n\n FWGlobalState.getInstance().resolveSdkInitCalled();\n }\n\n /**\n * You only need to call this method when you call init method in native side instead of JS side.\n */\n public async markInitCalled(): Promise<void> {\n FWGlobalState.getInstance().resolveSdkInitCalled();\n }\n\n /**\n * Open Video URL.\n * @param {string} url\n * @param {VideoPlayerConfiguration} config\n */\n public async openVideoPlayer(\n url: string,\n config?: OpenVideoPlayerConfiguration\n ): Promise<void> {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n FireworkSDKModule.openVideoPlayer(url, config ?? {});\n }\n\n /**\n * Records the user purchase. Only supported on iOS.\n * @param {TrackPurchaseParameters} parameters\n */\n public async trackPurchase(\n parameters: TrackPurchaseParameters\n ): Promise<void> {\n if (Platform.OS === 'ios') {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n FireworkSDKModule.trackPurchase(parameters);\n }\n }\n\n /**\n * Change App level language.\n * @param {string | undefined | null} language Such as en, ar and en-US. If language is undefined or null or empty string, SDK will use system language.\n * @returns {Promise<boolean>} The result of changing app language.\n */\n public async changeAppLanguage(language?: string | null): Promise<boolean> {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n\n const result = await FireworkSDKModule.changeAppLanguage(language);\n\n if (result) {\n const languageChanged = this._appLanguage !== language;\n if (Platform.OS === 'ios' && languageChanged) {\n await this.navigator.stopFloatingPlayer();\n }\n this.updateInternalAppLanguage(language);\n }\n return result;\n }\n\n private updateInternalAppLanguage(language?: string | null) {\n const valueHasChanged = this._appLanguage !== language;\n this._appLanguage = language;\n if (valueHasChanged) {\n this.eventEmitter.emit(FWEventName.AppLanguageUpdated);\n }\n }\n\n private updateInternalShareBaseURL(shareBaseURL?: string) {\n const shareBaseURLChanged = this._shareBaseURL !== shareBaseURL;\n this._shareBaseURL = shareBaseURL;\n if (shareBaseURLChanged) {\n this.eventEmitter.emit(FWEventName.ShareBaseURLUpdated);\n }\n }\n}\n\nexport default FireworkSDK;\n"]}
|
|
@@ -174,7 +174,27 @@ class VideoShopping {
|
|
|
174
174
|
this.eventEmitter.addListener(_FWEventName.FWEventName.CustomProductCardTap, event => {
|
|
175
175
|
_FWLoggerUtil.default.log(`Receive CustomProductCardTap event url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
if (event) {
|
|
178
|
+
if (!event.video) {
|
|
179
|
+
event.video = {
|
|
180
|
+
videoId: ''
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (event.callbackId) {
|
|
185
|
+
const callbackId = event.callbackId;
|
|
186
|
+
delete event.callbackId;
|
|
187
|
+
|
|
188
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
189
|
+
event.playerHandler = {
|
|
190
|
+
pause: () => _ShoppingModule.default.pausePlayer(callbackId),
|
|
191
|
+
resume: () => _ShoppingModule.default.resumePlayer(callbackId)
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
this.handleCustomProductCardTapEvent(event !== null && event !== void 0 ? event : {});
|
|
178
198
|
});
|
|
179
199
|
}
|
|
180
200
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","onCustomClickLinkButton","_onCustomClickLinkButton","value","ShoppingModule","setCustomClickLinkButtonEnabled","onCustomTapProductCard","_onCustomTapProductCard","Platform","OS","setCustomTapProductCardEnabled","cartIconVisible","_cartIconVisible","FWGlobalState","getInstance","sdkInitCalled","setCartIconVisible","sdkInitCalledPromise","then","productInfoViewConfiguration","_productInfoViewConfiguration","setProductInfoViewConfiguration","eventEmitter","ShoppingModuleEventEmitter","FWLoggerUtil","log","_instance","constructor","addListener","FWEventName","ShoppingCTAButtonClick","event","productId","unitId","url","handleShoppingCTAEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","LogMessage","CustomLinkButtonClick","handleCustomLinkButtonClickEvent","CustomProductCardTap","handleCustomProductCardTapEvent","setCartItemCount","count","callbackId","onShoppingCTA","result","updateShoppingCTAResult","clearCallbackId","onCustomClickCartIcon","onUpdateProductDetails","productList","map","product","length","updateVideoProducts"],"mappings":";;;;;;;AAAA;;AAEA;;AASA;;AAGA;;AAEA;;;;;;;;;;AAuBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACoC,MAAvBC,uBAAuB,GAEpB;AACZ,WAAO,KAAKC,wBAAZ;AACD;;AACiC,MAAvBD,uBAAuB,CAChCE,KADgC,EAEhC;AACA,SAAKD,wBAAL,GAAgCC,KAAhC;;AACAC,4BAAeC,+BAAf,CAA+C,CAAC,CAACF,KAAjD;AACD;;AAGD;AACF;AACA;AACA;AACA;AACA;AACA;AACmC,MAAtBG,sBAAsB,GAEnB;AACZ,WAAO,KAAKC,uBAAZ;AACD;;AACgC,MAAtBD,sBAAsB,CAC/BH,KAD+B,EAE/B;AACA,SAAKI,uBAAL,GAA+BJ,KAA/B;;AACA,QAAIK,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBL,8BAAeM,8BAAf,CAA8C,CAAC,CAACP,KAAhD;AACD;AACF;;AAGD;AACF;AACA;AACA;AAC4B,MAAfQ,eAAe,GAAY;AACpC,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACR,KAAD,EAAiB;AACzC,SAAKS,gBAAL,GAAwBT,KAAxB;;AACA,QAAIU,uBAAcC,WAAd,GAA4BC,aAAhC,EAA+C;AAC7CX,8BAAeY,kBAAf,CAAkCb,KAAlC;AACD,KAFD,MAEO;AACLU,6BAAcC,WAAd,GAA4BG,oBAA5B,CAAiDC,IAAjD,CAAsD,MAAM;AAC1Dd,gCAAeY,kBAAf,CAA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ASC,EAAT,KAAgB,KAApB,EAA2B;AACzBL,oCAAegD,eAAf,CACEJ,UADF,EAEEnB,yBAAYS,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACLd,4BAAaC,GAAb,CAAiB,6CAAjB;;AACA,UAAIuB,UAAJ,EAAgB;AACd,YAAIxC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBL,kCAAegD,eAAf,CACEJ,UADF,EAEEnB,yBAAYS,oBAFd;AAID;AACF;AACF;AACF;;AAE6C,QAAhCK,gCAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAK9B,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6B8B,KAA7B;AACD;AACF;;AAE4C,QAA/Bc,+BAA+B,CAC3Cd,KAD2C,EAE3C;AACA,QAAI,KAAKzB,sBAAT,EAAiC;AAC/B,WAAKA,sBAAL,CAA4ByB,KAA5B;AACD;AACF;;AA9QiB;;gBAAd/B,a;;eAiRSA,a","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomClickLinkButtonEvent,\n CustomTapProductCardEvent,\n ShoppingCTAEvent,\n UpdateProductDetailsEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport type ShoppingCTAResult from './models/ShoppingCTAResult';\nimport FWGlobalState from './utils/FWGlobalState';\n\nexport type ShoppingCTACallback = (\n event: ShoppingCTAEvent\n) => Promise<ShoppingCTAResult> | ShoppingCTAResult;\n\nexport type CustomClickCartIconCallback = () => Promise<void> | void;\n\nexport type UpdateProductDetailsCallbackResult = Product[] | undefined | null;\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) =>\n | Promise<UpdateProductDetailsCallbackResult>\n | UpdateProductDetailsCallbackResult;\n\nexport type CustomClickLinkButtonCallback = (\n event: CustomClickLinkButtonEvent\n) => Promise<void> | void;\n\nexport type CustomTapProductCardCallback = (\n event: CustomTapProductCardEvent\n) => Promise<void> | void;\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" or \"Shop now\" button.\n * The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.\n */\n public onShoppingCTA?: ShoppingCTACallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the click event processing logic of\n * the shopping cart icon by setting the callback.\n */\n public 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 user clicks\n * the link button next to Add to cart button.\n *\n * The host app can customize the click event processing logic of\n * the link button by setting the callback.\n */\n public get onCustomClickLinkButton():\n | CustomClickLinkButtonCallback\n | undefined {\n return this._onCustomClickLinkButton;\n }\n public set onCustomClickLinkButton(\n value: CustomClickLinkButtonCallback | undefined\n ) {\n this._onCustomClickLinkButton = value;\n ShoppingModule.setCustomClickLinkButtonEnabled(!!value);\n }\n private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;\n\n /**\n * This callback is triggered when the user clicks product card.\n * Only supported on iOS.\n *\n * The host app can customize the tap event processing logic of\n * the product card by setting the callback.\n */\n public get onCustomTapProductCard():\n | CustomTapProductCardCallback\n | undefined {\n return this._onCustomTapProductCard;\n }\n public set onCustomTapProductCard(\n value: CustomTapProductCardCallback | undefined\n ) {\n this._onCustomTapProductCard = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomTapProductCardEnabled(!!value);\n }\n }\n private _onCustomTapProductCard?: CustomTapProductCardCallback | undefined;\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 if (FWGlobalState.getInstance().sdkInitCalled) {\n ShoppingModule.setCartIconVisible(value);\n } else {\n FWGlobalState.getInstance().sdkInitCalledPromise.then(() => {\n ShoppingModule.setCartIconVisible(value);\n });\n }\n }\n private _cartIconVisible: boolean = true;\n\n /**\n * The configuration of product info view.\n * Please refer to {@link ProductInfoViewConfiguration} for more details.\n */\n public get productInfoViewConfiguration():\n | ProductInfoViewConfiguration\n | undefined {\n return this._productInfoViewConfiguration;\n }\n\n public set productInfoViewConfiguration(\n value: ProductInfoViewConfiguration | undefined\n ) {\n this._productInfoViewConfiguration = value;\n if (FWGlobalState.getInstance().sdkInitCalled) {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n } else {\n FWGlobalState.getInstance().sdkInitCalledPromise.then(() => {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n });\n }\n }\n\n private _productInfoViewConfiguration?:\n | ProductInfoViewConfiguration\n | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(\n FWEventName.ShoppingCTAButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive ShoppingCTA event productId: ${event?.productId} unitId: ${event?.unitId} url: ${event?.url}`\n );\n this.handleShoppingCTAEvent(event);\n }\n );\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, () => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent();\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event?.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n\n this.eventEmitter.addListener(\n FWEventName.CustomLinkButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive CustomLinkButtonClick event url: ${event?.url}`\n );\n this.handleCustomLinkButtonClickEvent(event);\n }\n );\n\n this.eventEmitter.addListener(FWEventName.CustomProductCardTap, (event) => {\n FWLoggerUtil.log(`Receive CustomProductCardTap event url: ${event?.url}`);\n this.handleCustomProductCardTapEvent(event);\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 async setCartItemCount(count: number): Promise<void> {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleShoppingCTAEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n\n if (this.onShoppingCTA) {\n const result = await this.onShoppingCTA(event as ShoppingCTAEvent);\n if (callbackId) {\n ShoppingModule.updateShoppingCTAResult(result, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.ShoppingCTAButtonClick\n );\n }\n }\n }\n }\n\n private async handleClickCartIconEvent() {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n }\n }\n\n private async handleUpdateProductDetailsEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n\n private async handleCustomProductCardTapEvent(\n event: CustomTapProductCardEvent\n ) {\n if (this.onCustomTapProductCard) {\n this.onCustomTapProductCard(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
|
1
|
+
{"version":3,"sources":["VideoShopping.ts"],"names":["VideoShopping","onCustomClickLinkButton","_onCustomClickLinkButton","value","ShoppingModule","setCustomClickLinkButtonEnabled","onCustomTapProductCard","_onCustomTapProductCard","Platform","OS","setCustomTapProductCardEnabled","cartIconVisible","_cartIconVisible","FWGlobalState","getInstance","sdkInitCalled","setCartIconVisible","sdkInitCalledPromise","then","productInfoViewConfiguration","_productInfoViewConfiguration","setProductInfoViewConfiguration","eventEmitter","ShoppingModuleEventEmitter","FWLoggerUtil","log","_instance","constructor","addListener","FWEventName","ShoppingCTAButtonClick","event","productId","unitId","url","handleShoppingCTAEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","LogMessage","CustomLinkButtonClick","handleCustomLinkButtonClickEvent","CustomProductCardTap","video","videoId","callbackId","playerHandler","pause","pausePlayer","resume","resumePlayer","handleCustomProductCardTapEvent","setCartItemCount","count","onShoppingCTA","result","updateShoppingCTAResult","clearCallbackId","onCustomClickCartIcon","onUpdateProductDetails","productList","map","product","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,UAAU,GAAG,CAACuB,WAAW,IAAI,EAAhB,EAAoBC,GAApB,CAChBC,OAAD;AAAA;;AAAA,qCAAaA,OAAO,CAAChC,SAArB,mEAAkC,EAAlC;AAAA,OADiB,CAAnB;;AAIAR,4BAAaC,GAAb,CACG,+DAA8Dc,UAAW,uBACxE,CAACuB,WAAW,IAAI,EAAhB,EAAoBG,MACrB,EAHH;;AAMA,UAAIH,WAAJ,EAAiB;AACf,YAAIf,UAAJ,EAAgB;AACd3C,kCAAe8D,mBAAf,CAAmCJ,WAAnC,EAAgDf,UAAhD;AACD;AACF,OAJD,MAIO;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAIvC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBL,oCAAeuD,eAAf,CACEZ,UADF,EAEElB,yBAAYS,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACLd,4BAAaC,GAAb,CAAiB,6CAAjB;;AACA,UAAIsB,UAAJ,EAAgB;AACd,YAAIvC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBL,kCAAeuD,eAAf,CACEZ,UADF,EAEElB,yBAAYS,oBAFd;AAID;AACF;AACF;AACF;;AAE6C,QAAhCK,gCAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAK9B,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6B8B,KAA7B;AACD;AACF;;AAE4C,QAA/BsB,+BAA+B,CAC3CtB,KAD2C,EAE3C;AACA,QAAI,KAAKzB,sBAAT,EAAiC;AAC/B,WAAKA,sBAAL,CAA4ByB,KAA5B;AACD;AACF;;AA/RiB;;gBAAd/B,a;;eAkSSA,a","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomClickLinkButtonEvent,\n CustomTapProductCardEvent,\n ShoppingCTAEvent,\n UpdateProductDetailsEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport type ShoppingCTAResult from './models/ShoppingCTAResult';\nimport FWGlobalState from './utils/FWGlobalState';\n\nexport type ShoppingCTACallback = (\n event: ShoppingCTAEvent\n) => Promise<ShoppingCTAResult> | ShoppingCTAResult;\n\nexport type CustomClickCartIconCallback = () => Promise<void> | void;\n\nexport type UpdateProductDetailsCallbackResult = Product[] | undefined | null;\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) =>\n | Promise<UpdateProductDetailsCallbackResult>\n | UpdateProductDetailsCallbackResult;\n\nexport type CustomClickLinkButtonCallback = (\n event: CustomClickLinkButtonEvent\n) => Promise<void> | void;\n\nexport type CustomTapProductCardCallback = (\n event: CustomTapProductCardEvent\n) => Promise<void> | void;\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" or \"Shop now\" button.\n * The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.\n */\n public onShoppingCTA?: ShoppingCTACallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the click event processing logic of\n * the shopping cart icon by setting the callback.\n */\n public 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 user clicks\n * the link button next to Add to cart button.\n *\n * The host app can customize the click event processing logic of\n * the link button by setting the callback.\n */\n public get onCustomClickLinkButton():\n | CustomClickLinkButtonCallback\n | undefined {\n return this._onCustomClickLinkButton;\n }\n public set onCustomClickLinkButton(\n value: CustomClickLinkButtonCallback | undefined\n ) {\n this._onCustomClickLinkButton = value;\n ShoppingModule.setCustomClickLinkButtonEnabled(!!value);\n }\n private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;\n\n /**\n * This callback is triggered when the user clicks product card.\n * Only supported on iOS.\n *\n * The host app can customize the tap event processing logic of\n * the product card by setting the callback.\n */\n public get onCustomTapProductCard():\n | CustomTapProductCardCallback\n | undefined {\n return this._onCustomTapProductCard;\n }\n public set onCustomTapProductCard(\n value: CustomTapProductCardCallback | undefined\n ) {\n this._onCustomTapProductCard = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomTapProductCardEnabled(!!value);\n }\n }\n private _onCustomTapProductCard?: CustomTapProductCardCallback | undefined;\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 if (FWGlobalState.getInstance().sdkInitCalled) {\n ShoppingModule.setCartIconVisible(value);\n } else {\n FWGlobalState.getInstance().sdkInitCalledPromise.then(() => {\n ShoppingModule.setCartIconVisible(value);\n });\n }\n }\n private _cartIconVisible: boolean = true;\n\n /**\n * The configuration of product info view.\n * Please refer to {@link ProductInfoViewConfiguration} for more details.\n */\n public get productInfoViewConfiguration():\n | ProductInfoViewConfiguration\n | undefined {\n return this._productInfoViewConfiguration;\n }\n\n public set productInfoViewConfiguration(\n value: ProductInfoViewConfiguration | undefined\n ) {\n this._productInfoViewConfiguration = value;\n if (FWGlobalState.getInstance().sdkInitCalled) {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n } else {\n FWGlobalState.getInstance().sdkInitCalledPromise.then(() => {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n });\n }\n }\n\n private _productInfoViewConfiguration?:\n | ProductInfoViewConfiguration\n | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(\n FWEventName.ShoppingCTAButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive ShoppingCTA event productId: ${event?.productId} unitId: ${event?.unitId} url: ${event?.url}`\n );\n this.handleShoppingCTAEvent(event);\n }\n );\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, () => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent();\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event?.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n\n this.eventEmitter.addListener(\n FWEventName.CustomLinkButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive CustomLinkButtonClick event url: ${event?.url}`\n );\n this.handleCustomLinkButtonClickEvent(event);\n }\n );\n\n this.eventEmitter.addListener(FWEventName.CustomProductCardTap, (event) => {\n FWLoggerUtil.log(`Receive CustomProductCardTap event url: ${event?.url}`);\n if (event) {\n if (!event.video) {\n event.video = { videoId: '' };\n }\n\n if (event.callbackId) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (Platform.OS === 'ios') {\n event.playerHandler = {\n pause: () => ShoppingModule.pausePlayer(callbackId),\n resume: () => ShoppingModule.resumePlayer(callbackId),\n };\n }\n }\n }\n\n this.handleCustomProductCardTapEvent(event ?? {});\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 async setCartItemCount(count: number): Promise<void> {\n if (!FWGlobalState.getInstance().sdkInitCalled) {\n await FWGlobalState.getInstance().sdkInitCalledPromise;\n }\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleShoppingCTAEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n\n if (this.onShoppingCTA) {\n const result = await this.onShoppingCTA(event as ShoppingCTAEvent);\n if (callbackId) {\n ShoppingModule.updateShoppingCTAResult(result, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.ShoppingCTAButtonClick\n );\n }\n }\n }\n }\n\n private async handleClickCartIconEvent() {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n }\n }\n\n private async handleUpdateProductDetailsEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n\n private async handleCustomProductCardTapEvent(\n event: CustomTapProductCardEvent\n ) {\n if (this.onCustomTapProductCard) {\n this.onCustomTapProductCard(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
|
@@ -66,6 +66,64 @@ const StoryBlock = (props, forwardedRef) => {
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
const handleStoryBlockDidStartPictureInPicture = event => {
|
|
70
|
+
_FWLoggerUtil.default.log(`StoryBlock handleStoryBlockDidStartPictureInPicture ${JSON.stringify(event.nativeEvent)}`);
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
onStoryBlockDidStartPictureInPicture
|
|
74
|
+
} = props;
|
|
75
|
+
const {
|
|
76
|
+
name,
|
|
77
|
+
reason
|
|
78
|
+
} = event.nativeEvent;
|
|
79
|
+
|
|
80
|
+
if (onStoryBlockDidStartPictureInPicture) {
|
|
81
|
+
if (name) {
|
|
82
|
+
if (reason) {
|
|
83
|
+
onStoryBlockDidStartPictureInPicture({
|
|
84
|
+
name,
|
|
85
|
+
reason
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
onStoryBlockDidStartPictureInPicture({
|
|
89
|
+
name
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
onStoryBlockDidStartPictureInPicture();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const handleStoryBlockDidStopPictureInPicture = event => {
|
|
99
|
+
_FWLoggerUtil.default.log(`StoryBlock handleStoryBlockDidStopPictureInPicture ${JSON.stringify(event.nativeEvent)}`);
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
onStoryBlockDidStopPictureInPicture
|
|
103
|
+
} = props;
|
|
104
|
+
const {
|
|
105
|
+
name,
|
|
106
|
+
reason
|
|
107
|
+
} = event.nativeEvent;
|
|
108
|
+
|
|
109
|
+
if (onStoryBlockDidStopPictureInPicture) {
|
|
110
|
+
if (name) {
|
|
111
|
+
if (reason) {
|
|
112
|
+
onStoryBlockDidStopPictureInPicture({
|
|
113
|
+
name,
|
|
114
|
+
reason
|
|
115
|
+
});
|
|
116
|
+
} else {
|
|
117
|
+
onStoryBlockDidStopPictureInPicture({
|
|
118
|
+
name
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
onStoryBlockDidStopPictureInPicture();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
69
127
|
const handleStoryBlockFullScreenStateChanged = event => {
|
|
70
128
|
_FWLoggerUtil.default.log(`StoryBlock handleStoryBlockFullScreenStateChanged ${event.nativeEvent.isFullScreen}`);
|
|
71
129
|
|
|
@@ -126,6 +184,10 @@ const StoryBlock = (props, forwardedRef) => {
|
|
|
126
184
|
return resultString;
|
|
127
185
|
};
|
|
128
186
|
|
|
187
|
+
const generateButtonInfoString = buttonInfo => {
|
|
188
|
+
return `imageName:${buttonInfo === null || buttonInfo === void 0 ? void 0 : buttonInfo.imageName}_systemImageName:${buttonInfo === null || buttonInfo === void 0 ? void 0 : buttonInfo.systemImageName}_tintColor:${buttonInfo === null || buttonInfo === void 0 ? void 0 : buttonInfo.tintColor}`;
|
|
189
|
+
};
|
|
190
|
+
|
|
129
191
|
const getStoryBlockConfiguration = () => {
|
|
130
192
|
const {
|
|
131
193
|
storyBlockConfiguration,
|
|
@@ -187,6 +249,7 @@ const StoryBlock = (props, forwardedRef) => {
|
|
|
187
249
|
const ctaHighlightDelayType = storyBlockConfiguration === null || storyBlockConfiguration === void 0 ? void 0 : (_storyBlockConfigurat4 = storyBlockConfiguration.ctaHighlightDelay) === null || _storyBlockConfigurat4 === void 0 ? void 0 : _storyBlockConfigurat4.type;
|
|
188
250
|
const ctaHighlightDelayValue = storyBlockConfiguration === null || storyBlockConfiguration === void 0 ? void 0 : (_storyBlockConfigurat5 = storyBlockConfiguration.ctaHighlightDelay) === null || _storyBlockConfigurat5 === void 0 ? void 0 : (_storyBlockConfigurat6 = _storyBlockConfigurat5.value) === null || _storyBlockConfigurat6 === void 0 ? void 0 : _storyBlockConfigurat6.toFixed(5);
|
|
189
251
|
const shareBaseURL = storyBlockConfiguration === null || storyBlockConfiguration === void 0 ? void 0 : storyBlockConfiguration.shareBaseURL;
|
|
252
|
+
const buttonConfiguration = storyBlockConfiguration === null || storyBlockConfiguration === void 0 ? void 0 : storyBlockConfiguration.buttonConfiguration;
|
|
190
253
|
const ctaWidth = storyBlockConfiguration === null || storyBlockConfiguration === void 0 ? void 0 : storyBlockConfiguration.ctaWidth;
|
|
191
254
|
const showVideoDetailTitle = storyBlockConfiguration === null || storyBlockConfiguration === void 0 ? void 0 : storyBlockConfiguration.showVideoDetailTitle;
|
|
192
255
|
const requiresAds = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.requiresAds;
|
|
@@ -229,6 +292,12 @@ const StoryBlock = (props, forwardedRef) => {
|
|
|
229
292
|
key += `_ctaHighlightDelayType:${ctaHighlightDelayType}`;
|
|
230
293
|
key += `_ctaHighlightDelayValue:${ctaHighlightDelayValue}`;
|
|
231
294
|
key += `_ctaWidth:${ctaWidth}`;
|
|
295
|
+
key += `_buttonConfiguration.videoDetailButton:${generateButtonInfoString(buttonConfiguration === null || buttonConfiguration === void 0 ? void 0 : buttonConfiguration.videoDetailButton)}`;
|
|
296
|
+
key += `_buttonConfiguration.closeButton:${generateButtonInfoString(buttonConfiguration === null || buttonConfiguration === void 0 ? void 0 : buttonConfiguration.closeButton)}`;
|
|
297
|
+
key += `_buttonConfiguration.muteButton:${generateButtonInfoString(buttonConfiguration === null || buttonConfiguration === void 0 ? void 0 : buttonConfiguration.muteButton)}`;
|
|
298
|
+
key += `_buttonConfiguration.unmuteButton:${generateButtonInfoString(buttonConfiguration === null || buttonConfiguration === void 0 ? void 0 : buttonConfiguration.unmuteButton)}`;
|
|
299
|
+
key += `_buttonConfiguration.playButton:${generateButtonInfoString(buttonConfiguration === null || buttonConfiguration === void 0 ? void 0 : buttonConfiguration.playButton)}`;
|
|
300
|
+
key += `_buttonConfiguration.pauseButton:${generateButtonInfoString(buttonConfiguration === null || buttonConfiguration === void 0 ? void 0 : buttonConfiguration.pauseButton)}`;
|
|
232
301
|
key += `_showVideoDetailTitle:${showVideoDetailTitle}`;
|
|
233
302
|
key += `_requiresAds:${requiresAds}`;
|
|
234
303
|
key += `_adsFetchTimeout:${adsFetchTimeout}`;
|
|
@@ -351,6 +420,8 @@ const StoryBlock = (props, forwardedRef) => {
|
|
|
351
420
|
storyBlockConfiguration: storyBlockConfiguration,
|
|
352
421
|
enablePictureInPicture: undefined,
|
|
353
422
|
onStoryBlockLoadFinished: handleStoryBlockLoadFinished,
|
|
423
|
+
onStoryBlockDidStartPictureInPicture: handleStoryBlockDidStartPictureInPicture,
|
|
424
|
+
onStoryBlockDidStopPictureInPicture: handleStoryBlockDidStopPictureInPicture,
|
|
354
425
|
onStoryBlockFullScreenStateChanged: handleStoryBlockFullScreenStateChanged
|
|
355
426
|
}));
|
|
356
427
|
};
|