@graineai/inapp-react-native 0.31.0 → 0.32.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 +2 -1
- package/dist/index.js +1 -0
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.js +12 -0
- package/dist/react-native/index.d.ts +7 -0
- package/dist/react-native/index.js +9 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export type { ActionHandler, AppActionRequest, AppActionResult, AppEvent, ScreenContext, ScreenField, } from "./protocol.js";
|
|
1
|
+
export type { ActionHandler, AppActionRequest, AppActionResult, AppEvent, ScreenContext, ScreenField, WidgetSurface, } from "./protocol.js";
|
|
2
|
+
export { widgetSurface } from "./protocol.js";
|
|
2
3
|
export { GraineInAppClient, type GraineInAppOptions, type SessionConfig, type ActionDiagnosis, } from "./client.js";
|
|
3
4
|
export { FrictionDetector, resolveFriction, rulesFor, DEFAULT_FRICTION, type FrictionConfig, type FrictionScreenRules, type FrictionNudge, type FrictionSignal, type FrictionKind, } from "./friction.js";
|
|
4
5
|
export { VoiceSession, liveAudioStreamAdapter, base64ToPcm16, CAPTURE_SAMPLE_RATE, type AudioAdapter, type VoiceSessionOptions, } from "./voice.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { widgetSurface } from "./protocol.js";
|
|
1
2
|
export { GraineInAppClient, } from "./client.js";
|
|
2
3
|
export { FrictionDetector, resolveFriction, rulesFor, DEFAULT_FRICTION, } from "./friction.js";
|
|
3
4
|
export { VoiceSession, liveAudioStreamAdapter, base64ToPcm16, CAPTURE_SAMPLE_RATE, } from "./voice.js";
|
package/dist/protocol.d.ts
CHANGED
|
@@ -62,3 +62,5 @@ export declare const ACTION_DEADLINE_MS = 6000;
|
|
|
62
62
|
export declare const CONTEXT_THROTTLE_MS = 400;
|
|
63
63
|
export declare const UNNAMED_TAP = "tap:screen";
|
|
64
64
|
export declare function resolveWidgetImages(data: Record<string, unknown>, baseUrl: string): Record<string, unknown>;
|
|
65
|
+
export type WidgetSurface = "screen" | "sheet" | "card";
|
|
66
|
+
export declare function widgetSurface(kind: string | null | undefined): WidgetSurface;
|
package/dist/protocol.js
CHANGED
|
@@ -29,3 +29,15 @@ export function resolveWidgetImages(data, baseUrl) {
|
|
|
29
29
|
}
|
|
30
30
|
return out;
|
|
31
31
|
}
|
|
32
|
+
const SURFACE = {
|
|
33
|
+
product_list: "screen",
|
|
34
|
+
products: "screen",
|
|
35
|
+
plan_comparison: "sheet",
|
|
36
|
+
choices: "sheet",
|
|
37
|
+
quick_actions: "sheet",
|
|
38
|
+
calendar_slots: "sheet",
|
|
39
|
+
info_card: "card",
|
|
40
|
+
};
|
|
41
|
+
export function widgetSurface(kind) {
|
|
42
|
+
return SURFACE[String(kind ?? "").trim().toLowerCase()] ?? "card";
|
|
43
|
+
}
|
|
@@ -4,6 +4,8 @@ import { type AudioAdapter, type VoiceSessionOptions } from "../voice.js";
|
|
|
4
4
|
import type { ActionHandler, ScreenContext, ScreenField } from "../protocol.js";
|
|
5
5
|
export { GraineFab, GraineTouchCapture } from "./fab.js";
|
|
6
6
|
export type { GraineFabProps, GraineTouchCaptureProps } from "./fab.js";
|
|
7
|
+
export { widgetSurface } from "../protocol.js";
|
|
8
|
+
export type { WidgetSurface } from "../protocol.js";
|
|
7
9
|
import type { FrictionConfig } from "../friction.js";
|
|
8
10
|
import { type LauncherInset, type LauncherVisibility } from "./navigation.js";
|
|
9
11
|
interface GraineContextValue {
|
|
@@ -123,6 +125,11 @@ export declare function useGraineHighlight(name: string): {
|
|
|
123
125
|
};
|
|
124
126
|
export declare function useGraineWidget(): {
|
|
125
127
|
widget: GraineWidget | null;
|
|
128
|
+
answered: {
|
|
129
|
+
widget: GraineWidget;
|
|
130
|
+
data: Record<string, unknown>;
|
|
131
|
+
summary: string;
|
|
132
|
+
} | null;
|
|
126
133
|
submit: (data: Record<string, unknown>, summary: string) => void;
|
|
127
134
|
dismiss: () => void;
|
|
128
135
|
};
|
|
@@ -6,6 +6,7 @@ import { VoiceSession } from "../voice.js";
|
|
|
6
6
|
import { resolveWidgetImages } from "../protocol.js";
|
|
7
7
|
import { GraineFab, GraineTouchCapture } from "./fab.js";
|
|
8
8
|
export { GraineFab, GraineTouchCapture } from "./fab.js";
|
|
9
|
+
export { widgetSurface } from "../protocol.js";
|
|
9
10
|
import { LauncherVisibilityTracker, activeRouteName, } from "./navigation.js";
|
|
10
11
|
export const Ctx = createContext(null);
|
|
11
12
|
let defaultClient = null;
|
|
@@ -398,14 +399,17 @@ export function useGraineWidget() {
|
|
|
398
399
|
}
|
|
399
400
|
: null, [client]);
|
|
400
401
|
const [widget, setWidget] = useState(() => adopt(client.pendingWidget));
|
|
402
|
+
const [answered, setAnswered] = useState(null);
|
|
401
403
|
useEffect(() => {
|
|
402
404
|
const pending = adopt(client.pendingWidget);
|
|
403
405
|
if (pending)
|
|
404
406
|
setWidget((cur) => (cur && cur.id === pending.id ? cur : pending));
|
|
405
407
|
return client.on("widget", (w) => {
|
|
406
408
|
const next = adopt(w);
|
|
407
|
-
if (next)
|
|
408
|
-
|
|
409
|
+
if (!next)
|
|
410
|
+
return;
|
|
411
|
+
setWidget(next);
|
|
412
|
+
setAnswered(null);
|
|
409
413
|
});
|
|
410
414
|
}, [client, adopt]);
|
|
411
415
|
const submit = useCallback((data, summary) => {
|
|
@@ -414,12 +418,14 @@ export function useGraineWidget() {
|
|
|
414
418
|
client.submitWidget(widget.id, data, summary);
|
|
415
419
|
client.clearPendingWidget();
|
|
416
420
|
setWidget(null);
|
|
421
|
+
setAnswered({ widget, data, summary });
|
|
417
422
|
}, [client, widget]);
|
|
418
423
|
const dismiss = useCallback(() => {
|
|
419
424
|
client.clearPendingWidget();
|
|
420
425
|
setWidget(null);
|
|
426
|
+
setAnswered(null);
|
|
421
427
|
}, [client]);
|
|
422
|
-
return { widget, submit, dismiss };
|
|
428
|
+
return { widget, answered, submit, dismiss };
|
|
423
429
|
}
|
|
424
430
|
export function useGraineAction(name, handler) {
|
|
425
431
|
const client = useGraineClient();
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graineai/inapp-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Graine in-app agent for React Native
|
|
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",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "dist/index.js",
|