@onairosofficial/onairos-capacitor 0.1.4 → 0.1.5

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 (88) hide show
  1. package/OnairosofficialOnairosCapacitor.podspec +1 -1
  2. package/README.md +1 -1
  3. package/dist/onairos.capacitor.esm.js +509 -1
  4. package/dist/onairos.capacitor.esm.turbopack.js +509 -1
  5. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosChatGPTNativePlugin.swift +187 -945
  6. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosRNScrapers.swift +1800 -0
  7. package/ios/Sources/OnairosNativeConnectorsPlugin/OnairosSpotifyNativePlugin.swift +180 -629
  8. package/onairos.d.ts +24 -0
  9. package/package.json +5 -2
  10. package/src/assets/connectors/Linkedinicon.png +0 -0
  11. package/src/assets/connectors/Redditicon.png +0 -0
  12. package/src/assets/connectors/YouTubeicon2.png +0 -0
  13. package/src/assets/connectors/chatgpt.png +0 -0
  14. package/src/assets/connectors/claude.png +0 -0
  15. package/src/assets/connectors/instagram.png +0 -0
  16. package/src/assets/connectors/netflix.png +0 -0
  17. package/src/assets/connectors/pinterest.png +0 -0
  18. package/src/assets/connectors/sephora.png +0 -0
  19. package/src/assets/connectors/spotify.png +0 -0
  20. package/src/assets/connectors/tiktok.png +0 -0
  21. package/src/assets/permissions/onairos.png +0 -0
  22. package/src/assets/permissions/personalization.png +0 -0
  23. package/src/assets/permissions/public-profile-person.png +0 -0
  24. package/src/assets/permissions/raw-memories.png +0 -0
  25. package/src/capacitorConnectorCatalog.js +2 -6
  26. package/src/components/DataRequest.jsx +96 -532
  27. package/src/components/PinSetup.jsx +39 -226
  28. package/src/components/SDKDesignPreview.jsx +33 -0
  29. package/src/components/SessionUserBar.jsx +2 -1
  30. package/src/components/UniversalOnboarding.jsx +190 -423
  31. package/src/components/WelcomeScreen.jsx +7 -0
  32. package/src/components/parity/NativeConnections.jsx +136 -0
  33. package/src/components/parity/NativeScreens.jsx +48 -0
  34. package/src/components/ui/PageLayout.jsx +7 -3
  35. package/src/nativeImport/ConnectorLoading.jsx +13 -0
  36. package/src/nativeImport/CustomImportSession.js +115 -0
  37. package/src/nativeImport/ImportIcon.jsx +29 -0
  38. package/src/nativeImport/ImportProgress.jsx +24 -0
  39. package/src/nativeImport/ImportStatus.jsx +9 -0
  40. package/src/nativeImport/NativeChatImport.jsx +28 -0
  41. package/src/nativeImport/NativeImportSession.js +123 -0
  42. package/src/nativeImport/NativeScraperImport.jsx +57 -0
  43. package/src/nativeImport/SmartFilter.jsx +28 -0
  44. package/src/nativeImport/customPayload.js +37 -0
  45. package/src/nativeImport/netflixExport.js +30 -0
  46. package/src/nativeImport/netflixHistory.js +28 -0
  47. package/src/nativeImport/netflixSession.js +59 -0
  48. package/src/nativeImport/rawHandoff.js +7 -0
  49. package/src/nativeImport/rn/config/api.js +5 -0
  50. package/src/nativeImport/rn/services/apiKeyService.js +2 -0
  51. package/src/nativeImport/rn/services/hingePayload.js +37 -0
  52. package/src/nativeImport/rn/services/nativeConversationImport.js +138 -0
  53. package/src/nativeImport/rn/services/nativeFileTransfer.js +127 -0
  54. package/src/nativeImport/rn/services/nativeRawRedaction.js +136 -0
  55. package/src/nativeImport/rn/services/netflixPayload.js +70 -0
  56. package/src/nativeImport/rn/services/rawMemoryPolicy.js +38 -0
  57. package/src/nativeImport/rn/services/sephoraPayload.js +166 -0
  58. package/src/nativeImport/rn/services/spotifyPayload.js +99 -0
  59. package/src/nativeImport/rn/source-manifest.json +45 -0
  60. package/src/nativeImport/rn/utils/importedFiles.js +74 -0
  61. package/src/nativeImport/rn/utils/nativeImportDates.js +45 -0
  62. package/src/nativeImport/rn/utils/nativeImportFileReceiver.js +51 -0
  63. package/src/nativeImport/rn/utils/nativeImportMetadata.js +74 -0
  64. package/src/nativeImport/rn/utils/nativeImportTopics.js +56 -0
  65. package/src/nativeImport/rn/utils/rawExportDelivery.js +12 -0
  66. package/src/nativeImport/rn/utils/webviewScripts/chatgptDiscovery.js +99 -0
  67. package/src/nativeImport/rn/utils/webviewScripts/claude.js +349 -0
  68. package/src/nativeImport/rn/utils/webviewScripts/gemini.js +356 -0
  69. package/src/nativeImport/rn/utils/webviewScripts/hinge.js +375 -0
  70. package/src/nativeImport/rn/utils/webviewScripts/instagram.js +152 -0
  71. package/src/nativeImport/rn/utils/webviewScripts/linkedin.js +825 -0
  72. package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTImport.js +202 -0
  73. package/src/nativeImport/rn/utils/webviewScripts/nativeChatGPTSession.js +63 -0
  74. package/src/nativeImport/rn/utils/webviewScripts/nativeImportFiles.js +132 -0
  75. package/src/nativeImport/rn/utils/webviewScripts/nativeImportProviders.js +80 -0
  76. package/src/nativeImport/rn/utils/webviewScripts/nativeLoginViewport.js +28 -0
  77. package/src/nativeImport/rn/utils/webviewScripts/netflix.js +257 -0
  78. package/src/nativeImport/rn/utils/webviewScripts/sephora.js +862 -0
  79. package/src/nativeImport/rn/utils/webviewScripts/sephoraSession.js +160 -0
  80. package/src/nativeImport/rn/utils/webviewScripts/spotify.js +1868 -0
  81. package/src/nativeImport/rn/utils/webviewScripts/telegram.js +630 -0
  82. package/src/nativeImport/rn/utils/webviewScripts/tiktok.js +2920 -0
  83. package/src/onairos.core.jsx +3 -0
  84. package/src/onairosButton.jsx +23 -17
  85. package/src/styles/onairos-rn-parity.css +175 -0
  86. package/src/styles/tailwind.capacitor.css +4 -0
  87. package/src/utils/nativeConnectorSession.js +18 -0
  88. package/src/utils/parityPolicy.js +41 -0
@@ -1,3 +1,4 @@
1
+ import {NativeWelcome} from './parity/NativeScreens.jsx';
1
2
  import React, { useEffect, useState, useRef } from 'react';
2
3
  import { COLORS } from '../theme/colors.js';
3
4
  import { isMobileApp } from '../utils/capacitorDetection.js';
@@ -20,6 +21,8 @@ if (typeof window !== 'undefined') {
20
21
 
21
22
  export default function WelcomeScreen({
22
23
  onContinue,
24
+ rawMemoriesOnly = false,
25
+ sharesRawContent = false,
23
26
  onContinueAsVerified,
24
27
  onUseDifferentEmail,
25
28
  preVerifiedEmail = null,
@@ -131,6 +134,10 @@ export default function WelcomeScreen({
131
134
  return () => ro.disconnect();
132
135
  }, []);
133
136
 
137
+ if (isMobileApp()) return <NativeWelcome appName={appName === 'this app' ? 'This app' : appName} rawOnly={rawMemoriesOnly} sharesRawContent={sharesRawContent}
138
+ onContinue={hasPreVerifiedEmail ? onContinueAsVerified : onContinue} onUseDifferentEmail={onUseDifferentEmail}
139
+ verifiedEmail={hasPreVerifiedEmail ? maskEmail(preVerifiedEmail) : null} loading={continueLoading} error={continueError}/>;
140
+
134
141
  return (
135
142
  <div
136
143
  ref={rootRef}
@@ -0,0 +1,136 @@
1
+ import React, {useEffect, useLayoutEffect, useRef, useState} from 'react';
2
+ import Lottie from 'lottie-react';
3
+ import persona from '../../../public/persona-anim.json';
4
+ import {NativeAction, NativeInfoIcon} from './NativeScreens.jsx';
5
+ import chatgpt from '../../assets/connectors/chatgpt.png';
6
+ import youtube from '../../assets/connectors/YouTubeicon2.png';
7
+ import linkedin from '../../assets/connectors/Linkedinicon.png';
8
+ import pinterest from '../../assets/connectors/pinterest.png';
9
+ import reddit from '../../assets/connectors/Redditicon.png';
10
+ import spotify from '../../assets/connectors/spotify.png';
11
+ import tiktok from '../../assets/connectors/tiktok.png';
12
+
13
+ import claude from '../../assets/connectors/claude.png';
14
+ import netflix from '../../assets/connectors/netflix.png';
15
+ import sephora from '../../assets/connectors/sephora.png';
16
+ import instagram from '../../assets/connectors/instagram.png';
17
+ const icons={chatgpt,claude,netflix,sephora,instagram,instagramdata:instagram,youtube,linkedin,pinterest,reddit,spotify,tiktok};
18
+ const topics={chatgpt:'conversations and memories',youtube:'likes and watch history',linkedin:'professional profile and posts',pinterest:'boards and pins',reddit:'communities and activities',spotify:'listening activity',tiktok:'watch history'};
19
+ const key=p=>String(p.connector || p.name).toLowerCase().replace(/[\s_-]/g,'');
20
+ const icon=p=>icons[key(p)] ? <img src={icons[key(p)]} alt="" draggable={false}/> : p.icon || p.name.slice(0,2);
21
+ const colorProgress=(count,total)=>{
22
+ if(!total)return 0;
23
+ const milestones=[0,.22,.45,.75,1],position=Math.min(4,count/total*4),lower=Math.floor(position);
24
+ return lower>=4?1:milestones[lower]+(milestones[lower+1]-milestones[lower])*(position-lower);
25
+ };
26
+
27
+ function PlatformDirectory({platforms,connected,selected,onSelect,onClose}) {
28
+ const [query,setQuery]=useState('');
29
+ const dialog=useRef(null);
30
+ useEffect(()=>{
31
+ const previous=document.activeElement;
32
+ dialog.current?.querySelector('button')?.focus();
33
+ return()=>previous?.focus?.();
34
+ },[]);
35
+ const results=platforms.filter(p=>`${p.name} ${p.connector}`.toLowerCase().includes(query.trim().toLowerCase())).sort((a,b)=>a.name.localeCompare(b.name));
36
+ const handleKey=event=>{
37
+ if(event.key==='Escape'){event.stopPropagation();onClose();}
38
+ if(event.key==='Tab'){
39
+ const nodes=Array.from(dialog.current.querySelectorAll('button,input')).filter(el=>!el.disabled);
40
+ const first=nodes[0],last=nodes[nodes.length-1];
41
+ if(event.shiftKey&&document.activeElement===first){event.preventDefault();last?.focus();}
42
+ else if(!event.shiftKey&&document.activeElement===last){event.preventDefault();first?.focus();}
43
+ }
44
+ };
45
+ return <div className="rn-directory-backdrop" onClick={e=>{if(e.target===e.currentTarget)onClose();}} onKeyDown={handleKey}>
46
+ <section ref={dialog} className="rn-directory-sheet" role="dialog" aria-modal="true" aria-label="All platforms">
47
+ <header><h2>All platforms</h2><button type="button" aria-label="Close connections" onClick={onClose}>Done</button></header>
48
+ <label className="rn-directory-search"><svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6"/><path d="m15 15 5 5"/></svg><input type="search" aria-label="Search platforms" placeholder="Search platforms" value={query} onChange={e=>setQuery(e.target.value)} autoCapitalize="none" autoComplete="off"/></label>
49
+ <div className="rn-directory-grid">{results.map(p=><button type="button" key={key(p)} aria-label={`${p.name}, ${connected[p.name]?'connected':'not connected'}`} aria-pressed={p.name===selected} onClick={()=>{onSelect(p.name);onClose();}}><span>{icon(p)}</span><strong>{p.name}</strong>{connected[p.name]&&<small>Connected</small>}</button>)}{!results.length&&<p role="status">No platforms found</p>}</div>
50
+ </section>
51
+ </div>;
52
+ }
53
+
54
+ export default function NativeConnections({platforms,connected={},selected,onSelect,onToggle,pending,onContinue,allowEmpty=false,descriptions={},error,progress,rawOnly=false,privacyPolicyUrl='https://privacy.onairos.io',recommendedPlatforms=[]}) {
55
+ const [directory,setDirectory]=useState(false),[continuing,setContinuing]=useState(false),[continueError,setContinueError]=useState('');
56
+ const root=useRef(null),stage=useRef(null),animation=useRef(null),continuePending=useRef(false),touch=useRef(null);
57
+ const [size,setSize]=useState({width:393,height:852,body:700,stage:335,heading:80,footer:313});
58
+ const [reduced,setReduced]=useState(true);
59
+ useEffect(()=>{
60
+ const media=window.matchMedia?.('(prefers-reduced-motion: reduce)');
61
+ const update=()=>setReduced(media?.matches ?? true);update();media?.addEventListener?.('change',update);
62
+ return()=>media?.removeEventListener?.('change',update);
63
+ },[]);
64
+ useLayoutEffect(()=>{
65
+ const measure=()=>{
66
+ const node=root.current,viewport=window.innerHeight||852;
67
+ const modalBottom=node?.closest('[data-onairos-modal]')?.getBoundingClientRect().bottom||viewport;
68
+ // Percentage-height ancestors can exceed a native sheet's visible area.
69
+ // Bound this screen to the actual sheet/viewport so its inner body scrolls.
70
+ const available=Math.max(0,Math.min(viewport,modalBottom)-(node?.getBoundingClientRect().top||0));
71
+ setSize({width:node?.clientWidth||393,height:viewport,available,body:Math.min(node?.clientHeight||700,available),stage:stage.current?.clientHeight||335,heading:node?.querySelector('.rn-connections-heading')?.clientHeight||80,footer:node?.querySelector('.rn-connections-footer')?.clientHeight||313});
72
+ };
73
+ measure();const observer=typeof ResizeObserver==='undefined'?null:new ResizeObserver(measure);
74
+ if(root.current)observer?.observe(root.current);if(stage.current)observer?.observe(stage.current);
75
+ window.addEventListener('resize',measure);return()=>{observer?.disconnect();window.removeEventListener('resize',measure);};
76
+ },[]);
77
+ const focused=Math.max(0,platforms.findIndex(p=>p.name===selected)),current=platforms[focused];
78
+ const count=platforms.filter(p=>connected[p.name]).length;
79
+ const target=colorProgress(count,platforms.length),painted=useRef(target),frameRequest=useRef(null);
80
+ const [ready,setReady]=useState(false);
81
+ useEffect(()=>{
82
+ if(!ready)return;
83
+ const from=painted.current,start=performance.now(),duration=reduced?0:3200;
84
+ const paint=now=>{
85
+ const t=duration?Math.min(1,(now-start)/duration):1,eased=t<.5?2*t*t:-1+(4-2*t)*t;
86
+ painted.current=from+(target-from)*eased;
87
+ animation.current?.goToAndStop(painted.current*Math.max(0,persona.op-persona.ip-1),true);
88
+ if(t<1)frameRequest.current=requestAnimationFrame(paint);
89
+ };
90
+ frameRequest.current=requestAnimationFrame(paint);return()=>cancelAnimationFrame(frameRequest.current);
91
+ },[target,reduced,ready]);
92
+ const veryCompact=size.height<700,compact=size.height<780,tall=size.height>=880;
93
+ const stack=veryCompact?220:compact?260:tall?365:335;
94
+ const artSize=Math.min(veryCompact?340:compact?400:tall?510:470,size.width+(veryCompact?16:92));
95
+ const artTop=Math.max(12,(stack-size.stage)/2+12);
96
+ const stride=rawOnly?88:size.width<375?44:48;
97
+ const pageStart=Math.min(Math.floor(focused/3)*3,Math.max(0,platforms.length-3));
98
+ const move=direction=>{
99
+ const next=rawOnly?Math.max(0,Math.min(platforms.length-3,pageStart+direction*3)):focused+direction;
100
+ if(platforms[next])onSelect?.(platforms[next].name);
101
+ };
102
+ const continueFlow=async()=>{
103
+ if(continuePending.current||pending||(!count&&!allowEmpty))return;
104
+ continuePending.current=true;setContinuing(true);setContinueError('');
105
+ try{await onContinue?.();}catch(_){setContinueError('Could not continue. Please try again.');}
106
+ finally{continuePending.current=false;setContinuing(false);}
107
+ };
108
+ const isConnected=!!connected[current?.name];
109
+ const topic=current&&topics[key(current)];
110
+ const description=current?(rawOnly?descriptions[current.name]:topic&&<>Use your <strong>{topic}</strong> to enrich your persona</>)||descriptions[current.name]||'Import the memories you review and confirm.':'This app’s allowed platforms do not include an available connector.';
111
+ return <section ref={root} className={`rn-screen rn-connections ${veryCompact||size.body<size.heading+stack+4+size.footer?'is-short':''} ${rawOnly?'is-raw':''}`} data-testid="native-connections" style={{maxHeight:size.available==null?undefined:`${size.available}px`,'--stack-height':`${stack}px`,'--art-size':`${artSize}px`,'--art-top':`${artTop}px`,'--stride':`${stride}px`}}>
112
+ <div className="rn-connections-body" tabIndex={0} aria-label="Connection choices" inert={directory?'':undefined}>
113
+ <header className="rn-connections-heading"><h1>{rawOnly?'Connect your data':'Build your persona'}</h1><p className="rn-subtitle">{rawOnly?'Toggle a source for this one time data export':'Each connection securely brings your persona into focus'}{privacyPolicyUrl&&<a href={privacyPolicyUrl} target="_blank" rel="noreferrer" aria-label="About connection privacy">&nbsp;<NativeInfoIcon/></a>}</p></header>
114
+ <div ref={stage} className="rn-connector-stage"><div className="rn-persona-stack">
115
+ <div className="rn-persona-art" aria-hidden="true"><Lottie lottieRef={animation} animationData={persona} autoplay={false} loop={false} onDOMLoaded={()=>setReady(true)}/></div>
116
+ <div className="rn-focus-carousel" role="region" aria-label="Platform carousel" tabIndex={0}
117
+ onKeyDown={e=>{if(e.key==='ArrowLeft'||e.key==='ArrowRight'){e.preventDefault();move(e.key==='ArrowLeft'?-1:1);}}}
118
+ onTouchStart={e=>{touch.current={x:e.touches[0].clientX,y:e.touches[0].clientY};}}
119
+ onTouchEnd={e=>{const from=touch.current;touch.current=null;if(!from)return;const dx=e.changedTouches[0].clientX-from.x,dy=e.changedTouches[0].clientY-from.y;if(Math.abs(dx)>=24&&Math.abs(dx)>Math.abs(dy)*1.5)move(dx>0?-1:1);}}>
120
+ {platforms.map((p,index)=>{
121
+ const offset=rawOnly?index-pageStart-1:index-focused,distance=Math.abs(offset),visible=distance<=2&&(rawOnly?index>=pageStart&&index<pageStart+3:true);
122
+ const scale=rawOnly?(index===focused?1.24:1):distance===0?1.2:distance===1?.93:distance===2?.72:.62;
123
+ return <button type="button" key={key(p)} className={`rn-focus-platform ${index===focused?'is-selected':''} ${connected[p.name]?'is-connected':''}`} aria-label={`Select ${p.name}`} aria-pressed={index===focused} aria-hidden={!visible} tabIndex={visible?0:-1} disabled={!visible} onClick={()=>onSelect?.(p.name)} style={{'--offset':offset,'--scale':scale,'--alpha':!visible?0:rawOnly?1:distance===0?1:distance===1?.84:.35,'--blur':`${rawOnly?0:Math.min(2,distance)*1.1}px`,zIndex:Math.max(0,3-distance)}}><span className="rn-platform-orb"><span className={`rn-platform-logo rn-logo-${key(p)}`}>{icon(p)}</span></span></button>;
124
+ })}
125
+ </div>
126
+ </div></div>
127
+ <footer className="rn-connections-footer">
128
+ {platforms.length>(rawOnly?3:1)&&<div className="rn-connection-navigation"><span/><div><button type="button" aria-label="Show previous platforms" disabled={focused===0} onClick={()=>move(-1)}>‹</button><button type="button" aria-label="Show more platforms" disabled={rawOnly?pageStart>=platforms.length-3:focused>=platforms.length-1} onClick={()=>move(1)}>›</button></div>{!rawOnly?<button type="button" className="rn-view-all" onClick={()=>setDirectory(true)}>View all</button>:<span/>}</div>}
129
+ <div data-testid="connection-card" className={`rn-connection-card ${isConnected?'is-connected':''}`}><div className="rn-card-header"><strong>{current?.name||'No available sources'}</strong>{current&&(recommendedPlatforms || []).some(p=>String(p).toLowerCase()===key(current)||p===current.name)&&<small className="rn-recommended">Highly Recommended</small>}<button type="button" role="switch" aria-label={current?`Connect ${current.name}`:'No source selected'} aria-checked={isConnected} aria-busy={!!pending} disabled={!current||!!pending} className={`rn-switch ${isConnected?'is-on':''}`} onClick={()=>onToggle?.(current.name)}><span/></button></div><div className="rn-connection-description"><p key={current?.name}>{description}</p></div></div>
130
+ {progress&&<p role="status" className="rn-subtitle">{progress}</p>}{error&&<p role="alert" className="rn-error">{error}</p>}{continueError&&<p role="alert" className="rn-error">{continueError}</p>}
131
+ <NativeAction tabIndex={0} disabled={continuing||!!pending||(!count&&!allowEmpty)} busy={continuing} onClick={continueFlow}>{continuing?'Continuing…':'Continue'}</NativeAction>
132
+ </footer>
133
+ </div>
134
+ {directory&&<PlatformDirectory platforms={platforms} connected={connected} selected={selected} onSelect={onSelect} onClose={()=>setDirectory(false)}/>}
135
+ </section>;
136
+ }
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import logo from '../../assets/permissions/onairos.png';
3
+ import basic from '../../assets/permissions/public-profile-person.png';
4
+ import personalization from '../../assets/permissions/personalization.png';
5
+ import rawMemories from '../../assets/permissions/raw-memories.png';
6
+ const images = {basic, personalization, rawMemories};
7
+ export function NativeInfoIcon() {
8
+ return <svg className="rn-info-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v6"/><circle cx="12" cy="7.5" r=".8" fill="currentColor" stroke="none"/></svg>;
9
+ }
10
+ export function NativeAction({children, busy, ...props}) {
11
+ return <button type="button" className="rn-action" aria-busy={!!busy} {...props}>{children}</button>;
12
+ }
13
+ export function NativeWelcome({appName = 'This app', rawOnly = false, sharesRawContent = false, onContinue, onUseDifferentEmail, verifiedEmail, loading, error}) {
14
+ const ticks = [
15
+ ['Secure & private', rawOnly ? 'Encrypted. No access to your passwords.' : 'Encrypted and password-protected. No access to your credentials.'],
16
+ ['In your control', 'Choose what to share. Revoke anytime.'],
17
+ rawOnly || sharesRawContent ? ['Only what you approve', 'Review the requested raw-data access before sharing.'] : ['Review before sharing', 'Choose which context this app can access before you approve.'],
18
+ ];
19
+ return <section className="rn-screen rn-welcome" data-testid="native-welcome">
20
+ <div className="rn-scroll">
21
+ <img className="rn-brand" src={logo} alt="Onairos" />
22
+ <h1>{rawOnly ? `${appName} uses Onairos to access your data.` : `${appName} uses Onairos for context, only after your approval.`}</h1>
23
+ {!rawOnly && <p className="rn-teaser">An experience that understands you.</p>}
24
+ <div className="rn-benefits">{ticks.map(([title, body])=><div key={title}><span aria-hidden="true">✓</span><div><strong>{title}</strong><p>{body}</p></div></div>)}</div>
25
+ </div>
26
+ <footer className="rn-footer">
27
+ {!rawOnly && <div className="rn-reuse"><strong>Connect once, use forever.</strong><p>Your connections stay ready for next time.</p></div>}
28
+ {error && <p role="alert" className="rn-error">{error}</p>}
29
+ <NativeAction onClick={onContinue} disabled={loading} busy={loading}>{loading ? 'Continuing…' : verifiedEmail ? `Continue as ${verifiedEmail}` : 'Get Started'}</NativeAction>
30
+ {verifiedEmail && <button className="rn-link" onClick={onUseDifferentEmail}>Use a different email</button>}
31
+ </footer>
32
+ </section>;
33
+ }
34
+ export {default as NativeConnections} from './NativeConnections.jsx';
35
+ export function NativeConsent({appName, customTitle, rawOnly, options, selected, onToggle, connections, renderPlatform, onConnectMore, onAccept, onDecline, canSubmit, submitting, error, privacyPolicyUrl, showTime, freq, setFreq}) {
36
+ return <section className="rn-screen rn-consent" data-testid="native-consent"><div className="rn-scroll">
37
+ <img className="rn-brand rn-brand-small" src={logo} alt="Onairos"/>
38
+ <h1>{customTitle || (rawOnly ? `${appName} wants to access your data` : `${appName} wants to personalize your experience`)}</h1><p className="rn-subtitle">Choose what to share. You’re in control.</p>
39
+ <div className="rn-permissions">{options.map(option=><div className="rn-permission" key={option.id}><button type="button" role="checkbox" aria-checked={!!selected[option.id]} aria-label={option.name} disabled={option.required || option.disabled || submitting} onClick={()=>onToggle(option.id,!selected[option.id])}><img src={images[option.id]} alt=""/><span><strong>{option.id==='basic'?'Public profile':option.name}</strong><small>{option.required?'Always included':option.disabled?'Connect a supported source first':option.description}</small></span><span className={`rn-check ${selected[option.id]&&!option.disabled?'is-checked':''}`}>{selected[option.id]&&!option.disabled?'✓':''}</span></button></div>)}</div>
40
+ {showTime && <label className="rn-frequency">Update frequency<select value={freq} onChange={e=>setFreq(e.target.value)}><option value="once">One time</option><option value="weekly">Weekly</option><option value="daily">Daily</option></select></label>}
41
+ {privacyPolicyUrl && <a className="rn-privacy" href={privacyPolicyUrl} target="_blank" rel="noreferrer">How your data is used <NativeInfoIcon/></a>}
42
+ </div><footer className="rn-footer">
43
+ <div className="rn-connected-line"><div>{connections.map(renderPlatform)}</div>{onConnectMore && <button type="button" className="rn-link" disabled={submitting} onClick={onConnectMore}>{connections.length ? 'Manage connections' : 'Connect a source'} +</button>}</div>
44
+ {error && <p role="alert" className="rn-error">{error}</p>}
45
+ <NativeAction disabled={!canSubmit} busy={submitting} onClick={onAccept}>{submitting?'Approving…':rawOnly?'Accept':'Approve'}</NativeAction>
46
+ {onDecline && <button className="rn-link" disabled={submitting} onClick={onDecline}>Deny</button>}
47
+ </footer></section>;
48
+ }
@@ -160,6 +160,7 @@ const PageLayout = ({
160
160
  onClose,
161
161
  onBack,
162
162
  showBackButton = false,
163
+ nativeConnectionHeader = false,
163
164
  className = '',
164
165
  contentClassName = '',
165
166
  centerContent = true,
@@ -246,7 +247,8 @@ const PageLayout = ({
246
247
  {/* Header with navigation */}
247
248
  {showHeader && (
248
249
  <div style={headerStyle}>
249
- <div className="flex items-center justify-between">
250
+ <div className="flex items-center justify-between" style={nativeConnectionHeader ? {position:'relative'} : undefined}>
251
+ {nativeConnectionHeader && <span style={{position:'absolute',left:'50%',transform:'translateX(-50%)',fontFamily:'"DM Sans",sans-serif',fontSize:20,fontWeight:600,color:'#202024'}}>Onairos</span>}
250
252
  {/* Left side: Close button (always on left when present) */}
251
253
  <div className="flex items-center">
252
254
  {showCloseButton && onClose && (
@@ -259,7 +261,7 @@ const PageLayout = ({
259
261
  aria-label="Close"
260
262
  type="button"
261
263
  >
262
- <span style={{ fontSize: '28px', fontWeight: '300', color: isGlass ? '#FFFFFF' : COLORS.textPrimary }}>×</span>
264
+ <span style={{ fontSize: nativeConnectionHeader ? '20px' : '28px', fontWeight: '300', color: isGlass ? '#FFFFFF' : COLORS.textPrimary }}>×</span>
263
265
  </button>
264
266
  )}
265
267
  {/* Invisible spacer when no close button to maintain layout */}
@@ -870,7 +872,9 @@ const ModalPageLayout = ({
870
872
  overflow: 'hidden',
871
873
  overflowX: 'hidden',
872
874
  overscrollBehavior: 'none',
873
- touchAction: 'none',
875
+ // Native sheet content needs vertical gestures; the scroll guard below
876
+ // still prevents gestures from moving the host page.
877
+ touchAction: isCapacitorNative ? 'pan-y' : 'none',
874
878
  minHeight: 0,
875
879
  } : {}),
876
880
  // Glass theme: transition/willChange create stacking contexts that break backdrop-filter
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import logo from '../assets/permissions/onairos.png';
3
+
4
+ /** Matches RN ConnectorBrowserFrame's welcome mark and quiet thinking text. */
5
+ export default function ConnectorLoading({provider,processing=false}){
6
+ const chat=['ChatGPT','Claude'].includes(provider);
7
+ const detail={Spotify:'liked songs and playlists',Netflix:'viewing history',Sephora:'beauty profile, loves, and shopping activity',Instagram:'liked posts, saved posts, and followed accounts'}[provider]||'activity';
8
+ return <section className="rn-connector-loading" role="status" aria-live="polite">
9
+ <span className="rn-connector-mark"><img src={logo} alt="Onairos"/></span>
10
+ <span className="rn-connector-thinking">{processing?(chat?'Processing chats…':`Connecting ${provider}…`):`Sign in to ${provider}`}</span>
11
+ {!processing&&<p>{chat?'Once you’re signed in, you’ll choose which chats to connect to Onairos.':`Finish signing in to connect your ${detail} to Onairos.`}</p>}
12
+ </section>;
13
+ }
@@ -0,0 +1,115 @@
1
+ import {NETFLIX_RENDERED_EXPORT_SCRIPT} from './netflixExport.js';
2
+ import {SEPHORA_EXPORT_SCRIPT} from './rn/utils/webviewScripts/sephora.js';
3
+ import {SEPHORA_SESSION_SCRIPT} from './rn/utils/webviewScripts/sephoraSession.js';
4
+ import {HINGE_EXPORT_SCRIPT} from './rn/utils/webviewScripts/hinge.js';
5
+ import {INSTAGRAM_SESSION_SCRIPT,INSTAGRAM_EXPORT_SCRIPT} from './rn/utils/webviewScripts/instagram.js';
6
+ import {NATIVE_LOGIN_VIEWPORT_SCRIPT} from './rn/utils/webviewScripts/nativeLoginViewport.js';
7
+ import {NETFLIX_SESSION_SCRIPT,NETFLIX_PREPARE_SCRIPT} from './netflixSession.js';
8
+ import {getRequiredUserAuthHeaders} from '../utils/authHeaders.js';
9
+ import {storeCustomPayload} from './customPayload.js';
10
+ const providers={
11
+ netflix:{origins:['https://www.netflix.com'],prefix:'NETFLIX',session:NETFLIX_SESSION_SCRIPT,settle:2000,script:NETFLIX_RENDERED_EXPORT_SCRIPT,ready:path=>/^\/(browse|latest|my-list|title|viewingactivity)(\/|$)/.test(path)},
12
+ sephora:{origins:['https://www.sephora.com'],prefix:'SEPHORA',session:SEPHORA_SESSION_SCRIPT,script:SEPHORA_EXPORT_SCRIPT},
13
+ 'instagram-data':{origins:['https://www.instagram.com','https://instagram.com'],prefix:'INSTAGRAM',session:INSTAGRAM_SESSION_SCRIPT,script:INSTAGRAM_EXPORT_SCRIPT},
14
+ hinge:{origins:['https://hinge.co'],prefix:'HINGE',script:HINGE_EXPORT_SCRIPT,ready:path=>!/^\/(login|auth|signup)/.test(path)},
15
+ };
16
+ export class CustomImportSession{
17
+ constructor({plugin,platform,onState=()=>{},onComplete=()=>{},onCancel=()=>{},store=storeCustomPayload}){Object.assign(this,{plugin,platform,onState,onComplete,onCancel,store});this.provider=providers[platform];this.sessionId=crypto.randomUUID();this.active=true;this.stage='login';this.completed=0;this.listeners=[];this.control=new AbortController();}
18
+ state(stage,extra={}){if(this.active){this.stage=stage;this.onState({stage,...extra});}}
19
+ async start(){try{
20
+ if(!this.provider)throw new Error('Unsupported native scraper.');
21
+ this.authorization=getRequiredUserAuthHeaders({requireToken:true}).Authorization;
22
+ for(const [name,fn] of [['nativeImportMessage',e=>this.receive(e)],['nativeImportLifecycle',e=>this.lifecycle(e)]]){
23
+ const handle=await this.plugin.addListener(name,e=>{void Promise.resolve(fn(e)).catch(error=>this.fail(error));});
24
+ if(!this.active){await handle.remove();return;}this.listeners.push(handle);
25
+ }
26
+ await this.plugin.startNativeImport({platform:this.platform,sessionId:this.sessionId,useHostIntro:true,sessionScript:NATIVE_LOGIN_VIEWPORT_SCRIPT+(this.provider.session||'true;')});
27
+ if(!this.active)try{await this.plugin.finishNativeImport({sessionId:this.sessionId});}catch{}
28
+ }catch(error){await this.fail(error);}}
29
+ async lifecycle(e){
30
+ if(!this.active||e.sessionId!==this.sessionId)return;
31
+ if(e.status==='cancelled'){await this.cancel();this.onCancel();return;}
32
+ if(e.status==='error')throw new Error(e.message||'The provider browser ended. Please retry.');
33
+ if(e.status==='navigation'&&this.stage==='login'&&this.provider.ready){
34
+ if(this.provider.origins.includes(e.origin)&&this.readyPath===e.path&&this.readyTimer)return;
35
+ clearTimeout(this.readyTimer);
36
+ this.readyTimer=null;this.readyPath=null;
37
+ if(this.provider.origins.includes(e.origin)&&this.provider.ready(e.path)){
38
+ this.scheduleBegin(e.path);
39
+ }
40
+ }
41
+ }
42
+ scheduleBegin(path){
43
+ if(!this.active||this.stage!=='login'||(this.readyTimer&&this.readyPath===path))return;
44
+ clearTimeout(this.readyTimer);this.readyPath=path;
45
+ this.readyTimer=setTimeout(()=>void this.begin().catch(error=>this.fail(error)),this.provider.settle||0);
46
+ }
47
+ async begin(){
48
+ if(!this.active||!['login','preparing'].includes(this.stage))return;
49
+ if(this.platform==='netflix'&&!this.netflixHistoryReady){
50
+ clearTimeout(this.readyTimer);this.readyTimer=null;
51
+ await this.plugin.runNativeImportScript({sessionId:this.sessionId,script:NETFLIX_PREPARE_SCRIPT});
52
+ return;
53
+ }
54
+ clearTimeout(this.readyTimer);clearTimeout(this.timeout);this.completed=5;this.state('importing',{completed:5});
55
+ await this.plugin.setNativeImportVisible({sessionId:this.sessionId,visible:false});
56
+ if(!this.active)return;
57
+ await this.plugin.runNativeImportScript({sessionId:this.sessionId,script:this.provider.script});
58
+ if(this.active&&this.stage==='importing')this.timeout=setTimeout(()=>void this.fail(new Error('The provider took too long. Please retry.')),180000);
59
+ }
60
+ async receive(e){
61
+ if(!this.active||e.sessionId!==this.sessionId||!this.provider.origins.includes(e.origin)||typeof e.raw!=='string'||e.raw.length>4_000_000)return;
62
+ let message;try{message=JSON.parse(e.raw);}catch{return;}
63
+ if(message.type===`${this.provider.prefix}_AUTH_STATE`&&message.authenticated===true){
64
+ if(this.platform==='netflix'&&message.profileReady===true&&this.stage==='login'){
65
+ clearTimeout(this.readyTimer);this.readyTimer=null;
66
+ this.state('preparing',{completed:5});
67
+ await this.plugin.setNativeImportVisible({sessionId:this.sessionId,visible:false});
68
+ if(!this.active)return;
69
+ this.timeout=setTimeout(()=>void this.fail(new Error('Netflix’s viewing history took too long to load. Please retry.')),180000);
70
+ await this.plugin.runNativeImportScript({sessionId:this.sessionId,script:"window.location.assign('https://www.netflix.com/viewingactivity');true;"});
71
+ return;
72
+ }
73
+ if(this.platform==='netflix'&&message.historyReady===true){
74
+ this.netflixHistoryReady=true;await this.begin();return;
75
+ }
76
+ if(this.provider.settle){if(typeof message.path==='string')this.scheduleBegin(message.path);}
77
+ else await this.begin();
78
+ return;
79
+ }
80
+ if(this.stage!=='importing')return;
81
+ if(message.type===`${this.provider.prefix}_EXPORT_PROGRESS`){
82
+ if(message.stage==='debug'||String(message.message||'').startsWith('[DEBUG]'))return;
83
+ this.completed=Math.max(this.completed,Math.min(89,Number(message.progress)||5));this.onState({completed:this.completed});return;
84
+ }
85
+ if(message.type===`${this.provider.prefix}_EXPORT_ERROR`){
86
+ if(this.platform==='netflix'&&message.code==='HISTORY_UNREADABLE'){
87
+ clearTimeout(this.timeout);this.netflixHistoryReady=false;this.state('login');
88
+ await this.plugin.setNativeImportVisible({sessionId:this.sessionId,visible:true});return;
89
+ }
90
+ if(message.code==='AUTH_REQUIRED'){
91
+ clearTimeout(this.timeout);this.state('login');await this.plugin.setNativeImportVisible({sessionId:this.sessionId,visible:true});return;
92
+ }
93
+ throw new Error(message.code==='NO_DATA'?'No activity was available in this account. Please retry.':'The provider could not read your activity. Please retry.');
94
+ }
95
+ if(message.type!==`${this.provider.prefix}_EXPORT_COMPLETE`)return;
96
+ if(this.platform!=='instagram-data'&&message.success!==true)throw new Error('The provider did not confirm extraction.');
97
+ if(this.platform==='netflix'&&!message.data?.viewingHistory?.some(row=>row?.videoId&&row?.title)){
98
+ clearTimeout(this.timeout);this.netflixHistoryReady=false;this.state('login');
99
+ await this.plugin.setNativeImportVisible({sessionId:this.sessionId,visible:true});
100
+ // Keep the private session available for profile/history inspection and retry.
101
+ return;
102
+ }
103
+ this.state('saving',{completed:90});clearTimeout(this.timeout);
104
+ this.timeout=setTimeout(()=>void this.fail(new Error('Saving took too long. Please retry.')),45000);
105
+ const result=await this.store(this.platform,message.data,{signal:this.control.signal,authorization:this.authorization});
106
+ if(!this.active||this.control.signal.aborted)return;
107
+ if(getRequiredUserAuthHeaders({requireToken:true}).Authorization!==this.authorization)throw new Error('Your Onairos account changed. Please retry.');
108
+ clearTimeout(this.timeout);await this.plugin.finishNativeImport({sessionId:this.sessionId});
109
+ if(!this.active||this.control.signal.aborted)return;
110
+ this.state('complete',{completed:100,count:result.count});await this.dispose();this.onComplete();
111
+ }
112
+ async fail(error){if(!this.active)return;this.state('error',{error:error?.message||'Import failed. Please retry.'});await this.cancel();}
113
+ async dispose(){this.active=false;clearTimeout(this.readyTimer);clearTimeout(this.timeout);this.control.abort();await Promise.all(this.listeners.splice(0).map(h=>Promise.resolve(h.remove()).catch(()=>{})));}
114
+ async cancel(){await this.dispose();try{await this.plugin.finishNativeImport({sessionId:this.sessionId});}catch{}}
115
+ }
@@ -0,0 +1,29 @@
1
+ // SVG geometry ported from RN NativeImportIcon.tsx.
2
+ import React from 'react';
3
+ const categoryPaths = {
4
+ "Travel": "M22 12c0-.8-.7-1.5-1.5-1.5H15L10 3H8l2.5 7.5H5L3 8H1l1.5 4L1 16h2l2-2.5h5.5L8 21h2l5-7.5h5.5c.8 0 1.5-.7 1.5-1.5Z",
5
+ "Learning & Study": "M5 3h14v18H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm2 0v15m-2 0h14M3 19a2 2 0 0 1 2-1",
6
+ "Food & Cooking": "M4 3v5a3 3 0 0 0 6 0V3M7 3v18M18 3c-3 3-4 7-4 10h4m0-10v18",
7
+ "Work & Career": "M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2M4 7h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2Zm-2 5c6 3 14 3 20 0M12 13v3",
8
+ "Health & Wellness": "M12 21 3 12C-3 5 7-1 12 6c5-7 15-1 9 6Z",
9
+ "Finances": "M2 5h20v14H2ZM5 5a3 3 0 0 1-3 3m17-3a3 3 0 0 0 3 3M2 16a3 3 0 0 1 3 3m14 0a3 3 0 0 1 3-3M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z",
10
+ "Relationships": "M10 7a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm10 0a3 3 0 1 1-6 0 3 3 0 0 1 6 0ZM9 20H2v-2c0-3 3-5 6-4m2 6v-2a6 6 0 0 1 12 0v2Z",
11
+ "Legal": "M12 3v18m-5 0h10M3 7h18M6 7l-4 8h8Zm12 0-4 8h8Z",
12
+ "Coding & Tech": "m7 5-6 7 6 7m10-14 6 7-6 7M14 3l-4 18",
13
+ "Writing & Content": "m4 16 12-12 4 4L8 20l-5 1Zm10-10 4 4M4 16l4 4m3 1h10",
14
+ "Entertainment": "M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm6 4v8l6-4Z",
15
+ "Shopping": "M4 7h16l1 14H3ZM8 8V6a4 4 0 0 1 8 0v2",
16
+ "Other chats": "M5 3h14a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2h-8l-6 4v-4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm3 5h8m-8 4h8"
17
+ };
18
+ function NativeImportCategoryIcon({ label }) {
19
+ return <svg width={19} height={19} viewBox="0 0 24 24" fill="none" stroke="#4B5563" strokeWidth={1.7} strokeLinecap="round" strokeLinejoin="round" aria-hidden={true}><path d={categoryPaths[label] || categoryPaths["Other chats"]} fill={label === "Travel" ? "#4B5563" : "none"} strokeWidth={label === "Travel" ? 0 : 1.7} /></svg>;
20
+ }
21
+ function NativeImportIcon({ name, size = 16, color = "#737373" }) {
22
+ return <svg width={size} height={size} viewBox="0 0 24 24" fill="none" stroke={color} strokeWidth={name === "conversation" ? 1.5 : 1.8} strokeLinecap="round" strokeLinejoin="round" aria-hidden={true}>
23
+ {name === "file" ? <><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z" /><path d="M14 2v6h6" /></> : name === "close" ? <path d="m6 6 12 12M6 18 18 6" /> : name === "chevron" ? <path d="m6 9 6 6 6-6" /> : name === "conversation" ? <><path d="M15 7V5a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2v3l3-3" /><path d="M11 8h9a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2v3l-3-3h-6a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2Z" /></> : name === "chat" ? <><rect x={3} y={4} width={18} height={16} rx={3} /><path d="M7 9h6M7 13h10" /></> : name === "lock" ? <><rect x={4} y={11} width={16} height={10} rx={2} /><path d="M7 11V7a5 5 0 0 1 10 0v4" /></> : name === "active" ? <path d="m10 7 5 5-5 5" /> : <><circle cx={12} cy={12} r={9} strokeDasharray={name === "pending" ? "1.8 3.6" : void 0} />{name === "done" ? <path d="m8 12 3 3 5-6" /> : name === "empty" ? <path d="M9 12h6" /> : null}</>}
24
+ </svg>;
25
+ }
26
+ export {
27
+ NativeImportCategoryIcon,
28
+ NativeImportIcon as default
29
+ };
@@ -0,0 +1,24 @@
1
+ import React,{useEffect,useRef,useState} from 'react';
2
+ import ImportStatus from './ImportStatus.jsx';
3
+ import ImportIcon from './ImportIcon.jsx';
4
+ export const IMPORT_SUCCESS_HOLD_MS=3570;
5
+ export default function ImportProgress({provider,completed=0,total=0,label,success=false,finalizing=false,rawOnly=false,items=[],cooldown=false}){
6
+ const [expanded,setExpanded]=useState(false),[size,setSize]=useState({width:340,height:52});
7
+ const card=useRef(null);
8
+ useEffect(()=>{if(success)setExpanded(false);},[success]);
9
+ useEffect(()=>{if(!card.current||typeof ResizeObserver==='undefined')return;const observer=new ResizeObserver(([entry])=>setSize({width:entry.contentRect.width,height:entry.contentRect.height}));observer.observe(card.current);return()=>observer.disconnect();},[]);
10
+ const fraction=success?1:total?Math.min(1,Math.max(0,completed/total)):0;
11
+ const status=label||(success?`${completed} ${completed===1?'conversation has':'conversations have'} been successfully connected`:cooldown?`Waiting for ${provider}`:rawOnly?`Preparing your memories · ${completed} / ${total}`:finalizing?`Securely connecting chats to Onairos · ${completed} / ${total}`:`Reading chats from ${provider} · ${completed} / ${total}`);
12
+ return <div className="rn-import-surface"><div ref={card} className={`rn-import-card${success?' is-success':''}`}>
13
+ <button className="rn-import-card-header" disabled={success||!items.length} aria-expanded={expanded} onClick={()=>setExpanded(v=>!v)}>
14
+ <span className="rn-progress-glyph">{success?<ImportStatus status="done"/>:<ImportIcon name="conversation" size={20}/>}</span>
15
+ <span className={`rn-import-card-title${!success&&!cooldown?' is-thinking':''}`} role="status">{status}</span>{items.length>0&&!success&&<span className={`rn-topic-chevron ${expanded?'is-open':''}`} aria-hidden="true"><ImportIcon name="chevron" color="#a1a1a1"/></span>}
16
+ </button>
17
+ {cooldown&&<p className="rn-import-hint">Resuming automatically once {provider} is ready.</p>}
18
+ {expanded&&!success&&<ul className="rn-import-card-list">{items.map(item=><li key={item.id}><ImportStatus status={item.status}/><span>{item.title}</span></li>)}</ul>}
19
+ <svg className="rn-import-edge" width={size.width} height={size.height} viewBox={`0 0 ${size.width} ${size.height}`} role="progressbar" aria-label={`${provider} connection progress`} aria-valuemin={0} aria-valuemax={Math.max(1,total)} aria-valuenow={success?Math.max(1,total):completed}>
20
+ <rect x="1" y="1" width={Math.max(1,size.width-2)} height={Math.max(1,size.height-2)} rx="15" fill="none" stroke="#d4d4d4"/>
21
+ <rect x="1" y="1" width={Math.max(1,size.width-2)} height={Math.max(1,size.height-2)} rx="15" fill="none" stroke={success?'#cfd4df':'#239d76'} strokeWidth="2" pathLength="100" strokeDasharray="100" strokeDashoffset={100*(1-fraction)} opacity={fraction>0?1:0}/>
22
+ </svg>
23
+ </div></div>;
24
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ /** The RN ChatStatus geometry; SVG keeps the check centered on every text scale. */
3
+ export default function ImportStatus({status='pending'}){
4
+ const done=status==='done',importing=status==='importing';
5
+ return <svg className="rn-chat-status" width="18" height="18" viewBox="0 0 18 18" role="img" aria-label={done?'Chat connected':importing?'Connecting chat':'Waiting to connect'}>
6
+ <circle className={importing?'is-spinning':undefined} cx="9" cy="9" r="7" stroke={done||importing?'#239D76':'#D5D8DE'} strokeWidth="1.5" fill={done?'#E9F7EF':'none'} strokeLinecap="round" strokeDasharray={importing?'0.5 3.7':undefined}/>
7
+ {done&&<path className="rn-status-check" d="M5 9L8 12L13 6" fill="none" stroke="#168B57" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" strokeDasharray="13 13"/>}
8
+ </svg>;
9
+ }
@@ -0,0 +1,28 @@
1
+ import React,{useEffect,useRef,useState} from 'react';
2
+ import {OnairosChatGPTNative} from '../nativeConnectors.js';
3
+ import {NativeImportSession} from './NativeImportSession.js';
4
+ import ImportProgress,{IMPORT_SUCCESS_HOLD_MS} from './ImportProgress.jsx';
5
+ import ConnectorLoading from './ConnectorLoading.jsx';
6
+ import SmartFilter from './SmartFilter.jsx';
7
+ import {NativeAction} from '../components/parity/NativeScreens.jsx';
8
+
9
+ export default function NativeChatImport({platform='chatgpt',rawOnly=false,onClose,onConnected}){
10
+ const session=useRef(null),[attempt,setAttempt]=useState(0),[view,setView]=useState({stage:'login',items:[],completed:0,total:0});
11
+ const callbacks=useRef({onClose,onConnected});callbacks.current={onClose,onConnected};
12
+ useEffect(()=>{
13
+ let mounted=true,completionTimer;
14
+ const flow=new NativeImportSession({plugin:OnairosChatGPTNative,platform,rawOnly,onState:patch=>{
15
+ if(!mounted)return;
16
+ setView(previous=>({...previous,...patch,items:patch.items||previous.items,...(patch.item?{items:previous.items.map(item=>item.id===patch.item.id?{...item,status:patch.item.status}:item)}:{})}));
17
+ },onComplete:payload=>{completionTimer=setTimeout(()=>{if(mounted)callbacks.current.onConnected(payload);},IMPORT_SUCCESS_HOLD_MS);},onCancel:()=>callbacks.current.onClose()});
18
+ session.current=flow;void flow.start();return()=>{mounted=false;clearTimeout(completionTimer);void flow.cancel();};
19
+ },[platform,rawOnly,attempt]);
20
+ const close=()=>{void session.current?.cancel();onClose();};
21
+ const name=platform==='claude'?'Claude':'ChatGPT';
22
+ return <div className="rn-import-overlay" role="dialog" aria-modal="true" aria-label={`${name} import`}>
23
+ {view.stage==='topics'?<SmartFilter key={attempt} provider={name} items={view.items} filesAvailable={rawOnly} onClose={close} onImport={(items,options)=>{void session.current.begin(items,options).catch(error=>session.current.fail(error));}}/>:
24
+ <><header className="rn-import-header"><button onClick={close} aria-label={`Close ${name}`}>×</button><strong>Onairos</strong><span/></header>
25
+ {['importing','saving','complete'].includes(view.stage)?<ImportProgress provider={name} completed={view.completed} total={view.total} items={view.items} finalizing={view.stage==='saving'} rawOnly={rawOnly} success={view.stage==='complete'}/>:
26
+ view.stage==='error'?<div className="rn-import-progress"><h1>Let’s try that again</h1><p role="alert">{view.error}</p><NativeAction onClick={()=>{setView({stage:'login',items:[],completed:0,total:0});setAttempt(x=>x+1);}}>Try again</NativeAction></div>:<ConnectorLoading provider={name} processing={view.stage==='scanning'}/>}</>}
27
+ </div>;
28
+ }