react-native-monflowts 0.0.0-stage → 0.5.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 (479) hide show
  1. package/LICENSE +20 -0
  2. package/Monflowts.podspec +22 -0
  3. package/README.md +229 -2
  4. package/android/build.gradle +58 -0
  5. package/android/src/main/AndroidManifest.xml +8 -0
  6. package/android/src/main/java/com/monflowts/MonflowtsAssetsModule.kt +219 -0
  7. package/android/src/main/java/com/monflowts/MonflowtsCrashFeedModule.kt +175 -0
  8. package/android/src/main/java/com/monflowts/MonflowtsHapticModule.kt +170 -0
  9. package/android/src/main/java/com/monflowts/MonflowtsLottieView.kt +96 -0
  10. package/android/src/main/java/com/monflowts/MonflowtsLottieViewManager.kt +53 -0
  11. package/android/src/main/java/com/monflowts/MonflowtsPackage.kt +70 -0
  12. package/android/src/main/java/com/monflowts/MonflowtsSoundModule.kt +132 -0
  13. package/android/src/main/java/com/monflowts/MonflowtsSpeechModule.kt +81 -0
  14. package/android/src/main/java/com/monflowts/MonflowtsSvgView.kt +355 -0
  15. package/android/src/main/java/com/monflowts/MonflowtsSvgViewManager.kt +59 -0
  16. package/android/src/main/java/com/monflowts/MonflowtsWebView.kt +86 -0
  17. package/android/src/main/java/com/monflowts/MonflowtsWebViewManager.kt +33 -0
  18. package/android/src/main/java/com/monflowts/MonflowtsWheelView.kt +98 -0
  19. package/android/src/main/java/com/monflowts/MonflowtsWheelViewManager.kt +46 -0
  20. package/ios/Monflowts-Bridging-Header.h +5 -0
  21. package/ios/MonflowtsAssetsBridge.m +14 -0
  22. package/ios/MonflowtsAssetsModule.swift +217 -0
  23. package/ios/MonflowtsCrashFeedBridge.m +9 -0
  24. package/ios/MonflowtsCrashFeedModule.swift +88 -0
  25. package/ios/MonflowtsHTTP1EventSource.swift +296 -0
  26. package/ios/MonflowtsHapticBridge.m +8 -0
  27. package/ios/MonflowtsHapticModule.swift +55 -0
  28. package/ios/MonflowtsLottieBridge.m +12 -0
  29. package/ios/MonflowtsLottieUIView.swift +95 -0
  30. package/ios/MonflowtsLottieViewManager.swift +13 -0
  31. package/ios/MonflowtsSSEParser.swift +58 -0
  32. package/ios/MonflowtsSoundBridge.m +8 -0
  33. package/ios/MonflowtsSoundModule.swift +100 -0
  34. package/ios/MonflowtsSpeechBridge.m +9 -0
  35. package/ios/MonflowtsSpeechModule.swift +61 -0
  36. package/ios/MonflowtsSvgBridge.m +11 -0
  37. package/ios/MonflowtsSvgUIView.swift +431 -0
  38. package/ios/MonflowtsSvgViewManager.swift +13 -0
  39. package/ios/MonflowtsWebBridge.m +8 -0
  40. package/ios/MonflowtsWebUIView.swift +92 -0
  41. package/ios/MonflowtsWebViewManager.swift +14 -0
  42. package/ios/MonflowtsWheelBridge.m +7 -0
  43. package/ios/MonflowtsWheelUIView.swift +126 -0
  44. package/ios/MonflowtsWheelViewManager.swift +14 -0
  45. package/lib/module/HapticsManager.js +93 -0
  46. package/lib/module/HapticsManager.js.map +1 -0
  47. package/lib/module/HubContent.js +642 -0
  48. package/lib/module/HubContent.js.map +1 -0
  49. package/lib/module/Icons.js +64 -0
  50. package/lib/module/Icons.js.map +1 -0
  51. package/lib/module/MonflowtsHub.js +233 -0
  52. package/lib/module/MonflowtsHub.js.map +1 -0
  53. package/lib/module/NativeLottieView.js +6 -0
  54. package/lib/module/NativeLottieView.js.map +1 -0
  55. package/lib/module/NativeSvgView.js +6 -0
  56. package/lib/module/NativeSvgView.js.map +1 -0
  57. package/lib/module/NativeWebView.js +14 -0
  58. package/lib/module/NativeWebView.js.map +1 -0
  59. package/lib/module/NativeWheelView.js +6 -0
  60. package/lib/module/NativeWheelView.js.map +1 -0
  61. package/lib/module/SoundManager.js +120 -0
  62. package/lib/module/SoundManager.js.map +1 -0
  63. package/lib/module/SpeechManager.js +40 -0
  64. package/lib/module/SpeechManager.js.map +1 -0
  65. package/lib/module/api/client.js +109 -0
  66. package/lib/module/api/client.js.map +1 -0
  67. package/lib/module/api/gameTypes.js +2 -0
  68. package/lib/module/api/gameTypes.js.map +1 -0
  69. package/lib/module/api/http.js +252 -0
  70. package/lib/module/api/http.js.map +1 -0
  71. package/lib/module/api/mutations.js +359 -0
  72. package/lib/module/api/mutations.js.map +1 -0
  73. package/lib/module/api/playerTypes.js +2 -0
  74. package/lib/module/api/playerTypes.js.map +1 -0
  75. package/lib/module/api/queries.js +403 -0
  76. package/lib/module/api/queries.js.map +1 -0
  77. package/lib/module/api/sdkTypes.js +2 -0
  78. package/lib/module/api/sdkTypes.js.map +1 -0
  79. package/lib/module/assets/assetKeys.js +4 -0
  80. package/lib/module/assets/assetKeys.js.map +1 -0
  81. package/lib/module/assets/assetSync.js +61 -0
  82. package/lib/module/assets/assetSync.js.map +1 -0
  83. package/lib/module/assets/nativeAssets.js +25 -0
  84. package/lib/module/assets/nativeAssets.js.map +1 -0
  85. package/lib/module/assets/remote.js +47 -0
  86. package/lib/module/assets/remote.js.map +1 -0
  87. package/lib/module/components/AbandonPolicyNotice.js +200 -0
  88. package/lib/module/components/AbandonPolicyNotice.js.map +1 -0
  89. package/lib/module/components/AnimatedAmount.js +39 -0
  90. package/lib/module/components/AnimatedAmount.js.map +1 -0
  91. package/lib/module/components/CoinFlyOverlay.js +157 -0
  92. package/lib/module/components/CoinFlyOverlay.js.map +1 -0
  93. package/lib/module/components/GameCharacter.js +45 -0
  94. package/lib/module/components/GameCharacter.js.map +1 -0
  95. package/lib/module/components/GameRulesModal.js +279 -0
  96. package/lib/module/components/GameRulesModal.js.map +1 -0
  97. package/lib/module/components/HypeCallout.js +103 -0
  98. package/lib/module/components/HypeCallout.js.map +1 -0
  99. package/lib/module/components/InsufficientFundsOverlay.js +285 -0
  100. package/lib/module/components/InsufficientFundsOverlay.js.map +1 -0
  101. package/lib/module/components/JackpotNearMiss.js +89 -0
  102. package/lib/module/components/JackpotNearMiss.js.map +1 -0
  103. package/lib/module/components/JackpotTeaser.js +341 -0
  104. package/lib/module/components/JackpotTeaser.js.map +1 -0
  105. package/lib/module/components/MonflowtsButton.js +129 -0
  106. package/lib/module/components/MonflowtsButton.js.map +1 -0
  107. package/lib/module/components/MonflowtsChipGroup.js +40 -0
  108. package/lib/module/components/MonflowtsChipGroup.js.map +1 -0
  109. package/lib/module/components/MonflowtsPressable.js +42 -0
  110. package/lib/module/components/MonflowtsPressable.js.map +1 -0
  111. package/lib/module/components/QuitConfirmModal.js +180 -0
  112. package/lib/module/components/QuitConfirmModal.js.map +1 -0
  113. package/lib/module/components/SessionTimer.js +77 -0
  114. package/lib/module/components/SessionTimer.js.map +1 -0
  115. package/lib/module/components/SideDemoTab.js +110 -0
  116. package/lib/module/components/SideDemoTab.js.map +1 -0
  117. package/lib/module/components/StakeInput.js +138 -0
  118. package/lib/module/components/StakeInput.js.map +1 -0
  119. package/lib/module/constants.js +50 -0
  120. package/lib/module/constants.js.map +1 -0
  121. package/lib/module/content.js +21 -0
  122. package/lib/module/content.js.map +1 -0
  123. package/lib/module/effects/EffectBurst.js +56 -0
  124. package/lib/module/effects/EffectBurst.js.map +1 -0
  125. package/lib/module/effects/beaverStates.js +11 -0
  126. package/lib/module/effects/beaverStates.js.map +1 -0
  127. package/lib/module/effects/hypePhrases.js +67 -0
  128. package/lib/module/effects/hypePhrases.js.map +1 -0
  129. package/lib/module/effects/particleAnims.js +17 -0
  130. package/lib/module/effects/particleAnims.js.map +1 -0
  131. package/lib/module/hooks/useAvailableGames.js +29 -0
  132. package/lib/module/hooks/useAvailableGames.js.map +1 -0
  133. package/lib/module/hooks/useCrash.js +137 -0
  134. package/lib/module/hooks/useCrash.js.map +1 -0
  135. package/lib/module/hooks/useCrashFeed.js +49 -0
  136. package/lib/module/hooks/useCrashFeed.js.map +1 -0
  137. package/lib/module/hooks/useCurrency.js +13 -0
  138. package/lib/module/hooks/useCurrency.js.map +1 -0
  139. package/lib/module/hooks/useFairSeed.js +55 -0
  140. package/lib/module/hooks/useFairSeed.js.map +1 -0
  141. package/lib/module/hooks/useGameEvents.js +186 -0
  142. package/lib/module/hooks/useGameEvents.js.map +1 -0
  143. package/lib/module/hooks/useGameHistory.js +55 -0
  144. package/lib/module/hooks/useGameHistory.js.map +1 -0
  145. package/lib/module/hooks/useLeaderboard.js +83 -0
  146. package/lib/module/hooks/useLeaderboard.js.map +1 -0
  147. package/lib/module/hooks/useMines.js +166 -0
  148. package/lib/module/hooks/useMines.js.map +1 -0
  149. package/lib/module/hooks/useNotifications.js +66 -0
  150. package/lib/module/hooks/useNotifications.js.map +1 -0
  151. package/lib/module/hooks/usePlayGame.js +408 -0
  152. package/lib/module/hooks/usePlayGame.js.map +1 -0
  153. package/lib/module/hooks/usePlinko.js +75 -0
  154. package/lib/module/hooks/usePlinko.js.map +1 -0
  155. package/lib/module/hooks/useRaffleDrawState.js +57 -0
  156. package/lib/module/hooks/useRaffleDrawState.js.map +1 -0
  157. package/lib/module/hooks/useRefreshWallet.js +24 -0
  158. package/lib/module/hooks/useRefreshWallet.js.map +1 -0
  159. package/lib/module/hooks/useResponsive.js +16 -0
  160. package/lib/module/hooks/useResponsive.js.map +1 -0
  161. package/lib/module/hooks/useRevealWin.js +120 -0
  162. package/lib/module/hooks/useRevealWin.js.map +1 -0
  163. package/lib/module/hooks/useScreenShake.js +32 -0
  164. package/lib/module/hooks/useScreenShake.js.map +1 -0
  165. package/lib/module/hooks/useWallet.js +77 -0
  166. package/lib/module/hooks/useWallet.js.map +1 -0
  167. package/lib/module/i18n.js +104 -0
  168. package/lib/module/i18n.js.map +1 -0
  169. package/lib/module/index.js +22 -0
  170. package/lib/module/index.js.map +1 -0
  171. package/lib/module/lottieAnimations.js +15 -0
  172. package/lib/module/lottieAnimations.js.map +1 -0
  173. package/lib/module/package.json +1 -0
  174. package/lib/module/stores/assetStore.js +140 -0
  175. package/lib/module/stores/assetStore.js.map +1 -0
  176. package/lib/module/stores/authStore.js +47 -0
  177. package/lib/module/stores/authStore.js.map +1 -0
  178. package/lib/module/stores/gameStore.js +23 -0
  179. package/lib/module/stores/gameStore.js.map +1 -0
  180. package/lib/module/stores/sdkInitStore.js +155 -0
  181. package/lib/module/stores/sdkInitStore.js.map +1 -0
  182. package/lib/module/stores/settingsStore.js +40 -0
  183. package/lib/module/stores/settingsStore.js.map +1 -0
  184. package/lib/module/theme.js +160 -0
  185. package/lib/module/theme.js.map +1 -0
  186. package/lib/module/types.js +4 -0
  187. package/lib/module/types.js.map +1 -0
  188. package/lib/module/utils/apolloError.js +69 -0
  189. package/lib/module/utils/apolloError.js.map +1 -0
  190. package/lib/module/utils/crashMultiplier.js +8 -0
  191. package/lib/module/utils/crashMultiplier.js.map +1 -0
  192. package/lib/module/utils/crashMultiplier.test.js +34 -0
  193. package/lib/module/utils/crashMultiplier.test.js.map +1 -0
  194. package/lib/module/utils/deviceAnalytics.js +51 -0
  195. package/lib/module/utils/deviceAnalytics.js.map +1 -0
  196. package/lib/module/utils/idempotency.js +66 -0
  197. package/lib/module/utils/idempotency.js.map +1 -0
  198. package/lib/module/utils/layout.js +14 -0
  199. package/lib/module/utils/layout.js.map +1 -0
  200. package/lib/module/utils/safeInlineScript.js +12 -0
  201. package/lib/module/utils/safeInlineScript.js.map +1 -0
  202. package/lib/module/utils/sseClient.js +40 -0
  203. package/lib/module/utils/sseClient.js.map +1 -0
  204. package/lib/module/views/DepositSelect.js +275 -0
  205. package/lib/module/views/DepositSelect.js.map +1 -0
  206. package/lib/module/views/Dice.js +111 -0
  207. package/lib/module/views/Dice.js.map +1 -0
  208. package/lib/module/views/DiceBattle.js +815 -0
  209. package/lib/module/views/DiceBattle.js.map +1 -0
  210. package/lib/module/views/DiceLobby.js +577 -0
  211. package/lib/module/views/DiceLobby.js.map +1 -0
  212. package/lib/module/views/FortuneWheel.js +892 -0
  213. package/lib/module/views/FortuneWheel.js.map +1 -0
  214. package/lib/module/views/Freefall.js +808 -0
  215. package/lib/module/views/Freefall.js.map +1 -0
  216. package/lib/module/views/History.js +366 -0
  217. package/lib/module/views/History.js.map +1 -0
  218. package/lib/module/views/Home.js +554 -0
  219. package/lib/module/views/Home.js.map +1 -0
  220. package/lib/module/views/Jetstream.js +889 -0
  221. package/lib/module/views/Jetstream.js.map +1 -0
  222. package/lib/module/views/Leaderboard.js +1206 -0
  223. package/lib/module/views/Leaderboard.js.map +1 -0
  224. package/lib/module/views/MillionaireHunter.js +1697 -0
  225. package/lib/module/views/MillionaireHunter.js.map +1 -0
  226. package/lib/module/views/Minefield.js +826 -0
  227. package/lib/module/views/Minefield.js.map +1 -0
  228. package/lib/module/views/PaymentWebView.js +546 -0
  229. package/lib/module/views/PaymentWebView.js.map +1 -0
  230. package/lib/module/views/PlayerCard.js +184 -0
  231. package/lib/module/views/PlayerCard.js.map +1 -0
  232. package/lib/module/views/Profile.js +531 -0
  233. package/lib/module/views/Profile.js.map +1 -0
  234. package/lib/module/views/RaffleDraw.js +1242 -0
  235. package/lib/module/views/RaffleDraw.js.map +1 -0
  236. package/lib/module/views/RevealWin.js +1267 -0
  237. package/lib/module/views/RevealWin.js.map +1 -0
  238. package/lib/module/views/Splash.js +370 -0
  239. package/lib/module/views/Splash.js.map +1 -0
  240. package/lib/module/views/Success.js +363 -0
  241. package/lib/module/views/Success.js.map +1 -0
  242. package/lib/module/views/TicketShop.js +372 -0
  243. package/lib/module/views/TicketShop.js.map +1 -0
  244. package/lib/module/views/TriviaLobby.js +582 -0
  245. package/lib/module/views/TriviaLobby.js.map +1 -0
  246. package/lib/module/views/TriviaMaster.js +884 -0
  247. package/lib/module/views/TriviaMaster.js.map +1 -0
  248. package/lib/module/views/Wallet.js +622 -0
  249. package/lib/module/views/Wallet.js.map +1 -0
  250. package/lib/module/views/WithdrawFlow.js +445 -0
  251. package/lib/module/views/WithdrawFlow.js.map +1 -0
  252. package/lib/module/views/gridGeometry.js +26 -0
  253. package/lib/module/views/gridGeometry.js.map +1 -0
  254. package/lib/module/views/revealWinHelpers.js +29 -0
  255. package/lib/module/views/revealWinHelpers.js.map +1 -0
  256. package/lib/module/views/ticketBundlePresets.js +29 -0
  257. package/lib/module/views/ticketBundlePresets.js.map +1 -0
  258. package/lib/module/views/triviaHelpers.js +78 -0
  259. package/lib/module/views/triviaHelpers.js.map +1 -0
  260. package/lib/module/voiceClips.js +16 -0
  261. package/lib/module/voiceClips.js.map +1 -0
  262. package/lib/typescript/package.json +1 -0
  263. package/lib/typescript/src/HapticsManager.d.ts +28 -0
  264. package/lib/typescript/src/HapticsManager.d.ts.map +1 -0
  265. package/lib/typescript/src/HubContent.d.ts +7 -0
  266. package/lib/typescript/src/HubContent.d.ts.map +1 -0
  267. package/lib/typescript/src/Icons.d.ts +14 -0
  268. package/lib/typescript/src/Icons.d.ts.map +1 -0
  269. package/lib/typescript/src/MonflowtsHub.d.ts +5 -0
  270. package/lib/typescript/src/MonflowtsHub.d.ts.map +1 -0
  271. package/lib/typescript/src/NativeLottieView.d.ts +13 -0
  272. package/lib/typescript/src/NativeLottieView.d.ts.map +1 -0
  273. package/lib/typescript/src/NativeSvgView.d.ts +12 -0
  274. package/lib/typescript/src/NativeSvgView.d.ts.map +1 -0
  275. package/lib/typescript/src/NativeWebView.d.ts +22 -0
  276. package/lib/typescript/src/NativeWebView.d.ts.map +1 -0
  277. package/lib/typescript/src/NativeWheelView.d.ts +9 -0
  278. package/lib/typescript/src/NativeWheelView.d.ts.map +1 -0
  279. package/lib/typescript/src/SoundManager.d.ts +29 -0
  280. package/lib/typescript/src/SoundManager.d.ts.map +1 -0
  281. package/lib/typescript/src/SpeechManager.d.ts +10 -0
  282. package/lib/typescript/src/SpeechManager.d.ts.map +1 -0
  283. package/lib/typescript/src/api/client.d.ts +7 -0
  284. package/lib/typescript/src/api/client.d.ts.map +1 -0
  285. package/lib/typescript/src/api/gameTypes.d.ts +326 -0
  286. package/lib/typescript/src/api/gameTypes.d.ts.map +1 -0
  287. package/lib/typescript/src/api/http.d.ts +61 -0
  288. package/lib/typescript/src/api/http.d.ts.map +1 -0
  289. package/lib/typescript/src/api/mutations.d.ts +22 -0
  290. package/lib/typescript/src/api/mutations.d.ts.map +1 -0
  291. package/lib/typescript/src/api/playerTypes.d.ts +53 -0
  292. package/lib/typescript/src/api/playerTypes.d.ts.map +1 -0
  293. package/lib/typescript/src/api/queries.d.ts +21 -0
  294. package/lib/typescript/src/api/queries.d.ts.map +1 -0
  295. package/lib/typescript/src/api/sdkTypes.d.ts +87 -0
  296. package/lib/typescript/src/api/sdkTypes.d.ts.map +1 -0
  297. package/lib/typescript/src/assets/assetKeys.d.ts +3 -0
  298. package/lib/typescript/src/assets/assetKeys.d.ts.map +1 -0
  299. package/lib/typescript/src/assets/assetSync.d.ts +41 -0
  300. package/lib/typescript/src/assets/assetSync.d.ts.map +1 -0
  301. package/lib/typescript/src/assets/nativeAssets.d.ts +30 -0
  302. package/lib/typescript/src/assets/nativeAssets.d.ts.map +1 -0
  303. package/lib/typescript/src/assets/remote.d.ts +8 -0
  304. package/lib/typescript/src/assets/remote.d.ts.map +1 -0
  305. package/lib/typescript/src/components/AbandonPolicyNotice.d.ts +16 -0
  306. package/lib/typescript/src/components/AbandonPolicyNotice.d.ts.map +1 -0
  307. package/lib/typescript/src/components/AnimatedAmount.d.ts +12 -0
  308. package/lib/typescript/src/components/AnimatedAmount.d.ts.map +1 -0
  309. package/lib/typescript/src/components/CoinFlyOverlay.d.ts +17 -0
  310. package/lib/typescript/src/components/CoinFlyOverlay.d.ts.map +1 -0
  311. package/lib/typescript/src/components/GameCharacter.d.ts +14 -0
  312. package/lib/typescript/src/components/GameCharacter.d.ts.map +1 -0
  313. package/lib/typescript/src/components/GameRulesModal.d.ts +10 -0
  314. package/lib/typescript/src/components/GameRulesModal.d.ts.map +1 -0
  315. package/lib/typescript/src/components/HypeCallout.d.ts +11 -0
  316. package/lib/typescript/src/components/HypeCallout.d.ts.map +1 -0
  317. package/lib/typescript/src/components/InsufficientFundsOverlay.d.ts +12 -0
  318. package/lib/typescript/src/components/InsufficientFundsOverlay.d.ts.map +1 -0
  319. package/lib/typescript/src/components/JackpotNearMiss.d.ts +8 -0
  320. package/lib/typescript/src/components/JackpotNearMiss.d.ts.map +1 -0
  321. package/lib/typescript/src/components/JackpotTeaser.d.ts +13 -0
  322. package/lib/typescript/src/components/JackpotTeaser.d.ts.map +1 -0
  323. package/lib/typescript/src/components/MonflowtsButton.d.ts +21 -0
  324. package/lib/typescript/src/components/MonflowtsButton.d.ts.map +1 -0
  325. package/lib/typescript/src/components/MonflowtsChipGroup.d.ts +18 -0
  326. package/lib/typescript/src/components/MonflowtsChipGroup.d.ts.map +1 -0
  327. package/lib/typescript/src/components/MonflowtsPressable.d.ts +39 -0
  328. package/lib/typescript/src/components/MonflowtsPressable.d.ts.map +1 -0
  329. package/lib/typescript/src/components/QuitConfirmModal.d.ts +11 -0
  330. package/lib/typescript/src/components/QuitConfirmModal.d.ts.map +1 -0
  331. package/lib/typescript/src/components/SessionTimer.d.ts +14 -0
  332. package/lib/typescript/src/components/SessionTimer.d.ts.map +1 -0
  333. package/lib/typescript/src/components/SideDemoTab.d.ts +18 -0
  334. package/lib/typescript/src/components/SideDemoTab.d.ts.map +1 -0
  335. package/lib/typescript/src/components/StakeInput.d.ts +16 -0
  336. package/lib/typescript/src/components/StakeInput.d.ts.map +1 -0
  337. package/lib/typescript/src/constants.d.ts +21 -0
  338. package/lib/typescript/src/constants.d.ts.map +1 -0
  339. package/lib/typescript/src/content.d.ts +53 -0
  340. package/lib/typescript/src/content.d.ts.map +1 -0
  341. package/lib/typescript/src/effects/EffectBurst.d.ts +20 -0
  342. package/lib/typescript/src/effects/EffectBurst.d.ts.map +1 -0
  343. package/lib/typescript/src/effects/beaverStates.d.ts +4 -0
  344. package/lib/typescript/src/effects/beaverStates.d.ts.map +1 -0
  345. package/lib/typescript/src/effects/hypePhrases.d.ts +11 -0
  346. package/lib/typescript/src/effects/hypePhrases.d.ts.map +1 -0
  347. package/lib/typescript/src/effects/particleAnims.d.ts +9 -0
  348. package/lib/typescript/src/effects/particleAnims.d.ts.map +1 -0
  349. package/lib/typescript/src/hooks/useAvailableGames.d.ts +14 -0
  350. package/lib/typescript/src/hooks/useAvailableGames.d.ts.map +1 -0
  351. package/lib/typescript/src/hooks/useCrash.d.ts +13 -0
  352. package/lib/typescript/src/hooks/useCrash.d.ts.map +1 -0
  353. package/lib/typescript/src/hooks/useCrashFeed.d.ts +22 -0
  354. package/lib/typescript/src/hooks/useCrashFeed.d.ts.map +1 -0
  355. package/lib/typescript/src/hooks/useCurrency.d.ts +6 -0
  356. package/lib/typescript/src/hooks/useCurrency.d.ts.map +1 -0
  357. package/lib/typescript/src/hooks/useFairSeed.d.ts +8 -0
  358. package/lib/typescript/src/hooks/useFairSeed.d.ts.map +1 -0
  359. package/lib/typescript/src/hooks/useGameEvents.d.ts +50 -0
  360. package/lib/typescript/src/hooks/useGameEvents.d.ts.map +1 -0
  361. package/lib/typescript/src/hooks/useGameHistory.d.ts +14 -0
  362. package/lib/typescript/src/hooks/useGameHistory.d.ts.map +1 -0
  363. package/lib/typescript/src/hooks/useLeaderboard.d.ts +71 -0
  364. package/lib/typescript/src/hooks/useLeaderboard.d.ts.map +1 -0
  365. package/lib/typescript/src/hooks/useMines.d.ts +11 -0
  366. package/lib/typescript/src/hooks/useMines.d.ts.map +1 -0
  367. package/lib/typescript/src/hooks/useNotifications.d.ts +26 -0
  368. package/lib/typescript/src/hooks/useNotifications.d.ts.map +1 -0
  369. package/lib/typescript/src/hooks/usePlayGame.d.ts +62 -0
  370. package/lib/typescript/src/hooks/usePlayGame.d.ts.map +1 -0
  371. package/lib/typescript/src/hooks/usePlinko.d.ts +8 -0
  372. package/lib/typescript/src/hooks/usePlinko.d.ts.map +1 -0
  373. package/lib/typescript/src/hooks/useRaffleDrawState.d.ts +50 -0
  374. package/lib/typescript/src/hooks/useRaffleDrawState.d.ts.map +1 -0
  375. package/lib/typescript/src/hooks/useRefreshWallet.d.ts +8 -0
  376. package/lib/typescript/src/hooks/useRefreshWallet.d.ts.map +1 -0
  377. package/lib/typescript/src/hooks/useResponsive.d.ts +8 -0
  378. package/lib/typescript/src/hooks/useResponsive.d.ts.map +1 -0
  379. package/lib/typescript/src/hooks/useRevealWin.d.ts +10 -0
  380. package/lib/typescript/src/hooks/useRevealWin.d.ts.map +1 -0
  381. package/lib/typescript/src/hooks/useScreenShake.d.ts +14 -0
  382. package/lib/typescript/src/hooks/useScreenShake.d.ts.map +1 -0
  383. package/lib/typescript/src/hooks/useWallet.d.ts +23 -0
  384. package/lib/typescript/src/hooks/useWallet.d.ts.map +1 -0
  385. package/lib/typescript/src/i18n.d.ts +29 -0
  386. package/lib/typescript/src/i18n.d.ts.map +1 -0
  387. package/lib/typescript/src/index.d.ts +12 -0
  388. package/lib/typescript/src/index.d.ts.map +1 -0
  389. package/lib/typescript/src/lottieAnimations.d.ts +2 -0
  390. package/lib/typescript/src/lottieAnimations.d.ts.map +1 -0
  391. package/lib/typescript/src/stores/assetStore.d.ts +17 -0
  392. package/lib/typescript/src/stores/assetStore.d.ts.map +1 -0
  393. package/lib/typescript/src/stores/authStore.d.ts +25 -0
  394. package/lib/typescript/src/stores/authStore.d.ts.map +1 -0
  395. package/lib/typescript/src/stores/gameStore.d.ts +14 -0
  396. package/lib/typescript/src/stores/gameStore.d.ts.map +1 -0
  397. package/lib/typescript/src/stores/sdkInitStore.d.ts +38 -0
  398. package/lib/typescript/src/stores/sdkInitStore.d.ts.map +1 -0
  399. package/lib/typescript/src/stores/settingsStore.d.ts +23 -0
  400. package/lib/typescript/src/stores/settingsStore.d.ts.map +1 -0
  401. package/lib/typescript/src/theme.d.ts +149 -0
  402. package/lib/typescript/src/theme.d.ts.map +1 -0
  403. package/lib/typescript/src/types.d.ts +49 -0
  404. package/lib/typescript/src/types.d.ts.map +1 -0
  405. package/lib/typescript/src/utils/apolloError.d.ts +12 -0
  406. package/lib/typescript/src/utils/apolloError.d.ts.map +1 -0
  407. package/lib/typescript/src/utils/crashMultiplier.d.ts +2 -0
  408. package/lib/typescript/src/utils/crashMultiplier.d.ts.map +1 -0
  409. package/lib/typescript/src/utils/crashMultiplier.test.d.ts +2 -0
  410. package/lib/typescript/src/utils/crashMultiplier.test.d.ts.map +1 -0
  411. package/lib/typescript/src/utils/deviceAnalytics.d.ts +3 -0
  412. package/lib/typescript/src/utils/deviceAnalytics.d.ts.map +1 -0
  413. package/lib/typescript/src/utils/idempotency.d.ts +14 -0
  414. package/lib/typescript/src/utils/idempotency.d.ts.map +1 -0
  415. package/lib/typescript/src/utils/layout.d.ts +10 -0
  416. package/lib/typescript/src/utils/layout.d.ts.map +1 -0
  417. package/lib/typescript/src/utils/safeInlineScript.d.ts +5 -0
  418. package/lib/typescript/src/utils/safeInlineScript.d.ts.map +1 -0
  419. package/lib/typescript/src/utils/sseClient.d.ts +5 -0
  420. package/lib/typescript/src/utils/sseClient.d.ts.map +1 -0
  421. package/lib/typescript/src/views/DepositSelect.d.ts +9 -0
  422. package/lib/typescript/src/views/DepositSelect.d.ts.map +1 -0
  423. package/lib/typescript/src/views/Dice.d.ts +10 -0
  424. package/lib/typescript/src/views/Dice.d.ts.map +1 -0
  425. package/lib/typescript/src/views/DiceBattle.d.ts +15 -0
  426. package/lib/typescript/src/views/DiceBattle.d.ts.map +1 -0
  427. package/lib/typescript/src/views/DiceLobby.d.ts +12 -0
  428. package/lib/typescript/src/views/DiceLobby.d.ts.map +1 -0
  429. package/lib/typescript/src/views/FortuneWheel.d.ts +13 -0
  430. package/lib/typescript/src/views/FortuneWheel.d.ts.map +1 -0
  431. package/lib/typescript/src/views/Freefall.d.ts +13 -0
  432. package/lib/typescript/src/views/Freefall.d.ts.map +1 -0
  433. package/lib/typescript/src/views/History.d.ts +7 -0
  434. package/lib/typescript/src/views/History.d.ts.map +1 -0
  435. package/lib/typescript/src/views/Home.d.ts +13 -0
  436. package/lib/typescript/src/views/Home.d.ts.map +1 -0
  437. package/lib/typescript/src/views/Jetstream.d.ts +14 -0
  438. package/lib/typescript/src/views/Jetstream.d.ts.map +1 -0
  439. package/lib/typescript/src/views/Leaderboard.d.ts +8 -0
  440. package/lib/typescript/src/views/Leaderboard.d.ts.map +1 -0
  441. package/lib/typescript/src/views/MillionaireHunter.d.ts +13 -0
  442. package/lib/typescript/src/views/MillionaireHunter.d.ts.map +1 -0
  443. package/lib/typescript/src/views/Minefield.d.ts +13 -0
  444. package/lib/typescript/src/views/Minefield.d.ts.map +1 -0
  445. package/lib/typescript/src/views/PaymentWebView.d.ts +29 -0
  446. package/lib/typescript/src/views/PaymentWebView.d.ts.map +1 -0
  447. package/lib/typescript/src/views/PlayerCard.d.ts +15 -0
  448. package/lib/typescript/src/views/PlayerCard.d.ts.map +1 -0
  449. package/lib/typescript/src/views/Profile.d.ts +9 -0
  450. package/lib/typescript/src/views/Profile.d.ts.map +1 -0
  451. package/lib/typescript/src/views/RaffleDraw.d.ts +12 -0
  452. package/lib/typescript/src/views/RaffleDraw.d.ts.map +1 -0
  453. package/lib/typescript/src/views/RevealWin.d.ts +13 -0
  454. package/lib/typescript/src/views/RevealWin.d.ts.map +1 -0
  455. package/lib/typescript/src/views/Splash.d.ts +10 -0
  456. package/lib/typescript/src/views/Splash.d.ts.map +1 -0
  457. package/lib/typescript/src/views/Success.d.ts +12 -0
  458. package/lib/typescript/src/views/Success.d.ts.map +1 -0
  459. package/lib/typescript/src/views/TicketShop.d.ts +15 -0
  460. package/lib/typescript/src/views/TicketShop.d.ts.map +1 -0
  461. package/lib/typescript/src/views/TriviaLobby.d.ts +12 -0
  462. package/lib/typescript/src/views/TriviaLobby.d.ts.map +1 -0
  463. package/lib/typescript/src/views/TriviaMaster.d.ts +16 -0
  464. package/lib/typescript/src/views/TriviaMaster.d.ts.map +1 -0
  465. package/lib/typescript/src/views/Wallet.d.ts +10 -0
  466. package/lib/typescript/src/views/Wallet.d.ts.map +1 -0
  467. package/lib/typescript/src/views/WithdrawFlow.d.ts +9 -0
  468. package/lib/typescript/src/views/WithdrawFlow.d.ts.map +1 -0
  469. package/lib/typescript/src/views/gridGeometry.d.ts +19 -0
  470. package/lib/typescript/src/views/gridGeometry.d.ts.map +1 -0
  471. package/lib/typescript/src/views/revealWinHelpers.d.ts +15 -0
  472. package/lib/typescript/src/views/revealWinHelpers.d.ts.map +1 -0
  473. package/lib/typescript/src/views/ticketBundlePresets.d.ts +18 -0
  474. package/lib/typescript/src/views/ticketBundlePresets.d.ts.map +1 -0
  475. package/lib/typescript/src/views/triviaHelpers.d.ts +31 -0
  476. package/lib/typescript/src/views/triviaHelpers.d.ts.map +1 -0
  477. package/lib/typescript/src/voiceClips.d.ts +4 -0
  478. package/lib/typescript/src/voiceClips.d.ts.map +1 -0
  479. package/package.json +160 -4
@@ -0,0 +1,98 @@
1
+ package com.monflowts
2
+
3
+ import android.content.Context
4
+ import android.graphics.Canvas
5
+ import android.graphics.Color
6
+ import android.graphics.Paint
7
+ import android.graphics.RectF
8
+ import android.util.AttributeSet
9
+ import android.view.View
10
+ import kotlin.math.PI
11
+ import kotlin.math.cos
12
+ import kotlin.math.sin
13
+
14
+ class MonflowtsWheelView @JvmOverloads constructor(
15
+ context: Context,
16
+ attrs: AttributeSet? = null,
17
+ defStyleAttr: Int = 0
18
+ ) : View(context, attrs, defStyleAttr) {
19
+
20
+ data class Segment(val label: String, val value: Int, val color: Int)
21
+
22
+ private var segments: List<Segment> = emptyList()
23
+ private val segmentPaint = Paint(Paint.ANTI_ALIAS_FLAG)
24
+ private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
25
+ color = Color.WHITE
26
+ textAlign = Paint.Align.CENTER
27
+ isFakeBoldText = true
28
+ }
29
+ private val borderPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
30
+ style = Paint.Style.STROKE
31
+ color = Color.argb(25, 255, 255, 255)
32
+ strokeWidth = 2f
33
+ }
34
+ private val rectF = RectF()
35
+
36
+ fun setSegments(newSegments: List<Segment>) {
37
+ segments = newSegments
38
+ invalidate()
39
+ }
40
+
41
+ override fun onDraw(canvas: Canvas) {
42
+ super.onDraw(canvas)
43
+ if (segments.isEmpty()) return
44
+
45
+ val cx = width / 2f
46
+ val cy = height / 2f
47
+ val radius = minOf(cx, cy) - 8f
48
+ val segmentAngle = 360f / segments.size
49
+
50
+ rectF.set(cx - radius, cy - radius, cx + radius, cy + radius)
51
+
52
+ // Draw segments
53
+ segments.forEachIndexed { i, segment ->
54
+ val startAngle = i * segmentAngle - 90f
55
+
56
+ // Fill
57
+ segmentPaint.style = Paint.Style.FILL
58
+ segmentPaint.color = segment.color
59
+ canvas.drawArc(rectF, startAngle, segmentAngle, true, segmentPaint)
60
+
61
+ // Border
62
+ canvas.drawArc(rectF, startAngle, segmentAngle, true, borderPaint)
63
+
64
+ // Text
65
+ val textAngle = startAngle + segmentAngle / 2f
66
+ val textRadius = radius * 0.65f
67
+ val textX = cx + textRadius * cos(textAngle * PI.toFloat() / 180f)
68
+ val textY = cy + textRadius * sin(textAngle * PI.toFloat() / 180f)
69
+ textPaint.textSize = radius * 0.08f
70
+
71
+ canvas.save()
72
+ canvas.rotate(textAngle + 90f, textX, textY)
73
+ canvas.drawText(segment.label, textX, textY + textPaint.textSize / 3f, textPaint)
74
+ canvas.restore()
75
+ }
76
+
77
+ // Outer ring
78
+ val outerPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
79
+ style = Paint.Style.STROKE
80
+ color = Color.argb(40, 255, 255, 255)
81
+ strokeWidth = 4f
82
+ }
83
+ canvas.drawCircle(cx, cy, radius, outerPaint)
84
+
85
+ // Center hub
86
+ val hubPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
87
+ style = Paint.Style.FILL
88
+ color = Color.parseColor("#0f172a")
89
+ }
90
+ val hubBorder = Paint(Paint.ANTI_ALIAS_FLAG).apply {
91
+ style = Paint.Style.STROKE
92
+ color = Color.parseColor("#1e293b")
93
+ strokeWidth = 6f
94
+ }
95
+ canvas.drawCircle(cx, cy, radius * 0.12f, hubPaint)
96
+ canvas.drawCircle(cx, cy, radius * 0.12f, hubBorder)
97
+ }
98
+ }
@@ -0,0 +1,46 @@
1
+ package com.monflowts
2
+
3
+ import android.graphics.Color
4
+ import com.facebook.react.bridge.ReadableArray
5
+ import com.facebook.react.module.annotations.ReactModule
6
+ import com.facebook.react.uimanager.SimpleViewManager
7
+ import com.facebook.react.uimanager.ThemedReactContext
8
+ import com.facebook.react.uimanager.annotations.ReactProp
9
+
10
+ @ReactModule(name = MonflowtsWheelViewManager.NAME)
11
+ class MonflowtsWheelViewManager : SimpleViewManager<MonflowtsWheelView>() {
12
+
13
+ companion object {
14
+ const val NAME = "MonflowtsWheelView"
15
+ }
16
+
17
+ override fun getName(): String = NAME
18
+
19
+ override fun createViewInstance(context: ThemedReactContext): MonflowtsWheelView {
20
+ return MonflowtsWheelView(context)
21
+ }
22
+
23
+ @ReactProp(name = "segments")
24
+ fun setSegments(view: MonflowtsWheelView, segments: ReadableArray?) {
25
+ if (segments == null) return
26
+
27
+ val segmentList = mutableListOf<MonflowtsWheelView.Segment>()
28
+ for (i in 0 until segments.size()) {
29
+ val map = segments.getMap(i) ?: continue
30
+ val label = map.getString("label") ?: ""
31
+ val value = map.getInt("value")
32
+ // Canonical segment-color fallback shared with the JS SDK and the iOS wheel
33
+ // (FortuneWheel.tsx → SEGMENT_COLORS ultimate fallback). Keeps an un-coloured
34
+ // segment identical across web, iOS and Android instead of a platform-specific shade.
35
+ val colorStr = map.getString("color") ?: "#4f46e5"
36
+ val color = try {
37
+ Color.parseColor(colorStr)
38
+ } catch (e: Exception) {
39
+ Color.parseColor("#4f46e5")
40
+ }
41
+ segmentList.add(MonflowtsWheelView.Segment(label, value, color))
42
+ }
43
+
44
+ view.setSegments(segmentList)
45
+ }
46
+ }
@@ -0,0 +1,5 @@
1
+ // This header is used to expose ObjC files to Swift
2
+ #import <React/RCTBridgeModule.h>
3
+ #import <React/RCTViewManager.h>
4
+ #import <React/RCTComponent.h>
5
+ #import <React/RCTEventEmitter.h>
@@ -0,0 +1,14 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(MonflowtsAssets, RCTEventEmitter)
5
+
6
+ RCT_EXTERN_METHOD(getBaseUri:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
7
+ RCT_EXTERN_METHOD(download:(NSArray *)files resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
8
+ RCT_EXTERN_METHOD(readText:(NSString *)name resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
9
+ RCT_EXTERN_METHOD(missing:(NSArray *)names resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
10
+ RCT_EXTERN_METHOD(saveIndex:(NSString *)json resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
11
+ RCT_EXTERN_METHOD(loadIndex:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
12
+ RCT_EXTERN_METHOD(removeExcept:(NSArray *)names resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
13
+
14
+ @end
@@ -0,0 +1,217 @@
1
+ import Foundation
2
+ import CryptoKit
3
+ import React
4
+
5
+ @objc(MonflowtsAssets)
6
+ class MonflowtsAssetsModule: RCTEventEmitter {
7
+
8
+ private let session: URLSession = {
9
+ let configuration = URLSessionConfiguration.default
10
+ configuration.httpMaximumConnectionsPerHost = 4
11
+ configuration.requestCachePolicy = .reloadIgnoringLocalCacheData
12
+ return URLSession(configuration: configuration)
13
+ }()
14
+ private let indexName = "index.json"
15
+ private var hasListeners = false
16
+
17
+ @objc override static func requiresMainQueueSetup() -> Bool { return false }
18
+
19
+ override func supportedEvents() -> [String]! { return ["MonflowtsAssetsProgress"] }
20
+ override func startObserving() { hasListeners = true }
21
+ override func stopObserving() { hasListeners = false }
22
+
23
+ private func baseDirectory() throws -> URL {
24
+ let support = try FileManager.default.url(
25
+ for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
26
+ var directory = support.appendingPathComponent("monflowts-assets", isDirectory: true)
27
+ if !FileManager.default.fileExists(atPath: directory.path) {
28
+ try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)
29
+ var values = URLResourceValues()
30
+ values.isExcludedFromBackup = true
31
+ try directory.setResourceValues(values)
32
+ }
33
+ return directory
34
+ }
35
+
36
+ @objc func getBaseUri(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
37
+ do {
38
+ let uri = try baseDirectory().absoluteString
39
+ resolve(uri.hasSuffix("/") ? uri : uri + "/")
40
+ } catch {
41
+ reject("E_ASSETS_DIR", error.localizedDescription, error)
42
+ }
43
+ }
44
+
45
+ @objc func download(_ files: NSArray, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
46
+ let directory: URL
47
+ do { directory = try baseDirectory() } catch {
48
+ reject("E_ASSETS_DIR", error.localizedDescription, error)
49
+ return
50
+ }
51
+ var malformed: [[String: String]] = []
52
+ let items: [(url: URL, sha256: String, ext: String, size: Int64)] = files.compactMap { entry -> (url: URL, sha256: String, ext: String, size: Int64)? in
53
+ guard let file = entry as? [String: Any],
54
+ let urlString = file["url"] as? String,
55
+ let url = URL(string: urlString),
56
+ let sha256 = file["sha256"] as? String,
57
+ let ext = file["ext"] as? String else {
58
+ let sha256 = (entry as? [String: Any])?["sha256"] as? String ?? ""
59
+ malformed.append(["sha256": sha256, "reason": "NETWORK"])
60
+ return nil
61
+ }
62
+ let size = (file["size"] as? NSNumber)?.int64Value ?? 0
63
+ return (url, sha256, ext, size)
64
+ }
65
+ let bytesTotal = items.reduce(Int64(0)) { $0 + $1.size }
66
+ let lock = NSLock()
67
+ var bytesDone: Int64 = 0
68
+ var filesDone = 0
69
+ var failed: [[String: String]] = malformed
70
+ let group = DispatchGroup()
71
+
72
+ for item in items {
73
+ let target = directory.appendingPathComponent("\(item.sha256).\(item.ext)")
74
+ if FileManager.default.fileExists(atPath: target.path) {
75
+ lock.lock()
76
+ bytesDone += item.size
77
+ filesDone += 1
78
+ lock.unlock()
79
+ continue
80
+ }
81
+ group.enter()
82
+ fetch(item.url, sha256: item.sha256, to: target) { [weak self] reason in
83
+ lock.lock()
84
+ if let reason = reason {
85
+ failed.append(["sha256": item.sha256, "reason": reason])
86
+ } else {
87
+ bytesDone += item.size
88
+ }
89
+ filesDone += 1
90
+ let progress: [String: Any] = [
91
+ "bytesDone": bytesDone, "bytesTotal": bytesTotal, "filesDone": filesDone, "filesTotal": items.count,
92
+ ]
93
+ lock.unlock()
94
+ self?.emitProgress(progress)
95
+ group.leave()
96
+ }
97
+ }
98
+
99
+ group.notify(queue: .global(qos: .utility)) {
100
+ lock.lock()
101
+ let result: [String: Any] = ["failed": failed]
102
+ lock.unlock()
103
+ resolve(result)
104
+ }
105
+ }
106
+
107
+ private func fetch(_ url: URL, sha256: String, to target: URL, completion: @escaping (String?) -> Void) {
108
+ session.downloadTask(with: url) { temporary, response, error in
109
+ if let error = error {
110
+ completion(MonflowtsAssetsModule.isOutOfSpace(error) ? "NO_SPACE" : "NETWORK")
111
+ return
112
+ }
113
+ let status = (response as? HTTPURLResponse)?.statusCode ?? 0
114
+ if status == 403 {
115
+ completion("EXPIRED")
116
+ return
117
+ }
118
+ guard (200..<300).contains(status), let temporary = temporary else {
119
+ completion("NETWORK")
120
+ return
121
+ }
122
+ do {
123
+ let data = try Data(contentsOf: temporary)
124
+ let digest = SHA256.hash(data: data).map { String(format: "%02x", $0) }.joined()
125
+ guard digest == sha256 else {
126
+ completion("HASH_MISMATCH")
127
+ return
128
+ }
129
+ if FileManager.default.fileExists(atPath: target.path) {
130
+ completion(nil)
131
+ return
132
+ }
133
+ try FileManager.default.moveItem(at: temporary, to: target)
134
+ completion(nil)
135
+ } catch {
136
+ completion(MonflowtsAssetsModule.isOutOfSpace(error) ? "NO_SPACE" : "NETWORK")
137
+ }
138
+ }.resume()
139
+ }
140
+
141
+ private static func isOutOfSpace(_ error: Error) -> Bool {
142
+ let nsError = error as NSError
143
+ if nsError.domain == NSURLErrorDomain,
144
+ nsError.code == NSURLErrorCannotWriteToFile || nsError.code == NSURLErrorCannotCreateFile {
145
+ return true
146
+ }
147
+ if nsError.domain == NSCocoaErrorDomain && nsError.code == NSFileWriteOutOfSpaceError {
148
+ return true
149
+ }
150
+ let underlying = nsError.userInfo[NSUnderlyingErrorKey] as? NSError
151
+ return (nsError.domain == NSPOSIXErrorDomain && nsError.code == Int(ENOSPC))
152
+ || (underlying?.domain == NSPOSIXErrorDomain && underlying?.code == Int(ENOSPC))
153
+ }
154
+
155
+ private func emitProgress(_ body: [String: Any]) {
156
+ guard hasListeners else { return }
157
+ sendEvent(withName: "MonflowtsAssetsProgress", body: body)
158
+ }
159
+
160
+ @objc func readText(_ name: NSString, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
161
+ do {
162
+ let url = try baseDirectory().appendingPathComponent(name as String)
163
+ resolve(try String(contentsOf: url, encoding: .utf8))
164
+ } catch {
165
+ reject("E_ASSETS_READ", error.localizedDescription, error)
166
+ }
167
+ }
168
+
169
+ @objc func missing(_ names: NSArray, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
170
+ do {
171
+ let directory = try baseDirectory()
172
+ let absent = names.compactMap { $0 as? String }.filter {
173
+ !FileManager.default.fileExists(atPath: directory.appendingPathComponent($0).path)
174
+ }
175
+ resolve(absent)
176
+ } catch {
177
+ reject("E_ASSETS_DIR", error.localizedDescription, error)
178
+ }
179
+ }
180
+
181
+ @objc func saveIndex(_ json: NSString, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
182
+ do {
183
+ let url = try baseDirectory().appendingPathComponent(indexName)
184
+ try (json as String).write(to: url, atomically: true, encoding: .utf8)
185
+ resolve(nil)
186
+ } catch {
187
+ reject("E_ASSETS_WRITE", error.localizedDescription, error)
188
+ }
189
+ }
190
+
191
+ @objc func loadIndex(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
192
+ do {
193
+ let url = try baseDirectory().appendingPathComponent(indexName)
194
+ guard FileManager.default.fileExists(atPath: url.path) else {
195
+ resolve(nil)
196
+ return
197
+ }
198
+ resolve(try String(contentsOf: url, encoding: .utf8))
199
+ } catch {
200
+ reject("E_ASSETS_READ", error.localizedDescription, error)
201
+ }
202
+ }
203
+
204
+ @objc func removeExcept(_ names: NSArray, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
205
+ do {
206
+ let directory = try baseDirectory()
207
+ var keep = Set(names.compactMap { $0 as? String })
208
+ keep.insert(indexName)
209
+ for name in try FileManager.default.contentsOfDirectory(atPath: directory.path) where !keep.contains(name) {
210
+ try? FileManager.default.removeItem(at: directory.appendingPathComponent(name))
211
+ }
212
+ resolve(nil)
213
+ } catch {
214
+ reject("E_ASSETS_DIR", error.localizedDescription, error)
215
+ }
216
+ }
217
+ }
@@ -0,0 +1,9 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(MonflowtsCrashFeed, RCTEventEmitter)
5
+
6
+ RCT_EXTERN_METHOD(connect:(NSString *)urlString)
7
+ RCT_EXTERN_METHOD(disconnect)
8
+
9
+ @end
@@ -0,0 +1,88 @@
1
+ import Foundation
2
+ import React
3
+
4
+ @objc(MonflowtsCrashFeed)
5
+ class MonflowtsCrashFeedModule: RCTEventEmitter {
6
+
7
+ private let queue = DispatchQueue(label: "com.monflowts.crashfeed", qos: .utility)
8
+ private var source: MonflowtsHTTP1EventSource?
9
+ private var hasListeners = false
10
+ private var reconnectAttempts = 0
11
+ private var currentURL: URL?
12
+ private var generation = 0
13
+ private var stopped = true
14
+
15
+ @objc override static func requiresMainQueueSetup() -> Bool { return false }
16
+
17
+ override func supportedEvents() -> [String]! {
18
+ return ["MonflowtsCrashCashout", "MonflowtsCrashFeedStatus"]
19
+ }
20
+
21
+ override func startObserving() { hasListeners = true }
22
+ override func stopObserving() { hasListeners = false }
23
+
24
+ @objc func connect(_ urlString: NSString) {
25
+ queue.async { [weak self] in
26
+ guard let self = self, let url = URL(string: urlString as String) else { return }
27
+ self.currentURL = url
28
+ self.stopped = false
29
+ self.reconnectAttempts = 0
30
+ self.generation += 1
31
+ self.openConnection(generation: self.generation)
32
+ }
33
+ }
34
+
35
+ @objc func disconnect() {
36
+ queue.async { [weak self] in
37
+ guard let self = self else { return }
38
+ self.stopped = true
39
+ self.generation += 1
40
+ self.source?.disconnect()
41
+ self.source = nil
42
+ }
43
+ }
44
+
45
+ private func openConnection(generation: Int) {
46
+ guard !stopped, generation == self.generation, let url = currentURL else { return }
47
+ guard #available(iOS 13.0, *) else { return }
48
+ let src = MonflowtsHTTP1EventSource(url: url, headers: ["Accept": "text/event-stream"], queue: queue)
49
+ self.source = src
50
+ src.onOpen = { [weak self] in
51
+ self?.reconnectAttempts = 0
52
+ self?.emit(name: "MonflowtsCrashFeedStatus", body: ["connected": true])
53
+ }
54
+ src.onEvent = { [weak self] event, _, data in
55
+ guard let self = self, event == "crash.cashout", let data = data else { return }
56
+ if let parsed = self.jsonObject(from: data) {
57
+ self.emit(name: "MonflowtsCrashCashout", body: parsed)
58
+ }
59
+ }
60
+ src.onComplete = { [weak self] _, _ in
61
+ guard let self = self else { return }
62
+ self.source = nil
63
+ self.emit(name: "MonflowtsCrashFeedStatus", body: ["connected": false])
64
+ self.scheduleReconnect(generation: generation)
65
+ }
66
+ src.connect()
67
+ }
68
+
69
+ private func scheduleReconnect(generation: Int) {
70
+ guard !stopped, generation == self.generation else { return }
71
+ let attempt = reconnectAttempts
72
+ reconnectAttempts += 1
73
+ let delay = min(pow(2.0, Double(attempt)), 30.0)
74
+ queue.asyncAfter(deadline: .now() + delay) { [weak self] in
75
+ self?.openConnection(generation: generation)
76
+ }
77
+ }
78
+
79
+ private func emit(name: String, body: Any) {
80
+ guard hasListeners else { return }
81
+ sendEvent(withName: name, body: body)
82
+ }
83
+
84
+ private func jsonObject(from string: String) -> [String: Any]? {
85
+ guard let data = string.data(using: .utf8) else { return nil }
86
+ return (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]
87
+ }
88
+ }