@live-assistant/react-native 0.3.1 → 0.3.4
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/live-assistant.d.ts
CHANGED
|
@@ -53,6 +53,10 @@ export type LiveAssistantProps = LiveAssistantEndpointProps | LiveAssistantConne
|
|
|
53
53
|
* through a ref, so passing them inline — which is how anyone passes them —
|
|
54
54
|
* cannot re-run the lifecycle effect. It once could, and its cleanup hung up
|
|
55
55
|
* on a live session whenever a parent re-rendered.
|
|
56
|
+
* - **`tools`, `page` and `timing` are read once**, when the assistant is
|
|
57
|
+
* created: they configure a controller that outlives any one render. Register
|
|
58
|
+
* a tool later through the controller `onReady` hands you. `theme`, `strings`,
|
|
59
|
+
* `headers` and `language` are live.
|
|
56
60
|
* - **`headers` and `language` are read at connection time, not at mount.** An
|
|
57
61
|
* app whose `Authorization` header is refreshed mid-session would otherwise
|
|
58
62
|
* reconnect with the token it had when the component first rendered — which
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-assistant.d.ts","sourceRoot":"","sources":["../src/live-assistant.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG1H,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAGpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,mEAAmE;AACnE,UAAU,wBAAyB,SAAQ,oBAAoB;IAC7D,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,oHAAoH;IACpH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC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AM,MAAM,kBAAkB,GAAG,0BAA0B,GAAG,4BAA4B,CAAC;AAK3F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,aAAa,EACb,QAA2B,EAC3B,OAAO,EACP,KAAK,EACL,IAAI,EACJ,MAAM,EACN,OAAO,EACP,SAAS,EACT,GAAG,MAAM,EACV,EAAE,kBAAkB,+BA8CpB"}
|
package/dist/live-assistant.js
CHANGED
|
@@ -31,6 +31,10 @@ const JSON_TYPE = 'application/json';
|
|
|
31
31
|
* through a ref, so passing them inline — which is how anyone passes them —
|
|
32
32
|
* cannot re-run the lifecycle effect. It once could, and its cleanup hung up
|
|
33
33
|
* on a live session whenever a parent re-rendered.
|
|
34
|
+
* - **`tools`, `page` and `timing` are read once**, when the assistant is
|
|
35
|
+
* created: they configure a controller that outlives any one render. Register
|
|
36
|
+
* a tool later through the controller `onReady` hands you. `theme`, `strings`,
|
|
37
|
+
* `headers` and `language` are live.
|
|
34
38
|
* - **`headers` and `language` are read at connection time, not at mount.** An
|
|
35
39
|
* app whose `Authorization` header is refreshed mid-session would otherwise
|
|
36
40
|
* reconnect with the token it had when the component first rendered — which
|
|
@@ -46,8 +50,8 @@ const JSON_TYPE = 'application/json';
|
|
|
46
50
|
*/
|
|
47
51
|
function LiveAssistant({ tokenEndpoint, getConnection, language = DEFAULT_LANGUAGE, headers, tools, page, timing, onReady, onFailure, ...widget }) {
|
|
48
52
|
// Read at connection time rather than captured at mount: see the doc block.
|
|
49
|
-
const latest = (0, react_1.useRef)({ tokenEndpoint, getConnection, language, headers, onReady
|
|
50
|
-
latest.current = { tokenEndpoint, getConnection, language, headers, onReady
|
|
53
|
+
const latest = (0, react_1.useRef)({ tokenEndpoint, getConnection, language, headers, onReady });
|
|
54
|
+
latest.current = { tokenEndpoint, getConnection, language, headers, onReady };
|
|
51
55
|
const [controller] = (0, react_1.useState)(() => new core_1.AssistantController({
|
|
52
56
|
session: new gemini_1.GeminiLiveSession(),
|
|
53
57
|
microphone: new audio_1.Microphone(),
|
|
@@ -59,6 +63,10 @@ function LiveAssistant({ tokenEndpoint, getConnection, language = DEFAULT_LANGUA
|
|
|
59
63
|
const current = latest.current;
|
|
60
64
|
if (current.getConnection !== undefined)
|
|
61
65
|
return current.getConnection({ resumptionHandle });
|
|
66
|
+
// Types make this unreachable; JavaScript does not, and `fetch(undefined)`
|
|
67
|
+
// fails as a network error nobody can place.
|
|
68
|
+
if (current.tokenEndpoint === undefined)
|
|
69
|
+
throw new Error('LiveAssistant needs tokenEndpoint or getConnection');
|
|
62
70
|
const response = await fetch(current.tokenEndpoint, {
|
|
63
71
|
method: 'POST',
|
|
64
72
|
headers: { 'content-type': JSON_TYPE, ...current.headers },
|
|
@@ -77,7 +85,7 @@ function LiveAssistant({ tokenEndpoint, getConnection, language = DEFAULT_LANGUA
|
|
|
77
85
|
latest.current.onReady?.(controller);
|
|
78
86
|
return () => void controller.stop();
|
|
79
87
|
}, [controller]);
|
|
80
|
-
return ((0, jsx_runtime_1.jsxs)(react_2.AssistantProvider, { controller: controller, children: [(0, jsx_runtime_1.jsx)(FailureReporter, { onFailure:
|
|
88
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.AssistantProvider, { controller: controller, children: [(0, jsx_runtime_1.jsx)(FailureReporter, { onFailure: onFailure }), (0, jsx_runtime_1.jsx)(widget_1.AssistantWidget, { ...widget })] }));
|
|
81
89
|
}
|
|
82
90
|
const selectError = (state) => state.error;
|
|
83
91
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-assistant.js","sourceRoot":"","sources":["../src/live-assistant.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"live-assistant.js","sourceRoot":"","sources":["../src/live-assistant.tsx"],"names":[],"mappings":";;AAmFA,sCAyDC;;AA5ID,iCAAoD;AACpD,+CAAyE;AAEzE,iDAA8D;AAC9D,mDAA2D;AAE3D,iDAA6E;A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AC,KAAK,CAAC,KAAK,CAAC;AAEjH;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,EAAE,SAAS,EAAgE;IAClG,MAAM,KAAK,GAAG,IAAA,yBAAiB,EAAC,WAAW,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAA,cAAM,EAAC,SAAS,CAAC,CAAC;IACjC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-assistant/react-native",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "One install for a voice assistant in a React Native or Expo app: the session, a Gemini Live connection, microphone and playback, React bindings and a ready-made widget, all re-exported from one place.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Recep Tayyip Ekşi",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@live-assistant/audio": "0.3.
|
|
45
|
-
"@live-assistant/core": "0.3.
|
|
46
|
-
"@live-assistant/gemini": "0.3.
|
|
47
|
-
"@live-assistant/react": "0.3.
|
|
48
|
-
"@live-assistant/widget": "0.3.
|
|
44
|
+
"@live-assistant/audio": "0.3.4",
|
|
45
|
+
"@live-assistant/core": "0.3.4",
|
|
46
|
+
"@live-assistant/gemini": "0.3.4",
|
|
47
|
+
"@live-assistant/react": "0.3.4",
|
|
48
|
+
"@live-assistant/widget": "0.3.4"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": ">=18",
|
package/src/live-assistant.tsx
CHANGED
|
@@ -64,6 +64,10 @@ const JSON_TYPE = 'application/json';
|
|
|
64
64
|
* through a ref, so passing them inline — which is how anyone passes them —
|
|
65
65
|
* cannot re-run the lifecycle effect. It once could, and its cleanup hung up
|
|
66
66
|
* on a live session whenever a parent re-rendered.
|
|
67
|
+
* - **`tools`, `page` and `timing` are read once**, when the assistant is
|
|
68
|
+
* created: they configure a controller that outlives any one render. Register
|
|
69
|
+
* a tool later through the controller `onReady` hands you. `theme`, `strings`,
|
|
70
|
+
* `headers` and `language` are live.
|
|
67
71
|
* - **`headers` and `language` are read at connection time, not at mount.** An
|
|
68
72
|
* app whose `Authorization` header is refreshed mid-session would otherwise
|
|
69
73
|
* reconnect with the token it had when the component first rendered — which
|
|
@@ -90,8 +94,8 @@ export function LiveAssistant({
|
|
|
90
94
|
...widget
|
|
91
95
|
}: LiveAssistantProps) {
|
|
92
96
|
// Read at connection time rather than captured at mount: see the doc block.
|
|
93
|
-
const latest = useRef({ tokenEndpoint, getConnection, language, headers, onReady
|
|
94
|
-
latest.current = { tokenEndpoint, getConnection, language, headers, onReady
|
|
97
|
+
const latest = useRef({ tokenEndpoint, getConnection, language, headers, onReady });
|
|
98
|
+
latest.current = { tokenEndpoint, getConnection, language, headers, onReady };
|
|
95
99
|
|
|
96
100
|
const [controller] = useState(
|
|
97
101
|
() =>
|
|
@@ -105,7 +109,10 @@ export function LiveAssistant({
|
|
|
105
109
|
getConnection: async ({ resumptionHandle }) => {
|
|
106
110
|
const current = latest.current;
|
|
107
111
|
if (current.getConnection !== undefined) return current.getConnection({ resumptionHandle });
|
|
108
|
-
|
|
112
|
+
// Types make this unreachable; JavaScript does not, and `fetch(undefined)`
|
|
113
|
+
// fails as a network error nobody can place.
|
|
114
|
+
if (current.tokenEndpoint === undefined) throw new Error('LiveAssistant needs tokenEndpoint or getConnection');
|
|
115
|
+
const response = await fetch(current.tokenEndpoint, {
|
|
109
116
|
method: 'POST',
|
|
110
117
|
headers: { 'content-type': JSON_TYPE, ...current.headers },
|
|
111
118
|
body: JSON.stringify({ resumptionHandle, languageCode: current.language }),
|
|
@@ -127,7 +134,7 @@ export function LiveAssistant({
|
|
|
127
134
|
|
|
128
135
|
return (
|
|
129
136
|
<AssistantProvider controller={controller}>
|
|
130
|
-
<FailureReporter onFailure={
|
|
137
|
+
<FailureReporter onFailure={onFailure} />
|
|
131
138
|
<AssistantWidget {...widget} />
|
|
132
139
|
</AssistantProvider>
|
|
133
140
|
);
|