@adminide-stack/yantra-mobile 12.0.163 → 12.0.164-alpha.0
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/lib/components/CustomDrawer.js +8 -1
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/components/NavigationHeader/HeaderSheet.js +23 -8
- package/lib/components/NavigationHeader/HeaderSheet.js.map +1 -1
- package/lib/components/NavigationHeader/HeaderSkillsButton.js +6 -3
- package/lib/components/NavigationHeader/HeaderSkillsButton.js.map +1 -1
- package/lib/components/NavigationHeader/HeaderSystemButtons.js +7 -0
- package/lib/components/NavigationHeader/HeaderSystemButtons.js.map +1 -0
- package/lib/components/NavigationHeader/HeaderTasksButton.js +144 -93
- package/lib/components/NavigationHeader/HeaderTasksButton.js.map +1 -1
- package/lib/components/NavigationHeader/NavigationHeader.js +2 -2
- package/lib/components/NavigationHeader/NavigationHeader.js.map +1 -1
- package/lib/features/agent-chat/NativeAgentChat.js +3 -3
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/audio-input/AudioRecorderPanel.js +1 -1
- package/lib/features/audio-input/NativeDictationBar.js +1 -1
- package/lib/features/canvas/CanvasExperience.js +1 -1
- package/lib/features/channels/ConnectAppsSheet.js +1 -1
- package/lib/features/channels/HomeImessage.js +1 -1
- package/lib/features/channels/useChannelsApi.js +1 -1
- package/lib/features/chat/OneTimeCodePrompt.js +1 -1
- package/lib/features/chat/QueuedFollowUps.js +4 -3
- package/lib/features/chat/QueuedFollowUps.js.map +1 -1
- package/lib/features/chat/TemporaryChatView.js +238 -0
- package/lib/features/chat/TemporaryChatView.js.map +1 -0
- package/lib/features/chat/connectorConnect.js +1 -1
- package/lib/features/chat/temporaryChatStore.js +59 -7
- package/lib/features/chat/temporaryChatStore.js.map +1 -1
- package/lib/features/chat/withTemporaryChat.js +24 -0
- package/lib/features/chat/withTemporaryChat.js.map +1 -0
- package/lib/features/dictate/recorderStatus.js +22 -0
- package/lib/features/dictate/recorderStatus.js.map +1 -0
- package/lib/features/dictate/useDictationRecorder.js +4 -4
- package/lib/features/dictate/useDictationRecorder.js.map +1 -1
- package/lib/features/home/sky/HomeSky.js +1 -1
- package/lib/features/skills/SkillTemplatePicker.js +107 -143
- package/lib/features/skills/SkillTemplatePicker.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +402 -33
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/components/CloudSheet.js +35 -15
- package/lib/features/webbuilder/components/CloudSheet.js.map +1 -1
- package/lib/features/webbuilder/components/Credits.js +149 -0
- package/lib/features/webbuilder/components/Credits.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewFrame.js +15 -4
- package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +5 -2
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +58 -8
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectSheets.js +29 -6
- package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectsScreen.js +16 -7
- package/lib/features/webbuilder/components/ProjectsScreen.js.map +1 -1
- package/lib/features/webbuilder/components/PublishSheet.js +133 -2
- package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
- package/lib/features/webbuilder/components/RetentionBanner.js +130 -0
- package/lib/features/webbuilder/components/RetentionBanner.js.map +1 -0
- package/lib/features/webbuilder/components/ShareSheet.js +265 -0
- package/lib/features/webbuilder/components/ShareSheet.js.map +1 -0
- package/lib/features/webbuilder/components/SiteStatusSheet.js +533 -0
- package/lib/features/webbuilder/components/SiteStatusSheet.js.map +1 -0
- package/lib/features/webbuilder/components/StudioHome.js +8 -1
- package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
- package/lib/features/webbuilder/components/TemplateSuggestions.js +98 -0
- package/lib/features/webbuilder/components/TemplateSuggestions.js.map +1 -0
- package/lib/features/webbuilder/connectorTemplates.js +3 -3
- package/lib/features/webbuilder/connectorTemplates.js.map +1 -1
- package/lib/features/webbuilder/creditsLinks.js +5 -0
- package/lib/features/webbuilder/creditsLinks.js.map +1 -0
- package/lib/features/webbuilder/previewAccess.js +207 -0
- package/lib/features/webbuilder/previewAccess.js.map +1 -0
- package/lib/features/webbuilder/previewProbe.js +49 -1
- package/lib/features/webbuilder/previewProbe.js.map +1 -1
- package/lib/features/webbuilder/readiness.js +14 -0
- package/lib/features/webbuilder/readiness.js.map +1 -0
- package/lib/features/webbuilder/shareLink.js +26 -0
- package/lib/features/webbuilder/shareLink.js.map +1 -0
- package/lib/features/webbuilder/templateCover.js +11 -0
- package/lib/features/webbuilder/templateCover.js.map +1 -0
- package/lib/features/webbuilder/templateSuggestions.js +112 -0
- package/lib/features/webbuilder/templateSuggestions.js.map +1 -0
- package/lib/features/webbuilder/useGithubAutoSync.js +83 -0
- package/lib/features/webbuilder/useGithubAutoSync.js.map +1 -0
- package/lib/features/webbuilder/usePreviewAccess.js +61 -0
- package/lib/features/webbuilder/usePreviewAccess.js.map +1 -0
- package/lib/features/webbuilder/useWebBuilderCredits.js +99 -0
- package/lib/features/webbuilder/useWebBuilderCredits.js.map +1 -0
- package/lib/features/webbuilder/web/credits/credits.js +203 -0
- package/lib/features/webbuilder/web/credits/credits.js.map +1 -0
- package/lib/features/webbuilder/web/credits/creditsReader.js +65 -0
- package/lib/features/webbuilder/web/credits/creditsReader.js.map +1 -0
- package/lib/features/webbuilder/web/data/cloud.js +3 -3
- package/lib/features/webbuilder/web/data/cloud.js.map +1 -1
- package/lib/features/webbuilder/web/data/database.js +4 -1
- package/lib/features/webbuilder/web/data/database.js.map +1 -1
- package/lib/features/webbuilder/web/github/autoSync.js +231 -0
- package/lib/features/webbuilder/web/github/autoSync.js.map +1 -0
- package/lib/features/webbuilder/web/github/autoSyncEngine.js +367 -0
- package/lib/features/webbuilder/web/github/autoSyncEngine.js.map +1 -0
- package/lib/features/webbuilder/web/github/githubSync.js +54 -0
- package/lib/features/webbuilder/web/github/githubSync.js.map +1 -0
- package/lib/features/webbuilder/web/history/versions.js +83 -0
- package/lib/features/webbuilder/web/history/versions.js.map +1 -0
- package/lib/features/webbuilder/web/project/retention.js +217 -0
- package/lib/features/webbuilder/web/project/retention.js.map +1 -0
- package/lib/features/webbuilder/web/publish/actionErrors.js +81 -0
- package/lib/features/webbuilder/web/publish/actionErrors.js.map +1 -0
- package/lib/features/webbuilder/web/publish/publishSteps.js +86 -0
- package/lib/features/webbuilder/web/publish/publishSteps.js.map +1 -0
- package/lib/features/webbuilder/web/publish/siteAddress.js +79 -0
- package/lib/features/webbuilder/web/publish/siteAddress.js.map +1 -0
- package/lib/features/webbuilder/web/publish/siteHealth.js +497 -0
- package/lib/features/webbuilder/web/publish/siteHealth.js.map +1 -0
- package/lib/features/webbuilder/web/publish/siteInsights.js +145 -0
- package/lib/features/webbuilder/web/publish/siteInsights.js.map +1 -0
- package/lib/features/webbuilder/web/sharing/roles.js +108 -2
- package/lib/features/webbuilder/web/sharing/roles.js.map +1 -1
- package/lib/features/webbuilder/web/sharing/share.js +52 -0
- package/lib/features/webbuilder/web/sharing/share.js.map +1 -0
- package/lib/features/webbuilder/web/sharing/sharingApi.js +199 -0
- package/lib/features/webbuilder/web/sharing/sharingApi.js.map +1 -0
- package/lib/features/webbuilder/web/webServices.js +13 -2
- package/lib/features/webbuilder/web/webServices.js.map +1 -1
- package/lib/features/webbuilder/webbuilderPrompts.js +4 -1
- package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
- package/lib/features/webbuilder/workflow.js +2 -2
- package/lib/features/webbuilder/workflow.js.map +1 -1
- package/lib/hooks/useSurfaceJobs.js +113 -28
- package/lib/hooks/useSurfaceJobs.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/screens/Chat/index.js +3 -2
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +1 -1
- package/lib/screens/Home/components/BuildTemplatesSection.js +1 -1
- package/lib/screens/Home/components/ChooseTemplateModal.js +1 -1
- package/lib/screens/Home/components/HomeHero.js +1 -1
- package/lib/screens/Home/components/HomeSuggestions.js +1 -1
- package/lib/screens/Home/components/TemplateBrowserModal.js +1 -1
- package/lib/screens/Home/index.js +1 -1
- package/lib/screens/Home/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/index.js +1 -1
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js +33 -3
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +33 -13
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderJobs.js +11 -4
- package/lib/screens/WebBuilderNative/useWebBuilderJobs.js.map +1 -1
- package/lib/screens/WebBuilderNative/webbuilderTransport.js +1 -1
- package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
- package/lib/services/brainQuickReply.js +47 -14
- package/lib/services/brainQuickReply.js.map +1 -1
- package/package.json +4 -4
- package/lib/components/NavigationHeader/HeaderMoreMenu.js +0 -78
- package/lib/components/NavigationHeader/HeaderMoreMenu.js.map +0 -1
- package/lib/components/NavigationHeader/HeaderSettingsMenu.js +0 -132
- package/lib/components/NavigationHeader/HeaderSettingsMenu.js.map +0 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import {jsxs,jsx}from'react/jsx-runtime';import {useSyncExternalStore,useState,useRef,useMemo,useCallback}from'react';import {useWindowDimensions,Keyboard,View,StyleSheet,Text,Pressable,ScrollView}from'react-native';import {InputToolBar}from'@admin-layout/gluestack-ui-mobile';import {MaterialCommunityIcons}from'@expo/vector-icons';import {useSafeAreaInsets}from'react-native-safe-area-context';import {KeyboardAwareScreen,KeyboardComposerDock}from'../../components/KeyboardComposerDock.js';import {YantraMascot}from'../../components/mascot/YantraMascot.js';import {greetingFor}from'../../screens/Home/components/homeCatalog.js';import {brainCompleteViaBrain}from'../../services/brainQuickReply.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';import {mobileColors}from'../../theme/mobileTokens.js';import {AssistantMarkdown}from'./AssistantMarkdown.js';import {subscribeTemporaryChat,getTemporaryChat,setTemporaryChatActive,clearTemporaryMessages,appendTemporaryMessage,setTemporaryError,setTemporaryLoading}from'./temporaryChatStore.js';const TEMPORARY_MODEL = "yantra-brain/smart";
|
|
2
|
+
const SYSTEM_PROMPT = "You are Yantra, a helpful assistant. This is a temporary chat that is not saved anywhere. Answer directly and concisely.";
|
|
3
|
+
const REPLY_MAX_TOKENS = 1500;
|
|
4
|
+
const REPLY_TIMEOUT_MS = 6e4;
|
|
5
|
+
const OPENERS = ["What shall we think through?", "What are we building today?", "What shall we untangle?", "Where shall we start?", "What\u2019s on your mind?"];
|
|
6
|
+
function newId() {
|
|
7
|
+
return `tmp_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
8
|
+
}
|
|
9
|
+
async function sendTemporary(text) {
|
|
10
|
+
const trimmed = text.trim();
|
|
11
|
+
if (!trimmed || getTemporaryChat().loading) return;
|
|
12
|
+
appendTemporaryMessage({
|
|
13
|
+
id: newId(),
|
|
14
|
+
role: "user",
|
|
15
|
+
content: trimmed
|
|
16
|
+
});
|
|
17
|
+
setTemporaryError(null);
|
|
18
|
+
setTemporaryLoading(true);
|
|
19
|
+
const history = getTemporaryChat().messages.map((m) => ({
|
|
20
|
+
role: m.role,
|
|
21
|
+
content: m.content
|
|
22
|
+
}));
|
|
23
|
+
try {
|
|
24
|
+
const reply = await brainCompleteViaBrain([{
|
|
25
|
+
role: "system",
|
|
26
|
+
content: SYSTEM_PROMPT
|
|
27
|
+
}, ...history], {
|
|
28
|
+
model: TEMPORARY_MODEL,
|
|
29
|
+
maxTokens: REPLY_MAX_TOKENS,
|
|
30
|
+
timeoutMs: REPLY_TIMEOUT_MS
|
|
31
|
+
});
|
|
32
|
+
if (!getTemporaryChat().active) return;
|
|
33
|
+
if (reply) appendTemporaryMessage({
|
|
34
|
+
id: newId(),
|
|
35
|
+
role: "assistant",
|
|
36
|
+
content: reply
|
|
37
|
+
});
|
|
38
|
+
else setTemporaryError("No answer came back. Try again.");
|
|
39
|
+
} finally {
|
|
40
|
+
setTemporaryLoading(false);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function TemporaryChatView() {
|
|
44
|
+
const {
|
|
45
|
+
messages,
|
|
46
|
+
loading,
|
|
47
|
+
error
|
|
48
|
+
} = useSyncExternalStore(subscribeTemporaryChat, getTemporaryChat, getTemporaryChat);
|
|
49
|
+
const {
|
|
50
|
+
isDark
|
|
51
|
+
} = useAppTheme();
|
|
52
|
+
const c = mobileColors(isDark);
|
|
53
|
+
const insets = useSafeAreaInsets();
|
|
54
|
+
const {
|
|
55
|
+
width: screenWidth
|
|
56
|
+
} = useWindowDimensions();
|
|
57
|
+
const contentMaxWidth = Math.min(720, Math.max(360, screenWidth - 24));
|
|
58
|
+
const [input, setInput] = useState("");
|
|
59
|
+
const inputRef = useRef(null);
|
|
60
|
+
const scrollRef = useRef(null);
|
|
61
|
+
const greeting = useMemo(() => ({
|
|
62
|
+
eyebrow: greetingFor((/* @__PURE__ */ new Date()).getHours()),
|
|
63
|
+
opener: OPENERS[Math.floor(Math.random() * OPENERS.length)]
|
|
64
|
+
}), []);
|
|
65
|
+
const hasMessages = messages.length > 0;
|
|
66
|
+
const canSend = input.trim().length > 0 && !loading;
|
|
67
|
+
const submit = useCallback(() => {
|
|
68
|
+
const text = input.trim();
|
|
69
|
+
if (!text || getTemporaryChat().loading) return;
|
|
70
|
+
setInput("");
|
|
71
|
+
void sendTemporary(text);
|
|
72
|
+
}, [input]);
|
|
73
|
+
const inputConfig = useMemo(() => ({
|
|
74
|
+
value: input,
|
|
75
|
+
onChange: (e) => setInput(e.nativeEvent.text),
|
|
76
|
+
placeholder: "Ask anything (temporary)\u2026",
|
|
77
|
+
inputRef
|
|
78
|
+
}), [input]);
|
|
79
|
+
const micSendButton = useMemo(() => ({
|
|
80
|
+
hasContent: true,
|
|
81
|
+
onSend: () => {
|
|
82
|
+
Keyboard.dismiss();
|
|
83
|
+
submit();
|
|
84
|
+
},
|
|
85
|
+
onMic: () => void 0,
|
|
86
|
+
disabled: !canSend,
|
|
87
|
+
isLoading: loading
|
|
88
|
+
}), [canSend, loading, submit]);
|
|
89
|
+
const temporaryChip = /* @__PURE__ */ jsxs(View, { style: styles.chip, children: [
|
|
90
|
+
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "ghost-outline", size: 16, color: c.textMuted }),
|
|
91
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.chipText, {
|
|
92
|
+
color: c.textMuted
|
|
93
|
+
}], numberOfLines: 1, children: "Temporary \xB7 not saved" }),
|
|
94
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: () => setTemporaryChatActive(false), accessibilityRole: "button", accessibilityLabel: "Exit temporary chat", hitSlop: 8, children: /* @__PURE__ */ jsx(Text, { style: [styles.chipText, styles.exit, {
|
|
95
|
+
color: c.text
|
|
96
|
+
}], children: "Exit" }) })
|
|
97
|
+
] });
|
|
98
|
+
const composer = /* @__PURE__ */ jsx(InputToolBar, { inputConfig, leftCustomRender: temporaryChip, micSendButton });
|
|
99
|
+
return /* @__PURE__ */ jsxs(KeyboardAwareScreen, { style: {
|
|
100
|
+
backgroundColor: c.bg
|
|
101
|
+
}, children: [
|
|
102
|
+
hasMessages ? /* @__PURE__ */ jsxs(ScrollView, { ref: scrollRef, style: styles.flex, contentContainerStyle: styles.transcript, keyboardShouldPersistTaps: "handled", onContentSizeChange: () => {
|
|
103
|
+
var _a;
|
|
104
|
+
return (_a = scrollRef.current) == null ? void 0 : _a.scrollToEnd({
|
|
105
|
+
animated: true
|
|
106
|
+
});
|
|
107
|
+
}, children: [
|
|
108
|
+
messages.map((m) => m.role === "user" ? /* @__PURE__ */ jsx(View, { style: [styles.userBubble, {
|
|
109
|
+
backgroundColor: c.surfaceMuted
|
|
110
|
+
}], children: /* @__PURE__ */ jsx(Text, { style: [styles.userText, {
|
|
111
|
+
color: c.text
|
|
112
|
+
}], children: m.content }) }, m.id) : /* @__PURE__ */ jsx(View, { style: styles.assistant, children: /* @__PURE__ */ jsx(AssistantMarkdown, { text: m.content, isDark }) }, m.id)),
|
|
113
|
+
loading ? /* @__PURE__ */ jsxs(View, { style: styles.thinking, accessibilityLiveRegion: "polite", children: [
|
|
114
|
+
/* @__PURE__ */ jsx(YantraMascot, { mode: "working", size: 28, shadowColor: c.text }),
|
|
115
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.thinkingText, {
|
|
116
|
+
color: c.textMuted
|
|
117
|
+
}], children: "Thinking\u2026" })
|
|
118
|
+
] }) : null,
|
|
119
|
+
error ? /* @__PURE__ */ jsxs(Text, { style: [styles.error, {
|
|
120
|
+
color: c.dangerText
|
|
121
|
+
}], children: [
|
|
122
|
+
"Couldn't reach the model: ",
|
|
123
|
+
error
|
|
124
|
+
] }) : null,
|
|
125
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: clearTemporaryMessages, accessibilityRole: "button", style: styles.clear, children: /* @__PURE__ */ jsx(Text, { style: [styles.clearText, {
|
|
126
|
+
color: c.textMuted
|
|
127
|
+
}], children: "Clear temporary chat" }) })
|
|
128
|
+
] }) : /* @__PURE__ */ jsxs(View, { style: styles.empty, children: [
|
|
129
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.eyebrow, {
|
|
130
|
+
color: c.textMuted
|
|
131
|
+
}], children: greeting.eyebrow }),
|
|
132
|
+
/* @__PURE__ */ jsxs(View, { style: styles.openerRow, children: [
|
|
133
|
+
/* @__PURE__ */ jsx(YantraMascot, { mode: "idle", size: 34, shadowColor: c.text }),
|
|
134
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.opener, {
|
|
135
|
+
color: c.text
|
|
136
|
+
}], children: greeting.opener })
|
|
137
|
+
] })
|
|
138
|
+
] }),
|
|
139
|
+
/* @__PURE__ */ jsx(KeyboardComposerDock, { closedInset: insets.bottom, onSwipeUp: () => {
|
|
140
|
+
var _a;
|
|
141
|
+
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
142
|
+
}, children: /* @__PURE__ */ jsx(View, { style: [styles.dock, {
|
|
143
|
+
width: contentMaxWidth
|
|
144
|
+
}], children: composer }) })
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
const styles = StyleSheet.create({
|
|
148
|
+
flex: {
|
|
149
|
+
flex: 1
|
|
150
|
+
},
|
|
151
|
+
transcript: {
|
|
152
|
+
paddingHorizontal: 16,
|
|
153
|
+
paddingTop: 16,
|
|
154
|
+
paddingBottom: 8,
|
|
155
|
+
gap: 14
|
|
156
|
+
},
|
|
157
|
+
userBubble: {
|
|
158
|
+
alignSelf: "flex-end",
|
|
159
|
+
maxWidth: "85%",
|
|
160
|
+
borderRadius: 18,
|
|
161
|
+
paddingHorizontal: 14,
|
|
162
|
+
paddingVertical: 10
|
|
163
|
+
},
|
|
164
|
+
userText: {
|
|
165
|
+
fontSize: 15,
|
|
166
|
+
lineHeight: 21
|
|
167
|
+
},
|
|
168
|
+
assistant: {
|
|
169
|
+
alignSelf: "stretch"
|
|
170
|
+
},
|
|
171
|
+
thinking: {
|
|
172
|
+
flexDirection: "row",
|
|
173
|
+
alignItems: "center",
|
|
174
|
+
gap: 8
|
|
175
|
+
},
|
|
176
|
+
thinkingText: {
|
|
177
|
+
fontSize: 14
|
|
178
|
+
},
|
|
179
|
+
error: {
|
|
180
|
+
fontSize: 14
|
|
181
|
+
},
|
|
182
|
+
clear: {
|
|
183
|
+
alignSelf: "flex-end",
|
|
184
|
+
paddingVertical: 4
|
|
185
|
+
},
|
|
186
|
+
clearText: {
|
|
187
|
+
fontSize: 12,
|
|
188
|
+
textDecorationLine: "underline"
|
|
189
|
+
},
|
|
190
|
+
empty: {
|
|
191
|
+
flex: 1,
|
|
192
|
+
alignItems: "center",
|
|
193
|
+
justifyContent: "center",
|
|
194
|
+
paddingHorizontal: 20
|
|
195
|
+
},
|
|
196
|
+
eyebrow: {
|
|
197
|
+
fontSize: 14,
|
|
198
|
+
fontWeight: "500",
|
|
199
|
+
letterSpacing: 0.3,
|
|
200
|
+
marginBottom: 6
|
|
201
|
+
},
|
|
202
|
+
openerRow: {
|
|
203
|
+
flexDirection: "row",
|
|
204
|
+
alignItems: "center",
|
|
205
|
+
gap: 8,
|
|
206
|
+
flexWrap: "wrap",
|
|
207
|
+
justifyContent: "center"
|
|
208
|
+
},
|
|
209
|
+
opener: {
|
|
210
|
+
fontSize: 26,
|
|
211
|
+
fontFamily: "Georgia",
|
|
212
|
+
letterSpacing: -0.3,
|
|
213
|
+
textAlign: "center"
|
|
214
|
+
},
|
|
215
|
+
dock: {
|
|
216
|
+
alignSelf: "center",
|
|
217
|
+
paddingHorizontal: 14,
|
|
218
|
+
paddingTop: 4,
|
|
219
|
+
paddingBottom: 8
|
|
220
|
+
},
|
|
221
|
+
chip: {
|
|
222
|
+
flexShrink: 1,
|
|
223
|
+
flexDirection: "row",
|
|
224
|
+
alignItems: "center",
|
|
225
|
+
gap: 6,
|
|
226
|
+
minWidth: 0,
|
|
227
|
+
paddingLeft: 4
|
|
228
|
+
},
|
|
229
|
+
chipText: {
|
|
230
|
+
fontSize: 13,
|
|
231
|
+
lineHeight: 18,
|
|
232
|
+
flexShrink: 1
|
|
233
|
+
},
|
|
234
|
+
exit: {
|
|
235
|
+
textDecorationLine: "underline",
|
|
236
|
+
fontWeight: "600"
|
|
237
|
+
}
|
|
238
|
+
});export{TemporaryChatView};//# sourceMappingURL=TemporaryChatView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemporaryChatView.js","sources":["../../../src/features/chat/TemporaryChatView.tsx"],"sourcesContent":["/**\n * The temporary (\"incognito\") chat surface - the browser's TemporaryChatView for the phone.\n *\n * Its own isolated surface, not a gated fork of the main chat: nothing here can reach the\n * agent connection, create a channel or save a message, so \"saved nowhere\" holds by\n * construction. Sends are a stateless yantra-brain completion (brainCompleteViaBrain) with\n * the whole transcript each turn as the model's only memory - no tools, skills or\n * connectors; a temporary chat is a plain model exchange, as on the web.\n */\nimport React, { useCallback, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport {\n Keyboard,\n Pressable,\n ScrollView,\n StyleSheet,\n Text,\n View,\n useWindowDimensions,\n type NativeSyntheticEvent,\n type TextInput,\n type TextInputChangeEventData,\n} from 'react-native';\nimport { InputToolBar } from '@admin-layout/gluestack-ui-mobile';\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { KeyboardAwareScreen, KeyboardComposerDock } from '../../components/KeyboardComposerDock';\nimport { YantraMascot } from '../../components/mascot/YantraMascot';\nimport { greetingFor } from '../../screens/Home/components/homeCatalog';\nimport { brainCompleteViaBrain } from '../../services/brainQuickReply';\nimport { useAppTheme } from '../../theme/AppThemeProvider';\nimport { mobileColors } from '../../theme/mobileTokens';\nimport { AssistantMarkdown } from './AssistantMarkdown';\nimport {\n appendTemporaryMessage,\n clearTemporaryMessages,\n getTemporaryChat,\n setTemporaryChatActive,\n setTemporaryError,\n setTemporaryLoading,\n subscribeTemporaryChat,\n} from './temporaryChatStore';\n\n/** Better answers than the fast tier for a person-facing chat; still stateless (web TEMPORARY_MODEL). */\nconst TEMPORARY_MODEL = 'yantra-brain/smart';\nconst SYSTEM_PROMPT =\n 'You are Yantra, a helpful assistant. This is a temporary chat that is not saved anywhere. ' +\n 'Answer directly and concisely.';\nconst REPLY_MAX_TOKENS = 1500;\nconst REPLY_TIMEOUT_MS = 60_000;\n\n/** The web's openers, drawn once per session. */\nconst OPENERS = [\n 'What shall we think through?',\n 'What are we building today?',\n 'What shall we untangle?',\n 'Where shall we start?',\n 'What’s on your mind?',\n];\n\nfunction newId(): string {\n return `tmp_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;\n}\n\n/** One user turn; appends the reply. No-op while a turn is in flight (read live, not from a render). */\nasync function sendTemporary(text: string): Promise<void> {\n const trimmed = text.trim();\n if (!trimmed || getTemporaryChat().loading) return;\n appendTemporaryMessage({ id: newId(), role: 'user', content: trimmed });\n setTemporaryError(null);\n setTemporaryLoading(true);\n const history = getTemporaryChat().messages.map((m) => ({ role: m.role, content: m.content }));\n try {\n const reply = await brainCompleteViaBrain([{ role: 'system', content: SYSTEM_PROMPT }, ...history], {\n model: TEMPORARY_MODEL,\n maxTokens: REPLY_MAX_TOKENS,\n timeoutMs: REPLY_TIMEOUT_MS,\n });\n // Exited while it ran: the session is gone, so is its reply.\n if (!getTemporaryChat().active) return;\n if (reply) appendTemporaryMessage({ id: newId(), role: 'assistant', content: reply });\n else setTemporaryError('No answer came back. Try again.');\n } finally {\n setTemporaryLoading(false);\n }\n}\n\nexport function TemporaryChatView() {\n const { messages, loading, error } = useSyncExternalStore(\n subscribeTemporaryChat,\n getTemporaryChat,\n getTemporaryChat,\n );\n const { isDark } = useAppTheme();\n const c = mobileColors(isDark);\n const insets = useSafeAreaInsets();\n // The home composer's width (HomeScreen `contentMaxWidth`).\n const { width: screenWidth } = useWindowDimensions();\n const contentMaxWidth = Math.min(720, Math.max(360, screenWidth - 24));\n const [input, setInput] = useState('');\n const inputRef = useRef<TextInput>(null);\n const scrollRef = useRef<ScrollView>(null);\n const greeting = useMemo(\n () => ({\n eyebrow: greetingFor(new Date().getHours()),\n opener: OPENERS[Math.floor(Math.random() * OPENERS.length)],\n }),\n [],\n );\n const hasMessages = messages.length > 0;\n const canSend = input.trim().length > 0 && !loading;\n\n const submit = useCallback(() => {\n const text = input.trim();\n if (!text || getTemporaryChat().loading) return;\n setInput('');\n void sendTemporary(text);\n }, [input]);\n\n const inputConfig = useMemo(\n () => ({\n value: input,\n onChange: (e: NativeSyntheticEvent<TextInputChangeEventData>) => setInput(e.nativeEvent.text),\n placeholder: 'Ask anything (temporary)…',\n inputRef,\n }),\n [input],\n );\n // The main composer's send button; a temporary chat has no voice, so it never turns into the mic.\n const micSendButton = useMemo(\n () => ({\n hasContent: true,\n onSend: () => {\n Keyboard.dismiss();\n submit();\n },\n onMic: () => undefined,\n disabled: !canSend,\n isLoading: loading,\n }),\n [canSend, loading, submit],\n );\n // The web composer's quiet \"Temporary\" marker, in place of the mode buttons.\n const temporaryChip = (\n <View style={styles.chip}>\n <MaterialCommunityIcons name=\"ghost-outline\" size={16} color={c.textMuted} />\n <Text style={[styles.chipText, { color: c.textMuted }]} numberOfLines={1}>\n Temporary · not saved\n </Text>\n <Pressable\n onPress={() => setTemporaryChatActive(false)}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Exit temporary chat\"\n hitSlop={8}\n >\n <Text style={[styles.chipText, styles.exit, { color: c.text }]}>Exit</Text>\n </Pressable>\n </View>\n );\n const composer = (\n <InputToolBar inputConfig={inputConfig} leftCustomRender={temporaryChip} micSendButton={micSendButton} />\n );\n\n return (\n <KeyboardAwareScreen style={{ backgroundColor: c.bg }}>\n {hasMessages ? (\n <ScrollView\n ref={scrollRef}\n style={styles.flex}\n contentContainerStyle={styles.transcript}\n keyboardShouldPersistTaps=\"handled\"\n onContentSizeChange={() => scrollRef.current?.scrollToEnd({ animated: true })}\n >\n {messages.map((m) =>\n m.role === 'user' ? (\n <View key={m.id} style={[styles.userBubble, { backgroundColor: c.surfaceMuted }]}>\n <Text style={[styles.userText, { color: c.text }]}>{m.content}</Text>\n </View>\n ) : (\n <View key={m.id} style={styles.assistant}>\n <AssistantMarkdown text={m.content} isDark={isDark} />\n </View>\n ),\n )}\n {loading ? (\n <View style={styles.thinking} accessibilityLiveRegion=\"polite\">\n <YantraMascot mode=\"working\" size={28} shadowColor={c.text} />\n <Text style={[styles.thinkingText, { color: c.textMuted }]}>Thinking…</Text>\n </View>\n ) : null}\n {error ? (\n <Text style={[styles.error, { color: c.dangerText }]}>\n Couldn't reach the model: {error}\n </Text>\n ) : null}\n <Pressable onPress={clearTemporaryMessages} accessibilityRole=\"button\" style={styles.clear}>\n <Text style={[styles.clearText, { color: c.textMuted }]}>Clear temporary chat</Text>\n </Pressable>\n </ScrollView>\n ) : (\n <View style={styles.empty}>\n <Text style={[styles.eyebrow, { color: c.textMuted }]}>{greeting.eyebrow}</Text>\n <View style={styles.openerRow}>\n <YantraMascot mode=\"idle\" size={34} shadowColor={c.text} />\n <Text style={[styles.opener, { color: c.text }]}>{greeting.opener}</Text>\n </View>\n </View>\n )}\n <KeyboardComposerDock closedInset={insets.bottom} onSwipeUp={() => inputRef.current?.focus()}>\n <View style={[styles.dock, { width: contentMaxWidth }]}>{composer}</View>\n </KeyboardComposerDock>\n </KeyboardAwareScreen>\n );\n}\n\nconst styles = StyleSheet.create({\n flex: { flex: 1 },\n transcript: { paddingHorizontal: 16, paddingTop: 16, paddingBottom: 8, gap: 14 },\n userBubble: {\n alignSelf: 'flex-end',\n maxWidth: '85%',\n borderRadius: 18,\n paddingHorizontal: 14,\n paddingVertical: 10,\n },\n userText: { fontSize: 15, lineHeight: 21 },\n assistant: { alignSelf: 'stretch' },\n thinking: { flexDirection: 'row', alignItems: 'center', gap: 8 },\n thinkingText: { fontSize: 14 },\n error: { fontSize: 14 },\n clear: { alignSelf: 'flex-end', paddingVertical: 4 },\n clearText: { fontSize: 12, textDecorationLine: 'underline' },\n empty: { flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: 20 },\n eyebrow: { fontSize: 14, fontWeight: '500', letterSpacing: 0.3, marginBottom: 6 },\n openerRow: { flexDirection: 'row', alignItems: 'center', gap: 8, flexWrap: 'wrap', justifyContent: 'center' },\n opener: { fontSize: 26, fontFamily: 'Georgia', letterSpacing: -0.3, textAlign: 'center' },\n dock: { alignSelf: 'center', paddingHorizontal: 14, paddingTop: 4, paddingBottom: 8 },\n chip: { flexShrink: 1, flexDirection: 'row', alignItems: 'center', gap: 6, minWidth: 0, paddingLeft: 4 },\n chipText: { fontSize: 13, lineH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B;AAAA,EACA,OAAS,EAAA;AAAA,IACP,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,KAAA;AAAA,IACZ,aAAe,EAAA,GAAA;AAAA,IACf,YAAc,EAAA;AAAA,GAChB;AAAA,EACA,SAAW,EAAA;AAAA,IACT,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,GAAK,EAAA,CAAA;AAAA,IACL,QAAU,EAAA,MAAA;AAAA,IACV,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,SAAA;AAAA,IACZ,aAAe,EAAA,IAAA;AAAA,IACf,SAAW,EAAA;AAAA,GACb;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,SAAW,EAAA,QAAA;AAAA,IACX,iBAAmB,EAAA,EAAA;AAAA,IACnB,UAAY,EAAA,CAAA;AAAA,IACZ,aAAe,EAAA;AAAA,GACjB;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,UAAY,EAAA,CAAA;AAAA,IACZ,aAAe,EAAA,KAAA;AAAA,IACf,UAAY,EAAA,QAAA;AAAA,IACZ,GAAK,EAAA,CAAA;AAAA,IACL,QAAU,EAAA,CAAA;AAAA,IACV,WAAa,EAAA;AAAA,GACf;AAAA,EACA,QAAU,EAAA;AAAA,IACR,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA,EAAA;AAAA,IACZ,UAAY,EAAA;AAAA,GACd;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,kBAAoB,EAAA,WAAA;AAAA,IACpB,UAAY,EAAA;AAAA;AAEhB,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {vaultKindOf,CONNECTOR_CONNECT_WEB_RETURN_PATH,isSiteLoginRequest,parseConnectorConnect,pickConnectorCredential,autofillCardTitle,VAULT_FORM_KINDS,credentialVaultKind,SITE_LOGIN_CONNECTOR,credentialSavedAt,autofillCardReason}from'common';export{displayConnectorConnectMessages,displayConnectorConnectText}from'common';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -1,6 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const INACTIVE = {
|
|
21
|
+
active: false,
|
|
22
|
+
messages: [],
|
|
23
|
+
loading: false,
|
|
24
|
+
error: null
|
|
25
|
+
};
|
|
26
|
+
let state = INACTIVE;
|
|
2
27
|
const listeners = /* @__PURE__ */ new Set();
|
|
3
|
-
function
|
|
28
|
+
function setState(patch) {
|
|
29
|
+
state = __spreadValues(__spreadValues({}, state), patch);
|
|
4
30
|
listeners.forEach((listener) => listener());
|
|
5
31
|
}
|
|
6
32
|
function subscribeTemporaryChat(listener) {
|
|
@@ -9,11 +35,37 @@ function subscribeTemporaryChat(listener) {
|
|
|
9
35
|
listeners.delete(listener);
|
|
10
36
|
};
|
|
11
37
|
}
|
|
38
|
+
function getTemporaryChat() {
|
|
39
|
+
return state;
|
|
40
|
+
}
|
|
12
41
|
function getTemporaryChatActive() {
|
|
13
|
-
return active;
|
|
42
|
+
return state.active;
|
|
14
43
|
}
|
|
15
44
|
function setTemporaryChatActive(next) {
|
|
16
|
-
if (active === next) return;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
45
|
+
if (state.active === next) return;
|
|
46
|
+
setState(next ? __spreadProps(__spreadValues({}, INACTIVE), {
|
|
47
|
+
active: true
|
|
48
|
+
}) : INACTIVE);
|
|
49
|
+
}
|
|
50
|
+
function clearTemporaryMessages() {
|
|
51
|
+
setState({
|
|
52
|
+
messages: [],
|
|
53
|
+
loading: false,
|
|
54
|
+
error: null
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function appendTemporaryMessage(message) {
|
|
58
|
+
setState({
|
|
59
|
+
messages: [...state.messages, message].slice(-200)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function setTemporaryLoading(loading) {
|
|
63
|
+
setState({
|
|
64
|
+
loading
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function setTemporaryError(error) {
|
|
68
|
+
setState({
|
|
69
|
+
error
|
|
70
|
+
});
|
|
71
|
+
}export{appendTemporaryMessage,clearTemporaryMessages,getTemporaryChat,getTemporaryChatActive,setTemporaryChatActive,setTemporaryError,setTemporaryLoading,subscribeTemporaryChat};//# sourceMappingURL=temporaryChatStore.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporaryChatStore.js","sources":["../../../src/features/chat/temporaryChatStore.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"temporaryChatStore.js","sources":["../../../src/features/chat/temporaryChatStore.ts"],"sourcesContent":["/**\n * Temporary (\"incognito\") chat - the browser's temporaryChatStore for the phone.\n *\n * The promise: never written to the app DB or chat history (nothing here creates a\n * channel or saves a message), and gone when it ends. The web keeps it for the tab's\n * life in sessionStorage; the phone has no tab, so it lives in memory - until Exit, the\n * header toggle, or the app closing.\n *\n * A module-level external store because two unrelated places read it: the header\n * toggle and the chat screens (useSyncExternalStore subscribes both).\n */\n\nexport interface TemporaryMessage {\n id: string;\n role: 'user' | 'assistant';\n content: string;\n}\n\nexport interface TemporaryState {\n active: boolean;\n messages: TemporaryMessage[];\n loading: boolean;\n error: string | null;\n}\n\n/** Cap the transcript so a long session cannot grow without end (web MAX_MESSAGES). */\nconst MAX_MESSAGES = 200;\n\nconst INACTIVE: TemporaryState = { active: false, messages: [], loading: false, error: null };\n\nlet state: TemporaryState = INACTIVE;\nconst listeners = new Set<() => void>();\n\nfunction setState(patch: Partial<TemporaryState>): void {\n state = { ...state, ...patch };\n listeners.forEach((listener) => listener());\n}\n\nexport function subscribeTemporaryChat(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getTemporaryChat(): TemporaryState {\n return state;\n}\n\nexport function getTemporaryChatActive(): boolean {\n return state.active;\n}\n\n/** On: a fresh session. Off: the session is dropped entirely. */\nexport function setTemporaryChatActive(next: boolean): void {\n if (state.active === next) return;\n setState(next ? { ...INACTIVE, active: true } : INACTIVE);\n}\n\nexport function toggleTemporaryChat(): boolean {\n setTemporaryChatActive(!state.active);\n return state.active;\n}\n\n/** Clear the transcript but stay in temporary mode. */\nexport function clearTemporaryMessages(): void {\n setState({ messages: [], loading: false, error: null });\n}\n\nexport function appendTemporaryMessage(message: TemporaryMessage): void {\n setState({ messages: [...state.messages, message].slice(-MAX_MESSAGES) });\n}\n\nexport function setTemporaryLoading(loading: boolean): void {\n setState({ loading });\n}\n\nexport function setTemporaryError(error: string | null): void {\n setState({ error });\n}\n"],"names":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,OAAwB,EAAA;AAC1D,EAAS,QAAA,CAAA;AAAA,IACP;AAAA,GACD,CAAA;AACH;AACO,SAAS,kBAAkB,KAA4B,EAAA;AAC5D,EAAS,QAAA,CAAA;AAAA,IACP;AAAA,GACD,CAAA;AACH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {jsx}from'react/jsx-runtime';import {useSyncExternalStore}from'react';import {TemporaryChatView}from'./TemporaryChatView.js';import {subscribeTemporaryChat,getTemporaryChatActive}from'./temporaryChatStore.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
function withTemporaryChat(Screen) {
|
|
18
|
+
function TemporaryAwareScreen(props) {
|
|
19
|
+
const active = useSyncExternalStore(subscribeTemporaryChat, getTemporaryChatActive, getTemporaryChatActive);
|
|
20
|
+
return active ? /* @__PURE__ */ jsx(TemporaryChatView, {}) : /* @__PURE__ */ jsx(Screen, __spreadValues({}, props));
|
|
21
|
+
}
|
|
22
|
+
TemporaryAwareScreen.displayName = `withTemporaryChat(${Screen.displayName || Screen.name || "Screen"})`;
|
|
23
|
+
return TemporaryAwareScreen;
|
|
24
|
+
}export{withTemporaryChat};//# sourceMappingURL=withTemporaryChat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withTemporaryChat.js","sources":["../../../src/features/chat/withTemporaryChat.tsx"],"sourcesContent":["/**\n * While temporary mode is on, a chat screen shows the temporary chat instead - as the web's\n * ChatConversationPage swaps in TemporaryChatView for both a new chat and an open one.\n */\nimport React, { useSyncExternalStore } from 'react';\nimport { TemporaryChatView } from './TemporaryChatView';\nimport { getTemporaryChatActive, subscribeTemporaryChat } from './temporaryChatStore';\n\nexport function withTemporaryChat<P extends object>(Screen: React.ComponentType<P>): React.ComponentType<P> {\n function TemporaryAwareScreen(props: P) {\n const active = useSyncExternalStore(subscribeTemporaryChat, getTemporaryChatActive, getTemporaryChatActive);\n return active ? <TemporaryChatView /> : <Screen {...props} />;\n }\n TemporaryAwareScreen.displayName = `withTemporaryChat(${Screen.displayName || Screen.name || 'Screen'})`;\n return TemporaryAwareScreen;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAOO,SAAS,kBAAoC,MAAwD,EAAA;AAC1G,EAAA,SAAS,qBAAqB,KAAU,EAAA;AACtC,IAAA,MAAM,MAAS,GAAA,oBAAA,CAAqB,sBAAwB,EAAA,sBAAA,EAAwB,sBAAsB,CAAA;AAC1G,IAAA,OAAO,yBAAU,GAAA,CAAA,iBAAA,EAAA,EAAkB,CAAK,mBAAA,GAAA,CAAC,2BAAW,KAAO,CAAA,CAAA;AAAA;AAE7D,EAAA,oBAAA,CAAqB,cAAc,CAAqB,kBAAA,EAAA,MAAA,CAAO,WAAe,IAAA,MAAA,CAAO,QAAQ,QAAQ,CAAA,CAAA,CAAA;AACrG,EAAO,OAAA,oBAAA;AACT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {useState,useEffect}from'react';import {AppState}from'react-native';const FOREGROUND_POLL_MS = 100;
|
|
2
|
+
const BACKGROUND_POLL_MS = 1e3;
|
|
3
|
+
function pollInterval(recording, appState) {
|
|
4
|
+
if (!recording) return null;
|
|
5
|
+
return appState === "active" ? FOREGROUND_POLL_MS : BACKGROUND_POLL_MS;
|
|
6
|
+
}
|
|
7
|
+
function useRecorderStatus(recorder, recording) {
|
|
8
|
+
const [state, setState] = useState(() => recorder.getStatus());
|
|
9
|
+
const [appState, setAppState] = useState(AppState.currentState);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const sub = AppState.addEventListener("change", setAppState);
|
|
12
|
+
return () => sub.remove();
|
|
13
|
+
}, []);
|
|
14
|
+
const interval = pollInterval(recording, appState);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
setState(recorder.getStatus());
|
|
17
|
+
if (interval === null) return void 0;
|
|
18
|
+
const id = setInterval(() => setState(recorder.getStatus()), interval);
|
|
19
|
+
return () => clearInterval(id);
|
|
20
|
+
}, [recorder, interval]);
|
|
21
|
+
return state;
|
|
22
|
+
}export{BACKGROUND_POLL_MS,FOREGROUND_POLL_MS,pollInterval,useRecorderStatus};//# sourceMappingURL=recorderStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recorderStatus.js","sources":["../../../src/features/dictate/recorderStatus.ts"],"sourcesContent":["/**\n * The recorder's time and level, polled only as often as anyone can use them.\n *\n * expo-audio's own useAudioRecorderState polls at one fixed rate for as long\n * as the screen is mounted, recording or not, and re-renders the screen each\n * time. A dictation can run for an hour in the background, so here:\n * - recording on screen: 10 a second, for a live timer and level;\n * - recording in the background: once a second, enough for the hour cap and\n * the no-sound check, with nothing drawn;\n * - paused or idle: no polling at all, one reading when that starts.\n */\nimport { useEffect, useState } from 'react';\nimport { AppState, type AppStateStatus } from 'react-native';\nimport type { AudioRecorder, RecorderState } from 'expo-audio';\n\nexport const FOREGROUND_POLL_MS = 100;\nexport const BACKGROUND_POLL_MS = 1000;\n\n/** How often to read the recorder: null for not at all. */\nexport function pollInterval(recording: boolean, appState: AppStateStatus): number | null {\n if (!recording) return null;\n return appState === 'active' ? FOREGROUND_POLL_MS : BACKGROUND_POLL_MS;\n}\n\nexport function useRecorderStatus(recorder: AudioRecorder, recording: boolean): RecorderState {\n const [state, setState] = useState<RecorderState>(() => recorder.getStatus());\n const [appState, setAppState] = useState<AppStateStatus>(AppState.currentState);\n\n useEffect(() => {\n const sub = AppState.addEventListener('change', setAppState);\n return () => sub.remove();\n }, []);\n\n const interval = pollInterval(recording, appState);\n useEffect(() => {\n setState(recorder.getStatus());\n if (interval === null) return undefined;\n const id = setInterval(() => setState(recorder.getStatus()), interval);\n return () => clearInterval(id);\n }, [recorder, interval]);\n\n return state;\n}\n"],"names":[],"mappings":"2EAcO,MAAM,kBAAqB,GAAA;AAC3B,MAAM,kBAAqB,GAAA;AAGlB,SAAA,YAAA,CAAa,WAAoB,QAAyC,EAAA;AACxF,EAAI,IAAA,CAAC,WAAkB,OAAA,IAAA;AACvB,EAAO,OAAA,QAAA,KAAa,WAAW,kBAAqB,GAAA,kBAAA;AACtD;AACgB,SAAA,iBAAA,CAAkB,UAAyB,SAAmC,EAAA;AAC5F,EAAM,MAAA,CAAC,OAAO,QAAQ,CAAA,GAAI,SAAwB,MAAM,QAAA,CAAS,WAAW,CAAA;AAC5E,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAA,QAAA,CAAyB,SAAS,YAAY,CAAA;AAC9E,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,GAAM,GAAA,QAAA,CAAS,gBAAiB,CAAA,QAAA,EAAU,WAAW,CAAA;AAC3D,IAAO,OAAA,MAAM,IAAI,MAAO,EAAA;AAAA,GAC1B,EAAG,EAAE,CAAA;AACL,EAAM,MAAA,QAAA,GAAW,YAAa,CAAA,SAAA,EAAW,QAAQ,CAAA;AACjD,EAAA,SAAA,CAAU,MAAM;AACd,IAAS,QAAA,CAAA,QAAA,CAAS,WAAW,CAAA;AAC7B,IAAI,IAAA,QAAA,KAAa,MAAa,OAAA,MAAA;AAC9B,IAAM,MAAA,EAAA,GAAK,YAAY,MAAM,QAAA,CAAS,SAAS,SAAU,EAAC,GAAG,QAAQ,CAAA;AACrE,IAAO,OAAA,MAAM,cAAc,EAAE,CAAA;AAAA,GAC5B,EAAA,CAAC,QAAU,EAAA,QAAQ,CAAC,CAAA;AACvB,EAAO,OAAA,KAAA;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useState,useRef,useMemo,useCallback,useEffect}from'react';import {Platform,AppState}from'react-native';import {useAudioRecorder,
|
|
1
|
+
import {useState,useRef,useMemo,useCallback,useEffect}from'react';import {Platform,AppState}from'react-native';import {useAudioRecorder,setAudioModeAsync,requestRecordingPermissionsAsync,setIsAudioActiveAsync,RecordingPresets,AudioQuality,IOSOutputFormat}from'expo-audio';import {deactivateKeepAwake,activateKeepAwakeAsync}from'expo-keep-awake';import {backgroundRecordingNative,BACKGROUND_NOTICE}from'./backgroundRecording.js';import {useRecorderStatus}from'./recorderStatus.js';import {readMicPreference,writeMicPreference}from'./dictatePreference.js';import {micsOf,chooseMic,otherMic,micOf}from'./micInput.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -19,9 +19,9 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
const DICTATION_RECORDING = __spreadProps(__spreadValues({}, RecordingPresets.HIGH_QUALITY), {
|
|
21
21
|
extension: ".m4a",
|
|
22
|
-
sampleRate:
|
|
22
|
+
sampleRate: 16e3,
|
|
23
23
|
numberOfChannels: 1,
|
|
24
|
-
bitRate:
|
|
24
|
+
bitRate: 32e3,
|
|
25
25
|
isMeteringEnabled: true,
|
|
26
26
|
ios: __spreadProps(__spreadValues({}, RecordingPresets.HIGH_QUALITY.ios), {
|
|
27
27
|
outputFormat: IOSOutputFormat.MPEG4AAC,
|
|
@@ -84,8 +84,8 @@ class MicrophoneDeniedError extends Error {
|
|
|
84
84
|
}
|
|
85
85
|
function useDictationRecorder() {
|
|
86
86
|
const recorder = useAudioRecorder(DICTATION_RECORDING);
|
|
87
|
-
const state = useAudioRecorderState(recorder, 100);
|
|
88
87
|
const [phase, setPhase] = useState("idle");
|
|
88
|
+
const state = useRecorderStatus(recorder, phase === "recording");
|
|
89
89
|
const [pauseReason, setPauseReason] = useState(null);
|
|
90
90
|
const phaseRef = useRef("idle");
|
|
91
91
|
phaseRef.current = phase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictationRecorder.js","sources":["../../../src/features/dictate/useDictationRecorder.ts"],"sourcesContent":["/**\n * The dictation recorder: mono AAC at 64 kbps (speech, about 0.5 MB a minute),\n * pause and resume, and a live level.\n *\n * A binary with the background-recording module keeps recording when Yantra\n * leaves the screen or the phone locks, like a call, and on iOS shows it on the\n * lock screen and in the Dynamic Island meanwhile (backgroundRecording.ts).\n * An older binary cannot: iOS stops the microphone there, so the recorder\n * keeps the screen awake, pauses itself when the app leaves the screen, and\n * says so. Either way, a call or another app taking the microphone pauses the\n * dictation and says why, instead of recording nothing under a running timer.\n *\n * With AirPods or another headset connected, the dictation records through them\n * unless the person chose the phone's microphone (micInput.ts); either can be\n * switched to mid-dictation. A headset that goes away mid-dictation (taken\n * out, battery flat) leaves the recording running on the phone's microphone,\n * and the screen says so. On Android the headset microphone is let go when the\n * dictation ends, or it would keep the AirPods in call mode.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { AppState, Platform } from 'react-native';\nimport {\n AudioQuality,\n IOSOutputFormat,\n RecordingPresets,\n requestRecordingPermissionsAsync,\n setAudioModeAsync,\n setIsAudioActiveAsync,\n useAudioRecorder,\n useAudioRecorderState,\n type RecordingOptions,\n} from 'expo-audio';\nimport { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake';\nimport { BACKGROUND_NOTICE, backgroundRecordingNative } from './backgroundRecording';\nimport { readMicPreference, writeMicPreference } from './dictatePreference';\nimport { chooseMic, micOf, micsOf, otherMic, type Mic } from './micInput';\n\nexport const DICTATION_RECORDING: RecordingOptions = {\n ...RecordingPresets.HIGH_QUALITY,\n extension: '.m4a',\n sampleRate: 44100,\n numberOfChannels: 1,\n bitRate: 64000,\n isMeteringEnabled: true,\n ios: {\n ...RecordingPresets.HIGH_QUALITY.ios,\n outputFormat: IOSOutputFormat.MPEG4AAC,\n audioQuality: AudioQuality.HIGH,\n },\n android: {\n ...RecordingPresets.HIGH_QUALITY.android,\n outputFormat: 'mpeg4',\n audioEncoder: 'aac',\n },\n};\n\n/** One visit is well under this; past it the recording pauses and asks to be finished. */\nexport const MAX_DICTATION_MS = 60 * 60_000;\nconst KEEP_AWAKE_TAG = 'yantra-dictate';\n/** How often a running dictation checks which microphone it is hearing (a headset can go away). */\nexport const MIC_CHECK_MS = 2000;\n\n/** What the phone's own microphone is called on this device. */\nfunction phoneWord(): string {\n if (Platform.OS !== 'ios') return 'Phone';\n return (Platform as { isPad?: boolean }).isPad ? 'iPad' : 'iPhone';\n}\n\nexport type RecorderPhase = 'idle' | 'recording' | 'paused';\nexport type PauseReason = 'user' | 'background' | 'interrupted' | 'limit' | null;\n\n/** -60 dB (silence) .. 0 dB (loud) mapped to 0..1. */\nexport function levelFromMetering(db: number | undefined): number {\n if (typeof db !== 'number' || !Number.isFinite(db)) return 0;\n return Math.min(1, Math.max(0, (db + 60) / 60));\n}\n\n/**\n * Below this the microphone carries no signal at all (iOS reports -120 to\n * -160 dB): it is blocked, taken by another app, or failed to start. A quiet\n * room still reads about -50 dB, so silence between sentences never trips it.\n */\nconst NO_SIGNAL_DB = -100;\n/** How long a running recording may carry no signal before the clinician is told. */\nexport const NO_INPUT_WARN_MS = 4000;\n\n/** False only for a metering reading that shows no signal; no reading at all says nothing either way. */\nexport function carriesSignal(db: number | undefined): boolean {\n return typeof db !== 'number' || !Number.isFinite(db) || db > NO_SIGNAL_DB;\n}\n\n/** The Live Activity's words for where the dictation stands; nothing once it is done. */\nexport function backgroundActivityText(\n phase: RecorderPhase,\n pauseReason: PauseReason,\n noInput: boolean,\n): { title: string; detail: string } | null {\n if (phase === 'idle') return null;\n if (phase === 'recording') {\n return noInput\n ? { title: BACKGROUND_NOTICE.title, detail: 'No sound is reaching the microphone. Open Yantra to check.' }\n : { title: BACKGROUND_NOTICE.title, detail: BACKGROUND_NOTICE.text };\n }\n if (pauseReason === 'interrupted') {\n return {\n title: 'Paused for a call',\n detail: 'A call or another app took the microphone. Open Yantra to resume.',\n };\n }\n if (pauseReason === 'limit') {\n return {\n title: 'Paused at one hour',\n detail: 'An hour is the most one dictation holds. Open Yantra to write the note.',\n };\n }\n return { title: 'Paused', detail: 'Open Yantra to resume or finish the dictation.' };\n}\n\nexport class MicrophoneDeniedError extends Error {\n constructor() {\n super('Microphone access was declined. Allow it in Settings to dictate.');\n this.name = 'MicrophoneDeniedError';\n }\n}\n\nexport function useDictationRecorder() {\n const recorder = useAudioRecorder(DICTATION_RECORDING);\n const state = useAudioRecorderState(recorder, 100);\n const [phase, setPhase] = useState<RecorderPhase>('idle');\n const [pauseReason, setPauseReason] = useState<PauseReason>(null);\n const phaseRef = useRef<RecorderPhase>('idle');\n phaseRef.current = phase;\n const background = useMemo(() => backgroundRecordingNative(), []);\n /** This dictation keeps recording when Yantra leaves the screen. */\n const inBackgroundRef = useRef(false);\n const [mic, setMic] = useState<Mic | null>(null);\n const [mics, setMics] = useState<Mic[]>([]);\n /** The headset this dictation was recording through until it went away. */\n const [micLost, setMicLost] = useState<string | null>(null);\n const micRef = useRef<Mic | null>(null);\n micRef.current = mic;\n const micsRef = useRef<Mic[]>([]);\n micsRef.current = mics;\n\n // The recorder lists and switches inputs only once prepared; an older binary may not offer it at all.\n const listMics = useCallback((): Mic[] => {\n try {\n return micsOf(recorder.getAvailableInputs(), phoneWord());\n } catch {\n return [];\n }\n }, [recorder]);\n const selectMic = useCallback(\n (next: Mic): boolean => {\n try {\n recorder.setInput(next.uid);\n return true;\n } catch {\n return false;\n }\n },\n [recorder],\n );\n\n const releaseSession = useCallback(async () => {\n // Android keeps a Bluetooth headset in call mode while its microphone is selected: let it go.\n const phoneMic = micsRef.current.find((m) => m.kind === 'phone');\n if (Platform.OS === 'android' && micRef.current?.kind === 'headset' && phoneMic) selectMic(phoneMic);\n setMic(null);\n setMics([]);\n setMicLost(null);\n if (inBackgroundRef.current) await background?.stop().catch(() => undefined);\n inBackgroundRef.current = false;\n await deactivateKeepAwake(KEEP_AWAKE_TAG).catch(() => undefined);\n // The rest of the app's audio (chat voice notes) does not play on in the background.\n await setAudioModeAsync({\n allowsRecording: false,\n playsInSilentMode: true,\n shouldPlayInBackground: false,\n }).catch(() => undefined);\n }, [background, selectMic]);\n\n const pause = useCallback(\n (reason: Exclude<PauseReason, null> = 'user') => {\n if (phaseRef.current !== 'recording') return;\n recorder.pause();\n setPhase('paused');\n setPauseReason(reason);\n },\n [recorder],\n );\n\n const start = useCallback(async () => {\n const permission = await requestRecordingPermissionsAsync();\n if (!permission.granted) throw new MicrophoneDeniedError();\n // Android's microphone service has to be running before Yantra leaves the screen, and\n // may only start while it is on it: now. A refusal means pausing on leave, as before.\n inBackgroundRef.current = background?.supported\n ? await background.start(BACKGROUND_NOTICE.title, BACKGROUND_NOTICE.text).then(\n () => true,\n () => false,\n )\n : false;\n try {\n await setAudioModeAsync({\n allowsRecording: true,\n playsInSilentMode: true,\n shouldPlayInBackground: inBackgroundRef.current,\n });\n await recorder.prepareToRecordAsync();\n const available = listMics();\n const chosen = chooseMic(available, await readMicPreference());\n if (chosen && available.length > 1) selectMic(chosen);\n setMics(available);\n setMic(chosen);\n setMicLost(null);\n recorder.record();\n } catch (err) {\n await releaseSession();\n throw err;\n }\n // Without background recording the screen must stay on, or the microphone stops.\n if (!inBackgroundRef.current) await activateKeepAwakeAsync(KEEP_AWAKE_TAG).catch(() => undefined);\n setPhase('recording');\n setPauseReason(null);\n }, [recorder, background, releaseSession, listMics, selectMic]);\n\n /** The other microphone (AirPods <-> the phone's), remembered for the next dictation. */\n const switchMic = useCallback(() => {\n const available = listMics();\n const next = otherMic(available, micRef.current);\n if (!next || !selectMic(next)) return;\n setMics(available);\n setMic(next);\n setMicLost(null);\n writeMicPreference(next.kind);\n }, [listMics, selectMic]);\n\n const resume = useCallback(async () => {\n if (phaseRef.current !== 'paused') return;\n // A call or another app deactivated the audio session; recording needs it back.\n await setIsAudioActiveAsync(true).catch(() => undefined);\n recorder.record();\n setPhase('recording');\n setPauseReason(null);\n }, [recorder]);\n\n /** Ends the recording; resolves to its file (in the recorder's cache - move it before anything else). */\n const finish = useCallback(async (): Promise<{ uri: string; durationMs: number } | null> => {\n if (phaseRef.current === 'idle') return null;\n const durationMs = recorder.getStatus().durationMillis;\n await recorder.stop();\n setPhase('idle');\n setPauseReason(null);\n await releaseSession();\n return recorder.uri ? { uri: recorder.uri, durationMs } : null;\n }, [recorder, releaseSession]);\n\n // Without background recording the microphone stops when the app leaves the screen: pause, and say so.\n useEffect(() => {\n const sub = AppState.addEventListener('change', (next) => {\n if (next !== 'active' && !inBackgroundRef.current) pause('background');\n });\n return () => sub.remove();\n }, [pause]);\n\n // A call or another app took the microphone. Nothing is recorded from here, though\n // expo-audio's timer would keep running: pause, and stay paused until the clinician resumes.\n useEffect(() => {\n const sub = background?.addListener('onInterruption', (event) => {\n if (event.state === 'began') pause('interrupted');\n });\n return () => sub?.remove();\n }, [background, pause]);\n\n useEffect(() => {\n if (phase === 'recording' && state.durationMillis >= MAX_DICTATION_MS) pause('limit');\n }, [phase, state.durationMillis, pause]);\n\n // A headset can go away mid-dictation (taken out, battery flat): the system moves the recording\n // to the phone's microphone without a word, so look, and say so. One coming back is offered again.\n useEffect(() => {\n if (phase !== 'recording') return undefined;\n const id = setInterval(() => {\n void Promise.resolve()\n .then(() => recorder.getCurrentInput())\n .then((input) => {\n const heard = micOf(input, phoneWord());\n const was = micRef.current;\n const now = listMics();\n const uids = (list: Mic[]) => list.map((m) => m.uid).join(' ');\n if (uids(now) !== uids(micsRef.current)) setMics(now);\n if (!was || heard.uid === was.uid) return;\n setMicLost(was.kind === 'headset' && heard.kind === 'phone' ? was.label : null);\n setMic(heard);\n })\n .catch(() => undefined);\n }, MIC_CHECK_MS);\n return () => clearInterval(id);\n }, [phase, recorder, listMics]);\n\n // Recording time at which the microphone last carried a signal. A paused or idle recorder\n // starts the count again, so Resume gets a fresh few seconds; so does a new recording,\n // whose time restarts below the last one's.\n const signalAtRef = useRef(0);\n useEffect(() => {\n if (phase !== 'recording' || carriesSignal(state.metering) || state.durationMillis < signalAtRef.current) {\n signalAtRef.current = state.durationMillis;\n }\n }, [phase, state.durationMillis, state.metering]);\n // Without this a dead microphone records a whole visit of silence, timer running.\n const noInput =\n phase === 'recording' &&\n !carriesSignal(state.metering) &&\n state.durationMillis - signalAtRef.current >= NO_INPUT_WARN_MS;\n\n // The lock screen and the Dynamic Island follow the dictation while it records in the background (iOS).\n const activity = backgroundActivityText(phase, pauseReason, noInput);\n const activityTitle = activity?.title;\n const activityDetail = activity?.detail;\n useEffect(() => {\n if (!activityTitle || !activityDetail || !inBackgroundRef.current || !background?.update) return;\n void background\n .update({\n title: activityTitle,\n detail: activityDetail,\n recording: phase === 'recording',\n recordedMs: recorder.getStatus().durationMillis,\n noSound: noInput,\n })\n .catch(() => undefined);\n }, [activityTitle, activityDetail, phase, noInput, background, recorder]);\n\n // Leaving the screen mid-dictation stops the microphone and lets the screen sleep.\n useEffect(\n () => () => {\n if (phaseRef.current !== 'idle') void recorder.stop().catch(() => undefined);\n void releaseSession();\n },\n [recorder, releaseSession],\n );\n\n return {\n phase,\n pauseReason,\n elapsedMs: state.durationMillis,\n level: phase === 'recording' ? levelFromMetering(state.metering) : 0,\n noInput,\n /** This binary keeps a dictation recording with the phone locked or another app open. */\n recordsInBackground: background?.supported === true,\n /** The microphone the dictation is recording from, once it started. */\n mic,\n /** The other microphone it can switch to (AirPods <-> the phone's), if one is connected. */\n otherMic: otherMic(mics, mic),\n /** The headset that went away mid-dictation, while the phone's microphone carries on. */\n micLost,\n switchMic,\n start,\n pause: () => pause('user'),\n resume,\n finish,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA0Ba,MAAA,mBAAA,GAAwC,aAChD,CAAA,cAAA,CAAA,EAAA,EAAA,gBAAA,CAAiB,YAD+B,CAAA,EAAA;AAAA,EAEnD,SAAW,EAAA,MAAA;AAAA,EACX,UAAY,EAAA,KAAA;AAAA,EACZ,gBAAkB,EAAA,CAAA;AAAA,EAClB,OAAS,EAAA,IAAA;AAAA,EACT,iBAAmB,EAAA,IAAA;AAAA,EACnB,GAAK,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACA,gBAAiB,CAAA,YAAA,CAAa,GAD9B,CAAA,EAAA;AAAA,IAEH,cAAc,eAAgB,CAAA,QAAA;AAAA,IAC9B,cAAc,YAAa,CAAA;AAAA,GAC7B,CAAA;AAAA,EACA,OAAS,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACJ,gBAAiB,CAAA,YAAA,CAAa,OAD1B,CAAA,EAAA;AAAA,IAEP,YAAc,EAAA,OAAA;AAAA,IACd,YAAc,EAAA;AAAA,GAChB;AACF,CAAA;AAGO,MAAM,mBAAmB,EAAK,GAAA;AACrC,MAAM,cAAiB,GAAA,gBAAA;AAEhB,MAAM,YAAe,GAAA;AAG5B,SAAS,SAAoB,GAAA;AAC3B,EAAI,IAAA,QAAA,CAAS,EAAO,KAAA,KAAA,EAAc,OAAA,OAAA;AAClC,EAAQ,OAAA,QAAA,CAEL,QAAQ,MAAS,GAAA,QAAA;AACtB;AAKO,SAAS,kBAAkB,EAAgC,EAAA;AAChE,EAAI,IAAA,OAAO,OAAO,QAAY,IAAA,CAAC,OAAO,QAAS,CAAA,EAAE,GAAU,OAAA,CAAA;AAC3D,EAAO,OAAA,IAAA,CAAK,IAAI,CAAG,EAAA,IAAA,CAAK,IAAI,CAAI,EAAA,C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GAAc,iBAAkB,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,CAAA;AAAA,IACnE,OAAA;AAAA;AAAA,IAEA,mBAAA,EAAA,CAAqB,yCAAY,SAAc,MAAA,IAAA;AAAA;AAAA,IAE/C,GAAA;AAAA;AAAA,IAEA,QAAA,EAAU,QAAS,CAAA,IAAA,EAAM,GAAG,CAAA;AAAA;AAAA,IAE5B,OAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA,EAAO,MAAM,KAAA,CAAM,MAAM,CAAA;AAAA,IACzB,MAAA;AAAA,IACA;AAAA,GACF;AACF"}
|
|
1
|
+
{"version":3,"file":"useDictationRecorder.js","sources":["../../../src/features/dictate/useDictationRecorder.ts"],"sourcesContent":["/**\n * The dictation recorder: mono AAC, 16 kHz at 32 kbps (about 0.24 MB a\n * minute), pause and resume, and a live level.\n *\n * 16 kHz is speech recognition's own rate: the medical transcriber heard a\n * test dictation at least as well as at 44.1 kHz/64 kbps, while the phone\n * encodes a third of the samples and uploads half the bytes. The recorder is\n * read only while it records, and once a second in the background\n * (recorderStatus.ts), so an hour-long dictation costs little battery.\n *\n * A binary with the background-recording module keeps recording when Yantra\n * leaves the screen or the phone locks, like a call, and on iOS shows it on the\n * lock screen and in the Dynamic Island meanwhile (backgroundRecording.ts).\n * An older binary cannot: iOS stops the microphone there, so the recorder\n * keeps the screen awake, pauses itself when the app leaves the screen, and\n * says so. Either way, a call or another app taking the microphone pauses the\n * dictation and says why, instead of recording nothing under a running timer.\n *\n * With AirPods or another headset connected, the dictation records through them\n * unless the person chose the phone's microphone (micInput.ts); either can be\n * switched to mid-dictation. A headset that goes away mid-dictation (taken\n * out, battery flat) leaves the recording running on the phone's microphone,\n * and the screen says so. On Android the headset microphone is let go when the\n * dictation ends, or it would keep the AirPods in call mode.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { AppState, Platform } from 'react-native';\nimport {\n AudioQuality,\n IOSOutputFormat,\n RecordingPresets,\n requestRecordingPermissionsAsync,\n setAudioModeAsync,\n setIsAudioActiveAsync,\n useAudioRecorder,\n type RecordingOptions,\n} from 'expo-audio';\nimport { activateKeepAwakeAsync, deactivateKeepAwake } from 'expo-keep-awake';\nimport { BACKGROUND_NOTICE, backgroundRecordingNative } from './backgroundRecording';\nimport { useRecorderStatus } from './recorderStatus';\nimport { readMicPreference, writeMicPreference } from './dictatePreference';\nimport { chooseMic, micOf, micsOf, otherMic, type Mic } from './micInput';\n\nexport const DICTATION_RECORDING: RecordingOptions = {\n ...RecordingPresets.HIGH_QUALITY,\n extension: '.m4a',\n sampleRate: 16000,\n numberOfChannels: 1,\n bitRate: 32000,\n isMeteringEnabled: true,\n ios: {\n ...RecordingPresets.HIGH_QUALITY.ios,\n outputFormat: IOSOutputFormat.MPEG4AAC,\n audioQuality: AudioQuality.HIGH,\n },\n android: {\n ...RecordingPresets.HIGH_QUALITY.android,\n outputFormat: 'mpeg4',\n audioEncoder: 'aac',\n },\n};\n\n/** One visit is well under this; past it the recording pauses and asks to be finished. */\nexport const MAX_DICTATION_MS = 60 * 60_000;\nconst KEEP_AWAKE_TAG = 'yantra-dictate';\n/** How often a running dictation checks which microphone it is hearing (a headset can go away). */\nexport const MIC_CHECK_MS = 2000;\n\n/** What the phone's own microphone is called on this device. */\nfunction phoneWord(): string {\n if (Platform.OS !== 'ios') return 'Phone';\n return (Platform as { isPad?: boolean }).isPad ? 'iPad' : 'iPhone';\n}\n\nexport type RecorderPhase = 'idle' | 'recording' | 'paused';\nexport type PauseReason = 'user' | 'background' | 'interrupted' | 'limit' | null;\n\n/** -60 dB (silence) .. 0 dB (loud) mapped to 0..1. */\nexport function levelFromMetering(db: number | undefined): number {\n if (typeof db !== 'number' || !Number.isFinite(db)) return 0;\n return Math.min(1, Math.max(0, (db + 60) / 60));\n}\n\n/**\n * Below this the microphone carries no signal at all (iOS reports -120 to\n * -160 dB): it is blocked, taken by another app, or failed to start. A quiet\n * room still reads about -50 dB, so silence between sentences never trips it.\n */\nconst NO_SIGNAL_DB = -100;\n/** How long a running recording may carry no signal before the clinician is told. */\nexport const NO_INPUT_WARN_MS = 4000;\n\n/** False only for a metering reading that shows no signal; no reading at all says nothing either way. */\nexport function carriesSignal(db: number | undefined): boolean {\n return typeof db !== 'number' || !Number.isFinite(db) || db > NO_SIGNAL_DB;\n}\n\n/** The Live Activity's words for where the dictation stands; nothing once it is done. */\nexport function backgroundActivityText(\n phase: RecorderPhase,\n pauseReason: PauseReason,\n noInput: boolean,\n): { title: string; detail: string } | null {\n if (phase === 'idle') return null;\n if (phase === 'recording') {\n return noInput\n ? { title: BACKGROUND_NOTICE.title, detail: 'No sound is reaching the microphone. Open Yantra to check.' }\n : { title: BACKGROUND_NOTICE.title, detail: BACKGROUND_NOTICE.text };\n }\n if (pauseReason === 'interrupted') {\n return {\n title: 'Paused for a call',\n detail: 'A call or another app took the microphone. Open Yantra to resume.',\n };\n }\n if (pauseReason === 'limit') {\n return {\n title: 'Paused at one hour',\n detail: 'An hour is the most one dictation holds. Open Yantra to write the note.',\n };\n }\n return { title: 'Paused', detail: 'Open Yantra to resume or finish the dictation.' };\n}\n\nexport class MicrophoneDeniedError extends Error {\n constructor() {\n super('Microphone access was declined. Allow it in Settings to dictate.');\n this.name = 'MicrophoneDeniedError';\n }\n}\n\nexport function useDictationRecorder() {\n const recorder = useAudioRecorder(DICTATION_RECORDING);\n const [phase, setPhase] = useState<RecorderPhase>('idle');\n const state = useRecorderStatus(recorder, phase === 'recording');\n const [pauseReason, setPauseReason] = useState<PauseReason>(null);\n const phaseRef = useRef<RecorderPhase>('idle');\n phaseRef.current = phase;\n const background = useMemo(() => backgroundRecordingNative(), []);\n /** This dictation keeps recording when Yantra leaves the screen. */\n const inBackgroundRef = useRef(false);\n const [mic, setMic] = useState<Mic | null>(null);\n const [mics, setMics] = useState<Mic[]>([]);\n /** The headset this dictation was recording through until it went away. */\n const [micLost, setMicLost] = useState<string | null>(null);\n const micRef = useRef<Mic | null>(null);\n micRef.current = mic;\n const micsRef = useRef<Mic[]>([]);\n micsRef.current = mics;\n\n // The recorder lists and switches inputs only once prepared; an older binary may not offer it at all.\n const listMics = useCallback((): Mic[] => {\n try {\n return micsOf(recorder.getAvailableInputs(), phoneWord());\n } catch {\n return [];\n }\n }, [recorder]);\n const selectMic = useCallback(\n (next: Mic): boolean => {\n try {\n recorder.setInput(next.uid);\n return true;\n } catch {\n return false;\n }\n },\n [recorder],\n );\n\n const releaseSession = useCallback(async () => {\n // Android keeps a Bluetooth headset in call mode while its microphone is selected: let it go.\n const phoneMic = micsRef.current.find((m) => m.kind === 'phone');\n if (Platform.OS === 'android' && micRef.current?.kind === 'headset' && phoneMic) selectMic(phoneMic);\n setMic(null);\n setMics([]);\n setMicLost(null);\n if (inBackgroundRef.current) await background?.stop().catch(() => undefined);\n inBackgroundRef.current = false;\n await deactivateKeepAwake(KEEP_AWAKE_TAG).catch(() => undefined);\n // The rest of the app's audio (chat voice notes) does not play on in the background.\n await setAudioModeAsync({\n allowsRecording: false,\n playsInSilentMode: true,\n shouldPlayInBackground: false,\n }).catch(() => undefined);\n }, [background, selectMic]);\n\n const pause = useCallback(\n (reason: Exclude<PauseReason, null> = 'user') => {\n if (phaseRef.current !== 'recording') return;\n recorder.pause();\n setPhase('paused');\n setPauseReason(reason);\n },\n [recorder],\n );\n\n const start = useCallback(async () => {\n const permission = await requestRecordingPermissionsAsync();\n if (!permission.granted) throw new MicrophoneDeniedError();\n // Android's microphone service has to be running before Yantra leaves the screen, and\n // may only start while it is on it: now. A refusal means pausing on leave, as before.\n inBackgroundRef.current = background?.supported\n ? await background.start(BACKGROUND_NOTICE.title, BACKGROUND_NOTICE.text).then(\n () => true,\n () => false,\n )\n : false;\n try {\n await setAudioModeAsync({\n allowsRecording: true,\n playsInSilentMode: true,\n shouldPlayInBackground: inBackgroundRef.current,\n });\n await recorder.prepareToRecordAsync();\n const available = listMics();\n const chosen = chooseMic(available, await readMicPreference());\n if (chosen && available.length > 1) selectMic(chosen);\n setMics(available);\n setMic(chosen);\n setMicLost(null);\n recorder.record();\n } catch (err) {\n await releaseSession();\n throw err;\n }\n // Without background recording the screen must stay on, or the microphone stops.\n if (!inBackgroundRef.current) await activateKeepAwakeAsync(KEEP_AWAKE_TAG).catch(() => undefined);\n setPhase('recording');\n setPauseReason(null);\n }, [recorder, background, releaseSession, listMics, selectMic]);\n\n /** The other microphone (AirPods <-> the phone's), remembered for the next dictation. */\n const switchMic = useCallback(() => {\n const available = listMics();\n const next = otherMic(available, micRef.current);\n if (!next || !selectMic(next)) return;\n setMics(available);\n setMic(next);\n setMicLost(null);\n writeMicPreference(next.kind);\n }, [listMics, selectMic]);\n\n const resume = useCallback(async () => {\n if (phaseRef.current !== 'paused') return;\n // A call or another app deactivated the audio session; recording needs it back.\n await setIsAudioActiveAsync(true).catch(() => undefined);\n recorder.record();\n setPhase('recording');\n setPauseReason(null);\n }, [recorder]);\n\n /** Ends the recording; resolves to its file (in the recorder's cache - move it before anything else). */\n const finish = useCallback(async (): Promise<{ uri: string; durationMs: number } | null> => {\n if (phaseRef.current === 'idle') return null;\n const durationMs = recorder.getStatus().durationMillis;\n await recorder.stop();\n setPhase('idle');\n setPauseReason(null);\n await releaseSession();\n return recorder.uri ? { uri: recorder.uri, durationMs } : null;\n }, [recorder, releaseSession]);\n\n // Without background recording the microphone stops when the app leaves the screen: pause, and say so.\n useEffect(() => {\n const sub = AppState.addEventListener('change', (next) => {\n if (next !== 'active' && !inBackgroundRef.current) pause('background');\n });\n return () => sub.remove();\n }, [pause]);\n\n // A call or another app took the microphone. Nothing is recorded from here, though\n // expo-audio's timer would keep running: pause, and stay paused until the clinician resumes.\n useEffect(() => {\n const sub = background?.addListener('onInterruption', (event) => {\n if (event.state === 'began') pause('interrupted');\n });\n return () => sub?.remove();\n }, [background, pause]);\n\n useEffect(() => {\n if (phase === 'recording' && state.durationMillis >= MAX_DICTATION_MS) pause('limit');\n }, [phase, state.durationMillis, pause]);\n\n // A headset can go away mid-dictation (taken out, battery flat): the system moves the recording\n // to the phone's microphone without a word, so look, and say so. One coming back is offered again.\n useEffect(() => {\n if (phase !== 'recording') return undefined;\n const id = setInterval(() => {\n void Promise.resolve()\n .then(() => recorder.getCurrentInput())\n .then((input) => {\n const heard = micOf(input, phoneWord());\n const was = micRef.current;\n const now = listMics();\n const uids = (list: Mic[]) => list.map((m) => m.uid).join(' ');\n if (uids(now) !== uids(micsRef.current)) setMics(now);\n if (!was || heard.uid === was.uid) return;\n setMicLost(was.kind === 'headset' && heard.kind === 'phone' ? was.label : null);\n setMic(heard);\n })\n .catch(() => undefined);\n }, MIC_CHECK_MS);\n return () => clearInterval(id);\n }, [phase, recorder, listMics]);\n\n // Recording time at which the microphone last carried a signal. A paused or idle recorder\n // starts the count again, so Resume gets a fresh few seconds; so does a new recording,\n // whose time restarts below the last one's.\n const signalAtRef = useRef(0);\n useEffect(() => {\n if (phase !== 'recording' || carriesSignal(state.metering) || state.durationMillis < signalAtRef.current) {\n signalAtRef.current = state.durationMillis;\n }\n }, [phase, state.durationMillis, state.metering]);\n // Without this a dead microphone records a whole visit of silence, timer running.\n const noInput =\n phase === 'recording' &&\n !carriesSignal(state.metering) &&\n state.durationMillis - signalAtRef.current >= NO_INPUT_WARN_MS;\n\n // The lock screen and the Dynamic Island follow the dictation while it records in the background (iOS).\n const activity = backgroundActivityText(phase, pauseReason, noInput);\n const activityTitle = activity?.title;\n const activityDetail = activity?.detail;\n useEffect(() => {\n if (!activityTitle || !activityDetail || !inBackgroundRef.current || !background?.update) return;\n void background\n .update({\n title: activityTitle,\n detail: activityDetail,\n recording: phase === 'recording',\n recordedMs: recorder.getStatus().durationMillis,\n noSound: noInput,\n })\n .catch(() => undefined);\n }, [activityTitle, activityDetail, phase, noInput, background, recorder]);\n\n // Leaving the screen mid-dictation stops the microphone and lets the screen sleep.\n useEffect(\n () => () => {\n if (phaseRef.current !== 'idle') void recorder.stop().catch(() => undefined);\n void releaseSession();\n },\n [recorder, releaseSession],\n );\n\n return {\n phase,\n pauseReason,\n elapsedMs: state.durationMillis,\n level: phase === 'recording' ? levelFromMetering(state.metering) : 0,\n noInput,\n /** This binary keeps a dictation recording with the phone locked or another app open. */\n recordsInBackground: background?.supported === true,\n /** The microphone the dictation is recording from, once it started. */\n mic,\n /** The other microphone it can switch to (AirPods <-> the phone's), if one is connected. */\n otherMic: otherMic(mics, mic),\n /** The headset that went away mid-dictation, while the phone's microphone carries on. */\n micLost,\n switchMic,\n start,\n pause: () => pause('user'),\n resume,\n finish,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAiCa,MAAA,mBAAA,GAAwC,aAChD,CAAA,cAAA,CAAA,EAAA,EAAA,gBAAA,CAAiB,YAD+B,CAAA,EAAA;AAAA,EAEnD,SAAW,EAAA,MAAA;AAAA,EACX,UAAY,EAAA,IAAA;AAAA,EACZ,gBAAkB,EAAA,CAAA;AAAA,EAClB,OAAS,EAAA,IAAA;AAAA,EACT,iBAAmB,EAAA,IAAA;AAAA,EACnB,GAAK,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACA,gBAAiB,CAAA,YAAA,CAAa,GAD9B,CAAA,EAAA;AAAA,IAEH,cAAc,eAAgB,CAAA,QAAA;AAAA,IAC9B,cAAc,YAAa,CAAA;AAAA,GAC7B,CAAA;AAAA,EACA,OAAS,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EACJ,gBAAiB,CAAA,YAAA,CAAa,OAD1B,CAAA,EAAA;AAAA,IAEP,YAAc,EAAA,OAAA;AAAA,IACd,YAAc,EAAA;AAAA,GAChB;AACF,CAAA;AAGO,MAAM,mBAAmB,EAAK,GAAA;AACrC,MAAM,cAAiB,GAAA,gBAAA;AAEhB,MAAM,YAAe,GAAA;AAG5B,SAAS,SAAoB,GAAA;AAC3B,EAAI,IAAA,QAAA,CAAS,EAAO,KAAA,KAAA,EAAc,OAAA,OAAA;AAClC,EAAQ,OAAA,QAAA,CAEL,QAAQ,MAAS,GAAA,QAAA;AAC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MAAS,CAAA;AAC3E,IAAA,KAAK,cAAe,EAAA;AAAA,GACnB,EAAA,CAAC,QAAU,EAAA,cAAc,CAAC,CAAA;AAC7B,EAAO,OAAA;AAAA,IACL,KAAA;AAAA,IACA,WAAA;AAAA,IACA,WAAW,KAAM,CAAA,cAAA;AAAA,IACjB,OAAO,KAAU,KAAA,WAAA,GAAc,iBAAkB,CAAA,KAAA,CAAM,QAAQ,CAAI,GAAA,CAAA;AAAA,IACnE,OAAA;AAAA;AAAA,IAEA,mBAAA,EAAA,CAAqB,yCAAY,SAAc,MAAA,IAAA;AAAA;AAAA,IAE/C,GAAA;AAAA;AAAA,IAEA,QAAA,EAAU,QAAS,CAAA,IAAA,EAAM,GAAG,CAAA;AAAA;AAAA,IAE5B,OAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA,EAAO,MAAM,KAAA,CAAM,MAAM,CAAA;AAAA,IACzB,MAAA;AAAA,IACA;AAAA,GACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useState,useRef,useEffect,useMemo}from'react';import {Animated,View,
|
|
1
|
+
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useState,useRef,useEffect,useMemo}from'react';import {StyleSheet,Animated,View,AccessibilityInfo,Easing}from'react-native';import Svg,{Defs,LinearGradient,Stop,RadialGradient,Rect,Ellipse,Circle,G,Path,Polyline,Line}from'react-native-svg';import {skyGeometry,bodyPosition,moonPath,seeded}from'./skyScene.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|