@convai/web-widget 0.2.1 → 0.3.1
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/README.md +27 -5
- package/index.js +1 -1
- package/package.json +1 -1
- package/react.js +88 -2
- package/runtime.js +1169 -1120
- package/ui/react/components/ConvaiWidget.d.ts +8 -7
- package/ui/react/hooks/useCharacterInfo.d.ts +1 -1
- package/ui/react/hooks/useLiveClient.d.ts +26 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { type LiveClientFields } from "../hooks/useLiveClient";
|
|
1
2
|
import type { LinkPreviewResolver } from "@convai/web-sdk/core";
|
|
2
3
|
import type { IConvaiClient, PublishedChatConnectOptions } from "@convai/web-sdk/core";
|
|
3
4
|
import type { PublishedChatDescriptor } from "@convai/web-sdk/embed";
|
|
4
5
|
interface ConvaiWidgetProps {
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The Convai client (required). Either `useConvaiClient`'s result, or any
|
|
8
|
+
* `ConvaiClient` — one built with `new ConvaiClient(...)`, or the character's
|
|
9
|
+
* own client from `@convai/embody`. The widget subscribes to a bare client's
|
|
10
|
+
* events itself and never opens a second connection.
|
|
11
|
+
*/
|
|
12
|
+
convaiClient: IConvaiClient & Partial<LiveClientFields>;
|
|
12
13
|
/**
|
|
13
14
|
* Show video toggle button in settings (default: true).
|
|
14
15
|
* Only works if connection type is "video". If false, hides the video button.
|
|
@@ -6,7 +6,7 @@ import { type CharacterInfo } from "@convai/web-sdk/core";
|
|
|
6
6
|
* the same code rather than a hand-synced copy of it.
|
|
7
7
|
*
|
|
8
8
|
* @param characterId - Character to look up
|
|
9
|
-
* @param apiKey - Convai API key, sent as `
|
|
9
|
+
* @param apiKey - Convai API key, sent as `CONVAI-API-KEY`
|
|
10
10
|
* @param authToken - Preferred over `apiKey`, sent as `API-AUTH-TOKEN`
|
|
11
11
|
* @param baseUrl - Origin to ask; defaults to `https://api.convai.com`. Pass
|
|
12
12
|
* `client.characterInfoUrl` so a non-SaaS deployment is not asked to send
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IConvaiClient } from "@convai/web-sdk/core";
|
|
2
|
+
/** The fields `useConvaiClient` adds on top of the client. */
|
|
3
|
+
export interface LiveClientFields {
|
|
4
|
+
activity: string;
|
|
5
|
+
isAudioMuted: boolean;
|
|
6
|
+
isVideoEnabled: boolean;
|
|
7
|
+
isScreenShareActive: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** True for a `useConvaiClient` result, which carries the UI fields itself. */
|
|
10
|
+
export declare function isManagedClient(client: object): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The four UI fields for `client`: its own when `useConvaiClient` supplied
|
|
13
|
+
* them, otherwise read live from the client, re-rendering on every change.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useLiveClient(client: IConvaiClient & Partial<LiveClientFields>): LiveClientFields;
|
|
16
|
+
/**
|
|
17
|
+
* The client as the widget should see it: a `useConvaiClient` result as-is,
|
|
18
|
+
* otherwise a view that adds the four UI fields and changes identity on every
|
|
19
|
+
* client event — exactly how a `useConvaiClient` result behaves, so the widget
|
|
20
|
+
* and its children re-render and re-run their effects the same way.
|
|
21
|
+
*
|
|
22
|
+
* A Proxy, not a copy: reads, writes and `this` inside methods all reach the
|
|
23
|
+
* real client, and only the four fields are answered here. The app's own
|
|
24
|
+
* reference to the client is never modified.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useLiveClientView<C extends IConvaiClient & Partial<LiveClientFields>>(client: C): C & LiveClientFields;
|