react-native-firework-sdk 1.0.0-beta

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.
Files changed (190) hide show
  1. package/README.md +39 -0
  2. package/android/build.gradle +193 -0
  3. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  4. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  5. package/android/gradle.properties +5 -0
  6. package/android/gradlew +185 -0
  7. package/android/gradlew.bat +89 -0
  8. package/android/publish.gradle +65 -0
  9. package/android/src/main/AndroidManifest.xml +16 -0
  10. package/android/src/main/java/com/reactnativefireworksdk/FireworkSDKPackage.kt +20 -0
  11. package/android/src/main/java/com/reactnativefireworksdk/components/videofeed/FWVideoFeed.kt +123 -0
  12. package/android/src/main/java/com/reactnativefireworksdk/constants/FWCommandConstant.kt +6 -0
  13. package/android/src/main/java/com/reactnativefireworksdk/constants/FWVideoPlayerConstant.kt +20 -0
  14. package/android/src/main/java/com/reactnativefireworksdk/manager/FWVideoFeedManager.kt +88 -0
  15. package/android/src/main/java/com/reactnativefireworksdk/models/FWEventName.kt +35 -0
  16. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedConfigModel.kt +27 -0
  17. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedItemDetailsModel.kt +11 -0
  18. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedMode.kt +7 -0
  19. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedSource.kt +7 -0
  20. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoFeedTitlePosition.kt +7 -0
  21. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoPlaybackDetails.kt +19 -0
  22. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoPlayerConfigModel.kt +20 -0
  23. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoShoppingInterface.kt +13 -0
  24. package/android/src/main/java/com/reactnativefireworksdk/models/FWVideoShoppingProduct.kt +34 -0
  25. package/android/src/main/java/com/reactnativefireworksdk/models/FireworkSDKInterface.kt +12 -0
  26. package/android/src/main/java/com/reactnativefireworksdk/module/FWVideoShoppingModule.kt +190 -0
  27. package/android/src/main/java/com/reactnativefireworksdk/module/FireworkSDKModule.kt +248 -0
  28. package/android/src/main/java/com/reactnativefireworksdk/pages/FWVideoShoppingCartActivity.kt +43 -0
  29. package/android/src/main/java/com/reactnativefireworksdk/utils/FWEventUtils.kt +127 -0
  30. package/android/src/main/java/com/reactnativefireworksdk/utils/FWJsonUtils.kt +57 -0
  31. package/android/src/main/java/com/reactnativefireworksdk/utils/FWLogUtils.kt +147 -0
  32. package/android/src/main/java/com/reactnativefireworksdk/utils/FWUrlUtils.kt +68 -0
  33. package/android/src/main/java/com/reactnativefireworksdk/utils/FWVideoPlayerUtils.kt +18 -0
  34. package/android/src/main/res/layout/fwrn_fragment_shoppingcart.xml +8 -0
  35. package/android/src/main/res/layout/fwrn_fragment_videofeed.xml +20 -0
  36. package/android/src/main/res/values/styles.xml +43 -0
  37. package/ios/Component/VideoFeed.swift +262 -0
  38. package/ios/Component/VideoFeedConfiguration.swift +32 -0
  39. package/ios/Component/VideoFeedManager.m +51 -0
  40. package/ios/Component/VideoFeedManager.swift +40 -0
  41. package/ios/Component/VideoPlayerConfiguration.swift +30 -0
  42. package/ios/FireworkSdk-Bridging-Header.h +6 -0
  43. package/ios/FireworkSdk.xcodeproj/project.pbxproj +291 -0
  44. package/ios/Models/FireworkJsEvent.swift +34 -0
  45. package/ios/Models/FireworkSDK+JsModel.swift +62 -0
  46. package/ios/Models/RCTConvert+FireworkSDKModule.swift +91 -0
  47. package/ios/Models/RCTConvert+Shopping.swift +49 -0
  48. package/ios/Models/RCTConvert+VideoFeed.swift +69 -0
  49. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+CTA.swift +17 -0
  50. package/ios/Modules/FireworkSDKModule/FireworkSDKModule+EventTracking.swift +74 -0
  51. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.m +19 -0
  52. package/ios/Modules/FireworkSDKModule/FireworkSDKModule.swift +106 -0
  53. package/ios/Modules/FireworkSDKModule/MobileADConfiguration.swift +17 -0
  54. package/ios/Modules/Shopping/CartViewController.swift +98 -0
  55. package/ios/Modules/Shopping/Product.swift +33 -0
  56. package/ios/Modules/Shopping/ProductInfoViewConfiguration.swift +24 -0
  57. package/ios/Modules/Shopping/ShoppingModule.m +19 -0
  58. package/ios/Modules/Shopping/ShoppingModule.swift +214 -0
  59. package/ios/Utils/String+Color.swift +38 -0
  60. package/ios/Utils/UIView+Constraints.swift +91 -0
  61. package/ios/Utils/UIView+ParentViewController.swift +21 -0
  62. package/ios/Utils/UIViewController+AttachChild.swift +69 -0
  63. package/lib/commonjs/FireworkSDK.js +171 -0
  64. package/lib/commonjs/FireworkSDK.js.map +1 -0
  65. package/lib/commonjs/VideoShopping.js +146 -0
  66. package/lib/commonjs/VideoShopping.js.map +1 -0
  67. package/lib/commonjs/components/CartContainer.js +35 -0
  68. package/lib/commonjs/components/CartContainer.js.map +1 -0
  69. package/lib/commonjs/components/FWVideoFeed.js +18 -0
  70. package/lib/commonjs/components/FWVideoFeed.js.map +1 -0
  71. package/lib/commonjs/components/VideoFeed.js +82 -0
  72. package/lib/commonjs/components/VideoFeed.js.map +1 -0
  73. package/lib/commonjs/constants/FWErrorMessage.js +15 -0
  74. package/lib/commonjs/constants/FWErrorMessage.js.map +1 -0
  75. package/lib/commonjs/index.js +44 -0
  76. package/lib/commonjs/index.js.map +1 -0
  77. package/lib/commonjs/models/ADConfig.js +2 -0
  78. package/lib/commonjs/models/ADConfig.js.map +1 -0
  79. package/lib/commonjs/models/AddToCartResult.js +2 -0
  80. package/lib/commonjs/models/AddToCartResult.js.map +1 -0
  81. package/lib/commonjs/models/FWError.js +2 -0
  82. package/lib/commonjs/models/FWError.js.map +1 -0
  83. package/lib/commonjs/models/FWEvents.js +20 -0
  84. package/lib/commonjs/models/FWEvents.js.map +1 -0
  85. package/lib/commonjs/models/FeedItemDetails.js +2 -0
  86. package/lib/commonjs/models/FeedItemDetails.js.map +1 -0
  87. package/lib/commonjs/models/Product.js +2 -0
  88. package/lib/commonjs/models/Product.js.map +1 -0
  89. package/lib/commonjs/models/ProductInfoViewConfiguration.js +2 -0
  90. package/lib/commonjs/models/ProductInfoViewConfiguration.js.map +1 -0
  91. package/lib/commonjs/models/ProductUnit.js +2 -0
  92. package/lib/commonjs/models/ProductUnit.js.map +1 -0
  93. package/lib/commonjs/models/VideoFeedConfiguration.js +2 -0
  94. package/lib/commonjs/models/VideoFeedConfiguration.js.map +1 -0
  95. package/lib/commonjs/models/VideoPlaybackDetails.js +2 -0
  96. package/lib/commonjs/models/VideoPlaybackDetails.js.map +1 -0
  97. package/lib/commonjs/models/VideoPlaybackEventName.js +23 -0
  98. package/lib/commonjs/models/VideoPlaybackEventName.js.map +1 -0
  99. package/lib/commonjs/models/VideoPlayerConfiguration.js +2 -0
  100. package/lib/commonjs/models/VideoPlayerConfiguration.js.map +1 -0
  101. package/lib/commonjs/modules/FireworkSDKModule.js +20 -0
  102. package/lib/commonjs/modules/FireworkSDKModule.js.map +1 -0
  103. package/lib/commonjs/modules/ShoppingModule.js +20 -0
  104. package/lib/commonjs/modules/ShoppingModule.js.map +1 -0
  105. package/lib/module/FireworkSDK.js +153 -0
  106. package/lib/module/FireworkSDK.js.map +1 -0
  107. package/lib/module/VideoShopping.js +134 -0
  108. package/lib/module/VideoShopping.js.map +1 -0
  109. package/lib/module/components/CartContainer.js +18 -0
  110. package/lib/module/components/CartContainer.js.map +1 -0
  111. package/lib/module/components/FWVideoFeed.js +8 -0
  112. package/lib/module/components/FWVideoFeed.js.map +1 -0
  113. package/lib/module/components/VideoFeed.js +66 -0
  114. package/lib/module/components/VideoFeed.js.map +1 -0
  115. package/lib/module/constants/FWErrorMessage.js +7 -0
  116. package/lib/module/constants/FWErrorMessage.js.map +1 -0
  117. package/lib/module/index.js +10 -0
  118. package/lib/module/index.js.map +1 -0
  119. package/lib/module/models/ADConfig.js +2 -0
  120. package/lib/module/models/ADConfig.js.map +1 -0
  121. package/lib/module/models/AddToCartResult.js +2 -0
  122. package/lib/module/models/AddToCartResult.js.map +1 -0
  123. package/lib/module/models/FWError.js +2 -0
  124. package/lib/module/models/FWError.js.map +1 -0
  125. package/lib/module/models/FWEvents.js +13 -0
  126. package/lib/module/models/FWEvents.js.map +1 -0
  127. package/lib/module/models/FeedItemDetails.js +2 -0
  128. package/lib/module/models/FeedItemDetails.js.map +1 -0
  129. package/lib/module/models/Product.js +2 -0
  130. package/lib/module/models/Product.js.map +1 -0
  131. package/lib/module/models/ProductInfoViewConfiguration.js +2 -0
  132. package/lib/module/models/ProductInfoViewConfiguration.js.map +1 -0
  133. package/lib/module/models/ProductUnit.js +2 -0
  134. package/lib/module/models/ProductUnit.js.map +1 -0
  135. package/lib/module/models/VideoFeedConfiguration.js +2 -0
  136. package/lib/module/models/VideoFeedConfiguration.js.map +1 -0
  137. package/lib/module/models/VideoPlaybackDetails.js +2 -0
  138. package/lib/module/models/VideoPlaybackDetails.js.map +1 -0
  139. package/lib/module/models/VideoPlaybackEventName.js +16 -0
  140. package/lib/module/models/VideoPlaybackEventName.js.map +1 -0
  141. package/lib/module/models/VideoPlayerConfiguration.js +2 -0
  142. package/lib/module/models/VideoPlayerConfiguration.js.map +1 -0
  143. package/lib/module/modules/FireworkSDKModule.js +10 -0
  144. package/lib/module/modules/FireworkSDKModule.js.map +1 -0
  145. package/lib/module/modules/ShoppingModule.js +10 -0
  146. package/lib/module/modules/ShoppingModule.js.map +1 -0
  147. package/lib/typescript/FireworkSDK.d.ts +74 -0
  148. package/lib/typescript/VideoShopping.d.ts +54 -0
  149. package/lib/typescript/components/CartContainer.d.ts +3 -0
  150. package/lib/typescript/components/FWVideoFeed.d.ts +2 -0
  151. package/lib/typescript/components/VideoFeed.d.ts +53 -0
  152. package/lib/typescript/constants/FWErrorMessage.d.ts +2 -0
  153. package/lib/typescript/index.d.ts +25 -0
  154. package/lib/typescript/models/ADConfig.d.ts +10 -0
  155. package/lib/typescript/models/AddToCartResult.d.ts +10 -0
  156. package/lib/typescript/models/FWError.d.ts +10 -0
  157. package/lib/typescript/models/FWEvents.d.ts +55 -0
  158. package/lib/typescript/models/FeedItemDetails.d.ts +14 -0
  159. package/lib/typescript/models/Product.d.ts +19 -0
  160. package/lib/typescript/models/ProductInfoViewConfiguration.d.ts +18 -0
  161. package/lib/typescript/models/ProductUnit.d.ts +22 -0
  162. package/lib/typescript/models/VideoFeedConfiguration.d.ts +32 -0
  163. package/lib/typescript/models/VideoPlaybackDetails.d.ts +31 -0
  164. package/lib/typescript/models/VideoPlaybackEventName.d.ts +39 -0
  165. package/lib/typescript/models/VideoPlayerConfiguration.d.ts +25 -0
  166. package/lib/typescript/modules/FireworkSDKModule.d.ts +12 -0
  167. package/lib/typescript/modules/ShoppingModule.d.ts +13 -0
  168. package/package.json +147 -0
  169. package/react-native-firework-sdk.podspec +22 -0
  170. package/src/FireworkSDK.ts +153 -0
  171. package/src/VideoShopping.ts +165 -0
  172. package/src/components/CartContainer.tsx +20 -0
  173. package/src/components/FWVideoFeed.tsx +10 -0
  174. package/src/components/VideoFeed.tsx +109 -0
  175. package/src/constants/FWErrorMessage.ts +11 -0
  176. package/src/index.tsx +109 -0
  177. package/src/models/ADConfig.ts +10 -0
  178. package/src/models/AddToCartResult.ts +10 -0
  179. package/src/models/FWError.ts +10 -0
  180. package/src/models/FWEvents.ts +63 -0
  181. package/src/models/FeedItemDetails.ts +14 -0
  182. package/src/models/Product.ts +20 -0
  183. package/src/models/ProductInfoViewConfiguration.ts +20 -0
  184. package/src/models/ProductUnit.ts +23 -0
  185. package/src/models/VideoFeedConfiguration.ts +35 -0
  186. package/src/models/VideoPlaybackDetails.ts +33 -0
  187. package/src/models/VideoPlaybackEventName.ts +40 -0
  188. package/src/models/VideoPlayerConfiguration.ts +26 -0
  189. package/src/modules/FireworkSDKModule.ts +27 -0
  190. package/src/modules/ShoppingModule.ts +29 -0
@@ -0,0 +1,109 @@
1
+ import React from 'react';
2
+ import { UIManager, findNodeHandle, StyleProp, ViewStyle } from 'react-native';
3
+ import type { NativeSyntheticEvent, TargetedEvent } from 'react-native';
4
+ import type VideoPlayerConfiguration from '../models/VideoPlayerConfiguration';
5
+ import type VideoFeedConfiguration from '../models/VideoFeedConfiguration';
6
+ import type FWError from '../models/FWError';
7
+ import FWVideoFeed from './FWVideoFeed';
8
+
9
+ export type VideoFeedSource = 'discover' | 'channel' | 'playlist';
10
+ export type VideoFeedMode = 'row' | 'column' | 'grid';
11
+
12
+ export interface IVideoFeedProps {
13
+ /**
14
+ * Standard React Native View Style.
15
+ */
16
+ style?: StyleProp<ViewStyle>;
17
+ /**
18
+ * One of three available video feed sources.
19
+ */
20
+ source: VideoFeedSource;
21
+ /**
22
+ * Channel name from which content should be displayed. Videos are ordered as a channel timeline. The prop is required when the source is set as channel or playlist.
23
+ */
24
+ channel?: string;
25
+ /**
26
+ * Playlist Id for selected content. Please note channel name is necessary. Required when the source is set as playlist.
27
+ */
28
+ playlist?: string;
29
+ /**
30
+ * One of three available display modes. Defaults to row.
31
+ */
32
+ mode?: VideoFeedMode;
33
+ /**
34
+ * Configuration of Video Feed.
35
+ */
36
+ videoFeedConfiguration?: VideoFeedConfiguration;
37
+ /**
38
+ * Configuration of Video Player.
39
+ */
40
+ videoPlayerConfiguration?: VideoPlayerConfiguration;
41
+ /**
42
+ * Video feed loading result callback. It means loading successfully when error equals to undefined.
43
+ */
44
+ onVideoFeedLoadFinished?: (error?: FWError) => void;
45
+ }
46
+
47
+ interface VideoFeedLoadFinishedEvent extends TargetedEvent {
48
+ name: string;
49
+ reason?: string | null;
50
+ }
51
+
52
+ const NativeComponentName = 'FWVideoFeed';
53
+
54
+ export default class VideoFeed extends React.Component<IVideoFeedProps> {
55
+ static defaultProps = {
56
+ mode: 'row',
57
+ };
58
+
59
+ nativeComponentRef = React.createRef<any>();
60
+ /**
61
+ * Force refreshing the video feed.
62
+ */
63
+ public refresh = () => {
64
+ const nativeNodeHandle = findNodeHandle(this.nativeComponentRef.current);
65
+
66
+ UIManager.dispatchViewManagerCommand(
67
+ findNodeHandle(nativeNodeHandle),
68
+ UIManager.getViewManagerConfig(NativeComponentName).Commands.refresh,
69
+ []
70
+ );
71
+ };
72
+
73
+ private _onVideoFeedLoadFinished = (
74
+ event: NativeSyntheticEvent<VideoFeedLoadFinishedEvent>
75
+ ) => {
76
+ const { name, reason } = event.nativeEvent;
77
+ if (this.props.onVideoFeedLoadFinished) {
78
+ if (name) {
79
+ this.props.onVideoFeedLoadFinished({ name, reason });
80
+ } else {
81
+ this.props.onVideoFeedLoadFinished();
82
+ }
83
+ }
84
+ };
85
+
86
+ render() {
87
+ const {
88
+ source,
89
+ channel = '',
90
+ playlist = '',
91
+ mode = 'row',
92
+ videoFeedConfiguration,
93
+ } = this.props;
94
+ const titleHidden = videoFeedConfiguration?.title?.hidden ?? false;
95
+ const titlePosition = videoFeedConfiguration?.titlePosition ?? 'nested';
96
+
97
+ const key = `source:${source}_channel:${channel}_playlist:${playlist}_mode:${mode}_titleHidden:${titleHidden}_titlePosition:${titlePosition}`;
98
+
99
+ return (
100
+ <FWVideoFeed
101
+ key={key}
102
+ {...this.props}
103
+ ref={this.nativeComponentRef}
104
+ onVideoFeedLoadFinished={this._onVideoFeedLoadFinished}
105
+ mode={mode}
106
+ />
107
+ );
108
+ }
109
+ }
@@ -0,0 +1,11 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ const LINKING_ERROR =
4
+ `The package 'react-native-firework-sdk' doesn't seem to be linked. Make sure: \n\n` +
5
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
6
+ '- You rebuilt the app after installing the package\n' +
7
+ '- You are not using Expo managed workflow\n';
8
+
9
+ export {
10
+ LINKING_ERROR,
11
+ };
package/src/index.tsx ADDED
@@ -0,0 +1,109 @@
1
+ import { AppRegistry } from 'react-native';
2
+
3
+ import CartContainer from './components/CartContainer';
4
+ import type {
5
+ IVideoFeedProps,
6
+ VideoFeedMode,
7
+ VideoFeedSource,
8
+ } from './components/VideoFeed';
9
+ import VideoFeed from './components/VideoFeed';
10
+ import type {
11
+ CustomCTAClickCallback,
12
+ SDKInitCallback,
13
+ VideoFeedClickCallback,
14
+ VideoPlaybackCallback,
15
+ } from './FireworkSDK';
16
+ import FireworkSDK from './FireworkSDK';
17
+ import type ADConfig from './models/ADConfig';
18
+ import type AddToCartResult from './models/AddToCartResult';
19
+ import type FeedItemDetails from './models/FeedItemDetails';
20
+ import type FWError from './models/FWError';
21
+ import type {
22
+ AddToCartEvent,
23
+ CustomCTAClickEvent,
24
+ SDKInitEvent,
25
+ UpdateProductDetailsEvent,
26
+ VideoPlaybackEvent,
27
+ WillDisplayProductEvent,
28
+ } from './models/FWEvents';
29
+ import type Product from './models/Product';
30
+ import type ProductInfoViewConfiguration from './models/ProductInfoViewConfiguration';
31
+ import type {
32
+ AddToCartButtonConfiguration,
33
+ CartIconConfiguration,
34
+ } from './models/ProductInfoViewConfiguration';
35
+ import type ProductUnit from './models/ProductUnit';
36
+ import type { ProductPrice } from './models/ProductUnit';
37
+ import type VideoFeedConfiguration from './models/VideoFeedConfiguration';
38
+ import type {
39
+ VideoFeedPlayIconConfiguration,
40
+ VideoFeedTitleConfiguration,
41
+ VideoFeedTitlePosition,
42
+ } from './models/VideoFeedConfiguration';
43
+ import type VideoPlaybackDetails from './models/VideoPlaybackDetails';
44
+ import type {
45
+ VideoBadge,
46
+ VideoPlayerSize,
47
+ } from './models/VideoPlaybackDetails';
48
+ import VideoPlaybackEventName from './models/VideoPlaybackEventName';
49
+ import type VideoPlayerConfiguration from './models/VideoPlayerConfiguration';
50
+ import type {
51
+ VideoPlayerCompleteAction,
52
+ VideoPlayerCTAStyle,
53
+ VideoPlayerStyle,
54
+ } from './models/VideoPlayerConfiguration';
55
+ import type {
56
+ AddToCartCallback,
57
+ ClickCartIconCallback,
58
+ UpdateProductDetailsCallback,
59
+ WillDisplayProductCallback,
60
+ } from './VideoShopping';
61
+ import VideoShopping from './VideoShopping';
62
+
63
+ AppRegistry.registerComponent('FWShoppingCartPage', () => CartContainer);
64
+
65
+ export default FireworkSDK;
66
+
67
+ export {
68
+ ADConfig,
69
+ AddToCartButtonConfiguration,
70
+ AddToCartCallback,
71
+ AddToCartEvent,
72
+ AddToCartResult,
73
+ CartIconConfiguration,
74
+ ClickCartIconCallback,
75
+ CustomCTAClickCallback,
76
+ CustomCTAClickEvent,
77
+ FeedItemDetails,
78
+ FWError,
79
+ IVideoFeedProps,
80
+ Product,
81
+ ProductInfoViewConfiguration,
82
+ ProductPrice,
83
+ ProductUnit,
84
+ SDKInitCallback,
85
+ SDKInitEvent,
86
+ UpdateProductDetailsCallback,
87
+ UpdateProductDetailsEvent,
88
+ VideoBadge,
89
+ VideoFeed,
90
+ VideoFeedClickCallback,
91
+ VideoFeedConfiguration,
92
+ VideoFeedMode,
93
+ VideoFeedPlayIconConfiguration,
94
+ VideoFeedSource,
95
+ VideoFeedTitleConfiguration,
96
+ VideoFeedTitlePosition,
97
+ VideoPlaybackCallback,
98
+ VideoPlaybackDetails,
99
+ VideoPlaybackEvent,
100
+ VideoPlaybackEventName,
101
+ VideoPlayerCompleteAction,
102
+ VideoPlayerConfiguration,
103
+ VideoPlayerCTAStyle,
104
+ VideoPlayerSize,
105
+ VideoPlayerStyle,
106
+ VideoShopping,
107
+ WillDisplayProductCallback,
108
+ WillDisplayProductEvent,
109
+ };
@@ -0,0 +1,10 @@
1
+ export default interface ADConfig {
2
+ /**
3
+ * Defaults to none.
4
+ */
5
+ type?: 'none' | 'admob' | 'ima',
6
+ /**
7
+ * Defaults to true. The property only takes effect when type is admob.
8
+ */
9
+ startMobileAds?: boolean,
10
+ }
@@ -0,0 +1,10 @@
1
+ export default interface AddToCartResult {
2
+ /**
3
+ * The result of Adding to Cart
4
+ */
5
+ res: 'success' | 'fail';
6
+ /**
7
+ * Success or fail message to display to the user
8
+ */
9
+ tips: string;
10
+ }
@@ -0,0 +1,10 @@
1
+ export default interface FWError {
2
+ /**
3
+ * Error name
4
+ */
5
+ name: string;
6
+ /**
7
+ * Error Reason
8
+ */
9
+ reason?: string | null;
10
+ }
@@ -0,0 +1,63 @@
1
+ import type VideoPlaybackDetails from './VideoPlaybackDetails';
2
+ import type FWError from './FWError';
3
+ import type VideoPlaybackEventName from './VideoPlaybackEventName';
4
+ import type FeedItemDetails from './FeedItemDetails';
5
+
6
+ export enum FWEventName {
7
+ SDKInit = 'fw:sdk-init',
8
+ CustomCTAClick = 'fw:custom-cta-click',
9
+ VideoPlayback = 'fw:video-playback',
10
+ VideoFeedClick = 'fw:video-feed-click',
11
+ AddToCart = 'fw:shopping:add-to-cart',
12
+ ClickCartIcon = 'fw:shopping:click-cart-icon',
13
+ UpdateProductDetails = 'fw:shopping:update-product-details',
14
+ WillDisplayProduct = 'fw:shopping:will-display-product',
15
+ }
16
+
17
+ export interface SDKInitEvent {
18
+ /**
19
+ * If error equals undefined/null, it means the initialization is successful.
20
+ */
21
+ error?: FWError | null;
22
+ }
23
+
24
+ export interface CustomCTAClickEvent {
25
+ /**
26
+ * Action URL that is associated with this CTA
27
+ */
28
+ url: string;
29
+ }
30
+
31
+ export interface VideoPlaybackEvent {
32
+ eventName: VideoPlaybackEventName;
33
+ info: VideoPlaybackDetails;
34
+ }
35
+
36
+ export interface VideoFeedClickEvent {
37
+ info: FeedItemDetails;
38
+ }
39
+
40
+ export interface AddToCartEvent {
41
+ /**
42
+ * A unique identifier of the product.
43
+ */
44
+ productId: string;
45
+ /**
46
+ * A unique identifier of the product unit.
47
+ */
48
+ unitId: string;
49
+ }
50
+
51
+ export interface UpdateProductDetailsEvent {
52
+ /**
53
+ * A unique identifier of the product.
54
+ */
55
+ productId: string;
56
+ }
57
+
58
+ export interface WillDisplayProductEvent {
59
+ /**
60
+ * A unique identifier of the video.
61
+ */
62
+ videoId: string;
63
+ }
@@ -0,0 +1,14 @@
1
+ export default interface FeedItemDetails {
2
+ /**
3
+ * The index of the thumbnail tapped in the video feed.
4
+ */
5
+ index: number;
6
+ /**
7
+ * A unique id for the video.
8
+ */
9
+ videoId: string;
10
+ /**
11
+ * The total duration of the video
12
+ */
13
+ duration: number;
14
+ }
@@ -0,0 +1,20 @@
1
+ import type ProductUnit from './ProductUnit';
2
+
3
+ export default interface Product {
4
+ /**
5
+ * A unique identifier of the product.
6
+ */
7
+ productId: string;
8
+ /**
9
+ * The name of the product.
10
+ */
11
+ name?: string | null;
12
+ /**
13
+ * The description of the product.
14
+ */
15
+ description?: string | null;
16
+ /**
17
+ * The unit array of the product
18
+ */
19
+ units?: ProductUnit[] | null;
20
+ }
@@ -0,0 +1,20 @@
1
+ export interface CartIconConfiguration {
2
+ isHidden?: boolean;
3
+ }
4
+
5
+ export interface AddToCartButtonConfiguration {
6
+ backgroundColor?: string;
7
+ textColor?: string;
8
+ fontSize?: number;
9
+ }
10
+
11
+ export default interface ProductInfoViewConfiguration {
12
+ /**
13
+ * Configuration of cart icon.
14
+ */
15
+ cartIcon?: CartIconConfiguration;
16
+ /**
17
+ * Configuration of "Add to cart" button.
18
+ */
19
+ addToCartButton?: AddToCartButtonConfiguration;
20
+ }
@@ -0,0 +1,23 @@
1
+ export interface ProductPrice {
2
+ amount: number;
3
+ currencyCode: string;
4
+ }
5
+
6
+ export default interface ProductUnit {
7
+ /**
8
+ * The unique identifier of the product unit.
9
+ */
10
+ unitId: string;
11
+ /**
12
+ * The name of the product unit.
13
+ */
14
+ name?: string | null;
15
+ /**
16
+ * The url of the product unit.
17
+ */
18
+ url?: string;
19
+ /**
20
+ * The price of the product unit.
21
+ */
22
+ price?: ProductPrice;
23
+ }
@@ -0,0 +1,35 @@
1
+ export interface VideoFeedTitleConfiguration {
2
+ hidden?: boolean;
3
+ textColor?: string;
4
+ fontSize?: number;
5
+ }
6
+
7
+ export interface VideoFeedPlayIconConfiguration {
8
+ hidden?: boolean;
9
+ iconWidth?: number;
10
+ }
11
+
12
+ export type VideoFeedTitlePosition = 'stacked' | 'nested';
13
+
14
+ export default interface VideoFeedConfiguration {
15
+ /**
16
+ * BackgroundColor of video feed.
17
+ */
18
+ backgroundColor?: string;
19
+ /**
20
+ * CornerRadius of video feed.
21
+ */
22
+ cornerRadius?: number;
23
+ /**
24
+ * Configuration of video feed title.
25
+ */
26
+ title?: VideoFeedTitleConfiguration;
27
+ /**
28
+ * Configuration of video feed title position.
29
+ */
30
+ titlePosition?: VideoFeedTitlePosition;
31
+ /**
32
+ * Configuration of video feed play icon.
33
+ */
34
+ playIcon?: VideoFeedPlayIconConfiguration;
35
+ }
@@ -0,0 +1,33 @@
1
+ export interface VideoPlayerSize {
2
+ width: number;
3
+ height: number;
4
+ }
5
+
6
+ export type VideoBadge = 'ad' | 'demo' | 'featured';
7
+
8
+ export default interface VideoPlaybackDetails {
9
+ /**
10
+ * A unique identifier of the video.
11
+ */
12
+ videoId: string;
13
+ /**
14
+ * The total duration of the video.
15
+ */
16
+ duration?: number | null;
17
+ /**
18
+ * The caption for the video.
19
+ */
20
+ caption?: string | null;
21
+ /**
22
+ * Video badge type.
23
+ */
24
+ badge?: VideoBadge | null;
25
+ /**
26
+ * The size of the player.
27
+ */
28
+ playerSize?: VideoPlayerSize | null;
29
+ /**
30
+ * Indicates if the video is associated with a call-to-action (CTA).
31
+ */
32
+ hasCTA?: boolean | null;
33
+ }
@@ -0,0 +1,40 @@
1
+ enum VideoPlaybackEventName {
2
+ /**
3
+ * When video is shown to the user.
4
+ */
5
+ Impression = 'fw:video:impression',
6
+ /**
7
+ * Video started.
8
+ */
9
+ Start = 'fw:video:start',
10
+ /**
11
+ * Video reached 25%.
12
+ */
13
+ FirstQuartile = 'fw:video:first-quartile',
14
+ /**
15
+ * Video reached 50%.
16
+ */
17
+ Midpoint = 'fw:video:midpoint',
18
+ /**
19
+ * Video reached 75%.
20
+ */
21
+ ThirdQuartile = 'fw:video:third-quartile',
22
+ /**
23
+ * Video reached 100%.
24
+ */
25
+ Complete = 'fw:video:complete',
26
+ /**
27
+ * When ad video finishes playing
28
+ */
29
+ AdEnd = 'fw:video:ad-end',
30
+ /**
31
+ * When a visitor clicks on CTA button (if available).
32
+ */
33
+ ClickCTA = 'fw:video:click-cta',
34
+ /**
35
+ * When user clicks on "Share" button.
36
+ */
37
+ ClickShare = 'fw:video:click-share',
38
+ }
39
+
40
+ export default VideoPlaybackEventName;
@@ -0,0 +1,26 @@
1
+ export type VideoPlayerStyle = 'full' | 'fit';
2
+ export type VideoPlayerCompleteAction = 'loop' | 'advanceToNext';
3
+ export interface VideoPlayerCTAStyle {
4
+ backgroundColor?: string;
5
+ textColor?: string;
6
+ fontSize?: number;
7
+ }
8
+
9
+ export default interface VideoPlayerConfiguration {
10
+ /**
11
+ * Sets the proportion of the video player to its container.
12
+ */
13
+ playerStyle?: VideoPlayerStyle;
14
+ /**
15
+ * Behavior occurring after video is complete.
16
+ */
17
+ videoCompleteAction?: VideoPlayerCompleteAction;
18
+ /**
19
+ * Indicates if the video player shows share button.
20
+ */
21
+ showShareButton?: boolean;
22
+ /**
23
+ * The style of CTA button style.
24
+ */
25
+ ctaButtonStyle?: VideoPlayerCTAStyle;
26
+ }
@@ -0,0 +1,27 @@
1
+ import type { NativeModule } from 'react-native';
2
+ import { NativeModules } from 'react-native';
3
+
4
+ import { LINKING_ERROR } from '../constants/FWErrorMessage';
5
+ import type ADConfig from '../models/ADConfig';
6
+ import type VideoPlayerConfiguration from '../models/VideoPlayerConfiguration';
7
+
8
+ const FireworkSDKModule = NativeModules.FireworkSDK
9
+ ? NativeModules.FireworkSDK
10
+ : new Proxy(
11
+ {},
12
+ {
13
+ get() {
14
+ throw new Error(LINKING_ERROR);
15
+ },
16
+ }
17
+ );
18
+
19
+ interface IFireworkSDKModule extends NativeModule {
20
+ init(userId?: string, adConfig?: ADConfig): void;
21
+ openVideoPlayer(url: string, config?: VideoPlayerConfiguration): void;
22
+ setCustomCTAClickEnabled(enabled: boolean): void;
23
+ setShareBaseURL(url?: string): void;
24
+ setVideoPlaybackEventEnabled(enabled: boolean): void;
25
+ }
26
+
27
+ export default FireworkSDKModule as IFireworkSDKModule;
@@ -0,0 +1,29 @@
1
+ import {
2
+ NativeModule,
3
+ NativeModules,
4
+ } from 'react-native';
5
+ import type Product from '../models/Product';
6
+ import type ProductInfoViewConfiguration from '../models/ProductInfoViewConfiguration';
7
+ import { LINKING_ERROR } from '../constants/FWErrorMessage';
8
+
9
+ const ShoppingModule = NativeModules.ShoppingModule
10
+ ? NativeModules.ShoppingModule
11
+ : new Proxy(
12
+ {},
13
+ {
14
+ get() {
15
+ throw new Error(LINKING_ERROR);
16
+ },
17
+ }
18
+ );
19
+
20
+ interface IShoppingModule extends NativeModule {
21
+ init(): void;
22
+ updateVideoProduct(production: Product, callbackId: number): void;
23
+ updateProductViewConfig(config: ProductInfoViewConfiguration, callbackId: number): void;
24
+ updateAddToCartStatus(res: string, tips: string, callbackId: number): void;
25
+ jumpToCartPage(callbackId: number): void;
26
+ exitCartPage(): void;
27
+ }
28
+
29
+ export default ShoppingModule as IShoppingModule;