react-native-firework-sdk 2.0.0 → 2.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FireworkVideoUI.xcframework/Info.plist +40 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +280 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +18 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Info.plist +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.abi.json +1327 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.private.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64/FireworkVideoUI.framework/Modules/module.modulemap +11 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/FireworkVideoUI +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI-Swift.h +556 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Headers/FireworkVideoUI.h +18 -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/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.abi.json +1327 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.abi.json +1327 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/FireworkVideoUI.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +41 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/Modules/module.modulemap +11 -0
- package/FireworkVideoUI.xcframework/ios-arm64_x86_64-simulator/FireworkVideoUI.framework/_CodeSignature/CodeResources +245 -0
- package/README.md +1 -1
- package/android/build.gradle +5 -4
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/FWVideoFeed.kt +6 -0
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/StoryBlockFragment.kt +129 -0
- package/android/src/main/java/com/fireworksdk/bridge/components/videofeed/StoryBlockFrameLayout.kt +90 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWAdBadgeConfigModelDeserializer.kt +3 -3
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +5 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWFontInfoModelDeserializer.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfiguration.kt +18 -5
- package/android/src/main/java/com/fireworksdk/bridge/models/FWProductInfoViewConfigurationDeserializer.kt +36 -8
- package/android/src/main/java/com/fireworksdk/bridge/models/FWSDKInitOptionsModelDeserializer.kt +3 -3
- package/android/src/main/java/com/fireworksdk/bridge/models/FWShoppingCtaResult.kt +17 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWShoppingCtaResultDeserializer.kt +33 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedConfigModelDeserializer.kt +14 -12
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedPropsModelDeserializer.kt +11 -7
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoFeedSource.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlaybackDetails.kt +8 -8
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModel.kt +1 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoPlayerConfigModelDeserializer.kt +19 -12
- package/android/src/main/java/com/fireworksdk/bridge/models/FWVideoShoppingProductDeserializer.kt +11 -11
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +131 -45
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +11 -3
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/models/FWVideoShoppingInterface.kt +2 -2
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWLiveStreamModule.kt +45 -4
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWNavigatorModule.kt +9 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +83 -50
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +112 -36
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +16 -6
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +26 -32
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +10 -0
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWLanguageUtil.kt +48 -16
- package/android/src/main/res/layout/fw_bridge_story_block.xml +24 -0
- package/ios/Components/StoryBlock.swift +32 -2
- package/ios/Components/StoryBlockManager.m +33 -0
- package/ios/Components/StoryBlockManager.swift +4 -0
- package/ios/Components/VideoFeed.swift +16 -32
- package/ios/Components/VideoFeedManager.m +12 -6
- package/ios/Components/VideoFeedManager.swift +4 -0
- package/ios/Components/VideoPlayerConfiguration.swift +1 -0
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +276 -212
- package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.docc/FireworkVideoUI.md +13 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/FireworkVideoUI.h +18 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/AppLanguageManager.swift +147 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/Bundle+AppLanguage.swift +58 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/NumberFormatter+AppLanguage.swift +25 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/Foundation/URLSession+AppLanguage.swift +69 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIImageView+AppLanguage.swift +91 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UILabel+AppLanguage.swift +98 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextField+AppLanguage.swift +97 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UITextView+AppLanguage.swift +97 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIView+AppLanguage.swift +38 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIViewController+AppLanguage.swift +46 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/Extensions/UIKit/UIWindow+AppLanguage.swift +26 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/AppLanguage/LanguageUtil.swift +43 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/Foundation/NSObject+LayoutFlip.swift +42 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/CALayer+LayoutFlip.swift +160 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UILabel+LayoutFlip.swift +35 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/Extensions/UIKit/UIView+LayoutFlip.swift +199 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/LayoutFlip/LayoutFlipManager.swift +59 -0
- package/ios/{Utils/DispatchQueue+FWOnce.swift → FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/DispatchQueue+Once.swift} +5 -5
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/Foundation/String+Base64.swift +18 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Extensions/UIKit/UIView+UIHierarchy.swift +46 -0
- package/ios/FireworkVideoUI/FireworkVideoUI/Sources/Utils/Swizzle.swift +37 -0
- package/ios/FireworkVideoUI/FireworkVideoUI.xcodeproj/project.pbxproj +766 -0
- package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/FireworkVideoUI/FireworkVideoUI.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/FireworkVideoUI/FireworkVideoUITests/FireworkVideoUITests.swift +37 -0
- package/ios/FireworkVideoUI/Podfile +15 -0
- package/ios/FireworkVideoUI/Podfile.lock +16 -0
- package/ios/Models/NativeToRN/FireworkEventName.swift +7 -1
- package/ios/Models/NativeToRN/FireworkSDK+Json.swift +5 -1
- package/ios/Models/RNToNative/RCTConvert+Shopping.swift +21 -0
- package/ios/Models/RNToNative/RCTConvert+StoryBlock.swift +2 -1
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +29 -1
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +13 -101
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +34 -16
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +48 -2
- package/ios/Modules/FireworkSDKModule/SDKInitOptions.swift +0 -1
- package/ios/Modules/LiveStream/LiveStreamModule.swift +1 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +7 -2
- package/ios/Modules/Shopping/ShoppingCTAResult.swift +16 -0
- package/ios/Modules/Shopping/ShoppingModule.m +2 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +92 -34
- package/ios/Support/MultiHostStreaming/FWMultiHostStreaming.podspec +22 -0
- package/ios/Support/MultiHostStreaming/Sources/MultiHostStreamingSDK.swift +17 -0
- package/ios/Utils/{UINavigationController+FWSwizzle.swift → Extensions/Swizzle/UINavigationController+FWSwizzle.swift} +9 -8
- package/ios/Utils/FWSwizzleLoader.m +6 -1
- package/ios/Utils/FWSwizzleLoader.swift +13 -0
- package/ios/react_native_firework_sdk.h +1 -0
- package/ios/scripts/react_native_firework_sdk_pods.rb +27 -0
- package/lib/commonjs/FireworkSDK.js +55 -15
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/LiveStream.js +2 -2
- package/lib/commonjs/LiveStream.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +21 -38
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +193 -128
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +17 -5
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +3 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/ShoppingCTAResult.js +2 -0
- package/lib/commonjs/models/VideoPlaybackEventName.js +3 -0
- package/lib/commonjs/models/VideoPlaybackEventName.js.map +1 -1
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +54 -15
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/LiveStream.js +2 -2
- package/lib/module/LiveStream.js.map +1 -1
- package/lib/module/VideoShopping.js +21 -40
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +183 -133
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +16 -5
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +3 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/ShoppingCTAResult.js +2 -0
- package/lib/module/models/VideoPlaybackEventName.js +3 -0
- package/lib/module/models/VideoPlaybackEventName.js.map +1 -1
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +15 -8
- package/lib/typescript/LiveStream.d.ts +2 -2
- package/lib/typescript/VideoShopping.d.ts +10 -12
- package/lib/typescript/components/StoryBlock.d.ts +25 -24
- package/lib/typescript/components/VideoFeed.d.ts +7 -0
- package/lib/typescript/index.d.ts +6 -6
- package/lib/typescript/models/FWEventName.d.ts +3 -0
- package/lib/typescript/models/FWEvents.d.ts +14 -1
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +12 -8
- package/lib/typescript/models/SDKInitOptions.d.ts +6 -1
- package/lib/typescript/models/ShoppingCTAResult.d.ts +11 -0
- package/lib/typescript/models/StoryBlockSource.d.ts +1 -1
- package/lib/typescript/models/VideoFeedSource.d.ts +1 -1
- package/lib/typescript/models/VideoPlaybackDetails.d.ts +16 -0
- package/lib/typescript/models/VideoPlaybackEventName.d.ts +13 -1
- package/lib/typescript/models/VideoPlayerConfiguration.d.ts +4 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -2
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -1
- package/package.json +8 -3
- package/react-native-firework-sdk.podspec +31 -24
- package/src/FireworkSDK.ts +54 -15
- package/src/LiveStream.ts +2 -2
- package/src/VideoShopping.ts +41 -54
- package/src/components/StoryBlock.tsx +210 -98
- package/src/components/VideoFeed.tsx +23 -4
- package/src/index.ts +15 -9
- package/src/models/FWEventName.ts +3 -0
- package/src/models/FWEvents.ts +14 -1
- package/src/models/ProductInfoViewConfiguration.ts +13 -8
- package/src/models/SDKInitOptions.ts +6 -1
- package/src/models/ShoppingCTAResult.ts +11 -0
- package/src/models/StoryBlockSource.ts +2 -1
- package/src/models/VideoFeedSource.ts +2 -1
- package/src/models/VideoPlaybackDetails.ts +16 -0
- package/src/models/VideoPlaybackEventName.ts +13 -1
- package/src/models/VideoPlayerConfiguration.ts +4 -0
- package/src/modules/FireworkSDKModule.ts +1 -2
- package/src/modules/ShoppingModule.ts +5 -5
- package/android/src/main/java/com/fireworksdk/bridge/constants/FWCommandConstant.kt +0 -6
- package/ios/Utils/FWSwizzleUtil.swift +0 -29
- package/ios/Utils/UIView+ParentViewController.swift +0 -21
- package/lib/commonjs/models/AddToCartResult.js +0 -2
- package/lib/module/models/AddToCartResult.js +0 -2
- package/lib/typescript/models/AddToCartResult.d.ts +0 -10
- package/src/models/AddToCartResult.ts +0 -10
- /package/ios/Utils/{String+Color.swift → Extensions/String+Color.swift} +0 -0
- /package/ios/Utils/{UIView+Constraints.swift → Extensions/UIView+Constraints.swift} +0 -0
- /package/ios/Utils/{UIViewController+AttachChild.swift → Extensions/UIViewController+AttachChild.swift} +0 -0
- /package/lib/commonjs/models/{AddToCartResult.js.map → ShoppingCTAResult.js.map} +0 -0
- /package/lib/module/models/{AddToCartResult.js.map → ShoppingCTAResult.js.map} +0 -0
|
@@ -26,10 +26,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
26
26
|
*/
|
|
27
27
|
class VideoShopping {
|
|
28
28
|
/**
|
|
29
|
-
* This callback is triggered when the user clicks the "Add to cart" button.
|
|
30
|
-
*
|
|
31
|
-
* The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.
|
|
32
|
-
* 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.
|
|
29
|
+
* This callback is triggered when the user clicks the "Add to cart" or "Shop now" button.
|
|
30
|
+
* The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.
|
|
33
31
|
*/
|
|
34
32
|
|
|
35
33
|
/**
|
|
@@ -65,8 +63,8 @@ class VideoShopping {
|
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
/**
|
|
68
|
-
* The
|
|
69
|
-
*
|
|
66
|
+
* The configuration of product info view.
|
|
67
|
+
* Please refer to {@link ProductInfoViewConfiguration} for more details.
|
|
70
68
|
*/
|
|
71
69
|
get productInfoViewConfiguration() {
|
|
72
70
|
return this._productInfoViewConfiguration;
|
|
@@ -75,14 +73,12 @@ class VideoShopping {
|
|
|
75
73
|
set productInfoViewConfiguration(value) {
|
|
76
74
|
this._productInfoViewConfiguration = value;
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
_ShoppingModule.default.setProductInfoViewConfiguration(value !== null && value !== void 0 ? value : {});
|
|
80
|
-
}
|
|
76
|
+
_ShoppingModule.default.setProductInfoViewConfiguration(value !== null && value !== void 0 ? value : {});
|
|
81
77
|
}
|
|
82
78
|
|
|
83
79
|
/**
|
|
84
80
|
* This callback is triggered when the user clicks
|
|
85
|
-
* the link button next to Add to cart button.
|
|
81
|
+
* the link button next to Add to cart button.
|
|
86
82
|
*
|
|
87
83
|
* The host app can customize the click event processing logic of
|
|
88
84
|
* the link button by setting the callback.
|
|
@@ -94,9 +90,7 @@ class VideoShopping {
|
|
|
94
90
|
set onCustomClickLinkButton(value) {
|
|
95
91
|
this._onCustomClickLinkButton = value;
|
|
96
92
|
|
|
97
|
-
|
|
98
|
-
_ShoppingModule.default.setCustomClickLinkButtonEnabled(!!value);
|
|
99
|
-
}
|
|
93
|
+
_ShoppingModule.default.setCustomClickLinkButtonEnabled(!!value);
|
|
100
94
|
}
|
|
101
95
|
|
|
102
96
|
get eventEmitter() {
|
|
@@ -114,7 +108,7 @@ class VideoShopping {
|
|
|
114
108
|
}
|
|
115
109
|
|
|
116
110
|
constructor() {
|
|
117
|
-
_defineProperty(this, "
|
|
111
|
+
_defineProperty(this, "onShoppingCTA", void 0);
|
|
118
112
|
|
|
119
113
|
_defineProperty(this, "_onCustomClickCartIcon", void 0);
|
|
120
114
|
|
|
@@ -126,10 +120,10 @@ class VideoShopping {
|
|
|
126
120
|
|
|
127
121
|
_defineProperty(this, "_onCustomClickLinkButton", void 0);
|
|
128
122
|
|
|
129
|
-
this.eventEmitter.addListener(_FWEventName.FWEventName.
|
|
130
|
-
_FWLoggerUtil.default.log(`Receive
|
|
123
|
+
this.eventEmitter.addListener(_FWEventName.FWEventName.ShoppingCTAButtonClick, event => {
|
|
124
|
+
_FWLoggerUtil.default.log(`Receive ShoppingCTA event productId: ${event === null || event === void 0 ? void 0 : event.productId} unitId: ${event === null || event === void 0 ? void 0 : event.unitId} url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
131
125
|
|
|
132
|
-
this.
|
|
126
|
+
this.handleShoppingCTAEvent(event);
|
|
133
127
|
});
|
|
134
128
|
this.eventEmitter.addListener(_FWEventName.FWEventName.ClickCartIcon, () => {
|
|
135
129
|
_FWLoggerUtil.default.log('Receive ClickCartIcon event');
|
|
@@ -142,14 +136,11 @@ class VideoShopping {
|
|
|
142
136
|
this.handleUpdateProductDetailsEvent(event);
|
|
143
137
|
});
|
|
144
138
|
this.eventEmitter.addListener(_FWEventName.FWEventName.LogMessage, () => {});
|
|
139
|
+
this.eventEmitter.addListener(_FWEventName.FWEventName.CustomLinkButtonClick, event => {
|
|
140
|
+
_FWLoggerUtil.default.log(`Receive CustomLinkButtonClick event url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
145
141
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
_FWLoggerUtil.default.log(`Receive CustomLinkButtonClick event url: ${event === null || event === void 0 ? void 0 : event.url}`);
|
|
149
|
-
|
|
150
|
-
this.handleCustomLinkButtonClickEvent(event);
|
|
151
|
-
});
|
|
152
|
-
}
|
|
142
|
+
this.handleCustomLinkButtonClickEvent(event);
|
|
143
|
+
});
|
|
153
144
|
}
|
|
154
145
|
/**
|
|
155
146
|
*
|
|
@@ -165,28 +156,20 @@ class VideoShopping {
|
|
|
165
156
|
_ShoppingModule.default.setCartItemCount(count);
|
|
166
157
|
}
|
|
167
158
|
|
|
168
|
-
async
|
|
159
|
+
async handleShoppingCTAEvent(event) {
|
|
169
160
|
const callbackId = event.callbackId;
|
|
170
161
|
delete event.callbackId;
|
|
171
162
|
|
|
172
|
-
if (this.
|
|
173
|
-
const result = await this.
|
|
163
|
+
if (this.onShoppingCTA) {
|
|
164
|
+
const result = await this.onShoppingCTA(event);
|
|
174
165
|
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
_ShoppingModule.default.updateAddToCartStatus(result.res, result.tips, callbackId);
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
if (callbackId) {
|
|
181
|
-
if (_reactNative.Platform.OS === 'ios') {
|
|
182
|
-
_ShoppingModule.default.clearCallbackId(callbackId, _FWEventName.FWEventName.AddToCart);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
166
|
+
if (callbackId) {
|
|
167
|
+
_ShoppingModule.default.updateShoppingCTAResult(result, callbackId);
|
|
185
168
|
}
|
|
186
169
|
} else {
|
|
187
170
|
if (callbackId) {
|
|
188
171
|
if (_reactNative.Platform.OS === 'ios') {
|
|
189
|
-
_ShoppingModule.default.clearCallbackId(callbackId, _FWEventName.FWEventName.
|
|
172
|
+
_ShoppingModule.default.clearCallbackId(callbackId, _FWEventName.FWEventName.ShoppingCTAButtonClick);
|
|
190
173
|
}
|
|
191
174
|
}
|
|
192
175
|
}
|
|
@@ -1 +1 @@
|
|
|
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","LogMessage","CustomLinkButtonClick","url","handleCustomLinkButtonClickEvent","setCartItemCount","count","callbackId","onAddToCart","result","updateAddToCartStatus","res","tips","clearCallbackId","onUpdateProductDetails","productList","map","product","length","updateVideoProducts"],"mappings":";;;;;;;AAAA;;AAGA;;AAQA;;AAGA;;;;;;;;;;AAgBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;AACA;;AAG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AACgB,WAAW,IAAI,EAAhB,EAAoBC,GAApB,CAChBC,OAAD;AAAA;;AAAA,qCAAaA,OAAO,CAACxB,SAArB,mEAAkC,EAAlC;AAAA,OADiB,CAAnB;;AAIAR,4BAAaC,GAAb,CACG,+DAA8Da,UAAW,uBACxE,CAACgB,WAAW,IAAI,EAAhB,EAAoBG,MACrB,EAHH;;AAMA,UAAIH,WAAJ,EAAiB;AACf,YAAIR,UAAJ,EAAgB;AACdpC,kCAAegD,mBAAf,CAAmCJ,WAAnC,EAAgDR,UAAhD;AACD;AACF,OAJD,MAIO;AACL,YAAIA,UAAJ,EAAgB;AACd,cAAItC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,oCAAe0C,eAAf,CACEN,UADF,EAEEjB,yBAAYQ,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACLb,4BAAaC,GAAb,CAAiB,6CAAjB;;AACA,UAAIqB,UAAJ,EAAgB;AACd,YAAItC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzBC,kCAAe0C,eAAf,CACEN,UADF,EAEEjB,yBAAYQ,oBAFd;AAID;AACF;AACF;AACF;;AAE6C,QAAhCM,gCAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAKb,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6Ba,KAA7B;AACD;AACF;;AApPiB;;gBAAd3B,a;;eAuPSA,a","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport type AddToCartResult from './models/AddToCartResult';\nimport { FWEventName } from './models/FWEventName';\nimport type {\n AddToCartEvent,\n CustomClickLinkButtonEvent,\n UpdateProductDetailsEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\n\nexport type AddToCartCallback = (\n event: AddToCartEvent\n) => Promise<AddToCartResult | undefined | null>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type CustomClickLinkButtonCallback = (\n event: CustomClickLinkButtonEvent\n) => Promise<void>;\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" button.\n *\n * The host apps can return an AddToCartResult object to tell FireworkSDK the result of adding to cart.\n * If the host apps want to customize the processing logic of clicking \"Add to cart\" button, they could return null or undefined in the callback.\n */\n public onAddToCart?: AddToCartCallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the click event processing logic of\n * the shopping cart icon by setting the callback.\n */\n public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {\n return this._onCustomClickCartIcon;\n }\n public set onCustomClickCartIcon(\n value: CustomClickCartIconCallback | undefined\n ) {\n this._onCustomClickCartIcon = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomClickCartIconEnabled(!!value);\n }\n }\n private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product list to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * Defaults to true.\n * You can hide the cart icon by setting this property to false.\n */\n public get cartIconVisible(): boolean {\n return this._cartIconVisible;\n }\n public set cartIconVisible(value: boolean) {\n this._cartIconVisible = value;\n ShoppingModule.setCartIconVisible(value);\n }\n private _cartIconVisible: boolean = true;\n\n /**\n * The host app can use this property to configure \"Add to cart\" button style\n * and hide the link button next to \"Add to cart\" button. Only supported on iOS.\n */\n public get productInfoViewConfiguration():\n | ProductInfoViewConfiguration\n | undefined {\n return this._productInfoViewConfiguration;\n }\n\n public set productInfoViewConfiguration(\n value: ProductInfoViewConfiguration | undefined\n ) {\n this._productInfoViewConfiguration = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n }\n }\n\n private _productInfoViewConfiguration?:\n | ProductInfoViewConfiguration\n | undefined;\n\n /**\n * This callback is triggered when the user clicks\n * the link button next to Add to cart button. Only supported on Android.\n *\n * The host app can customize the click event processing logic of\n * the link button by setting the callback.\n */\n public get onCustomClickLinkButton():\n | CustomClickLinkButtonCallback\n | undefined {\n return this._onCustomClickLinkButton;\n }\n public set onCustomClickLinkButton(\n value: CustomClickLinkButtonCallback | undefined\n ) {\n this._onCustomClickLinkButton = value;\n if (Platform.OS === 'android') {\n ShoppingModule.setCustomClickLinkButtonEnabled(!!value);\n }\n }\n private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(FWEventName.AddToCart, (event) => {\n FWLoggerUtil.log(\n `Receive AddToCart event productId: ${event?.productId} unitId: ${event?.unitId}`\n );\n this.handleAddToCartEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, () => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent();\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event?.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n\n if (Platform.OS === 'android') {\n this.eventEmitter.addListener(\n FWEventName.CustomLinkButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive CustomLinkButtonClick event url: ${event?.url}`\n );\n this.handleCustomLinkButtonClickEvent(event);\n }\n );\n }\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart.\n * The count should be greater than or equal to 0.\n * We just use count to show or hide red indicator on the cart icon.\n * If cound > 0, we will show the red indicator on the cart icon.\n * Otherwise, we will hide the red indicator on the cart icon.\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleAddToCartEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onAddToCart) {\n const result = await this.onAddToCart(event as AddToCartEvent);\n if (result) {\n if (callbackId) {\n ShoppingModule.updateAddToCartStatus(\n result.res,\n result.tips,\n callbackId\n );\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(callbackId, FWEventName.AddToCart);\n }\n }\n }\n }\n\n private async handleClickCartIconEvent() {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n }\n }\n\n private async handleUpdateProductDetailsEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
|
1
|
+
{"version":3,"sources":["VideoShopping.ts"],"names":["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","ShoppingCTAButtonClick","event","productId","unitId","url","handleShoppingCTAEvent","ClickCartIcon","handleClickCartIconEvent","UpdateProductDetails","productIds","handleUpdateProductDetailsEvent","LogMessage","CustomLinkButtonClick","handleCustomLinkButtonClickEvent","setCartItemCount","count","callbackId","onShoppingCTA","result","updateShoppingCTAResult","clearCallbackId","onUpdateProductDetails","productList","map","product","length","updateVideoProducts"],"mappings":";;;;;;;AAAA;;AAEA;;AAQA;;AAGA;;;;;;;;;;AAiBA;AACA;AACA;AACA,MAAMA,aAAN,CAAoB;AAGlB;AACF;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,EAA2B;AACzBC,8BAAeC,6BAAf,CAA6C,CAAC,CAACJ,KAA/C;AACD;AACF;;AAUD;AACF;AACA;AACA;AAC4B,MAAfK,eAAe,GAAY;AACpC,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACL,KAAD,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CAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAKb,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6Ba,KAA7B;AACD;AACF;;AAvOiB;;gBAAd3B,a;;eA0OSA,a","sourcesContent":["import { NativeEventEmitter, Platform } from 'react-native';\n\nimport { FWEventName } from './models/FWEventName';\nimport type {\n CustomClickLinkButtonEvent,\n ShoppingCTAEvent,\n UpdateProductDetailsEvent,\n} from './models/FWEvents';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport ShoppingModule, {\n ShoppingModuleEventEmitter,\n} from './modules/ShoppingModule';\nimport FWLoggerUtil from './utils/FWLoggerUtil';\nimport type ShoppingCTAResult from './models/ShoppingCTAResult';\n\nexport type ShoppingCTACallback = (\n event: ShoppingCTAEvent\n) => Promise<ShoppingCTAResult>;\n\nexport type CustomClickCartIconCallback = () => Promise<void>;\n\nexport type UpdateProductDetailsCallback = (\n event: UpdateProductDetailsEvent\n) => Promise<Product[] | undefined | null>;\n\nexport type CustomClickLinkButtonCallback = (\n event: CustomClickLinkButtonEvent\n) => Promise<void>;\n\n/**\n * The entry class of video shopping.\n */\nclass VideoShopping {\n private static _instance?: VideoShopping;\n\n /**\n * This callback is triggered when the user clicks the \"Add to cart\" or \"Shop now\" button.\n * The host app can return a ShoppingCTAResult object to tell SDK how to handle the result.\n */\n public onShoppingCTA?: ShoppingCTACallback;\n\n /**\n * This callback is triggered when the user clicks the shopping cart icon.\n *\n * The host app can customize the click event processing logic of\n * the shopping cart icon by setting the callback.\n */\n public get onCustomClickCartIcon(): CustomClickCartIconCallback | undefined {\n return this._onCustomClickCartIcon;\n }\n public set onCustomClickCartIcon(\n value: CustomClickCartIconCallback | undefined\n ) {\n this._onCustomClickCartIcon = value;\n if (Platform.OS === 'ios') {\n ShoppingModule.setCustomClickCartIconEnabled(!!value);\n }\n }\n private _onCustomClickCartIcon?: CustomClickCartIconCallback | undefined;\n\n /**\n * This callback is triggered when the video will be shown.\n *\n * The host app can return a Product list to update the latest product information.\n */\n public onUpdateProductDetails?: UpdateProductDetailsCallback;\n\n /**\n * Defaults to true.\n * You can hide the cart icon by setting this property to false.\n */\n public get cartIconVisible(): boolean {\n return this._cartIconVisible;\n }\n public set cartIconVisible(value: boolean) {\n this._cartIconVisible = value;\n ShoppingModule.setCartIconVisible(value);\n }\n private _cartIconVisible: boolean = true;\n\n /**\n * The configuration of product info view.\n * Please refer to {@link ProductInfoViewConfiguration} for more details.\n */\n public get productInfoViewConfiguration():\n | ProductInfoViewConfiguration\n | undefined {\n return this._productInfoViewConfiguration;\n }\n\n public set productInfoViewConfiguration(\n value: ProductInfoViewConfiguration | undefined\n ) {\n this._productInfoViewConfiguration = value;\n ShoppingModule.setProductInfoViewConfiguration(value ?? {});\n }\n\n private _productInfoViewConfiguration?:\n | ProductInfoViewConfiguration\n | undefined;\n\n /**\n * This callback is triggered when the user clicks\n * the link button next to Add to cart button.\n *\n * The host app can customize the click event processing logic of\n * the link button by setting the callback.\n */\n public get onCustomClickLinkButton():\n | CustomClickLinkButtonCallback\n | undefined {\n return this._onCustomClickLinkButton;\n }\n public set onCustomClickLinkButton(\n value: CustomClickLinkButtonCallback | undefined\n ) {\n this._onCustomClickLinkButton = value;\n ShoppingModule.setCustomClickLinkButtonEnabled(!!value);\n }\n private _onCustomClickLinkButton?: CustomClickLinkButtonCallback | undefined;\n\n private get eventEmitter(): NativeEventEmitter {\n return ShoppingModuleEventEmitter;\n }\n\n public static getInstance() {\n FWLoggerUtil.log('VideoShopping constructor');\n if (!VideoShopping._instance) {\n VideoShopping._instance = new VideoShopping();\n }\n\n return VideoShopping._instance!;\n }\n\n private constructor() {\n this.eventEmitter.addListener(\n FWEventName.ShoppingCTAButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive ShoppingCTA event productId: ${event?.productId} unitId: ${event?.unitId} url: ${event?.url}`\n );\n this.handleShoppingCTAEvent(event);\n }\n );\n\n this.eventEmitter.addListener(FWEventName.ClickCartIcon, () => {\n FWLoggerUtil.log('Receive ClickCartIcon event');\n this.handleClickCartIconEvent();\n });\n\n this.eventEmitter.addListener(FWEventName.UpdateProductDetails, (event) => {\n FWLoggerUtil.log(\n `Receive UpdateProductDetails event productIds: ${event?.productIds}`\n );\n this.handleUpdateProductDetailsEvent(event);\n });\n\n this.eventEmitter.addListener(FWEventName.LogMessage, () => {});\n\n this.eventEmitter.addListener(\n FWEventName.CustomLinkButtonClick,\n (event) => {\n FWLoggerUtil.log(\n `Receive CustomLinkButtonClick event url: ${event?.url}`\n );\n this.handleCustomLinkButtonClickEvent(event);\n }\n );\n }\n\n /**\n *\n * @param {number} count The number of items in the host app cart.\n * The count should be greater than or equal to 0.\n * We just use count to show or hide red indicator on the cart icon.\n * If cound > 0, we will show the red indicator on the cart icon.\n * Otherwise, we will hide the red indicator on the cart icon.\n */\n public setCartItemCount(count: number) {\n ShoppingModule.setCartItemCount(count);\n }\n\n private async handleShoppingCTAEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n\n if (this.onShoppingCTA) {\n const result = await this.onShoppingCTA(event as ShoppingCTAEvent);\n if (callbackId) {\n ShoppingModule.updateShoppingCTAResult(result, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.ShoppingCTAButtonClick\n );\n }\n }\n }\n }\n\n private async handleClickCartIconEvent() {\n if (this.onCustomClickCartIcon) {\n this.onCustomClickCartIcon();\n }\n }\n\n private async handleUpdateProductDetailsEvent(event: any) {\n const callbackId = event.callbackId;\n delete event.callbackId;\n if (this.onUpdateProductDetails) {\n FWLoggerUtil.log(\n `Call onUpdateProductDetails callback productIds: ${event.productIds} callbackId: ${callbackId}`\n );\n const productList = await this.onUpdateProductDetails(\n event as UpdateProductDetailsEvent\n );\n\n const productIds = (productList || []).map(\n (product) => product.productId ?? ''\n );\n\n FWLoggerUtil.log(\n `Get result from onUpdateProductDetails callback productIds: ${productIds} productListLength: ${\n (productList || []).length\n }`\n );\n\n if (productList) {\n if (callbackId) {\n ShoppingModule.updateVideoProducts(productList, callbackId);\n }\n } else {\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n } else {\n FWLoggerUtil.log('onUpdateProductDetails callback is not set.');\n if (callbackId) {\n if (Platform.OS === 'ios') {\n ShoppingModule.clearCallbackId(\n callbackId,\n FWEventName.UpdateProductDetails\n );\n }\n }\n }\n }\n\n private async handleCustomLinkButtonClickEvent(\n event: CustomClickLinkButtonEvent\n ) {\n if (this.onCustomClickLinkButton) {\n this.onCustomClickLinkButton(event);\n }\n }\n}\n\nexport default VideoShopping;\n"]}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
|
|
@@ -21,162 +21,125 @@ var _FWStoryBlock = _interopRequireDefault(require("./FWStoryBlock"));
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
|
|
24
|
-
function
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
|
|
26
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
27
|
|
|
26
|
-
function
|
|
28
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
27
29
|
|
|
28
30
|
const NativeComponentName = 'FWStoryBlock';
|
|
29
31
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
class StoryBlock extends _react.default.Component {
|
|
44
|
-
constructor() {
|
|
45
|
-
super(...arguments);
|
|
46
|
-
|
|
47
|
-
_defineProperty(this, "_nativeComponentRef", /*#__PURE__*/_react.default.createRef());
|
|
48
|
-
|
|
49
|
-
_defineProperty(this, "_subscriptions", []);
|
|
50
|
-
|
|
51
|
-
_defineProperty(this, "_onStoryBlockLoadFinished", event => {
|
|
52
|
-
_FWLoggerUtil.default.log(`StoryBlock _onStoryBlockLoadFinished ${event.nativeEvent.name}`);
|
|
53
|
-
|
|
54
|
-
const {
|
|
55
|
-
onStoryBlockLoadFinished
|
|
56
|
-
} = this.props;
|
|
57
|
-
const {
|
|
58
|
-
name,
|
|
59
|
-
reason
|
|
60
|
-
} = event.nativeEvent;
|
|
61
|
-
|
|
62
|
-
if (onStoryBlockLoadFinished) {
|
|
63
|
-
if (name) {
|
|
64
|
-
if (reason) {
|
|
65
|
-
onStoryBlockLoadFinished({
|
|
66
|
-
name,
|
|
67
|
-
reason
|
|
68
|
-
});
|
|
69
|
-
} else {
|
|
70
|
-
onStoryBlockLoadFinished({
|
|
71
|
-
name
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
75
|
-
onStoryBlockLoadFinished();
|
|
76
|
-
}
|
|
32
|
+
const StoryBlock = (props, forwardedRef) => {
|
|
33
|
+
const nativeComponentRef = (0, _react.useRef)(null);
|
|
34
|
+
const [isFullscreenState, setIsFullscreenState] = (0, _react.useState)(false);
|
|
35
|
+
const [, forceUpdate] = (0, _react.useReducer)(x => x + 1, 0);
|
|
36
|
+
(0, _react.useImperativeHandle)(forwardedRef, () => {
|
|
37
|
+
const sendCommand = command => {
|
|
38
|
+
const nativeNodeHandle = (0, _reactNative.findNodeHandle)(nativeComponentRef.current);
|
|
39
|
+
|
|
40
|
+
let commandId = _reactNative.UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
|
|
41
|
+
|
|
42
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
43
|
+
commandId = commandId.toString();
|
|
77
44
|
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
45
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
46
|
+
_reactNative.UIManager.dispatchViewManagerCommand((0, _reactNative.findNodeHandle)(nativeNodeHandle), commandId, []);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
play: () => {
|
|
51
|
+
sendCommand('play');
|
|
52
|
+
},
|
|
53
|
+
pause: () => {
|
|
54
|
+
sendCommand('pause');
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, []);
|
|
58
|
+
(0, _react.useEffect)(() => {
|
|
85
59
|
const subscriptionOfShareBaseURLUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.ShareBaseURLUpdated, () => {
|
|
86
|
-
|
|
87
|
-
});
|
|
60
|
+
_FWLoggerUtil.default.log('Receive FWEventName.ShareBaseURLUpdated');
|
|
88
61
|
|
|
89
|
-
|
|
62
|
+
forceUpdate();
|
|
63
|
+
});
|
|
90
64
|
|
|
91
65
|
const subscriptionOfAdBadgeConfigurationUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.AdBadgeConfigurationUpdated, () => {
|
|
92
|
-
|
|
93
|
-
});
|
|
66
|
+
_FWLoggerUtil.default.log('Receive FWEventName.AdBadgeConfigurationUpdated');
|
|
94
67
|
|
|
95
|
-
|
|
68
|
+
forceUpdate();
|
|
69
|
+
});
|
|
96
70
|
|
|
97
71
|
const subscriptionOfVideoLaunchBehaviorUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.VideoLaunchBehaviorUpdated, () => {
|
|
98
72
|
_FWLoggerUtil.default.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
|
|
99
73
|
|
|
100
|
-
|
|
74
|
+
forceUpdate();
|
|
101
75
|
});
|
|
102
76
|
|
|
103
|
-
|
|
77
|
+
const subscriptionOfAppLanguageUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.AppLanguageUpdated, () => {
|
|
78
|
+
_FWLoggerUtil.default.log('Receive FWEventName.AppLanguageUpdated');
|
|
79
|
+
|
|
80
|
+
forceUpdate();
|
|
81
|
+
});
|
|
104
82
|
|
|
105
83
|
if (_reactNative.Platform.OS === 'android') {
|
|
106
|
-
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
const viewId = (0, _reactNative.findNodeHandle)(nativeComponentRef.current);
|
|
107
86
|
|
|
108
|
-
|
|
87
|
+
_FWLoggerUtil.default.log(`StoryBlock createFragment viewId: ${viewId}`);
|
|
109
88
|
|
|
110
|
-
|
|
89
|
+
_reactNative.UIManager.dispatchViewManagerCommand(viewId, _reactNative.UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
|
|
90
|
+
}, 500);
|
|
111
91
|
}
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* @ignore
|
|
115
|
-
*/
|
|
116
92
|
|
|
93
|
+
return () => {
|
|
94
|
+
subscriptionOfShareBaseURLUpdated.remove();
|
|
95
|
+
subscriptionOfAdBadgeConfigurationUpdated.remove();
|
|
96
|
+
subscriptionOfVideoLaunchBehaviorUpdated.remove();
|
|
97
|
+
subscriptionOfAppLanguageUpdated.remove();
|
|
98
|
+
};
|
|
99
|
+
}, []);
|
|
117
100
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
value.remove();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
this._subscriptions = [];
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* @ignore
|
|
127
|
-
*/
|
|
128
|
-
|
|
101
|
+
const handleStoryBlockLoadFinished = event => {
|
|
102
|
+
_FWLoggerUtil.default.log(`StoryBlock handleStoryBlockLoadFinished ${event.nativeEvent.name}`);
|
|
129
103
|
|
|
130
|
-
render() {
|
|
131
104
|
const {
|
|
132
|
-
|
|
133
|
-
} =
|
|
134
|
-
return /*#__PURE__*/_react.default.createElement(_FWStoryBlock.default, _extends({
|
|
135
|
-
ref: this._nativeComponentRef,
|
|
136
|
-
key: this._generateKey()
|
|
137
|
-
}, this.props, {
|
|
138
|
-
onStoryBlockLoadFinished: this._onStoryBlockLoadFinished,
|
|
139
|
-
style: Object.assign({}, style, {
|
|
140
|
-
zIndex: -1
|
|
141
|
-
})
|
|
142
|
-
}));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
_generateKey() {
|
|
146
|
-
var _FireworkSDK$getInsta, _FireworkSDK$getInsta2, _adBadgeConfiguration, _adBadgeConfiguration2, _adBadgeConfiguration3, _FireworkSDK$getInsta3;
|
|
147
|
-
|
|
105
|
+
onStoryBlockLoadFinished
|
|
106
|
+
} = props;
|
|
148
107
|
const {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
108
|
+
name,
|
|
109
|
+
reason
|
|
110
|
+
} = event.nativeEvent;
|
|
111
|
+
|
|
112
|
+
if (onStoryBlockLoadFinished) {
|
|
113
|
+
if (name) {
|
|
114
|
+
if (reason) {
|
|
115
|
+
onStoryBlockLoadFinished({
|
|
116
|
+
name,
|
|
117
|
+
reason
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
onStoryBlockLoadFinished({
|
|
121
|
+
name
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
onStoryBlockLoadFinished();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
159
129
|
|
|
160
|
-
|
|
130
|
+
const handleStoryBlockFullscreenStateChanged = event => {
|
|
131
|
+
_FWLoggerUtil.default.log(`StoryBlock handleStoryBlockFullscreenStateChanged ${event.nativeEvent.isFullScreen}`);
|
|
161
132
|
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
key += `_adBadgeTextType:${adBadgeTextType}`;
|
|
168
|
-
key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;
|
|
169
|
-
key += `_textColorOfAdBadge:${textColorOfAdBadge}`;
|
|
170
|
-
key += `_dynamicContentParameters:${dynamicContentParametersString}`;
|
|
171
|
-
key += `_enablePictureInPicture:${enablePictureInPicture}`;
|
|
172
|
-
key += `_videoLaunchBehavior:${videoLaunchBehavior}`;
|
|
173
|
-
return key;
|
|
174
|
-
}
|
|
133
|
+
const {
|
|
134
|
+
isFullScreen
|
|
135
|
+
} = event.nativeEvent;
|
|
136
|
+
setIsFullscreenState(isFullScreen);
|
|
137
|
+
};
|
|
175
138
|
|
|
176
|
-
|
|
139
|
+
const generateDynamicContentParametersString = () => {
|
|
177
140
|
const {
|
|
178
141
|
dynamicContentParameters
|
|
179
|
-
} =
|
|
142
|
+
} = props;
|
|
180
143
|
|
|
181
144
|
if (!dynamicContentParameters) {
|
|
182
145
|
return '';
|
|
@@ -197,10 +160,112 @@ class StoryBlock extends _react.default.Component {
|
|
|
197
160
|
}
|
|
198
161
|
|
|
199
162
|
return resultString;
|
|
200
|
-
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const generateVastAttributesString = () => {
|
|
166
|
+
var _adConfiguration$vast;
|
|
167
|
+
|
|
168
|
+
const {
|
|
169
|
+
adConfiguration
|
|
170
|
+
} = props;
|
|
171
|
+
const vastAttributes = (_adConfiguration$vast = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.vastAttributes) !== null && _adConfiguration$vast !== void 0 ? _adConfiguration$vast : '';
|
|
172
|
+
|
|
173
|
+
if (!vastAttributes) {
|
|
174
|
+
return '';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let resultString = '';
|
|
178
|
+
|
|
179
|
+
for (const attribute of vastAttributes) {
|
|
180
|
+
var _attribute$name;
|
|
181
|
+
|
|
182
|
+
if (resultString.length > 0) {
|
|
183
|
+
resultString += '_';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
resultString += `${(_attribute$name = attribute.name) !== null && _attribute$name !== void 0 ? _attribute$name : ''}:${attribute.value}`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return resultString;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const generateKey = () => {
|
|
193
|
+
var _FireworkSDK$getInsta, _FireworkSDK$getInsta2, _FireworkSDK$getInsta3, _adBadgeConfiguration, _adBadgeConfiguration2, _adBadgeConfiguration3, _FireworkSDK$getInsta4, _adConfiguration$requ, _adConfiguration$adsF;
|
|
194
|
+
|
|
195
|
+
const {
|
|
196
|
+
source,
|
|
197
|
+
channel = '',
|
|
198
|
+
playlist = '',
|
|
199
|
+
enablePictureInPicture = false,
|
|
200
|
+
adConfiguration,
|
|
201
|
+
hashtagFilterExpression = ''
|
|
202
|
+
} = props;
|
|
203
|
+
const gShareBaseURL = (_FireworkSDK$getInsta = _FireworkSDK.default.getInstance().shareBaseURL) !== null && _FireworkSDK$getInsta !== void 0 ? _FireworkSDK$getInsta : '';
|
|
204
|
+
const videoLaunchBehavior = (_FireworkSDK$getInsta2 = _FireworkSDK.default.getInstance().videoLaunchBehavior) !== null && _FireworkSDK$getInsta2 !== void 0 ? _FireworkSDK$getInsta2 : 'default';
|
|
205
|
+
const adBadgeConfiguration = (_FireworkSDK$getInsta3 = _FireworkSDK.default.getInstance().getAdBadgeConfiguration()) !== null && _FireworkSDK$getInsta3 !== void 0 ? _FireworkSDK$getInsta3 : {};
|
|
206
|
+
const adBadgeTextType = (_adBadgeConfiguration = adBadgeConfiguration.badgeTextType) !== null && _adBadgeConfiguration !== void 0 ? _adBadgeConfiguration : '';
|
|
207
|
+
const backgroundColorOfAdBadge = (_adBadgeConfiguration2 = adBadgeConfiguration.backgroundColor) !== null && _adBadgeConfiguration2 !== void 0 ? _adBadgeConfiguration2 : '';
|
|
208
|
+
const textColorOfAdBadge = (_adBadgeConfiguration3 = adBadgeConfiguration.textColor) !== null && _adBadgeConfiguration3 !== void 0 ? _adBadgeConfiguration3 : '';
|
|
209
|
+
const dynamicContentParametersString = generateDynamicContentParametersString();
|
|
210
|
+
const appLanguage = (_FireworkSDK$getInsta4 = _FireworkSDK.default.getInstance().appLanguage) !== null && _FireworkSDK$getInsta4 !== void 0 ? _FireworkSDK$getInsta4 : '';
|
|
211
|
+
const requiresAds = (_adConfiguration$requ = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.requiresAds) !== null && _adConfiguration$requ !== void 0 ? _adConfiguration$requ : false;
|
|
212
|
+
const adsFetchTimeout = (_adConfiguration$adsF = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.adsFetchTimeout) !== null && _adConfiguration$adsF !== void 0 ? _adConfiguration$adsF : 10;
|
|
213
|
+
const vastAttributesString = generateVastAttributesString();
|
|
214
|
+
let key = `source:${source}`;
|
|
215
|
+
key += `_channel:${channel}`;
|
|
216
|
+
key += `_playlist:${playlist}`;
|
|
217
|
+
key += `_gShareBaseURL:${gShareBaseURL}`;
|
|
218
|
+
key += `_videoLaunchBehavior:${videoLaunchBehavior}`;
|
|
219
|
+
key += `_adBadgeTextType:${adBadgeTextType}`;
|
|
220
|
+
key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;
|
|
221
|
+
key += `_textColorOfAdBadge:${textColorOfAdBadge}`;
|
|
222
|
+
key += `_dynamicContentParameters:${dynamicContentParametersString}`;
|
|
223
|
+
key += `_enablePictureInPicture:${enablePictureInPicture}`;
|
|
224
|
+
key += `_appLanguage:${appLanguage}`;
|
|
225
|
+
key += `_requiresAds:${requiresAds}`;
|
|
226
|
+
key += `_adsFetchTimeout:${adsFetchTimeout}`;
|
|
227
|
+
key += `_vastAttributes:${vastAttributesString}`;
|
|
228
|
+
key += `_hashtagFilterExpression:${hashtagFilterExpression}`;
|
|
229
|
+
return key;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
(0, _react.useEffect)(() => {
|
|
233
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
234
|
+
const onBackPress = () => {
|
|
235
|
+
if (isFullscreenState) {
|
|
236
|
+
_FireworkSDK.default.getInstance().navigator.popNativeContainer();
|
|
237
|
+
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return false;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const subscription = _reactNative.BackHandler.addEventListener('hardwareBackPress', onBackPress);
|
|
245
|
+
|
|
246
|
+
return () => {
|
|
247
|
+
subscription.remove();
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return;
|
|
252
|
+
}, [isFullscreenState]);
|
|
253
|
+
const {
|
|
254
|
+
style
|
|
255
|
+
} = props;
|
|
256
|
+
return /*#__PURE__*/_react.default.createElement(_FWStoryBlock.default, _extends({
|
|
257
|
+
ref: nativeComponentRef,
|
|
258
|
+
key: generateKey()
|
|
259
|
+
}, props, {
|
|
260
|
+
onStoryBlockLoadFinished: handleStoryBlockLoadFinished,
|
|
261
|
+
onStoryBlockFullScreenStateChanged: handleStoryBlockFullscreenStateChanged,
|
|
262
|
+
style: Object.assign({}, style, {
|
|
263
|
+
zIndex: -1
|
|
264
|
+
})
|
|
265
|
+
}));
|
|
266
|
+
};
|
|
201
267
|
|
|
202
|
-
|
|
268
|
+
var _default = /*#__PURE__*/(0, _react.forwardRef)(StoryBlock);
|
|
203
269
|
|
|
204
|
-
var _default = StoryBlock;
|
|
205
270
|
exports.default = _default;
|
|
206
271
|
//# sourceMappingURL=StoryBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["StoryBlock.tsx"],"names":["NativeComponentName","createFragment","viewId","Platform","OS","UIManager","dispatchViewManagerCommand","getViewManagerConfig","Commands","create","toString","StoryBlock","React","Component","createRef","event","FWLoggerUtil","log","nativeEvent","name","onStoryBlockLoadFinished","props","reason","componentDidMount","subscriptionOfShareBaseURLUpdated","FireworkSDKModuleEventEmitter","addListener","FWEventName","ShareBaseURLUpdated","setState","_subscriptions","push","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","subscriptionOfVideoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","_nativeComponentRef","current","componentWillUnmount","forEach","value","remove","render","style","_generateKey","_onStoryBlockLoadFinished","Object","assign","zIndex","source","channel","playlist","enablePictureInPicture","shareBaseURL","FireworkSDK","getInstance","getShareBaseURL","adBadgeConfiguration","getAdBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","dynamicContentParametersString","_generateDynamicContentParametersString","videoLaunchBehavior","getVideoLaunchBehavior","key","dynamicContentParameters","resultString","sortedKeyList","keys","sort","valueString","join","length"],"mappings":";;;;;;;AAAA;;AAQA;;AAEA;;AAEA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EI,MAAAA;AAAF,QAA+B,KAAKjD,KAA1C;;AAEA,QAAI,CAACiD,wBAAL,EAA+B;AAC7B,aAAO,EAAP;AACD;;AAED,QAAIC,YAAY,GAAG,EAAnB;AACA,UAAMC,aAAa,GAAG1B,MAAM,CAAC2B,IAAP,CAAYH,wBAAZ,EAAsCI,IAAtC,EAAtB;;AACA,SAAK,MAAML,GAAX,IAAkBG,aAAlB,EAAiC;AAC/B,YAAMhC,KAAK,GAAG8B,wBAAwB,CAACD,GAAD,CAAtC;AACA,YAAMM,WAAW,GAAGnC,KAAK,CAACoC,IAAN,CAAW,GAAX,CAApB;;AACA,UAAIL,YAAY,CAACM,MAAb,GAAsB,CAA1B,EAA6B;AAC3BN,QAAAA,YAAY,IAAI,GAAhB;AACD;;AAEDA,MAAAA,YAAY,IAAK,GAAEF,GAAI,IAAGM,WAAY,EAAtC;AACD;;AAED,WAAOJ,YAAP;AACD;;AApJwD;;eAuJ5C5D,U","sourcesContent":["import React from 'react';\n\nimport type {\n EmitterSubscription,\n NativeSyntheticEvent,\n StyleProp,\n ViewStyle,\n} from 'react-native';\nimport { findNodeHandle, Platform, UIManager } from 'react-native';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type { StoryBlockSource } from '../models/StoryBlockSource';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\nimport FWStoryBlock from './FWStoryBlock';\n\nconst NativeComponentName = 'FWStoryBlock';\n\nconst createFragment = (viewId: any) => {\n if (Platform.OS === 'android') {\n UIManager.dispatchViewManagerCommand(\n viewId,\n UIManager.getViewManagerConfig(\n NativeComponentName\n ).Commands.create.toString(),\n [viewId]\n );\n }\n};\n\n/**\n * The props type of StoryBlock component.\n */\nexport interface IStoryBlockProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of four available story block sources.\n */\n source: StoryBlockSource;\n /**\n * Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * The dynamic content parameters of the story block. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * Specifies if Picture in Picture is enabled.\n */\n enablePictureInPicture?: boolean;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\n/**\n * StoryBlock component. Only supported on iOS.\n */\nclass StoryBlock extends React.Component<IStoryBlockProps> {\n private _nativeComponentRef = React.createRef<any>();\n\n private _subscriptions: EmitterSubscription[] = [];\n\n /**\n * @ignore\n */\n componentDidMount() {\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n this.setState({});\n }\n );\n this._subscriptions.push(subscriptionOfShareBaseURLUpdated);\n\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n this.setState({});\n }\n );\n this._subscriptions.push(subscriptionOfAdBadgeConfigurationUpdated);\n\n const subscriptionOfVideoLaunchBehaviorUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.VideoLaunchBehaviorUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');\n this.setState({});\n }\n );\n this._subscriptions.push(subscriptionOfVideoLaunchBehaviorUpdated);\n\n if (Platform.OS === 'android') {\n const viewId = findNodeHandle(this._nativeComponentRef.current);\n FWLoggerUtil.log(\n `StoryBlock componentDidMount createFragment viewId: ${viewId}`\n );\n createFragment(viewId);\n }\n }\n\n /**\n * @ignore\n */\n componentWillUnmount() {\n this._subscriptions.forEach((value) => {\n value.remove();\n });\n\n this._subscriptions = [];\n }\n\n /**\n * @ignore\n */\n render() {\n const { style } = this.props;\n\n return (\n <FWStoryBlock\n ref={this._nativeComponentRef}\n key={this._generateKey()}\n {...this.props}\n onStoryBlockLoadFinished={this._onStoryBlockLoadFinished}\n style={Object.assign({}, style, { zIndex: -1 })}\n />\n );\n }\n\n private _onStoryBlockLoadFinished = (event: NativeSyntheticEvent<any>) => {\n FWLoggerUtil.log(\n `StoryBlock _onStoryBlockLoadFinished ${event.nativeEvent.name}`\n );\n\n const { onStoryBlockLoadFinished } = this.props;\n const { name, reason } = event.nativeEvent;\n\n if (onStoryBlockLoadFinished) {\n if (name) {\n if (reason) {\n onStoryBlockLoadFinished({ name, reason });\n } else {\n onStoryBlockLoadFinished({ name });\n }\n } else {\n onStoryBlockLoadFinished();\n }\n }\n };\n\n private _generateKey(): string {\n const {\n source,\n channel = '',\n playlist = '',\n enablePictureInPicture = false,\n } = this.props;\n\n const shareBaseURL = FireworkSDK.getInstance().getShareBaseURL() ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().getAdBadgeConfiguration() ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const dynamicContentParametersString =\n this._generateDynamicContentParametersString();\n const videoLaunchBehavior =\n FireworkSDK.getInstance().getVideoLaunchBehavior() ?? 'default';\n\n let key = `source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_shareBaseURL:${shareBaseURL}`;\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n\n return key;\n }\n\n private _generateDynamicContentParametersString(): string {\n const { dynamicContentParameters } = this.props;\n\n if (!dynamicContentParameters) {\n return '';\n }\n\n let resultString = '';\n const sortedKeyList = Object.keys(dynamicContentParameters).sort();\n for (const key of sortedKeyList) {\n const value = dynamicContentParameters[key];\n const valueString = value.join(',');\n if (resultString.length > 0) {\n resultString += '_';\n }\n\n resultString += `${key}:${valueString}`;\n }\n\n return resultString;\n }\n}\n\nexport default StoryBlock;\n"]}
|
|
1
|
+
{"version":3,"sources":["StoryBlock.tsx"],"names":["NativeComponentName","StoryBlock","props","forwardedRef","nativeComponentRef","isFullscreenState","setIsFullscreenState","forceUpdate","x","sendCommand","command","nativeNodeHandle","current","commandId","UIManager","getViewManagerConfig","Commands","Platform","OS","toString","dispatchViewManagerCommand","play","pause","subscriptionOfShareBaseURLUpdated","FireworkSDKModuleEventEmitter","addListener","FWEventName","ShareBaseURLUpdated","FWLoggerUtil","log","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","subscriptionOfVideoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","subscriptionOfAppLanguageUpdated","AppLanguageUpdated","setTimeout","viewId","create","remove","handleStoryBlockLoadFinished","event","nativeEvent","name","onStoryBlockLoadFinished","reason","handleStoryBlockFullscreenStateChanged","isFullScreen","generateDynamicContentParametersString","dynamicContentParameters","resultString","sortedKeyList","Object","keys","sort","key","value","valueString","join","length","generateVastAttributesString","adConfiguration","vastAttributes","attribute","generateKey","source","channel","playlist","enablePictureInPicture","hashtagFilterExpression","gShareBaseURL","FireworkSDK","getInstance","shareBaseURL","videoLaunchBehavior","adBadgeConfiguration","getAdBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","dynamicContentParametersString","appLanguage","requiresAds","adsFetchTimeout","vastAttributesString","onBackPress","navigator","popNativeContainer","subscription","BackHandler","addEventListener","style","assign","zIndex"],"mappings":";;;;;;;AACA;;AASA;;AAUA;;AAGA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,M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AOA,YAAMC,YAAY,GAAGC,yBAAYC,gBAAZ,CACnB,mBADmB,EAEnBL,WAFmB,CAArB;;AAIA,aAAO,MAAM;AACXG,QAAAA,YAAY,CAACpD,MAAb;AACD,OAFD;AAGD;;AAED;AACD,GAnBD,EAmBG,CAAClC,iBAAD,CAnBH;AAqBA,QAAM;AAAEyF,IAAAA;AAAF,MAAY5F,KAAlB;AACA,sBACE,6BAAC,qBAAD;AACE,IAAA,GAAG,EAAEE,kBADP;AAEE,IAAA,GAAG,EAAE4D,WAAW;AAFlB,KAGM9D,KAHN;AAIE,IAAA,wBAAwB,EAAEsC,4BAJ5B;AAKE,IAAA,kCAAkC,EAChCM,sCANJ;AAQE,IAAA,KAAK,EAAEM,MAAM,CAAC2C,MAAP,CAAc,EAAd,EAAkBD,KAAlB,EAAyB;AAAEE,MAAAA,MAAM,EAAE,CAAC;AAAX,KAAzB;AART,KADF;AAYD,CAnPD;;4BAqPe,uBAAW/F,UAAX,C","sourcesContent":["import type { ForwardRefRenderFunction } from 'react';\nimport React, {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useReducer,\n useRef,\n useState,\n} from 'react';\n\nimport {\n BackHandler,\n findNodeHandle,\n NativeSyntheticEvent,\n Platform,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type AdConfiguration from '../models/AdConfiguration';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type { StoryBlockSource } from '../models/StoryBlockSource';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\nimport FWStoryBlock from './FWStoryBlock';\n\nconst NativeComponentName = 'FWStoryBlock';\n\nexport interface IStoryBlockMethods {\n /**\n * Play the story block.\n */\n play: () => void;\n /**\n * Pause the story block.\n */\n pause: () => void;\n}\n\n/**\n * The props type of StoryBlock component.\n */\nexport interface IStoryBlockProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of four available story block sources.\n */\n source: StoryBlockSource;\n /**\n * Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * The dynamic content parameters of the story block. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * Hashtag filter expression is an s-expression used to provide feeds filtered by hashtags with specified criteria.\n * Queries are specified with boolean predicates on what hashtags are there on the video.\n * For instance, (and sport food) (or sport food) (and sport (or food comedy)) sport are all valid expressions.\n * Non-UTF-8 characters are not allowed. If using boolean predicates, the expression needs to be wrapped with parenthesis.\n */\n hashtagFilterExpression?: string;\n /**\n * Specifies if Picture in Picture is enabled. Only supported on iOS.\n */\n enablePictureInPicture?: boolean;\n /**\n * Ad configuration of the feed. Only supported on iOS.\n */\n adConfiguration?: AdConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\nconst StoryBlock: ForwardRefRenderFunction<\n IStoryBlockMethods,\n IStoryBlockProps\n> = (props: IStoryBlockProps, forwardedRef) => {\n const nativeComponentRef = useRef(null);\n const [isFullscreenState, setIsFullscreenState] = useState<boolean>(false);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n useImperativeHandle(\n forwardedRef,\n () => {\n const sendCommand = (command: string) => {\n const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);\n\n let commandId: string | number =\n UIManager.getViewManagerConfig(NativeComponentName).Commands[command];\n if (Platform.OS === 'android') {\n commandId = commandId.toString();\n }\n\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(nativeNodeHandle),\n commandId,\n []\n );\n };\n return {\n play: () => {\n sendCommand('play');\n },\n pause: () => {\n sendCommand('pause');\n },\n };\n },\n []\n );\n useEffect(() => {\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');\n forceUpdate();\n }\n );\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfVideoLaunchBehaviorUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.VideoLaunchBehaviorUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfAppLanguageUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AppLanguageUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');\n forceUpdate();\n }\n );\n\n if (Platform.OS === 'android') {\n setTimeout(() => {\n const viewId = findNodeHandle(nativeComponentRef.current);\n FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);\n UIManager.dispatchViewManagerCommand(\n viewId,\n UIManager.getViewManagerConfig(\n NativeComponentName\n ).Commands.create.toString(),\n [viewId]\n );\n }, 500);\n }\n\n return () => {\n subscriptionOfShareBaseURLUpdated.remove();\n subscriptionOfAdBadgeConfigurationUpdated.remove();\n subscriptionOfVideoLaunchBehaviorUpdated.remove();\n subscriptionOfAppLanguageUpdated.remove();\n };\n }, []);\n\n const handleStoryBlockLoadFinished = (event: NativeSyntheticEvent<any>) => {\n FWLoggerUtil.log(\n `StoryBlock handleStoryBlockLoadFinished ${event.nativeEvent.name}`\n );\n\n const { onStoryBlockLoadFinished } = props;\n const { name, reason } = event.nativeEvent;\n\n if (onStoryBlockLoadFinished) {\n if (name) {\n if (reason) {\n onStoryBlockLoadFinished({ name, reason });\n } else {\n onStoryBlockLoadFinished({ name });\n }\n } else {\n onStoryBlockLoadFinished();\n }\n }\n };\n\n const handleStoryBlockFullscreenStateChanged = (\n event: NativeSyntheticEvent<any>\n ) => {\n FWLoggerUtil.log(\n `StoryBlock handleStoryBlockFullscreenStateChanged ${event.nativeEvent.isFullScreen}`\n );\n const { isFullScreen } = event.nativeEvent;\n setIsFullscreenState(isFullScreen);\n };\n\n const generateDynamicContentParametersString = (): string => {\n const { dynamicContentParameters } = props;\n\n if (!dynamicContentParameters) {\n return '';\n }\n\n let resultString = '';\n const sortedKeyList = Object.keys(dynamicContentParameters).sort();\n for (const key of sortedKeyList) {\n const value = dynamicContentParameters[key];\n const valueString = value.join(',');\n if (resultString.length > 0) {\n resultString += '_';\n }\n\n resultString += `${key}:${valueString}`;\n }\n\n return resultString;\n };\n\n const generateVastAttributesString = () => {\n const { adConfiguration } = props;\n const vastAttributes = adConfiguration?.vastAttributes ?? '';\n if (!vastAttributes) {\n return '';\n }\n\n let resultString = '';\n for (const attribute of vastAttributes) {\n if (resultString.length > 0) {\n resultString += '_';\n }\n resultString += `${attribute.name ?? ''}:${attribute.value}`;\n }\n\n return resultString;\n };\n\n const generateKey = (): string => {\n const {\n source,\n channel = '',\n playlist = '',\n enablePictureInPicture = false,\n adConfiguration,\n hashtagFilterExpression = '',\n } = props;\n\n const gShareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const videoLaunchBehavior =\n FireworkSDK.getInstance().videoLaunchBehavior ?? 'default';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().getAdBadgeConfiguration() ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const dynamicContentParametersString =\n generateDynamicContentParametersString();\n const appLanguage = FireworkSDK.getInstance().appLanguage ?? '';\n const requiresAds = adConfiguration?.requiresAds ?? false;\n const adsFetchTimeout = adConfiguration?.adsFetchTimeout ?? 10;\n const vastAttributesString = generateVastAttributesString();\n\n let key = `source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_gShareBaseURL:${gShareBaseURL}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n key += `_appLanguage:${appLanguage}`;\n key += `_requiresAds:${requiresAds}`;\n key += `_adsFetchTimeout:${adsFetchTimeout}`;\n key += `_vastAttributes:${vastAttributesString}`;\n key += `_hashtagFilterExpression:${hashtagFilterExpression}`;\n\n return key;\n };\n\n useEffect(() => {\n if (Platform.OS === 'android') {\n const onBackPress = () => {\n if (isFullscreenState) {\n FireworkSDK.getInstance().navigator.popNativeContainer();\n return true;\n }\n return false;\n };\n const subscription = BackHandler.addEventListener(\n 'hardwareBackPress',\n onBackPress\n );\n return () => {\n subscription.remove();\n };\n }\n\n return;\n }, [isFullscreenState]);\n\n const { style } = props;\n return (\n <FWStoryBlock\n ref={nativeComponentRef}\n key={generateKey()}\n {...props}\n onStoryBlockLoadFinished={handleStoryBlockLoadFinished}\n onStoryBlockFullScreenStateChanged={\n handleStoryBlockFullscreenStateChanged\n }\n style={Object.assign({}, style, { zIndex: -1 })}\n />\n );\n};\n\nexport default forwardRef(StoryBlock);\n"]}
|