@onairosofficial/onairos-capacitor 0.1.0 → 0.1.2

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 (202) hide show
  1. package/CAPACITOR_QUICK_START.md +379 -0
  2. package/CONNECTORS.md +122 -0
  3. package/LICENSE +194 -10
  4. package/OnairosofficialOnairosCapacitor.podspec +13 -0
  5. package/Package.swift +26 -0
  6. package/README.md +176 -25
  7. package/dist/onairos.capacitor.esm.js +1 -0
  8. package/dist/onairos.capacitor.esm.turbopack.js +1 -0
  9. package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
  10. package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
  11. package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
  12. package/docs/CROSS_SDK_PARITY.md +239 -0
  13. package/docs/DATA_FREQUENCY.md +57 -0
  14. package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
  15. package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
  16. package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
  17. package/docs/PLATFORM_APIS.md +559 -0
  18. package/docs/RAW_MEMORIES_API.md +305 -0
  19. package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
  20. package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
  21. package/docs/oldFixes.md +216 -0
  22. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
  23. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
  24. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
  25. package/onairos.d.ts +656 -0
  26. package/package.json +188 -37
  27. package/src/OnairosReconnectButton.jsx +272 -0
  28. package/src/RSA.jsx +57 -0
  29. package/src/assets/NewLogo.png +0 -0
  30. package/src/assets/OnairosNewLogo.png +0 -0
  31. package/src/assets/chatgpt-icon.png +0 -0
  32. package/src/assets/fire-horse.png +0 -0
  33. package/src/assets/fire-horse.transparent.png +0 -0
  34. package/src/assets/latest-firehorse.png +0 -0
  35. package/src/assets/perplexity.png +0 -0
  36. package/src/assets/persona.png +0 -0
  37. package/src/assets/persona1.png +0 -0
  38. package/src/assets/persona2.png +0 -0
  39. package/src/assets/persona3.png +0 -0
  40. package/src/assets/persona4.png +0 -0
  41. package/src/assets/persona5.png +0 -0
  42. package/src/capacitorConnectorCatalog.js +38 -0
  43. package/src/capacitorOAuthConfig.js +52 -0
  44. package/src/chatgptHostedImport/index.js +303 -0
  45. package/src/components/AuthButtons.jsx +48 -0
  46. package/src/components/ConnectChatGPTModal.jsx +666 -0
  47. package/src/components/ConnectClaudeModal.jsx +610 -0
  48. package/src/components/ConnectGeminiModal.jsx +639 -0
  49. package/src/components/ConnectGrokModal.jsx +701 -0
  50. package/src/components/ConnectPerplexityModal.jsx +726 -0
  51. package/src/components/DataExplainerScreen.jsx +349 -0
  52. package/src/components/DataRequest.js +885 -0
  53. package/src/components/DataRequest.jsx +1055 -0
  54. package/src/components/EmailAuth.js +1871 -0
  55. package/src/components/EmailAuth.jsx +2062 -0
  56. package/src/components/ExtensionInstallPrompt.jsx +142 -0
  57. package/src/components/GoogleButton.js +133 -0
  58. package/src/components/LLMConnectorManager.jsx +201 -0
  59. package/src/components/LoadingPage.jsx +19 -0
  60. package/src/components/LoadingScreen.jsx +81 -0
  61. package/src/components/LunarBirthdate.jsx +96 -0
  62. package/src/components/LunarLoadingPage.jsx +251 -0
  63. package/src/components/Notification.jsx +21 -0
  64. package/src/components/OnairosAppButton.jsx +85 -0
  65. package/src/components/OnairosSSO.jsx +645 -0
  66. package/src/components/OnairosTrigger.jsx +61 -0
  67. package/src/components/PerplexityLogo.jsx +43 -0
  68. package/src/components/PinSetup.js +200 -0
  69. package/src/components/PinSetup.jsx +228 -0
  70. package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
  71. package/src/components/SdkErrorBoundary.jsx +36 -0
  72. package/src/components/SecuritySetup.js +81 -0
  73. package/src/components/SessionUserBar.jsx +83 -0
  74. package/src/components/SignUp.js +123 -0
  75. package/src/components/TestTelegramButton.js +53 -0
  76. package/src/components/TrainingComponent.jsx +200 -0
  77. package/src/components/TrainingScreen.jsx +897 -0
  78. package/src/components/UniversalOnboarding.js +306 -0
  79. package/src/components/UniversalOnboarding.jsx +4837 -0
  80. package/src/components/ValentineLoadingPage.jsx +502 -0
  81. package/src/components/ValentineModeSelector.jsx +162 -0
  82. package/src/components/WelcomeScreen.jsx +435 -0
  83. package/src/components/WrappedLoadingPage.jsx +205 -0
  84. package/src/components/connectors/ChatGPTConnector.js +348 -0
  85. package/src/components/connectors/ChatGPTConnector.jsx +348 -0
  86. package/src/components/connectors/ClaudeConnector.js +44 -0
  87. package/src/components/connectors/ClaudeConnector.jsx +44 -0
  88. package/src/components/connectors/GeminiConnector.js +170 -0
  89. package/src/components/connectors/GeminiConnector.jsx +170 -0
  90. package/src/components/connectors/GmailConnector.js +148 -0
  91. package/src/components/connectors/GmailConnector.jsx +148 -0
  92. package/src/components/connectors/GrokConnector.js +16 -0
  93. package/src/components/connectors/GrokConnector.jsx +16 -0
  94. package/src/components/connectors/HingeConnector.js +419 -0
  95. package/src/components/connectors/HingeConnector.jsx +419 -0
  96. package/src/components/connectors/InstagramDataConnector.js +726 -0
  97. package/src/components/connectors/InstagramDataConnector.jsx +726 -0
  98. package/src/components/connectors/LinkedInConnector.js +4 -0
  99. package/src/components/connectors/LinkedInConnector.jsx +296 -0
  100. package/src/components/connectors/PerplexityConnector.jsx +16 -0
  101. package/src/components/connectors/PinterestConnector.js +208 -0
  102. package/src/components/connectors/PinterestConnector.jsx +208 -0
  103. package/src/components/connectors/README.md +292 -0
  104. package/src/components/connectors/RedditConnector.js +229 -0
  105. package/src/components/connectors/RedditConnector.jsx +229 -0
  106. package/src/components/connectors/SephoraConnector.js +482 -0
  107. package/src/components/connectors/SephoraConnector.jsx +482 -0
  108. package/src/components/connectors/TikTokConnector.jsx +430 -0
  109. package/src/components/connectors/YoutubeConnector.js +361 -0
  110. package/src/components/connectors/YoutubeConnector.jsx +361 -0
  111. package/src/components/connectors/index.js +50 -0
  112. package/src/components/icons.jsx +46 -0
  113. package/src/components/icons.tsx +21 -0
  114. package/src/components/ui/PageLayout.jsx +1255 -0
  115. package/src/components/ui/PrimaryButton.jsx +162 -0
  116. package/src/components/ui/button.jsx +49 -0
  117. package/src/components/ui/card.jsx +61 -0
  118. package/src/components/ui/checkbox.jsx +33 -0
  119. package/src/components/ui/label.jsx +29 -0
  120. package/src/components/utils/UpdateConnections.js +45 -0
  121. package/src/components/utils/oauthHelper.js +97 -0
  122. package/src/config/api-config.js +138 -0
  123. package/src/deepLink.jsx +38 -0
  124. package/src/getPin.js +26 -0
  125. package/src/icons/Avatar.png +0 -0
  126. package/src/icons/Sentiment.png +0 -0
  127. package/src/icons/Trait.png +0 -0
  128. package/src/iframe/DataRequestPage.jsx +285 -0
  129. package/src/iframe/OnairosButtonIntegration.md +148 -0
  130. package/src/iframe/components/Box.jsx +56 -0
  131. package/src/iframe/components/IndividualConnection.jsx +88 -0
  132. package/src/iframe/dataRequestHandler.js +714 -0
  133. package/src/iframe/data_request_iframe.html +27 -0
  134. package/src/iframe/data_request_page.js +47 -0
  135. package/src/iframe/icons/Avatar.png +1 -0
  136. package/src/iframe/icons/Avatar2.png +1 -0
  137. package/src/iframe/icons/Sentiment.png +1 -0
  138. package/src/iframe/icons/Trait.png +1 -0
  139. package/src/iframe/icons/onairos_logo.png +0 -0
  140. package/src/iframe/utils/api.js +57 -0
  141. package/src/index.js +274 -0
  142. package/src/laravel/OnairosVue.vue +410 -0
  143. package/src/laravel/blade-helpers.js +320 -0
  144. package/src/laravel/vite-plugin.js +179 -0
  145. package/src/mobile/MobileDataRequestPage.jsx +233 -0
  146. package/src/mobile/components/MobileBox.jsx +71 -0
  147. package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
  148. package/src/mobile/shims/browser-apis.js +78 -0
  149. package/src/mobile/shims/lucide-shim.js +85 -0
  150. package/src/nativeConnectors.js +5 -0
  151. package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
  152. package/src/newUI/PlatformConnectorsStep.tsx +435 -0
  153. package/src/newUI/PrimaryButton.tsx +213 -0
  154. package/src/newUI/SignInStep.tsx +194 -0
  155. package/src/newUI/VerificationStep.tsx +133 -0
  156. package/src/newUI/WelcomeScreen.tsx +311 -0
  157. package/src/newUI/services/connectedAccountsService.js +129 -0
  158. package/src/onairos.capacitor.jsx +15 -0
  159. package/src/onairos.core.jsx +133 -0
  160. package/src/onairos.jsx +14 -0
  161. package/src/onairos.native.jsx +15 -0
  162. package/src/onairosButton.jsx +9000 -0
  163. package/src/overlay/CheckBox.jsx +114 -0
  164. package/src/overlay/IndividualConnection copy.js +86 -0
  165. package/src/overlay/IndividualConnection.js +191 -0
  166. package/src/overlay/IndividualConnectionNew.jsx +157 -0
  167. package/src/overlay/box.js +84 -0
  168. package/src/overlay/overlay.js +437 -0
  169. package/src/styles/onairos-scoped-preflight.css +97 -0
  170. package/src/styles/sdkCssRegistry.js +20 -0
  171. package/src/styles/styleLoaderInsertShadow.js +69 -0
  172. package/src/styles/tailwind.capacitor.css +395 -0
  173. package/src/styles/tailwind.css +395 -0
  174. package/src/theme/colors.js +40 -0
  175. package/src/utils/apiKeyValidation.js +341 -0
  176. package/src/utils/apiResponseLogger.js +316 -0
  177. package/src/utils/authHeaders.js +275 -0
  178. package/src/utils/biometrics.js +26 -0
  179. package/src/utils/bookmarkletUtils.js +28 -0
  180. package/src/utils/capacitorDetection.js +278 -0
  181. package/src/utils/capacitorLLMHelper.js +352 -0
  182. package/src/utils/capacitorPlugins.js +366 -0
  183. package/src/utils/crossDomainSSO.js +587 -0
  184. package/src/utils/deepLinking.js +27 -0
  185. package/src/utils/devLogger.js +46 -0
  186. package/src/utils/extensionDetection.js +418 -0
  187. package/src/utils/extractMemory.js +277 -0
  188. package/src/utils/framerBrandingOverrides.js +40 -0
  189. package/src/utils/googleWebClientId.js +55 -0
  190. package/src/utils/overlayHandler.js +224 -0
  191. package/src/utils/platformDisconnect.js +309 -0
  192. package/src/utils/pollTrainingStatus.js +200 -0
  193. package/src/utils/rawMemoriesAccess.js +211 -0
  194. package/src/utils/resolveBackendAppId.js +47 -0
  195. package/src/utils/responseFormatter.js +140 -0
  196. package/src/utils/sdkDebugStorage.js +113 -0
  197. package/src/utils/sdkInitialization.js +645 -0
  198. package/src/utils/sessionManager.js +1258 -0
  199. package/src/utils/startBackgroundTraining.js +100 -0
  200. package/src/utils/userDataFormatter.js +222 -0
  201. package/index.d.ts +0 -1
  202. package/index.js +0 -1
@@ -0,0 +1,410 @@
1
+ <template>
2
+ <div class="onairos-vue-wrapper">
3
+ <!-- Loading State -->
4
+ <div v-if="isLoading" class="onairos-loading">
5
+ <div class="onairos-spinner"></div>
6
+ <span>{{ loadingText }}</span>
7
+ </div>
8
+
9
+ <!-- Button State -->
10
+ <button
11
+ v-else
12
+ :class="buttonClasses"
13
+ :disabled="disabled"
14
+ @click="handleClick"
15
+ >
16
+ <slot name="icon" v-if="$slots.icon"></slot>
17
+ <span :class="textClasses">
18
+ <slot>{{ buttonText }}</slot>
19
+ </span>
20
+ </button>
21
+
22
+ <!-- Success Message -->
23
+ <div v-if="showSuccess" class="onairos-success">
24
+ ✅ {{ successMessage }}
25
+ </div>
26
+
27
+ <!-- Error Message -->
28
+ <div v-if="error" class="onairos-error">
29
+ ❌ {{ error }}
30
+ </div>
31
+ </div>
32
+ </template>
33
+
34
+ <script setup>
35
+ import { ref, computed, onMounted, defineEmits, defineProps } from 'vue';
36
+
37
+ // Props
38
+ const props = defineProps({
39
+ requestData: {
40
+ type: [Array, Object],
41
+ default: () => ['email', 'profile']
42
+ },
43
+ webpageName: {
44
+ type: String,
45
+ default: 'Laravel Vue App'
46
+ },
47
+ testMode: {
48
+ type: Boolean,
49
+ default: false
50
+ },
51
+ autoFetch: {
52
+ type: Boolean,
53
+ default: true
54
+ },
55
+ buttonType: {
56
+ type: String,
57
+ default: 'pill',
58
+ validator: (value) => ['pill', 'icon', 'rounded'].includes(value)
59
+ },
60
+ textColor: {
61
+ type: String,
62
+ default: 'white'
63
+ },
64
+ textLayout: {
65
+ type: String,
66
+ default: 'center',
67
+ validator: (value) => ['left', 'center', 'right'].includes(value)
68
+ },
69
+ disabled: {
70
+ type: Boolean,
71
+ default: false
72
+ },
73
+ customClass: {
74
+ type: String,
75
+ default: ''
76
+ },
77
+ loadingText: {
78
+ type: String,
79
+ default: 'Connecting...'
80
+ },
81
+ successMessage: {
82
+ type: String,
83
+ default: 'Successfully connected!'
84
+ },
85
+ size: {
86
+ type: String,
87
+ default: 'medium',
88
+ validator: (value) => ['small', 'medium', 'large'].includes(value)
89
+ }
90
+ });
91
+
92
+ // Emits
93
+ const emit = defineEmits(['complete', 'error', 'loading', 'click']);
94
+
95
+ // Reactive state
96
+ const isLoading = ref(false);
97
+ const showSuccess = ref(false);
98
+ const error = ref(null);
99
+
100
+ // Computed properties
101
+ const buttonText = computed(() => {
102
+ if (isLoading.value) return props.loadingText;
103
+ return 'Connect with Onairos';
104
+ });
105
+
106
+ const buttonClasses = computed(() => {
107
+ const baseClasses = ['onairos-vue-btn'];
108
+
109
+ // Button type
110
+ baseClasses.push(`onairos-btn-${props.buttonType}`);
111
+
112
+ // Size
113
+ baseClasses.push(`onairos-btn-${props.size}`);
114
+
115
+ // States
116
+ if (isLoading.value) baseClasses.push('onairos-btn-loading');
117
+ if (props.disabled) baseClasses.push('onairos-btn-disabled');
118
+
119
+ // Custom class
120
+ if (props.customClass) baseClasses.push(props.customClass);
121
+
122
+ return baseClasses.join(' ');
123
+ });
124
+
125
+ const textClasses = computed(() => {
126
+ return [
127
+ 'onairos-btn-text',
128
+ `onairos-text-${props.textLayout}`,
129
+ `onairos-text-color-${props.textColor}`
130
+ ].join(' ');
131
+ });
132
+
133
+ // Methods
134
+ async function handleClick() {
135
+ if (isLoading.value || props.disabled) return;
136
+
137
+ try {
138
+ isLoading.value = true;
139
+ error.value = null;
140
+ emit('loading', true);
141
+ emit('click');
142
+
143
+ // Simulate connection process
144
+ const result = await initializeOnairosConnection();
145
+
146
+ showSuccess.value = true;
147
+ setTimeout(() => {
148
+ showSuccess.value = false;
149
+ }, 3000);
150
+
151
+ emit('complete', result);
152
+ } catch (err) {
153
+ error.value = err.message || 'Connection failed';
154
+ emit('error', err);
155
+ } finally {
156
+ isLoading.value = false;
157
+ emit('loading', false);
158
+ }
159
+ }
160
+
161
+ async function initializeOnairosConnection() {
162
+ // Check if global Onairos is available
163
+ if (typeof window.createOnairosButton === 'function') {
164
+ return new Promise((resolve, reject) => {
165
+ // Use the global Blade helper
166
+ const config = {
167
+ requestData: props.requestData,
168
+ webpageName: props.webpageName,
169
+ testMode: props.testMode,
170
+ autoFetch: props.autoFetch,
171
+ onComplete: (result) => {
172
+ resolve(result);
173
+ },
174
+ onError: (err) => {
175
+ reject(err);
176
+ }
177
+ };
178
+
179
+ // Trigger the connection flow
180
+ const tempId = `temp-${Date.now()}`;
181
+ const tempElement = document.createElement('div');
182
+ tempElement.id = tempId;
183
+ tempElement.style.display = 'none';
184
+ document.body.appendChild(tempElement);
185
+
186
+ window.createOnairosButton(tempId, config);
187
+
188
+ // Trigger the button click programmatically
189
+ setTimeout(() => {
190
+ const btn = document.querySelector(`#${tempId}-btn`);
191
+ if (btn) btn.click();
192
+ }, 100);
193
+ });
194
+ } else {
195
+ // Fallback: dynamic import of OnairosButton
196
+ const { OnairosButton } = await import(/* @vite-ignore */ 'onairos');
197
+
198
+ return new Promise((resolve, reject) => {
199
+ // Create a temporary React component mount
200
+ const config = {
201
+ requestData: props.requestData,
202
+ webpageName: props.webpageName,
203
+ testMode: props.testMode,
204
+ autoFetch: props.autoFetch,
205
+ onComplete: resolve,
206
+ onError: reject
207
+ };
208
+
209
+ // This would need React DOM integration
210
+ // For now, we'll resolve with a mock result
211
+ setTimeout(() => {
212
+ resolve({
213
+ success: true,
214
+ data: 'Mock connection successful',
215
+ timestamp: new Date().toISOString()
216
+ });
217
+ }, 2000);
218
+ });
219
+ }
220
+ }
221
+
222
+ // Lifecycle
223
+ onMounted(() => {
224
+ // Initialize any needed global configurations
225
+ if (typeof window.initializeOnairosForBlade === 'function') {
226
+ window.initializeOnairosForBlade({
227
+ testMode: props.testMode,
228
+ autoDetectMobile: true,
229
+ globalStyles: false // Vue component will handle its own styles
230
+ });
231
+ }
232
+ });
233
+
234
+ defineExpose({
235
+ _setLoading: (v) => {
236
+ isLoading.value = v;
237
+ },
238
+ _setShowSuccess: (v) => {
239
+ showSuccess.value = v;
240
+ },
241
+ _setError: (msg) => {
242
+ error.value = msg;
243
+ },
244
+ });
245
+ </script>
246
+
247
+ <style scoped>
248
+ .onairos-vue-wrapper {
249
+ display: inline-block;
250
+ position: relative;
251
+ }
252
+
253
+ .onairos-vue-btn {
254
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
255
+ border: none;
256
+ color: white;
257
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
258
+ font-weight: 600;
259
+ cursor: pointer;
260
+ transition: all 0.3s ease;
261
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
262
+ outline: none;
263
+ }
264
+
265
+ .onairos-vue-btn:hover:not(.onairos-btn-disabled) {
266
+ transform: translateY(-2px);
267
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
268
+ }
269
+
270
+ .onairos-vue-btn:active:not(.onairos-btn-disabled) {
271
+ transform: translateY(0);
272
+ }
273
+
274
+ /* Button Types */
275
+ .onairos-btn-pill {
276
+ border-radius: 25px;
277
+ }
278
+
279
+ .onairos-btn-rounded {
280
+ border-radius: 8px;
281
+ }
282
+
283
+ .onairos-btn-icon {
284
+ border-radius: 50%;
285
+ width: 50px;
286
+ height: 50px;
287
+ padding: 0;
288
+ display: flex;
289
+ align-items: center;
290
+ justify-content: center;
291
+ }
292
+
293
+ /* Sizes */
294
+ .onairos-btn-small {
295
+ padding: 8px 16px;
296
+ font-size: 12px;
297
+ }
298
+
299
+ .onairos-btn-medium {
300
+ padding: 12px 24px;
301
+ font-size: 14px;
302
+ }
303
+
304
+ .onairos-btn-large {
305
+ padding: 16px 32px;
306
+ font-size: 16px;
307
+ }
308
+
309
+ .onairos-btn-icon.onairos-btn-small {
310
+ width: 35px;
311
+ height: 35px;
312
+ }
313
+
314
+ .onairos-btn-icon.onairos-btn-large {
315
+ width: 60px;
316
+ height: 60px;
317
+ }
318
+
319
+ /* Text Layout */
320
+ .onairos-text-left {
321
+ text-align: left;
322
+ }
323
+
324
+ .onairos-text-center {
325
+ text-align: center;
326
+ }
327
+
328
+ .onairos-text-right {
329
+ text-align: right;
330
+ }
331
+
332
+ /* States */
333
+ .onairos-btn-loading {
334
+ opacity: 0.7;
335
+ cursor: not-allowed;
336
+ }
337
+
338
+ .onairos-btn-disabled {
339
+ opacity: 0.5;
340
+ cursor: not-allowed;
341
+ }
342
+
343
+ /* Loading Spinner */
344
+ .onairos-loading {
345
+ display: flex;
346
+ align-items: center;
347
+ gap: 8px;
348
+ padding: 12px 24px;
349
+ background: #f8f9fa;
350
+ border-radius: 25px;
351
+ border: 1px solid #e9ecef;
352
+ }
353
+
354
+ .onairos-spinner {
355
+ width: 16px;
356
+ height: 16px;
357
+ border: 2px solid #e9ecef;
358
+ border-top: 2px solid #667eea;
359
+ border-radius: 50%;
360
+ animation: onairos-spin 1s linear infinite;
361
+ }
362
+
363
+ @keyframes onairos-spin {
364
+ 0% { transform: rotate(0deg); }
365
+ 100% { transform: rotate(360deg); }
366
+ }
367
+
368
+ /* Success/Error Messages */
369
+ .onairos-success,
370
+ .onairos-error {
371
+ margin-top: 8px;
372
+ padding: 8px 12px;
373
+ border-radius: 4px;
374
+ font-size: 12px;
375
+ font-weight: 500;
376
+ }
377
+
378
+ .onairos-success {
379
+ background: #d4edda;
380
+ color: #155724;
381
+ border: 1px solid #c3e6cb;
382
+ }
383
+
384
+ .onairos-error {
385
+ background: #f8d7da;
386
+ color: #721c24;
387
+ border: 1px solid #f5c6cb;
388
+ }
389
+
390
+ /* Mobile Responsive */
391
+ @media (max-width: 768px) {
392
+ .onairos-btn-medium {
393
+ width: 100%;
394
+ padding: 15px 20px;
395
+ font-size: 16px;
396
+ }
397
+
398
+ .onairos-btn-small {
399
+ width: 100%;
400
+ padding: 12px 16px;
401
+ font-size: 14px;
402
+ }
403
+
404
+ .onairos-btn-large {
405
+ width: 100%;
406
+ padding: 18px 24px;
407
+ font-size: 18px;
408
+ }
409
+ }
410
+ </style>
@@ -0,0 +1,320 @@
1
+ /**
2
+ * Onairos Laravel Blade Integration Helpers
3
+ *
4
+ * This file provides utilities for integrating Onairos components
5
+ * directly in PHP Blade templates without requiring React setup.
6
+ */
7
+
8
+ import { getApiBaseUrl } from '../config/api-config.js';
9
+
10
+ // Global Onairos instance for Blade templates
11
+ let onairosInstance = null;
12
+
13
+ /**
14
+ * Initialize Onairos for Blade template usage
15
+ * @param {Object} config - Global configuration
16
+ */
17
+ export function initializeOnairosForBlade(config = {}) {
18
+ const defaultConfig = {
19
+ apiKey: null,
20
+ baseUrl: getApiBaseUrl(),
21
+ testMode: false,
22
+ autoDetectMobile: true,
23
+ globalStyles: true
24
+ };
25
+
26
+ window.OnairosConfig = { ...defaultConfig, ...config };
27
+
28
+ // Inject global styles if enabled
29
+ if (window.OnairosConfig.globalStyles) {
30
+ injectOnairosStyles();
31
+ }
32
+
33
+ // Initialize mobile detection
34
+ window.OnairosUtils = {
35
+ isMobile: detectMobileDevice(),
36
+ detectMobile: detectMobileDevice
37
+ };
38
+
39
+ console.log('🔥 Onairos initialized for Laravel Blade templates');
40
+ }
41
+
42
+ /**
43
+ * Create an Onairos button element that can be used in Blade templates
44
+ * @param {string} targetElementId - ID of the element to mount to
45
+ * @param {Object} options - Onairos button options
46
+ */
47
+ export function createOnairosButton(targetElementId, options = {}) {
48
+ let element = document.getElementById(targetElementId);
49
+ if (!element) {
50
+ if (window.OnairosUtils && window.OnairosUtils.isMobile) {
51
+ const container = document.createElement('div');
52
+ container.id = targetElementId;
53
+ document.body.appendChild(container);
54
+ element = container;
55
+ } else {
56
+ console.error(`❌ Element with ID "${targetElementId}" not found`);
57
+ return;
58
+ }
59
+ }
60
+
61
+ const defaultOptions = {
62
+ requestData: ['email', 'profile'],
63
+ webpageName: 'Laravel App',
64
+ testMode: window.OnairosConfig?.testMode || false,
65
+ /** Forward global Blade config so React gate + authHeaders resolve the same key. */
66
+ apiKey: window.OnairosConfig?.apiKey || null,
67
+ autoFetch: true,
68
+ buttonType: 'pill',
69
+ textColor: 'black'
70
+ };
71
+
72
+ const config = { ...defaultOptions, ...options };
73
+
74
+ // Create button HTML
75
+ element.innerHTML = `
76
+ <div class="onairos-button-container">
77
+ <button
78
+ id="${targetElementId}-btn"
79
+ class="onairos-btn onairos-btn-${config.buttonType}"
80
+ data-onairos-config='${JSON.stringify(config)}'
81
+ >
82
+ <span class="onairos-btn-text" style="color: ${config.textColor}">
83
+ Connect with Onairos
84
+ </span>
85
+ <span class="onairos-btn-loading" style="display: none;">
86
+ Loading...
87
+ </span>
88
+ </button>
89
+ </div>
90
+ `;
91
+
92
+ // Add event listener
93
+ const button = document.getElementById(`${targetElementId}-btn`);
94
+ // Ensure both property and event listener are set for testing compatibility
95
+ button.onclick = () => handleOnairosButtonClick(config);
96
+ button.addEventListener('click', () => handleOnairosButtonClick(config));
97
+ }
98
+
99
+ /**
100
+ * Handle Onairos button click in Blade context
101
+ * @param {Object} config - Button configuration
102
+ */
103
+ function handleOnairosButtonClick(config) {
104
+ // For Blade templates, reuse the React overlay logic by mounting the React component dynamically
105
+ mountReactOverlay(config);
106
+ }
107
+
108
+ /**
109
+ * Handle mobile OAuth flow (redirect-based)
110
+ * @param {Object} config - Configuration
111
+ */
112
+ function handleMobileFlow(config) {
113
+ const authUrl = buildAuthUrl(config);
114
+ window.location.href = authUrl;
115
+ }
116
+
117
+ /**
118
+ * Handle desktop OAuth flow (popup-based)
119
+ * @param {Object} config - Configuration
120
+ */
121
+ function handleDesktopFlow(config) {
122
+ const authUrl = buildAuthUrl(config);
123
+
124
+ const popup = window.open(
125
+ authUrl,
126
+ 'onairosAuth',
127
+ 'width=450,height=700,scrollbars=yes,resizable=yes'
128
+ );
129
+
130
+ if (popup) {
131
+ const checkClosed = setInterval(() => {
132
+ if (popup.closed) {
133
+ clearInterval(checkClosed);
134
+ handleAuthComplete(config);
135
+ }
136
+ }, 1000);
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Build authentication URL for OAuth flow
142
+ * @param {Object} config - Configuration
143
+ * @returns {string} Auth URL
144
+ */
145
+ function buildAuthUrl(config) {
146
+ const baseUrl = window.OnairosConfig.baseUrl;
147
+ const params = new URLSearchParams({
148
+ webpageName: config.webpageName,
149
+ requestData: JSON.stringify(config.requestData),
150
+ testMode: config.testMode,
151
+ returnUrl: window.location.href
152
+ });
153
+
154
+ return `${baseUrl}/auth/laravel?${params.toString()}`;
155
+ }
156
+
157
+ /**
158
+ * Handle authentication completion
159
+ * @param {Object} config - Configuration
160
+ */
161
+ function handleAuthComplete(config) {
162
+ if (config.onComplete && typeof config.onComplete === 'function') {
163
+ config.onComplete({
164
+ success: true,
165
+ timestamp: new Date().toISOString()
166
+ });
167
+ }
168
+
169
+ // Trigger custom event for Laravel apps to listen to
170
+ const event = new CustomEvent('onairosAuthComplete', {
171
+ detail: { config, success: true }
172
+ });
173
+ window.dispatchEvent(event);
174
+ }
175
+
176
+ /**
177
+ * Detect if device is mobile
178
+ * @returns {boolean}
179
+ */
180
+ function detectMobileDevice() {
181
+ return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ||
182
+ (window.innerWidth <= 768);
183
+ }
184
+
185
+ /**
186
+ * Inject Onairos styles into the page
187
+ */
188
+ function injectOnairosStyles() {
189
+ if (document.getElementById('onairos-styles')) return;
190
+
191
+ const styles = `
192
+ <style id="onairos-styles">
193
+ .onairos-button-container {
194
+ display: inline-block;
195
+ margin: 10px 0;
196
+ }
197
+
198
+ .onairos-btn {
199
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
200
+ border: none;
201
+ border-radius: 25px;
202
+ padding: 12px 24px;
203
+ color: white;
204
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
205
+ font-size: 14px;
206
+ font-weight: 600;
207
+ cursor: pointer;
208
+ transition: all 0.3s ease;
209
+ box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
210
+ }
211
+
212
+ .onairos-btn:hover {
213
+ transform: translateY(-2px);
214
+ box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
215
+ }
216
+
217
+ .onairos-btn-pill {
218
+ border-radius: 25px;
219
+ }
220
+
221
+ .onairos-btn-icon {
222
+ border-radius: 50%;
223
+ width: 45px;
224
+ height: 45px;
225
+ padding: 0;
226
+ display: flex;
227
+ align-items: center;
228
+ justify-content: center;
229
+ }
230
+
231
+ .onairos-btn-loading {
232
+ color: #888;
233
+ }
234
+
235
+ @media (max-width: 768px) {
236
+ .onairos-btn {
237
+ width: 100%;
238
+ padding: 15px 20px;
239
+ font-size: 16px;
240
+ }
241
+ }
242
+ </style>
243
+ `;
244
+
245
+ document.head.insertAdjacentHTML('beforeend', styles);
246
+ }
247
+
248
+ /**
249
+ * Laravel Blade template directive helper
250
+ * Usage in Blade: @onairos(['requestData' => ['email'], 'webpageName' => 'My App'])
251
+ */
252
+ export function renderOnairosDirective(options = {}) {
253
+ const elementId = `onairos-${Math.random().toString(36).substr(2, 9)}`;
254
+
255
+ return `
256
+ <div id="${elementId}"></div>
257
+ <script>
258
+ document.addEventListener('DOMContentLoaded', function() {
259
+ if (window.createOnairosButton) {
260
+ window.createOnairosButton('${elementId}', ${JSON.stringify(options)});
261
+ }
262
+ });
263
+ </script>
264
+ `;
265
+ }
266
+
267
+ // Dynamically mount the React OnairosButton to reuse overlay flow
268
+ async function mountReactOverlay(config) {
269
+ try {
270
+ const containerId = `onairos-react-${Math.random().toString(36).substr(2, 9)}`;
271
+ const container = document.createElement('div');
272
+ container.id = containerId;
273
+ document.body.appendChild(container);
274
+
275
+ const React = (await import(/* @vite-ignore */ 'react')).default || (await import(/* @vite-ignore */ 'react'));
276
+ const ReactDOM = (await import(/* @vite-ignore */ 'react-dom')).default || (await import(/* @vite-ignore */ 'react-dom'));
277
+ const { OnairosButton } = await import(/* @vite-ignore */ '../onairosButton.jsx');
278
+
279
+ const onComplete = (result) => {
280
+ if (config.onComplete && typeof config.onComplete === 'function') {
281
+ config.onComplete(result);
282
+ }
283
+ setTimeout(() => {
284
+ if (container && container.parentNode) {
285
+ container.parentNode.removeChild(container);
286
+ }
287
+ }, 0);
288
+ };
289
+
290
+ const element = React.createElement(OnairosButton, {
291
+ requestData: config.requestData,
292
+ webpageName: config.webpageName,
293
+ apiKey: config.apiKey || window.OnairosConfig?.apiKey || null,
294
+ autoFetch: config.autoFetch,
295
+ testMode: config.testMode,
296
+ textColor: config.textColor || 'white',
297
+ buttonType: config.buttonType || 'pill',
298
+ onComplete
299
+ });
300
+
301
+ ReactDOM.render(element, container);
302
+
303
+ // Programmatically click the button to open overlay immediately
304
+ setTimeout(() => {
305
+ const btn = container.querySelector('button');
306
+ if (btn) {
307
+ btn.click();
308
+ }
309
+ }, 0);
310
+ } catch (error) {
311
+ console.error('Failed to mount React overlay for Laravel:', error);
312
+ }
313
+ }
314
+
315
+ // Expose functions globally for Blade template access
316
+ if (typeof window !== 'undefined') {
317
+ window.initializeOnairosForBlade = initializeOnairosForBlade;
318
+ window.createOnairosButton = createOnairosButton;
319
+ window.renderOnairosDirective = renderOnairosDirective;
320
+ }