@graineai/inapp-react-native 0.17.0 → 0.18.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.
@@ -27,6 +27,7 @@ export interface GraineVoiceApi {
27
27
  connected: boolean;
28
28
  connecting: boolean;
29
29
  muted: boolean;
30
+ ready: boolean;
30
31
  start: () => void;
31
32
  end: () => void;
32
33
  setMuted: (m: boolean) => void;
@@ -116,7 +116,8 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, trans
116
116
  case "graine:ready":
117
117
  setReady(true);
118
118
  pushContext();
119
- if (autoStart && !startedRef.current) {
119
+ if ((autoStart || pendingStartRef.current) && !startedRef.current) {
120
+ pendingStartRef.current = false;
120
121
  startedRef.current = true;
121
122
  void beginCall();
122
123
  }
@@ -156,14 +157,20 @@ export function GraineVoiceLauncher({ webView: WebView, autoStart = false, trans
156
157
  }
157
158
  }
158
159
  }, [autoStart, beginCall, client, onCaption, onCallState, onMicDenied, onTransport, onError, onEnded, post, pushContext]);
160
+ const pendingStartRef = useRef(false);
159
161
  const api = {
160
162
  connected,
161
163
  connecting,
162
164
  muted,
165
+ ready: !!voiceAgentId && ready,
163
166
  start: useCallback(() => {
164
167
  setConnecting(true);
168
+ if (!ready) {
169
+ pendingStartRef.current = true;
170
+ return;
171
+ }
165
172
  void beginCall();
166
- }, [beginCall]),
173
+ }, [beginCall, ready]),
167
174
  end: useCallback(() => post({ type: "graine:end-call" }), [post]),
168
175
  setMuted: useCallback((m) => {
169
176
  setMutedState(m);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graineai/inapp-react-native",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "description": "Graine in-app agent for React Native \u2014 an agent that sees the screen your customer is on and can act on it.",
6
6
  "license": "MIT",