@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.
- package/CAPACITOR_QUICK_START.md +379 -0
- package/CONNECTORS.md +122 -0
- package/LICENSE +194 -10
- package/OnairosofficialOnairosCapacitor.podspec +13 -0
- package/Package.swift +26 -0
- package/README.md +176 -25
- package/dist/onairos.capacitor.esm.js +1 -0
- package/dist/onairos.capacitor.esm.turbopack.js +1 -0
- package/docs/CAPACITOR_INTEGRATION_GUIDE.md +159 -0
- package/docs/CAPACITOR_MOCK_APP_TESTING.md +213 -0
- package/docs/CAPACITOR_SDK_FIXES_SUMMARY.md +65 -0
- package/docs/CROSS_SDK_PARITY.md +239 -0
- package/docs/DATA_FREQUENCY.md +57 -0
- package/docs/DEVELOPER_SDK_CHANGES.md +532 -0
- package/docs/INCIDENT_ENABLETRAINING_PIN_WEB_8.1.9.md +82 -0
- package/docs/ONAIROS_BUTTON_PROPS.md +152 -0
- package/docs/PLATFORM_APIS.md +559 -0
- package/docs/RAW_MEMORIES_API.md +305 -0
- package/docs/RAW_MEMORIES_SDK_UPDATE.md +54 -0
- package/docs/SDK_PARITY_ROLLUP_2026_04_24_to_05_02.md +96 -0
- package/docs/oldFixes.md +216 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +993 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosNetflixNativePlugin.swift +33 -0
- package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +1082 -0
- package/onairos.d.ts +656 -0
- package/package.json +188 -37
- package/src/OnairosReconnectButton.jsx +272 -0
- package/src/RSA.jsx +57 -0
- package/src/assets/NewLogo.png +0 -0
- package/src/assets/OnairosNewLogo.png +0 -0
- package/src/assets/chatgpt-icon.png +0 -0
- package/src/assets/fire-horse.png +0 -0
- package/src/assets/fire-horse.transparent.png +0 -0
- package/src/assets/latest-firehorse.png +0 -0
- package/src/assets/perplexity.png +0 -0
- package/src/assets/persona.png +0 -0
- package/src/assets/persona1.png +0 -0
- package/src/assets/persona2.png +0 -0
- package/src/assets/persona3.png +0 -0
- package/src/assets/persona4.png +0 -0
- package/src/assets/persona5.png +0 -0
- package/src/capacitorConnectorCatalog.js +38 -0
- package/src/capacitorOAuthConfig.js +52 -0
- package/src/chatgptHostedImport/index.js +303 -0
- package/src/components/AuthButtons.jsx +48 -0
- package/src/components/ConnectChatGPTModal.jsx +666 -0
- package/src/components/ConnectClaudeModal.jsx +610 -0
- package/src/components/ConnectGeminiModal.jsx +639 -0
- package/src/components/ConnectGrokModal.jsx +701 -0
- package/src/components/ConnectPerplexityModal.jsx +726 -0
- package/src/components/DataExplainerScreen.jsx +349 -0
- package/src/components/DataRequest.js +885 -0
- package/src/components/DataRequest.jsx +1055 -0
- package/src/components/EmailAuth.js +1871 -0
- package/src/components/EmailAuth.jsx +2062 -0
- package/src/components/ExtensionInstallPrompt.jsx +142 -0
- package/src/components/GoogleButton.js +133 -0
- package/src/components/LLMConnectorManager.jsx +201 -0
- package/src/components/LoadingPage.jsx +19 -0
- package/src/components/LoadingScreen.jsx +81 -0
- package/src/components/LunarBirthdate.jsx +96 -0
- package/src/components/LunarLoadingPage.jsx +251 -0
- package/src/components/Notification.jsx +21 -0
- package/src/components/OnairosAppButton.jsx +85 -0
- package/src/components/OnairosSSO.jsx +645 -0
- package/src/components/OnairosTrigger.jsx +61 -0
- package/src/components/PerplexityLogo.jsx +43 -0
- package/src/components/PinSetup.js +200 -0
- package/src/components/PinSetup.jsx +228 -0
- package/src/components/SDK_PIN_INTEGRATION_REQUIRED_CHANGES.md +526 -0
- package/src/components/SdkErrorBoundary.jsx +36 -0
- package/src/components/SecuritySetup.js +81 -0
- package/src/components/SessionUserBar.jsx +83 -0
- package/src/components/SignUp.js +123 -0
- package/src/components/TestTelegramButton.js +53 -0
- package/src/components/TrainingComponent.jsx +200 -0
- package/src/components/TrainingScreen.jsx +897 -0
- package/src/components/UniversalOnboarding.js +306 -0
- package/src/components/UniversalOnboarding.jsx +4837 -0
- package/src/components/ValentineLoadingPage.jsx +502 -0
- package/src/components/ValentineModeSelector.jsx +162 -0
- package/src/components/WelcomeScreen.jsx +435 -0
- package/src/components/WrappedLoadingPage.jsx +205 -0
- package/src/components/connectors/ChatGPTConnector.js +348 -0
- package/src/components/connectors/ChatGPTConnector.jsx +348 -0
- package/src/components/connectors/ClaudeConnector.js +44 -0
- package/src/components/connectors/ClaudeConnector.jsx +44 -0
- package/src/components/connectors/GeminiConnector.js +170 -0
- package/src/components/connectors/GeminiConnector.jsx +170 -0
- package/src/components/connectors/GmailConnector.js +148 -0
- package/src/components/connectors/GmailConnector.jsx +148 -0
- package/src/components/connectors/GrokConnector.js +16 -0
- package/src/components/connectors/GrokConnector.jsx +16 -0
- package/src/components/connectors/HingeConnector.js +419 -0
- package/src/components/connectors/HingeConnector.jsx +419 -0
- package/src/components/connectors/InstagramDataConnector.js +726 -0
- package/src/components/connectors/InstagramDataConnector.jsx +726 -0
- package/src/components/connectors/LinkedInConnector.js +4 -0
- package/src/components/connectors/LinkedInConnector.jsx +296 -0
- package/src/components/connectors/PerplexityConnector.jsx +16 -0
- package/src/components/connectors/PinterestConnector.js +208 -0
- package/src/components/connectors/PinterestConnector.jsx +208 -0
- package/src/components/connectors/README.md +292 -0
- package/src/components/connectors/RedditConnector.js +229 -0
- package/src/components/connectors/RedditConnector.jsx +229 -0
- package/src/components/connectors/SephoraConnector.js +482 -0
- package/src/components/connectors/SephoraConnector.jsx +482 -0
- package/src/components/connectors/TikTokConnector.jsx +430 -0
- package/src/components/connectors/YoutubeConnector.js +361 -0
- package/src/components/connectors/YoutubeConnector.jsx +361 -0
- package/src/components/connectors/index.js +50 -0
- package/src/components/icons.jsx +46 -0
- package/src/components/icons.tsx +21 -0
- package/src/components/ui/PageLayout.jsx +1255 -0
- package/src/components/ui/PrimaryButton.jsx +162 -0
- package/src/components/ui/button.jsx +49 -0
- package/src/components/ui/card.jsx +61 -0
- package/src/components/ui/checkbox.jsx +33 -0
- package/src/components/ui/label.jsx +29 -0
- package/src/components/utils/UpdateConnections.js +45 -0
- package/src/components/utils/oauthHelper.js +97 -0
- package/src/config/api-config.js +138 -0
- package/src/deepLink.jsx +38 -0
- package/src/getPin.js +26 -0
- package/src/icons/Avatar.png +0 -0
- package/src/icons/Sentiment.png +0 -0
- package/src/icons/Trait.png +0 -0
- package/src/iframe/DataRequestPage.jsx +285 -0
- package/src/iframe/OnairosButtonIntegration.md +148 -0
- package/src/iframe/components/Box.jsx +56 -0
- package/src/iframe/components/IndividualConnection.jsx +88 -0
- package/src/iframe/dataRequestHandler.js +714 -0
- package/src/iframe/data_request_iframe.html +27 -0
- package/src/iframe/data_request_page.js +47 -0
- package/src/iframe/icons/Avatar.png +1 -0
- package/src/iframe/icons/Avatar2.png +1 -0
- package/src/iframe/icons/Sentiment.png +1 -0
- package/src/iframe/icons/Trait.png +1 -0
- package/src/iframe/icons/onairos_logo.png +0 -0
- package/src/iframe/utils/api.js +57 -0
- package/src/index.js +274 -0
- package/src/laravel/OnairosVue.vue +410 -0
- package/src/laravel/blade-helpers.js +320 -0
- package/src/laravel/vite-plugin.js +179 -0
- package/src/mobile/MobileDataRequestPage.jsx +233 -0
- package/src/mobile/components/MobileBox.jsx +71 -0
- package/src/mobile/components/MobileIndividualConnection.jsx +51 -0
- package/src/mobile/shims/browser-apis.js +78 -0
- package/src/mobile/shims/lucide-shim.js +85 -0
- package/src/nativeConnectors.js +5 -0
- package/src/newUI/EMAIL_VERIFICATION_API_SCHEMA.md +268 -0
- package/src/newUI/PlatformConnectorsStep.tsx +435 -0
- package/src/newUI/PrimaryButton.tsx +213 -0
- package/src/newUI/SignInStep.tsx +194 -0
- package/src/newUI/VerificationStep.tsx +133 -0
- package/src/newUI/WelcomeScreen.tsx +311 -0
- package/src/newUI/services/connectedAccountsService.js +129 -0
- package/src/onairos.capacitor.jsx +15 -0
- package/src/onairos.core.jsx +133 -0
- package/src/onairos.jsx +14 -0
- package/src/onairos.native.jsx +15 -0
- package/src/onairosButton.jsx +9000 -0
- package/src/overlay/CheckBox.jsx +114 -0
- package/src/overlay/IndividualConnection copy.js +86 -0
- package/src/overlay/IndividualConnection.js +191 -0
- package/src/overlay/IndividualConnectionNew.jsx +157 -0
- package/src/overlay/box.js +84 -0
- package/src/overlay/overlay.js +437 -0
- package/src/styles/onairos-scoped-preflight.css +97 -0
- package/src/styles/sdkCssRegistry.js +20 -0
- package/src/styles/styleLoaderInsertShadow.js +69 -0
- package/src/styles/tailwind.capacitor.css +395 -0
- package/src/styles/tailwind.css +395 -0
- package/src/theme/colors.js +40 -0
- package/src/utils/apiKeyValidation.js +341 -0
- package/src/utils/apiResponseLogger.js +316 -0
- package/src/utils/authHeaders.js +275 -0
- package/src/utils/biometrics.js +26 -0
- package/src/utils/bookmarkletUtils.js +28 -0
- package/src/utils/capacitorDetection.js +278 -0
- package/src/utils/capacitorLLMHelper.js +352 -0
- package/src/utils/capacitorPlugins.js +366 -0
- package/src/utils/crossDomainSSO.js +587 -0
- package/src/utils/deepLinking.js +27 -0
- package/src/utils/devLogger.js +46 -0
- package/src/utils/extensionDetection.js +418 -0
- package/src/utils/extractMemory.js +277 -0
- package/src/utils/framerBrandingOverrides.js +40 -0
- package/src/utils/googleWebClientId.js +55 -0
- package/src/utils/overlayHandler.js +224 -0
- package/src/utils/platformDisconnect.js +309 -0
- package/src/utils/pollTrainingStatus.js +200 -0
- package/src/utils/rawMemoriesAccess.js +211 -0
- package/src/utils/resolveBackendAppId.js +47 -0
- package/src/utils/responseFormatter.js +140 -0
- package/src/utils/sdkDebugStorage.js +113 -0
- package/src/utils/sdkInitialization.js +645 -0
- package/src/utils/sessionManager.js +1258 -0
- package/src/utils/startBackgroundTraining.js +100 -0
- package/src/utils/userDataFormatter.js +222 -0
- package/index.d.ts +0 -1
- package/index.js +0 -1
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
/* eslint-disable no-script-url */
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import * as ReactDOM from 'react-dom';
|
|
4
|
+
import { getApiBaseUrl } from '../config/api-config.js';
|
|
5
|
+
import { getApiKey, getUserToken } from '../utils/authHeaders.js';
|
|
6
|
+
|
|
7
|
+
const CLAUDE_BOOKMARKLET_HREF = [
|
|
8
|
+
"javascript:(async function(){try{",
|
|
9
|
+
"var host=(location.hostname||'').toLowerCase();",
|
|
10
|
+
"if(!(host==='claude.ai'||host.endsWith('.claude.ai'))){alert('Please open Claude first.');return;}",
|
|
11
|
+
"var APP_ORIGIN='__ONAIROS_ORIGIN__';",
|
|
12
|
+
"var APP_URL='__ONAIROS_URL__';",
|
|
13
|
+
"var API_URL='__API_URL__';",
|
|
14
|
+
"var token='__ONAIROS_TOKEN__';",
|
|
15
|
+
"var notifyApp=function(msg){try{if(window.opener&&!window.opener.closed){window.opener.postMessage(msg,APP_ORIGIN);return true;}}catch(_){}try{var p=window.open(APP_URL,'_blank');if(!p)return false;var n=0;var iv=setInterval(function(){try{if(!p||p.closed||n++>30){clearInterval(iv);return;}p.postMessage(msg,APP_ORIGIN);}catch(_){}},500);return true;}catch(_){return false;}};",
|
|
16
|
+
"var syncOrigin=(function(){try{return new URL(API_URL).origin}catch(_){return API_URL}})();var syncWin=null;var openSync=function(){try{syncWin=window.open(API_URL+'/claude-sync?receive=1','_dpSyncWin','width=480,height=560,toolbar=0,location=0,scrollbars=1,resizable=1');return syncWin}catch(_){return null}};openSync();",
|
|
17
|
+
"var hintEl=null;",
|
|
18
|
+
"var setHint=function(m){try{if(!hintEl){hintEl=document.createElement('div');hintEl.setAttribute('data-claude-export-status','1');hintEl.style.cssText='position:fixed;top:16px;right:16px;z-index:2147483647;max-width:280px;padding:8px 12px;border-radius:999px;background:rgba(15,23,42,.88);color:#fff;font:12px/1.2 -apple-system,BlinkMacSystemFont,Segoe UI,system-ui,sans-serif;box-shadow:0 10px 30px rgba(0,0,0,.22);pointer-events:none;opacity:.96;letter-spacing:.01em';document.body.appendChild(hintEl);}hintEl.textContent=String(m||'Preparing export...');}catch(_){}};",
|
|
19
|
+
"var clearHint=function(){try{if(hintEl&&hintEl.parentNode)hintEl.parentNode.removeChild(hintEl);}catch(_){}hintEl=null;};",
|
|
20
|
+
"var wait=function(ms){return new Promise(function(resolve){setTimeout(resolve,ms||0)});};",
|
|
21
|
+
"var uuidRe=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;",
|
|
22
|
+
"var clean=function(t){return String(t||'').replace(/\\s+$/,'').replace(/^\\s+/,'').replace(/\\n{3,}/g,'\\n\\n').trim();};",
|
|
23
|
+
"var normalizeTime=function(v){if(!v)return null;var n=Number(v);if(Number.isFinite(n))return new Date((n>9999999999?n:n*1000)).toISOString();var d=Date.parse(v);return Number.isFinite(d)?new Date(d).toISOString():null;};",
|
|
24
|
+
"var findOrgId=async function(){var orgId=null;try{var keys=Object.keys(localStorage);for(var i=0;i<keys.length&&!orgId;i++){if(!/org/i.test(keys[i])||typeof localStorage[keys[i]]!=='string')continue;try{var parsed=JSON.parse(localStorage[keys[i]]);var vals=[parsed&&parsed.uuid,parsed&&parsed.organization_uuid,parsed&&parsed.id];for(var vi=0;vi<vals.length;vi++){if(typeof vals[vi]==='string'&&uuidRe.test(vals[vi])){orgId=vals[vi];break;}}}catch(_){}}}catch(_){}if(orgId)return orgId;var res=await fetch('/api/organizations',{credentials:'include',headers:{accept:'application/json'}});if(!res.ok)return null;var data=await res.json();var arr=Array.isArray(data)?data:((data&&data.organizations)||[]);for(var oi=0;oi<arr.length;oi++){var o=arr[oi]||{};var cands=[o.uuid,o.organization_uuid,o.id];for(var ci=0;ci<cands.length;ci++){if(typeof cands[ci]==='string'&&uuidRe.test(cands[ci]))return cands[ci];}}return null;};",
|
|
25
|
+
"var extractMessages=function(raw){var candidates=[];if(raw&&Array.isArray(raw.messages))candidates.push(raw.messages);if(raw&&Array.isArray(raw.chat_messages))candidates.push(raw.chat_messages);if(raw&&Array.isArray(raw.data))candidates.push(raw.data);if(raw&&Array.isArray(raw.items))candidates.push(raw.items);if(raw&&raw.messages&&Array.isArray(raw.messages.items))candidates.push(raw.messages.items);if(raw&&raw.messages&&Array.isArray(raw.messages.data))candidates.push(raw.messages.data);if(raw&&Array.isArray(raw.tree))candidates.push(raw.tree);if(raw&&raw.conversation&&Array.isArray(raw.conversation.messages))candidates.push(raw.conversation.messages);var visited=[];var scan=function(node){if(!node||typeof node!=='object'||visited.indexOf(node)!==-1)return;visited.push(node);if(Array.isArray(node)){if(node.length&&typeof node[0]==='object'){var hasText=node.some(function(m){return typeof(m&&m.text)==='string'||Array.isArray(m&&m.content)||typeof(m&&m.content)==='string';});var hasRole=node.some(function(m){return (m&&m.role)||(m&&m.author)||(m&&m.sender)||(m&&m.type);});if(hasText&&hasRole)candidates.push(node);}for(var ai=0;ai<node.length;ai++)scan(node[ai]);return;}for(var k in node)scan(node[k]);};scan(raw);var unique=[];var seen={};for(var ui=0;ui<candidates.length;ui++){var arr=candidates[ui];if(!Array.isArray(arr))continue;var key='len:'+arr.length+'|keys:'+(arr[0]?Object.keys(arr[0]).sort().join(','):'none');if(!seen[key]){seen[key]=1;unique.push(arr);}}unique.sort(function(a,b){return (b.length||0)-(a.length||0);});var pick=unique[0]||[];var out=[];for(var mi=0;mi<pick.length;mi++){var m=pick[mi]||{};var role=(m.author&&m.author.role)||m.sender||m.role||(m.type==='user'?'user':'assistant');var rawRole=String(role||'').toLowerCase();role=rawRole.indexOf('user')!==-1||rawRole.indexOf('human')!==-1?'user':'assistant';var ts=m.updated_at||m.created_at||m.timestamp||m.create_time||m.time||null;var text='';if(typeof m.text==='string')text+=m.text;if(Array.isArray(m.content)){for(var pi=0;pi<m.content.length;pi++){var part=m.content[pi];if(typeof part==='string'){text+=part;continue;}if(part&&part.type==='text'&&typeof part.text==='string')text+=part.text;if(part&&part.text&&typeof part.text==='string')text+=part.text;if(part&&part.type==='tool_result'&&typeof part.result==='string')text+='\\n\\n[tool]\\n'+part.result+'\\n';}}if(!text&&typeof m.content==='string')text=m.content;if(!text&&Array.isArray(m.attachments))text+='\\n[attachments:'+m.attachments.length+']';text=clean(text);if(text)out.push({role:role,content:text,timestamp:normalizeTime(ts),meta:m});}return out;};",
|
|
26
|
+
"setHint('Finding your Claude workspace...');var orgId=await findOrgId();if(!orgId){clearHint();alert('Could not find your Claude organization. Make sure you are logged in, then retry.');return;}",
|
|
27
|
+
"setHint('Fetching conversations...');var listRes=await fetch('/api/organizations/'+encodeURIComponent(orgId)+'/chat_conversations?limit=50',{credentials:'include',cache:'no-store',headers:{accept:'application/json'}});if(!listRes.ok){clearHint();alert('Could not fetch Claude conversations.');return;}var listData=await listRes.json();var items=Array.isArray(listData)?listData:((listData&&listData.chat_conversations)||(listData&&listData.items)||[]);var meta=items.map(function(x){return {id:x.uuid||x.id,title:x.name||x.title||'Claude Conversation',created:x.created_at||x.create_time||x.createdAt,updated:x.updated_at||x.update_time||x.updatedAt,model:x.model||x.model_slug||null};}).filter(function(x){return x.id;});meta.sort(function(a,b){return new Date(b.updated||0)-new Date(a.updated||0);});meta=meta.slice(0,10);",
|
|
28
|
+
"var convos=[];for(var i=0;i<meta.length;i++){try{setHint((i+1)+' / '+meta.length+' conversations');var detailUrl='/api/organizations/'+encodeURIComponent(orgId)+'/chat_conversations/'+encodeURIComponent(meta[i].id)+'?tree=True&rendering_mode=messages&render_all_tools=true';var detail=await fetch(detailUrl,{credentials:'include',cache:'no-store',referrerPolicy:'strict-origin-when-cross-origin',headers:{accept:'application/json'}});if(!detail.ok)continue;var raw=await detail.json();var messages=extractMessages(raw);convos.push({id:meta[i].id,title:meta[i].title,created:meta[i].created,model:meta[i].model,url:location.origin+'/chat/'+meta[i].id,messages:messages});if(i<meta.length-1)await wait(200);}catch(_){}}",
|
|
29
|
+
"if(!convos.length){clearHint();alert('No Claude conversations found. Open an existing Claude chat, then retry.');return;}",
|
|
30
|
+
"setHint('Uploading to Onairos...');var data={type:'claude-export-data',exportId:String(Date.now())+'_'+Math.random().toString(36).slice(2),convos:convos,token:token,platform:'web-claude'};try{notifyApp(data)}catch(_){}if(!syncWin||syncWin.closed)openSync();var sends=0;var sendIv=setInterval(function(){try{if(!syncWin||syncWin.closed||sends++>40){clearInterval(sendIv);return;}syncWin.postMessage({type:'onairos-llm-sync-payload',platform:'web-claude',payload:data},syncOrigin);}catch(_){}},500);setHint('Sync in progress - see popup');setTimeout(clearHint,2500);",
|
|
31
|
+
"}catch(e){try{clearHint()}catch(_){}alert('Export error: '+(e&&e.message?e.message:e));}})();",
|
|
32
|
+
].join('');
|
|
33
|
+
|
|
34
|
+
const PENDING_IMPORT_KEY = '_pending_claude_import';
|
|
35
|
+
const SYNC_SUCCESS_KEY = 'onairos_claude_sync_success';
|
|
36
|
+
|
|
37
|
+
export const getOnairosClaudeBookmarklet = () => CLAUDE_BOOKMARKLET_HREF;
|
|
38
|
+
|
|
39
|
+
const notifyLlmSyncPopup = (popupId, status, detail = {}) => {
|
|
40
|
+
if (!popupId) return;
|
|
41
|
+
try {
|
|
42
|
+
const popup = window.open('', '_dpSyncWin');
|
|
43
|
+
if (popup && !popup.closed) {
|
|
44
|
+
popup.postMessage({
|
|
45
|
+
type: 'onairos-llm-sync-status',
|
|
46
|
+
popupId,
|
|
47
|
+
status,
|
|
48
|
+
...detail,
|
|
49
|
+
}, '*');
|
|
50
|
+
}
|
|
51
|
+
} catch (_) {}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (typeof window !== 'undefined') {
|
|
55
|
+
window.addEventListener('message', (event) => {
|
|
56
|
+
if (event.data?.type !== 'claude-export-data') return;
|
|
57
|
+
try {
|
|
58
|
+
localStorage.setItem(PENDING_IMPORT_KEY, JSON.stringify({
|
|
59
|
+
convos: event.data.convos,
|
|
60
|
+
exportId: event.data.exportId,
|
|
61
|
+
receivedAt: Date.now(),
|
|
62
|
+
}));
|
|
63
|
+
if (event.source) {
|
|
64
|
+
event.source.postMessage({ type: 'claude-export-ack' }, event.origin);
|
|
65
|
+
}
|
|
66
|
+
} catch (_) {}
|
|
67
|
+
if (!window.__onairosClaudeModalOpen) {
|
|
68
|
+
uploadClaudeExportData(event.data.convos, event.data.exportId).then((stored) => {
|
|
69
|
+
const statusMessage = {
|
|
70
|
+
platform: 'Claude',
|
|
71
|
+
count: Array.isArray(event.data.convos) ? event.data.convos.length : 0,
|
|
72
|
+
message: stored ? '' : 'Could not store Claude data. Check the Onairos app tab.',
|
|
73
|
+
};
|
|
74
|
+
notifyLlmSyncPopup(event.data.popupId, stored ? 'success' : 'error', statusMessage);
|
|
75
|
+
try {
|
|
76
|
+
event.source?.postMessage({
|
|
77
|
+
type: 'onairos-llm-sync-status',
|
|
78
|
+
popupId: event.data.popupId,
|
|
79
|
+
status: stored ? 'success' : 'error',
|
|
80
|
+
...statusMessage,
|
|
81
|
+
}, event.origin);
|
|
82
|
+
} catch (_) {}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const encodePayload = (value) => {
|
|
89
|
+
const json = JSON.stringify(value || {});
|
|
90
|
+
try {
|
|
91
|
+
return btoa(unescape(encodeURIComponent(json)));
|
|
92
|
+
} catch (_) {
|
|
93
|
+
return btoa(json);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const generateDataHash = async (value) => {
|
|
98
|
+
try {
|
|
99
|
+
const encoded = new TextEncoder().encode(JSON.stringify(value || {}));
|
|
100
|
+
const digest = await crypto.subtle.digest('SHA-256', encoded);
|
|
101
|
+
return `sha256-${Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, '0')).join('')}`;
|
|
102
|
+
} catch (_) {
|
|
103
|
+
return `sha256-${Date.now()}`;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const getClaudeIdentifierForAccountCheck = () => {
|
|
108
|
+
try {
|
|
109
|
+
const user = JSON.parse(localStorage.getItem('onairosUser') || '{}');
|
|
110
|
+
return user.email || user.userEmail || user.identifier || user.userName || user.username || localStorage.getItem('onairos_user_email') || null;
|
|
111
|
+
} catch (_) {
|
|
112
|
+
return localStorage.getItem('onairos_user_email') || null;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const markClaudeConnectedLocally = () => {
|
|
117
|
+
try {
|
|
118
|
+
const storedConnections = JSON.parse(localStorage.getItem('onairos_connected_accounts') || '{}');
|
|
119
|
+
storedConnections.Claude = true;
|
|
120
|
+
localStorage.setItem('onairos_connected_accounts', JSON.stringify(storedConnections));
|
|
121
|
+
} catch (_) {}
|
|
122
|
+
try {
|
|
123
|
+
const connectedAccounts = JSON.parse(localStorage.getItem('connectedAccounts') || '[]');
|
|
124
|
+
if (!connectedAccounts.includes('Claude')) {
|
|
125
|
+
connectedAccounts.push('Claude');
|
|
126
|
+
localStorage.setItem('connectedAccounts', JSON.stringify(connectedAccounts));
|
|
127
|
+
}
|
|
128
|
+
} catch (_) {}
|
|
129
|
+
try {
|
|
130
|
+
const userData = JSON.parse(localStorage.getItem('onairosUser') || '{}');
|
|
131
|
+
if (!Array.isArray(userData.connectedAccounts)) userData.connectedAccounts = [];
|
|
132
|
+
if (!userData.connectedAccounts.includes('Claude')) {
|
|
133
|
+
userData.connectedAccounts.push('Claude');
|
|
134
|
+
localStorage.setItem('onairosUser', JSON.stringify(userData));
|
|
135
|
+
}
|
|
136
|
+
} catch (_) {}
|
|
137
|
+
try {
|
|
138
|
+
window.dispatchEvent(new CustomEvent('connected-accounts-updated', { detail: { platform: 'Claude' } }));
|
|
139
|
+
} catch (_) {}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const seenClaudeExportIds = new Set();
|
|
143
|
+
|
|
144
|
+
const uploadClaudeExportData = async (convos, exportId = '') => {
|
|
145
|
+
const dedupeKey = exportId || JSON.stringify({ count: convos?.length || 0, first: convos?.[0]?.id || '' });
|
|
146
|
+
if (seenClaudeExportIds.has(dedupeKey)) return false;
|
|
147
|
+
seenClaudeExportIds.add(dedupeKey);
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
const userData = JSON.parse(localStorage.getItem('onairosUser') || '{}');
|
|
151
|
+
const jwt = getUserToken() || userData.token || userData.jwt || localStorage.getItem('onairos_user_token') || '';
|
|
152
|
+
if (!jwt) {
|
|
153
|
+
console.warn('[Claude] Cannot upload: missing Onairos user token');
|
|
154
|
+
try {
|
|
155
|
+
localStorage.setItem(PENDING_IMPORT_KEY, JSON.stringify({ convos, exportId, receivedAt: Date.now(), reason: 'missing-token' }));
|
|
156
|
+
} catch (_) {}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
const baseUrl = (typeof window !== 'undefined' && window.onairosBaseUrl) || getApiBaseUrl();
|
|
160
|
+
const apiKey = getApiKey();
|
|
161
|
+
const identifier = getClaudeIdentifierForAccountCheck();
|
|
162
|
+
const conversationData = { platform: 'claude', conversations: convos, timestamp: new Date().toISOString() };
|
|
163
|
+
const resp = await fetch(`${baseUrl}/llm-data/store`, {
|
|
164
|
+
method: 'POST',
|
|
165
|
+
headers: {
|
|
166
|
+
'Content-Type': 'application/json',
|
|
167
|
+
Authorization: `Bearer ${jwt}`,
|
|
168
|
+
...(apiKey ? { 'x-api-key': apiKey } : {}),
|
|
169
|
+
...(identifier ? { 'X-Onairos-User': identifier } : {}),
|
|
170
|
+
},
|
|
171
|
+
body: JSON.stringify({
|
|
172
|
+
encryptedData: encodePayload(conversationData),
|
|
173
|
+
encryptionMetadata: { algorithm: 'AES-GCM', keyDerivation: 'PBKDF2', iterations: 100000 },
|
|
174
|
+
authentication: { username: identifier || userData.username || userData.email || '', timestamp: Date.now() },
|
|
175
|
+
integrity: { hash: await generateDataHash(conversationData), algorithm: 'SHA-256' },
|
|
176
|
+
platform: 'claude',
|
|
177
|
+
source: 'web_bookmarklet',
|
|
178
|
+
metadata: { importedAt: new Date().toISOString(), conversationCount: Array.isArray(convos) ? convos.length : 0 },
|
|
179
|
+
}),
|
|
180
|
+
});
|
|
181
|
+
if (!resp.ok) {
|
|
182
|
+
console.warn('[Claude] /llm-data/store failed', resp.status, await resp.text().catch(() => ''));
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
console.info('[Claude] Stored export via /llm-data/store', { conversationCount: convos?.length || 0 });
|
|
186
|
+
markClaudeConnectedLocally();
|
|
187
|
+
return true;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.warn('[Claude] Upload failed before backend storage', error);
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export default function ConnectClaudeModal({ open, onClose, onConnected }) {
|
|
195
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
196
|
+
const [copied, setCopied] = useState(false);
|
|
197
|
+
const [bookmarkletHrefFinal, setBookmarkletHrefFinal] = useState(() => {
|
|
198
|
+
if (typeof window === 'undefined') return '#';
|
|
199
|
+
const origin = window.location.origin;
|
|
200
|
+
const jwt = getUserToken() || '';
|
|
201
|
+
const baseUrl = (window.onairosBaseUrl) || getApiBaseUrl();
|
|
202
|
+
return CLAUDE_BOOKMARKLET_HREF
|
|
203
|
+
.replace(/__ONAIROS_ORIGIN__/g, origin)
|
|
204
|
+
.replace(/__ONAIROS_URL__/g, window.location.href)
|
|
205
|
+
.replace(/__API_URL__/g, baseUrl)
|
|
206
|
+
.replace(/__ONAIROS_TOKEN__/g, jwt);
|
|
207
|
+
});
|
|
208
|
+
const bookmarkletRef = useRef(null);
|
|
209
|
+
const syncTimeoutRef = useRef(null);
|
|
210
|
+
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
setIsMobile(window.innerWidth <= 768);
|
|
213
|
+
const handleResize = () => setIsMobile(window.innerWidth <= 768);
|
|
214
|
+
window.addEventListener('resize', handleResize);
|
|
215
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
216
|
+
}, []);
|
|
217
|
+
|
|
218
|
+
useEffect(() => {
|
|
219
|
+
if (!open) return () => {};
|
|
220
|
+
window.__onairosClaudeModalOpen = true;
|
|
221
|
+
const origin = window.location.origin;
|
|
222
|
+
const jwt = getUserToken() || '';
|
|
223
|
+
const baseUrl = (typeof window !== 'undefined' && window.onairosBaseUrl) || getApiBaseUrl();
|
|
224
|
+
const href = CLAUDE_BOOKMARKLET_HREF
|
|
225
|
+
.replace(/__ONAIROS_ORIGIN__/g, origin)
|
|
226
|
+
.replace(/__ONAIROS_URL__/g, window.location.href)
|
|
227
|
+
.replace(/__API_URL__/g, baseUrl)
|
|
228
|
+
.replace(/__ONAIROS_TOKEN__/g, jwt);
|
|
229
|
+
setBookmarkletHrefFinal(href);
|
|
230
|
+
if (bookmarkletRef.current && href) {
|
|
231
|
+
bookmarkletRef.current.href = href;
|
|
232
|
+
bookmarkletRef.current.title = 'Export Claude';
|
|
233
|
+
}
|
|
234
|
+
return () => {
|
|
235
|
+
window.__onairosClaudeModalOpen = false;
|
|
236
|
+
};
|
|
237
|
+
}, [open]);
|
|
238
|
+
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (!open) return () => {};
|
|
241
|
+
|
|
242
|
+
const baseUrl = (typeof window !== 'undefined' && window.onairosBaseUrl) || getApiBaseUrl();
|
|
243
|
+
const apiKey = getApiKey();
|
|
244
|
+
|
|
245
|
+
const markConnectedLocallyAndClose = () => {
|
|
246
|
+
if (syncTimeoutRef.current) {
|
|
247
|
+
window.clearTimeout(syncTimeoutRef.current);
|
|
248
|
+
syncTimeoutRef.current = null;
|
|
249
|
+
}
|
|
250
|
+
markClaudeConnectedLocally();
|
|
251
|
+
try {
|
|
252
|
+
localStorage.removeItem(SYNC_SUCCESS_KEY);
|
|
253
|
+
} catch (_) {}
|
|
254
|
+
if (typeof onConnected === 'function') onConnected();
|
|
255
|
+
if (typeof onClose === 'function') onClose();
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const uploadExportData = async (convos, exportId = '', popupId = '') => {
|
|
259
|
+
try {
|
|
260
|
+
const stored = await uploadClaudeExportData(convos, exportId);
|
|
261
|
+
const statusMessage = {
|
|
262
|
+
platform: 'Claude',
|
|
263
|
+
count: Array.isArray(convos) ? convos.length : 0,
|
|
264
|
+
message: stored ? '' : 'Could not store Claude data. Check the Onairos app tab.',
|
|
265
|
+
};
|
|
266
|
+
notifyLlmSyncPopup(popupId, stored ? 'success' : 'error', statusMessage);
|
|
267
|
+
try {
|
|
268
|
+
window.postMessage({
|
|
269
|
+
type: 'onairos-llm-sync-status',
|
|
270
|
+
popupId,
|
|
271
|
+
status: stored ? 'success' : 'error',
|
|
272
|
+
...statusMessage,
|
|
273
|
+
}, '*');
|
|
274
|
+
} catch (_) {}
|
|
275
|
+
if (stored) {
|
|
276
|
+
markConnectedLocallyAndClose();
|
|
277
|
+
}
|
|
278
|
+
return stored;
|
|
279
|
+
} catch (error) {
|
|
280
|
+
console.warn('[Claude] Upload failed before backend storage', error);
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const processPendingImport = (raw) => {
|
|
286
|
+
try {
|
|
287
|
+
const pending = JSON.parse(raw);
|
|
288
|
+
uploadExportData(pending.convos, pending.exportId);
|
|
289
|
+
} catch (_) {}
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const pendingRaw = localStorage.getItem(PENDING_IMPORT_KEY);
|
|
293
|
+
if (pendingRaw) {
|
|
294
|
+
localStorage.removeItem(PENDING_IMPORT_KEY);
|
|
295
|
+
processPendingImport(pendingRaw);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const pollInterval = setInterval(() => {
|
|
299
|
+
const raw = localStorage.getItem(PENDING_IMPORT_KEY);
|
|
300
|
+
if (raw) {
|
|
301
|
+
localStorage.removeItem(PENDING_IMPORT_KEY);
|
|
302
|
+
processPendingImport(raw);
|
|
303
|
+
}
|
|
304
|
+
}, 1000);
|
|
305
|
+
|
|
306
|
+
const isClaudeConnectedFromAccountStatus = (data) => {
|
|
307
|
+
try {
|
|
308
|
+
const acct = data?.AccountInfo?.accounts?.claude || data?.AccountInfo?.accounts?.Claude;
|
|
309
|
+
if (acct?.connected === true) return true;
|
|
310
|
+
const connectedPlatforms = data?.accountStatus?.connectedPlatforms;
|
|
311
|
+
if (Array.isArray(connectedPlatforms)) {
|
|
312
|
+
return connectedPlatforms.some((p) => String(p).toLowerCase().includes('claude'));
|
|
313
|
+
}
|
|
314
|
+
const connections = data?.AccountInfo?.connections;
|
|
315
|
+
if (Array.isArray(connections)) {
|
|
316
|
+
return connections.some((p) => String(p).toLowerCase().includes('claude'));
|
|
317
|
+
}
|
|
318
|
+
if (connections && typeof connections === 'object') {
|
|
319
|
+
return !!(connections.Claude || connections.claude);
|
|
320
|
+
}
|
|
321
|
+
} catch (_) {}
|
|
322
|
+
return false;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// localStorage fast-path: the sync window or module-level listener may have already
|
|
326
|
+
// written to onairos_connected_accounts before handleMessage fires.
|
|
327
|
+
// Snapshot at open time so we only react to NEW connections, not stale cached state.
|
|
328
|
+
const alreadyConnectedInLocalStorage = (() => {
|
|
329
|
+
try {
|
|
330
|
+
const s = JSON.parse(localStorage.getItem('onairos_connected_accounts') || '{}');
|
|
331
|
+
return !!(s.claude || s.Claude);
|
|
332
|
+
} catch (_) { return false; }
|
|
333
|
+
})();
|
|
334
|
+
const connectionCheck = setInterval(() => {
|
|
335
|
+
try {
|
|
336
|
+
const storedConnections = JSON.parse(localStorage.getItem('onairos_connected_accounts') || '{}');
|
|
337
|
+
const syncSuccess = localStorage.getItem(SYNC_SUCCESS_KEY);
|
|
338
|
+
const nowConnected = storedConnections.claude || storedConnections.Claude || syncSuccess === 'true';
|
|
339
|
+
if (nowConnected && !alreadyConnectedInLocalStorage) {
|
|
340
|
+
markConnectedLocallyAndClose();
|
|
341
|
+
clearInterval(connectionCheck);
|
|
342
|
+
clearInterval(backendPoll);
|
|
343
|
+
}
|
|
344
|
+
} catch (_) {}
|
|
345
|
+
}, 1000);
|
|
346
|
+
|
|
347
|
+
// Backend poll: catches the case where the bookmarklet had no window.opener
|
|
348
|
+
// (user already had claude.ai open in a separate tab) and sent data directly
|
|
349
|
+
// to the sync window. Once the backend confirms Claude is connected, fire onConnected.
|
|
350
|
+
let backendPollInFlight = false;
|
|
351
|
+
const backendPoll = setInterval(async () => {
|
|
352
|
+
if (!open || backendPollInFlight) return;
|
|
353
|
+
const identifier = getClaudeIdentifierForAccountCheck();
|
|
354
|
+
if (!identifier) return;
|
|
355
|
+
backendPollInFlight = true;
|
|
356
|
+
try {
|
|
357
|
+
const resp = await fetch(`${baseUrl}/getAccountInfo/email`, {
|
|
358
|
+
method: 'POST',
|
|
359
|
+
headers: {
|
|
360
|
+
'Content-Type': 'application/json',
|
|
361
|
+
...(apiKey ? { 'x-api-key': apiKey } : {}),
|
|
362
|
+
},
|
|
363
|
+
body: JSON.stringify({ Info: { identifier: String(identifier).trim().toLowerCase() } }),
|
|
364
|
+
});
|
|
365
|
+
if (resp.ok && isClaudeConnectedFromAccountStatus(await resp.json())) {
|
|
366
|
+
clearInterval(connectionCheck);
|
|
367
|
+
clearInterval(backendPoll);
|
|
368
|
+
markConnectedLocallyAndClose();
|
|
369
|
+
}
|
|
370
|
+
} catch (_) {
|
|
371
|
+
// Keep polling.
|
|
372
|
+
} finally {
|
|
373
|
+
backendPollInFlight = false;
|
|
374
|
+
}
|
|
375
|
+
}, 2000);
|
|
376
|
+
|
|
377
|
+
const handleMessage = (event) => {
|
|
378
|
+
if (event.data?.type === 'claude-export-data') {
|
|
379
|
+
localStorage.removeItem(PENDING_IMPORT_KEY);
|
|
380
|
+
if (event.source) {
|
|
381
|
+
try { event.source.postMessage({ type: 'claude-export-ack' }, event.origin); } catch (_) {}
|
|
382
|
+
}
|
|
383
|
+
uploadExportData(event.data.convos, event.data.exportId, event.data.popupId).then((stored) => {
|
|
384
|
+
try {
|
|
385
|
+
event.source?.postMessage({
|
|
386
|
+
type: 'onairos-llm-sync-status',
|
|
387
|
+
popupId: event.data.popupId,
|
|
388
|
+
status: stored ? 'success' : 'error',
|
|
389
|
+
platform: 'Claude',
|
|
390
|
+
count: Array.isArray(event.data.convos) ? event.data.convos.length : 0,
|
|
391
|
+
message: stored ? '' : 'Could not store Claude data. Check the Onairos app tab.',
|
|
392
|
+
}, event.origin);
|
|
393
|
+
} catch (_) {}
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
window.addEventListener('message', handleMessage);
|
|
398
|
+
|
|
399
|
+
return () => {
|
|
400
|
+
window.removeEventListener('message', handleMessage);
|
|
401
|
+
clearInterval(pollInterval);
|
|
402
|
+
clearInterval(connectionCheck);
|
|
403
|
+
clearInterval(backendPoll);
|
|
404
|
+
if (syncTimeoutRef.current) window.clearTimeout(syncTimeoutRef.current);
|
|
405
|
+
};
|
|
406
|
+
}, [open, onConnected, onClose]);
|
|
407
|
+
|
|
408
|
+
const handleCopyCode = () => {
|
|
409
|
+
navigator.clipboard.writeText(bookmarkletHrefFinal);
|
|
410
|
+
setCopied(true);
|
|
411
|
+
setTimeout(() => setCopied(false), 2000);
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const handleGotIt = () => {
|
|
415
|
+
if (typeof onClose === 'function') onClose();
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
if (!open) return null;
|
|
419
|
+
|
|
420
|
+
return ReactDOM.createPortal(
|
|
421
|
+
<div style={{ position: 'fixed', inset: 0, zIndex: 2147483647, pointerEvents: 'auto' }}>
|
|
422
|
+
<style>{`
|
|
423
|
+
@keyframes gentlePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(251, 146, 60, 0.32); } 50% { box-shadow: 0 0 0 10px rgba(251, 146, 60, 0); } }
|
|
424
|
+
@keyframes fadeInScale { 0% { opacity: 0; transform: translateY(8px) scale(0.96); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
|
|
425
|
+
.claude-modal-card { animation: fadeInScale 200ms cubic-bezier(0.16, 1, 0.3, 1); }
|
|
426
|
+
.bookmarklet-button { background: linear-gradient(135deg, rgba(251, 146, 60, 0.95), rgba(234, 88, 12, 0.9)); border-radius: 9999px; border: 1px solid rgba(255,237,213,0.42); backdrop-filter: blur(18px); box-shadow: 0 14px 32px rgba(234, 88, 12, 0.26); }
|
|
427
|
+
.bookmarklet-button:hover { background: linear-gradient(135deg, rgba(253, 186, 116, 0.98), rgba(249, 115, 22, 0.95)); }
|
|
428
|
+
.step-circle { background: linear-gradient(135deg, #fb923c, #ea580c); box-shadow: 0 8px 18px rgba(234, 88, 12, 0.28); min-width: 28px; width: 28px; height: 28px; }
|
|
429
|
+
.claude-got-it-button { color: #431407 !important; background: linear-gradient(135deg, #fed7aa 0%, #fb923c 100%) !important; }
|
|
430
|
+
.claude-got-it-button:hover { background: linear-gradient(135deg, #ffedd5 0%, #f97316 100%) !important; }
|
|
431
|
+
@media (max-width: 768px) {
|
|
432
|
+
.claude-modal-backdrop { align-items: flex-end !important; padding: 0 !important; }
|
|
433
|
+
.claude-modal-card { max-width: 100% !important; height: 90vh !important; max-height: 90vh !important; border-radius: 24px 24px 0 0 !important; display: flex; flex-direction: column; }
|
|
434
|
+
.claude-modal-content { overflow-y: auto; flex: 1; }
|
|
435
|
+
}
|
|
436
|
+
`}</style>
|
|
437
|
+
<div className="claude-modal-backdrop fixed inset-0 flex items-center justify-center p-4 bg-black/60" style={{ zIndex: 2147483647 }}>
|
|
438
|
+
<div
|
|
439
|
+
className="claude-modal-card w-full max-w-md rounded-3xl shadow-2xl border border-white/10 overflow-hidden text-white relative"
|
|
440
|
+
style={{
|
|
441
|
+
background: 'radial-gradient(circle at top left, rgba(251, 146, 60, 0.22), transparent 34%), linear-gradient(135deg, rgba(17, 24, 39, 0.98) 0%, rgba(31, 41, 55, 0.95) 48%, rgba(15, 23, 42, 0.98) 100%)',
|
|
442
|
+
boxShadow: 'inset 0 1px 0 0 rgba(255, 237, 213, 0.16), 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 100px rgba(234, 88, 12, 0.14)',
|
|
443
|
+
}}
|
|
444
|
+
>
|
|
445
|
+
<div className="relative px-5 py-4 border-b border-white/10 bg-white/5 flex-shrink-0">
|
|
446
|
+
<button
|
|
447
|
+
onClick={onClose}
|
|
448
|
+
aria-label="Close"
|
|
449
|
+
type="button"
|
|
450
|
+
className="onairos-close-btn absolute right-3 top-3 inline-flex items-center justify-center rounded-full transition-all hover:scale-105 z-50 cursor-pointer"
|
|
451
|
+
style={{
|
|
452
|
+
width: 28,
|
|
453
|
+
height: 28,
|
|
454
|
+
padding: 0,
|
|
455
|
+
background: 'rgba(255, 255, 255, 0.08)',
|
|
456
|
+
border: '1px solid rgba(255, 255, 255, 0.18)',
|
|
457
|
+
backdropFilter: 'blur(8px)',
|
|
458
|
+
WebkitBackdropFilter: 'blur(8px)',
|
|
459
|
+
color: '#ffffff',
|
|
460
|
+
}}
|
|
461
|
+
onMouseEnter={(e) => { e.currentTarget.style.background = 'rgba(255,255,255,0.16)'; }}
|
|
462
|
+
onMouseLeave={(e) => { e.currentTarget.style.background = 'rgba(255,255,255,0.08)'; }}
|
|
463
|
+
>
|
|
464
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden>
|
|
465
|
+
<path d="M3 3l6 6M9 3l-6 6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
466
|
+
</svg>
|
|
467
|
+
</button>
|
|
468
|
+
<h2 className="text-xl font-semibold pr-8 text-white">{isMobile ? 'Export Claude' : 'Connect Claude'}</h2>
|
|
469
|
+
<p className="text-sm mt-0.5 text-white">Import your recent chats.</p>
|
|
470
|
+
</div>
|
|
471
|
+
|
|
472
|
+
<div className="px-5 py-4 space-y-4 claude-modal-content">
|
|
473
|
+
{isMobile ? (
|
|
474
|
+
<>
|
|
475
|
+
<div className="flex gap-3">
|
|
476
|
+
<div className="flex-shrink-0">
|
|
477
|
+
<div className="step-circle rounded-full flex items-center justify-center"><span className="text-white font-bold text-sm">1</span></div>
|
|
478
|
+
</div>
|
|
479
|
+
<div className="flex-1 pt-0.5">
|
|
480
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Copy the bookmark code</h3>
|
|
481
|
+
<button onClick={handleCopyCode} className="mt-1 w-full flex items-center justify-center gap-2 py-3 rounded-xl text-sm font-medium active:scale-95 transition-all text-white border border-orange-200/30" style={{ background: 'rgba(251, 146, 60, 0.18)' }}>
|
|
482
|
+
{copied ? 'Copied' : 'Copy code'}
|
|
483
|
+
</button>
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
|
|
487
|
+
<div className="flex gap-3">
|
|
488
|
+
<div className="flex-shrink-0">
|
|
489
|
+
<div className="step-circle rounded-full flex items-center justify-center"><span className="text-white font-bold text-sm">2</span></div>
|
|
490
|
+
</div>
|
|
491
|
+
<div className="flex-1 pt-0.5">
|
|
492
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Add a bookmark</h3>
|
|
493
|
+
<p className="text-xs text-slate-200 leading-relaxed mb-2">Add a bookmark, then paste the code into the bookmark URL.</p>
|
|
494
|
+
</div>
|
|
495
|
+
</div>
|
|
496
|
+
|
|
497
|
+
<div className="flex gap-3">
|
|
498
|
+
<div className="flex-shrink-0">
|
|
499
|
+
<div className="step-circle rounded-full flex items-center justify-center"><span className="text-white font-bold text-sm">3</span></div>
|
|
500
|
+
</div>
|
|
501
|
+
<div className="flex-1 pt-0.5">
|
|
502
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Run it on Claude</h3>
|
|
503
|
+
<button type="button" onClick={() => window.open('https://claude.ai', '_blank')} className="mt-2 text-xs text-white px-3 py-1.5 rounded-lg inline-flex items-center gap-1" style={{ background: 'linear-gradient(135deg, #fb923c 0%, #ea580c 100%)' }}>
|
|
504
|
+
Open Claude
|
|
505
|
+
</button>
|
|
506
|
+
<p className="text-xs text-slate-300 mt-2">In the address bar, search your bookmark name and tap it.</p>
|
|
507
|
+
</div>
|
|
508
|
+
</div>
|
|
509
|
+
</>
|
|
510
|
+
) : (
|
|
511
|
+
<>
|
|
512
|
+
<div className="flex gap-3">
|
|
513
|
+
<div className="flex-shrink-0">
|
|
514
|
+
<div className="step-circle rounded-full flex items-center justify-center"><span className="text-white font-bold text-sm">1</span></div>
|
|
515
|
+
</div>
|
|
516
|
+
<div className="flex-1 pt-0.5">
|
|
517
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Drag this button to your bookmarks bar</h3>
|
|
518
|
+
<div className="relative inline-block mt-2">
|
|
519
|
+
<div className="absolute inset-0 rounded-full" style={{ animation: 'gentlePulse 2s ease-in-out infinite' }} />
|
|
520
|
+
<a
|
|
521
|
+
ref={bookmarkletRef}
|
|
522
|
+
href={bookmarkletHrefFinal || '#'}
|
|
523
|
+
title="Export Claude"
|
|
524
|
+
aria-label="Export Claude"
|
|
525
|
+
draggable="true"
|
|
526
|
+
onDragStart={(e) => {
|
|
527
|
+
try {
|
|
528
|
+
const bookmarkTitle = 'Export Claude';
|
|
529
|
+
const href = bookmarkletRef.current?.href || bookmarkletHrefFinal || '#';
|
|
530
|
+
if (bookmarkletRef.current && href) bookmarkletRef.current.href = href;
|
|
531
|
+
if (bookmarkletRef.current) bookmarkletRef.current.title = bookmarkTitle;
|
|
532
|
+
|
|
533
|
+
const ua = navigator?.userAgent || '';
|
|
534
|
+
const isChromium =
|
|
535
|
+
/\bChrome\/|\bChromium\//.test(ua) && !/\bEdg\/|\bOPR\//.test(ua);
|
|
536
|
+
if (isChromium) return;
|
|
537
|
+
|
|
538
|
+
const html = `<a href="${href}">${bookmarkTitle}</a>`;
|
|
539
|
+
e.dataTransfer.setData('text/uri-list', href);
|
|
540
|
+
e.dataTransfer.setData('text/plain', href);
|
|
541
|
+
e.dataTransfer.setData('text/html', html);
|
|
542
|
+
e.dataTransfer.setData('text/x-moz-url', `${href}\n${bookmarkTitle}`);
|
|
543
|
+
e.dataTransfer.effectAllowed = 'copy';
|
|
544
|
+
} catch (err) {
|
|
545
|
+
console.warn('Drag start error:', err);
|
|
546
|
+
}
|
|
547
|
+
}}
|
|
548
|
+
onClick={(e) => {
|
|
549
|
+
e.preventDefault();
|
|
550
|
+
alert('Drag this button to your bookmarks bar.');
|
|
551
|
+
}}
|
|
552
|
+
className="bookmarklet-button relative inline-flex items-center gap-1.5 px-4 py-2 font-medium cursor-move select-none transition-all hover:scale-[1.03]"
|
|
553
|
+
suppressHydrationWarning
|
|
554
|
+
>
|
|
555
|
+
<span className="text-base">✨</span>
|
|
556
|
+
<span className="text-sm">Export Claude</span>
|
|
557
|
+
</a>
|
|
558
|
+
</div>
|
|
559
|
+
</div>
|
|
560
|
+
</div>
|
|
561
|
+
|
|
562
|
+
<div className="flex gap-3">
|
|
563
|
+
<div className="flex-shrink-0">
|
|
564
|
+
<div className="step-circle rounded-full flex items-center justify-center"><span className="text-white font-bold text-sm">2</span></div>
|
|
565
|
+
</div>
|
|
566
|
+
<div className="flex-1 pt-0.5">
|
|
567
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Open Claude</h3>
|
|
568
|
+
<button type="button" onClick={() => window.open('https://claude.ai', '_blank')} className="inline-flex items-center gap-1.5 px-4 py-2 rounded-full text-xs font-medium transition-all hover:scale-[1.02] active:scale-[0.98]" style={{ background: 'linear-gradient(135deg, #fb923c 0%, #ea580c 100%)', color: '#ffffff', boxShadow: '0 0 25px rgba(234, 88, 12, 0.24), inset 0 1px 0 rgba(255, 237, 213, 0.35)' }}>
|
|
569
|
+
<svg
|
|
570
|
+
className="w-3.5 h-3.5"
|
|
571
|
+
fill="none"
|
|
572
|
+
stroke="currentColor"
|
|
573
|
+
viewBox="0 0 24 24"
|
|
574
|
+
>
|
|
575
|
+
<path
|
|
576
|
+
strokeLinecap="round"
|
|
577
|
+
strokeLinejoin="round"
|
|
578
|
+
strokeWidth={2}
|
|
579
|
+
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
|
|
580
|
+
/>
|
|
581
|
+
</svg>
|
|
582
|
+
Open Claude
|
|
583
|
+
</button>
|
|
584
|
+
</div>
|
|
585
|
+
</div>
|
|
586
|
+
|
|
587
|
+
<div className="flex gap-3">
|
|
588
|
+
<div className="flex-shrink-0">
|
|
589
|
+
<div className="step-circle rounded-full flex items-center justify-center"><span className="text-white font-bold text-sm">3</span></div>
|
|
590
|
+
</div>
|
|
591
|
+
<div className="flex-1 pt-0.5">
|
|
592
|
+
<h3 className="text-sm font-semibold mb-1 text-white">Click the bookmark</h3>
|
|
593
|
+
<p className="text-xs text-slate-200">Click <strong className="text-white">"Export Claude"</strong> in your bookmarks bar.</p>
|
|
594
|
+
</div>
|
|
595
|
+
</div>
|
|
596
|
+
</>
|
|
597
|
+
)}
|
|
598
|
+
</div>
|
|
599
|
+
|
|
600
|
+
<div className="px-5 py-4 bg-white/5 border-t border-white/10 flex-shrink-0">
|
|
601
|
+
<button type="button" onClick={handleGotIt} className="w-full px-4 py-2.5 rounded-full font-medium text-sm transition-all hover:scale-[1.01] active:scale-[0.99] shadow-[0_10px_30px_rgba(15,23,42,0.45)] border border-white/40 claude-got-it-button">
|
|
602
|
+
<span>{isMobile ? 'Close' : 'Got it!'}</span>
|
|
603
|
+
</button>
|
|
604
|
+
</div>
|
|
605
|
+
</div>
|
|
606
|
+
</div>
|
|
607
|
+
</div>,
|
|
608
|
+
document.body
|
|
609
|
+
);
|
|
610
|
+
}
|