vdb-ai-chat 1.0.78 → 1.0.80

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 (79) hide show
  1. package/dist/chat-widget.js +189 -164
  2. package/dist/chat-widget.js.LICENSE.txt +2 -0
  3. package/lib/commonjs/api.js +84 -4
  4. package/lib/commonjs/api.js.map +1 -1
  5. package/lib/commonjs/components/ChatInput.js +227 -65
  6. package/lib/commonjs/components/ChatInput.js.map +1 -1
  7. package/lib/commonjs/components/ChatWidget.js +6 -2
  8. package/lib/commonjs/components/ChatWidget.js.map +1 -1
  9. package/lib/commonjs/components/MessageBubble.js +22 -2
  10. package/lib/commonjs/components/MessageBubble.js.map +1 -1
  11. package/lib/commonjs/components/icons/VDBCustomIcon.js +54 -0
  12. package/lib/commonjs/components/icons/VDBCustomIcon.js.map +1 -0
  13. package/lib/commonjs/components/icons/VDBIcon.js +141 -0
  14. package/lib/commonjs/components/icons/VDBIcon.js.map +1 -0
  15. package/lib/commonjs/components/icons/VDBIcons.js +16 -0
  16. package/lib/commonjs/components/icons/VDBIcons.js.map +1 -0
  17. package/lib/commonjs/components/icons/index.js +34 -0
  18. package/lib/commonjs/components/icons/index.js.map +1 -0
  19. package/lib/commonjs/index.js +29 -0
  20. package/lib/commonjs/index.js.map +1 -1
  21. package/lib/commonjs/index.native.js +30 -1
  22. package/lib/commonjs/index.native.js.map +1 -1
  23. package/lib/commonjs/routes.js +1 -0
  24. package/lib/commonjs/routes.js.map +1 -1
  25. package/lib/module/api.js +81 -5
  26. package/lib/module/api.js.map +1 -1
  27. package/lib/module/components/ChatInput.js +228 -66
  28. package/lib/module/components/ChatInput.js.map +1 -1
  29. package/lib/module/components/ChatWidget.js +6 -2
  30. package/lib/module/components/ChatWidget.js.map +1 -1
  31. package/lib/module/components/MessageBubble.js +22 -2
  32. package/lib/module/components/MessageBubble.js.map +1 -1
  33. package/lib/module/components/icons/VDBCustomIcon.js +47 -0
  34. package/lib/module/components/icons/VDBCustomIcon.js.map +1 -0
  35. package/lib/module/components/icons/VDBIcon.js +134 -0
  36. package/lib/module/components/icons/VDBIcon.js.map +1 -0
  37. package/lib/module/components/icons/VDBIcons.js +10 -0
  38. package/lib/module/components/icons/VDBIcons.js.map +1 -0
  39. package/lib/module/components/icons/index.js +3 -0
  40. package/lib/module/components/icons/index.js.map +1 -0
  41. package/lib/module/index.js +1 -1
  42. package/lib/module/index.js.map +1 -1
  43. package/lib/module/index.native.js +1 -0
  44. package/lib/module/index.native.js.map +1 -1
  45. package/lib/module/routes.js +1 -0
  46. package/lib/module/routes.js.map +1 -1
  47. package/lib/typescript/api.d.ts +22 -0
  48. package/lib/typescript/api.d.ts.map +1 -1
  49. package/lib/typescript/components/ChatInput.d.ts +4 -0
  50. package/lib/typescript/components/ChatInput.d.ts.map +1 -1
  51. package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
  52. package/lib/typescript/components/MessageBubble.d.ts +2 -0
  53. package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
  54. package/lib/typescript/components/icons/VDBCustomIcon.d.ts +11 -0
  55. package/lib/typescript/components/icons/VDBCustomIcon.d.ts.map +1 -0
  56. package/lib/typescript/components/icons/VDBIcon.d.ts +34 -0
  57. package/lib/typescript/components/icons/VDBIcon.d.ts.map +1 -0
  58. package/lib/typescript/components/icons/VDBIcons.d.ts +9 -0
  59. package/lib/typescript/components/icons/VDBIcons.d.ts.map +1 -0
  60. package/lib/typescript/components/icons/index.d.ts +5 -0
  61. package/lib/typescript/components/icons/index.d.ts.map +1 -0
  62. package/lib/typescript/index.d.ts +2 -0
  63. package/lib/typescript/index.d.ts.map +1 -1
  64. package/lib/typescript/index.native.d.ts +2 -0
  65. package/lib/typescript/index.native.d.ts.map +1 -1
  66. package/lib/typescript/routes.d.ts +1 -0
  67. package/lib/typescript/routes.d.ts.map +1 -1
  68. package/package.json +18 -2
  69. package/src/api.ts +147 -3
  70. package/src/components/ChatInput.tsx +360 -83
  71. package/src/components/ChatWidget.tsx +9 -0
  72. package/src/components/MessageBubble.tsx +27 -1
  73. package/src/components/icons/VDBCustomIcon.tsx +74 -0
  74. package/src/components/icons/VDBIcon.tsx +186 -0
  75. package/src/components/icons/VDBIcons.ts +9 -0
  76. package/src/components/icons/index.ts +4 -0
  77. package/src/index.native.tsx +12 -0
  78. package/src/index.ts +12 -0
  79. package/src/routes.ts +1 -0
@@ -0,0 +1,186 @@
1
+ import React from "react";
2
+ import { Image, ImageResizeMode, Platform } from "react-native";
3
+ import VDBCustomIcon from "./VDBCustomIcon";
4
+
5
+ let AntDesign: any = null;
6
+ let FontAwesome: any = null;
7
+ let FontAwesome5: any = null;
8
+ try {
9
+ const antDesignMod = require("@expo/vector-icons/build/AntDesign");
10
+ const faMod = require("@expo/vector-icons/build/FontAwesome");
11
+ const fa5Mod = require("@expo/vector-icons/build/FontAwesome5");
12
+ AntDesign = antDesignMod?.default ?? antDesignMod;
13
+ FontAwesome = faMod?.default ?? faMod;
14
+ FontAwesome5 = fa5Mod?.default ?? fa5Mod;
15
+ } catch {
16
+ }
17
+
18
+ let SvgUri: any = null;
19
+ try {
20
+ SvgUri = require("react-native-svg").SvgUri;
21
+ } catch {
22
+ }
23
+
24
+ let ImageComponent: typeof Image = Image;
25
+ let ExpoImage: any = null;
26
+ if (Platform.OS !== "web") {
27
+ try {
28
+ ExpoImage = require("expo-image").Image;
29
+ if (ExpoImage) ImageComponent = ExpoImage;
30
+ } catch {
31
+ }
32
+ }
33
+
34
+ export enum IconsVariant {
35
+ AntDesign = "AntDesign",
36
+ FontAwesome = "FontAwesome",
37
+ FontAwesome5 = "FontAwesome5",
38
+ VDBCustom = "VDBCustom",
39
+ CustomUrl = "CustomUrl",
40
+ }
41
+
42
+ export enum IconsType {
43
+ img = "img",
44
+ svg = "svg",
45
+ img_url = "img-url",
46
+ svg_url = "svg-url",
47
+ url = "url",
48
+ }
49
+
50
+ export interface IconProps {
51
+ variant: IconsVariant;
52
+ name?: string;
53
+ color?: string;
54
+ size?: number;
55
+ uri?: string;
56
+ height?: number;
57
+ resizeMode?: ImageResizeMode;
58
+ }
59
+
60
+ export interface CustomIconProps extends IconProps {
61
+ others?: object;
62
+ avoidSVGCheck?: boolean;
63
+ thumbSize?: number;
64
+ style?: any;
65
+ }
66
+
67
+ const isSvgUri = (uri?: string) =>
68
+ !!uri && uri.split(/[?#]/)[0].toLowerCase().endsWith(".svg");
69
+
70
+ const isGifUri = (uri?: string) =>
71
+ !!uri && uri.split(/[?#]/)[0].toLowerCase().endsWith(".gif");
72
+
73
+ const VDBIcon: React.FC<CustomIconProps> = ({
74
+ variant,
75
+ name,
76
+ size = 16,
77
+ height,
78
+ color,
79
+ uri,
80
+ others = {},
81
+ resizeMode = "contain",
82
+ avoidSVGCheck = false,
83
+ thumbSize,
84
+ style,
85
+ }) => {
86
+ const normalizedName =
87
+ typeof name === "string" ? name.toLowerCase() : (name as any);
88
+
89
+ switch (variant) {
90
+ case IconsVariant.AntDesign:
91
+ if (!AntDesign) return null;
92
+ return (
93
+ <AntDesign
94
+ name={normalizedName}
95
+ color={color}
96
+ size={size}
97
+ style={style}
98
+ {...others}
99
+ />
100
+ );
101
+
102
+ case IconsVariant.FontAwesome:
103
+ if (!FontAwesome) return null;
104
+ return (
105
+ <FontAwesome
106
+ name={normalizedName}
107
+ color={color}
108
+ size={size}
109
+ style={style}
110
+ {...others}
111
+ />
112
+ );
113
+
114
+ case IconsVariant.FontAwesome5:
115
+ if (!FontAwesome5) return null;
116
+ return (
117
+ <FontAwesome5
118
+ name={normalizedName}
119
+ color={color}
120
+ size={size}
121
+ style={style}
122
+ {...others}
123
+ />
124
+ );
125
+
126
+ case IconsVariant.VDBCustom:
127
+ return (
128
+ <VDBCustomIcon
129
+ name={normalizedName}
130
+ size={size}
131
+ color={color}
132
+ style={style}
133
+ {...others}
134
+ />
135
+ );
136
+
137
+ case IconsVariant.CustomUrl: {
138
+ if (!uri) return null;
139
+ if (isSvgUri(uri) && !avoidSVGCheck && SvgUri) {
140
+ return (
141
+ <SvgUri
142
+ width={size}
143
+ height={height ?? size}
144
+ uri={uri}
145
+ fill={color}
146
+ style={style}
147
+ {...others}
148
+ />
149
+ );
150
+ }
151
+
152
+ if (isGifUri(uri) && ExpoImage) {
153
+ const dim = thumbSize ?? size;
154
+ return (
155
+ <ExpoImage
156
+ source={uri}
157
+ style={[{ width: dim, height: height ?? dim }, style]}
158
+ contentFit="contain"
159
+ {...others}
160
+ />
161
+ );
162
+ }
163
+
164
+ return (
165
+ <ImageComponent
166
+ style={[
167
+ {
168
+ width: size,
169
+ height: height ?? size,
170
+ ...(color ? { tintColor: color } : {}),
171
+ },
172
+ style,
173
+ ]}
174
+ source={{ uri }}
175
+ resizeMode={resizeMode}
176
+ {...others}
177
+ />
178
+ );
179
+ }
180
+
181
+ default:
182
+ return null;
183
+ }
184
+ };
185
+
186
+ export default VDBIcon;
@@ -0,0 +1,9 @@
1
+ export enum VDBIcons {
2
+ MINUS_CIRCLE = "minus-cirlce",
3
+ SEND = "send",
4
+ LIKE = "like",
5
+ DISLIKE = "dislike",
6
+ MIC = "mic",
7
+ STOP_CIRCLE = "stop-circle",
8
+ }
9
+
@@ -0,0 +1,4 @@
1
+ export { default as VDBIcon, IconsVariant, IconsType } from "./VDBIcon";
2
+ export type { IconProps, CustomIconProps } from "./VDBIcon";
3
+ export { default as VDBCustomIcon } from "./VDBCustomIcon";
4
+ export type { VDBCustomIconProps } from "./VDBCustomIcon";
@@ -4,3 +4,15 @@ export * from "./types";
4
4
  export * from "./theme";
5
5
  export { normaliseMessages } from "./api";
6
6
  export { initStorage, isStorageInitialized, Storage } from "./storage";
7
+
8
+ export {
9
+ VDBIcon,
10
+ VDBCustomIcon,
11
+ IconsVariant,
12
+ IconsType,
13
+ } from "./components/icons";
14
+ export type {
15
+ IconProps,
16
+ CustomIconProps,
17
+ VDBCustomIconProps,
18
+ } from "./components/icons";
package/src/index.ts CHANGED
@@ -5,6 +5,18 @@ export * from "./theme";
5
5
  export { normaliseMessages } from "./api";
6
6
  export { initStorage, isStorageInitialized, Storage } from "./storage";
7
7
 
8
+ export {
9
+ VDBIcon,
10
+ VDBCustomIcon,
11
+ IconsVariant,
12
+ IconsType,
13
+ } from "./components/icons";
14
+ export type {
15
+ IconProps,
16
+ CustomIconProps,
17
+ VDBCustomIconProps,
18
+ } from "./components/icons";
19
+
8
20
  // i18n exports
9
21
  export {
10
22
  initI18n,
package/src/routes.ts CHANGED
@@ -2,6 +2,7 @@ const API_VERSION = "v3";
2
2
 
3
3
  const Routes = {
4
4
  AGENCT_CONVERSATIONS: (apiUrl: string) => `${apiUrl}${API_VERSION}/agent_conversations`,
5
+ TRANSCRIBE: (apiUrl: string) => `${apiUrl}${API_VERSION}/agent_conversations/transcribe`,
5
6
  SEARCH_DIAMONDS: (apiUrl: string) => `${apiUrl}${API_VERSION}/vdb/search_diamonds`,
6
7
  REACTION: (apiUrl: string, conversation_id: string, message_id: string) => `${apiUrl}${API_VERSION}/agent_conversations/${conversation_id}/conversation_messages/${message_id}/reaction`,
7
8
  }