@tavus/cvi-ui 0.0.1-beta.3 → 0.0.1-beta.5

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.
Files changed (50) hide show
  1. package/README.md +15 -59
  2. package/dev-components/components/README.md +95 -70
  3. package/dev-components/components/conversation-01/conversation.module.css +7 -1
  4. package/dev-components/components/conversation-01/index.tsx +38 -45
  5. package/dev-components/components/{controls → device-select}/index.tsx +5 -5
  6. package/dev-components/components/hair-check-01/hair-check.module.css +1 -1
  7. package/dev-components/components/hair-check-01/index.tsx +3 -3
  8. package/dev-components/components/media-controls/index.tsx +207 -0
  9. package/dev-components/components/media-controls/media-controls.module.css +49 -0
  10. package/dev-components/hooks/cvi-events-hooks.tsx +6 -6
  11. package/dev-components/hooks/use-cvi-call.tsx +7 -0
  12. package/dist/index.js +195 -145
  13. package/dist/types/constants/frameworks.d.ts +4 -0
  14. package/dist/types/templates/components.d.ts +6 -3
  15. package/dist/types/templates/jsx/index.d.ts +2 -1
  16. package/dist/types/templates/tsx/index.d.ts +2 -1
  17. package/package.json +6 -2
  18. package/prepare-scripts/create-templates.js +1 -1
  19. package/src/constants/frameworks.ts +4 -0
  20. package/src/preflights/preflight-init.ts +1 -1
  21. package/src/templates/components.ts +2 -1
  22. package/src/templates/jsx/components/conversation-01.json +6 -4
  23. package/src/templates/jsx/components/device-select.json +10 -0
  24. package/src/templates/jsx/components/hair-check-01.json +5 -4
  25. package/src/templates/jsx/components/media-controls.json +10 -0
  26. package/src/templates/jsx/hooks/cvi-events-hooks.json +1 -1
  27. package/src/templates/jsx/hooks/use-cvi-call.json +1 -1
  28. package/src/templates/jsx/index.ts +2 -1
  29. package/src/templates/tsx/components/conversation-01.json +6 -4
  30. package/src/templates/tsx/components/device-select.json +10 -0
  31. package/src/templates/tsx/components/hair-check-01.json +5 -4
  32. package/src/templates/tsx/components/media-controls.json +10 -0
  33. package/src/templates/tsx/hooks/cvi-events-hooks.json +1 -1
  34. package/src/templates/tsx/hooks/use-cvi-call.json +1 -1
  35. package/src/templates/tsx/index.ts +2 -1
  36. package/src/utils/get-project-info.ts +118 -124
  37. package/dist/templates/components/controls.tsx +0 -279
  38. package/dist/templates/components/cvi-provider.tsx +0 -9
  39. package/dist/templates/controls.tsx +0 -279
  40. package/dist/templates/cvi-hooks.tsx +0 -38
  41. package/dist/templates/cvi-provider.tsx +0 -9
  42. package/dist/templates/hooks/cvi-hooks.tsx +0 -38
  43. package/dist/templates/tsx/components/controls.tsx +0 -279
  44. package/dist/templates/tsx/components/cvi-provider.tsx +0 -9
  45. package/dist/types/constants/components.d.ts +0 -59
  46. package/dist/types/utils/resolve-import.d.ts +0 -2
  47. package/dist/typescript-XxXP1Woc.js +0 -14
  48. package/src/templates/jsx/components/controls.json +0 -10
  49. package/src/templates/tsx/components/controls.json +0 -10
  50. /package/dev-components/components/{controls/controls.module.css → device-select/device-select.module.css} +0 -0
@@ -0,0 +1,207 @@
1
+ import React, { memo } from "react";
2
+ import { useLocalCamera } from "../../hooks/use-local-camera";
3
+ import { useLocalMicrophone } from "../../hooks/use-local-microphone";
4
+ import { useLocalScreenshare } from "../../hooks/use-local-screenshare";
5
+
6
+ import styles from "./media-controls.module.css";
7
+
8
+ export const MicToggleButton = memo(() => {
9
+ const { onToggleMicrophone, isMicReady, isMicMuted } = useLocalMicrophone();
10
+
11
+ return (
12
+ <button
13
+ type="button"
14
+ onClick={onToggleMicrophone}
15
+ disabled={!isMicReady}
16
+ className={styles.deviceButton}
17
+ >
18
+ <span className={styles.deviceButtonIcon}>
19
+ {isMicMuted || !isMicReady ? (
20
+ <svg
21
+ xmlns="http://www.w3.org/2000/svg"
22
+ width="24"
23
+ height="24"
24
+ viewBox="0 0 24 24"
25
+ fill="none"
26
+ role="img"
27
+ aria-label="Microphone Muted"
28
+ >
29
+ <path
30
+ d="M12 18C10.1435 18 8.36301 17.2625 7.05025 15.9497C5.7375 14.637 5 12.8565 5 11V10M12 18C13.8565 18 15.637 17.2625 16.9497 15.9497C18.2625 14.637 18.1339 14.0992 18.1339 14.0992M12 18V21"
31
+ stroke="#020617"
32
+ strokeWidth="1.66667"
33
+ strokeLinecap="round"
34
+ strokeLinejoin="round"
35
+ />
36
+ <rect
37
+ x="1.30225"
38
+ y="3"
39
+ width="26"
40
+ height="2.24738"
41
+ rx="1.12369"
42
+ transform="rotate(30 1.30225 3)"
43
+ fill="#020617"
44
+ />
45
+ <path
46
+ fillRule="evenodd"
47
+ clipRule="evenodd"
48
+ d="M9 9.39031V11C9 11.7956 9.31607 12.5587 9.87868 13.1213C10.4413 13.6839 11.2044 14 12 14C12.7956 14 13.5587 13.6839 14.1213 13.1213C14.2829 12.9597 14.4242 12.7816 14.5435 12.5908L9 9.39031ZM15 7.71466V6C15 5.20435 14.6839 4.44129 14.1213 3.87868C13.5587 3.31607 12.7956 3 12 3C11.2044 3 10.4413 3.31607 9.87868 3.87868C9.69528 4.06208 9.53807 4.26678 9.40948 4.48697L15 7.71466Z"
49
+ fill="#020617"
50
+ />
51
+ <path
52
+ d="M9 9.39031L9.41667 8.66862C9.15883 8.51976 8.84117 8.51976 8.58333 8.66862C8.3255 8.81748 8.16667 9.09259 8.16667 9.39031H9ZM9.87868 13.1213L9.28942 13.7106H9.28942L9.87868 13.1213ZM14.1213 13.1213L14.7106 13.7106L14.7106 13.7106L14.1213 13.1213ZM14.5435 12.5908L15.25 13.0327C15.3699 12.841 15.4068 12.6088 15.3521 12.3894C15.2974 12.17 15.156 11.9822 14.9601 11.8692L14.5435 12.5908ZM15 7.71466L14.5833 8.43635C14.8412 8.58521 15.1588 8.58521 15.4167 8.43635C15.6745 8.28749 15.8333 8.01238 15.8333 7.71466H15ZM14.1213 3.87868L14.7106 3.28942L14.7106 3.28942L14.1213 3.87868ZM9.87868 3.87868L9.28942 3.28942L9.28942 3.28942L9.87868 3.87868ZM9.40948 4.48697L8.68988 4.06671C8.57806 4.25818 8.54715 4.48633 8.604 4.70065C8.66086 4.91497 8.80078 5.09779 8.99281 5.20866L9.40948 4.48697ZM9.83333 11V9.39031H8.16667V11H9.83333ZM10.4679 12.5321C10.0616 12.1257 9.83333 11.5746 9.83333 11H8.16667C8.16667 12.0167 8.57053 12.9917 9.28942 13.7106L10.4679 12.5321ZM12 13.1667C11.4254 13.1667 10.8743 12.9384 10.4679 12.5321L9.28942 13.7106C10.0083 14.4295 10.9833 14.8333 12 14.8333V13.1667ZM13.5321 12.5321C13.1257 12.9384 12.5746 13.1667 12 13.1667V14.8333C13.0167 14.8333 13.9917 14.4295 14.7106 13.7106L13.5321 12.5321ZM13.837 12.149C13.7508 12.2867 13.6488 12.4153 13.5321 12.5321L14.7106 13.7106C14.917 13.5041 15.0976 13.2764 15.25 13.0327L13.837 12.149ZM14.9601 11.8692L9.41667 8.66862L8.58333 10.112L14.1268 13.3125L14.9601 11.8692ZM14.1667 6V7.71466H15.8333V6H14.1667ZM13.5321 4.46794C13.9384 4.87426 14.1667 5.42536 14.1667 6H15.8333C15.8333 4.98334 15.4295 4.00831 14.7106 3.28942L13.5321 4.46794ZM12 3.83333C12.5746 3.83333 13.1257 4.06161 13.5321 4.46794L14.7106 3.28942C13.9917 2.57053 13.0167 2.16667 12 2.16667V3.83333ZM10.4679 4.46794C10.8743 4.06161 11.4254 3.83333 12 3.83333V2.16667C10.9833 2.16667 10.0083 2.57053 9.28942 3.28942L10.4679 4.46794ZM10.1291 4.90724C10.2219 4.74824 10.3354 4.60042 10.4679 4.46794L9.28942 3.28942C9.05511 3.52374 8.85421 3.78533 8.68988 4.06671L10.1291 4.90724ZM8.99281 5.20866L14.5833 8.43635L15.4167 6.99298L9.82615 3.76529L8.99281 5.20866Z"
53
+ fill="#020617"
54
+ />
55
+ </svg>
56
+ ) : (
57
+ <svg
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ width="24"
60
+ height="24"
61
+ viewBox="0 0 24 24"
62
+ fill="none"
63
+ role="img"
64
+ aria-label="Microphone"
65
+ >
66
+ <path
67
+ d="M9 6C9 5.20435 9.31607 4.44129 9.87868 3.87868C10.4413 3.31607 11.2044 3 12 3C12.7956 3 13.5587 3.31607 14.1213 3.87868C14.6839 4.44129 15 5.20435 15 6V11C15 11.7956 14.6839 12.5587 14.1213 13.1213C13.5587 13.6839 12.7956 14 12 14C11.2044 14 10.4413 13.6839 9.87868 13.1213C9.31607 12.5587 9 11.7956 9 11V6Z"
68
+ fill="#020617"
69
+ stroke="#020617"
70
+ strokeWidth="2"
71
+ strokeLinecap="round"
72
+ strokeLinejoin="round"
73
+ />
74
+ <path
75
+ d="M12 18C10.1435 18 8.36301 17.2625 7.05025 15.9497C5.7375 14.637 5 12.8565 5 11V10M12 18C13.8565 18 15.637 17.2625 16.9497 15.9497C18.2625 14.637 19 12.8565 19 11V10M12 18V21"
76
+ stroke="#020617"
77
+ strokeWidth="2"
78
+ strokeLinecap="round"
79
+ strokeLinejoin="round"
80
+ />
81
+ </svg>
82
+ )}
83
+ </span>
84
+ <span className={styles.srOnly}>Microphone</span>
85
+ </button>
86
+ );
87
+ });
88
+
89
+ MicToggleButton.displayName = "MicToggleButton";
90
+
91
+ export const CameraToggleButton = memo(() => {
92
+ const { onToggleCamera, isCamReady, isCamMuted } = useLocalCamera();
93
+
94
+ return (
95
+ <button
96
+ type="button"
97
+ onClick={onToggleCamera}
98
+ disabled={!isCamReady}
99
+ className={styles.deviceButton}
100
+ >
101
+ <span className={styles.deviceButtonIcon}>
102
+ {isCamMuted ? (
103
+ <svg
104
+ xmlns="http://www.w3.org/2000/svg"
105
+ width="24"
106
+ height="24"
107
+ viewBox="0 0 24 24"
108
+ fill="none"
109
+ role="img"
110
+ aria-label="Camera Muted"
111
+ >
112
+ <g clipPath="url(#clip0_7082_14220)">
113
+ <path
114
+ fillRule="evenodd"
115
+ clipRule="evenodd"
116
+ d="M3.19874 5.60093C3.08628 5.68537 2.97928 5.77808 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V16C2 16.7956 2.31607 17.5587 2.87868 18.1213C3.44129 18.6839 4.20435 19 5 19H15C15.7956 19 16.5587 18.6839 17.1213 18.1213C17.6839 17.5587 18 16.7956 18 16V15.048C17.7787 14.8204 17.5304 14.6189 17.2595 14.4485L3.19874 5.60093ZM22 12.655V8C22 7.80225 21.9413 7.60895 21.8314 7.44454C21.7215 7.28013 21.5654 7.15199 21.3827 7.07632C21.2 7.00065 20.9989 6.98085 20.805 7.01942C20.611 7.05798 20.4329 7.15319 20.293 7.293L18 9.586V8C18 7.20435 17.6839 6.44129 17.1213 5.87868C16.5587 5.31607 15.7956 5 15 5H8.7412L22 12.655Z"
117
+ fill="#020617"
118
+ />
119
+ <rect
120
+ x="0.777222"
121
+ y="2.64844"
122
+ width="26.7988"
123
+ height="2.24738"
124
+ rx="1.12369"
125
+ transform="rotate(30 0.777222 2.64844)"
126
+ fill="#020617"
127
+ />
128
+ </g>
129
+ <defs>
130
+ <clipPath id="clip0_7082_14220">
131
+ <rect width="24" height="24" fill="white" />
132
+ </clipPath>
133
+ </defs>
134
+ </svg>
135
+ ) : (
136
+ <svg
137
+ xmlns="http://www.w3.org/2000/svg"
138
+ width="24"
139
+ height="24"
140
+ viewBox="0 0 24 24"
141
+ fill="none"
142
+ role="img"
143
+ aria-label="Camera"
144
+ >
145
+ <path
146
+ fillRule="evenodd"
147
+ clipRule="evenodd"
148
+ d="M5 5C4.20435 5 3.44129 5.31607 2.87868 5.87868C2.31607 6.44129 2 7.20435 2 8V16C2 16.7956 2.31607 17.5587 2.87868 18.1213C3.44129 18.6839 4.20435 19 5 19H15C15.7956 19 16.5587 18.6839 17.1213 18.1213C17.6839 17.5587 18 16.7956 18 16V14.414L20.293 16.707C20.4329 16.8468 20.611 16.942 20.805 16.9806C20.9989 17.0192 21.2 16.9993 21.3827 16.9237C21.5654 16.848 21.7215 16.7199 21.8314 16.5555C21.9413 16.391 22 16.1978 22 16V8C22 7.80225 21.9413 7.60895 21.8314 7.44454C21.7215 7.28013 21.5654 7.15199 21.3827 7.07632C21.2 7.00065 20.9989 6.98085 20.805 7.01942C20.611 7.05798 20.4329 7.15319 20.293 7.293L18 9.586V8C18 7.20435 17.6839 6.44129 17.1213 5.87868C16.5587 5.31607 15.7956 5 15 5H5Z"
149
+ fill="#020617"
150
+ />
151
+ </svg>
152
+ )}
153
+ </span>
154
+ <span className={styles.srOnly}>Camera</span>
155
+ </button>
156
+ );
157
+ });
158
+
159
+ CameraToggleButton.displayName = "CameraToggleButton";
160
+
161
+ export const ScreenShareButton = memo(() => {
162
+ const { onToggleScreenshare, isScreenSharing } = useLocalScreenshare();
163
+
164
+ return (
165
+ <button
166
+ type="button"
167
+ onClick={onToggleScreenshare}
168
+ className={`${styles.deviceButtonContainer} ${styles.screenShareButton}`}
169
+ >
170
+ <span>
171
+ {isScreenSharing ? (
172
+ <svg
173
+ xmlns="http://www.w3.org/2000/svg"
174
+ width="24"
175
+ height="24"
176
+ viewBox="0 0 24 24"
177
+ fill="none"
178
+ role="img"
179
+ aria-label="Screen Share"
180
+ >
181
+ <path
182
+ d="M21.0008 19C21.2557 19.0003 21.5009 19.0979 21.6862 19.2728C21.8715 19.4478 21.9831 19.687 21.998 19.9414C22.013 20.1958 21.9302 20.4464 21.7666 20.6418C21.603 20.8373 21.3709 20.9629 21.1178 20.993L21.0008 21H3.00085C2.74597 20.9997 2.50081 20.9021 2.31548 20.7272C2.13014 20.5522 2.01861 20.313 2.00367 20.0586C1.98874 19.8042 2.07152 19.5536 2.23511 19.3582C2.3987 19.1627 2.63075 19.0371 2.88385 19.007L3.00085 19H21.0008ZM19.0008 4C19.5054 3.99984 19.9914 4.19041 20.3614 4.5335C20.7314 4.87659 20.958 5.34684 20.9958 5.85L21.0008 6V16C21.001 16.5046 20.8104 16.9906 20.4673 17.3605C20.1243 17.7305 19.654 17.9572 19.1508 17.995L19.0008 18H5.00085C4.49627 18.0002 4.01028 17.8096 3.6403 17.4665C3.27032 17.1234 3.04369 16.6532 3.00585 16.15L3.00085 16V6C3.00069 5.49542 3.19125 5.00943 3.53434 4.63945C3.87743 4.26947 4.34769 4.04284 4.85085 4.005L5.00085 4H19.0008Z"
183
+ fill="#2D65FF"
184
+ />
185
+ </svg>
186
+ ) : (
187
+ <svg
188
+ xmlns="http://www.w3.org/2000/svg"
189
+ width="24"
190
+ height="24"
191
+ viewBox="0 0 24 24"
192
+ fill="none"
193
+ role="img"
194
+ aria-label="Screen Share"
195
+ >
196
+ <path
197
+ d="M20.9999 19C21.2547 19.0003 21.4999 19.0979 21.6852 19.2728C21.8706 19.4478 21.9821 19.687 21.997 19.9414C22.012 20.1958 21.9292 20.4464 21.7656 20.6418C21.602 20.8373 21.37 20.9629 21.1169 20.993L20.9999 21H2.99987C2.74499 20.9997 2.49984 20.9021 2.3145 20.7272C2.12916 20.5522 2.01763 20.313 2.0027 20.0586C1.98776 19.8042 2.07054 19.5536 2.23413 19.3582C2.39772 19.1627 2.62977 19.0371 2.88287 19.007L2.99987 19H20.9999ZM18.9999 4C19.5044 3.99984 19.9904 4.19041 20.3604 4.5335C20.7304 4.87659 20.957 5.34684 20.9949 5.85L20.9999 6V16C21 16.5046 20.8095 16.9906 20.4664 17.3605C20.1233 17.7305 19.653 17.9572 19.1499 17.995L18.9999 18H4.99987C4.49529 18.0002 4.0093 17.8096 3.63932 17.4665C3.26934 17.1234 3.04271 16.6532 3.00487 16.15L2.99987 16V6C2.99971 5.49542 3.19028 5.00943 3.53337 4.63945C3.87646 4.26947 4.34671 4.04284 4.84987 4.005L4.99987 4H18.9999Z"
198
+ fill="white"
199
+ />
200
+ </svg>
201
+ )}
202
+ </span>
203
+ </button>
204
+ );
205
+ });
206
+
207
+ ScreenShareButton.displayName = "ScreenShareButton";
@@ -0,0 +1,49 @@
1
+ /* Device button styles */
2
+ .deviceButton {
3
+ position: relative;
4
+ z-index: 10;
5
+ height: 3rem;
6
+ width: 3rem;
7
+ border-radius: 9999px;
8
+ background-color: white;
9
+ display: flex;
10
+ align-items: center;
11
+ justify-content: center;
12
+ border: 1px solid transparent;
13
+ cursor: pointer;
14
+ }
15
+
16
+ .deviceButtonIcon {
17
+ display: flex;
18
+ }
19
+
20
+ .deviceButton:disabled {
21
+ opacity: 0.5;
22
+ }
23
+
24
+ /* Screen reader only text */
25
+ .srOnly {
26
+ position: absolute;
27
+ width: 1px;
28
+ height: 1px;
29
+ padding: 0;
30
+ margin: -1px;
31
+ overflow: hidden;
32
+ clip: rect(0, 0, 0, 0);
33
+ white-space: nowrap;
34
+ border-width: 0;
35
+ }
36
+
37
+ .screenShareButton {
38
+ cursor: pointer;
39
+ position: relative;
40
+ height: 3rem;
41
+ width: 3rem;
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ border-radius: 9999px;
46
+ backdrop-filter: blur(4px);
47
+ background-color: rgba(255, 255, 255, 0.2);
48
+ border: 1px solid rgba(255, 255, 255, 0.2);
49
+ }
@@ -98,11 +98,11 @@ type AppMessageEcho = {
98
98
  "conversation_id": string,
99
99
  "properties": {
100
100
  "modality": "audio" | "text",
101
- "text": string,
102
- "audio": string,
103
- "sample_rate": number,
104
- "inference_id": string,
105
- "done": boolean
101
+ "text"?: string,
102
+ "audio"?: string,
103
+ "sample_rate"?: number,
104
+ "inference_id"?: string,
105
+ "done"?: boolean
106
106
  }
107
107
  }
108
108
 
@@ -163,6 +163,6 @@ export function useSendAppMessage(): (message: SendAppMessageProps) => void {
163
163
  const sendAppMessage = useAppMessage();
164
164
 
165
165
  return useCallback((message: SendAppMessageProps) => {
166
- sendAppMessage({ msg: message }, '*');
166
+ sendAppMessage(message, '*');
167
167
  }, [sendAppMessage]);
168
168
  }
@@ -11,6 +11,13 @@ export const useCVICall = (): {
11
11
  ({ url }: { url: string }) => {
12
12
  daily?.join({
13
13
  url: url,
14
+ inputSettings: {
15
+ audio: {
16
+ processor: {
17
+ type: "noise-cancellation",
18
+ },
19
+ },
20
+ },
14
21
  });
15
22
  },
16
23
  [daily]