@graineai/inapp-react-native 0.27.1 → 0.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,5 +19,6 @@ export interface GraineFabProps {
19
19
  }>;
20
20
  onOpen?: () => void;
21
21
  onClose?: () => void;
22
+ prewarm?: boolean;
22
23
  }
23
- export declare function GraineFab({ webView, position, size, accent: accentProp, label, overlay, onOpen, onClose }: GraineFabProps): React.JSX.Element | null;
24
+ export declare function GraineFab({ webView, position, size, accent: accentProp, label, overlay, prewarm, onOpen, onClose }: GraineFabProps): React.JSX.Element;
@@ -53,23 +53,26 @@ export function GraineTouchCapture({ children, enabled = true, style }) {
53
53
  }, [client, ctx, enabled]);
54
54
  return (_jsx(View, { style: [{ flex: 1 }, style], onTouchStart: onTouchStart, onTouchEnd: onTouchEnd, children: children }));
55
55
  }
56
- export function GraineFab({ webView, position = "bottom-right", size = 56, accent: accentProp, label, overlay, onOpen, onClose }) {
56
+ export function GraineFab({ webView, position = "bottom-right", size = 56, accent: accentProp, label, overlay, prewarm = true, onOpen, onClose }) {
57
57
  const { launcherVisible, launcherInset, appearance, error } = useGraineAgent();
58
58
  const [open, setOpen] = useState(false);
59
59
  const dashboard = resolveNativeAppearance(appearance, { accent: "#318CE7", heading: "Assistant", radius: 18 });
60
60
  const accent = accentProp ?? dashboard.accent;
61
61
  const name = dashboard.heading;
62
- if (error || !launcherVisible)
63
- return null;
64
- if (open) {
65
- return (_jsx(AboveNativeScreens, { overlay: overlay, children: _jsx(GraineVoiceLauncher, { webView: webView, autoStart: true, onEnded: () => { setOpen(false); onClose?.(); }, children: () => _jsx(GraineAgentBar, { accent: accent, name: name }) }) }));
66
- }
67
- const side = position === "bottom-left" ? { left: launcherInset.right } : { right: launcherInset.right };
68
- return (_jsx(AboveNativeScreens, { overlay: overlay, children: _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label ?? `Talk to ${name}`, onPress: () => { setOpen(true); onOpen?.(); }, style: ({ pressed }) => ({
62
+ const dashboardAccent = accentProp ?? dashboard.accent;
63
+ const button = (api) => {
64
+ if (error || !launcherVisible)
65
+ return null;
66
+ const side = position === "bottom-left" ? { left: launcherInset.right } : { right: launcherInset.right };
67
+ return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label ?? `Talk to ${name}`, onPress: () => { setOpen(true); api.start(); onOpen?.(); }, style: ({ pressed }) => ({
69
68
  position: "absolute", bottom: launcherInset.bottom, ...side,
70
- width: size, height: size, borderRadius: size / 2, backgroundColor: accent,
69
+ width: size, height: size, borderRadius: size / 2, backgroundColor: dashboardAccent,
71
70
  alignItems: "center", justifyContent: "center",
72
71
  opacity: pressed ? 0.85 : 1,
73
72
  elevation: 6, shadowColor: "#000", shadowOpacity: 0.25, shadowRadius: 8, shadowOffset: { width: 0, height: 4 },
74
- }), children: dashboard.logoUrl ? (_jsx(Image, { source: { uri: dashboard.logoUrl }, style: { width: size * 0.6, height: size * 0.6, borderRadius: size * 0.3 } })) : (_jsx(Text, { style: { color: "#fff", fontSize: size * 0.4, fontWeight: "700" }, children: name.trim().charAt(0).toUpperCase() || "•" })) }) }));
73
+ }), children: dashboard.logoUrl ? (_jsx(Image, { source: { uri: dashboard.logoUrl }, style: { width: size * 0.6, height: size * 0.6, borderRadius: size * 0.3 } })) : (_jsx(Text, { style: { color: "#fff", fontSize: size * 0.4, fontWeight: "700" }, children: name.trim().charAt(0).toUpperCase() || "•" })) }));
74
+ };
75
+ if (!prewarm && !open)
76
+ return _jsx(AboveNativeScreens, { overlay: overlay, children: button({ start: () => { } }) });
77
+ return (_jsx(GraineVoiceLauncher, { webView: webView, onEnded: () => { setOpen(false); onClose?.(); }, children: (api) => (_jsx(AboveNativeScreens, { overlay: overlay, children: open ? _jsx(GraineAgentBar, { accent: dashboardAccent, name: name }) : button(api) })) }));
75
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graineai/inapp-react-native",
3
- "version": "0.27.1",
3
+ "version": "0.27.2",
4
4
  "type": "module",
5
5
  "description": "Graine in-app agent for React Native — an agent that sees the screen your customer is on and can act on it.",
6
6
  "license": "MIT",