@graineai/inapp-react-native 0.9.0 → 0.11.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/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { GraineInAppClient, type GraineInAppOptions, type SessionConfig } from "
|
|
|
3
3
|
export { VoiceSession, liveAudioStreamAdapter, base64ToPcm16, CAPTURE_SAMPLE_RATE, type AudioAdapter, type VoiceSessionOptions, } from "./voice";
|
|
4
4
|
export { EchoGuard, decodeAgentAudio, decodeMuLaw, decodePcm16, base64ToBytes, type AudioFormat, type DecodedAudio, } from "./audio";
|
|
5
5
|
export { addMaskRule, maskDeep, maskString } from "./mask";
|
|
6
|
-
export { GraineProvider, useGraineAgent, useGraineScreen, useGraineAction, useGraineVoice, useGraineIdentify, useGraineEvents, useGraineTrack, type GraineEvent, type GraineProviderProps, type Turn, type Caption, } from "./react-native/index";
|
|
6
|
+
export { GraineProvider, useGraineAgent, useGraineScreen, useGraineAction, useGraineVoice, useGraineIdentify, useGraineEvents, useGraineTrack, useGraineTap, type GraineEvent, type GraineProviderProps, type Turn, type Caption, } from "./react-native/index";
|
|
7
7
|
export { GraineAgentBar, GraineLauncher, type GraineAgentBarProps, type GraineLauncherProps } from "./react-native/ui";
|
|
8
8
|
export { GraineVoiceLauncher, type GraineVoiceLauncherProps, type GraineVoiceApi, } from "./react-native/voice-launcher";
|
|
9
9
|
export { LauncherVisibilityTracker, activeRouteName, type LauncherInset, type LauncherContinuity, type LauncherDelayPolicy, type LauncherGroup, type LauncherVisibility, type VisibilityDecision, } from "./react-native/navigation";
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { GraineInAppClient } from "./client";
|
|
|
2
2
|
export { VoiceSession, liveAudioStreamAdapter, base64ToPcm16, CAPTURE_SAMPLE_RATE, } from "./voice";
|
|
3
3
|
export { EchoGuard, decodeAgentAudio, decodeMuLaw, decodePcm16, base64ToBytes, } from "./audio";
|
|
4
4
|
export { addMaskRule, maskDeep, maskString } from "./mask";
|
|
5
|
-
export { GraineProvider, useGraineAgent, useGraineScreen, useGraineAction, useGraineVoice, useGraineIdentify, useGraineEvents, useGraineTrack, } from "./react-native/index";
|
|
5
|
+
export { GraineProvider, useGraineAgent, useGraineScreen, useGraineAction, useGraineVoice, useGraineIdentify, useGraineEvents, useGraineTrack, useGraineTap, } from "./react-native/index";
|
|
6
6
|
export { GraineAgentBar, GraineLauncher } from "./react-native/ui";
|
|
7
7
|
export { GraineVoiceLauncher, } from "./react-native/voice-launcher";
|
|
8
8
|
export { LauncherVisibilityTracker, activeRouteName, } from "./react-native/navigation";
|
|
@@ -75,6 +75,7 @@ export declare function GraineProvider({ children, autoConnect, onProactive, nav
|
|
|
75
75
|
export declare function useGraineAgent(): GraineContextValue;
|
|
76
76
|
export declare function useGraineEvents(handler: (e: GraineEvent) => void): void;
|
|
77
77
|
export declare function useGraineTrack(): (name: string, data?: Record<string, unknown>) => void;
|
|
78
|
+
export declare function useGraineTap<T extends (...args: any[]) => any>(name: string, handler?: T, data?: Record<string, unknown>): (...args: Parameters<T>) => ReturnType<T> | undefined;
|
|
78
79
|
export declare function useGraineIdentify(): (user: Record<string, unknown> | null) => void;
|
|
79
80
|
export declare function useGraineVoice(adapter: AudioAdapter | null, options?: VoiceSessionOptions): {
|
|
80
81
|
listening: boolean;
|
|
@@ -211,6 +211,21 @@ export function useGraineTrack() {
|
|
|
211
211
|
const { track } = useGraine();
|
|
212
212
|
return track;
|
|
213
213
|
}
|
|
214
|
+
export function useGraineTap(name, handler, data) {
|
|
215
|
+
const { track } = useGraine();
|
|
216
|
+
const handlerRef = useRef(handler);
|
|
217
|
+
handlerRef.current = handler;
|
|
218
|
+
const dataRef = useRef(data);
|
|
219
|
+
dataRef.current = data;
|
|
220
|
+
return useCallback((...args) => {
|
|
221
|
+
try {
|
|
222
|
+
track(`tap:${name}`, dataRef.current);
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
}
|
|
226
|
+
return handlerRef.current?.(...args);
|
|
227
|
+
}, [name, track]);
|
|
228
|
+
}
|
|
214
229
|
export function useGraineIdentify() {
|
|
215
230
|
const { client } = useGraine();
|
|
216
231
|
return useCallback((user) => client.identify(user), [client]);
|
|
@@ -11,6 +11,8 @@ export interface GraineVoiceLauncherProps {
|
|
|
11
11
|
connected: boolean;
|
|
12
12
|
connecting: boolean;
|
|
13
13
|
}) => void;
|
|
14
|
+
onEnded?: () => void;
|
|
15
|
+
onMicDenied?: (reason: string) => void;
|
|
14
16
|
children?: (api: GraineVoiceApi) => React.ReactNode;
|
|
15
17
|
}
|
|
16
18
|
export interface GraineVoiceApi {
|
|
@@ -21,4 +23,4 @@ export interface GraineVoiceApi {
|
|
|
21
23
|
end: () => void;
|
|
22
24
|
setMuted: (m: boolean) => void;
|
|
23
25
|
}
|
|
24
|
-
export declare function GraineVoiceLauncher({ webView: WebView, autoStart, onCaption, onCallState, children, }: GraineVoiceLauncherProps): React.JSX.Element;
|
|
26
|
+
export declare function GraineVoiceLauncher({ webView: WebView, autoStart, onCaption, onCallState, onMicDenied, onEnded, children, }: GraineVoiceLauncherProps): React.JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { useGraineAgent } from "./index";
|
|
5
|
-
export function GraineVoiceLauncher({ webView: WebView, autoStart = false, onCaption, onCallState, children, }) {
|
|
5
|
+
export function GraineVoiceLauncher({ webView: WebView, autoStart = false, onCaption, onCallState, onMicDenied, onEnded, children, }) {
|
|
6
6
|
const { client, appearance } = useGraineAgent();
|
|
7
7
|
const ref = useRef(null);
|
|
8
8
|
const [connected, setConnected] = useState(false);
|
|
@@ -54,6 +54,14 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, onCap
|
|
|
54
54
|
case "graine:caption":
|
|
55
55
|
onCaption?.({ role: msg.role, text: msg.text, live: !!msg.live });
|
|
56
56
|
return;
|
|
57
|
+
case "graine:ended":
|
|
58
|
+
setConnected(false);
|
|
59
|
+
setConnecting(false);
|
|
60
|
+
onEnded?.();
|
|
61
|
+
return;
|
|
62
|
+
case "graine:mic-denied":
|
|
63
|
+
onMicDenied?.(String(msg.reason || "denied"));
|
|
64
|
+
return;
|
|
57
65
|
case "graine:app-action": {
|
|
58
66
|
const action = msg.action || {};
|
|
59
67
|
const result = await client.executeAction(action.name, action.arguments || {});
|
|
@@ -67,7 +75,7 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, onCap
|
|
|
67
75
|
return;
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
|
-
}, [autoStart, client, onCaption, onCallState, post, pushContext]);
|
|
78
|
+
}, [autoStart, client, onCaption, onCallState, onMicDenied, onEnded, post, pushContext]);
|
|
71
79
|
const api = {
|
|
72
80
|
connected,
|
|
73
81
|
connecting,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graineai/inapp-react-native",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Graine in-app agent for React Native
|
|
3
|
+
"version": "0.11.0",
|
|
4
|
+
"description": "Graine in-app agent for React Native — an agent that sees the screen your customer is on and can act on it.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"main": "dist/index.js",
|