@onairosofficial/onairos-capacitor 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/LICENSE +194 -10
  2. package/README.md +182 -25
  3. package/dist/onairos.capacitor.esm.js +1 -0
  4. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  5. package/onairos.d.ts +656 -0
  6. package/package.json +186 -38
  7. package/src/OnairosReconnectButton.jsx +272 -0
  8. package/src/RSA.jsx +57 -0
  9. package/src/assets/NewLogo.png +0 -0
  10. package/src/assets/OnairosNewLogo.png +0 -0
  11. package/src/assets/chatgpt-icon.png +0 -0
  12. package/src/assets/fire-horse.png +0 -0
  13. package/src/assets/fire-horse.transparent.png +0 -0
  14. package/src/assets/latest-firehorse.png +0 -0
  15. package/src/assets/perplexity.png +0 -0
  16. package/src/assets/persona.png +0 -0
  17. package/src/assets/persona1.png +0 -0
  18. package/src/assets/persona2.png +0 -0
  19. package/src/assets/persona3.png +0 -0
  20. package/src/assets/persona4.png +0 -0
  21. package/src/assets/persona5.png +0 -0
  22. package/src/capacitorConnectorCatalog.js +38 -0
  23. package/src/capacitorOAuthConfig.js +52 -0
  24. package/src/chatgptHostedImport/index.js +303 -0
  25. package/src/components/AuthButtons.jsx +48 -0
  26. package/src/components/ConnectChatGPTModal.jsx +666 -0
  27. package/src/components/ConnectClaudeModal.jsx +610 -0
  28. package/src/components/ConnectGeminiModal.jsx +639 -0
  29. package/src/components/ConnectGrokModal.jsx +701 -0
  30. package/src/components/ConnectPerplexityModal.jsx +726 -0
  31. package/src/components/DataExplainerScreen.jsx +349 -0
  32. package/src/components/DataRequest.js +885 -0
  33. package/src/components/DataRequest.jsx +1055 -0
  34. package/src/components/EmailAuth.js +1871 -0
  35. package/src/components/EmailAuth.jsx +2062 -0
  36. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  37. package/src/components/GoogleButton.js +133 -0
  38. package/src/components/LLMConnectorManager.jsx +201 -0
  39. package/src/components/LoadingPage.jsx +19 -0
  40. package/src/components/LoadingScreen.jsx +81 -0
  41. package/src/components/LunarBirthdate.jsx +96 -0
  42. package/src/components/LunarLoadingPage.jsx +251 -0
  43. package/src/components/Notification.jsx +21 -0
  44. package/src/components/OnairosAppButton.jsx +85 -0
  45. package/src/components/OnairosSSO.jsx +645 -0
  46. package/src/components/OnairosTrigger.jsx +61 -0
  47. package/src/components/PerplexityLogo.jsx +43 -0
  48. package/src/components/PinSetup.js +200 -0
  49. package/src/components/PinSetup.jsx +228 -0
  50. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  51. package/src/components/SdkErrorBoundary.jsx +36 -0
  52. package/src/components/SecuritySetup.js +81 -0
  53. package/src/components/SessionUserBar.jsx +83 -0
  54. package/src/components/SignUp.js +123 -0
  55. package/src/components/TestTelegramButton.js +53 -0
  56. package/src/components/TrainingComponent.jsx +200 -0
  57. package/src/components/TrainingScreen.jsx +897 -0
  58. package/src/components/UniversalOnboarding.js +306 -0
  59. package/src/components/UniversalOnboarding.jsx +4837 -0
  60. package/src/components/ValentineLoadingPage.jsx +502 -0
  61. package/src/components/ValentineModeSelector.jsx +162 -0
  62. package/src/components/WelcomeScreen.jsx +435 -0
  63. package/src/components/WrappedLoadingPage.jsx +205 -0
  64. package/src/components/connectors/ChatGPTConnector.js +348 -0
  65. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  66. package/src/components/connectors/ClaudeConnector.js +44 -0
  67. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  68. package/src/components/connectors/GeminiConnector.js +170 -0
  69. package/src/components/connectors/GeminiConnector.jsx +170 -0
  70. package/src/components/connectors/GmailConnector.js +148 -0
  71. package/src/components/connectors/GmailConnector.jsx +148 -0
  72. package/src/components/connectors/GrokConnector.js +16 -0
  73. package/src/components/connectors/GrokConnector.jsx +16 -0
  74. package/src/components/connectors/HingeConnector.js +419 -0
  75. package/src/components/connectors/HingeConnector.jsx +419 -0
  76. package/src/components/connectors/InstagramDataConnector.js +726 -0
  77. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  78. package/src/components/connectors/LinkedInConnector.js +4 -0
  79. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  80. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  81. package/src/components/connectors/PinterestConnector.js +208 -0
  82. package/src/components/connectors/PinterestConnector.jsx +208 -0
  83. package/src/components/connectors/README.md +292 -0
  84. package/src/components/connectors/RedditConnector.js +229 -0
  85. package/src/components/connectors/RedditConnector.jsx +229 -0
  86. package/src/components/connectors/SephoraConnector.js +482 -0
  87. package/src/components/connectors/SephoraConnector.jsx +482 -0
  88. package/src/components/connectors/TikTokConnector.jsx +430 -0
  89. package/src/components/connectors/YoutubeConnector.js +361 -0
  90. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  91. package/src/components/connectors/index.js +50 -0
  92. package/src/components/icons.jsx +46 -0
  93. package/src/components/icons.tsx +21 -0
  94. package/src/components/ui/PageLayout.jsx +1255 -0
  95. package/src/components/ui/PrimaryButton.jsx +162 -0
  96. package/src/components/ui/button.jsx +49 -0
  97. package/src/components/ui/card.jsx +61 -0
  98. package/src/components/ui/checkbox.jsx +33 -0
  99. package/src/components/ui/label.jsx +29 -0
  100. package/src/components/utils/UpdateConnections.js +45 -0
  101. package/src/components/utils/oauthHelper.js +97 -0
  102. package/src/config/api-config.js +138 -0
  103. package/src/deepLink.jsx +38 -0
  104. package/src/getPin.js +26 -0
  105. package/src/icons/Avatar.png +0 -0
  106. package/src/icons/Sentiment.png +0 -0
  107. package/src/icons/Trait.png +0 -0
  108. package/src/iframe/DataRequestPage.jsx +285 -0
  109. package/src/iframe/OnairosButtonIntegration.md +148 -0
  110. package/src/iframe/components/Box.jsx +56 -0
  111. package/src/iframe/components/IndividualConnection.jsx +88 -0
  112. package/src/iframe/dataRequestHandler.js +714 -0
  113. package/src/iframe/data_request_iframe.html +27 -0
  114. package/src/iframe/data_request_page.js +47 -0
  115. package/src/iframe/icons/Avatar.png +1 -0
  116. package/src/iframe/icons/Avatar2.png +1 -0
  117. package/src/iframe/icons/Sentiment.png +1 -0
  118. package/src/iframe/icons/Trait.png +1 -0
  119. package/src/iframe/icons/onairos_logo.png +0 -0
  120. package/src/iframe/utils/api.js +57 -0
  121. package/src/index.js +274 -0
  122. package/src/laravel/OnairosVue.vue +410 -0
  123. package/src/laravel/blade-helpers.js +320 -0
  124. package/src/laravel/vite-plugin.js +179 -0
  125. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  126. package/src/mobile/components/MobileBox.jsx +71 -0
  127. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  128. package/src/mobile/shims/browser-apis.js +78 -0
  129. package/src/mobile/shims/lucide-shim.js +85 -0
  130. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  131. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  132. package/src/newUI/PrimaryButton.tsx +213 -0
  133. package/src/newUI/SignInStep.tsx +194 -0
  134. package/src/newUI/VerificationStep.tsx +133 -0
  135. package/src/newUI/WelcomeScreen.tsx +311 -0
  136. package/src/newUI/services/connectedAccountsService.js +129 -0
  137. package/src/onairos.capacitor.jsx +16 -0
  138. package/src/onairos.core.jsx +133 -0
  139. package/src/onairos.jsx +14 -0
  140. package/src/onairos.native.jsx +15 -0
  141. package/src/onairosButton.jsx +9000 -0
  142. package/src/overlay/CheckBox.jsx +114 -0
  143. package/src/overlay/IndividualConnection copy.js +86 -0
  144. package/src/overlay/IndividualConnection.js +191 -0
  145. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  146. package/src/overlay/box.js +84 -0
  147. package/src/overlay/overlay.js +437 -0
  148. package/src/styles/onairos-scoped-preflight.css +97 -0
  149. package/src/styles/sdkCssRegistry.js +20 -0
  150. package/src/styles/styleLoaderInsertShadow.js +69 -0
  151. package/src/styles/tailwind.capacitor.css +395 -0
  152. package/src/styles/tailwind.css +395 -0
  153. package/src/theme/colors.js +40 -0
  154. package/src/utils/apiKeyValidation.js +341 -0
  155. package/src/utils/apiResponseLogger.js +316 -0
  156. package/src/utils/authHeaders.js +275 -0
  157. package/src/utils/biometrics.js +26 -0
  158. package/src/utils/bookmarkletUtils.js +28 -0
  159. package/src/utils/capacitorDetection.js +278 -0
  160. package/src/utils/capacitorLLMHelper.js +352 -0
  161. package/src/utils/capacitorPlugins.js +366 -0
  162. package/src/utils/crossDomainSSO.js +587 -0
  163. package/src/utils/deepLinking.js +27 -0
  164. package/src/utils/devLogger.js +46 -0
  165. package/src/utils/extensionDetection.js +418 -0
  166. package/src/utils/extractMemory.js +277 -0
  167. package/src/utils/framerBrandingOverrides.js +40 -0
  168. package/src/utils/googleWebClientId.js +55 -0
  169. package/src/utils/overlayHandler.js +224 -0
  170. package/src/utils/platformDisconnect.js +309 -0
  171. package/src/utils/pollTrainingStatus.js +200 -0
  172. package/src/utils/rawMemoriesAccess.js +211 -0
  173. package/src/utils/resolveBackendAppId.js +47 -0
  174. package/src/utils/responseFormatter.js +140 -0
  175. package/src/utils/sdkDebugStorage.js +113 -0
  176. package/src/utils/sdkInitialization.js +645 -0
  177. package/src/utils/sessionManager.js +1258 -0
  178. package/src/utils/startBackgroundTraining.js +100 -0
  179. package/src/utils/userDataFormatter.js +222 -0
  180. package/index.d.ts +0 -1
  181. package/index.js +0 -1
@@ -0,0 +1,142 @@
1
+ import React from 'react';
2
+ import { openExtensionInstallPage, LLM_URLS } from '../utils/extensionDetection';
3
+
4
+ /**
5
+ * Extension Installation Prompt Component
6
+ *
7
+ * Displays when a user tries to connect to an LLM but doesn't have
8
+ * the Onairos browser extension installed.
9
+ */
10
+ const ExtensionInstallPrompt = ({
11
+ open = false,
12
+ onClose,
13
+ platform = 'chatgpt',
14
+ onInstallClick = null
15
+ }) => {
16
+ if (!open) return null;
17
+
18
+ const platformNames = {
19
+ chatgpt: 'ChatGPT',
20
+ claude: 'Claude',
21
+ gemini: 'Gemini',
22
+ grok: 'Grok',
23
+ perplexity: 'Perplexity'
24
+ };
25
+
26
+ const platformName = platformNames[platform] || 'LLM';
27
+ const platformUrl = LLM_URLS[platform] || '#';
28
+
29
+ const handleInstallClick = () => {
30
+ if (onInstallClick) {
31
+ onInstallClick(platform);
32
+ } else {
33
+ openExtensionInstallPage(platform);
34
+ }
35
+ };
36
+
37
+ const handleDirectVisit = () => {
38
+ window.open(platformUrl, '_blank');
39
+ if (onClose) onClose();
40
+ };
41
+
42
+ return (
43
+ <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[2147483647]">
44
+ <div className="bg-white rounded-lg shadow-xl max-w-md w-full mx-4 max-h-full md:max-h-[90vh] overflow-hidden">
45
+ <div className="p-6">
46
+ {/* Header */}
47
+ <div className="flex items-center mb-4">
48
+ <div className="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-3">
49
+ <svg className="w-6 h-6 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
50
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
51
+ </svg>
52
+ </div>
53
+ <h2 className="text-xl font-bold text-gray-900">
54
+ Install Onairos Extension
55
+ </h2>
56
+ </div>
57
+
58
+ {/* Content */}
59
+ <div className="space-y-4 text-gray-700">
60
+ <p>
61
+ To connect with <strong>{platformName}</strong> and enable personalized AI interactions,
62
+ you need the Onairos browser extension installed.
63
+ </p>
64
+
65
+ <div className="bg-blue-50 border border-blue-200 rounded-lg p-4">
66
+ <h3 className="font-semibold text-blue-900 mb-2">🚀 What the extension does:</h3>
67
+ <ul className="list-disc ml-4 space-y-1 text-blue-800 text-sm">
68
+ <li>Detects when you're on {platformName} and other LLM sites</li>
69
+ <li>Enables secure data sharing with your consent</li>
70
+ <li>Personalizes AI responses based on your preferences</li>
71
+ <li>Works seamlessly in the background</li>
72
+ </ul>
73
+ </div>
74
+
75
+ <div className="bg-amber-50 border border-amber-200 rounded-lg p-4">
76
+ <h3 className="font-semibold text-amber-900 mb-2">⚡ Quick Setup:</h3>
77
+ <ol className="list-decimal ml-4 space-y-1 text-amber-800 text-sm">
78
+ <li>Click "Install Extension" below</li>
79
+ <li>Add the extension from Chrome Web Store</li>
80
+ <li>Return here and try connecting again</li>
81
+ </ol>
82
+ </div>
83
+
84
+ <p className="text-sm text-gray-600">
85
+ Don't want to install the extension? You can still visit{' '}
86
+ <a
87
+ href={platformUrl}
88
+ className="text-blue-600 hover:underline"
89
+ target="_blank"
90
+ rel="noopener noreferrer"
91
+ >
92
+ {platformUrl}
93
+ </a>
94
+ {' '}directly, but you won't get personalized AI features.
95
+ </p>
96
+ </div>
97
+
98
+ {/* Actions */}
99
+ <div className="flex flex-col space-y-3 mt-6">
100
+ <button
101
+ onClick={handleInstallClick}
102
+ className="w-full px-4 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 font-medium flex items-center justify-center"
103
+ >
104
+ <svg className="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
105
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
106
+ </svg>
107
+ Install Onairos Extension
108
+ </button>
109
+
110
+ <div className="flex space-x-3">
111
+ <button
112
+ onClick={handleDirectVisit}
113
+ className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 text-sm"
114
+ >
115
+ Visit {platformName} Anyway
116
+ </button>
117
+ <button
118
+ onClick={onClose}
119
+ className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 text-sm"
120
+ >
121
+ Cancel
122
+ </button>
123
+ </div>
124
+ </div>
125
+
126
+ {/* Footer */}
127
+ <div className="mt-4 pt-4 border-t border-gray-200">
128
+ <p className="text-xs text-gray-500 text-center">
129
+ The Onairos extension is free, secure, and respects your privacy.
130
+ <br />
131
+ <a href="https://onairos.uk/privacy" className="text-blue-600 hover:underline">
132
+ Learn more about our privacy policy
133
+ </a>
134
+ </p>
135
+ </div>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ );
140
+ };
141
+
142
+ export default ExtensionInstallPrompt;
@@ -0,0 +1,133 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import { miniApp, openLink } from '@telegram-apps/sdk';
3
+ import { getCapacitorBrowser, isCapacitorNativePlatform } from '../utils/capacitorPlugins.js';
4
+
5
+ export default function GoogleButton({ onLoginSuccess = () => {} }) {
6
+ const [error, setError] = useState(null);
7
+
8
+ const handleTelegramAuth = useCallback(async () => {
9
+ setError(null);
10
+
11
+ // 1. Check if running in Capacitor Native App (iOS/Android)
12
+ if (isCapacitorNativePlatform()) {
13
+ try {
14
+ console.log('Detected Native Platform, using Capacitor Browser');
15
+ let connectUrl = new URL('https://onairos.uk/othent-connect');
16
+ // Important: windowPresentationStyle: 'popover' is for iPad, 'fullscreen' is standard on iPhone
17
+ const CapBrowser = getCapacitorBrowser();
18
+ if (!CapBrowser?.open) throw new Error('Capacitor Browser plugin not available');
19
+ await CapBrowser.open({
20
+ url: connectUrl.toString(),
21
+ windowName: '_blank', // Force new window context
22
+ presentationStyle: 'fullscreen'
23
+ });
24
+ } catch (e) {
25
+ console.error('Capacitor Browser open failed', e);
26
+ setError('Failed to open browser: ' + e.message);
27
+ }
28
+ return;
29
+ }
30
+
31
+ // 2. Check if we're in a Telegram Web App environment
32
+ if (typeof window !== 'undefined' && window.Telegram?.WebApp) {
33
+ // ... existing Telegram logic ...
34
+ // Check SDK initialization
35
+ if (!miniApp.isInitialized) {
36
+ setError('Telegram Mini App not initialized');
37
+ return;
38
+ }
39
+
40
+ try {
41
+ // Safely get Telegram Mini App data
42
+ const telegramAppUrl = miniApp.initData || '';
43
+ const botUsername = 'OnairosMiniApp';
44
+
45
+ // Log debug information
46
+ console.log('Telegram App URL:', telegramAppUrl);
47
+ console.log('Bot Username:', botUsername);
48
+
49
+ // Construct URL with error handling
50
+ let connectUrl;
51
+ try {
52
+ connectUrl = new URL('https://onairos.uk/othent-connect');
53
+ connectUrl.searchParams.append('tgAppUrl', encodeURIComponent(telegramAppUrl));
54
+ connectUrl.searchParams.append('botUsername', botUsername);
55
+ } catch (urlError) {
56
+ setError('Error constructing URL: ' + urlError.message);
57
+ return;
58
+ }
59
+
60
+ // Register event listener before opening link
61
+ const handleAppActive = () => {
62
+ try {
63
+ const startParam = miniApp.initDataUnsafe?.start_param;
64
+ console.log('Start param received:', startParam);
65
+
66
+ if (startParam) {
67
+ const authData = JSON.parse(decodeURIComponent(startParam));
68
+ if (authData) {
69
+ onLoginSuccess(authData);
70
+ }
71
+ }
72
+ } catch (error) {
73
+ setError('Error processing auth data: ' + error.message);
74
+ } finally {
75
+ miniApp.removeEvent('active', handleAppActive);
76
+ }
77
+ };
78
+
79
+ miniApp.onEvent('active', handleAppActive);
80
+
81
+ // Open link with error handling
82
+ await openLink(connectUrl.toString(), {
83
+ tryInstantView: false,
84
+ });
85
+
86
+ } catch (error) {
87
+ setError('Auth flow failed: ' + error.message);
88
+ console.error('Full error:', error);
89
+ }
90
+ return;
91
+ }
92
+
93
+ // 3. Fallback for generic web / other environments
94
+ console.warn('Unknown environment, attempting default behavior');
95
+ // For now, let's try Capacitor Browser even if not explicitly "native" if the plugin is available,
96
+ // otherwise fallback to window.location
97
+ try {
98
+ const CapBrowser = getCapacitorBrowser();
99
+ if (!CapBrowser?.open) throw new Error('Capacitor Browser plugin not available');
100
+ await CapBrowser.open({ url: 'https://onairos.uk/othent-connect' });
101
+ } catch {
102
+ window.location.href = 'https://onairos.uk/othent-connect';
103
+ }
104
+
105
+ }, [onLoginSuccess]);
106
+
107
+ return (
108
+ <div className="flex flex-col items-center">
109
+ {error && (
110
+ <div className="text-red-500 text-sm mb-2 px-4 py-2 bg-red-50 rounded">
111
+ {error}
112
+ </div>
113
+ )}
114
+ <button
115
+ onClick={handleTelegramAuth}
116
+ className="flex items-center justify-center px-4 py-2 border border-gray-300 rounded-full shadow-sm bg-white hover:bg-gray-50 relative"
117
+ type="button"
118
+ >
119
+ <svg
120
+ viewBox="0 0 24 24"
121
+ className="w-5 h-5 mr-2"
122
+ fill="#4285F4"
123
+ >
124
+ <path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/>
125
+ <path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/>
126
+ <path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/>
127
+ <path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
128
+ </svg>
129
+ <span className="text-gray-700">Continue with Google</span>
130
+ </button>
131
+ </div>
132
+ );
133
+ }
@@ -0,0 +1,201 @@
1
+ import React, { useState, useCallback } from 'react';
2
+ import { openLLMWithExtensionCheck, detectOnairosExtension, getUserInfoFromStorage } from '../utils/extensionDetection';
3
+ import ExtensionInstallPrompt from './ExtensionInstallPrompt';
4
+
5
+ /**
6
+ * LLM Connector Manager Component
7
+ *
8
+ * Manages the connection flow for LLM platforms (ChatGPT, Claude, Gemini, Grok).
9
+ * Handles extension detection and shows appropriate prompts.
10
+ */
11
+ const LLMConnectorManager = ({
12
+ children,
13
+ onConnectionChange = null,
14
+ username = null
15
+ }) => {
16
+ const [showInstallPrompt, setShowInstallPrompt] = useState(false);
17
+ const [currentPlatform, setCurrentPlatform] = useState(null);
18
+ const [isConnecting, setIsConnecting] = useState(false);
19
+
20
+ /**
21
+ * Handle LLM connection attempt
22
+ * @param {string} platform - LLM platform name
23
+ * @param {Function} onSuccess - Callback for successful connection
24
+ * @param {Function} onError - Callback for connection error
25
+ */
26
+ const handleLLMConnect = useCallback(async (platform, onSuccess = null, onError = null) => {
27
+ if (isConnecting) {
28
+ return;
29
+ }
30
+
31
+ setIsConnecting(true);
32
+ setCurrentPlatform(platform);
33
+
34
+ try {
35
+ // Prepare user information for the browser extension
36
+ // First try to get comprehensive user info from localStorage
37
+ const storedUserInfo = getUserInfoFromStorage();
38
+
39
+ const userInfo = {
40
+ // Use stored info as primary source, fallback to props
41
+ username: storedUserInfo.username || username,
42
+ userId: storedUserInfo.userId || storedUserInfo.username || username,
43
+ email: storedUserInfo.email,
44
+ sessionToken: storedUserInfo.sessionToken,
45
+ jwtToken: storedUserInfo.jwtToken,
46
+
47
+ // User metadata
48
+ isNewUser: storedUserInfo.isNewUser,
49
+ verified: storedUserInfo.verified,
50
+ onboardingComplete: storedUserInfo.onboardingComplete,
51
+ pinCreated: storedUserInfo.pinCreated,
52
+
53
+ // Account details
54
+ accountInfo: storedUserInfo.accountInfo,
55
+ connectedAccounts: storedUserInfo.connectedAccounts,
56
+
57
+ // Add additional context
58
+ source: 'onairos_npm_connector',
59
+ connectorVersion: '3.4.2', // Updated version from package.json
60
+ timestamp: new Date().toISOString(),
61
+ platform: platform
62
+ };
63
+
64
+ // Use the extension detection utility with user info
65
+ const success = await openLLMWithExtensionCheck(
66
+ platform,
67
+ (missingPlatform) => {
68
+ // Extension is missing - show install prompt
69
+ setCurrentPlatform(missingPlatform);
70
+ setShowInstallPrompt(true);
71
+ },
72
+ userInfo
73
+ );
74
+
75
+ if (success) {
76
+ // Simulate connection after a short delay (like the original ChatGPT connector)
77
+ setTimeout(() => {
78
+ if (onConnectionChange) {
79
+ onConnectionChange(platform, true);
80
+ }
81
+ if (onSuccess) {
82
+ onSuccess(platform);
83
+ }
84
+ setIsConnecting(false);
85
+ }, 1000);
86
+ } else {
87
+ // Failed to open (popup blocked or other error)
88
+ setIsConnecting(false);
89
+
90
+ if (onError) {
91
+ onError(platform, 'Failed to open LLM platform');
92
+ }
93
+ }
94
+ } catch (error) {
95
+ console.error('Error connecting to ' + platform + ':', error);
96
+ setIsConnecting(false);
97
+
98
+ if (onError) {
99
+ onError(platform, error.message);
100
+ }
101
+ }
102
+ }, [isConnecting, onConnectionChange]);
103
+
104
+ /**
105
+ * Handle disconnection from LLM platform
106
+ * @param {string} platform - LLM platform name
107
+ */
108
+ const handleLLMDisconnect = useCallback((platform) => {
109
+ if (onConnectionChange) {
110
+ onConnectionChange(platform, false);
111
+ }
112
+ }, [onConnectionChange]);
113
+
114
+ /**
115
+ * Close the extension install prompt
116
+ */
117
+ const handleCloseInstallPrompt = useCallback(() => {
118
+ setShowInstallPrompt(false);
119
+ setCurrentPlatform(null);
120
+ setIsConnecting(false);
121
+ }, []);
122
+
123
+ /**
124
+ * Handle extension installation click
125
+ */
126
+ const handleExtensionInstall = useCallback((platform) => {
127
+ // The ExtensionInstallPrompt component will handle opening the store
128
+ // We'll close the prompt after a delay to let the user install
129
+ setTimeout(() => {
130
+ setShowInstallPrompt(false);
131
+ setCurrentPlatform(null);
132
+ setIsConnecting(false);
133
+ }, 1000);
134
+ }, []);
135
+
136
+ /**
137
+ * Check extension status
138
+ * @returns {Promise<boolean>} True if extension is available
139
+ */
140
+ const checkExtensionStatus = useCallback(async () => {
141
+ return await detectOnairosExtension();
142
+ }, []);
143
+
144
+ // Provide context to children components
145
+ const contextValue = {
146
+ // Connection methods
147
+ connectToLLM: handleLLMConnect,
148
+ disconnectFromLLM: handleLLMDisconnect,
149
+
150
+ // State
151
+ isConnecting,
152
+ currentPlatform,
153
+
154
+ // Utilities
155
+ checkExtensionStatus,
156
+
157
+ // User info
158
+ username
159
+ };
160
+
161
+ return (
162
+ <div data-llm-manager="true">
163
+ {/* Render children with context */}
164
+ {React.Children.map(children, child => {
165
+ if (React.isValidElement(child)) {
166
+ return React.cloneElement(child, {
167
+ ...child.props,
168
+ llmConnectorManager: contextValue
169
+ });
170
+ }
171
+ return child;
172
+ })}
173
+
174
+ {/* Extension Install Prompt */}
175
+ <ExtensionInstallPrompt
176
+ open={showInstallPrompt}
177
+ platform={currentPlatform}
178
+ onClose={handleCloseInstallPrompt}
179
+ onInstallClick={handleExtensionInstall}
180
+ />
181
+ </div>
182
+ );
183
+ };
184
+
185
+ /**
186
+ * Hook for using LLM Connector Manager context
187
+ * @param {Object} props - Component props that might contain llmConnectorManager
188
+ * @returns {Object} LLM connector manager context
189
+ */
190
+ export const useLLMConnectorManager = (props) => {
191
+ return props.llmConnectorManager || {
192
+ connectToLLM: () => console.warn('LLM Connector Manager not available'),
193
+ disconnectFromLLM: () => console.warn('LLM Connector Manager not available'),
194
+ isConnecting: false,
195
+ currentPlatform: null,
196
+ checkExtensionStatus: () => Promise.resolve(false),
197
+ username: null
198
+ };
199
+ };
200
+
201
+ export default LLMConnectorManager;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * LoadingPage Component
5
+ * Displays a loading spinner with optional theme
6
+ */
7
+ const LoadingPage = ({ theme = 'black' }) => {
8
+ const spinnerColor = theme === 'black' ? 'border-black' : 'border-white';
9
+ const textColor = theme === 'black' ? 'text-black' : 'text-white';
10
+
11
+ return (
12
+ <div className="flex flex-col items-center justify-center min-h-screen">
13
+ <div className={`animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 ${spinnerColor} mb-4`}></div>
14
+ <p className={`text-sm font-medium ${textColor}`}>Loading...</p>
15
+ </div>
16
+ );
17
+ };
18
+
19
+ export default LoadingPage;
@@ -0,0 +1,81 @@
1
+ import React, { useState, useEffect } from "react";
2
+ import Lottie from 'lottie-react';
3
+ import rainAnim from '../../public/rain-anim.json';
4
+
5
+ export default function LoadingScreen({ onComplete, appName }) {
6
+ const [progress, setProgress] = useState(0);
7
+
8
+ useEffect(() => {
9
+ // Smooth progress animation
10
+ const progressInterval = setInterval(() => {
11
+ setProgress((prev) => {
12
+ if (prev >= 95) return prev; // Cap at 95% until onComplete is called
13
+ return prev + 1;
14
+ });
15
+ }, 150); // Smooth increment every 150ms
16
+
17
+ // Auto-complete after reasonable time (fallback)
18
+ const completeTimer = setTimeout(() => {
19
+ setProgress(100);
20
+ setTimeout(() => {
21
+ onComplete?.();
22
+ }, 500);
23
+ }, 15000); // 15 seconds fallback
24
+
25
+ return () => {
26
+ clearInterval(progressInterval);
27
+ clearTimeout(completeTimer);
28
+ };
29
+ }, [onComplete]);
30
+
31
+ return (
32
+ <div className="h-full w-full flex flex-col items-center justify-center px-6 py-4">
33
+ {/* Fixed layout container to match TrainingScreen */}
34
+ <div
35
+ className="w-full max-w-md flex flex-col items-center"
36
+ style={{
37
+ minHeight: 520,
38
+ justifyContent: 'center',
39
+ gap: 18
40
+ }}
41
+ >
42
+ {/* Header */}
43
+ <div className="text-center" style={{ minHeight: 56, display: 'flex', alignItems: 'center' }}>
44
+ <h2
45
+ className="text-xl md:text-2xl font-semibold text-gray-900"
46
+ style={{
47
+ fontFamily: 'IBM Plex Sans, system-ui, sans-serif',
48
+ lineHeight: 1.2,
49
+ maxWidth: 360
50
+ }}
51
+ >
52
+ Finalizing...
53
+ </h2>
54
+ </div>
55
+
56
+ {/* Lottie Animation */}
57
+ <div className="w-full flex items-center justify-center" style={{ height: 300 }}>
58
+ <div className="relative" style={{ width: 300, height: 300 }}>
59
+ <Lottie
60
+ animationData={rainAnim}
61
+ loop={true}
62
+ autoplay={true}
63
+ className="absolute inset-0"
64
+ style={{ width: '100%', height: '100%' }}
65
+ />
66
+ </div>
67
+ </div>
68
+
69
+ {/* Black and White Loading Bar */}
70
+ <div className="w-full" style={{ maxWidth: 360 }}>
71
+ <div className="relative w-full h-1.5 bg-gray-200 rounded-full overflow-hidden">
72
+ <div
73
+ className="absolute top-0 left-0 h-full bg-gray-900 rounded-full transition-all duration-300 ease-out"
74
+ style={{ width: `${progress}%` }}
75
+ ></div>
76
+ </div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ );
81
+ }
@@ -0,0 +1,96 @@
1
+ import React, { useMemo, useState } from 'react';
2
+ import PageLayout from './ui/PageLayout.jsx';
3
+
4
+ /**
5
+ * Lunar-only birthdate capture screen.
6
+ * - Stores a YYYY-MM-DD date string (ISO date, no time) upstream.
7
+ * - We intentionally do NOT compute the Chinese zodiac client-side here; the Lunar backend can do it
8
+ * correctly with Lunar New Year boundary rules.
9
+ */
10
+ export default function LunarBirthdate({
11
+ initialBirthdate = '',
12
+ onComplete,
13
+ onBack,
14
+ appName = 'Onairos Lunar',
15
+ }) {
16
+ const [birthdate, setBirthdate] = useState(initialBirthdate || '');
17
+ const [error, setError] = useState(null);
18
+
19
+ const isValid = useMemo(() => {
20
+ if (!birthdate) return false;
21
+ // HTML date input returns "YYYY-MM-DD" when filled.
22
+ return /^\d{4}-\d{2}-\d{2}$/.test(birthdate);
23
+ }, [birthdate]);
24
+
25
+ return (
26
+ <PageLayout
27
+ title="Birthdate"
28
+ subtitle={`Used to personalize your Lunar (zodiac) slides for ${appName}.`}
29
+ icon="🧧"
30
+ showHeader={false}
31
+ centerContent={true}
32
+ className="w-full h-full"
33
+ contentClassName="w-full"
34
+ >
35
+ <div className="w-full max-w-md">
36
+ <div className="w-full rounded-2xl border border-amber-200 bg-white shadow-sm p-4">
37
+ <label className="w-full block overflow-hidden">
38
+ <div className="text-xs font-semibold text-amber-900/80 mb-2" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
39
+ Your birthdate
40
+ </div>
41
+ <input
42
+ type="date"
43
+ value={birthdate}
44
+ onChange={(e) => {
45
+ setBirthdate(e.target.value);
46
+ setError(null);
47
+ }}
48
+ className="w-full border border-amber-200 rounded-xl px-4 py-3 text-gray-900 focus:outline-none focus:ring-2 focus:ring-amber-500/20"
49
+ style={{ backgroundColor: '#FFFBEB', maxWidth: '100%', boxSizing: 'border-box' }}
50
+ />
51
+ </label>
52
+
53
+ {error && (
54
+ <div className="text-xs mt-3 text-red-600" style={{ fontFamily: 'Inter, system-ui, sans-serif' }}>
55
+ {error}
56
+ </div>
57
+ )}
58
+
59
+ <button
60
+ type="button"
61
+ disabled={!isValid}
62
+ onClick={() => {
63
+ if (!isValid) {
64
+ setError('Please enter a valid birthdate.');
65
+ return;
66
+ }
67
+ onComplete?.({ birthdate });
68
+ }}
69
+ className={`w-full mt-4 rounded-xl px-4 py-3 font-semibold transition ${
70
+ isValid ? 'text-white hover:bg-amber-700' : 'bg-amber-100 text-amber-900/50 cursor-not-allowed'
71
+ }`}
72
+ style={{
73
+ fontFamily: 'Inter, system-ui, sans-serif',
74
+ backgroundColor: isValid ? '#B45309' : undefined,
75
+ }}
76
+ >
77
+ Continue
78
+ </button>
79
+
80
+ {typeof onBack === 'function' && (
81
+ <button
82
+ type="button"
83
+ onClick={onBack}
84
+ className="w-full mt-2 rounded-xl px-4 py-3 font-medium bg-white border border-amber-200 text-amber-900 hover:bg-amber-50 transition"
85
+ style={{ fontFamily: 'Inter, system-ui, sans-serif' }}
86
+ >
87
+ Back
88
+ </button>
89
+ )}
90
+ </div>
91
+ </div>
92
+ </PageLayout>
93
+ );
94
+ }
95
+
96
+