react-native-firework-sdk 2.2.4 → 2.2.5

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.
@@ -6,30 +6,30 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64</string>
9
+ <string>ios-arm64_x86_64-simulator</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>FireworkVideoUI.framework</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
+ <string>x86_64</string>
15
16
  </array>
16
17
  <key>SupportedPlatform</key>
17
18
  <string>ios</string>
19
+ <key>SupportedPlatformVariant</key>
20
+ <string>simulator</string>
18
21
  </dict>
19
22
  <dict>
20
23
  <key>LibraryIdentifier</key>
21
- <string>ios-arm64_x86_64-simulator</string>
24
+ <string>ios-arm64</string>
22
25
  <key>LibraryPath</key>
23
26
  <string>FireworkVideoUI.framework</string>
24
27
  <key>SupportedArchitectures</key>
25
28
  <array>
26
29
  <string>arm64</string>
27
- <string>x86_64</string>
28
30
  </array>
29
31
  <key>SupportedPlatform</key>
30
32
  <string>ios</string>
31
- <key>SupportedPlatformVariant</key>
32
- <string>simulator</string>
33
33
  </dict>
34
34
  </array>
35
35
  <key>CFBundlePackageType</key>
@@ -14,7 +14,7 @@
14
14
  </data>
15
15
  <key>Info.plist</key>
16
16
  <data>
17
- 9WgvClY2mYHKvTCGLV3Nk54g82o=
17
+ P3i/2edTGa9yeKILUEa7IMZfWSg=
18
18
  </data>
19
19
  <key>Modules/FireworkVideoUI.swiftmodule/arm64-apple-ios-simulator.abi.json</key>
20
20
  <data>
@@ -33,72 +33,6 @@ const StoryBlock = (props, forwardedRef) => {
33
33
  const nativeComponentRef = (0, _react.useRef)(null);
34
34
  const [isFullscreenState, setIsFullscreenState] = (0, _react.useState)(false);
35
35
  const [, forceUpdate] = (0, _react.useReducer)(x => x + 1, 0);
36
- (0, _react.useImperativeHandle)(forwardedRef, () => {
37
- const sendCommand = command => {
38
- const nativeNodeHandle = (0, _reactNative.findNodeHandle)(nativeComponentRef.current);
39
-
40
- let commandId = _reactNative.UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
41
-
42
- if (_reactNative.Platform.OS === 'android') {
43
- commandId = commandId.toString();
44
- }
45
-
46
- _reactNative.UIManager.dispatchViewManagerCommand((0, _reactNative.findNodeHandle)(nativeNodeHandle), commandId, []);
47
- };
48
-
49
- return {
50
- play: () => {
51
- sendCommand('play');
52
- },
53
- pause: () => {
54
- sendCommand('pause');
55
- }
56
- };
57
- }, []);
58
- (0, _react.useEffect)(() => {
59
- const subscriptionOfShareBaseURLUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.ShareBaseURLUpdated, () => {
60
- _FWLoggerUtil.default.log('Receive FWEventName.ShareBaseURLUpdated');
61
-
62
- forceUpdate();
63
- });
64
-
65
- const subscriptionOfAdBadgeConfigurationUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.AdBadgeConfigurationUpdated, () => {
66
- _FWLoggerUtil.default.log('Receive FWEventName.AdBadgeConfigurationUpdated');
67
-
68
- forceUpdate();
69
- });
70
-
71
- const subscriptionOfVideoLaunchBehaviorUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.VideoLaunchBehaviorUpdated, () => {
72
- _FWLoggerUtil.default.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
73
-
74
- forceUpdate();
75
- });
76
-
77
- const subscriptionOfAppLanguageUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.AppLanguageUpdated, () => {
78
- _FWLoggerUtil.default.log('Receive FWEventName.AppLanguageUpdated');
79
-
80
- if (_reactNative.Platform.OS === 'android') {
81
- forceUpdate();
82
- }
83
- });
84
-
85
- if (_reactNative.Platform.OS === 'android') {
86
- setTimeout(() => {
87
- const viewId = (0, _reactNative.findNodeHandle)(nativeComponentRef.current);
88
-
89
- _FWLoggerUtil.default.log(`StoryBlock createFragment viewId: ${viewId}`);
90
-
91
- _reactNative.UIManager.dispatchViewManagerCommand(viewId, _reactNative.UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
92
- }, 500);
93
- }
94
-
95
- return () => {
96
- subscriptionOfShareBaseURLUpdated.remove();
97
- subscriptionOfAdBadgeConfigurationUpdated.remove();
98
- subscriptionOfVideoLaunchBehaviorUpdated.remove();
99
- subscriptionOfAppLanguageUpdated.remove();
100
- };
101
- }, []);
102
36
 
103
37
  const handleStoryBlockLoadFinished = event => {
104
38
  _FWLoggerUtil.default.log(`StoryBlock handleStoryBlockLoadFinished ${event.nativeEvent.name}`);
@@ -235,6 +169,74 @@ const StoryBlock = (props, forwardedRef) => {
235
169
  return key;
236
170
  };
237
171
 
172
+ const key = generateKey();
173
+ (0, _react.useImperativeHandle)(forwardedRef, () => {
174
+ const sendCommand = command => {
175
+ const nativeNodeHandle = (0, _reactNative.findNodeHandle)(nativeComponentRef.current);
176
+
177
+ let commandId = _reactNative.UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
178
+
179
+ if (_reactNative.Platform.OS === 'android') {
180
+ commandId = commandId.toString();
181
+ }
182
+
183
+ _reactNative.UIManager.dispatchViewManagerCommand((0, _reactNative.findNodeHandle)(nativeNodeHandle), commandId, []);
184
+ };
185
+
186
+ return {
187
+ play: () => {
188
+ sendCommand('play');
189
+ },
190
+ pause: () => {
191
+ sendCommand('pause');
192
+ }
193
+ };
194
+ }, []);
195
+ (0, _react.useEffect)(() => {
196
+ const subscriptionOfShareBaseURLUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.ShareBaseURLUpdated, () => {
197
+ _FWLoggerUtil.default.log('Receive FWEventName.ShareBaseURLUpdated');
198
+
199
+ forceUpdate();
200
+ });
201
+
202
+ const subscriptionOfAdBadgeConfigurationUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.AdBadgeConfigurationUpdated, () => {
203
+ _FWLoggerUtil.default.log('Receive FWEventName.AdBadgeConfigurationUpdated');
204
+
205
+ forceUpdate();
206
+ });
207
+
208
+ const subscriptionOfVideoLaunchBehaviorUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.VideoLaunchBehaviorUpdated, () => {
209
+ _FWLoggerUtil.default.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
210
+
211
+ forceUpdate();
212
+ });
213
+
214
+ const subscriptionOfAppLanguageUpdated = _FireworkSDKModule.FireworkSDKModuleEventEmitter.addListener(_FWEventName.FWEventName.AppLanguageUpdated, () => {
215
+ _FWLoggerUtil.default.log('Receive FWEventName.AppLanguageUpdated');
216
+
217
+ if (_reactNative.Platform.OS === 'android') {
218
+ forceUpdate();
219
+ }
220
+ });
221
+
222
+ return () => {
223
+ subscriptionOfShareBaseURLUpdated.remove();
224
+ subscriptionOfAdBadgeConfigurationUpdated.remove();
225
+ subscriptionOfVideoLaunchBehaviorUpdated.remove();
226
+ subscriptionOfAppLanguageUpdated.remove();
227
+ };
228
+ }, []);
229
+ (0, _react.useEffect)(() => {
230
+ if (_reactNative.Platform.OS === 'android') {
231
+ setTimeout(() => {
232
+ const viewId = (0, _reactNative.findNodeHandle)(nativeComponentRef.current);
233
+
234
+ _FWLoggerUtil.default.log(`StoryBlock createFragment viewId: ${viewId}`);
235
+
236
+ _reactNative.UIManager.dispatchViewManagerCommand(viewId, _reactNative.UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
237
+ }, 500);
238
+ }
239
+ }, [key]);
238
240
  (0, _react.useEffect)(() => {
239
241
  if (_reactNative.Platform.OS === 'android') {
240
242
  const onBackPress = () => {
@@ -261,7 +263,7 @@ const StoryBlock = (props, forwardedRef) => {
261
263
  } = props;
262
264
  return /*#__PURE__*/_react.default.createElement(_FWStoryBlock.default, _extends({
263
265
  ref: nativeComponentRef,
264
- key: generateKey()
266
+ key: key
265
267
  }, props, {
266
268
  onStoryBlockLoadFinished: handleStoryBlockLoadFinished,
267
269
  onStoryBlockFullScreenStateChanged: handleStoryBlockFullscreenStateChanged,
@@ -1 +1 @@
1
- {"version":3,"sources":["StoryBlock.tsx"],"names":["NativeComponentName","StoryBlock","props","forwardedRef","nativeComponentRef","isFullscreenState","setIsFullscreenState","forceUpdate","x","sendCommand","command","nativeNodeHandle","current","commandId","UIManager","getViewManagerConfig","Commands","Platform","OS","toString","dispatchViewManagerCommand","play","pause","subscriptionOfShareBaseURLUpdated","FireworkSDKModuleEventEmitter","addListener","FWEventName","ShareBaseURLUpdated","FWLoggerUtil","log","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","subscriptionOfVideoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","subscriptionOfAppLanguageUpdated","AppLanguageUpdated","setTimeout","viewId","create","remove","handleStoryBlockLoadFinished","event","nativeEvent","name","onStoryBlockLoadFinished","reason","handleStoryBlockFullscreenStateChanged","isFullScreen","generateDynamicContentParametersString","dynamicContentParameters","resultString","sortedKeyList","Object","keys","sort","key","value","valueString","join","length","generateVastAttributesString","adConfiguration","vastAttributes","attribute","generateKey","gShareBaseURL","FireworkSDK","getInstance","shareBaseURL","appLanguage","adBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","videoLaunchBehavior","source","channel","playlist","hashtagFilterExpression","enablePictureInPicture","dynamicContentParametersString","requiresAds","adsFetchTimeout","vastAttributesString","onBackPress","navigator","popNativeContainer","subscription","BackHandler","addEventListener","style","assign","zIndex"],"mappings":";;;;;;;AACA;;AASA;;AAUA;;AAGA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,mBAAmB,GAAG,cAA5B;;AA0DA,MAAMC,UAGL,GAAG,CAACC,KAAD,EAA0BC,YAA1B,KAA2C;AAC7C,QAAMC,kBAAkB,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OA,YAAMC,YAAY,GAAGC,yBAAYC,gBAAZ,CACnB,mBADmB,EAEnBL,WAFmB,CAArB;;AAIA,aAAO,MAAM;AACXG,QAAAA,YAAY,CAACnD,MAAb;AACD,OAFD;AAGD;;AAED;AACD,GAnBD,EAmBG,CAAClC,iBAAD,CAnBH;AAqBA,QAAM;AAAEwF,IAAAA;AAAF,MAAY3F,KAAlB;AACA,sBACE,6BAAC,qBAAD;AACE,IAAA,GAAG,EAAEE,kBADP;AAEE,IAAA,GAAG,EAAE4D,WAAW;AAFlB,KAGM9D,KAHN;AAIE,IAAA,wBAAwB,EAAEsC,4BAJ5B;AAKE,IAAA,kCAAkC,EAChCM,sCANJ;AAQE,IAAA,KAAK,EAAEM,MAAM,CAAC0C,MAAP,CAAc,EAAd,EAAkBD,KAAlB,EAAyB;AAAEE,MAAAA,MAAM,EAAE,CAAC;AAAX,KAAzB;AART,KADF;AAYD,CA1PD;;4BA4Pe,uBAAW9F,UAAX,C","sourcesContent":["import type { ForwardRefRenderFunction } from 'react';\nimport React, {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useReducer,\n useRef,\n useState,\n} from 'react';\n\nimport {\n BackHandler,\n findNodeHandle,\n NativeSyntheticEvent,\n Platform,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type AdConfiguration from '../models/AdConfiguration';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type { StoryBlockSource } from '../models/StoryBlockSource';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\nimport FWStoryBlock from './FWStoryBlock';\n\nconst NativeComponentName = 'FWStoryBlock';\n\nexport interface IStoryBlockMethods {\n /**\n * Play the story block.\n */\n play: () => void;\n /**\n * Pause the story block.\n */\n pause: () => void;\n}\n\n/**\n * The props type of StoryBlock component.\n */\nexport interface IStoryBlockProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of four available story block sources.\n */\n source: StoryBlockSource;\n /**\n * Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * The dynamic content parameters of the story block. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * Hashtag filter expression is an s-expression used to provide feeds filtered by hashtags with specified criteria.\n * Queries are specified with boolean predicates on what hashtags are there on the video.\n * For instance, (and sport food) (or sport food) (and sport (or food comedy)) sport are all valid expressions.\n * Non-UTF-8 characters are not allowed. If using boolean predicates, the expression needs to be wrapped with parenthesis.\n */\n hashtagFilterExpression?: string;\n /**\n * Specifies if Picture in Picture is enabled. Only supported on iOS.\n */\n enablePictureInPicture?: boolean;\n /**\n * Ad configuration of the feed. Only supported on iOS.\n */\n adConfiguration?: AdConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\nconst StoryBlock: ForwardRefRenderFunction<\n IStoryBlockMethods,\n IStoryBlockProps\n> = (props: IStoryBlockProps, forwardedRef) => {\n const nativeComponentRef = useRef(null);\n const [isFullscreenState, setIsFullscreenState] = useState<boolean>(false);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n useImperativeHandle(\n forwardedRef,\n () => {\n const sendCommand = (command: string) => {\n const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);\n\n let commandId: string | number =\n UIManager.getViewManagerConfig(NativeComponentName).Commands[command];\n if (Platform.OS === 'android') {\n commandId = commandId.toString();\n }\n\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(nativeNodeHandle),\n commandId,\n []\n );\n };\n return {\n play: () => {\n sendCommand('play');\n },\n pause: () => {\n sendCommand('pause');\n },\n };\n },\n []\n );\n useEffect(() => {\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');\n forceUpdate();\n }\n );\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfVideoLaunchBehaviorUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.VideoLaunchBehaviorUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfAppLanguageUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AppLanguageUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');\n if (Platform.OS === 'android') {\n forceUpdate();\n }\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 gShareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const appLanguage = FireworkSDK.getInstance().appLanguage ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().adBadgeConfiguration ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const videoLaunchBehavior =\n FireworkSDK.getInstance().videoLaunchBehavior ?? 'default';\n\n const {\n source,\n channel = '',\n playlist = '',\n hashtagFilterExpression = '',\n enablePictureInPicture = false,\n adConfiguration,\n } = props;\n const dynamicContentParametersString =\n generateDynamicContentParametersString();\n\n const requiresAds = adConfiguration?.requiresAds ?? false;\n const adsFetchTimeout = adConfiguration?.adsFetchTimeout ?? 10;\n const vastAttributesString = generateVastAttributesString();\n\n let key = `gShareBaseURL:${gShareBaseURL}`;\n if (Platform.OS === 'ios') {\n key += `_appLanguage:${appLanguage}`;\n }\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n\n key += `_source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_hashtagFilterExpression:${hashtagFilterExpression}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n\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"]}
1
+ {"version":3,"sources":["StoryBlock.tsx"],"names":["NativeComponentName","StoryBlock","props","forwardedRef","nativeComponentRef","isFullscreenState","setIsFullscreenState","forceUpdate","x","handleStoryBlockLoadFinished","event","FWLoggerUtil","log","nativeEvent","name","onStoryBlockLoadFinished","reason","handleStoryBlockFullscreenStateChanged","isFullScreen","generateDynamicContentParametersString","dynamicContentParameters","resultString","sortedKeyList","Object","keys","sort","key","value","valueString","join","length","generateVastAttributesString","adConfiguration","vastAttributes","attribute","generateKey","gShareBaseURL","FireworkSDK","getInstance","shareBaseURL","appLanguage","adBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","videoLaunchBehavior","source","channel","playlist","hashtagFilterExpression","enablePictureInPicture","dynamicContentParametersString","requiresAds","adsFetchTimeout","vastAttributesString","Platform","OS","sendCommand","command","nativeNodeHandle","current","commandId","UIManager","getViewManagerConfig","Commands","toString","dispatchViewManagerCommand","play","pause","subscriptionOfShareBaseURLUpdated","FireworkSDKModuleEventEmitter","addListener","FWEventName","ShareBaseURLUpdated","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","subscriptionOfVideoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","subscriptionOfAppLanguageUpdated","AppLanguageUpdated","remove","setTimeout","viewId","create","onBackPress","navigator","popNativeContainer","subscription","BackHandler","addEventListener","style","assign","zIndex"],"mappings":";;;;;;;AACA;;AASA;;AAUA;;AAGA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,mBAAmB,GAAG,cAA5B;;AA0DA,MAAMC,UAGL,GAAG,CAACC,KAAD,EAA0BC,YAA1B,KAA2C;AAC7C,QAAMC,kBAAkB,GAAG,mBAAO,IAAP,CAA3B;AACA,QAAM,CAACC,iBAAD,EAAoBC,oBAApB,IAA4C,qBAAkB,KAAlB,CAAlD;AACA,QAAM,GAAGC,WAAH,IAAkB,uBAAYC,CAAD,IAAOA,CAAC,GAAG,CAAtB,EAAyB,CAAzB,CAAxB;;AAEA,QAAMC,4BAA4B,GAAIC,KAAD,IAAsC;AACzEC,0BAAaC,GAAb,CACG,2CAA0CF,KAAK,CAACG,WAAN,CAAkBC,IAAK,EADpE;;AAIA,UAAM;AAAEC,MAAAA;AAAF,QAA+Bb,KAArC;AACA,UAAM;AAAEY,MAAAA,IAAF;AAAQE,MAAAA;AAAR,QAAmBN,KA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EsB;AAFP,KAGMxB,KAHN;AAIE,IAAA,wBAAwB,EAAEO,4BAJ5B;AAKE,IAAA,kCAAkC,EAChCQ,sCANJ;AAQE,IAAA,KAAK,EAAEM,MAAM,CAACuE,MAAP,CAAc,EAAd,EAAkBD,KAAlB,EAAyB;AAAEE,MAAAA,MAAM,EAAE,CAAC;AAAX,KAAzB;AART,KADF;AAYD,CAhQD;;4BAkQe,uBAAW9F,UAAX,C","sourcesContent":["import type { ForwardRefRenderFunction } from 'react';\nimport React, {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useReducer,\n useRef,\n useState,\n} from 'react';\n\nimport {\n BackHandler,\n findNodeHandle,\n NativeSyntheticEvent,\n Platform,\n StyleProp,\n UIManager,\n ViewStyle,\n} from 'react-native';\n\nimport FireworkSDK from '../FireworkSDK';\nimport type AdConfiguration from '../models/AdConfiguration';\nimport type FWError from '../models/FWError';\nimport { FWEventName } from '../models/FWEventName';\nimport type { StoryBlockSource } from '../models/StoryBlockSource';\nimport { FireworkSDKModuleEventEmitter } from '../modules/FireworkSDKModule';\nimport FWLoggerUtil from '../utils/FWLoggerUtil';\nimport FWStoryBlock from './FWStoryBlock';\n\nconst NativeComponentName = 'FWStoryBlock';\n\nexport interface IStoryBlockMethods {\n /**\n * Play the story block.\n */\n play: () => void;\n /**\n * Pause the story block.\n */\n pause: () => void;\n}\n\n/**\n * The props type of StoryBlock component.\n */\nexport interface IStoryBlockProps {\n /**\n * Standard React Native View Style.\n */\n style?: StyleProp<ViewStyle>;\n /**\n * One of four available story block sources.\n */\n source: StoryBlockSource;\n /**\n * Channel id of the story block. Required when the source is set as channel or playlist or dynamicContent.\n */\n channel?: string;\n /**\n * Playlist id of the story block. Please note channel id is necessary. Required when the source is set as playlist.\n */\n playlist?: string;\n /**\n * The dynamic content parameters of the story block. Required when the source is set as dynamicContent.\n */\n dynamicContentParameters?: { [key: string]: string[] };\n /**\n * Hashtag filter expression is an s-expression used to provide feeds filtered by hashtags with specified criteria.\n * Queries are specified with boolean predicates on what hashtags are there on the video.\n * For instance, (and sport food) (or sport food) (and sport (or food comedy)) sport are all valid expressions.\n * Non-UTF-8 characters are not allowed. If using boolean predicates, the expression needs to be wrapped with parenthesis.\n */\n hashtagFilterExpression?: string;\n /**\n * Specifies if Picture in Picture is enabled. Only supported on iOS.\n */\n enablePictureInPicture?: boolean;\n /**\n * Ad configuration of the feed. Only supported on iOS.\n */\n adConfiguration?: AdConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\nconst StoryBlock: ForwardRefRenderFunction<\n IStoryBlockMethods,\n IStoryBlockProps\n> = (props: IStoryBlockProps, forwardedRef) => {\n const nativeComponentRef = useRef(null);\n const [isFullscreenState, setIsFullscreenState] = useState<boolean>(false);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\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 gShareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const appLanguage = FireworkSDK.getInstance().appLanguage ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().adBadgeConfiguration ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const videoLaunchBehavior =\n FireworkSDK.getInstance().videoLaunchBehavior ?? 'default';\n\n const {\n source,\n channel = '',\n playlist = '',\n hashtagFilterExpression = '',\n enablePictureInPicture = false,\n adConfiguration,\n } = props;\n const dynamicContentParametersString =\n generateDynamicContentParametersString();\n\n const requiresAds = adConfiguration?.requiresAds ?? false;\n const adsFetchTimeout = adConfiguration?.adsFetchTimeout ?? 10;\n const vastAttributesString = generateVastAttributesString();\n\n let key = `gShareBaseURL:${gShareBaseURL}`;\n if (Platform.OS === 'ios') {\n key += `_appLanguage:${appLanguage}`;\n }\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n\n key += `_source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_hashtagFilterExpression:${hashtagFilterExpression}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n\n key += `_requiresAds:${requiresAds}`;\n key += `_adsFetchTimeout:${adsFetchTimeout}`;\n key += `_vastAttributes:${vastAttributesString}`;\n\n return key;\n };\n\n const key = generateKey();\n\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\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 if (Platform.OS === 'android') {\n forceUpdate();\n }\n }\n );\n\n return () => {\n subscriptionOfShareBaseURLUpdated.remove();\n subscriptionOfAdBadgeConfigurationUpdated.remove();\n subscriptionOfVideoLaunchBehaviorUpdated.remove();\n subscriptionOfAppLanguageUpdated.remove();\n };\n }, []);\n\n useEffect(() => {\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 }, [key]);\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={key}\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"]}
@@ -13,63 +13,6 @@ const StoryBlock = (props, forwardedRef) => {
13
13
  const nativeComponentRef = useRef(null);
14
14
  const [isFullscreenState, setIsFullscreenState] = useState(false);
15
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();
23
- }
24
-
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(() => {
38
- const subscriptionOfShareBaseURLUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.ShareBaseURLUpdated, () => {
39
- FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');
40
- forceUpdate();
41
- });
42
- const subscriptionOfAdBadgeConfigurationUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AdBadgeConfigurationUpdated, () => {
43
- FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');
44
- forceUpdate();
45
- });
46
- const subscriptionOfVideoLaunchBehaviorUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.VideoLaunchBehaviorUpdated, () => {
47
- FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
48
- forceUpdate();
49
- });
50
- const subscriptionOfAppLanguageUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AppLanguageUpdated, () => {
51
- FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');
52
-
53
- if (Platform.OS === 'android') {
54
- forceUpdate();
55
- }
56
- });
57
-
58
- if (Platform.OS === 'android') {
59
- setTimeout(() => {
60
- const viewId = findNodeHandle(nativeComponentRef.current);
61
- FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);
62
- UIManager.dispatchViewManagerCommand(viewId, UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
63
- }, 500);
64
- }
65
-
66
- return () => {
67
- subscriptionOfShareBaseURLUpdated.remove();
68
- subscriptionOfAdBadgeConfigurationUpdated.remove();
69
- subscriptionOfVideoLaunchBehaviorUpdated.remove();
70
- subscriptionOfAppLanguageUpdated.remove();
71
- };
72
- }, []);
73
16
 
74
17
  const handleStoryBlockLoadFinished = event => {
75
18
  FWLoggerUtil.log(`StoryBlock handleStoryBlockLoadFinished ${event.nativeEvent.name}`);
@@ -204,6 +147,64 @@ const StoryBlock = (props, forwardedRef) => {
204
147
  return key;
205
148
  };
206
149
 
150
+ const key = generateKey();
151
+ useImperativeHandle(forwardedRef, () => {
152
+ const sendCommand = command => {
153
+ const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);
154
+ let commandId = UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
155
+
156
+ if (Platform.OS === 'android') {
157
+ commandId = commandId.toString();
158
+ }
159
+
160
+ UIManager.dispatchViewManagerCommand(findNodeHandle(nativeNodeHandle), commandId, []);
161
+ };
162
+
163
+ return {
164
+ play: () => {
165
+ sendCommand('play');
166
+ },
167
+ pause: () => {
168
+ sendCommand('pause');
169
+ }
170
+ };
171
+ }, []);
172
+ useEffect(() => {
173
+ const subscriptionOfShareBaseURLUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.ShareBaseURLUpdated, () => {
174
+ FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');
175
+ forceUpdate();
176
+ });
177
+ const subscriptionOfAdBadgeConfigurationUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AdBadgeConfigurationUpdated, () => {
178
+ FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');
179
+ forceUpdate();
180
+ });
181
+ const subscriptionOfVideoLaunchBehaviorUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.VideoLaunchBehaviorUpdated, () => {
182
+ FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
183
+ forceUpdate();
184
+ });
185
+ const subscriptionOfAppLanguageUpdated = FireworkSDKModuleEventEmitter.addListener(FWEventName.AppLanguageUpdated, () => {
186
+ FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');
187
+
188
+ if (Platform.OS === 'android') {
189
+ forceUpdate();
190
+ }
191
+ });
192
+ return () => {
193
+ subscriptionOfShareBaseURLUpdated.remove();
194
+ subscriptionOfAdBadgeConfigurationUpdated.remove();
195
+ subscriptionOfVideoLaunchBehaviorUpdated.remove();
196
+ subscriptionOfAppLanguageUpdated.remove();
197
+ };
198
+ }, []);
199
+ useEffect(() => {
200
+ if (Platform.OS === 'android') {
201
+ setTimeout(() => {
202
+ const viewId = findNodeHandle(nativeComponentRef.current);
203
+ FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);
204
+ UIManager.dispatchViewManagerCommand(viewId, UIManager.getViewManagerConfig(NativeComponentName).Commands.create.toString(), [viewId]);
205
+ }, 500);
206
+ }
207
+ }, [key]);
207
208
  useEffect(() => {
208
209
  if (Platform.OS === 'android') {
209
210
  const onBackPress = () => {
@@ -228,7 +229,7 @@ const StoryBlock = (props, forwardedRef) => {
228
229
  } = props;
229
230
  return /*#__PURE__*/React.createElement(FWStoryBlock, _extends({
230
231
  ref: nativeComponentRef,
231
- key: generateKey()
232
+ key: key
232
233
  }, props, {
233
234
  onStoryBlockLoadFinished: handleStoryBlockLoadFinished,
234
235
  onStoryBlockFullScreenStateChanged: handleStoryBlockFullscreenStateChanged,
@@ -1 +1 @@
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","gShareBaseURL","getInstance","shareBaseURL","appLanguage","adBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","videoLaunchBehavior","source","channel","playlist","hashtagFilterExpression","enablePictureInPicture","dynamicContentParametersString","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;;AA0DA,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,CAACoB,oBAAV,CAA+Bd,mBAA/B,EAAoDe,QAApD,CAA6DL,OAA7D,CADF;;AAEA,UAAIjB,QAAQ,CAACuB,EAAT,KAAgB,SAApB,EAA+B;AAC7BH,QAAAA,SAAS,GAAGA,SAAS,CAACI,QAAV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;AAAF,MAAYpF,KAAlB;AACA,sBACE,oBAAC,YAAD;AACE,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,CAACwC,MAAP,CAAc,EAAd,EAAkBD,KAAlB,EAAyB;AAAEE,MAAAA,MAAM,EAAE,CAAC;AAAX,KAAzB;AART,KADF;AAYD,CA1PD;;AA4PA,4BAAevG,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 * Hashtag filter expression is an s-expression used to provide feeds filtered by hashtags with specified criteria.\n * Queries are specified with boolean predicates on what hashtags are there on the video.\n * For instance, (and sport food) (or sport food) (and sport (or food comedy)) sport are all valid expressions.\n * Non-UTF-8 characters are not allowed. If using boolean predicates, the expression needs to be wrapped with parenthesis.\n */\n hashtagFilterExpression?: string;\n /**\n * Specifies if Picture in Picture is enabled. Only supported on iOS.\n */\n enablePictureInPicture?: boolean;\n /**\n * Ad configuration of the feed. Only supported on iOS.\n */\n adConfiguration?: AdConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\nconst StoryBlock: ForwardRefRenderFunction<\n IStoryBlockMethods,\n IStoryBlockProps\n> = (props: IStoryBlockProps, forwardedRef) => {\n const nativeComponentRef = useRef(null);\n const [isFullscreenState, setIsFullscreenState] = useState<boolean>(false);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n useImperativeHandle(\n forwardedRef,\n () => {\n const sendCommand = (command: string) => {\n const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);\n\n let commandId: string | number =\n UIManager.getViewManagerConfig(NativeComponentName).Commands[command];\n if (Platform.OS === 'android') {\n commandId = commandId.toString();\n }\n\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(nativeNodeHandle),\n commandId,\n []\n );\n };\n return {\n play: () => {\n sendCommand('play');\n },\n pause: () => {\n sendCommand('pause');\n },\n };\n },\n []\n );\n useEffect(() => {\n const subscriptionOfShareBaseURLUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.ShareBaseURLUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');\n forceUpdate();\n }\n );\n const subscriptionOfAdBadgeConfigurationUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AdBadgeConfigurationUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfVideoLaunchBehaviorUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.VideoLaunchBehaviorUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');\n forceUpdate();\n }\n );\n\n const subscriptionOfAppLanguageUpdated =\n FireworkSDKModuleEventEmitter.addListener(\n FWEventName.AppLanguageUpdated,\n () => {\n FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');\n if (Platform.OS === 'android') {\n forceUpdate();\n }\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 gShareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const appLanguage = FireworkSDK.getInstance().appLanguage ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().adBadgeConfiguration ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const videoLaunchBehavior =\n FireworkSDK.getInstance().videoLaunchBehavior ?? 'default';\n\n const {\n source,\n channel = '',\n playlist = '',\n hashtagFilterExpression = '',\n enablePictureInPicture = false,\n adConfiguration,\n } = props;\n const dynamicContentParametersString =\n generateDynamicContentParametersString();\n\n const requiresAds = adConfiguration?.requiresAds ?? false;\n const adsFetchTimeout = adConfiguration?.adsFetchTimeout ?? 10;\n const vastAttributesString = generateVastAttributesString();\n\n let key = `gShareBaseURL:${gShareBaseURL}`;\n if (Platform.OS === 'ios') {\n key += `_appLanguage:${appLanguage}`;\n }\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n\n key += `_source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_hashtagFilterExpression:${hashtagFilterExpression}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n\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"]}
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","handleStoryBlockLoadFinished","event","log","nativeEvent","name","onStoryBlockLoadFinished","reason","handleStoryBlockFullscreenStateChanged","isFullScreen","generateDynamicContentParametersString","dynamicContentParameters","resultString","sortedKeyList","Object","keys","sort","key","value","valueString","join","length","generateVastAttributesString","adConfiguration","vastAttributes","attribute","generateKey","gShareBaseURL","getInstance","shareBaseURL","appLanguage","adBadgeConfiguration","adBadgeTextType","badgeTextType","backgroundColorOfAdBadge","backgroundColor","textColorOfAdBadge","textColor","videoLaunchBehavior","source","channel","playlist","hashtagFilterExpression","enablePictureInPicture","dynamicContentParametersString","requiresAds","adsFetchTimeout","vastAttributesString","OS","sendCommand","command","nativeNodeHandle","current","commandId","getViewManagerConfig","Commands","toString","dispatchViewManagerCommand","play","pause","subscriptionOfShareBaseURLUpdated","addListener","ShareBaseURLUpdated","subscriptionOfAdBadgeConfigurationUpdated","AdBadgeConfigurationUpdated","subscriptionOfVideoLaunchBehaviorUpdated","VideoLaunchBehaviorUpdated","subscriptionOfAppLanguageUpdated","AppLanguageUpdated","remove","setTimeout","viewId","create","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;;AA0DA,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;;AAEA,QAAMC,4BAA4B,GAAIC,KAAD,IAAsC;AACzEZ,IAAAA,YAAY,CAACa,GAA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B,WAAW,GAAG,MAAM;AACxB,YAAI5E,iBAAJ,EAAuB;AACrBV,UAAAA,WAAW,CAACyC,WAAZ,GAA0B8C,SAA1B,CAAoCC,kBAApC;AACA,iBAAO,IAAP;AACD;;AACD,eAAO,KAAP;AACD,OAND;;AAOA,YAAMC,YAAY,GAAG7F,WAAW,CAAC8F,gBAAZ,CACnB,mBADmB,EAEnBJ,WAFmB,CAArB;AAIA,aAAO,MAAM;AACXG,QAAAA,YAAY,CAACP,MAAb;AACD,OAFD;AAGD;;AAED;AACD,GAnBQ,EAmBN,CAACxE,iBAAD,CAnBM,CAAT;AAqBA,QAAM;AAAEiF,IAAAA;AAAF,MAAYpF,KAAlB;AACA,sBACE,oBAAC,YAAD;AACE,IAAA,GAAG,EAAEE,kBADP;AAEE,IAAA,GAAG,EAAEqB;AAFP,KAGMvB,KAHN;AAIE,IAAA,wBAAwB,EAAEO,4BAJ5B;AAKE,IAAA,kCAAkC,EAChCO,sCANJ;AAQE,IAAA,KAAK,EAAEM,MAAM,CAACiE,MAAP,CAAc,EAAd,EAAkBD,KAAlB,EAAyB;AAAEE,MAAAA,MAAM,EAAE,CAAC;AAAX,KAAzB;AART,KADF;AAYD,CAhQD;;AAkQA,4BAAevG,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 * Hashtag filter expression is an s-expression used to provide feeds filtered by hashtags with specified criteria.\n * Queries are specified with boolean predicates on what hashtags are there on the video.\n * For instance, (and sport food) (or sport food) (and sport (or food comedy)) sport are all valid expressions.\n * Non-UTF-8 characters are not allowed. If using boolean predicates, the expression needs to be wrapped with parenthesis.\n */\n hashtagFilterExpression?: string;\n /**\n * Specifies if Picture in Picture is enabled. Only supported on iOS.\n */\n enablePictureInPicture?: boolean;\n /**\n * Ad configuration of the feed. Only supported on iOS.\n */\n adConfiguration?: AdConfiguration;\n /**\n * The feed loading result callback. It means loading successfully when error equals to undefined.\n */\n onStoryBlockLoadFinished?: (error?: FWError) => void;\n}\n\nconst StoryBlock: ForwardRefRenderFunction<\n IStoryBlockMethods,\n IStoryBlockProps\n> = (props: IStoryBlockProps, forwardedRef) => {\n const nativeComponentRef = useRef(null);\n const [isFullscreenState, setIsFullscreenState] = useState<boolean>(false);\n const [, forceUpdate] = useReducer((x) => x + 1, 0);\n\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 gShareBaseURL = FireworkSDK.getInstance().shareBaseURL ?? '';\n const appLanguage = FireworkSDK.getInstance().appLanguage ?? '';\n const adBadgeConfiguration =\n FireworkSDK.getInstance().adBadgeConfiguration ?? {};\n const adBadgeTextType = adBadgeConfiguration.badgeTextType ?? '';\n const backgroundColorOfAdBadge = adBadgeConfiguration.backgroundColor ?? '';\n const textColorOfAdBadge = adBadgeConfiguration.textColor ?? '';\n const videoLaunchBehavior =\n FireworkSDK.getInstance().videoLaunchBehavior ?? 'default';\n\n const {\n source,\n channel = '',\n playlist = '',\n hashtagFilterExpression = '',\n enablePictureInPicture = false,\n adConfiguration,\n } = props;\n const dynamicContentParametersString =\n generateDynamicContentParametersString();\n\n const requiresAds = adConfiguration?.requiresAds ?? false;\n const adsFetchTimeout = adConfiguration?.adsFetchTimeout ?? 10;\n const vastAttributesString = generateVastAttributesString();\n\n let key = `gShareBaseURL:${gShareBaseURL}`;\n if (Platform.OS === 'ios') {\n key += `_appLanguage:${appLanguage}`;\n }\n key += `_adBadgeTextType:${adBadgeTextType}`;\n key += `_backgroundColorOfAdBadge:${backgroundColorOfAdBadge}`;\n key += `_textColorOfAdBadge:${textColorOfAdBadge}`;\n key += `_videoLaunchBehavior:${videoLaunchBehavior}`;\n\n key += `_source:${source}`;\n key += `_channel:${channel}`;\n key += `_playlist:${playlist}`;\n key += `_dynamicContentParameters:${dynamicContentParametersString}`;\n key += `_hashtagFilterExpression:${hashtagFilterExpression}`;\n key += `_enablePictureInPicture:${enablePictureInPicture}`;\n\n key += `_requiresAds:${requiresAds}`;\n key += `_adsFetchTimeout:${adsFetchTimeout}`;\n key += `_vastAttributes:${vastAttributesString}`;\n\n return key;\n };\n\n const key = generateKey();\n\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\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 if (Platform.OS === 'android') {\n forceUpdate();\n }\n }\n );\n\n return () => {\n subscriptionOfShareBaseURLUpdated.remove();\n subscriptionOfAdBadgeConfigurationUpdated.remove();\n subscriptionOfVideoLaunchBehaviorUpdated.remove();\n subscriptionOfAppLanguageUpdated.remove();\n };\n }, []);\n\n useEffect(() => {\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 }, [key]);\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={key}\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-firework-sdk",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
4
4
  "description": "Firework React Native SDK",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -92,94 +92,6 @@ const StoryBlock: ForwardRefRenderFunction<
92
92
  const nativeComponentRef = useRef(null);
93
93
  const [isFullscreenState, setIsFullscreenState] = useState<boolean>(false);
94
94
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
95
- useImperativeHandle(
96
- forwardedRef,
97
- () => {
98
- const sendCommand = (command: string) => {
99
- const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);
100
-
101
- let commandId: string | number =
102
- UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
103
- if (Platform.OS === 'android') {
104
- commandId = commandId.toString();
105
- }
106
-
107
- UIManager.dispatchViewManagerCommand(
108
- findNodeHandle(nativeNodeHandle),
109
- commandId,
110
- []
111
- );
112
- };
113
- return {
114
- play: () => {
115
- sendCommand('play');
116
- },
117
- pause: () => {
118
- sendCommand('pause');
119
- },
120
- };
121
- },
122
- []
123
- );
124
- useEffect(() => {
125
- const subscriptionOfShareBaseURLUpdated =
126
- FireworkSDKModuleEventEmitter.addListener(
127
- FWEventName.ShareBaseURLUpdated,
128
- () => {
129
- FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');
130
- forceUpdate();
131
- }
132
- );
133
- const subscriptionOfAdBadgeConfigurationUpdated =
134
- FireworkSDKModuleEventEmitter.addListener(
135
- FWEventName.AdBadgeConfigurationUpdated,
136
- () => {
137
- FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');
138
- forceUpdate();
139
- }
140
- );
141
-
142
- const subscriptionOfVideoLaunchBehaviorUpdated =
143
- FireworkSDKModuleEventEmitter.addListener(
144
- FWEventName.VideoLaunchBehaviorUpdated,
145
- () => {
146
- FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
147
- forceUpdate();
148
- }
149
- );
150
-
151
- const subscriptionOfAppLanguageUpdated =
152
- FireworkSDKModuleEventEmitter.addListener(
153
- FWEventName.AppLanguageUpdated,
154
- () => {
155
- FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');
156
- if (Platform.OS === 'android') {
157
- forceUpdate();
158
- }
159
- }
160
- );
161
-
162
- if (Platform.OS === 'android') {
163
- setTimeout(() => {
164
- const viewId = findNodeHandle(nativeComponentRef.current);
165
- FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);
166
- UIManager.dispatchViewManagerCommand(
167
- viewId,
168
- UIManager.getViewManagerConfig(
169
- NativeComponentName
170
- ).Commands.create.toString(),
171
- [viewId]
172
- );
173
- }, 500);
174
- }
175
-
176
- return () => {
177
- subscriptionOfShareBaseURLUpdated.remove();
178
- subscriptionOfAdBadgeConfigurationUpdated.remove();
179
- subscriptionOfVideoLaunchBehaviorUpdated.remove();
180
- subscriptionOfAppLanguageUpdated.remove();
181
- };
182
- }, []);
183
95
 
184
96
  const handleStoryBlockLoadFinished = (event: NativeSyntheticEvent<any>) => {
185
97
  FWLoggerUtil.log(
@@ -301,6 +213,100 @@ const StoryBlock: ForwardRefRenderFunction<
301
213
  return key;
302
214
  };
303
215
 
216
+ const key = generateKey();
217
+
218
+ useImperativeHandle(
219
+ forwardedRef,
220
+ () => {
221
+ const sendCommand = (command: string) => {
222
+ const nativeNodeHandle = findNodeHandle(nativeComponentRef.current);
223
+
224
+ let commandId: string | number =
225
+ UIManager.getViewManagerConfig(NativeComponentName).Commands[command];
226
+ if (Platform.OS === 'android') {
227
+ commandId = commandId.toString();
228
+ }
229
+
230
+ UIManager.dispatchViewManagerCommand(
231
+ findNodeHandle(nativeNodeHandle),
232
+ commandId,
233
+ []
234
+ );
235
+ };
236
+ return {
237
+ play: () => {
238
+ sendCommand('play');
239
+ },
240
+ pause: () => {
241
+ sendCommand('pause');
242
+ },
243
+ };
244
+ },
245
+ []
246
+ );
247
+
248
+ useEffect(() => {
249
+ const subscriptionOfShareBaseURLUpdated =
250
+ FireworkSDKModuleEventEmitter.addListener(
251
+ FWEventName.ShareBaseURLUpdated,
252
+ () => {
253
+ FWLoggerUtil.log('Receive FWEventName.ShareBaseURLUpdated');
254
+ forceUpdate();
255
+ }
256
+ );
257
+ const subscriptionOfAdBadgeConfigurationUpdated =
258
+ FireworkSDKModuleEventEmitter.addListener(
259
+ FWEventName.AdBadgeConfigurationUpdated,
260
+ () => {
261
+ FWLoggerUtil.log('Receive FWEventName.AdBadgeConfigurationUpdated');
262
+ forceUpdate();
263
+ }
264
+ );
265
+
266
+ const subscriptionOfVideoLaunchBehaviorUpdated =
267
+ FireworkSDKModuleEventEmitter.addListener(
268
+ FWEventName.VideoLaunchBehaviorUpdated,
269
+ () => {
270
+ FWLoggerUtil.log('Receive FWEventName.VideoLaunchBehaviorUpdated');
271
+ forceUpdate();
272
+ }
273
+ );
274
+
275
+ const subscriptionOfAppLanguageUpdated =
276
+ FireworkSDKModuleEventEmitter.addListener(
277
+ FWEventName.AppLanguageUpdated,
278
+ () => {
279
+ FWLoggerUtil.log('Receive FWEventName.AppLanguageUpdated');
280
+ if (Platform.OS === 'android') {
281
+ forceUpdate();
282
+ }
283
+ }
284
+ );
285
+
286
+ return () => {
287
+ subscriptionOfShareBaseURLUpdated.remove();
288
+ subscriptionOfAdBadgeConfigurationUpdated.remove();
289
+ subscriptionOfVideoLaunchBehaviorUpdated.remove();
290
+ subscriptionOfAppLanguageUpdated.remove();
291
+ };
292
+ }, []);
293
+
294
+ useEffect(() => {
295
+ if (Platform.OS === 'android') {
296
+ setTimeout(() => {
297
+ const viewId = findNodeHandle(nativeComponentRef.current);
298
+ FWLoggerUtil.log(`StoryBlock createFragment viewId: ${viewId}`);
299
+ UIManager.dispatchViewManagerCommand(
300
+ viewId,
301
+ UIManager.getViewManagerConfig(
302
+ NativeComponentName
303
+ ).Commands.create.toString(),
304
+ [viewId]
305
+ );
306
+ }, 500);
307
+ }
308
+ }, [key]);
309
+
304
310
  useEffect(() => {
305
311
  if (Platform.OS === 'android') {
306
312
  const onBackPress = () => {
@@ -326,7 +332,7 @@ const StoryBlock: ForwardRefRenderFunction<
326
332
  return (
327
333
  <FWStoryBlock
328
334
  ref={nativeComponentRef}
329
- key={generateKey()}
335
+ key={key}
330
336
  {...props}
331
337
  onStoryBlockLoadFinished={handleStoryBlockLoadFinished}
332
338
  onStoryBlockFullScreenStateChanged={