@onairos/react-native 3.7.2 → 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/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/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
|
-
function _0xc57e(_0x1ab69f,_0xc57edf){_0x1ab69f=_0x1ab69f-0x0;const _0x17e9d3=_0x1ab6();let _0x485623=_0x17e9d3[_0x1ab69f];return _0x485623;}Object['defineProperty'](exports,_0xc57e(0x0),{'value':!![]}),exports['convertImageToOptimizedBase64']=exports[_0xc57e(0x1)]=exports[_0xc57e(0x2)]=exports[_0xc57e(0x3)]=void 0x0;var _reactNativeImageResizer=_interopRequireDefault(__ONAIROS_REQ_FUNC__(0x0));function _0x1ab6(){const _0x45afde=['__esModule','compressProfilePicture','compressImageToTarget','compressForUpload','Error\x20getting\x20file\x20size:','size','xSygl','blALU','YXmSF','blob','onloadend','split','DPSsV','onerror','readAsDataURL','OoiDD','dRMgr','error','Error\x20converting\x20image\x20to\x20base64:','APWAW','📤\x20[COMPRESSION]\x20Final\x20result\x20(best\x20effort):','ffHzk','📊\x20[COMPRESSION]\x20Original\x20size:','✅\x20[COMPRESSION]\x20Image\x20already\x20under\x20target\x20size','GwEeR','Ihosi','contain','hZkxO','vcohB','❌\x20[COMPRESSION]\x20Compression\x20service\x20error:','MPGUi','HDbVH','gZenG','round','RxdgL','BptCd','log','kDFJN','lWLBK','MFQjd','etEch','🎯\x20[COMPRESSION]\x20Success:','BXehq','IIArg',':\x20quality=',',\x20size=','AJgQg','SaJyf','default','createResizedImage','sItMx','yYECZ','LCarY','uri','📊\x20[COMPRESSION]\x20Attempt\x20','\x20result:\x20','\x20KB','toFixed','bjsLn','gUZvA','oeaTR','max','result','gRkOu','TmQBc','❌\x20[COMPRESSION]\x20Resize\x20attempt\x20','\x20failed:','YYFwa','TstUv','ybhyH','CNsrg','fMneX','gzors','tYPRZ','JAOYo','EyigR','LUPNx','KB\x20after\x20','\x20attempts','YcHDb','YYqJw','message','Unknown\x20compression\x20error','JPEG','vPOcf','SqXpY','AXybR','PVhpd','RSCen','success','base64','convertImageToOptimizedBase64'];_0x1ab6=function(){return _0x45afde;};return _0x1ab6();}function _interopRequireDefault(_0x489341){return _0x489341&&_0x489341[_0xc57e(0x0)]?_0x489341:{'default':_0x489341};}const getFileSizeFromUri=async _0x44c4cb=>{const _0x5b2de9={'xSygl':_0xc57e(0x4)};try{const _0x37ccbf=await fetch(_0x44c4cb),_0x4f8116=await _0x37ccbf['blob']();return _0x4f8116[_0xc57e(0x5)];}catch(_0x3097ed){return console['error'](_0x5b2de9[_0xc57e(0x6)],_0x3097ed),0x0;}},imageToBase64=async _0x24227e=>{const _0x3d2cb2={'APWAW':function(_0x2f4fe0,_0x21301c){return _0x2f4fe0(_0x21301c);},'YXmSF':function(_0x296d08,_0x47bbf2){return _0x296d08(_0x47bbf2);},'OoiDD':function(_0x5658bb,_0x12a51d){return _0x5658bb===_0x12a51d;},'dRMgr':_0xc57e(0x7)};try{const _0xce2fbc=await _0x3d2cb2[_0xc57e(0x8)](fetch,_0x24227e),_0xbe7713=await _0xce2fbc[_0xc57e(0x9)]();return new Promise((_0x4fc719,_0x5f4289)=>{const _0x2fbf37={'DPSsV':function(_0x4e3076,_0x3fdf39){return _0x3d2cb2['APWAW'](_0x4e3076,_0x3fdf39);}},_0x469bc4=new FileReader();_0x469bc4[_0xc57e(0xa)]=()=>{try{const _0x4649c6=_0x469bc4['result'],_0x373267=_0x4649c6[_0xc57e(0xb)](',')[0x1];_0x2fbf37[_0xc57e(0xc)](_0x4fc719,_0x373267);}catch(_0x5b3f6c){_0x2fbf37['DPSsV'](_0x5f4289,_0x5b3f6c);}},_0x469bc4[_0xc57e(0xd)]=_0x5f4289,_0x469bc4[_0xc57e(0xe)](_0xbe7713);});}catch(_0xe7715e){if(_0x3d2cb2[_0xc57e(0xf)](_0x3d2cb2[_0xc57e(0x10)],_0x3d2cb2[_0xc57e(0x10)]))return console[_0xc57e(0x11)](_0xc57e(0x12),_0xe7715e),null;else{const _0x16b4b4=_0x565d4a['result'],_0x163769=_0x16b4b4['split'](',')[0x1];_0x3d2cb2[_0xc57e(0x13)](_0x5c257e,_0x163769);}}},compressImageToTarget=async(_0x12d961,_0x4523f3={})=>{const _0x3f01c7={'etEch':function(_0x3d0249,_0x4e8fa8){return _0x3d0249/_0x4e8fa8;},'BXehq':function(_0x21441e,_0x46ce63){return _0x21441e+_0x46ce63;},'lWLBK':function(_0x44fb06,_0x2cff35){return _0x44fb06(_0x2cff35);},'TmQBc':function(_0x5112c5,_0xe65da8,_0x5c346b){return _0x5112c5(_0xe65da8,_0x5c346b);},'MPGUi':'JPEG','gzors':function(_0x3cde82,_0x2c96b1){return _0x3cde82(_0x2c96b1);},'EyigR':_0xc57e(0x14),'HDbVH':function(_0x53efa9,_0x4e87d1){return _0x53efa9!==_0x4e87d1;},'gZenG':'xlYDC','uiwYM':_0xc57e(0x15),'WNAMo':function(_0x11d79a,_0x4a4ff8){return _0x11d79a(_0x4a4ff8);},'RxdgL':_0xc57e(0x16),'BptCd':function(_0x5ed6d2,_0x25c722){return _0x5ed6d2<=_0x25c722;},'kDFJN':_0xc57e(0x17),'MqUAw':_0xc57e(0x18),'MFQjd':'sCKgt','IIArg':function(_0x4e88d3,_0xc72d1c){return _0x4e88d3<_0xc72d1c;},'AJgQg':_0xc57e(0x19),'SaJyf':'FiJHN','sItMx':function(_0x9f8dfe,_0x2ee415){return _0x9f8dfe*_0x2ee415;},'yYECZ':_0xc57e(0x1a),'LCarY':function(_0x25ca9b,_0x297bf7){return _0x25ca9b(_0x297bf7);},'egblB':function(_0x573a85,_0x58cfb1){return _0x573a85<=_0x58cfb1;},'MavWE':'✅\x20[COMPRESSION]\x20Target\x20size\x20achieved!','dczad':function(_0x47ce15,_0x4e2c3a){return _0x47ce15>_0x4e2c3a;},'bjsLn':function(_0x32eeea,_0x3bbc71){return _0x32eeea===_0x3bbc71;},'gUZvA':'kCvIL','bPVxi':function(_0xae2545,_0x956dbe){return _0xae2545>_0x956dbe;},'oeaTR':function(_0xee2e2c,_0x55d86d){return _0xee2e2c*_0x55d86d;},'YSqll':_0xc57e(0x1b),'gRkOu':'wxCAa','YYFwa':function(_0x4f6c37,_0x1bf2a6){return _0x4f6c37*_0x1bf2a6;},'TstUv':function(_0x405d5d,_0x2694b7){return _0x405d5d<_0x2694b7;},'ybhyH':function(_0x12423c,_0x1e5033){return _0x12423c<_0x1e5033;},'CNsrg':function(_0x21ba91,_0x36cdda){return _0x21ba91<_0x36cdda;},'fMneX':_0xc57e(0x1c),'tYPRZ':'⚠️\x20[COMPRESSION]\x20Max\x20attempts\x20reached,\x20using\x20best\x20effort','JAOYo':'VuuGV','LUPNx':'hhfVF','YcHDb':_0xc57e(0x1d),'YYqJw':function(_0x3a8c37,_0x2ce054){return _0x3a8c37 instanceof _0x2ce054;}},{maxSizeKB:maxSizeKB=0x12c,maxWidth:maxWidth=0x4b0,maxHeight:maxHeight=0x4b0,quality:quality=0.8,format:format=_0x3f01c7[_0xc57e(0x1e)]}=_0x4523f3;try{if(_0x3f01c7[_0xc57e(0x1f)](_0x3f01c7[_0xc57e(0x20)],_0x3f01c7['uiwYM'])){console['log']('🖼️\x20[COMPRESSION]\x20Starting\x20compression\x20for:',_0x12d961);const _0x3a4157=await _0x3f01c7['WNAMo'](getFileSizeFromUri,_0x12d961),_0x2f3661=Math[_0xc57e(0x21)](_0x3a4157/0x400);console['log'](_0x3f01c7[_0xc57e(0x22)],_0x2f3661,'KB');if(_0x3f01c7[_0xc57e(0x23)](_0x2f3661,maxSizeKB)){console[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x25)]);const _0x5a5bef=await _0x3f01c7[_0xc57e(0x26)](imageToBase64,_0x12d961);if(_0x5a5bef){if(_0x3f01c7['HDbVH'](_0x3f01c7['MqUAw'],_0x3f01c7[_0xc57e(0x27)]))return{'success':!![],'base64':_0x5a5bef,'sizeKB':_0x2f3661,'originalSizeKB':_0x2f3661,'compressionRatio':0x1};else{const _0x9b1ee4=_0x3f01c7[_0xc57e(0x28)](_0x3b61ba,_0x34f41f);return _0x20416c[_0xc57e(0x24)](_0xc57e(0x29),{'originalSizeKB':_0x5bf3bb,'finalSizeKB':_0x32aa7b,'compressionRatio':_0x3f01c7[_0xc57e(0x2a)](_0x9b1ee4['toFixed'](0x2),'x'),'attempts':_0x244d58}),{'success':!![],'base64':_0x5df70f,'sizeKB':_0x35be1d,'originalSizeKB':_0x555499,'compressionRatio':_0x9b1ee4};}}}let _0x3e0770=quality,_0xc9d29=maxWidth,_0x36df98=maxHeight,_0x4c79b1=0x0;const _0x39db96=0x8;while(_0x3f01c7[_0xc57e(0x2b)](_0x4c79b1,_0x39db96)){_0x4c79b1++,console[_0xc57e(0x24)]('🔄\x20[COMPRESSION]\x20Attempt\x20'+_0x4c79b1+_0xc57e(0x2c)+_0x3e0770+_0xc57e(0x2d)+_0xc9d29+'x'+_0x36df98);try{if(_0x3f01c7[_0xc57e(0x2e)]===_0x3f01c7[_0xc57e(0x2f)])_0x29e79c[_0xc57e(0x11)]('❌\x20[COMPRESSION]\x20Final\x20compression\x20attempt\x20failed:',_0x3b463b);else{const _0x1d2272=await _reactNativeImageResizer[_0xc57e(0x30)][_0xc57e(0x31)](_0x12d961,_0xc9d29,_0x36df98,format,Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x32)](_0x3e0770,0x64)),0x0,undefined,![],{'mode':_0x3f01c7[_0xc57e(0x33)],'onlyScaleDown':!![]}),_0x18e17f=await _0x3f01c7[_0xc57e(0x34)](getFileSizeFromUri,_0x1d2272[_0xc57e(0x35)]),_0x54867b=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x28)](_0x18e17f,0x400));console[_0xc57e(0x24)](_0xc57e(0x36)+_0x4c79b1+_0xc57e(0x37)+_0x54867b+_0xc57e(0x38));if(_0x3f01c7['egblB'](_0x54867b,maxSizeKB)){console[_0xc57e(0x24)](_0x3f01c7['MavWE']);const _0x153b33=await imageToBase64(_0x1d2272[_0xc57e(0x35)]);if(_0x153b33){const _0x58d344=_0x3f01c7['etEch'](_0x2f3661,_0x54867b);return console[_0xc57e(0x24)](_0xc57e(0x29),{'originalSizeKB':_0x2f3661,'finalSizeKB':_0x54867b,'compressionRatio':_0x3f01c7['BXehq'](_0x58d344[_0xc57e(0x39)](0x2),'x'),'attempts':_0x4c79b1}),{'success':!![],'base64':_0x153b33,'sizeKB':_0x54867b,'originalSizeKB':_0x2f3661,'compressionRatio':_0x58d344};}}if(_0x3f01c7['dczad'](_0x54867b,maxSizeKB)){if(_0x3f01c7[_0xc57e(0x3a)](_0x3f01c7[_0xc57e(0x3b)],_0x3f01c7['gUZvA'])){const _0x1a8567=_0x3f01c7[_0xc57e(0x28)](_0x54867b,maxSizeKB);if(_0x3f01c7['bPVxi'](_0x1a8567,0x2))_0x3e0770*=0.6,_0xc9d29=Math['round'](_0x3f01c7[_0xc57e(0x32)](_0xc9d29,0.8)),_0x36df98=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x3c)](_0x36df98,0.8));else _0x1a8567>1.5?(_0x3e0770*=0.75,_0xc9d29=Math[_0xc57e(0x21)](_0xc9d29*0.9),_0x36df98=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x3c)](_0x36df98,0.9))):_0x3e0770*=0.85;_0x3e0770=Math[_0xc57e(0x3d)](0.1,_0x3e0770),_0xc9d29=Math[_0xc57e(0x3d)](0x190,_0xc9d29),_0x36df98=Math[_0xc57e(0x3d)](0x190,_0x36df98);}else try{const _0x196453=_0x203aee[_0xc57e(0x3e)],_0x2eae42=_0x196453[_0xc57e(0xb)](',')[0x1];_0x3f01c7[_0xc57e(0x26)](_0x43f0e9,_0x2eae42);}catch(_0x2b2f24){_0x3f01c7[_0xc57e(0x26)](_0x2f93e8,_0x2b2f24);}}}}catch(_0x3e30b0){if(_0x3f01c7[_0xc57e(0x3a)](_0x3f01c7['YSqll'],_0x3f01c7[_0xc57e(0x3f)]))return _0x3f01c7[_0xc57e(0x40)](_0x369e92,_0x3c5689,{'maxSizeKB':_0x3e5a7d,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x3f01c7[_0xc57e(0x1e)]});else{console['error'](_0xc57e(0x41)+_0x4c79b1+_0xc57e(0x42),_0x3e30b0),_0x3e0770*=0.7,_0xc9d29=Math[_0xc57e(0x21)](_0x3f01c7[_0xc57e(0x3c)](_0xc9d29,0.8)),_0x36df98=Math['round'](_0x3f01c7[_0xc57e(0x43)](_0x36df98,0.8));if(_0x3f01c7[_0xc57e(0x44)](_0x3e0770,0.1)||_0x3f01c7[_0xc57e(0x45)](_0xc9d29,0xc8)||_0x3f01c7[_0xc57e(0x46)](_0x36df98,0xc8)){if(_0x3f01c7[_0xc57e(0x1f)](_0xc57e(0x1c),_0x3f01c7[_0xc57e(0x47)]))_0x3f01c7[_0xc57e(0x48)](_0x34a0bb,_0x35c17f);else break;}}}}console[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x49)]);try{if(_0x3f01c7[_0xc57e(0x1f)](_0x3f01c7[_0xc57e(0x4a)],_0x3f01c7[_0xc57e(0x4a)]))return _0x1e40d3(_0x235713,{'maxSizeKB':0x12c,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x3f01c7[_0xc57e(0x1e)]});else{const _0x2aa752=await _reactNativeImageResizer[_0xc57e(0x30)][_0xc57e(0x31)](_0x12d961,Math[_0xc57e(0x3d)](0x190,_0xc9d29),Math[_0xc57e(0x3d)](0x190,_0x36df98),format,0x1e,0x0,undefined,![],{'mode':_0x3f01c7[_0xc57e(0x33)],'onlyScaleDown':!![]}),_0x3b9a19=await _0x3f01c7[_0xc57e(0x26)](getFileSizeFromUri,_0x2aa752[_0xc57e(0x35)]),_0xe2954c=Math['round'](_0x3b9a19/0x400),_0x13efb1=await _0x3f01c7['lWLBK'](imageToBase64,_0x2aa752['uri']);if(_0x13efb1)return console[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x4b)],_0xe2954c,'KB'),{'success':!![],'base64':_0x13efb1,'sizeKB':_0xe2954c,'originalSizeKB':_0x2f3661,'compressionRatio':_0x3f01c7[_0xc57e(0x28)](_0x2f3661,_0xe2954c)};}}catch(_0x2c9731){if(_0x3f01c7[_0xc57e(0x3a)](_0x3f01c7[_0xc57e(0x4c)],_0x3f01c7[_0xc57e(0x4c)]))console[_0xc57e(0x11)]('❌\x20[COMPRESSION]\x20Final\x20compression\x20attempt\x20failed:',_0x2c9731);else return _0xdb42db[_0xc57e(0x24)](_0x3f01c7[_0xc57e(0x4b)],_0x3d8598,'KB'),{'success':!![],'base64':_0x1290ac,'sizeKB':_0x3c9917,'originalSizeKB':_0xa20c6f,'compressionRatio':_0x3f01c7['etEch'](_0x25cff1,_0x1590e3)};}return{'success':![],'error':'Failed\x20to\x20compress\x20image\x20to\x20'+maxSizeKB+_0xc57e(0x4d)+_0x39db96+_0xc57e(0x4e),'originalSizeKB':_0x2f3661};}else _0x2da7b8*=0.85;}catch(_0x25be2a){return console[_0xc57e(0x11)](_0x3f01c7[_0xc57e(0x4f)],_0x25be2a),{'success':![],'error':_0x3f01c7[_0xc57e(0x50)](_0x25be2a,Error)?_0x25be2a[_0xc57e(0x51)]:_0xc57e(0x52),'originalSizeKB':0x0};}};exports[_0xc57e(0x2)]=compressImageToTarget;const compressProfilePicture=async _0x34b5a6=>{const _0x5d1db5={'vPOcf':_0xc57e(0x53)};return compressImageToTarget(_0x34b5a6,{'maxSizeKB':0x12c,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x5d1db5[_0xc57e(0x54)]});};exports[_0xc57e(0x1)]=compressProfilePicture;const compressForUpload=async(_0x3b002e,_0x181758=0x12c)=>{const _0x5e7be0={'SqXpY':function(_0x27900e,_0xd4b2b9,_0x445a5f){return _0x27900e(_0xd4b2b9,_0x445a5f);},'AXybR':_0xc57e(0x53)};return _0x5e7be0[_0xc57e(0x55)](compressImageToTarget,_0x3b002e,{'maxSizeKB':_0x181758,'maxWidth':0x4b0,'maxHeight':0x4b0,'quality':0.8,'format':_0x5e7be0[_0xc57e(0x56)]});};exports[_0xc57e(0x3)]=compressForUpload;const convertImageToOptimizedBase64=async(_0x1ba2e8,_0xa12058=0.8)=>{const _0xd0d10c={'PVhpd':function(_0x1ff426,_0x301b7f,_0x1ce50d){return _0x1ff426(_0x301b7f,_0x1ce50d);},'RSCen':'JPEG'},_0x3da5fc=await _0xd0d10c[_0xc57e(0x57)](compressImageToTarget,_0x1ba2e8,{'maxSizeKB':0x12c,'quality':_0xa12058,'format':_0xd0d10c[_0xc57e(0x58)]});return _0x3da5fc[_0xc57e(0x59)]?_0x3da5fc[_0xc57e(0x5a)]||null:null;};exports[_0xc57e(0x5b)]=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
|