@octopus-community/react-native 1.0.8 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/OctopusReactNativeSdk.podspec +1 -1
  2. package/README.md +40 -35
  3. package/android/build.gradle +2 -0
  4. package/android/gradle.properties +2 -2
  5. package/android/src/main/AndroidManifest.xml +2 -1
  6. package/android/src/main/AndroidManifestNew.xml +2 -1
  7. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusActivity.kt +56 -0
  8. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusContent.kt +396 -0
  9. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventEmitter.kt +22 -0
  10. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusEventSerializer.kt +339 -0
  11. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactModule.kt +326 -0
  12. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/{OctopusReactNativeSdkPackage.kt → OctopusReactPackage.kt} +3 -3
  13. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSDKInitializer.kt +22 -9
  14. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusSSOAuthenticator.kt +5 -15
  15. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIController.kt +17 -2
  16. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIViewManager.kt +63 -0
  17. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/ProfileFieldMapper.kt +2 -2
  18. package/ios/OctopusEventManager.swift +27 -0
  19. package/ios/OctopusEventSerializer.swift +271 -0
  20. package/ios/OctopusReactNativeSdk.mm +26 -1
  21. package/ios/OctopusReactNativeSdk.swift +216 -2
  22. package/ios/OctopusSSOAuthenticator.swift +1 -5
  23. package/ios/OctopusUIManager.swift +83 -0
  24. package/ios/OctopusUIViewManager.m +7 -0
  25. package/ios/OctopusUIViewManager.swift +37 -0
  26. package/lib/module/OctopusUIView.js +39 -0
  27. package/lib/module/OctopusUIView.js.map +1 -0
  28. package/lib/module/addHasAccessToCommunityListener.js +33 -0
  29. package/lib/module/addHasAccessToCommunityListener.js.map +1 -0
  30. package/lib/module/addNavigateToUrlListener.js +41 -0
  31. package/lib/module/addNavigateToUrlListener.js.map +1 -0
  32. package/lib/module/addNotSeenNotificationsCountListener.js +30 -0
  33. package/lib/module/addNotSeenNotificationsCountListener.js.map +1 -0
  34. package/lib/module/addSDKEventListener.js +48 -0
  35. package/lib/module/addSDKEventListener.js.map +1 -0
  36. package/lib/module/connectUser.js +24 -3
  37. package/lib/module/connectUser.js.map +1 -1
  38. package/lib/module/index.js +12 -0
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/initialize.js +9 -12
  41. package/lib/module/initialize.js.map +1 -1
  42. package/lib/module/openUI.js +23 -2
  43. package/lib/module/openUI.js.map +1 -1
  44. package/lib/module/overrideCommunityAccess.js +36 -0
  45. package/lib/module/overrideCommunityAccess.js.map +1 -0
  46. package/lib/module/overrideDefaultLocale.js +75 -0
  47. package/lib/module/overrideDefaultLocale.js.map +1 -0
  48. package/lib/module/trackCommunityAccess.js +33 -0
  49. package/lib/module/trackCommunityAccess.js.map +1 -0
  50. package/lib/module/trackCustomEvent.js +36 -0
  51. package/lib/module/trackCustomEvent.js.map +1 -0
  52. package/lib/module/types/sdkEvents.js +2 -0
  53. package/lib/module/types/sdkEvents.js.map +1 -0
  54. package/lib/module/types/urlOpeningStrategy.js +23 -0
  55. package/lib/module/types/urlOpeningStrategy.js.map +1 -0
  56. package/lib/module/updateNotSeenNotificationsCount.js +33 -0
  57. package/lib/module/updateNotSeenNotificationsCount.js.map +1 -0
  58. package/lib/typescript/src/OctopusUIView.d.ts +32 -0
  59. package/lib/typescript/src/OctopusUIView.d.ts.map +1 -0
  60. package/lib/typescript/src/addHasAccessToCommunityListener.d.ts +27 -0
  61. package/lib/typescript/src/addHasAccessToCommunityListener.d.ts.map +1 -0
  62. package/lib/typescript/src/addNavigateToUrlListener.d.ts +31 -0
  63. package/lib/typescript/src/addNavigateToUrlListener.d.ts.map +1 -0
  64. package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts +24 -0
  65. package/lib/typescript/src/addNotSeenNotificationsCountListener.d.ts.map +1 -0
  66. package/lib/typescript/src/addSDKEventListener.d.ts +43 -0
  67. package/lib/typescript/src/addSDKEventListener.d.ts.map +1 -0
  68. package/lib/typescript/src/connectUser.d.ts +24 -8
  69. package/lib/typescript/src/connectUser.d.ts.map +1 -1
  70. package/lib/typescript/src/index.d.ts +13 -0
  71. package/lib/typescript/src/index.d.ts.map +1 -1
  72. package/lib/typescript/src/initialize.d.ts +9 -12
  73. package/lib/typescript/src/initialize.d.ts.map +1 -1
  74. package/lib/typescript/src/openUI.d.ts +28 -1
  75. package/lib/typescript/src/openUI.d.ts.map +1 -1
  76. package/lib/typescript/src/overrideCommunityAccess.d.ts +30 -0
  77. package/lib/typescript/src/overrideCommunityAccess.d.ts.map +1 -0
  78. package/lib/typescript/src/overrideDefaultLocale.d.ts +37 -0
  79. package/lib/typescript/src/overrideDefaultLocale.d.ts.map +1 -0
  80. package/lib/typescript/src/trackCommunityAccess.d.ts +27 -0
  81. package/lib/typescript/src/trackCommunityAccess.d.ts.map +1 -0
  82. package/lib/typescript/src/trackCustomEvent.d.ts +30 -0
  83. package/lib/typescript/src/trackCustomEvent.d.ts.map +1 -0
  84. package/lib/typescript/src/types/sdkEvents.d.ts +222 -0
  85. package/lib/typescript/src/types/sdkEvents.d.ts.map +1 -0
  86. package/lib/typescript/src/types/urlOpeningStrategy.d.ts +20 -0
  87. package/lib/typescript/src/types/urlOpeningStrategy.d.ts.map +1 -0
  88. package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts +27 -0
  89. package/lib/typescript/src/updateNotSeenNotificationsCount.d.ts.map +1 -0
  90. package/package.json +2 -1
  91. package/src/OctopusUIView.tsx +57 -0
  92. package/src/addHasAccessToCommunityListener.ts +38 -0
  93. package/src/addNavigateToUrlListener.ts +54 -0
  94. package/src/addNotSeenNotificationsCountListener.ts +35 -0
  95. package/src/addSDKEventListener.ts +49 -0
  96. package/src/connectUser.ts +24 -8
  97. package/src/index.ts +13 -0
  98. package/src/initialize.ts +9 -12
  99. package/src/openUI.ts +32 -2
  100. package/src/overrideCommunityAccess.ts +33 -0
  101. package/src/overrideDefaultLocale.ts +88 -0
  102. package/src/trackCommunityAccess.ts +30 -0
  103. package/src/trackCustomEvent.ts +36 -0
  104. package/src/types/sdkEvents.ts +315 -0
  105. package/src/types/urlOpeningStrategy.ts +20 -0
  106. package/src/updateNotSeenNotificationsCount.ts +30 -0
  107. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusReactNativeSdkModule.kt +0 -155
  108. package/android/src/main/java/com/octopuscommunity/octopusreactnativesdk/OctopusUIActivity.kt +0 -434
@@ -0,0 +1,315 @@
1
+ /**
2
+ * Types for SDK events emitted by Octopus SDK.
3
+ * These events represent various user interactions and system events within the Octopus community.
4
+ */
5
+
6
+ /**
7
+ * Content types that can be included in a post
8
+ */
9
+ export type PostContentType = 'text' | 'image' | 'poll';
10
+
11
+ /**
12
+ * Content kind (post, comment, or reply)
13
+ */
14
+ export type ContentKind = 'post' | 'comment' | 'reply';
15
+
16
+ /**
17
+ * Reaction kinds
18
+ */
19
+ export type ReactionKind =
20
+ | 'heart'
21
+ | 'joy'
22
+ | 'mouthOpen'
23
+ | 'clap'
24
+ | 'cry'
25
+ | 'rage'
26
+ | 'unknown';
27
+
28
+ /**
29
+ * Report reasons for content or profile reporting
30
+ */
31
+ export type ReportReason =
32
+ | 'hateSpeech'
33
+ | 'explicit'
34
+ | 'violence'
35
+ | 'spam'
36
+ | 'suicide'
37
+ | 'fakeProfile'
38
+ | 'childExploitation'
39
+ | 'intellectualProperty'
40
+ | 'other';
41
+
42
+ /**
43
+ * Gamification actions that can gain points
44
+ */
45
+ export type GamificationPointsGainedAction =
46
+ | 'post'
47
+ | 'comment'
48
+ | 'reply'
49
+ | 'reaction'
50
+ | 'vote'
51
+ | 'postCommented'
52
+ | 'profileCompleted'
53
+ | 'dailySession';
54
+
55
+ /**
56
+ * Gamification actions that can remove points
57
+ */
58
+ export type GamificationPointsRemovedAction =
59
+ | 'postDeleted'
60
+ | 'commentDeleted'
61
+ | 'replyDeleted'
62
+ | 'reactionDeleted';
63
+
64
+ /**
65
+ * Source of a post click
66
+ */
67
+ export type PostClickedSource = 'feed' | 'profile';
68
+
69
+ /**
70
+ * Screen types displayed in the Octopus UI
71
+ */
72
+ export type ScreenType =
73
+ | 'postsFeed'
74
+ | 'postDetail'
75
+ | 'commentDetail'
76
+ | 'createPost'
77
+ | 'profile'
78
+ | 'otherUserProfile'
79
+ | 'editProfile'
80
+ | 'reportContent'
81
+ | 'reportProfile'
82
+ | 'validateNickname'
83
+ | 'settingsList'
84
+ | 'settingsAccount'
85
+ | 'settingsAbout'
86
+ | 'reportExplanation'
87
+ | 'deleteAccount';
88
+
89
+ /**
90
+ * Base interface for all SDK events
91
+ */
92
+ export interface BaseSDKEvent {
93
+ type: string;
94
+ }
95
+
96
+ /**
97
+ * Event emitted when a post is created
98
+ */
99
+ export interface PostCreatedEvent extends BaseSDKEvent {
100
+ type: 'postCreated';
101
+ postId: string;
102
+ content: PostContentType[];
103
+ topicId: string | null;
104
+ textLength: number;
105
+ }
106
+
107
+ /**
108
+ * Event emitted when a comment is created
109
+ */
110
+ export interface CommentCreatedEvent extends BaseSDKEvent {
111
+ type: 'commentCreated';
112
+ commentId: string;
113
+ postId: string;
114
+ textLength: number;
115
+ }
116
+
117
+ /**
118
+ * Event emitted when a reply is created
119
+ */
120
+ export interface ReplyCreatedEvent extends BaseSDKEvent {
121
+ type: 'replyCreated';
122
+ replyId: string;
123
+ commentId: string;
124
+ textLength: number;
125
+ }
126
+
127
+ /**
128
+ * Event emitted when content is deleted
129
+ */
130
+ export interface ContentDeletedEvent extends BaseSDKEvent {
131
+ type: 'contentDeleted';
132
+ contentId: string;
133
+ contentKind: ContentKind;
134
+ }
135
+
136
+ /**
137
+ * Event emitted when a reaction is modified (added, changed, or removed)
138
+ */
139
+ export interface ReactionModifiedEvent extends BaseSDKEvent {
140
+ type: 'reactionModified';
141
+ contentId: string;
142
+ contentKind: ContentKind;
143
+ previousReaction: ReactionKind | null;
144
+ newReaction: ReactionKind | null;
145
+ }
146
+
147
+ /**
148
+ * Event emitted when a poll is voted on
149
+ */
150
+ export interface PollVotedEvent extends BaseSDKEvent {
151
+ type: 'pollVoted';
152
+ contentId: string;
153
+ optionId: string;
154
+ }
155
+
156
+ /**
157
+ * Event emitted when content is reported
158
+ */
159
+ export interface ContentReportedEvent extends BaseSDKEvent {
160
+ type: 'contentReported';
161
+ contentId: string;
162
+ reasons: ReportReason[];
163
+ }
164
+
165
+ /**
166
+ * Event emitted when a profile is reported
167
+ */
168
+ export interface ProfileReportedEvent extends BaseSDKEvent {
169
+ type: 'profileReported';
170
+ profileId: string;
171
+ reasons: ReportReason[];
172
+ }
173
+
174
+ /**
175
+ * Event emitted when gamification points are gained
176
+ */
177
+ export interface GamificationPointsGainedEvent extends BaseSDKEvent {
178
+ type: 'gamificationPointsGained';
179
+ points: number;
180
+ action: GamificationPointsGainedAction;
181
+ }
182
+
183
+ /**
184
+ * Event emitted when gamification points are removed
185
+ */
186
+ export interface GamificationPointsRemovedEvent extends BaseSDKEvent {
187
+ type: 'gamificationPointsRemoved';
188
+ points: number;
189
+ action: GamificationPointsRemovedAction;
190
+ }
191
+
192
+ /**
193
+ * Screen information for screen displayed events
194
+ */
195
+ export interface ScreenInfo {
196
+ type: ScreenType;
197
+ feedId?: string;
198
+ relatedTopicId?: string | null;
199
+ postId?: string;
200
+ commentId?: string;
201
+ profileId?: string;
202
+ }
203
+
204
+ /**
205
+ * Event emitted when a screen is displayed
206
+ */
207
+ export interface ScreenDisplayedEvent extends BaseSDKEvent {
208
+ type: 'screenDisplayed';
209
+ screen: ScreenInfo;
210
+ }
211
+
212
+ /**
213
+ * Event emitted when a notification is clicked
214
+ */
215
+ export interface NotificationClickedEvent extends BaseSDKEvent {
216
+ type: 'notificationClicked';
217
+ notificationId: string;
218
+ contentId: string | null;
219
+ }
220
+
221
+ /**
222
+ * Event emitted when a post is clicked
223
+ */
224
+ export interface PostClickedEvent extends BaseSDKEvent {
225
+ type: 'postClicked';
226
+ postId: string;
227
+ source: PostClickedSource;
228
+ }
229
+
230
+ /**
231
+ * Event emitted when the translation button is clicked
232
+ */
233
+ export interface TranslationButtonClickedEvent extends BaseSDKEvent {
234
+ type: 'translationButtonClicked';
235
+ contentId: string;
236
+ viewTranslated: boolean;
237
+ contentKind: ContentKind;
238
+ }
239
+
240
+ /**
241
+ * Event emitted when the comment button is clicked
242
+ */
243
+ export interface CommentButtonClickedEvent extends BaseSDKEvent {
244
+ type: 'commentButtonClicked';
245
+ postId: string;
246
+ }
247
+
248
+ /**
249
+ * Event emitted when the reply button is clicked
250
+ */
251
+ export interface ReplyButtonClickedEvent extends BaseSDKEvent {
252
+ type: 'replyButtonClicked';
253
+ commentId: string;
254
+ }
255
+
256
+ /**
257
+ * Event emitted when the "see replies" button is clicked
258
+ */
259
+ export interface SeeRepliesButtonClickedEvent extends BaseSDKEvent {
260
+ type: 'seeRepliesButtonClicked';
261
+ commentId: string;
262
+ }
263
+
264
+ /**
265
+ * Event emitted when a profile is modified
266
+ */
267
+ export interface ProfileModifiedEvent extends BaseSDKEvent {
268
+ type: 'profileModified';
269
+ nicknameUpdated: boolean;
270
+ bioUpdated: boolean;
271
+ bioLength: number | null;
272
+ pictureUpdated: boolean;
273
+ hasPicture: boolean | null;
274
+ }
275
+
276
+ /**
277
+ * Event emitted when a session starts
278
+ */
279
+ export interface SessionStartedEvent extends BaseSDKEvent {
280
+ type: 'sessionStarted';
281
+ sessionId: string;
282
+ }
283
+
284
+ /**
285
+ * Event emitted when a session stops
286
+ */
287
+ export interface SessionStoppedEvent extends BaseSDKEvent {
288
+ type: 'sessionStopped';
289
+ sessionId: string;
290
+ }
291
+
292
+ /**
293
+ * Union type of all possible SDK events
294
+ */
295
+ export type SDKEvent =
296
+ | PostCreatedEvent
297
+ | CommentCreatedEvent
298
+ | ReplyCreatedEvent
299
+ | ContentDeletedEvent
300
+ | ReactionModifiedEvent
301
+ | PollVotedEvent
302
+ | ContentReportedEvent
303
+ | ProfileReportedEvent
304
+ | GamificationPointsGainedEvent
305
+ | GamificationPointsRemovedEvent
306
+ | ScreenDisplayedEvent
307
+ | NotificationClickedEvent
308
+ | PostClickedEvent
309
+ | TranslationButtonClickedEvent
310
+ | CommentButtonClickedEvent
311
+ | ReplyButtonClickedEvent
312
+ | SeeRepliesButtonClickedEvent
313
+ | ProfileModifiedEvent
314
+ | SessionStartedEvent
315
+ | SessionStoppedEvent;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Strategy for handling URLs tapped inside the Octopus Community UI.
3
+ *
4
+ * When URL interception is enabled via `openUI({ interceptUrls: true })`,
5
+ * the app receives each tapped URL via `addNavigateToUrlListener`. The callback
6
+ * returns one of these strategies to decide who handles the URL.
7
+ */
8
+ export enum UrlOpeningStrategy {
9
+ /**
10
+ * The URL has been handled by the app. The SDK will not open it.
11
+ * Use this when you open the URL in an in-app web view or handle it yourself.
12
+ */
13
+ handledByApp = 'handledByApp',
14
+
15
+ /**
16
+ * The URL should be opened by the Octopus SDK (system browser).
17
+ * The native layer will open the URL in the default browser when this is returned.
18
+ */
19
+ handledByOctopus = 'handledByOctopus',
20
+ }
@@ -0,0 +1,30 @@
1
+ import { OctopusReactNativeSdk } from './internals/nativeModule';
2
+
3
+ /**
4
+ * Force refresh the unseen notification count from the server.
5
+ *
6
+ * This method triggers a manual update of the notification badge count.
7
+ * The updated count will be emitted via the notSeenNotificationsCountChanged event.
8
+ * Use `addNotSeenNotificationsCountListener` to listen for count changes.
9
+ *
10
+ * @returns A promise that resolves when the update is complete.
11
+ * @throws An error if the SDK is not initialized or if the update fails.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Listen to count changes
16
+ * const subscription = addNotSeenNotificationsCountListener((count) => {
17
+ * console.log(`Unseen notifications: ${count}`);
18
+ * // Update your badge UI
19
+ * });
20
+ *
21
+ * // Manually refresh the count
22
+ * await updateNotSeenNotificationsCount();
23
+ *
24
+ * // Later, unsubscribe
25
+ * subscription.remove();
26
+ * ```
27
+ */
28
+ export function updateNotSeenNotificationsCount(): Promise<void> {
29
+ return OctopusReactNativeSdk.updateNotSeenNotificationsCount();
30
+ }
@@ -1,155 +0,0 @@
1
- package com.octopuscommunity.octopusreactnativesdk
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
- import com.facebook.react.bridge.ReactContextBaseJavaModule
5
- import com.facebook.react.bridge.ReactMethod
6
- import com.facebook.react.bridge.Promise
7
- import com.facebook.react.bridge.ReadableMap
8
-
9
- class OctopusReactNativeSdkModule(reactContext: ReactApplicationContext) :
10
- ReactContextBaseJavaModule(reactContext) {
11
-
12
- private val sdkInitializer = OctopusSDKInitializer()
13
- private val eventEmitter = OctopusEventEmitter(reactContext)
14
- private val uiController = OctopusUIController(reactContext)
15
- private val ssoAuthenticator = OctopusSSOAuthenticator(reactContext, eventEmitter)
16
-
17
- override fun getName(): String = NAME
18
-
19
- @ReactMethod
20
- fun initialize(options: ReadableMap, promise: Promise) {
21
- sdkInitializer.initialize(reactApplicationContext, options, promise)
22
- }
23
-
24
- @ReactMethod
25
- fun openUI(promise: Promise) {
26
- uiController.openUI(promise)
27
- }
28
-
29
- @ReactMethod
30
- fun closeUI(promise: Promise) {
31
- uiController.closeUI(promise)
32
- }
33
-
34
- @ReactMethod
35
- fun connectUser(params: ReadableMap, promise: Promise) {
36
- ssoAuthenticator.connectUser(params, promise)
37
- }
38
-
39
- @ReactMethod
40
- fun disconnectUser(promise: Promise) {
41
- ssoAuthenticator.disconnectUser(promise)
42
- }
43
-
44
- @ReactMethod
45
- fun completeUserTokenRequest(requestId: String, token: String, promise: Promise) {
46
- ssoAuthenticator.completeTokenRequest(requestId, token)
47
- promise.resolve(null)
48
- }
49
-
50
- @ReactMethod
51
- fun cancelUserTokenRequest(requestId: String, promise: Promise) {
52
- ssoAuthenticator.cancelTokenRequest(requestId)
53
- promise.resolve(null)
54
- }
55
-
56
- @ReactMethod
57
- fun addListener(eventName: String) {
58
- eventEmitter.addListener(eventName)
59
- }
60
-
61
- @ReactMethod
62
- fun removeListeners(count: Int) {
63
- eventEmitter.removeListeners(count)
64
- }
65
-
66
- @ReactMethod
67
- fun updateColorScheme(colorScheme: String?, promise: Promise) {
68
- // Update the theme config with the new color scheme
69
- val currentThemeConfig = OctopusThemeManager.getThemeConfig()
70
- if (currentThemeConfig != null) {
71
- val updatedThemeConfig = currentThemeConfig.copy(colorScheme = colorScheme)
72
- OctopusThemeManager.setThemeConfig(updatedThemeConfig)
73
- }
74
- promise.resolve(null)
75
- }
76
-
77
- @ReactMethod
78
- fun updateTheme(themeOptions: ReadableMap, promise: Promise) {
79
- try {
80
- // Parse theme using the standard initializer
81
- val themeConfig = sdkInitializer.parseThemeConfig(themeOptions)
82
- OctopusThemeManager.setThemeConfig(themeConfig)
83
- promise.resolve(null)
84
- } catch (e: Exception) {
85
- promise.reject("UPDATE_THEME_ERROR", "Failed to update theme", e)
86
- }
87
- }
88
-
89
- private fun parseColor(colorString: String?): String? {
90
- if (colorString == null) return null
91
-
92
- return try {
93
- // Validate that the color string is a valid hex color
94
- android.graphics.Color.parseColor(colorString)
95
- // Return the original string if parsing succeeds
96
- colorString
97
- } catch (e: IllegalArgumentException) {
98
- // Invalid color format - return null to skip this color
99
- null
100
- }
101
- }
102
-
103
- private fun parseFontsConfig(fontsMap: ReadableMap): OctopusFontsConfig? {
104
- // Use pre-processed configuration from TypeScript layer
105
- val parsedConfig = fontsMap.getMap("parsedConfig")
106
- if (parsedConfig != null) {
107
- return parsePreProcessedFontsConfig(parsedConfig)
108
- }
109
-
110
- return null
111
- }
112
-
113
- private fun parsePreProcessedFontsConfig(parsedConfig: ReadableMap): OctopusFontsConfig? {
114
- val textStylesMap = parsedConfig.getMap("textStyles")
115
- val textStyles = mutableMapOf<String, OctopusTextStyleConfig>()
116
-
117
- // Parse pre-processed font configuration from TypeScript layer
118
- textStylesMap?.let { textStylesMap ->
119
- val textStyleKeys = arrayOf("title1", "title2", "body1", "body2", "caption1", "caption2")
120
-
121
- textStyleKeys.forEach { key ->
122
- val textStyleMap = textStylesMap.getMap(key)
123
- textStyleMap?.let { style ->
124
- val fontType = style.getString("fontType")
125
- val fontSize = if (style.hasKey("fontSize")) style.getDouble("fontSize") else Double.NaN
126
-
127
- if (fontType != null || (!fontSize.isNaN() && fontSize > 0)) {
128
- textStyles[key] = OctopusTextStyleConfig(
129
- fontType = fontType,
130
- fontSize = if (fontSize.isNaN() || fontSize <= 0) null else fontSize
131
- )
132
- }
133
- }
134
- }
135
- }
136
-
137
- // Only create fonts config if we have text styles
138
- if (textStyles.isNotEmpty()) {
139
- return OctopusFontsConfig(
140
- textStyles = textStyles
141
- )
142
- }
143
-
144
- return null
145
- }
146
-
147
-
148
- companion object {
149
- const val NAME = "OctopusReactNativeSdk"
150
- }
151
-
152
- init {
153
- OctopusEventEmitter.instance = eventEmitter
154
- }
155
- }