react-native-firework-sdk 1.3.1-beta.9 → 1.4.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/android/build.gradle +2 -8
- package/android/src/main/java/com/fireworksdk/bridge/FireworkSDKPackage.kt +6 -2
- package/android/src/main/java/com/fireworksdk/bridge/models/FWEventName.kt +4 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWStoryBlockManager.kt +274 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/manager/FWVideoFeedManager.kt +16 -9
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/module/FireworkSDKModule.kt +13 -0
- package/android/src/main/java/com/fireworksdk/bridge/reactnative/utils/FWEventUtils.kt +11 -0
- package/android/src/main/res/layout/fw_bridge_fragment_videofeed.xml +0 -4
- package/ios/Components/StoryBlock.swift +105 -0
- package/ios/Components/StoryBlockManager.m +29 -0
- package/ios/Components/StoryBlockManager.swift +31 -0
- package/ios/Components/VideoFeed.swift +8 -16
- package/ios/FireworkSdk.xcodeproj/project.pbxproj +26 -4
- package/ios/Models/NativeToRN/FireworkSDK+Json.swift +23 -5
- package/ios/Models/RNToNative/RCTConvert+StoryBlock.swift +28 -0
- package/ios/Models/RNToNative/RCTConvert+VideoFeed.swift +2 -2
- package/ios/Modules/FWNavigatorModule/FWNavigatorModule.swift +1 -1
- package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +2 -0
- package/ios/Modules/Shopping/{CartViewController.swift → FWCartViewController.swift} +8 -7
- package/ios/Modules/Shopping/ShoppingModule.swift +4 -3
- package/ios/Utils/UINavigationController+FWSwizzle.h +16 -0
- package/ios/Utils/UINavigationController+FWSwizzle.m +49 -0
- package/ios/Utils/UIViewController+AttachChild.swift +8 -11
- package/lib/commonjs/components/FWStoryBlock.js +18 -0
- package/lib/commonjs/components/FWStoryBlock.js.map +1 -0
- package/lib/commonjs/components/StoryBlock.js +174 -0
- package/lib/commonjs/components/StoryBlock.js.map +1 -0
- package/lib/commonjs/components/VideoFeed.js +31 -17
- package/lib/commonjs/components/VideoFeed.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/StoryBlockSource.js +2 -0
- package/lib/commonjs/models/StoryBlockSource.js.map +1 -0
- package/lib/module/components/FWStoryBlock.js +8 -0
- package/lib/module/components/FWStoryBlock.js.map +1 -0
- package/lib/module/components/StoryBlock.js +150 -0
- package/lib/module/components/StoryBlock.js.map +1 -0
- package/lib/module/components/VideoFeed.js +31 -16
- package/lib/module/components/VideoFeed.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/StoryBlockSource.js +2 -0
- package/lib/module/models/StoryBlockSource.js.map +1 -0
- package/lib/typescript/components/FWStoryBlock.d.ts +2 -0
- package/lib/typescript/components/StoryBlock.d.ts +42 -0
- package/lib/typescript/index.d.ts +3 -1
- package/lib/typescript/models/StoryBlockSource.d.ts +1 -0
- package/package.json +1 -1
- package/react-native-firework-sdk.podspec +1 -1
- package/src/components/FWStoryBlock.tsx +10 -0
- package/src/components/StoryBlock.tsx +180 -0
- package/src/components/VideoFeed.tsx +30 -23
- package/src/index.tsx +4 -0
- package/src/models/StoryBlockSource.ts +5 -0
|
@@ -3,11 +3,12 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { Platform } from 'react-native';
|
|
6
7
|
import { findNodeHandle, UIManager } from 'react-native';
|
|
7
|
-
import FWLoggerUtil from '../utils/FWLoggerUtil';
|
|
8
8
|
import FireworkSDK from '../FireworkSDK';
|
|
9
9
|
import { FWEventName } from '../models/FWEventName';
|
|
10
10
|
import { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';
|
|
11
|
+
import FWLoggerUtil from '../utils/FWLoggerUtil';
|
|
11
12
|
import FWVideoFeed from './FWVideoFeed';
|
|
12
13
|
const NativeComponentName = 'FWVideoFeed';
|
|
13
14
|
export default class VideoFeed extends React.Component {
|
|
@@ -21,24 +22,39 @@ export default class VideoFeed extends React.Component {
|
|
|
21
22
|
_defineProperty(this, "refresh", () => {
|
|
22
23
|
FWLoggerUtil.log(`VideoFeed refresh ${JSON.stringify(this.props)}`);
|
|
23
24
|
const nativeNodeHandle = findNodeHandle(this.nativeComponentRef.current);
|
|
24
|
-
|
|
25
|
+
let commandId = UIManager.getViewManagerConfig(NativeComponentName).Commands.refresh;
|
|
26
|
+
|
|
27
|
+
if (Platform.OS === 'android') {
|
|
28
|
+
commandId = commandId.toString();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeNodeHandle), commandId, []);
|
|
25
32
|
});
|
|
26
33
|
|
|
27
34
|
_defineProperty(this, "_onVideoFeedLoadFinished", event => {
|
|
28
35
|
FWLoggerUtil.log(`VideoFeed _onVideoFeedLoadFinished ${JSON.stringify(event.nativeEvent)}`);
|
|
36
|
+
const {
|
|
37
|
+
onVideoFeedLoadFinished
|
|
38
|
+
} = this.props;
|
|
29
39
|
const {
|
|
30
40
|
name,
|
|
31
41
|
reason
|
|
32
42
|
} = event.nativeEvent;
|
|
33
43
|
|
|
34
|
-
if (
|
|
44
|
+
if (onVideoFeedLoadFinished) {
|
|
35
45
|
if (name) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
if (reason) {
|
|
47
|
+
onVideoFeedLoadFinished({
|
|
48
|
+
name,
|
|
49
|
+
reason
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
onVideoFeedLoadFinished({
|
|
53
|
+
name
|
|
54
|
+
});
|
|
55
|
+
}
|
|
40
56
|
} else {
|
|
41
|
-
|
|
57
|
+
onVideoFeedLoadFinished();
|
|
42
58
|
}
|
|
43
59
|
}
|
|
44
60
|
});
|
|
@@ -152,17 +168,16 @@ export default class VideoFeed extends React.Component {
|
|
|
152
168
|
} = this.props;
|
|
153
169
|
|
|
154
170
|
if (!videoFeedConfiguration) {
|
|
155
|
-
return
|
|
171
|
+
return videoFeedConfiguration;
|
|
156
172
|
}
|
|
157
173
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
174
|
+
if (videoFeedConfiguration.gridColumns && Math.floor(videoFeedConfiguration.gridColumns) !== videoFeedConfiguration.gridColumns) {
|
|
175
|
+
return { ...videoFeedConfiguration,
|
|
176
|
+
gridColumns: Math.floor(videoFeedConfiguration.gridColumns)
|
|
177
|
+
};
|
|
178
|
+
} else {
|
|
179
|
+
return videoFeedConfiguration;
|
|
163
180
|
}
|
|
164
|
-
|
|
165
|
-
return resultFeedConfiguration;
|
|
166
181
|
}
|
|
167
182
|
|
|
168
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["VideoFeed.tsx"],"names":["React","findNodeHandle","UIManager","FWLoggerUtil","FireworkSDK","FWEventName","FireworkSDKModuleEventEmitter","FWVideoFeed","NativeComponentName","VideoFeed","Component","createRef","log","JSON","stringify","props","nativeNodeHandle","nativeComponentRef","current","dispatchViewManagerCommand","getViewManagerConfig","Commands","refresh","event","nativeEvent","name","reason","onVideoFeedLoadFinished","componentDidMount","subscriptionOfShareBaseURLUpdated","addListener","ShareBaseURLUpdated","setState","subscriptions","push","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","componentWillUnmount","forEach","value","remove","render","source","channel","playlist","playlistGroup","mode","videoFeedConfiguration","_getVideoFeedConfiguration","titleHidden","title","hidden","titlePosition","customLayoutName","shareBaseURL","getInstance","adBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","dynamicContentParametersString","_generateDynamicContentParametersString","enableAutoplay","gridColumns","key","_onVideoFeedLoadFinished","Object","assign","style","zIndex","dynamicContentParameters","resultString","sortedKeyList","keys","sort","valueString","join","length","undefined","resultFeedConfiguration","Math","floor"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAEEC,cAFF,EAIEC,SAJF,QAMO,cANP;AAOA,OAAOC,YAAP,MAAyB,uBAAzB;AAEA,OAAOC,WAAP,MAAwB,gBAAxB;AAEA,SAASC,WAAT,QAA4B,uBAA5B;AAIA,SAASC,6BAAT,QAA8C,8BAA9C;AACA,OAAOC,WAAP,MAAwB,eAAxB;AAoDA,MAAMC,mBAAmB,GAAG,aAA5B;AAEA,eAAe,MAAMC,SAAN,SAAwBT,KAAK,CAACU,SAA9B,CAAyD;AAAA;AAAA;;AAAA,6DAKjDV,KAAK,CAACW,SAAN,EALiD;;AAAA,2CAO/B,EAP+B;;AAAA,qCAYrD,MAAM;AACrBR,MAAAA,YAAY,CAACS,GAAb,CAAkB,qBAAoBC,IAAI,CAACC,SAAL,CAAe,KAAKC,KAApB,CAA2B,EAAjE;AAEA,YAAMC,gBAAgB,GAAGf,cAAc,CAAC,KAAKgB,kBAAL,CAAwBC,OAAzB,CAAvC;AAEAhB,MAAAA,SAAS,CAACiB,0BAAV,CACElB,cAAc,CAACe,gBAAD,CADhB,EAEEd,SAAS,CAACkB,oBAAV,CAA+BZ,mBAA/B,EAAoDa,QAApD,CAA6DC,OAF/D,EAGE,EAHF;AAKD,KAtBqE;;AAAA,sDAyBpEC,KADiC,IAE9B;AACHpB,MAAAA,YAAY,CAACS,GAAb,CACG,sCAAqCC,IAAI,CAACC,SAAL,CAAeS,KAAK,CAACC,WAArB,CAAkC,EAD1E;AAIA,YAAM;AAAEC,QAAAA,IAAF;AAAQC,QAAAA;AAAR,UAAmBH,KAAK,CAACC,WAA/B;;AAEA,UAAI,KAAKT,KAAL,CAAWY,uBAAf,EAAwC;AACtC,YAAIF,IAAJ,EA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GAAX,IAAkBQ,aAAlB,EAAiC;AAC/B,YAAMpC,KAAK,GAAGkC,wBAAwB,CAACN,GAAD,CAAtC;AACA,YAAMW,WAAW,GAAGvC,KAAK,CAACwC,IAAN,CAAW,GAAX,CAApB;;AACA,UAAIL,YAAY,CAACM,MAAb,GAAsB,CAA1B,EAA6B;AAC3BN,QAAAA,YAAY,IAAI,GAAhB;AACD;;AAEDA,MAAAA,YAAY,IAAK,GAAEP,GAAI,IAAGW,WAAY,EAAtC;AACD;;AAED,WAAOJ,YAAP;AACD;;AAEO1B,EAAAA,0BAA0B,GAAuC;AACvE,UAAM;AAAED,MAAAA;AAAF,QAA6B,KAAKhC,KAAxC;;AACA,QAAI,CAACgC,sBAAL,EAA6B;AAC3B,aAAOkC,SAAP;AACD;;AAED,QAAIC,uBAA+C,GAAG,EACpD,GAAGnC;AADiD,KAAtD;;AAGA,QAAImC,uBAAuB,CAAChB,WAA5B,EAAyC;AACvCgB,MAAAA,uBAAuB,CAAChB,WAAxB,GAAsCiB,IAAI,CAACC,KAAL,CACpCF,uBAAuB,CAAChB,WADY,CAAtC;AAGD;;AACD,WAAOgB,uBAAP;AACD;;AAzKqE;;gBAAnDzE,S,kBACG;AACpBqC,EAAAA,IAAI,EAAE;AADc,C","sourcesContent":["import React from 'react';\n\nimport type { NativeSyntheticEvent, TargetedEvent } from 'react-native';\nimport {\n EmitterSubscription,\n findNodeHandle,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type VideoFeedConfiguration from '../models/VideoFeedConfiguration';\nimport type { VideoFeedSource } from '../models/VideoFeedSource';\nimport type VideoPlayerConfiguration from '../models/VideoPlayerConfiguration';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWVideoFeed from './FWVideoFeed';\n\nexport type VideoFeedMode = 'row' | 'column' | 'grid';\n\nexport interface IVideoFeedProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of five available video feed sources.\n */\n source: VideoFeedSource;\n /**\n * Channel id of the feed. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the feed. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * PlaylistGroup id of the feed. Required when the source is set as playlistGroup.\n */\n playlistGroup?: string;\n /**\n * The dynamic content parameters of the feed. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * One of three available display modes. Defaults to row.\n */\n mode?: VideoFeedMode;\n /**\n * Configuration of the feed.\n */\n videoFeedConfiguration?: VideoFeedConfiguration;\n /**\n * Configuration of the player.\n */\n videoPlayerConfiguration?: VideoPlayerConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onVideoFeedLoadFinished?: (error?: FWError) => void;\n}\n\ninterface VideoFeedLoadFinishedEvent extends TargetedEvent {\n name: string;\n reason?: string | null;\n}\n\nconst NativeComponentName = 'FWVideoFeed';\n\nexport default class VideoFeed extends React.Component<IVideoFeedProps> {\n static defaultProps = {\n mode: 'row',\n };\n\n nativeComponentRef = React.createRef<any>();\n\n subscriptions: EmitterSubscription[] = [];\n\n /**\n * Force refreshing the video feed.\n */\n public refresh = () => {\n FWLoggerUtil.log(`VideoFeed refresh ${JSON.stringify(this.props)}`);\n\n const nativeNodeHandle = findNodeHandle(this.nativeComponentRef.current);\n\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(nativeNodeHandle),\n UIManager.getViewManagerConfig(NativeComponentName).Commands.refresh,\n []\n );\n };\n\n private _onVideoFeedLoadFinished = (\n event: NativeSyntheticEvent<VideoFeedLoadFinishedEvent>\n ) => {\n FWLoggerUtil.log(\n `VideoFeed _onVideoFeedLoadFinished ${JSON.stringify(event.nativeEvent)}`\n );\n\n const { name, reason } = event.nativeEvent;\n\n if (this.props.onVideoFeedLoadFinished) {\n if (name) {\n this.props.onVideoFeedLoadFinished({ name, reason });\n } else {\n this.props.onVideoFeedLoadFinished();\n }\n }\n };\n\n componentDidMount() {\n FWLoggerUtil.log(\n `VideoFeed componentDidMount ${JSON.stringify(this.props)}`\n );\n\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');\n this.setState({});\n }\n );\n this.subscriptions.push(subscriptionOfShareBaseURLUpdated);\n\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');\n this.setState({});\n }\n );\n this.subscriptions.push(subscriptionOfAdBadgeConfigurationUpdated);\n }\n\n componentWillUnmount() {\n FWLoggerUtil.log(\n `VideoFeed componentWillUnmount ${JSON.stringify(this.props)}`\n );\n\n this.subscriptions.forEach((value) => {\n value.remove();\n });\n\n this.subscriptions = [];\n }\n\n render() {\n FWLoggerUtil.log(`VideoFeed render ${JSON.stringify(this.props)}`);\n\n const {\n source,\n channel = '',\n playlist = '',\n playlistGroup = '',\n mode = 'row',\n } = this.props;\n const videoFeedConfiguration = this._getVideoFeedConfiguration();\n const titleHidden = videoFeedConfiguration?.title?.hidden ?? false;\n const titlePosition = videoFeedConfiguration?.titlePosition ?? 'nested';\n const customLayoutName = videoFeedConfiguration?.customLayoutName ?? '';\n const shareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().adBadgeConfiguration ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const dynamicContentParametersString =\n this._generateDynamicContentParametersString();\n const enableAutoplay = videoFeedConfiguration?.enableAutoplay ?? false;\n const gridColumns = videoFeedConfiguration?.gridColumns ?? 2;\n\n let key = `source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_playlistGroup:${playlistGroup}`;\n key += `_mode:${mode}`;\n key += `_titleHidden:${titleHidden}`;\n key += `_titlePosition:${titlePosition}`;\n key += `_customLayoutName:${customLayoutName}`;\n key += `_shareBaseURL:${shareBaseURL}`;\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_enableAutoplay:${enableAutoplay}`;\n key += `_gridColumns:${gridColumns}`;\n\n return (\n <FWVideoFeed\n key={key}\n {...this.props}\n ref={this.nativeComponentRef}\n onVideoFeedLoadFinished={this._onVideoFeedLoadFinished}\n mode={mode}\n style={Object.assign({}, this.props.style, { zIndex: -1 })}\n />\n );\n }\n\n private _generateDynamicContentParametersString(): string {\n const { dynamicContentParameters } = this.props;\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 private _getVideoFeedConfiguration(): VideoFeedConfiguration | undefined {\n const { videoFeedConfiguration } = this.props;\n if (!videoFeedConfiguration) {\n return undefined;\n }\n\n let resultFeedConfiguration: VideoFeedConfiguration = {\n ...videoFeedConfiguration,\n };\n if (resultFeedConfiguration.gridColumns) {\n resultFeedConfiguration.gridColumns = Math.floor(\n resultFeedConfiguration.gridColumns!\n );\n }\n return resultFeedConfiguration;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["VideoFeed.tsx"],"names":["React","Platform","findNodeHandle","UIManager","FireworkSDK","FWEventName","FireworkSDKModuleEventEmitter","FWLoggerUtil","FWVideoFeed","NativeComponentName","VideoFeed","Component","createRef","log","JSON","stringify","props","nativeNodeHandle","nativeComponentRef","current","commandId","getViewManagerConfig","Commands","refresh","OS","toString","dispatchViewManagerCommand","event","nativeEvent","onVideoFeedLoadFinished","name","reason","componentDidMount","subscriptionOfShareBaseURLUpdated","addListener","ShareBaseURLUpdated","setState","subscriptions","push","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","componentWillUnmount","forEach","value","remove","render","source","channel","playlist","playlistGroup","mode","videoFeedConfiguration","_getVideoFeedConfiguration","titleHidden","title","hidden","titlePosition","customLayoutName","shareBaseURL","getInstance","adBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","dynamicContentParametersString","_generateDynamicContentParametersString","enableAutoplay","gridColumns","key","_onVideoFeedLoadFinished","Object","assign","style","zIndex","dynamicContentParameters","resultString","sortedKeyList","keys","sort","valueString","join","length","Math","floor"],"mappings":";;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAA+BC,QAA/B,QAA+C,cAA/C;AACA,SAEEC,cAFF,EAIEC,SAJF,QAMO,cANP;AAQA,OAAOC,WAAP,MAAwB,gBAAxB;AAEA,SAASC,WAAT,QAA4B,uBAA5B;AAIA,SAASC,6BAAT,QAA8C,8BAA9C;AACA,OAAOC,YAAP,MAAyB,uBAAzB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AA+CA,MAAMC,mBAAmB,GAAG,aAA5B;AAEA,eAAe,MAAMC,SAAN,SAAwBV,KAAK,CAACW,SAA9B,CAAyD;AAAA;AAAA;;AAAA,6DAKjDX,KAAK,CAACY,SAAN,EALiD;;AAAA,2CAO/B,EAP+B;;AAAA,qCAYrD,MAAM;AACrBL,MAAAA,YAAY,CAACM,GAAb,CAAkB,qBAAoBC,IAAI,CAACC,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ACvE,UAAM;AAAED,MAAAA;AAAF,QAA6B,KAAKnC,KAAxC;;AACA,QAAI,CAACmC,sBAAL,EAA6B;AAC3B,aAAOA,sBAAP;AACD;;AAED,QACEA,sBAAsB,CAACmB,WAAvB,IACAe,IAAI,CAACC,KAAL,CAAWnC,sBAAsB,CAACmB,WAAlC,MACEnB,sBAAsB,CAACmB,WAH3B,EAIE;AACA,aAAO,EACL,GAAGnB,sBADE;AAELmB,QAAAA,WAAW,EAAEe,IAAI,CAACC,KAAL,CAAWnC,sBAAsB,CAACmB,WAAlC;AAFR,OAAP;AAID,KATD,MASO;AACL,aAAOnB,sBAAP;AACD;AACF;;AArLqE;;gBAAnDzC,S,kBACG;AACpBwC,EAAAA,IAAI,EAAE;AADc,C","sourcesContent":["import React from 'react';\n\nimport { NativeSyntheticEvent, Platform } from 'react-native';\nimport {\n EmitterSubscription,\n findNodeHandle,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type VideoFeedConfiguration from '../models/VideoFeedConfiguration';\nimport type { VideoFeedSource } from '../models/VideoFeedSource';\nimport type VideoPlayerConfiguration from '../models/VideoPlayerConfiguration';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\nimport FWVideoFeed from './FWVideoFeed';\n\nexport type VideoFeedMode = 'row' | 'column' | 'grid';\n\nexport interface IVideoFeedProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of five available video feed sources.\n */\n source: VideoFeedSource;\n /**\n * Channel id of the feed. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the feed. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * PlaylistGroup id of the feed. Required when the source is set as playlistGroup.\n */\n playlistGroup?: string;\n /**\n * The dynamic content parameters of the feed. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * One of three available display modes. Defaults to row.\n */\n mode?: VideoFeedMode;\n /**\n * Configuration of the feed.\n */\n videoFeedConfiguration?: VideoFeedConfiguration;\n /**\n * Configuration of the player.\n */\n videoPlayerConfiguration?: VideoPlayerConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onVideoFeedLoadFinished?: (error?: FWError) => void;\n}\n\nconst NativeComponentName = 'FWVideoFeed';\n\nexport default class VideoFeed extends React.Component<IVideoFeedProps> {\n static defaultProps = {\n mode: 'row',\n };\n\n nativeComponentRef = React.createRef<any>();\n\n subscriptions: EmitterSubscription[] = [];\n\n /**\n * Force refreshing the video feed.\n */\n public refresh = () => {\n FWLoggerUtil.log(`VideoFeed refresh ${JSON.stringify(this.props)}`);\n\n const nativeNodeHandle = findNodeHandle(this.nativeComponentRef.current);\n\n let commandId: string | number =\n UIManager.getViewManagerConfig(NativeComponentName).Commands.refresh;\n if (Platform.OS === 'android') {\n commandId = commandId.toString();\n }\n\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(nativeNodeHandle),\n commandId,\n []\n );\n };\n\n private _onVideoFeedLoadFinished = (event: NativeSyntheticEvent<any>) => {\n FWLoggerUtil.log(\n `VideoFeed _onVideoFeedLoadFinished ${JSON.stringify(event.nativeEvent)}`\n );\n const { onVideoFeedLoadFinished } = this.props;\n\n const { name, reason } = event.nativeEvent;\n\n if (onVideoFeedLoadFinished) {\n if (name) {\n if (reason) {\n onVideoFeedLoadFinished({ name, reason });\n } else {\n onVideoFeedLoadFinished({ name });\n }\n } else {\n onVideoFeedLoadFinished();\n }\n }\n };\n\n componentDidMount() {\n FWLoggerUtil.log(\n `VideoFeed componentDidMount ${JSON.stringify(this.props)}`\n );\n\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');\n this.setState({});\n }\n );\n this.subscriptions.push(subscriptionOfShareBaseURLUpdated);\n\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');\n this.setState({});\n }\n );\n this.subscriptions.push(subscriptionOfAdBadgeConfigurationUpdated);\n }\n\n componentWillUnmount() {\n FWLoggerUtil.log(\n `VideoFeed componentWillUnmount ${JSON.stringify(this.props)}`\n );\n\n this.subscriptions.forEach((value) => {\n value.remove();\n });\n\n this.subscriptions = [];\n }\n\n render() {\n FWLoggerUtil.log(`VideoFeed render ${JSON.stringify(this.props)}`);\n\n const {\n source,\n channel = '',\n playlist = '',\n playlistGroup = '',\n mode = 'row',\n } = this.props;\n const videoFeedConfiguration = this._getVideoFeedConfiguration();\n const titleHidden = videoFeedConfiguration?.title?.hidden ?? false;\n const titlePosition = videoFeedConfiguration?.titlePosition ?? 'nested';\n const customLayoutName = videoFeedConfiguration?.customLayoutName ?? '';\n const shareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().adBadgeConfiguration ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const dynamicContentParametersString =\n this._generateDynamicContentParametersString();\n const enableAutoplay = videoFeedConfiguration?.enableAutoplay ?? false;\n const gridColumns = videoFeedConfiguration?.gridColumns ?? 2;\n\n let key = `source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_playlistGroup:${playlistGroup}`;\n key += `_mode:${mode}`;\n key += `_titleHidden:${titleHidden}`;\n key += `_titlePosition:${titlePosition}`;\n key += `_customLayoutName:${customLayoutName}`;\n key += `_shareBaseURL:${shareBaseURL}`;\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_enableAutoplay:${enableAutoplay}`;\n key += `_gridColumns:${gridColumns}`;\n\n return (\n <FWVideoFeed\n key={key}\n {...this.props}\n ref={this.nativeComponentRef}\n onVideoFeedLoadFinished={this._onVideoFeedLoadFinished}\n mode={mode}\n style={Object.assign({}, this.props.style, { zIndex: -1 })}\n />\n );\n }\n\n private _generateDynamicContentParametersString(): string {\n const { dynamicContentParameters } = this.props;\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 private _getVideoFeedConfiguration(): VideoFeedConfiguration | undefined {\n const { videoFeedConfiguration } = this.props;\n if (!videoFeedConfiguration) {\n return videoFeedConfiguration;\n }\n\n if (\n videoFeedConfiguration.gridColumns &&\n Math.floor(videoFeedConfiguration.gridColumns!) !==\n videoFeedConfiguration.gridColumns\n ) {\n return {\n ...videoFeedConfiguration,\n gridColumns: Math.floor(videoFeedConfiguration.gridColumns!),\n };\n } else {\n return videoFeedConfiguration;\n }\n }\n}\n"]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import StoryBlock from './components/StoryBlock';
|
|
1
2
|
import VideoFeed from './components/VideoFeed';
|
|
2
3
|
import FireworkSDK from './FireworkSDK';
|
|
3
4
|
import FWNavigator from './FWNavigator';
|
|
@@ -7,5 +8,5 @@ import LiveStreamEventName from './models/LiveStreamEventName';
|
|
|
7
8
|
import VideoPlaybackEventName from './models/VideoPlaybackEventName';
|
|
8
9
|
import VideoShopping from './VideoShopping';
|
|
9
10
|
export default FireworkSDK;
|
|
10
|
-
export { FWNavigator, LiveStream, LiveStreamChatEventName, LiveStreamEventName, VideoFeed, VideoPlaybackEventName, VideoShopping };
|
|
11
|
+
export { FWNavigator, LiveStream, LiveStreamChatEventName, LiveStreamEventName, StoryBlock, VideoFeed, VideoPlaybackEventName, VideoShopping };
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["VideoFeed","FireworkSDK","FWNavigator","LiveStream","LiveStreamChatEventName","LiveStreamEventName","VideoPlaybackEventName","VideoShopping"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["StoryBlock","VideoFeed","FireworkSDK","FWNavigator","LiveStream","LiveStreamChatEventName","LiveStreamEventName","VideoPlaybackEventName","VideoShopping"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,yBAAvB;AAEA,OAAOC,SAAP,MAAsB,wBAAtB;AAQA,OAAOC,WAAP,MAAwB,eAAxB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AAKA,OAAOC,UAAP,MAAuB,cAAvB;AAgBA,OAAOC,uBAAP,MAAoC,kCAApC;AAEA,OAAOC,mBAAP,MAAgC,8BAAhC;AAmBA,OAAOC,sBAAP,MAAmC,iCAAnC;AAeA,OAAOC,aAAP,MAA0B,iBAA1B;AAEA,eAAeN,WAAf;AAEA,SAcEC,WAdF,EAgBEC,UAhBF,EAkBEC,uBAlBF,EAqBEC,mBArBF,EAiCEN,UAjCF,EAqCEC,SArCF,EAkDEM,sBAlDF,EAwDEC,aAxDF","sourcesContent":["import StoryBlock from './components/StoryBlock';\nimport type { IVideoFeedProps, VideoFeedMode } from './components/VideoFeed';\nimport VideoFeed from './components/VideoFeed';\nimport type {\n CustomCTAClickCallback,\n CustomCTALinkContentRender,\n SDKInitCallback,\n VideoFeedClickCallback,\n VideoPlaybackCallback,\n} from './FireworkSDK';\nimport FireworkSDK from './FireworkSDK';\nimport FWNavigator from './FWNavigator';\nimport type {\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n} from './LiveStream';\nimport LiveStream from './LiveStream';\nimport type AdBadgeConfiguration from './models/AdBadgeConfiguration';\nimport type { AdBadgeTextType } from './models/AdBadgeConfiguration';\nimport type AddToCartResult from './models/AddToCartResult';\nimport type FeedItemDetails from './models/FeedItemDetails';\nimport type FWError from './models/FWError';\nimport type {\n AddToCartEvent,\n CustomCTAClickEvent,\n LiveStreamChatEvent,\n LiveStreamEvent,\n SDKInitEvent,\n UpdateProductDetailsEvent,\n VideoPlaybackEvent,\n WillDisplayProductEvent,\n} from './models/FWEvents';\nimport LiveStreamChatEventName from './models/LiveStreamChatEventName';\nimport type LiveStreamEventDetails from './models/LiveStreamEventDetails';\nimport LiveStreamEventName from './models/LiveStreamEventName';\nimport type LiveStreamMessageDetails from './models/LiveStreamMessageDetails';\nimport type { NewNativeContainerProps } from './models/NewNativeContainerProps';\nimport type Product from './models/Product';\nimport type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';\nimport type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';\nimport type ProductUnit from './models/ProductUnit';\nimport type { ProductPrice, ProductUnitOption } from './models/ProductUnit';\nimport type { StoryBlockSource } from './models/StoryBlockSource';\nimport type VideoFeedConfiguration from './models/VideoFeedConfiguration';\nimport type {\n VideoFeedContentPadding,\n VideoFeedPlayIconConfiguration,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n} from './models/VideoFeedConfiguration';\nimport type { VideoFeedSource } from './models/VideoFeedSource';\nimport type VideoPlaybackDetails from './models/VideoPlaybackDetails';\nimport type { VideoPlayerSize } from './models/VideoPlaybackDetails';\nimport VideoPlaybackEventName from './models/VideoPlaybackEventName';\nimport type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';\nimport type {\n VideoLaunchBehavior,\n VideoPlayerCompleteAction,\n VideoPlayerCTAStyle,\n VideoPlayerStyle,\n} from './models/VideoPlayerConfiguration';\nimport type {\n AddToCartCallback,\n ClickCartIconCallback,\n CustomClickCartIconCallback,\n UpdateProductDetailsCallback,\n WillDisplayProductCallback,\n} from './VideoShopping';\nimport VideoShopping from './VideoShopping';\n\nexport default FireworkSDK;\n\nexport {\n AdBadgeConfiguration,\n AdBadgeTextType,\n AddToCartButtonConfiguration,\n AddToCartCallback,\n AddToCartEvent,\n AddToCartResult,\n ClickCartIconCallback,\n CustomClickCartIconCallback,\n CustomCTAClickCallback,\n CustomCTAClickEvent,\n CustomCTALinkContentRender,\n FeedItemDetails,\n FWError,\n FWNavigator,\n IVideoFeedProps,\n LiveStream,\n LiveStreamChatEvent,\n LiveStreamChatEventName,\n LiveStreamEvent,\n LiveStreamEventDetails,\n LiveStreamEventName,\n LiveStreamMessageDetails,\n NewNativeContainerProps,\n onLiveStreamChatEventCallback,\n onLiveStreamEventCallback,\n Product,\n ProductInfoViewConfiguration,\n ProductPrice,\n ProductUnit,\n ProductUnitOption,\n SDKInitCallback,\n SDKInitEvent,\n StoryBlock,\n StoryBlockSource,\n UpdateProductDetailsCallback,\n UpdateProductDetailsEvent,\n VideoFeed,\n VideoFeedClickCallback,\n VideoFeedConfiguration,\n VideoFeedContentPadding,\n VideoFeedMode,\n VideoFeedPlayIconConfiguration,\n VideoFeedSource,\n VideoFeedTitleConfiguration,\n VideoFeedTitlePosition,\n VideoLaunchBehavior,\n VideoPlaybackCallback,\n VideoPlaybackDetails,\n VideoPlaybackEvent,\n VideoPlaybackEventName,\n VideoPlayerCompleteAction,\n VideoPlayerConfiguration,\n VideoPlayerCTAStyle,\n VideoPlayerSize,\n VideoPlayerStyle,\n VideoShopping,\n WillDisplayProductCallback,\n WillDisplayProductEvent,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { EmitterSubscription, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type FWError from '../models/FWError';
|
|
4
|
+
import type { StoryBlockSource } from '../models/StoryBlockSource';
|
|
5
|
+
export interface IStoryBlockProps {
|
|
6
|
+
/**
|
|
7
|
+
* Standard React Native View Style.
|
|
8
|
+
*/
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
/**
|
|
11
|
+
* One of four available story block sources.
|
|
12
|
+
*/
|
|
13
|
+
source: StoryBlockSource;
|
|
14
|
+
/**
|
|
15
|
+
* Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.
|
|
16
|
+
*/
|
|
17
|
+
channel?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.
|
|
20
|
+
*/
|
|
21
|
+
playlist?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The dynamic content parameters of the story block. Required when the source is set as dynamicContent.
|
|
24
|
+
*/
|
|
25
|
+
dynamicContentParameters?: {
|
|
26
|
+
[key: string]: string[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The feed loading result callback. It means loading successfully when error equals to undefined.
|
|
30
|
+
*/
|
|
31
|
+
onStoryBlockLoadFinished?: (error?: FWError) => void;
|
|
32
|
+
}
|
|
33
|
+
export default class StoryBlock extends React.Component<IStoryBlockProps> {
|
|
34
|
+
nativeComponentRef: React.RefObject<any>;
|
|
35
|
+
subscriptions: EmitterSubscription[];
|
|
36
|
+
componentDidMount(): void;
|
|
37
|
+
componentWillUnmount(): void;
|
|
38
|
+
render(): JSX.Element;
|
|
39
|
+
private _onStoryBlockLoadFinished;
|
|
40
|
+
private _generateKey;
|
|
41
|
+
private _generateDynamicContentParametersString;
|
|
42
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import StoryBlock from './components/StoryBlock';
|
|
1
2
|
import type { IVideoFeedProps, VideoFeedMode } from './components/VideoFeed';
|
|
2
3
|
import VideoFeed from './components/VideoFeed';
|
|
3
4
|
import type { CustomCTAClickCallback, CustomCTALinkContentRender, SDKInitCallback, VideoFeedClickCallback, VideoPlaybackCallback } from './FireworkSDK';
|
|
@@ -21,6 +22,7 @@ import type ProductInfoViewConfiguration from './models/ProductInfoViewConfigura
|
|
|
21
22
|
import type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';
|
|
22
23
|
import type ProductUnit from './models/ProductUnit';
|
|
23
24
|
import type { ProductPrice, ProductUnitOption } from './models/ProductUnit';
|
|
25
|
+
import type { StoryBlockSource } from './models/StoryBlockSource';
|
|
24
26
|
import type VideoFeedConfiguration from './models/VideoFeedConfiguration';
|
|
25
27
|
import type { VideoFeedContentPadding, VideoFeedPlayIconConfiguration, VideoFeedTitleConfiguration, VideoFeedTitlePosition } from './models/VideoFeedConfiguration';
|
|
26
28
|
import type { VideoFeedSource } from './models/VideoFeedSource';
|
|
@@ -32,4 +34,4 @@ import type { VideoLaunchBehavior, VideoPlayerCompleteAction, VideoPlayerCTAStyl
|
|
|
32
34
|
import type { AddToCartCallback, ClickCartIconCallback, CustomClickCartIconCallback, UpdateProductDetailsCallback, WillDisplayProductCallback } from './VideoShopping';
|
|
33
35
|
import VideoShopping from './VideoShopping';
|
|
34
36
|
export default FireworkSDK;
|
|
35
|
-
export { AdBadgeConfiguration, AdBadgeTextType, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, ClickCartIconCallback, CustomClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, CustomCTALinkContentRender, FeedItemDetails, FWError, FWNavigator, IVideoFeedProps, LiveStream, LiveStreamChatEvent, LiveStreamChatEventName, LiveStreamEvent, LiveStreamEventDetails, LiveStreamEventName, LiveStreamMessageDetails, NewNativeContainerProps, onLiveStreamChatEventCallback, onLiveStreamEventCallback, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, ProductUnitOption, SDKInitCallback, SDKInitEvent, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedContentPadding, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoLaunchBehavior, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
|
|
37
|
+
export { AdBadgeConfiguration, AdBadgeTextType, AddToCartButtonConfiguration, AddToCartCallback, AddToCartEvent, AddToCartResult, ClickCartIconCallback, CustomClickCartIconCallback, CustomCTAClickCallback, CustomCTAClickEvent, CustomCTALinkContentRender, FeedItemDetails, FWError, FWNavigator, IVideoFeedProps, LiveStream, LiveStreamChatEvent, LiveStreamChatEventName, LiveStreamEvent, LiveStreamEventDetails, LiveStreamEventName, LiveStreamMessageDetails, NewNativeContainerProps, onLiveStreamChatEventCallback, onLiveStreamEventCallback, Product, ProductInfoViewConfiguration, ProductPrice, ProductUnit, ProductUnitOption, SDKInitCallback, SDKInitEvent, StoryBlock, StoryBlockSource, UpdateProductDetailsCallback, UpdateProductDetailsEvent, VideoFeed, VideoFeedClickCallback, VideoFeedConfiguration, VideoFeedContentPadding, VideoFeedMode, VideoFeedPlayIconConfiguration, VideoFeedSource, VideoFeedTitleConfiguration, VideoFeedTitlePosition, VideoLaunchBehavior, VideoPlaybackCallback, VideoPlaybackDetails, VideoPlaybackEvent, VideoPlaybackEventName, VideoPlayerCompleteAction, VideoPlayerConfiguration, VideoPlayerCTAStyle, VideoPlayerSize, VideoPlayerStyle, VideoShopping, WillDisplayProductCallback, WillDisplayProductEvent, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type StoryBlockSource = 'discover' | 'channel' | 'playlist' | 'dynamicContent';
|
package/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { requireNativeComponent, UIManager } from 'react-native';
|
|
2
|
+
import { LINKING_ERROR } from '../constants/FWErrorMessage';
|
|
3
|
+
const NativeComponentName = 'FWStoryBlock';
|
|
4
|
+
const FWStoryBlock =
|
|
5
|
+
UIManager.getViewManagerConfig(NativeComponentName) != null
|
|
6
|
+
? requireNativeComponent<any>(NativeComponentName)
|
|
7
|
+
: () => {
|
|
8
|
+
throw new Error(LINKING_ERROR);
|
|
9
|
+
};
|
|
10
|
+
export default FWStoryBlock;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
EmitterSubscription,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
StyleProp,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
import FireworkSDK from '../FireworkSDK';
|
|
11
|
+
import type FWError from '../models/FWError';
|
|
12
|
+
import { FWEventName } from '../models/FWEventName';
|
|
13
|
+
import type { StoryBlockSource } from '../models/StoryBlockSource';
|
|
14
|
+
import { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';
|
|
15
|
+
import FWLoggerUtil from '../utils/FWLoggerUtil';
|
|
16
|
+
import FWStoryBlock from './FWStoryBlock';
|
|
17
|
+
import { findNodeHandle, UIManager, Platform } from 'react-native';
|
|
18
|
+
|
|
19
|
+
const NativeComponentName = 'FWStoryBlock';
|
|
20
|
+
|
|
21
|
+
const createFragment = (viewId: any) => {
|
|
22
|
+
if (Platform.OS === 'android') {
|
|
23
|
+
UIManager.dispatchViewManagerCommand(
|
|
24
|
+
viewId,
|
|
25
|
+
UIManager.getViewManagerConfig(
|
|
26
|
+
NativeComponentName
|
|
27
|
+
).Commands.create.toString(),
|
|
28
|
+
[viewId]
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export interface IStoryBlockProps {
|
|
34
|
+
/**
|
|
35
|
+
* Standard React Native View Style.
|
|
36
|
+
*/
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
/**
|
|
39
|
+
* One of four available story block sources.
|
|
40
|
+
*/
|
|
41
|
+
source: StoryBlockSource;
|
|
42
|
+
/**
|
|
43
|
+
* Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.
|
|
44
|
+
*/
|
|
45
|
+
channel?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.
|
|
48
|
+
*/
|
|
49
|
+
playlist?: string;
|
|
50
|
+
/**
|
|
51
|
+
* The dynamic content parameters of the story block. Required when the source is set as dynamicContent.
|
|
52
|
+
*/
|
|
53
|
+
dynamicContentParameters?: { [key: string]: string[] };
|
|
54
|
+
/**
|
|
55
|
+
* The feed loading result callback. It means loading successfully when error equals to undefined.
|
|
56
|
+
*/
|
|
57
|
+
onStoryBlockLoadFinished?: (error?: FWError) => void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default class StoryBlock extends React.Component<IStoryBlockProps> {
|
|
61
|
+
nativeComponentRef = React.createRef<any>();
|
|
62
|
+
|
|
63
|
+
subscriptions: EmitterSubscription[] = [];
|
|
64
|
+
componentDidMount() {
|
|
65
|
+
const subscriptionOfShareBaseURLUpdated =
|
|
66
|
+
FireworkSDKModuleEventEmitter.addListener(
|
|
67
|
+
FWEventName.ShareBaseURLUpdated,
|
|
68
|
+
() => {
|
|
69
|
+
this.setState({});
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
this.subscriptions.push(subscriptionOfShareBaseURLUpdated);
|
|
73
|
+
|
|
74
|
+
const subscriptionOfAdBadgeConfigurationUpdated =
|
|
75
|
+
FireworkSDKModuleEventEmitter.addListener(
|
|
76
|
+
FWEventName.AdBadgeConfigurationUpdated,
|
|
77
|
+
() => {
|
|
78
|
+
this.setState({});
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
this.subscriptions.push(subscriptionOfAdBadgeConfigurationUpdated);
|
|
82
|
+
|
|
83
|
+
if (Platform.OS === 'android') {
|
|
84
|
+
const viewId = findNodeHandle(this.nativeComponentRef.current);
|
|
85
|
+
FWLoggerUtil.log(
|
|
86
|
+
`StoryBlock componentDidMount createFragment viewId: ${viewId}`
|
|
87
|
+
);
|
|
88
|
+
createFragment(viewId);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
componentWillUnmount() {
|
|
93
|
+
this.subscriptions.forEach((value) => {
|
|
94
|
+
value.remove();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
this.subscriptions = [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
render() {
|
|
101
|
+
const { style } = this.props;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<FWStoryBlock
|
|
105
|
+
ref={this.nativeComponentRef}
|
|
106
|
+
key={this._generateKey()}
|
|
107
|
+
{...this.props}
|
|
108
|
+
onStoryBlockLoadFinished={this._onStoryBlockLoadFinished}
|
|
109
|
+
style={Object.assign({}, style, { zIndex: -1 })}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private _onStoryBlockLoadFinished = (event: NativeSyntheticEvent<any>) => {
|
|
115
|
+
FWLoggerUtil.log(
|
|
116
|
+
`StoryBlock _onStoryBlockLoadFinished ${event.nativeEvent.name}`
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const { onStoryBlockLoadFinished } = this.props;
|
|
120
|
+
const { name, reason } = event.nativeEvent;
|
|
121
|
+
|
|
122
|
+
if (onStoryBlockLoadFinished) {
|
|
123
|
+
if (name) {
|
|
124
|
+
if (reason) {
|
|
125
|
+
onStoryBlockLoadFinished({ name, reason });
|
|
126
|
+
} else {
|
|
127
|
+
onStoryBlockLoadFinished({ name });
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
onStoryBlockLoadFinished();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
private _generateKey(): string {
|
|
136
|
+
const { source, channel = '', playlist = '' } = this.props;
|
|
137
|
+
|
|
138
|
+
const shareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';
|
|
139
|
+
const adBadgeConfiguration =
|
|
140
|
+
FireworkSDK.getInstance().adBadgeConfiguration ?? {};
|
|
141
|
+
const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';
|
|
142
|
+
const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';
|
|
143
|
+
const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';
|
|
144
|
+
const dynamicContentParametersString =
|
|
145
|
+
this._generateDynamicContentParametersString();
|
|
146
|
+
|
|
147
|
+
let key = `source:${source}`;
|
|
148
|
+
key += `_channel:${channel}`;
|
|
149
|
+
key += `_playlist:${playlist}`;
|
|
150
|
+
key += `_shareBaseURL:${shareBaseURL}`;
|
|
151
|
+
key += `_adBadgeTextType:${adBadgeTextType}`;
|
|
152
|
+
key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;
|
|
153
|
+
key += `_textColorOfAdBadge:${textColorOfAdBadge}`;
|
|
154
|
+
key += `_dynamicContentParameters:${dynamicContentParametersString}`;
|
|
155
|
+
|
|
156
|
+
return key;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private _generateDynamicContentParametersString(): string {
|
|
160
|
+
const { dynamicContentParameters } = this.props;
|
|
161
|
+
|
|
162
|
+
if (!dynamicContentParameters) {
|
|
163
|
+
return '';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let resultString = '';
|
|
167
|
+
const sortedKeyList = Object.keys(dynamicContentParameters).sort();
|
|
168
|
+
for (const key of sortedKeyList) {
|
|
169
|
+
const value = dynamicContentParameters[key];
|
|
170
|
+
const valueString = value.join(',');
|
|
171
|
+
if (resultString.length > 0) {
|
|
172
|
+
resultString += '_';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
resultString += `${key}:${valueString}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return resultString;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { NativeSyntheticEvent, Platform } from 'react-native';
|
|
4
4
|
import {
|
|
5
5
|
EmitterSubscription,
|
|
6
6
|
findNodeHandle,
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
UIManager,
|
|
9
9
|
ViewStyle,
|
|
10
10
|
} from 'react-native';
|
|
11
|
-
import FWLoggerUtil from '../utils/FWLoggerUtil';
|
|
12
11
|
|
|
13
12
|
import FireworkSDK from '../FireworkSDK';
|
|
14
13
|
import type FWError from '../models/FWError';
|
|
@@ -17,6 +16,7 @@ import type VideoFeedConfiguration from '../models/VideoFeedConfiguration';
|
|
|
17
16
|
import type { VideoFeedSource } from '../models/VideoFeedSource';
|
|
18
17
|
import type VideoPlayerConfiguration from '../models/VideoPlayerConfiguration';
|
|
19
18
|
import { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';
|
|
19
|
+
import FWLoggerUtil from '../utils/FWLoggerUtil';
|
|
20
20
|
import FWVideoFeed from './FWVideoFeed';
|
|
21
21
|
|
|
22
22
|
export type VideoFeedMode = 'row' | 'column' | 'grid';
|
|
@@ -64,11 +64,6 @@ export interface IVideoFeedProps {
|
|
|
64
64
|
onVideoFeedLoadFinished?: (error?: FWError) => void;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
interface VideoFeedLoadFinishedEvent extends TargetedEvent {
|
|
68
|
-
name: string;
|
|
69
|
-
reason?: string | null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
67
|
const NativeComponentName = 'FWVideoFeed';
|
|
73
68
|
|
|
74
69
|
export default class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
@@ -88,27 +83,36 @@ export default class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
|
88
83
|
|
|
89
84
|
const nativeNodeHandle = findNodeHandle(this.nativeComponentRef.current);
|
|
90
85
|
|
|
86
|
+
let commandId: string | number =
|
|
87
|
+
UIManager.getViewManagerConfig(NativeComponentName).Commands.refresh;
|
|
88
|
+
if (Platform.OS === 'android') {
|
|
89
|
+
commandId = commandId.toString();
|
|
90
|
+
}
|
|
91
|
+
|
|
91
92
|
UIManager.dispatchViewManagerCommand(
|
|
92
93
|
findNodeHandle(nativeNodeHandle),
|
|
93
|
-
|
|
94
|
+
commandId,
|
|
94
95
|
[]
|
|
95
96
|
);
|
|
96
97
|
};
|
|
97
98
|
|
|
98
|
-
private _onVideoFeedLoadFinished = (
|
|
99
|
-
event: NativeSyntheticEvent<VideoFeedLoadFinishedEvent>
|
|
100
|
-
) => {
|
|
99
|
+
private _onVideoFeedLoadFinished = (event: NativeSyntheticEvent<any>) => {
|
|
101
100
|
FWLoggerUtil.log(
|
|
102
101
|
`VideoFeed _onVideoFeedLoadFinished ${JSON.stringify(event.nativeEvent)}`
|
|
103
102
|
);
|
|
103
|
+
const { onVideoFeedLoadFinished } = this.props;
|
|
104
104
|
|
|
105
105
|
const { name, reason } = event.nativeEvent;
|
|
106
106
|
|
|
107
|
-
if (
|
|
107
|
+
if (onVideoFeedLoadFinished) {
|
|
108
108
|
if (name) {
|
|
109
|
-
|
|
109
|
+
if (reason) {
|
|
110
|
+
onVideoFeedLoadFinished({ name, reason });
|
|
111
|
+
} else {
|
|
112
|
+
onVideoFeedLoadFinished({ name });
|
|
113
|
+
}
|
|
110
114
|
} else {
|
|
111
|
-
|
|
115
|
+
onVideoFeedLoadFinished();
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
};
|
|
@@ -228,17 +232,20 @@ export default class VideoFeed extends React.Component<IVideoFeedProps> {
|
|
|
228
232
|
private _getVideoFeedConfiguration(): VideoFeedConfiguration | undefined {
|
|
229
233
|
const { videoFeedConfiguration } = this.props;
|
|
230
234
|
if (!videoFeedConfiguration) {
|
|
231
|
-
return
|
|
235
|
+
return videoFeedConfiguration;
|
|
232
236
|
}
|
|
233
237
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
if (
|
|
239
|
+
videoFeedConfiguration.gridColumns &&
|
|
240
|
+
Math.floor(videoFeedConfiguration.gridColumns!) !==
|
|
241
|
+
videoFeedConfiguration.gridColumns
|
|
242
|
+
) {
|
|
243
|
+
return {
|
|
244
|
+
...videoFeedConfiguration,
|
|
245
|
+
gridColumns: Math.floor(videoFeedConfiguration.gridColumns!),
|
|
246
|
+
};
|
|
247
|
+
} else {
|
|
248
|
+
return videoFeedConfiguration;
|
|
241
249
|
}
|
|
242
|
-
return resultFeedConfiguration;
|
|
243
250
|
}
|
|
244
251
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import StoryBlock from './components/StoryBlock';
|
|
1
2
|
import type { IVideoFeedProps, VideoFeedMode } from './components/VideoFeed';
|
|
2
3
|
import VideoFeed from './components/VideoFeed';
|
|
3
4
|
import type {
|
|
@@ -39,6 +40,7 @@ import type ProductInfoViewConfiguration from './models/ProductInfoViewConfigura
|
|
|
39
40
|
import type { AddToCartButtonConfiguration } from './models/ProductInfoViewConfiguration';
|
|
40
41
|
import type ProductUnit from './models/ProductUnit';
|
|
41
42
|
import type { ProductPrice, ProductUnitOption } from './models/ProductUnit';
|
|
43
|
+
import type { StoryBlockSource } from './models/StoryBlockSource';
|
|
42
44
|
import type VideoFeedConfiguration from './models/VideoFeedConfiguration';
|
|
43
45
|
import type {
|
|
44
46
|
VideoFeedContentPadding,
|
|
@@ -101,6 +103,8 @@ export {
|
|
|
101
103
|
ProductUnitOption,
|
|
102
104
|
SDKInitCallback,
|
|
103
105
|
SDKInitEvent,
|
|
106
|
+
StoryBlock,
|
|
107
|
+
StoryBlockSource,
|
|
104
108
|
UpdateProductDetailsCallback,
|
|
105
109
|
UpdateProductDetailsEvent,
|
|
106
110
|
VideoFeed,
|