@onairos/react-native 3.0.64 โ†’ 3.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/lib/commonjs/components/DataRequestScreen.js +329 -0
  2. package/lib/commonjs/components/DataRequestScreen.js.map +1 -0
  3. package/lib/commonjs/components/TrainingModal.js +75 -4
  4. package/lib/commonjs/components/TrainingModal.js.map +1 -1
  5. package/lib/commonjs/components/UniversalOnboarding.js +199 -30
  6. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  7. package/lib/commonjs/index.js +8 -0
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/module/components/DataRequestScreen.js +321 -0
  10. package/lib/module/components/DataRequestScreen.js.map +1 -0
  11. package/lib/module/components/TrainingModal.js +75 -4
  12. package/lib/module/components/TrainingModal.js.map +1 -1
  13. package/lib/module/components/UniversalOnboarding.js +199 -30
  14. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  15. package/lib/module/index.js +11 -9
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/typescript/components/DataRequestScreen.d.ts +11 -0
  18. package/lib/typescript/components/DataRequestScreen.d.ts.map +1 -0
  19. package/lib/typescript/components/TrainingModal.d.ts.map +1 -1
  20. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -1
  21. package/lib/typescript/index.d.ts +1 -0
  22. package/lib/typescript/index.d.ts.map +1 -1
  23. package/lib/typescript/types/index.d.ts +8 -1
  24. package/lib/typescript/types/index.d.ts.map +1 -1
  25. package/lib/typescript/types.d.ts +8 -1
  26. package/lib/typescript/types.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/components/DataRequestScreen.tsx +356 -0
  29. package/src/components/TrainingModal.tsx +58 -4
  30. package/src/components/UniversalOnboarding.tsx +218 -29
  31. package/src/index.ts +1 -0
  32. package/src/types/index.d.ts +5 -0
  33. package/src/types/index.ts +12 -1
  34. package/src/types.ts +12 -1
@@ -22,12 +22,12 @@ import Icon from 'react-native-vector-icons/MaterialIcons';
22
22
  import { PlatformList } from './PlatformList';
23
23
  import { PinInput } from './PinInput';
24
24
  import { TrainingModal } from './TrainingModal';
25
- import { DataRequestModal } from './DataRequestModal';
25
+ import { DataRequestScreen } from './DataRequestScreen';
26
26
  import { OAuthWebView } from './onboarding/OAuthWebView';
27
27
  import { useConnections } from '../hooks/useConnections';
28
28
  import { COLORS, DEEP_LINK_CONFIG } from '../constants';
29
29
  import { initiateOAuth, initiateNativeAuth, hasNativeSDK, isOAuthCallback, testApiConnectivity, handleOAuthCallbackUrl, refreshYouTubeTokens, requestEmailVerification, verifyEmailCode, checkEmailVerificationStatus, disconnectPlatform } from '../services/platformAuthService';
30
- import type { UniversalOnboardingProps, ConnectionStatus } from '../types';
30
+ import type { UniversalOnboardingProps, ConnectionStatus, TestModeOptions } from '../types';
31
31
 
32
32
  // Optional Opacity SDK imports with error handling
33
33
  let opacityInit: any = null;
@@ -80,7 +80,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
80
80
  const [email, setEmail] = useState<string>('');
81
81
  const [verificationCode, setVerificationCode] = useState<string>('');
82
82
  const [isVerifyingCode, setIsVerifyingCode] = useState<boolean>(false);
83
- const [showDataRequestModal, setShowDataRequestModal] = useState<boolean>(false);
83
+
84
84
  const [isExistingUser, setIsExistingUser] = useState<boolean>(false);
85
85
 
86
86
  // Add refs for cleanup and code inputs
@@ -88,14 +88,34 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
88
88
  const isMountedRef = useRef<boolean>(true);
89
89
  const codeInputRefs = useRef<Array<TextInput | null>>([]);
90
90
 
91
+ // Add state for showing additional platforms
92
+ const [showAllPlatforms, setShowAllPlatforms] = useState<boolean>(false);
93
+
94
+
95
+ // Parse test mode options
96
+ const testModeOptions = typeof test === 'object' ? test : {};
97
+ const isTestMode = test === true || (typeof test === 'object' && test !== null);
98
+ const showTestControls = (debug || isTestMode) && requestData;
99
+
100
+ // Simple 2-flow system
101
+ const isExistingUserFlow = testModeOptions.existingUser || false;
102
+ const isNewUserFlow = testModeOptions.newUser || false;
103
+
91
104
  const platforms = [
92
105
  { id: 'instagram', name: 'Instagram', icon: require('../assets/images/instagram.png') },
93
106
  { id: 'youtube', name: 'YouTube', icon: require('../assets/images/youtube.png') },
107
+ { id: 'email', name: 'Gmail', icon: require('../assets/images/email.png') },
94
108
  { id: 'reddit', name: 'Reddit', icon: require('../assets/images/reddit.png') },
95
109
  { id: 'pinterest', name: 'Pinterest', icon: require('../assets/images/pinterest.png') },
96
- { id: 'email', name: 'Gmail', icon: require('../assets/images/email.png') },
97
110
  ];
98
111
 
112
+ // Define primary platforms (shown by default)
113
+ const primaryPlatforms = platforms.slice(0, 3); // Instagram, YouTube, Gmail
114
+ const additionalPlatforms = platforms.slice(3); // Reddit, Pinterest
115
+
116
+ // Get platforms to display based on showAllPlatforms state
117
+ const platformsToDisplay = showAllPlatforms ? platforms : primaryPlatforms;
118
+
99
119
  const {
100
120
  connectPlatform,
101
121
  disconnectPlatform,
@@ -570,21 +590,41 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
570
590
  throw new Error('Email verification service not available');
571
591
  }
572
592
 
593
+ // Test Mode: Use specific flows
594
+ if (isTestMode) {
595
+ console.log('๐Ÿงช Test mode verification - simulating success');
596
+
597
+ if (isExistingUserFlow) {
598
+ // Flow 1: Existing User โ†’ Data Request โ†’ Close (return API URL)
599
+ console.log('๐Ÿงช Test Flow 1: Existing User โ†’ Show Data Request');
600
+ setIsExistingUser(true);
601
+ setStep('dataRequest');
602
+ return;
603
+ } else if (isNewUserFlow) {
604
+ // Flow 2: New User โ†’ Platform Connect โ†’ PIN โ†’ Training
605
+ console.log('๐Ÿงช Test Flow 2: New User โ†’ Platform Connect');
606
+ const emailPrefix = email.trim().split('@')[0] || 'TestUser';
607
+ setUsername(emailPrefix);
608
+ setStep('connect');
609
+ return;
610
+ }
611
+ }
612
+
613
+ // Real API call (production)
573
614
  const result = await verifyEmailCode(email.trim(), verificationCode.trim());
574
615
 
575
616
  if (result.success) {
576
617
  console.log('โœ… Email verification successful');
577
618
 
578
- // For now, always treat as new users for testing (can be updated later)
579
- // In production, this would check if user exists in database
580
- const existingUser = false; // TODO: Check backend for existing user
619
+ // Check if user exists in backend
620
+ const existingUser = (result as any).existingUser || false;
581
621
  setIsExistingUser(existingUser);
582
622
 
583
623
  if (existingUser) {
584
- console.log('Existing user detected, showing data request modal');
585
- setShowDataRequestModal(true);
624
+ console.log('๐Ÿ‘ค Existing user detected, showing data request screen');
625
+ setStep('dataRequest');
586
626
  } else {
587
- console.log('New user, proceeding to platform connection');
627
+ console.log('๐Ÿ†• New user, proceeding to platform connection');
588
628
  // Safely set username from email prefix
589
629
  try {
590
630
  const emailPrefix = email.trim().split('@')[0];
@@ -675,7 +715,6 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
675
715
 
676
716
  const handleDataRequestAccept = useCallback(() => {
677
717
  console.log('Data request accepted for existing user');
678
- setShowDataRequestModal(false);
679
718
 
680
719
  // Complete onboarding for existing user
681
720
  onComplete('https://api2.onairos.uk', 'existing-session-token', {
@@ -688,28 +727,27 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
688
727
 
689
728
  const handleDataRequestDecline = useCallback(() => {
690
729
  console.log('Data request declined');
691
- setShowDataRequestModal(false);
692
730
  handleClose();
693
731
  }, [handleClose]);
694
732
 
695
733
  const canProceedToPin = useCallback(() => {
696
- // For testing, allow proceeding without any platforms connected
697
- if (debug || test) {
698
- console.log('๐Ÿงช Testing mode: Allowing proceed without platform connections');
734
+ // Test mode: Always allow proceeding (simulates platform connections)
735
+ if (isTestMode || testModeOptions.skipRealConnections) {
736
+ console.log('๐Ÿงช Test mode: Allowing proceed without real platform connections');
699
737
  return true;
700
738
  }
701
739
 
702
- // Check if at least one platform is toggled on
740
+ // Production: Check if at least one platform is connected
703
741
  const hasPlatformConnected = Object.values(platformToggles).some(value => value === true);
704
742
 
705
- // If auto mode is enabled and partner is not "couplebible", require inferenceData
743
+ // Auto mode validation
706
744
  if (auto && partner !== 'couplebible' && !inferenceData) {
707
745
  console.warn('Auto mode enabled but no inference data provided (and partner is not couplebible)');
708
746
  return false;
709
747
  }
710
748
 
711
749
  return hasPlatformConnected;
712
- }, [platformToggles, auto, partner, inferenceData, debug, test]);
750
+ }, [platformToggles, auto, partner, inferenceData, isTestMode, testModeOptions]);
713
751
 
714
752
  const handleProceed = () => {
715
753
  console.log('Proceeding to next step');
@@ -931,7 +969,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
931
969
 
932
970
  {/* Platform connection options */}
933
971
  <View style={styles.platformsContainer}>
934
- {platforms.map((platform) => (
972
+ {platformsToDisplay.map((platform) => (
935
973
  <TouchableOpacity
936
974
  key={platform.id}
937
975
  style={styles.platformItem}
@@ -964,7 +1002,71 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
964
1002
  )}
965
1003
  </TouchableOpacity>
966
1004
  ))}
1005
+
1006
+ {/* Show more/less platforms button */}
1007
+ {additionalPlatforms.length > 0 && (
1008
+ <TouchableOpacity
1009
+ style={styles.expandButton}
1010
+ onPress={() => setShowAllPlatforms(!showAllPlatforms)}
1011
+ >
1012
+ <Icon
1013
+ name={showAllPlatforms ? "expand_less" : "add"}
1014
+ size={24}
1015
+ color={COLORS.primary}
1016
+ />
1017
+ <Text style={styles.expandButtonText}>
1018
+ {showAllPlatforms
1019
+ ? "Show Less"
1020
+ : `${additionalPlatforms.length} More Connectors`
1021
+ }
1022
+ </Text>
1023
+ </TouchableOpacity>
1024
+ )}
967
1025
  </View>
1026
+
1027
+ {/* Test mode controls - Simple 2-flow system */}
1028
+ {showTestControls && (
1029
+ <View style={styles.testModeContainer}>
1030
+ <Text style={styles.testModeTitle}>๐Ÿงช Test Mode - 2 Main Flows</Text>
1031
+
1032
+ <TouchableOpacity
1033
+ style={styles.testExistingUserButton}
1034
+ onPress={() => {
1035
+ // Flow 1: Existing User
1036
+ setIsExistingUser(true);
1037
+ setStep('dataRequest');
1038
+ }}
1039
+ >
1040
+ <Icon name="person" size={20} color="#28a745" />
1041
+ <Text style={styles.testExistingUserButtonText}>
1042
+ Flow 1: Existing User (Email โ†’ Code โ†’ Data Request โ†’ Close)
1043
+ </Text>
1044
+ </TouchableOpacity>
1045
+
1046
+ <TouchableOpacity
1047
+ style={styles.testSkipToTrainingButton}
1048
+ onPress={() => {
1049
+ // Flow 2: New User - Skip to connect step
1050
+ setStep('connect');
1051
+ }}
1052
+ >
1053
+ <Icon name="person-add" size={20} color="#17a2b8" />
1054
+ <Text style={styles.testSkipToTrainingButtonText}>
1055
+ Flow 2: New User (Connect โ†’ PIN โ†’ Training)
1056
+ </Text>
1057
+ </TouchableOpacity>
1058
+
1059
+ <TouchableOpacity
1060
+ style={styles.testDataRequestButton}
1061
+ onPress={() => setStep('dataRequest')}
1062
+ >
1063
+ <Icon name="preview" size={20} color={COLORS.primary} />
1064
+ <Text style={styles.testDataRequestButtonText}>
1065
+ Preview Data Request Screen
1066
+ </Text>
1067
+ </TouchableOpacity>
1068
+ </View>
1069
+ )}
968
1070
  </ScrollView>
969
1071
 
970
1072
  <View style={styles.footer}>
@@ -1038,6 +1140,17 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
1038
1140
  onComplete={handleTrainingComplete}
1039
1141
  modelKey="onairosTrainingModel"
1040
1142
  username={username}
1143
+ test={isTestMode}
1144
+ />
1145
+ )}
1146
+
1147
+ {step === 'dataRequest' && (
1148
+ <DataRequestScreen
1149
+ onAccept={handleDataRequestAccept}
1150
+ onDecline={handleDataRequestDecline}
1151
+ requestData={requestData || {}}
1152
+ AppName={AppName}
1153
+ appIcon={appIcon}
1041
1154
  />
1042
1155
  )}
1043
1156
 
@@ -1062,16 +1175,7 @@ export const UniversalOnboarding: React.FC<UniversalOnboardingProps> = ({
1062
1175
  </View>
1063
1176
  </TouchableWithoutFeedback>
1064
1177
 
1065
- {/* Data Request Modal for existing users */}
1066
- {showDataRequestModal && requestData && (
1067
- <DataRequestModal
1068
- visible={showDataRequestModal}
1069
- onClose={handleDataRequestDecline}
1070
- onAccept={handleDataRequestAccept}
1071
- requestData={requestData}
1072
- AppName={AppName}
1073
- />
1074
- )}
1178
+
1075
1179
  </Modal>
1076
1180
  );
1077
1181
  };
@@ -1420,4 +1524,89 @@ const styles = StyleSheet.create({
1420
1524
  color: '#666',
1421
1525
  fontSize: 16,
1422
1526
  },
1527
+ // Expand button styles
1528
+ expandButton: {
1529
+ flexDirection: 'row',
1530
+ alignItems: 'center',
1531
+ justifyContent: 'center',
1532
+ padding: 12,
1533
+ backgroundColor: '#f8f9fa',
1534
+ borderRadius: 12,
1535
+ borderWidth: 1,
1536
+ borderColor: '#e9ecef',
1537
+ marginTop: 8,
1538
+ },
1539
+ expandButtonText: {
1540
+ fontSize: 14,
1541
+ fontWeight: '500',
1542
+ color: COLORS.primary,
1543
+ marginLeft: 8,
1544
+ },
1545
+ // Test mode styles
1546
+ testModeContainer: {
1547
+ marginTop: 16,
1548
+ paddingHorizontal: 16,
1549
+ backgroundColor: '#f8f9fa',
1550
+ borderRadius: 12,
1551
+ padding: 16,
1552
+ borderWidth: 1,
1553
+ borderColor: '#e9ecef',
1554
+ },
1555
+ testModeTitle: {
1556
+ fontSize: 16,
1557
+ fontWeight: '600',
1558
+ color: '#495057',
1559
+ marginBottom: 12,
1560
+ textAlign: 'center',
1561
+ },
1562
+ testDataRequestButton: {
1563
+ flexDirection: 'row',
1564
+ alignItems: 'center',
1565
+ justifyContent: 'center',
1566
+ padding: 12,
1567
+ backgroundColor: '#fff3cd',
1568
+ borderRadius: 12,
1569
+ borderWidth: 1,
1570
+ borderColor: '#ffeaa7',
1571
+ marginBottom: 8,
1572
+ },
1573
+ testDataRequestButtonText: {
1574
+ fontSize: 14,
1575
+ fontWeight: '500',
1576
+ color: '#856404',
1577
+ marginLeft: 8,
1578
+ },
1579
+ testExistingUserButton: {
1580
+ flexDirection: 'row',
1581
+ alignItems: 'center',
1582
+ justifyContent: 'center',
1583
+ padding: 12,
1584
+ backgroundColor: '#d4edda',
1585
+ borderRadius: 12,
1586
+ borderWidth: 1,
1587
+ borderColor: '#c3e6cb',
1588
+ marginBottom: 8,
1589
+ },
1590
+ testExistingUserButtonText: {
1591
+ fontSize: 14,
1592
+ fontWeight: '500',
1593
+ color: '#155724',
1594
+ marginLeft: 8,
1595
+ },
1596
+ testSkipToTrainingButton: {
1597
+ flexDirection: 'row',
1598
+ alignItems: 'center',
1599
+ justifyContent: 'center',
1600
+ padding: 12,
1601
+ backgroundColor: '#d1ecf1',
1602
+ borderRadius: 12,
1603
+ borderWidth: 1,
1604
+ borderColor: '#bee5eb',
1605
+ },
1606
+ testSkipToTrainingButtonText: {
1607
+ fontSize: 14,
1608
+ fontWeight: '500',
1609
+ color: '#0c5460',
1610
+ marginLeft: 8,
1611
+ },
1423
1612
  });
package/src/index.ts CHANGED
@@ -110,6 +110,7 @@ export { PlatformList } from './components/PlatformList';
110
110
  export { PinInput } from './components/PinInput';
111
111
  export { TrainingModal } from './components/TrainingModal';
112
112
  export { EmailVerificationModal } from './components/EmailVerificationModal';
113
+ export { DataRequestScreen } from './components/DataRequestScreen';
113
114
  export { Overlay } from './components/Overlay';
114
115
  export { UniversalOnboarding } from './components/UniversalOnboarding';
115
116
  export { OnairosButton } from './components/OnairosButton';
@@ -90,9 +90,14 @@ declare module '@onairos/react-native' {
90
90
  }
91
91
 
92
92
  export interface TrainingModalProps {
93
+ visible: boolean;
93
94
  progress: number;
94
95
  eta: string;
95
96
  onCancel: () => void;
97
+ onComplete?: () => void;
98
+ modelKey?: string;
99
+ username?: string;
100
+ test?: boolean; // Enable test mode for simulated training
96
101
  }
97
102
 
98
103
  export interface OAuthWebViewProps {
@@ -33,6 +33,16 @@ export interface OnairosButtonProps {
33
33
  darkMode?: boolean;
34
34
  }
35
35
 
36
+ export interface TestModeOptions {
37
+ // Simple 2-flow system
38
+ existingUser?: boolean; // Flow 1: Email โ†’ Code โ†’ Data Request โ†’ Close (return API URL)
39
+ newUser?: boolean; // Flow 2: Email โ†’ Code โ†’ Platform Connect โ†’ PIN โ†’ Training โ†’ Complete
40
+
41
+ // Optional tweaks
42
+ fastTraining?: boolean; // Speed up training simulation
43
+ skipRealConnections?: boolean; // Allow mock platform connections
44
+ }
45
+
36
46
  export interface UniversalOnboardingProps {
37
47
  visible: boolean;
38
48
  onClose: () => void;
@@ -48,7 +58,7 @@ export interface UniversalOnboardingProps {
48
58
  onComplete: (apiUrl: string, token: string, userData: any) => void;
49
59
  preferredPlatform?: string;
50
60
  debug?: boolean;
51
- test?: boolean;
61
+ test?: boolean | TestModeOptions; // Enhanced test mode with options
52
62
  embedd?: boolean;
53
63
  }
54
64
 
@@ -83,6 +93,7 @@ export interface TrainingModalProps {
83
93
  onComplete?: () => void;
84
94
  modelKey?: string;
85
95
  username?: string;
96
+ test?: boolean; // Enable test mode for simulated training
86
97
  }
87
98
 
88
99
  export interface OAuthWebViewProps {
package/src/types.ts CHANGED
@@ -10,6 +10,16 @@ export interface DataRequest {
10
10
  reward: string;
11
11
  }
12
12
 
13
+ export interface TestModeOptions {
14
+ // Simple 2-flow system
15
+ existingUser?: boolean; // Flow 1: Email โ†’ Code โ†’ Data Request โ†’ Close (return API URL)
16
+ newUser?: boolean; // Flow 2: Email โ†’ Code โ†’ Platform Connect โ†’ PIN โ†’ Training โ†’ Complete
17
+
18
+ // Optional tweaks
19
+ fastTraining?: boolean; // Speed up training simulation
20
+ skipRealConnections?: boolean; // Allow mock platform connections
21
+ }
22
+
13
23
  export interface UniversalOnboardingProps {
14
24
  visible: boolean;
15
25
  onClose: () => void;
@@ -29,7 +39,7 @@ export interface UniversalOnboardingProps {
29
39
  onComplete: (apiUrl: string, token: string, data: any) => void;
30
40
  embedd?: boolean;
31
41
  debug?: boolean;
32
- test?: boolean;
42
+ test?: boolean | TestModeOptions; // Enhanced test mode with options
33
43
  buttonType?: 'default' | 'pill';
34
44
  buttonForm?: 'signup' | 'login';
35
45
  preferredPlatform?: string;
@@ -120,6 +130,7 @@ export interface TrainingModalProps {
120
130
  onComplete?: () => void;
121
131
  modelKey?: string;
122
132
  username?: string;
133
+ test?: boolean; // Enable test mode for simulated training
123
134
  }
124
135
 
125
136
  export interface OAuthWebViewProps {