react-native-firework-sdk 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +5 -3
- 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 +84 -0
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +2 -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 +33 -9
- 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/reactnative/manager/FWStoryBlockManager.kt +126 -45
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +6 -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/FWNavigatorModule.kt +9 -1
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FWVideoShoppingModule.kt +81 -50
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +9 -2
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWConfigUtil.kt +1 -1
- package/android/src/main/java/com/fireworksdk/bridge/utils/FWGlobalDataUtil.kt +4 -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 +33 -2
- package/ios/Components/StoryBlockManager.m +32 -0
- package/ios/Components/VideoFeed.swift +9 -29
- package/ios/Components/VideoFeedManager.m +11 -6
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +378 -104
- package/ios/Models/NativeToRN/FireworkEventName.swift +3 -1
- package/ios/Models/RNToNative/RCTConvert+Shopping.swift +21 -0
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +27 -0
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +5 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +1 -0
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +30 -0
- package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +13 -0
- package/ios/Modules/Shopping/ShoppingCTAResult.swift +16 -0
- package/ios/Modules/Shopping/ShoppingModule.m +2 -1
- package/ios/Modules/Shopping/ShoppingModule.swift +106 -30
- package/ios/Support/MultiHostStreaming/FWMultiHostStreaming.podspec +24 -0
- package/ios/Support/MultiHostStreaming/src/MultiHostStreamingSDK.swift +17 -0
- package/ios/Utils/AppLanguage/Bundle+FWSwizzle.swift +58 -0
- package/ios/Utils/AppLanguage/FWAppLanguageManager.swift +139 -0
- package/ios/Utils/AppLanguage/FWLanguageUtil.swift +43 -0
- package/ios/Utils/AppLanguage/NumberFormatter+FWSwizzle.swift +25 -0
- package/ios/Utils/AppLanguage/UIImageView+FWSwizzle.swift +91 -0
- package/ios/Utils/AppLanguage/UILabel+FWSwizzle.swift +98 -0
- package/ios/Utils/AppLanguage/UITextField+FWSwizzle.swift +97 -0
- package/ios/Utils/AppLanguage/UITextView+FWSwizzle.swift +97 -0
- package/ios/Utils/AppLanguage/UIView+FWSwizzle.swift +38 -0
- package/ios/Utils/AppLanguage/UIViewController+FWSwizzle.swift +32 -0
- package/ios/Utils/AppLanguage/UIWindow+FWSwizzle.swift +26 -0
- package/ios/Utils/AppLanguage/URLSession+FWSwizzle.swift +69 -0
- package/ios/Utils/{DispatchQueue+FWOnce.swift → Extensions/DispatchQueue+FWOnce.swift} +3 -3
- package/ios/Utils/{UINavigationController+FWSwizzle.swift → Extensions/Swizzle/UINavigationController+FWSwizzle.swift} +6 -8
- package/ios/Utils/Extensions/UIView+FWUIHierarchy.swift +47 -0
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.h +25 -0
- package/ios/Utils/FWRTL/Classes/Manager/FWRTLManager.m +75 -0
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.h +21 -0
- package/ios/Utils/FWRTL/Classes/UICategories/CALayer+FWRTL.m +124 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.h +11 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLRemoteViewControllerAdaptor.m +86 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.h +16 -0
- package/ios/Utils/FWRTL/Classes/UICategories/FWRTLWhiteListManager.m +55 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.h +18 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UILabel+FWRTL.m +39 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.h +54 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIView+FWRTL.m +141 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.h +16 -0
- package/ios/Utils/FWRTL/Classes/UICategories/UIWindow+FWRTL.m +20 -0
- package/ios/Utils/FWRTL/Classes/Utils/FWRTLDefinitions.h +52 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.h +19 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSObject+FWRTLReloadBlock.m +49 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.h +21 -0
- package/ios/Utils/FWRTL/Classes/Utils/NSString+FWRTL.m +38 -0
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.h +18 -0
- package/ios/Utils/FWRTL/Classes/Utils/UIImage+FWRTL.m +43 -0
- package/ios/Utils/FWSwizzleLoader.m +6 -1
- package/ios/Utils/FWSwizzleLoader.swift +13 -0
- package/ios/Utils/FWSwizzleUtil.swift +17 -9
- package/ios/react_native_firework_sdk.h +1 -0
- package/ios/scripts/react_native_firework_sdk_pods.rb +31 -0
- package/lib/commonjs/FireworkSDK.js +21 -4
- package/lib/commonjs/FireworkSDK.js.map +1 -1
- package/lib/commonjs/VideoShopping.js +20 -37
- package/lib/commonjs/VideoShopping.js.map +1 -1
- package/lib/commonjs/components/StoryBlock.js +190 -125
- package/lib/commonjs/components/StoryBlock.js.map +1 -1
- package/lib/commonjs/components/VideoFeed.js +11 -1
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/FWEventName.js +2 -0
- package/lib/commonjs/models/FWEventName.js.map +1 -1
- package/lib/commonjs/models/ShoppingCTAResult.js +2 -0
- package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -1
- package/lib/commonjs/modules/ShoppingModule.js.map +1 -1
- package/lib/module/FireworkSDK.js +21 -4
- package/lib/module/FireworkSDK.js.map +1 -1
- package/lib/module/VideoShopping.js +20 -39
- package/lib/module/VideoShopping.js.map +1 -1
- package/lib/module/components/StoryBlock.js +179 -131
- package/lib/module/components/StoryBlock.js.map +1 -1
- package/lib/module/components/VideoFeed.js +10 -1
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/FWEventName.js +2 -0
- package/lib/module/models/FWEventName.js.map +1 -1
- package/lib/module/models/ShoppingCTAResult.js +2 -0
- package/lib/module/modules/FireworkSDKModule.js.map +1 -1
- package/lib/module/modules/ShoppingModule.js.map +1 -1
- package/lib/typescript/FireworkSDK.d.ts +7 -4
- package/lib/typescript/VideoShopping.d.ts +9 -11
- package/lib/typescript/components/StoryBlock.d.ts +19 -25
- package/lib/typescript/index.d.ts +6 -6
- package/lib/typescript/models/FWEventName.d.ts +2 -0
- package/lib/typescript/models/FWEvents.d.ts +14 -1
- package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +36 -1
- package/lib/typescript/models/ShoppingCTAResult.d.ts +11 -0
- package/lib/typescript/modules/FireworkSDKModule.d.ts +1 -2
- package/lib/typescript/modules/ShoppingModule.d.ts +2 -1
- package/package.json +2 -2
- package/react-native-firework-sdk.podspec +26 -24
- package/src/FireworkSDK.ts +18 -5
- package/src/VideoShopping.ts +40 -53
- package/src/components/StoryBlock.tsx +199 -96
- package/src/components/VideoFeed.tsx +11 -0
- package/src/index.ts +15 -7
- package/src/models/FWEventName.ts +2 -0
- package/src/models/FWEvents.ts +14 -1
- package/src/models/ProductInfoViewConfiguration.ts +38 -1
- package/src/models/ShoppingCTAResult.ts +11 -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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoShopping.ts"],"names":["Platform","FWEventName","ShoppingModule","ShoppingModuleEventEmitter","FWLoggerUtil","VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","OS","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","productInfoViewConfiguration","_productInfoViewConfiguration","setProductInfoViewConfiguration","onCustomClickLinkButton","_onCustomClickLinkButton","setCustomClickLinkButtonEnabled","eventEmitter","getInstance","log","_instance","constructor","addListener","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,SAA6BA,QAA7B,QAA6C,cAA7C;AAGA,SAASC,WAAT,QAA4B,sBAA5B;AAQA,OAAOC,cAAP,IACEC,0BADF,QAEO,0BAFP;AAGA,OAAOC,YAAP,MAAyB,sBAAzB;;AAgBA;AACA;AACA;AACA,MAAMC,aAAN,CAAoB;AAGlB;AACF;AACA;AACA;AACA;AACA;;AAGE;AACF;AACA;AACA;AACA;AACA;AACkC,MAArBC,qBAAqB,GAA4C;AAC1E,WAAO,KAAKC,sBAAZ;AACD;;AAC+B,MAArBD,qBAAqB,CAC9BE,KAD8B,EAE9B;AACA,SAAKD,sBAAL,GAA8BC,KAA9B;;AACA,QAAIR,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,MAAAA,cAAc,CAACQ,6BAAf,CAA6C,CAAC,CAACF,KAA/C;AACD;AACF;;AAUD;AACF;AACA;AACA;AAC4B,MAAfG,eAAe,GAAY;AACpC,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACH,KAAD,EAAiB;AACzC,SAAKI,gBAAL,GAAwBJ,KAAxB;AACAN,IAAAA,cAAc,CAACW,kBAAf,CAAkCL,KAAlC;AACD;;AAGD;AACF;AACA;AACA;AACyC,MAA5BM,4BAA4B,GAEzB;AACZ,WAAO,KAAKC,6BAAZ;AACD;;AAEsC,MAA5BD,4BAA4B,CACrCN,KADqC,EAErC;AACA,SAAKO,6BAAL,GAAqCP,KAArC;;AACA,QAAIR,QAAQ,CAACS,EAAT,KAAgB,K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ACzBP,YAAAA,cAAc,CAAC8C,eAAf,CACEN,UADF,EAEEzC,WAAW,CAACgC,oBAFd;AAID;AACF;AACF;AACF,KAhCD,MAgCO;AACL7B,MAAAA,YAAY,CAACkB,GAAb,CAAiB,6CAAjB;;AACA,UAAIoB,UAAJ,EAAgB;AACd,YAAI1C,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,UAAAA,cAAc,CAAC8C,eAAf,CACEN,UADF,EAEEzC,WAAW,CAACgC,oBAFd;AAID;AACF;AACF;AACF;;AAE6C,QAAhCM,gCAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAKV,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6BU,KAA7B;AACD;AACF;;AApPiB;;gBAAdtB,a;;AAuPN,eAAeA,aAAf","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":["Platform","FWEventName","ShoppingModule","ShoppingModuleEventEmitter","FWLoggerUtil","VideoShopping","onCustomClickCartIcon","_onCustomClickCartIcon","value","OS","setCustomClickCartIconEnabled","cartIconVisible","_cartIconVisible","setCartIconVisible","productInfoViewConfiguration","_productInfoViewConfiguration","setProductInfoViewConfiguration","onCustomClickLinkButton","_onCustomClickLinkButton","setCustomClickLinkButtonEnabled","eventEmitter","getInstance","log","_instance","constructor","addListener","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,SAA6BA,QAA7B,QAA6C,cAA7C;AAEA,SAASC,WAAT,QAA4B,sBAA5B;AAQA,OAAOC,cAAP,IACEC,0BADF,QAEO,0BAFP;AAGA,OAAOC,YAAP,MAAyB,sBAAzB;;AAiBA;AACA;AACA;AACA,MAAMC,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,QAAIR,QAAQ,CAACS,EAAT,KAAgB,KAApB,EAA2B;AACzBP,MAAAA,cAAc,CAACQ,6BAAf,CAA6C,CAAC,CAACF,KAA/C;AACD;AACF;;AAUD;AACF;AACA;AACA;AAC4B,MAAfG,eAAe,GAAY;AACpC,WAAO,KAAKC,gBAAZ;AACD;;AACyB,MAAfD,eAAe,CAACH,KAAD,EAAiB;AACzC,SAAKI,gBAAL,GAAwBJ,KAAxB;AACAN,IAAAA,cAAc,CAACW,kBAAf,CAAkCL,KAAlC;AACD;;AAGD;AACF;AACA;AACA;AACyC,MAA5BM,4BAA4B,GAEzB;AACZ,WAAO,KAAKC,6BAAZ;AACD;;AAEsC,MAA5BD,4BAA4B,CACrCN,KADqC,EAErC;AACA,SAAKO,6BAAL,GAA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;AAE6C,QAAhCK,gCAAgC,CAC5CZ,KAD4C,EAE5C;AACA,QAAI,KAAKV,uBAAT,EAAkC;AAChC,WAAKA,uBAAL,CAA6BU,KAA7B;AACD;AACF;;AAvOiB;;gBAAdtB,a;;AA0ON,eAAeA,aAAf","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. 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 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"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
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); }
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { findNodeHandle, Platform, UIManager } from 'react-native';
|
|
3
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useReducer, useRef, useState } from 'react';
|
|
4
|
+
import { BackHandler, findNodeHandle, Platform, UIManager } from 'react-native';
|
|
7
5
|
import FireworkSDK from '../FireworkSDK';
|
|
8
6
|
import { FWEventName } from '../models/FWEventName';
|
|
9
7
|
import { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';
|
|
@@ -11,175 +9,225 @@ import FWLoggerUtil from '../utils/FWLoggerUtil';
|
|
|
11
9
|
import FWStoryBlock from './FWStoryBlock';
|
|
12
10
|
const NativeComponentName = 'FWStoryBlock';
|
|
13
11
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* StoryBlock component. Only supported on iOS.
|
|
26
|
-
*/
|
|
27
|
-
class StoryBlock extends React.Component {
|
|
28
|
-
constructor() {
|
|
29
|
-
super(...arguments);
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "_nativeComponentRef", /*#__PURE__*/React.createRef());
|
|
32
|
-
|
|
33
|
-
_defineProperty(this, "_subscriptions", []);
|
|
34
|
-
|
|
35
|
-
_defineProperty(this, "_onStoryBlockLoadFinished", event => {
|
|
36
|
-
FWLoggerUtil.log(`StoryBlock _onStoryBlockLoadFinished ${event.nativeEvent.name}`);
|
|
37
|
-
const {
|
|
38
|
-
onStoryBlockLoadFinished
|
|
39
|
-
} = this.props;
|
|
40
|
-
const {
|
|
41
|
-
name,
|
|
42
|
-
reason
|
|
43
|
-
} = event.nativeEvent;
|
|
44
|
-
|
|
45
|
-
if (onStoryBlockLoadFinished) {
|
|
46
|
-
if (name) {
|
|
47
|
-
if (reason) {
|
|
48
|
-
onStoryBlockLoadFinished({
|
|
49
|
-
name,
|
|
50
|
-
reason
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
onStoryBlockLoadFinished({
|
|
54
|
-
name
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
onStoryBlockLoadFinished();
|
|
59
|
-
}
|
|
12
|
+
const StoryBlock = (props, forwardedRef) => {
|
|
13
|
+
const nativeComponentRef = useRef(null);
|
|
14
|
+
const [isFullscreenState, setIsFullscreenState] = useState(false);
|
|
15
|
+
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
16
|
+
useImperativeHandle(forwardedRef, () => {
|
|
17
|
+
const sendCommand = command => {
|
|
18
|
+
const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);
|
|
19
|
+
let commandId = UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
|
|
20
|
+
|
|
21
|
+
if (Platform.OS === 'android') {
|
|
22
|
+
commandId = commandId.toString();
|
|
60
23
|
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
24
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
25
|
+
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeNodeHandle), commandId, []);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
play: () => {
|
|
30
|
+
sendCommand('play');
|
|
31
|
+
},
|
|
32
|
+
pause: () => {
|
|
33
|
+
sendCommand('pause');
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}, []);
|
|
37
|
+
useEffect(() => {
|
|
68
38
|
const subscriptionOfShareBaseURLUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.ShareBaseURLUpdated, () => {
|
|
69
|
-
|
|
39
|
+
FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');
|
|
40
|
+
forceUpdate();
|
|
70
41
|
});
|
|
71
|
-
|
|
72
|
-
this._subscriptions.push(subscriptionOfShareBaseURLUpdated);
|
|
73
|
-
|
|
74
42
|
const subscriptionOfAdBadgeConfigurationUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AdBadgeConfigurationUpdated, () => {
|
|
75
|
-
|
|
43
|
+
FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');
|
|
44
|
+
forceUpdate();
|
|
76
45
|
});
|
|
77
|
-
|
|
78
|
-
this._subscriptions.push(subscriptionOfAdBadgeConfigurationUpdated);
|
|
79
|
-
|
|
80
46
|
const subscriptionOfVideoLaunchBehaviorUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.VideoLaunchBehaviorUpdated, () => {
|
|
81
47
|
FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
|
|
82
|
-
|
|
48
|
+
forceUpdate();
|
|
49
|
+
});
|
|
50
|
+
const subscriptionOfAppLanguageUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AppLanguageUpdated, () => {
|
|
51
|
+
FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');
|
|
52
|
+
forceUpdate();
|
|
83
53
|
});
|
|
84
|
-
|
|
85
|
-
this._subscriptions.push(subscriptionOfVideoLaunchBehaviorUpdated);
|
|
86
54
|
|
|
87
55
|
if (Platform.OS === 'android') {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
const viewId = findNodeHandle(nativeComponentRef.current);
|
|
58
|
+
FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);
|
|
59
|
+
UIManager.dispatchViewManagerCommand(viewId, UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
|
|
60
|
+
}, 500);
|
|
91
61
|
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* @ignore
|
|
95
|
-
*/
|
|
96
62
|
|
|
63
|
+
return () => {
|
|
64
|
+
subscriptionOfShareBaseURLUpdated.remove();
|
|
65
|
+
subscriptionOfAdBadgeConfigurationUpdated.remove();
|
|
66
|
+
subscriptionOfVideoLaunchBehaviorUpdated.remove();
|
|
67
|
+
subscriptionOfAppLanguageUpdated.remove();
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
97
70
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
71
|
+
const handleStoryBlockLoadFinished = event => {
|
|
72
|
+
FWLoggerUtil.log(`StoryBlock handleStoryBlockLoadFinished ${event.nativeEvent.name}`);
|
|
73
|
+
const {
|
|
74
|
+
onStoryBlockLoadFinished
|
|
75
|
+
} = props;
|
|
76
|
+
const {
|
|
77
|
+
name,
|
|
78
|
+
reason
|
|
79
|
+
} = event.nativeEvent;
|
|
80
|
+
|
|
81
|
+
if (onStoryBlockLoadFinished) {
|
|
82
|
+
if (name) {
|
|
83
|
+
if (reason) {
|
|
84
|
+
onStoryBlockLoadFinished({
|
|
85
|
+
name,
|
|
86
|
+
reason
|
|
87
|
+
});
|
|
88
|
+
} else {
|
|
89
|
+
onStoryBlockLoadFinished({
|
|
90
|
+
name
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
onStoryBlockLoadFinished();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
102
98
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
99
|
+
const handleStoryBlockFullscreenStateChanged = event => {
|
|
100
|
+
FWLoggerUtil.log(`StoryBlock handleStoryBlockFullscreenStateChanged ${event.nativeEvent.isFullScreen}`);
|
|
101
|
+
const {
|
|
102
|
+
isFullScreen
|
|
103
|
+
} = event.nativeEvent;
|
|
104
|
+
setIsFullscreenState(isFullScreen);
|
|
105
|
+
};
|
|
108
106
|
|
|
107
|
+
const generateDynamicContentParametersString = () => {
|
|
108
|
+
const {
|
|
109
|
+
dynamicContentParameters
|
|
110
|
+
} = props;
|
|
111
|
+
|
|
112
|
+
if (!dynamicContentParameters) {
|
|
113
|
+
return '';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
let resultString = '';
|
|
117
|
+
const sortedKeyList = Object.keys(dynamicContentParameters).sort();
|
|
118
|
+
|
|
119
|
+
for (const key of sortedKeyList) {
|
|
120
|
+
const value = dynamicContentParameters[key];
|
|
121
|
+
const valueString = value.join(',');
|
|
122
|
+
|
|
123
|
+
if (resultString.length > 0) {
|
|
124
|
+
resultString += '_';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
resultString += `${key}:${valueString}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return resultString;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const generateVastAttributesString = () => {
|
|
134
|
+
var _adConfiguration$vast;
|
|
109
135
|
|
|
110
|
-
render() {
|
|
111
136
|
const {
|
|
112
|
-
|
|
113
|
-
} =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
adConfiguration
|
|
138
|
+
} = props;
|
|
139
|
+
const vastAttributes = (_adConfiguration$vast = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.vastAttributes) !== null && _adConfiguration$vast !== void 0 ? _adConfiguration$vast : '';
|
|
140
|
+
|
|
141
|
+
if (!vastAttributes) {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let resultString = '';
|
|
146
|
+
|
|
147
|
+
for (const attribute of vastAttributes) {
|
|
148
|
+
var _attribute$name;
|
|
149
|
+
|
|
150
|
+
if (resultString.length > 0) {
|
|
151
|
+
resultString += '_';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
resultString += `${(_attribute$name = attribute.name) !== null && _attribute$name !== void 0 ? _attribute$name : ''}:${attribute.value}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return resultString;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const generateKey = () => {
|
|
161
|
+
var _FireworkSDK$getInsta, _FireworkSDK$getInsta2, _adBadgeConfiguration, _adBadgeConfiguration2, _adBadgeConfiguration3, _FireworkSDK$getInsta3, _adConfiguration$requ, _adConfiguration$adsF;
|
|
127
162
|
|
|
128
163
|
const {
|
|
129
164
|
source,
|
|
130
165
|
channel = '',
|
|
131
166
|
playlist = '',
|
|
132
|
-
enablePictureInPicture = false
|
|
133
|
-
|
|
167
|
+
enablePictureInPicture = false,
|
|
168
|
+
adConfiguration
|
|
169
|
+
} = props;
|
|
134
170
|
const shareBaseURL = (_FireworkSDK$getInsta = FireworkSDK.getInstance().getShareBaseURL()) !== null && _FireworkSDK$getInsta !== void 0 ? _FireworkSDK$getInsta : '';
|
|
171
|
+
const videoLaunchBehavior = FireworkSDK.getInstance().getVideoLaunchBehavior();
|
|
135
172
|
const adBadgeConfiguration = (_FireworkSDK$getInsta2 = FireworkSDK.getInstance().getAdBadgeConfiguration()) !== null && _FireworkSDK$getInsta2 !== void 0 ? _FireworkSDK$getInsta2 : {};
|
|
136
173
|
const adBadgeTextType = (_adBadgeConfiguration = adBadgeConfiguration.badgeTextType) !== null && _adBadgeConfiguration !== void 0 ? _adBadgeConfiguration : '';
|
|
137
174
|
const backgroundColorOfAdBadge = (_adBadgeConfiguration2 = adBadgeConfiguration.backgroundColor) !== null && _adBadgeConfiguration2 !== void 0 ? _adBadgeConfiguration2 : '';
|
|
138
175
|
const textColorOfAdBadge = (_adBadgeConfiguration3 = adBadgeConfiguration.textColor) !== null && _adBadgeConfiguration3 !== void 0 ? _adBadgeConfiguration3 : '';
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
const
|
|
176
|
+
const dynamicContentParametersString = generateDynamicContentParametersString();
|
|
177
|
+
const appLanguage = (_FireworkSDK$getInsta3 = FireworkSDK.getInstance().appLanguage) !== null && _FireworkSDK$getInsta3 !== void 0 ? _FireworkSDK$getInsta3 : '';
|
|
178
|
+
const requiresAds = (_adConfiguration$requ = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.requiresAds) !== null && _adConfiguration$requ !== void 0 ? _adConfiguration$requ : false;
|
|
179
|
+
const adsFetchTimeout = (_adConfiguration$adsF = adConfiguration === null || adConfiguration === void 0 ? void 0 : adConfiguration.adsFetchTimeout) !== null && _adConfiguration$adsF !== void 0 ? _adConfiguration$adsF : 10;
|
|
180
|
+
const vastAttributesString = generateVastAttributesString();
|
|
143
181
|
let key = `source:${source}`;
|
|
144
182
|
key += `_channel:${channel}`;
|
|
145
183
|
key += `_playlist:${playlist}`;
|
|
146
184
|
key += `_shareBaseURL:${shareBaseURL}`;
|
|
185
|
+
key += `_videoLaunchBehavior:${videoLaunchBehavior}`;
|
|
147
186
|
key += `_adBadgeTextType:${adBadgeTextType}`;
|
|
148
187
|
key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;
|
|
149
188
|
key += `_textColorOfAdBadge:${textColorOfAdBadge}`;
|
|
150
189
|
key += `_dynamicContentParameters:${dynamicContentParametersString}`;
|
|
151
190
|
key += `_enablePictureInPicture:${enablePictureInPicture}`;
|
|
152
|
-
key += `
|
|
191
|
+
key += `_appLanguage:${appLanguage}`;
|
|
192
|
+
key += `_requiresAds:${requiresAds}`;
|
|
193
|
+
key += `_adsFetchTimeout:${adsFetchTimeout}`;
|
|
194
|
+
key += `_vastAttributes:${vastAttributesString}`;
|
|
153
195
|
return key;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
_generateDynamicContentParametersString() {
|
|
157
|
-
const {
|
|
158
|
-
dynamicContentParameters
|
|
159
|
-
} = this.props;
|
|
160
|
-
|
|
161
|
-
if (!dynamicContentParameters) {
|
|
162
|
-
return '';
|
|
163
|
-
}
|
|
196
|
+
};
|
|
164
197
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (Platform.OS === 'android') {
|
|
200
|
+
const onBackPress = () => {
|
|
201
|
+
if (isFullscreenState) {
|
|
202
|
+
FireworkSDK.getInstance().navigator.popNativeContainer();
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
171
205
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
206
|
+
return false;
|
|
207
|
+
};
|
|
175
208
|
|
|
176
|
-
|
|
209
|
+
const subscription = BackHandler.addEventListener('hardwareBackPress', onBackPress);
|
|
210
|
+
return () => {
|
|
211
|
+
subscription.remove();
|
|
212
|
+
};
|
|
177
213
|
}
|
|
178
214
|
|
|
179
|
-
return
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
215
|
+
return;
|
|
216
|
+
}, [isFullscreenState]);
|
|
217
|
+
const {
|
|
218
|
+
style
|
|
219
|
+
} = props;
|
|
220
|
+
return /*#__PURE__*/React.createElement(FWStoryBlock, _extends({
|
|
221
|
+
ref: nativeComponentRef,
|
|
222
|
+
key: generateKey()
|
|
223
|
+
}, props, {
|
|
224
|
+
onStoryBlockLoadFinished: handleStoryBlockLoadFinished,
|
|
225
|
+
onStoryBlockFullScreenStateChanged: handleStoryBlockFullscreenStateChanged,
|
|
226
|
+
style: Object.assign({}, style, {
|
|
227
|
+
zIndex: -1
|
|
228
|
+
})
|
|
229
|
+
}));
|
|
230
|
+
};
|
|
183
231
|
|
|
184
|
-
export default StoryBlock;
|
|
232
|
+
export default /*#__PURE__*/forwardRef(StoryBlock);
|
|
185
233
|
//# sourceMappingURL=StoryBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["StoryBlock.tsx"],"names":["React","findNodeHandle","Platform","UIManager","FireworkSDK","FWEventName","FireworkSDKModuleEventEmitter","FWLoggerUtil","FWStoryBlock","NativeComponentName","createFragment","viewId","OS","dispatchViewManagerCommand","getViewManagerConfig","Commands","create","toString","StoryBlock","Component","createRef","event","log","nativeEvent","name","onStoryBlockLoadFinished","props","reason","componentDidMount","subscriptionOfShareBaseURLUpdated","addListener","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","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,OAAOA,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K,oBAAmBV,eAAgB,EAA3C;AACAU,IAAAA,GAAG,IAAK,6BAA4BR,wBAAyB,EAA7D;AACAQ,IAAAA,GAAG,IAAK,uBAAsBN,kBAAmB,EAAjD;AACAM,IAAAA,GAAG,IAAK,6BAA4BJ,8BAA+B,EAAnE;AACAI,IAAAA,GAAG,IAAK,2BAA0BhB,sBAAuB,EAAzD;AACAgB,IAAAA,GAAG,IAAK,wBAAuBF,mBAAoB,EAAnD;AAEA,WAAOE,GAAP;AACD;;AAEOH,EAAAA,uCAAuC,GAAW;AACxD,UAAM;AAAEI,MAAAA;AAAF,QAA+B,KAAK9C,KAA1C;;AAEA,QAAI,CAAC8C,wBAAL,EAA+B;AAC7B,aAAO,EAAP;AACD;;AAED,QAAIC,YAAY,GAAG,EAAnB;AACA,UAAMC,aAAa,GAAGzB,MAAM,CAAC0B,IAAP,CAAYH,wBAAZ,EAAsCI,IAAtC,EAAtB;;AACA,SAAK,MAAML,GAAX,IAAkBG,aAAlB,EAAiC;AAC/B,YAAM/B,KAAK,GAAG6B,wBAAwB,CAACD,GAAD,CAAtC;AACA,YAAMM,WAAW,GAAGlC,KAAK,CAACmC,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;;AAuJ3D,eAAevD,UAAf","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":["React","forwardRef","useEffect","useImperativeHandle","useReducer","useRef","useState","BackHandler","findNodeHandle","Platform","UIManager","FireworkSDK","FWEventName","FireworkSDKModuleEventEmitter","FWLoggerUtil","FWStoryBlock","NativeComponentName","StoryBlock","props","forwardedRef","nativeComponentRef","isFullscreenState","setIsFullscreenState","forceUpdate","x","sendCommand","command","nativeNodeHandle","current","commandId","getViewManagerConfig","Commands","OS","toString","dispatchViewManagerCommand","play","pause","subscriptionOfShareBaseURLUpdated","addListener","ShareBaseURLUpdated","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","shareBaseURL","getInstance","getShareBaseURL","videoLaunchBehavior","getVideoLaunchBehavior","adBadgeConfiguration","getAdBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","dynamicContentParametersString","appLanguage","requiresAds","adsFetchTimeout","vastAttributesString","onBackPress","navigator","popNativeContainer","subscription","addEventListener","style","assign","zIndex"],"mappings":";;AACA,OAAOA,KAAP,IACEC,UADF,EAEEC,SAFF,EAGEC,mBAHF,EAIEC,UAJF,EAKEC,MALF,EAMEC,QANF,QAOO,OAPP;AASA,SACEC,WADF,EAEEC,cAFF,EAIEC,QAJF,EAMEC,SANF,QAQO,cARP;AAUA,OAAOC,WAAP,MAAwB,gBAAxB;AAGA,SAASC,WAAT,QAA4B,uBAA5B;AAEA,SAASC,6BAAT,QAA8C,8BAA9C;AACA,OAAOC,YAAP,MAAyB,uBAAzB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AAEA,MAAMC,mBAAmB,GAAG,cAA5B;;AAmDA,MAAMC,UAGL,GAAG,CAACC,KAAD,EAA0BC,YAA1B,KAA2C;AAC7C,QAAMC,kBAAkB,GAAGf,MAAM,CAAC,IAAD,CAAjC;AACA,QAAM,CAACgB,iBAAD,EAAoBC,oBAApB,IAA4ChB,QAAQ,CAAU,KAAV,CAA1D;AACA,QAAM,GAAGiB,WAAH,IAAkBnB,UAAU,CAAEoB,CAAD,IAAOA,CAAC,GAAG,CAAZ,EAAe,CAAf,CAAlC;AACArB,EAAAA,mBAAmB,CACjBgB,YADiB,EAEjB,MAAM;AACJ,UAAMM,WAAW,GAAIC,OAAD,IAAqB;AACvC,YAAMC,gBAAgB,GAAGnB,cAAc,CAACY,kBAAkB,CAACQ,OAApB,CAAvC;AAEA,UAAIC,SAA0B,GAC5BnB,SAAS,CAACo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IAAA,GAAG,EAAEE,kBADP;AAEE,IAAA,GAAG,EAAEuD,WAAW;AAFlB,KAGMzD,KAHN;AAIE,IAAA,wBAAwB,EAAEiC,4BAJ5B;AAKE,IAAA,kCAAkC,EAChCM,sCANJ;AAQE,IAAA,KAAK,EAAEM,MAAM,CAACyC,MAAP,CAAc,EAAd,EAAkBD,KAAlB,EAAyB;AAAEE,MAAAA,MAAM,EAAE,CAAC;AAAX,KAAzB;AART,KADF;AAYD,CAjPD;;AAmPA,4BAAexG,UAAU,CAACgB,UAAD,CAAzB","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 * 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 } = props;\n\n const shareBaseURL = FireworkSDK.getInstance().getShareBaseURL() ?? '';\n const videoLaunchBehavior =\n FireworkSDK.getInstance().getVideoLaunchBehavior();\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 += `_shareBaseURL:${shareBaseURL}`;\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\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"]}
|
|
@@ -88,6 +88,13 @@ class VideoFeed extends React.Component {
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
this._subscriptions.push(subscriptionOfVideoLaunchBehaviorUpdated);
|
|
91
|
+
|
|
92
|
+
const subscriptionOfAppLanguageUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AppLanguageUpdated, () => {
|
|
93
|
+
FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');
|
|
94
|
+
this.setState({});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
this._subscriptions.push(subscriptionOfAppLanguageUpdated);
|
|
91
98
|
}
|
|
92
99
|
/**
|
|
93
100
|
* @ignore
|
|
@@ -109,7 +116,7 @@ class VideoFeed extends React.Component {
|
|
|
109
116
|
|
|
110
117
|
|
|
111
118
|
render() {
|
|
112
|
-
var _videoFeedConfigurati, _videoFeedConfigurati2, _videoFeedConfigurati3, _FireworkSDK$getInsta, _FireworkSDK$getInsta2, _adBadgeConfiguration, _adBadgeConfiguration2, _adBadgeConfiguration3, _videoFeedConfigurati4, _videoFeedConfigurati5, _adConfiguration$requ, _adConfiguration$adsF, _videoFeedConfigurati6, _FireworkSDK$getInsta3;
|
|
119
|
+
var _videoFeedConfigurati, _videoFeedConfigurati2, _videoFeedConfigurati3, _FireworkSDK$getInsta, _FireworkSDK$getInsta2, _adBadgeConfiguration, _adBadgeConfiguration2, _adBadgeConfiguration3, _videoFeedConfigurati4, _videoFeedConfigurati5, _adConfiguration$requ, _adConfiguration$adsF, _videoFeedConfigurati6, _FireworkSDK$getInsta3, _FireworkSDK$getInsta4;
|
|
113
120
|
|
|
114
121
|
FWLoggerUtil.log(`VideoFeed render ${JSON.stringify(this.props)}`);
|
|
115
122
|
const {
|
|
@@ -143,6 +150,7 @@ class VideoFeed extends React.Component {
|
|
|
143
150
|
|
|
144
151
|
const showAdBadge = (_videoFeedConfigurati6 = videoFeedConfiguration === null || videoFeedConfiguration === void 0 ? void 0 : videoFeedConfiguration.showAdBadge) !== null && _videoFeedConfigurati6 !== void 0 ? _videoFeedConfigurati6 : false;
|
|
145
152
|
const videoLaunchBehavior = (_FireworkSDK$getInsta3 = FireworkSDK.getInstance().getVideoLaunchBehavior()) !== null && _FireworkSDK$getInsta3 !== void 0 ? _FireworkSDK$getInsta3 : 'default';
|
|
153
|
+
const appLanguage = (_FireworkSDK$getInsta4 = FireworkSDK.getInstance().appLanguage) !== null && _FireworkSDK$getInsta4 !== void 0 ? _FireworkSDK$getInsta4 : '';
|
|
146
154
|
let key = `source:${source}`;
|
|
147
155
|
key += `_channel:${channel}`;
|
|
148
156
|
key += `_playlist:${playlist}`;
|
|
@@ -163,6 +171,7 @@ class VideoFeed extends React.Component {
|
|
|
163
171
|
key += `_vastAttributes:${vastAttributesString}`;
|
|
164
172
|
key += `_showAdBadge:${showAdBadge}`;
|
|
165
173
|
key += `_videoLaunchBehavior:${videoLaunchBehavior}`;
|
|
174
|
+
key += `_appLanguage:${appLanguage}`;
|
|
166
175
|
return /*#__PURE__*/React.createElement(FWVideoFeed, _extends({
|
|
167
176
|
key: key
|
|
168
177
|
}, this.props, {
|