@onairos/react-native 3.7.1 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/assets/icons/spotify.png +0 -0
- package/lib/commonjs/assets/images/spotify.png +0 -0
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +116 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/assets/icons/spotify.png +0 -0
- package/lib/module/assets/images/spotify.png +0 -0
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +109 -1
- package/lib/module/components/EmailInput.js +23 -1
- package/lib/module/components/GoogleButton.js +49 -1
- package/lib/module/components/HeadingGroup.js +36 -1
- package/lib/module/components/LLMDataInputModal.js +656 -7
- package/lib/module/components/ModalHeader.js +92 -1
- package/lib/module/components/ModalSheet.js +39 -1
- package/lib/module/components/Onairos.js +373 -1
- package/lib/module/components/OnairosButton.js +305 -1
- package/lib/module/components/OnairosSignInButton.js +121 -1
- package/lib/module/components/Overlay.js +456 -1
- package/lib/module/components/PersonaImage.js +129 -1
- package/lib/module/components/PersonaLoadingScreen.js +310 -1
- package/lib/module/components/PersonalizationConsentScreen.js +460 -1
- package/lib/module/components/PinCreationScreen.js +396 -1
- package/lib/module/components/PinInput.js +456 -1
- package/lib/module/components/PlatformConnectorsStep.js +1302 -6
- package/lib/module/components/PlatformList.js +129 -1
- package/lib/module/components/PlatformToggle.js +173 -1
- package/lib/module/components/PrimaryButton.js +172 -1
- package/lib/module/components/SignInMatchAnimation.js +189 -1
- package/lib/module/components/SignInStep.js +338 -1
- package/lib/module/components/UniversalOnboarding.js +2770 -1
- package/lib/module/components/VerificationStep.js +168 -1
- package/lib/module/components/WelcomeScreen.js +453 -1
- package/lib/module/components/icons/Basicproficon.js +30 -1
- package/lib/module/components/icons/Basicprofile.js +14 -1
- package/lib/module/components/icons/Checkbox.js +14 -1
- package/lib/module/components/icons/Checkmark.js +20 -1
- package/lib/module/components/icons/Contentanalysis.js +14 -1
- package/lib/module/components/icons/Contenticon.js +32 -1
- package/lib/module/components/icons/EnochE.js +34 -1
- package/lib/module/components/icons/Personalityicon.js +23 -1
- package/lib/module/components/icons/Personalityprofile.js +14 -1
- package/lib/module/components/icons/Personalitytraits.js +14 -1
- package/lib/module/components/icons/Userpreferences.js +14 -1
- package/lib/module/components/icons/index.js +13 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
- package/lib/module/components/onboarding/PinInput.js +274 -1
- package/lib/module/components/onboarding/PlatformConnector.js +240 -1
- package/lib/module/config/PLATFORM_APIS.md +849 -0
- package/lib/module/config/api.js +47 -1
- package/lib/module/constants/index.js +114 -1
- package/lib/module/context/AuthContext.js +335 -1
- package/lib/module/hooks/useConnectedAccounts.js +106 -1
- package/lib/module/hooks/useConnections.js +95 -1
- package/lib/module/hooks/useCredentials.js +171 -6
- package/lib/module/hooks/useUserConnections.js +140 -1
- package/lib/module/index.js +172 -1
- package/lib/module/services/apiClient.js +295 -1
- package/lib/module/services/biometricPinService.js +169 -1
- package/lib/module/services/chatGPTConversationExtractor.js +149 -1
- package/lib/module/services/chatGPTConversationService.js +268 -1
- package/lib/module/services/claudeConversationExtractor.js +97 -1
- package/lib/module/services/claudeConversationService.js +151 -1
- package/lib/module/services/connectedAccountsService.js +293 -1
- package/lib/module/services/googleAuthService.js +241 -1
- package/lib/module/services/hingeDataExtractor.js +99 -1
- package/lib/module/services/hingeDataService.js +143 -1
- package/lib/module/services/imageCompressionService.js +250 -1
- package/lib/module/services/instagramDataExtractor.js +120 -1
- package/lib/module/services/instagramDataService.js +156 -1
- package/lib/module/services/jwtStorageService.js +257 -1
- package/lib/module/services/linkedinDOMExtractor.js +234 -1
- package/lib/module/services/linkedinProfileService.js +210 -1
- package/lib/module/services/linkedinScrapingService.js +219 -1
- package/lib/module/services/llmDataStorage.js +277 -1
- package/lib/module/services/mobileTrainingService.js +173 -1
- package/lib/module/services/netflixDataExtractor.js +114 -1
- package/lib/module/services/netflixDataService.js +191 -1
- package/lib/module/services/pinEncryptionService.js +74 -6
- package/lib/module/services/pinStorageUtils.js +93 -1
- package/lib/module/services/platformAuthService.js +1461 -1
- package/lib/module/services/sephoraDataExtractor.js +134 -1
- package/lib/module/services/sephoraDataService.js +193 -1
- package/lib/module/services/spotifyDataExtractor.js +142 -1
- package/lib/module/services/spotifyDataService.js +234 -1
- package/lib/module/services/storageService.js +383 -1
- package/lib/module/services/telegramDataExtractor.js +109 -1
- package/lib/module/services/telegramDataService.js +493 -1
- package/lib/module/services/trainingApiHelpers.js +67 -1
- package/lib/module/services/userConnectionsService.js +329 -1
- package/lib/module/services/youtubeMigrationService.js +405 -1
- package/lib/module/theme/index.js +245 -1
- package/lib/module/types.js +10 -1
- package/lib/module/utils/Portal.js +90 -1
- package/lib/module/utils/api.js +118 -1
- package/lib/module/utils/assetRegistry.js +200 -34
- package/lib/module/utils/auth.js +100 -1
- package/lib/module/utils/connectorTests.js +600 -27
- package/lib/module/utils/crypto.js +54 -1
- package/lib/module/utils/debugHelper.js +54 -1
- package/lib/module/utils/encryption.js +67 -1
- package/lib/module/utils/eventUtils.js +270 -1
- package/lib/module/utils/haptics.js +59 -8
- package/lib/module/utils/imagePreloader.js +3 -1
- package/lib/module/utils/networkDiagnostics.js +217 -1
- package/lib/module/utils/onairosApi.js +333 -1
- package/lib/module/utils/programmaticFlow.js +111 -1
- package/lib/module/utils/retryHelper.js +211 -1
- package/lib/module/utils/secureStorage.js +330 -6
- package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
- package/lib/module/utils/webviewScripts/claude.js +370 -1
- package/lib/module/utils/webviewScripts/hinge.js +405 -1
- package/lib/module/utils/webviewScripts/index.js +434 -1
- package/lib/module/utils/webviewScripts/instagram.js +448 -1
- package/lib/module/utils/webviewScripts/linkedin.js +874 -1
- package/lib/module/utils/webviewScripts/netflix.js +376 -1
- package/lib/module/utils/webviewScripts/sephora.js +510 -1
- package/lib/module/utils/webviewScripts/spotify.js +413 -1
- package/lib/module/utils/webviewScripts/telegram.js +672 -1
- package/package.json +2 -2
|
@@ -1,7 +1,260 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object[_0x19d0(0x0)](exports,_0x19d0(0x1),{'value':!![]}),exports[_0x19d0(0x2)]=exports['compressProfilePicture']=exports[_0x19d0(0x3)]=exports[_0x19d0(0x4)]=void 0x0;function _0x2f9c(){const _0x4e42e6=['defineProperty','__esModule','convertImageToOptimizedBase64','compressImageToTarget','compressForUpload','fJiUT','EXqJi','POsZu','blob','hZzCa','FydHk','MVMjU','atCYi','result','split','qbmjW','PxGHW','epJlL','eHhlB','round','oWPXm','max','sfISC','RQaGs','onloadend','WszPA','hUSqV','onerror','hNQDv','UDJUA','cADxQ','error','qUyoR','Unknown\x20compression\x20error','Error\x20getting\x20file\x20size:','JPEG','xVsdG','nmSHs','contain','🎯\x20[COMPRESSION]\x20Success:','KeCTj','qypOL','FosaM','📤\x20[COMPRESSION]\x20Final\x20result\x20(best\x20effort):','❌\x20[COMPRESSION]\x20Final\x20compression\x20attempt\x20failed:','log','🖼️\x20[COMPRESSION]\x20Starting\x20compression\x20for:','CjECr','koekD','🔄\x20[COMPRESSION]\x20Attempt\x20',':\x20quality=',',\x20size=','wsBPX','NULBe','LeQcY','default','createResizedImage','KFGob','xscqx','uri','MrAKV','\x20result:\x20','\x20KB','TDAAW','LEsmH','flKLv','JCeXM','AiFlW','aiell','gQRyU','jsmjA','ToKyY','RXIUl','Lyaqp','CDrGg','axJkg','VbTJu','\x20failed:','ZMATL','Cwgbh','tCiqm','hZwpZ','⚠️\x20[COMPRESSION]\x20Max\x20attempts\x20reached,\x20using\x20best\x20effort','WfRuW','IUrUG','oGppV','XhOvL','eKyAt','Failed\x20to\x20compress\x20image\x20to\x20','KB\x20after\x20','\x20attempts','ltjjF','compressProfilePicture','HhzKu','iNpOF','MAcpp','cbwCX','success','base64'];_0x2f9c=function(){return _0x4e42e6;};return _0x2f9c();}var _reactNativeImageResizer=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x0));function _interopRequireDefault(_0x20dfb7){return _0x20dfb7&&_0x20dfb7['__esModule']?_0x20dfb7:{'default':_0x20dfb7};}const getFileSizeFromUri=async _0xd6760b=>{const _0x2b57c3={'POsZu':function(_0x596d35,_0x480129){return _0x596d35(_0x480129);},'hZzCa':function(_0x2d7888,_0x516cbc){return _0x2d7888!==_0x516cbc;},'FydHk':_0x19d0(0x5),'MVMjU':_0x19d0(0x6),'atCYi':'Error\x20getting\x20file\x20size:'};try{const _0x47aee0=await _0x2b57c3[_0x19d0(0x7)](fetch,_0xd6760b),_0x5169e7=await _0x47aee0[_0x19d0(0x8)]();return _0x5169e7['size'];}catch(_0x492c2b){if(_0x2b57c3[_0x19d0(0x9)](_0x2b57c3[_0x19d0(0xa)],_0x2b57c3[_0x19d0(0xb)]))return console['error'](_0x2b57c3[_0x19d0(0xc)],_0x492c2b),0x0;else{const _0x51b3d2=_0x12cf4e[_0x19d0(0xd)],_0xff9e9e=_0x51b3d2[_0x19d0(0xe)](',')[0x1];_0x24fc11(_0xff9e9e);}}},imageToBase64=async _0x3a9b50=>{const _0x44b93d={'eHhlB':function(_0x13a2f1,_0xbb173f){return _0x13a2f1/_0xbb173f;},'utgpF':function(_0x212fb6,_0x3c5d76){return _0x212fb6>_0x3c5d76;},'oWPXm':function(_0x405e9c,_0xe85287){return _0x405e9c*_0xe85287;},'yzUqx':function(_0x3eca29,_0x38cff0){return _0x3eca29>_0x38cff0;},'RQaGs':function(_0x54ae3e,_0x4558e5){return _0x54ae3e(_0x4558e5);},'qUyoR':function(_0x4e28d0,_0x2956fa){return _0x4e28d0(_0x2956fa);},'PxGHW':function(_0x1fb8e7,_0xf2870f){return _0x1fb8e7!==_0xf2870f;},'wCKpF':'epJlL','sfISC':function(_0xd024d0,_0xd65272){return _0xd024d0(_0xd65272);},'hNQDv':function(_0x498b24,_0x22d321){return _0x498b24!==_0x22d321;},'UDJUA':_0x19d0(0xf),'iGTEi':'Error\x20converting\x20image\x20to\x20base64:'};try{if(_0x44b93d[_0x19d0(0x10)](_0x44b93d['wCKpF'],_0x19d0(0x11))){const _0x54400e=_0x44b93d[_0x19d0(0x12)](_0x165279,_0x43b507);if(_0x44b93d['utgpF'](_0x54400e,0x2))_0x513601*=0.6,_0x5ad29a=_0x139c76[_0x19d0(0x13)](_0x44b93d[_0x19d0(0x14)](_0xa6da58,0.8)),_0x416f1d=_0x2ab29f[_0x19d0(0x13)](_0x193b75*0.8);else _0x44b93d['yzUqx'](_0x54400e,1.5)?(_0x24211d*=0.75,_0x300c13=_0x43153c[_0x19d0(0x13)](_0x664ef9*0.9),_0x3fa7c7=_0x4703fa[_0x19d0(0x13)](_0x44b93d['oWPXm'](_0x3ad6f8,0.9))):_0x479265*=0.85;_0x33bc3d=_0x1e5176[_0x19d0(0x15)](0.1,_0x41652e),_0x2e82bc=_0xe90134['max'](0x190,_0x12c4cf),_0x12aa89=_0x2e2c3e[_0x19d0(0x15)](0x190,_0x58342d);}else{const _0xdcff23=await _0x44b93d[_0x19d0(0x16)](fetch,_0x3a9b50),_0xbce2e1=await _0xdcff23['blob']();return new Promise((_0x561649,_0x3bba0d)=>{const _0x4eaefe={'WszPA':function(_0x3bec0a,_0x1fb117){return _0x3bec0a(_0x1fb117);},'hUSqV':function(_0x5314a2,_0xb18089){return _0x44b93d[_0x19d0(0x17)](_0x5314a2,_0xb18089);}},_0x2de3a=new FileReader();_0x2de3a[_0x19d0(0x18)]=()=>{try{const _0x390391=_0x2de3a[_0x19d0(0xd)],_0x3ddb03=_0x390391[_0x19d0(0xe)](',')[0x1];_0x4eaefe[_0x19d0(0x19)](_0x561649,_0x3ddb03);}catch(_0x58d2b1){_0x4eaefe[_0x19d0(0x1a)](_0x3bba0d,_0x58d2b1);}},_0x2de3a[_0x19d0(0x1b)]=_0x3bba0d,_0x2de3a['readAsDataURL'](_0xbce2e1);});}}catch(_0x27c66c){if(_0x44b93d[_0x19d0(0x1c)](_0x44b93d[_0x19d0(0x1d)],_0x19d0(0x1e)))return console[_0x19d0(0x1f)](_0x44b93d['iGTEi'],_0x27c66c),null;else{const _0x375d15=new _0x490f8c();_0x375d15[_0x19d0(0x18)]=()=>{try{const _0x518cc5=_0x375d15[_0x19d0(0xd)],_0x48928f=_0x518cc5[_0x19d0(0xe)](',')[0x1];_0x44b93d[_0x19d0(0x20)](_0x291972,_0x48928f);}catch(_0x5eaa07){_0x44b93d[_0x19d0(0x20)](_0xf09e11,_0x5eaa07);}},_0x375d15[_0x19d0(0x1b)]=_0x7374e7,_0x375d15['readAsDataURL'](_0xb500da);}}},compressImageToTarget=async(_0x46cc4f,_0x1fb386={})=>{const _0x1428e3={'NULBe':function(_0x55bed9,_0x1ae2d4){return _0x55bed9 instanceof _0x1ae2d4;},'LeQcY':_0x19d0(0x21),'kpkCx':_0x19d0(0x22),'RXIUl':function(_0x2bbb71,_0x4cdbe2){return _0x2bbb71*_0x4cdbe2;},'DiPSw':_0x19d0(0x23),'WtxsY':'📊\x20[COMPRESSION]\x20Original\x20size:','CjECr':function(_0x496393,_0x49888f){return _0x496393<=_0x49888f;},'LEsmH':function(_0x27d456,_0x25e04){return _0x27d456(_0x25e04);},'koekD':function(_0x30567b,_0x2d03f2){return _0x30567b<_0x2d03f2;},'flKLv':function(_0x4d3685,_0x24109a){return _0x4d3685===_0x24109a;},'zXjqv':_0x19d0(0x24),'wsBPX':_0x19d0(0x25),'WNhzN':function(_0x25b8e7,_0x52d8ef){return _0x25b8e7*_0x52d8ef;},'KFGob':_0x19d0(0x26),'xscqx':function(_0x5051c1,_0x5447cd){return _0x5051c1(_0x5447cd);},'MrAKV':function(_0xf27036,_0x5d9128){return _0xf27036/_0x5d9128;},'TDAAW':'✅\x20[COMPRESSION]\x20Target\x20size\x20achieved!','oCvdq':'fywqe','JCeXM':_0x19d0(0x27),'AiFlW':function(_0x3365f9,_0xea0a84){return _0x3365f9+_0xea0a84;},'aiell':function(_0x2958a3,_0x182b33){return _0x2958a3!==_0x182b33;},'gQRyU':_0x19d0(0x28),'ToKyY':function(_0x3a4a12,_0x60e1ff){return _0x3a4a12>_0x60e1ff;},'Lyaqp':function(_0x3c4b63,_0xa8bd79){return _0x3c4b63>_0xa8bd79;},'CDrGg':function(_0x35086e,_0x5c9b27){return _0x35086e!==_0x5c9b27;},'VbTJu':_0x19d0(0x29),'gakdv':function(_0x2b90aa,_0x495058){return _0x2b90aa*_0x495058;},'ZMATL':function(_0x413145,_0x59943c){return _0x413145*_0x59943c;},'Cwgbh':function(_0x52e546,_0x366b59){return _0x52e546<_0x366b59;},'hZwpZ':'dZkeY','WfRuW':'bIWnV','IUrUG':_0x19d0(0x2a),'oGppV':_0x19d0(0x2b),'XhOvL':function(_0x449728,_0x4dedc4){return _0x449728/_0x4dedc4;},'eKyAt':_0x19d0(0x2c),'ltjjF':'❌\x20[COMPRESSION]\x20Compression\x20service\x20error:','HfBzD':function(_0x25bbc3,_0x453022){return _0x25bbc3 instanceof _0x453022;}},{maxSizeKB:maxSizeKB=0x12c,maxWidth:maxWidth=0x4b0,maxHeight:maxHeight=0x4b0,quality:quality=0.8,format:format=_0x1428e3['DiPSw']}=_0x1fb386;try{console[_0x19d0(0x2d)](_0x19d0(0x2e),_0x46cc4f);const _0xcf4822=await getFileSizeFromUri(_0x46cc4f),_0xbfe508=Math[_0x19d0(0x13)](_0xcf4822/0x400);console[_0x19d0(0x2d)](_0x1428e3['WtxsY'],_0xbfe508,'KB');if(_0x1428e3[_0x19d0(0x2f)](_0xbfe508,maxSizeKB)){console[_0x19d0(0x2d)]('✅\x20[COMPRESSION]\x20Image\x20already\x20under\x20target\x20size');const _0x1ab336=await _0x1428e3['LEsmH'](imageToBase64,_0x46cc4f);if(_0x1ab336)return{'success':!![],'base64':_0x1ab336,'sizeKB':_0xbfe508,'originalSizeKB':_0xbfe508,'compressionRatio':0x1};}let _0x2143ce=quality,_0x49a7a9=maxWidth,_0xff26d6=maxHeight,_0x5eab5c=0x0;const _0x129492=0x8;while(_0x1428e3[_0x19d0(0x30)](_0x5eab5c,_0x129492)){_0x5eab5c++,console['log'](_0x19d0(0x31)+_0x5eab5c+_0x19d0(0x32)+_0x2143ce+_0x19d0(0x33)+_0x49a7a9+'x'+_0xff26d6);try{if(_0x1428e3['flKLv'](_0x1428e3['zXjqv'],_0x1428e3[_0x19d0(0x34)]))return _0x4e8919[_0x19d0(0x1f)]('❌\x20[COMPRESSION]\x20Compression\x20service\x20error:',_0x18fe28),{'success':![],'error':_0x1428e3[_0x19d0(0x35)](_0x1f520f,_0x53ea27)?_0xe05c9e['message']:_0x1428e3[_0x19d0(0x36)],'originalSizeKB':0x0};else{const _0x30c20e=await _reactNativeImageResizer[_0x19d0(0x37)][_0x19d0(0x38)](_0x46cc4f,_0x49a7a9,_0xff26d6,format,Math['round'](_0x1428e3['WNhzN'](_0x2143ce,0x64)),0x0,undefined,![],{'mode':_0x1428e3[_0x19d0(0x39)],'onlyScaleDown':!![]}),_0x3414da=await _0x1428e3[_0x19d0(0x3a)](getFileSizeFromUri,_0x30c20e[_0x19d0(0x3b)]),_0x4a2b6d=Math[_0x19d0(0x13)](_0x1428e3[_0x19d0(0x3c)](_0x3414da,0x400));console[_0x19d0(0x2d)]('📊\x20[COMPRESSION]\x20Attempt\x20'+_0x5eab5c+_0x19d0(0x3d)+_0x4a2b6d+_0x19d0(0x3e));if(_0x1428e3[_0x19d0(0x2f)](_0x4a2b6d,maxSizeKB)){console[_0x19d0(0x2d)](_0x1428e3[_0x19d0(0x3f)]);const _0x2d6db7=await _0x1428e3[_0x19d0(0x40)](imageToBase64,_0x30c20e[_0x19d0(0x3b)]);if(_0x2d6db7){if(_0x1428e3[_0x19d0(0x41)](_0x1428e3['oCvdq'],_0x1428e3['oCvdq'])){const _0x1bd40b=_0xbfe508/_0x4a2b6d;return console[_0x19d0(0x2d)](_0x1428e3[_0x19d0(0x42)],{'originalSizeKB':_0xbfe508,'finalSizeKB':_0x4a2b6d,'compressionRatio':_0x1428e3[_0x19d0(0x43)](_0x1bd40b['toFixed'](0x2),'x'),'attempts':_0x5eab5c}),{'success':!![],'base64':_0x2d6db7,'sizeKB':_0x4a2b6d,'originalSizeKB':_0xbfe508,'compressionRatio':_0x1bd40b};}else return _0xcadb9c(_0x554f69,{'maxSizeKB':0x12c,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x19d0(0x23)});}}if(_0x4a2b6d>maxSizeKB){if(_0x1428e3[_0x19d0(0x44)](_0x1428e3[_0x19d0(0x45)],_0x19d0(0x46))){const _0x20a39e=_0x1428e3[_0x19d0(0x3c)](_0x4a2b6d,maxSizeKB);if(_0x1428e3[_0x19d0(0x47)](_0x20a39e,0x2))_0x2143ce*=0.6,_0x49a7a9=Math[_0x19d0(0x13)](_0x49a7a9*0.8),_0xff26d6=Math[_0x19d0(0x13)](_0x1428e3[_0x19d0(0x48)](_0xff26d6,0.8));else{if(_0x1428e3[_0x19d0(0x49)](_0x20a39e,1.5)){if(_0x1428e3[_0x19d0(0x4a)](_0x19d0(0x4b),_0x1428e3[_0x19d0(0x4c)]))_0x2143ce*=0.75,_0x49a7a9=Math[_0x19d0(0x13)](_0x1428e3[_0x19d0(0x48)](_0x49a7a9,0.9)),_0xff26d6=Math[_0x19d0(0x13)](_0x1428e3['WNhzN'](_0xff26d6,0.9));else return _0x228ab4[_0x19d0(0x1f)](_0x1428e3['kpkCx'],_0x50c193),0x0;}else _0x2143ce*=0.85;}_0x2143ce=Math[_0x19d0(0x15)](0.1,_0x2143ce),_0x49a7a9=Math[_0x19d0(0x15)](0x190,_0x49a7a9),_0xff26d6=Math['max'](0x190,_0xff26d6);}else return _0x5e81e3&&_0x205c5d[_0x19d0(0x1)]?_0x80acbe:{'default':_0x566e71};}}}catch(_0x71af8d){console[_0x19d0(0x1f)]('❌\x20[COMPRESSION]\x20Resize\x20attempt\x20'+_0x5eab5c+_0x19d0(0x4d),_0x71af8d),_0x2143ce*=0.7,_0x49a7a9=Math[_0x19d0(0x13)](_0x1428e3['gakdv'](_0x49a7a9,0.8)),_0xff26d6=Math[_0x19d0(0x13)](_0x1428e3[_0x19d0(0x4e)](_0xff26d6,0.8));if(_0x1428e3[_0x19d0(0x4f)](_0x2143ce,0.1)||_0x1428e3[_0x19d0(0x4f)](_0x49a7a9,0xc8)||_0xff26d6<0xc8){if(_0x1428e3[_0x19d0(0x4a)](_0x19d0(0x50),_0x1428e3[_0x19d0(0x51)]))break;else _0x463570*=0.85;}}}console[_0x19d0(0x2d)](_0x19d0(0x52));try{const _0x4b9a6c=await _reactNativeImageResizer[_0x19d0(0x37)][_0x19d0(0x38)](_0x46cc4f,Math[_0x19d0(0x15)](0x190,_0x49a7a9),Math[_0x19d0(0x15)](0x190,_0xff26d6),format,0x1e,0x0,undefined,![],{'mode':_0x19d0(0x26),'onlyScaleDown':!![]}),_0xfaa8b9=await _0x1428e3['LEsmH'](getFileSizeFromUri,_0x4b9a6c[_0x19d0(0x3b)]),_0x111702=Math['round'](_0x1428e3[_0x19d0(0x3c)](_0xfaa8b9,0x400)),_0x26f054=await _0x1428e3[_0x19d0(0x40)](imageToBase64,_0x4b9a6c[_0x19d0(0x3b)]);if(_0x26f054){if(_0x1428e3[_0x19d0(0x41)](_0x1428e3[_0x19d0(0x53)],_0x1428e3[_0x19d0(0x54)]))_0xa13ef4*=0.6,_0x386849=_0xe6b0a['round'](_0x1428e3[_0x19d0(0x48)](_0x436100,0.8)),_0x416fbb=_0x48c39c['round'](_0x1428e3[_0x19d0(0x48)](_0x43fb97,0.8));else return console[_0x19d0(0x2d)](_0x1428e3[_0x19d0(0x55)],_0x111702,'KB'),{'success':!![],'base64':_0x26f054,'sizeKB':_0x111702,'originalSizeKB':_0xbfe508,'compressionRatio':_0x1428e3[_0x19d0(0x56)](_0xbfe508,_0x111702)};}}catch(_0x1a8c7c){console[_0x19d0(0x1f)](_0x1428e3[_0x19d0(0x57)],_0x1a8c7c);}return{'success':![],'error':_0x19d0(0x58)+maxSizeKB+_0x19d0(0x59)+_0x129492+_0x19d0(0x5a),'originalSizeKB':_0xbfe508};}catch(_0x242e45){return console[_0x19d0(0x1f)](_0x1428e3[_0x19d0(0x5b)],_0x242e45),{'success':![],'error':_0x1428e3['HfBzD'](_0x242e45,Error)?_0x242e45['message']:_0x1428e3[_0x19d0(0x36)],'originalSizeKB':0x0};}};exports[_0x19d0(0x3)]=compressImageToTarget;const compressProfilePicture=async _0x51b530=>{const _0x4e0711={'KxaZf':function(_0xa4a910,_0x458c8d,_0x11a87c){return _0xa4a910(_0x458c8d,_0x11a87c);}};return _0x4e0711['KxaZf'](compressImageToTarget,_0x51b530,{'maxSizeKB':0x12c,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x19d0(0x23)});};exports[_0x19d0(0x5c)]=compressProfilePicture;const compressForUpload=async(_0x282887,_0x159256=0x12c)=>{const _0x395bc7={'HhzKu':function(_0x5b4989,_0x399bf6,_0x86f585){return _0x5b4989(_0x399bf6,_0x86f585);},'iNpOF':_0x19d0(0x23)};return _0x395bc7[_0x19d0(0x5d)](compressImageToTarget,_0x282887,{'maxSizeKB':_0x159256,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x395bc7[_0x19d0(0x5e)]});};function _0x19d0(_0x2f9c1f,_0x19d0aa){_0x2f9c1f=_0x2f9c1f-0x0;const _0x144973=_0x2f9c();let _0x1294d1=_0x144973[_0x2f9c1f];return _0x1294d1;}exports['compressForUpload']=compressForUpload;const convertImageToOptimizedBase64=async(_0x4f5490,_0x25a17b=0.8)=>{const _0x4410d6={'MAcpp':function(_0x48e357,_0x41d6ee,_0xffbf71){return _0x48e357(_0x41d6ee,_0xffbf71);},'cbwCX':_0x19d0(0x23)},_0x25db74=await _0x4410d6[_0x19d0(0x5f)](compressImageToTarget,_0x4f5490,{'maxSizeKB':0x12c,'quality':_0x25a17b,'format':_0x4410d6[_0x19d0(0x60)]});return _0x25db74[_0x19d0(0x61)]?_0x25db74[_0x19d0(0x62)]||null:null;};exports[_0x19d0(0x2)]=convertImageToOptimizedBase64;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.convertImageToOptimizedBase64 = exports.compressProfilePicture = exports.compressImageToTarget = exports.compressForUpload = void 0;
|
|
7
|
+
var _reactNativeImageResizer = _interopRequireDefault(require("@bam.tech/react-native-image-resizer"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
/**
|
|
10
|
+
* Comprehensive image compression service for React Native
|
|
11
|
+
* Supports iterative compression to meet specific size targets
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get file size from URI (React Native compatible)
|
|
16
|
+
*/
|
|
17
|
+
const getFileSizeFromUri = async uri => {
|
|
18
|
+
try {
|
|
19
|
+
const response = await fetch(uri);
|
|
20
|
+
const blob = await response.blob();
|
|
21
|
+
return blob.size;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error getting file size:', error);
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Convert image to base64 string
|
|
30
|
+
*/
|
|
31
|
+
const imageToBase64 = async uri => {
|
|
32
|
+
try {
|
|
33
|
+
const response = await fetch(uri);
|
|
34
|
+
const blob = await response.blob();
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const reader = new FileReader();
|
|
37
|
+
reader.onloadend = () => {
|
|
38
|
+
try {
|
|
39
|
+
const base64data = reader.result;
|
|
40
|
+
// Remove the data:image/jpeg;base64, prefix
|
|
41
|
+
const base64 = base64data.split(',')[1];
|
|
42
|
+
resolve(base64);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
reject(error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
reader.onerror = reject;
|
|
48
|
+
reader.readAsDataURL(blob);
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Error converting image to base64:', error);
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Compress image with iterative quality reduction to meet size target
|
|
58
|
+
*/
|
|
59
|
+
const compressImageToTarget = async (imageUri, options = {}) => {
|
|
60
|
+
const {
|
|
61
|
+
maxSizeKB = 300,
|
|
62
|
+
maxWidth = 1200,
|
|
63
|
+
maxHeight = 1200,
|
|
64
|
+
quality = 0.8,
|
|
65
|
+
format = 'JPEG'
|
|
66
|
+
} = options;
|
|
67
|
+
try {
|
|
68
|
+
console.log('🖼️ [COMPRESSION] Starting compression for:', imageUri);
|
|
69
|
+
|
|
70
|
+
// Get original file size
|
|
71
|
+
const originalSize = await getFileSizeFromUri(imageUri);
|
|
72
|
+
const originalSizeKB = Math.round(originalSize / 1024);
|
|
73
|
+
console.log('📊 [COMPRESSION] Original size:', originalSizeKB, 'KB');
|
|
74
|
+
|
|
75
|
+
// If already under target, just convert to base64
|
|
76
|
+
if (originalSizeKB <= maxSizeKB) {
|
|
77
|
+
console.log('✅ [COMPRESSION] Image already under target size');
|
|
78
|
+
const base64 = await imageToBase64(imageUri);
|
|
79
|
+
if (base64) {
|
|
80
|
+
return {
|
|
81
|
+
success: true,
|
|
82
|
+
base64,
|
|
83
|
+
sizeKB: originalSizeKB,
|
|
84
|
+
originalSizeKB,
|
|
85
|
+
compressionRatio: 1.0
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Start with initial compression parameters
|
|
91
|
+
let currentQuality = quality;
|
|
92
|
+
let currentWidth = maxWidth;
|
|
93
|
+
let currentHeight = maxHeight;
|
|
94
|
+
let attempts = 0;
|
|
95
|
+
const maxAttempts = 8;
|
|
96
|
+
while (attempts < maxAttempts) {
|
|
97
|
+
attempts++;
|
|
98
|
+
console.log(`🔄 [COMPRESSION] Attempt ${attempts}: quality=${currentQuality}, size=${currentWidth}x${currentHeight}`);
|
|
99
|
+
try {
|
|
100
|
+
// Resize and compress the image
|
|
101
|
+
const resizedImage = await _reactNativeImageResizer.default.createResizedImage(imageUri, currentWidth, currentHeight, format, Math.round(currentQuality * 100),
|
|
102
|
+
// Convert to percentage
|
|
103
|
+
0,
|
|
104
|
+
// rotation
|
|
105
|
+
undefined,
|
|
106
|
+
// outputPath
|
|
107
|
+
false,
|
|
108
|
+
// keepMeta
|
|
109
|
+
{
|
|
110
|
+
mode: 'contain',
|
|
111
|
+
// Maintain aspect ratio
|
|
112
|
+
onlyScaleDown: true // Don't upscale
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Check the size of the compressed image
|
|
116
|
+
const compressedSize = await getFileSizeFromUri(resizedImage.uri);
|
|
117
|
+
const compressedSizeKB = Math.round(compressedSize / 1024);
|
|
118
|
+
console.log(`📊 [COMPRESSION] Attempt ${attempts} result: ${compressedSizeKB} KB`);
|
|
119
|
+
|
|
120
|
+
// If we've hit our target, convert to base64 and return
|
|
121
|
+
if (compressedSizeKB <= maxSizeKB) {
|
|
122
|
+
console.log('✅ [COMPRESSION] Target size achieved!');
|
|
123
|
+
const base64 = await imageToBase64(resizedImage.uri);
|
|
124
|
+
if (base64) {
|
|
125
|
+
const compressionRatio = originalSizeKB / compressedSizeKB;
|
|
126
|
+
console.log('🎯 [COMPRESSION] Success:', {
|
|
127
|
+
originalSizeKB,
|
|
128
|
+
finalSizeKB: compressedSizeKB,
|
|
129
|
+
compressionRatio: compressionRatio.toFixed(2) + 'x',
|
|
130
|
+
attempts
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
success: true,
|
|
134
|
+
base64,
|
|
135
|
+
sizeKB: compressedSizeKB,
|
|
136
|
+
originalSizeKB,
|
|
137
|
+
compressionRatio
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// If still too large, adjust parameters for next attempt
|
|
143
|
+
if (compressedSizeKB > maxSizeKB) {
|
|
144
|
+
// Reduce quality more aggressively if we're way over
|
|
145
|
+
const sizeRatio = compressedSizeKB / maxSizeKB;
|
|
146
|
+
if (sizeRatio > 2.0) {
|
|
147
|
+
// Way too big - reduce quality and dimensions significantly
|
|
148
|
+
currentQuality *= 0.6;
|
|
149
|
+
currentWidth = Math.round(currentWidth * 0.8);
|
|
150
|
+
currentHeight = Math.round(currentHeight * 0.8);
|
|
151
|
+
} else if (sizeRatio > 1.5) {
|
|
152
|
+
// Moderately too big - reduce quality more
|
|
153
|
+
currentQuality *= 0.75;
|
|
154
|
+
currentWidth = Math.round(currentWidth * 0.9);
|
|
155
|
+
currentHeight = Math.round(currentHeight * 0.9);
|
|
156
|
+
} else {
|
|
157
|
+
// Close to target - fine-tune quality
|
|
158
|
+
currentQuality *= 0.85;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Ensure we don't go below minimum thresholds
|
|
162
|
+
currentQuality = Math.max(0.1, currentQuality);
|
|
163
|
+
currentWidth = Math.max(400, currentWidth);
|
|
164
|
+
currentHeight = Math.max(400, currentHeight);
|
|
165
|
+
}
|
|
166
|
+
} catch (resizeError) {
|
|
167
|
+
console.error(`❌ [COMPRESSION] Resize attempt ${attempts} failed:`, resizeError);
|
|
168
|
+
|
|
169
|
+
// Try with more aggressive settings
|
|
170
|
+
currentQuality *= 0.7;
|
|
171
|
+
currentWidth = Math.round(currentWidth * 0.8);
|
|
172
|
+
currentHeight = Math.round(currentHeight * 0.8);
|
|
173
|
+
if (currentQuality < 0.1 || currentWidth < 200 || currentHeight < 200) {
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// If we've exhausted all attempts, return the best effort
|
|
180
|
+
console.log('⚠️ [COMPRESSION] Max attempts reached, using best effort');
|
|
181
|
+
try {
|
|
182
|
+
const finalImage = await _reactNativeImageResizer.default.createResizedImage(imageUri, Math.max(400, currentWidth), Math.max(400, currentHeight), format, 30,
|
|
183
|
+
// Very low quality as last resort
|
|
184
|
+
0, undefined, false, {
|
|
185
|
+
mode: 'contain',
|
|
186
|
+
onlyScaleDown: true
|
|
187
|
+
});
|
|
188
|
+
const finalSize = await getFileSizeFromUri(finalImage.uri);
|
|
189
|
+
const finalSizeKB = Math.round(finalSize / 1024);
|
|
190
|
+
const base64 = await imageToBase64(finalImage.uri);
|
|
191
|
+
if (base64) {
|
|
192
|
+
console.log('📤 [COMPRESSION] Final result (best effort):', finalSizeKB, 'KB');
|
|
193
|
+
return {
|
|
194
|
+
success: true,
|
|
195
|
+
base64,
|
|
196
|
+
sizeKB: finalSizeKB,
|
|
197
|
+
originalSizeKB,
|
|
198
|
+
compressionRatio: originalSizeKB / finalSizeKB
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
} catch (finalError) {
|
|
202
|
+
console.error('❌ [COMPRESSION] Final compression attempt failed:', finalError);
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
success: false,
|
|
206
|
+
error: `Failed to compress image to ${maxSizeKB}KB after ${maxAttempts} attempts`,
|
|
207
|
+
originalSizeKB
|
|
208
|
+
};
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error('❌ [COMPRESSION] Compression service error:', error);
|
|
211
|
+
return {
|
|
212
|
+
success: false,
|
|
213
|
+
error: error instanceof Error ? error.message : 'Unknown compression error',
|
|
214
|
+
originalSizeKB: 0
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Quick compression for profile pictures (300KB target)
|
|
221
|
+
*/
|
|
222
|
+
exports.compressImageToTarget = compressImageToTarget;
|
|
223
|
+
const compressProfilePicture = async imageUri => {
|
|
224
|
+
return compressImageToTarget(imageUri, {
|
|
225
|
+
maxSizeKB: 300,
|
|
226
|
+
maxWidth: 1200,
|
|
227
|
+
maxHeight: 1200,
|
|
228
|
+
quality: 0.8,
|
|
229
|
+
format: 'JPEG'
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Compress image for upload with custom settings
|
|
235
|
+
*/
|
|
236
|
+
exports.compressProfilePicture = compressProfilePicture;
|
|
237
|
+
const compressForUpload = async (imageUri, maxSizeKB = 300) => {
|
|
238
|
+
return compressImageToTarget(imageUri, {
|
|
239
|
+
maxSizeKB,
|
|
240
|
+
maxWidth: 1200,
|
|
241
|
+
maxHeight: 1200,
|
|
242
|
+
quality: 0.8,
|
|
243
|
+
format: 'JPEG'
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Legacy function for backward compatibility
|
|
249
|
+
*/
|
|
250
|
+
exports.compressForUpload = compressForUpload;
|
|
251
|
+
const convertImageToOptimizedBase64 = async (imageUri, quality = 0.8) => {
|
|
252
|
+
const result = await compressImageToTarget(imageUri, {
|
|
253
|
+
maxSizeKB: 300,
|
|
254
|
+
quality,
|
|
255
|
+
format: 'JPEG'
|
|
256
|
+
});
|
|
257
|
+
return result.success ? result.base64 || null : null;
|
|
258
|
+
};
|
|
259
|
+
exports.convertImageToOptimizedBase64 = convertImageToOptimizedBase64;
|
|
260
|
+
//# sourceMappingURL=imageCompressionService.js.map
|
|
@@ -1,8 +1,126 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useInstagramDataExtractor = void 0;
|
|
7
|
+
var _instagramDataService = require("./instagramDataService");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* Instagram Data Extractor
|
|
11
|
+
*
|
|
12
|
+
* Orchestrates the Instagram data export flow:
|
|
13
|
+
* 1. Receives extracted activity data from WebView
|
|
14
|
+
* 2. Validates and formats data
|
|
15
|
+
* 3. Sends to backend via instagramDataService
|
|
16
|
+
*
|
|
17
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
18
|
+
*
|
|
19
|
+
* @reference ChatGPT implementation: src/services/chatGPTConversationExtractor.ts
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Combined Instagram export data from WebView
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook for Instagram data extraction operations
|
|
28
|
+
*/
|
|
29
|
+
const useInstagramDataExtractor = () => {
|
|
30
|
+
/**
|
|
31
|
+
* Initiate data export to backend
|
|
32
|
+
*
|
|
33
|
+
* @param username - User identifier
|
|
34
|
+
* @param data - Extracted Instagram data (likes, saves, collections)
|
|
35
|
+
* @returns true if successful, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
const initiateDataExport = async (username, data) => {
|
|
38
|
+
var _data$likes, _data$saves, _data$collections, _data$likes2, _data$saves2, _data$collections2;
|
|
39
|
+
console.log('🚀 [INSTAGRAM_EXTRACTOR] Initiating data export');
|
|
40
|
+
console.log('👤 [INSTAGRAM_EXTRACTOR] Username:', username);
|
|
41
|
+
console.log('📊 [INSTAGRAM_EXTRACTOR] Likes:', data.total_likes);
|
|
42
|
+
console.log('📊 [INSTAGRAM_EXTRACTOR] Saves:', data.total_saves);
|
|
43
|
+
console.log('📊 [INSTAGRAM_EXTRACTOR] Collections:', data.total_collections);
|
|
44
|
+
|
|
45
|
+
// Validation
|
|
46
|
+
if (!username) {
|
|
47
|
+
console.error('❌ [INSTAGRAM_EXTRACTOR] Username is required');
|
|
48
|
+
_reactNative.Alert.alert('Error', 'Username is required to export Instagram data.', [{
|
|
49
|
+
text: 'OK',
|
|
50
|
+
style: 'default'
|
|
51
|
+
}]);
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Handle empty data as success - user might be new or have private activity
|
|
56
|
+
const totalItems = (((_data$likes = data.likes) === null || _data$likes === void 0 ? void 0 : _data$likes.length) || 0) + (((_data$saves = data.saves) === null || _data$saves === void 0 ? void 0 : _data$saves.length) || 0) + (((_data$collections = data.collections) === null || _data$collections === void 0 ? void 0 : _data$collections.length) || 0);
|
|
57
|
+
if (totalItems === 0) {
|
|
58
|
+
console.log('ℹ️ [INSTAGRAM_EXTRACTOR] No data to export - treating as success (connected)');
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Validate likes structure
|
|
63
|
+
const validLikes = (data.likes || []).filter(like => {
|
|
64
|
+
const isValid = like.id && like.type === 'like';
|
|
65
|
+
if (!isValid) {
|
|
66
|
+
console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid like:', like);
|
|
67
|
+
}
|
|
68
|
+
return isValid;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Validate saves structure
|
|
72
|
+
const validSaves = (data.saves || []).filter(save => {
|
|
73
|
+
const isValid = save.id && save.type === 'save';
|
|
74
|
+
if (!isValid) {
|
|
75
|
+
console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid save:', save);
|
|
76
|
+
}
|
|
77
|
+
return isValid;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Validate collections structure
|
|
81
|
+
const validCollections = (data.collections || []).filter(col => {
|
|
82
|
+
const isValid = col.id && col.name;
|
|
83
|
+
if (!isValid) {
|
|
84
|
+
console.warn('⚠️ [INSTAGRAM_EXTRACTOR] Invalid collection:', col);
|
|
85
|
+
}
|
|
86
|
+
return isValid;
|
|
87
|
+
});
|
|
88
|
+
const filteredOut = (((_data$likes2 = data.likes) === null || _data$likes2 === void 0 ? void 0 : _data$likes2.length) || 0) - validLikes.length + (((_data$saves2 = data.saves) === null || _data$saves2 === void 0 ? void 0 : _data$saves2.length) || 0) - validSaves.length + (((_data$collections2 = data.collections) === null || _data$collections2 === void 0 ? void 0 : _data$collections2.length) || 0) - validCollections.length;
|
|
89
|
+
if (filteredOut > 0) {
|
|
90
|
+
console.warn(`⚠️ [INSTAGRAM_EXTRACTOR] Filtered out ${filteredOut} invalid items`);
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
console.log('📡 [INSTAGRAM_EXTRACTOR] Sending to backend...');
|
|
94
|
+
const result = await (0, _instagramDataService.storeInstagramData)(username, {
|
|
95
|
+
likes: validLikes,
|
|
96
|
+
saves: validSaves,
|
|
97
|
+
collections: validCollections,
|
|
98
|
+
userId: data.userId
|
|
99
|
+
});
|
|
100
|
+
if (result.success) {
|
|
101
|
+
console.log('✅ [INSTAGRAM_EXTRACTOR] Export completed successfully');
|
|
102
|
+
console.log('📊 [INSTAGRAM_EXTRACTOR] Backend response:', result.data);
|
|
103
|
+
return true;
|
|
104
|
+
} else {
|
|
105
|
+
console.error('❌ [INSTAGRAM_EXTRACTOR] Backend storage failed:', result.error);
|
|
106
|
+
_reactNative.Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
|
|
107
|
+
text: 'OK',
|
|
108
|
+
style: 'default'
|
|
109
|
+
}]);
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.error('❌ [INSTAGRAM_EXTRACTOR] Unexpected error during export:', error);
|
|
114
|
+
_reactNative.Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
|
|
115
|
+
text: 'OK',
|
|
116
|
+
style: 'default'
|
|
117
|
+
}]);
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
initiateDataExport
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
exports.useInstagramDataExtractor = useInstagramDataExtractor;
|
|
126
|
+
//# sourceMappingURL=instagramDataExtractor.js.map
|
|
@@ -1,9 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.storeInstagramData = void 0;
|
|
7
|
+
var _api = require("../config/api");
|
|
8
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* Instagram Data Service
|
|
13
|
+
*
|
|
14
|
+
* API layer for storing Instagram activity data on backend.
|
|
15
|
+
* Sends extracted likes, saves, and collections to /platform-data/store endpoint.
|
|
16
|
+
*
|
|
17
|
+
* MATCHES ChatGPT implementation pattern
|
|
18
|
+
* - Uses format: { platform, data, metadata }
|
|
19
|
+
* - Platform: "mobile-instagram"
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Structure of a liked post
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Structure of a saved post
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Structure of a collection
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Combined Instagram data to store
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Response from backend endpoint
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Store Instagram data on backend
|
|
44
|
+
*
|
|
45
|
+
* @param userId - Username or identifier
|
|
46
|
+
* @param data - Instagram likes, saves, and collections data
|
|
47
|
+
* @returns Response indicating success/failure with metadata
|
|
48
|
+
*/
|
|
49
|
+
const storeInstagramData = async (userId, data) => {
|
|
50
|
+
console.log('🚀 [INSTAGRAM_SERVICE] Storing Instagram data for:', userId);
|
|
51
|
+
console.log('📊 [INSTAGRAM_SERVICE] Likes:', data.likes.length);
|
|
52
|
+
console.log('📊 [INSTAGRAM_SERVICE] Saves:', data.saves.length);
|
|
53
|
+
console.log('📊 [INSTAGRAM_SERVICE] Collections:', data.collections.length);
|
|
54
|
+
|
|
55
|
+
// Input validation
|
|
56
|
+
if (!userId) {
|
|
57
|
+
console.error('❌ [INSTAGRAM_SERVICE] Invalid input: userId missing');
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
error: 'Invalid input: userId missing.'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
// Get auth token - check all possible storage keys
|
|
65
|
+
const authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
66
|
+
if (!authToken) {
|
|
67
|
+
console.error('❌ [INSTAGRAM_SERVICE] No auth token found');
|
|
68
|
+
return {
|
|
69
|
+
success: false,
|
|
70
|
+
error: 'Authentication token not found. Please log in again.'
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
console.log('🔑 [INSTAGRAM_SERVICE] Auth token found');
|
|
74
|
+
|
|
75
|
+
// Mobile metadata
|
|
76
|
+
const mobileMetadata = {
|
|
77
|
+
platform: _reactNative.Platform.OS,
|
|
78
|
+
appVersion: '1.0.0',
|
|
79
|
+
osVersion: _reactNative.Platform.OS === 'ios' ? '17.0' : _reactNative.Platform.OS,
|
|
80
|
+
deviceModel: _reactNative.Platform.OS === 'ios' ? 'iPhone' : 'Android',
|
|
81
|
+
isOfflineSync: false,
|
|
82
|
+
extractedAt: new Date().toISOString()
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// Build request body
|
|
86
|
+
const requestBody = {
|
|
87
|
+
platform: 'mobile-instagram',
|
|
88
|
+
dataType: 'social',
|
|
89
|
+
data: {
|
|
90
|
+
likes: data.likes.map(like => ({
|
|
91
|
+
postId: like.id,
|
|
92
|
+
type: 'like',
|
|
93
|
+
mediaType: like.mediaType,
|
|
94
|
+
caption: like.caption,
|
|
95
|
+
owner: like.owner,
|
|
96
|
+
timestamp: like.timestamp,
|
|
97
|
+
url: like.url
|
|
98
|
+
})),
|
|
99
|
+
saves: data.saves.map(save => ({
|
|
100
|
+
postId: save.id,
|
|
101
|
+
type: 'save',
|
|
102
|
+
mediaType: save.mediaType,
|
|
103
|
+
caption: save.caption,
|
|
104
|
+
owner: save.owner,
|
|
105
|
+
timestamp: save.timestamp,
|
|
106
|
+
url: save.url
|
|
107
|
+
})),
|
|
108
|
+
collections: data.collections.map(col => ({
|
|
109
|
+
collectionId: col.id,
|
|
110
|
+
name: col.name,
|
|
111
|
+
mediaCount: col.mediaCount,
|
|
112
|
+
coverUrl: col.coverUrl
|
|
113
|
+
})),
|
|
114
|
+
instagramUserId: data.userId
|
|
115
|
+
},
|
|
116
|
+
summary: {
|
|
117
|
+
likeCount: data.likes.length,
|
|
118
|
+
saveCount: data.saves.length,
|
|
119
|
+
collectionCount: data.collections.length,
|
|
120
|
+
totalEngagements: data.likes.length + data.saves.length
|
|
121
|
+
},
|
|
122
|
+
mobileMetadata: mobileMetadata
|
|
123
|
+
};
|
|
124
|
+
console.log('📡 [INSTAGRAM_SERVICE] Sending to backend...');
|
|
125
|
+
console.log('📍 [INSTAGRAM_SERVICE] URL:', `${_api.API_CONFIG.BASE_URL}/platform-data/store`);
|
|
126
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/platform-data/store`, {
|
|
127
|
+
method: 'POST',
|
|
128
|
+
headers: {
|
|
129
|
+
'Content-Type': 'application/json',
|
|
130
|
+
'Authorization': `Bearer ${authToken}`,
|
|
131
|
+
'User-Agent': `OnairosSDK/1.0.0 (${_reactNative.Platform.OS})`
|
|
132
|
+
},
|
|
133
|
+
body: JSON.stringify(requestBody)
|
|
134
|
+
});
|
|
135
|
+
const responseData = await response.json();
|
|
136
|
+
if (response.ok) {
|
|
137
|
+
console.log('✅ [INSTAGRAM_SERVICE] Successfully stored Instagram data');
|
|
138
|
+
if (responseData.message) {
|
|
139
|
+
console.log(`📝 [INSTAGRAM_SERVICE] Backend response: ${responseData.message}`);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
success: true,
|
|
143
|
+
message: responseData.message || 'Instagram data stored successfully',
|
|
144
|
+
data: responseData.data
|
|
145
|
+
};
|
|
146
|
+
} else {
|
|
147
|
+
console.warn(`⚠️ [INSTAGRAM_SERVICE] Backend returned status: ${response.status}`);
|
|
148
|
+
console.warn(`⚠️ [INSTAGRAM_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
|
|
149
|
+
return {
|
|
150
|
+
success: false,
|
|
151
|
+
error: responseData.error || `HTTP ${response.status}`
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error('❌ [INSTAGRAM_SERVICE] Network error:', error);
|
|
156
|
+
return {
|
|
157
|
+
success: false,
|
|
158
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
exports.storeInstagramData = storeInstagramData;
|
|
163
|
+
//# sourceMappingURL=instagramDataService.js.map
|