@chatwillow/widget 0.0.10 → 0.1.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.
@@ -0,0 +1,5 @@
1
+ declare function MarkdownRenderer({ content, className, }: {
2
+ content: string;
3
+ className?: string;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ export default MarkdownRenderer;
@@ -1,7 +1,7 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  import * as React from "react";
3
3
  declare const badgeVariants: (props?: ({
4
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
4
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
5
5
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
6
  declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
7
7
  asChild?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  import * as React from "react";
3
3
  declare const buttonVariants: (props?: ({
4
- variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
4
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
5
5
  size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
6
6
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
7
  declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
@@ -3,7 +3,7 @@ import { Button } from './button';
3
3
  import * as React from "react";
4
4
  declare function InputGroup({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
5
5
  declare const inputGroupAddonVariants: (props?: ({
6
- align?: "inline-start" | "inline-end" | "block-start" | "block-end" | null | undefined;
6
+ align?: "inline-end" | "inline-start" | "block-end" | "block-start" | null | undefined;
7
7
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
8
  declare function InputGroupAddon({ className, align, ...props }: React.ComponentProps<"div"> & VariantProps<typeof inputGroupAddonVariants>): import("react/jsx-runtime").JSX.Element;
9
9
  declare const inputGroupButtonVariants: (props?: ({
@@ -11,7 +11,7 @@ declare function Item({ className, variant, size, asChild, ...props }: React.Com
11
11
  asChild?: boolean;
12
12
  }): import("react/jsx-runtime").JSX.Element;
13
13
  declare const itemMediaVariants: (props?: ({
14
- variant?: "image" | "default" | "icon" | null | undefined;
14
+ variant?: "default" | "image" | "icon" | null | undefined;
15
15
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
16
16
  declare function ItemMedia({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>): import("react/jsx-runtime").JSX.Element;
17
17
  declare function ItemContent({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
@@ -3,7 +3,7 @@ import { Tabs as TabsPrimitive } from 'radix-ui';
3
3
  import * as React from "react";
4
4
  declare function Tabs({ className, orientation, ...props }: React.ComponentProps<typeof TabsPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
5
5
  declare const tabsListVariants: (props?: ({
6
- variant?: "line" | "default" | null | undefined;
6
+ variant?: "default" | "line" | null | undefined;
7
7
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
8
  declare function TabsList({ className, variant, ...props }: React.ComponentProps<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>): import("react/jsx-runtime").JSX.Element;
9
9
  declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ export declare class EncryptionService {
2
+ /**
3
+ * Encrypts a string using AES-256-CBC.
4
+ * Returns: IV(Hex):Ciphertext(Base64)
5
+ */
6
+ static encrypt(data: string): string;
7
+ /**
8
+ * Decrypts a string formatted as IV(Hex):Ciphertext(Base64).
9
+ */
10
+ static decrypt(encryptedString: string): string;
11
+ /**
12
+ * Encrypts a File object content.
13
+ * Reads file as DataURL (base64), encrypts that string.
14
+ * Returns a new File object where the content is the encrypted string.
15
+ */
16
+ static encryptFile(file: File): Promise<File>;
17
+ }
@@ -0,0 +1,11 @@
1
+ export declare class UrlParsingService {
2
+ /**
3
+ * Convert data object to a URL-safe base64 string.
4
+ * Matches server/src/shared/url_parsing.py logic.
5
+ */
6
+ static encode(data: any): string;
7
+ /**
8
+ * Decode a URL-safe base64 string back to original data.
9
+ */
10
+ static decode<T = any>(encodedStr: string): T;
11
+ }
@@ -1,5 +1,6 @@
1
1
  export interface IChatWidgetProps {
2
+ apiKey: string;
2
3
  className?: string;
3
4
  style?: React.CSSProperties;
4
5
  }
5
- export declare function ChatWidget({ className, style }: IChatWidgetProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function ChatWidget({ apiKey, className, style }: IChatWidgetProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { IChatWidgetConfig } from '../types/configurable.type';
2
+ interface ChatInputAreaProps {
3
+ onSendMessage: (message: string, files?: File[]) => void;
4
+ isSending: boolean;
5
+ config: IChatWidgetConfig;
6
+ onPreviewFile: (file: File) => void;
7
+ }
8
+ export declare function ChatInputArea({ onSendMessage, isSending, config, onPreviewFile, }: ChatInputAreaProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,9 @@
1
+ import { IMessage } from '../types/chatWidget.type';
2
+ import { IChatWidgetConfig } from '../types/configurable.type';
3
+ interface ChatMessageListProps {
4
+ messages: IMessage[];
5
+ isSending: boolean;
6
+ config: IChatWidgetConfig;
7
+ }
8
+ export declare function ChatMessageList({ messages, isSending, config, }: ChatMessageListProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -1,2 +1,2 @@
1
1
  import { IChatWidgetUIProps } from '../types/chatWidget.type';
2
- export declare function ChatWidgetUI({ messages, onSendMessage, isSending, className, style, }: IChatWidgetUIProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ChatWidgetUI({ messages, onSendMessage, isSending, onClose, className, style, config, }: IChatWidgetUIProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { IChatWidgetConfig } from '../types/configurable.type';
2
+ interface ChatWindowHeaderProps {
3
+ config: IChatWidgetConfig;
4
+ onClose: () => void;
5
+ }
6
+ export declare function ChatWindowHeader({ config, onClose }: ChatWindowHeaderProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ interface FilePreviewDialogProps {
2
+ file: File | null;
3
+ onClose: () => void;
4
+ }
5
+ export declare function FilePreviewDialog({ file, onClose }: FilePreviewDialogProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ import { IChatWidgetConfig } from '../types/configurable.type';
2
+ export declare const chatWidgetConfig: IChatWidgetConfig;
@@ -0,0 +1,10 @@
1
+ import { Socket } from 'socket.io-client';
2
+ import { IMessage } from '../types/chatWidget.type';
3
+ interface UseChatSocketProps {
4
+ sessionId: string;
5
+ onGenerating?: () => void;
6
+ onCompleted?: (message: IMessage) => void;
7
+ onError?: (error: string) => void;
8
+ }
9
+ export declare function useChatSocket({ sessionId, onGenerating, onCompleted, onError, }: UseChatSocketProps): Socket<import('@socket.io/component-emitter').DefaultEventsMap, import('@socket.io/component-emitter').DefaultEventsMap> | null;
10
+ export {};
@@ -1 +1,8 @@
1
- export declare function useSendMessage(): import('@tanstack/react-query').UseMutationResult<import('../types/chatWidget.type').ISendMessageResponse, Error, string, unknown>;
1
+ interface SendMessageParams {
2
+ message: string;
3
+ sessionId: string;
4
+ files?: File[];
5
+ }
6
+ export declare function useSendMessage(): import('@tanstack/react-query').UseMutationResult<import('../types/chatWidget.type').ISendMessageResponse, Error, SendMessageParams, unknown>;
7
+ export declare function useGetThread(sessionId: string): import('@tanstack/react-query').UseQueryResult<any, Error>;
8
+ export {};
@@ -3,9 +3,25 @@ export declare const queryKeyEnumType: {
3
3
  readonly CHAT_MESSAGES: "chatMessages";
4
4
  };
5
5
  declare class ChatWidgetService {
6
- private readonly apiClient;
7
- constructor();
8
- sendMessage(message: string): Promise<ISendMessageResponse>;
6
+ private apiClient;
7
+ constructor(apiKey?: string);
8
+ /**
9
+ * Re-initialize the API client when the API key changes.
10
+ */
11
+ updateApiKey(apiKey: string): void;
12
+ /**
13
+ * Encrypts and encodes session ID for secure transport.
14
+ * Format: UrlSafeBase64(JSON({ sid: Encrypted(SessionId) }))
15
+ */
16
+ private getSecureSessionId;
17
+ sendMessage(message: string, sessionId: string, files?: File[]): Promise<ISendMessageResponse>;
18
+ getThread(sessionId: string): Promise<any>;
19
+ encodeSessionId(sessionId: string): string;
9
20
  }
10
- export declare const chatWidgetService: ChatWidgetService;
21
+ export declare let chatWidgetService: ChatWidgetService;
22
+ /**
23
+ * Initialize or re-initialize the chat service singleton with an API key.
24
+ * Called by ChatWidget on mount.
25
+ */
26
+ export declare function initChatWidgetService(apiKey: string): ChatWidgetService;
11
27
  export {};
@@ -1,3 +1,4 @@
1
+ import { IChatWidgetConfig } from './configurable.type';
1
2
  export interface ISendMessageRequest {
2
3
  message: string;
3
4
  }
@@ -12,11 +13,14 @@ export interface IMessage {
12
13
  role: "user" | "assistant";
13
14
  content: string;
14
15
  timestamp: Date;
16
+ shouldAnimate?: boolean;
15
17
  }
16
18
  export interface IChatWidgetUIProps {
17
19
  messages: IMessage[];
18
- onSendMessage: (message: string) => void;
20
+ onSendMessage: (message: string, files?: File[]) => void;
19
21
  isSending: boolean;
22
+ onClose: () => void;
20
23
  className?: string;
21
24
  style?: React.CSSProperties;
25
+ config: IChatWidgetConfig;
22
26
  }
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod';
2
+ export declare const ChatWidgetConfigSchema: z.ZodObject<{
3
+ headerBackgroundColor: z.ZodString;
4
+ messageBackgroundColor: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
5
+ userBubbleBackgroundColor: z.ZodString;
6
+ botBubbleBackgroundColor: z.ZodString;
7
+ inputSectionBackgroundColor: z.ZodString;
8
+ sendButtonBackgroundColor: z.ZodString;
9
+ headerImage: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">]>;
10
+ headerTitle: z.ZodString;
11
+ subLabelTitle: z.ZodString;
12
+ closeButtonColor: z.ZodString;
13
+ headerTextColor: z.ZodString;
14
+ subLabelColor: z.ZodString;
15
+ userBubbleTextColor: z.ZodString;
16
+ botBubbleTextColor: z.ZodString;
17
+ botAvatarImage: z.ZodString;
18
+ initialMessage: z.ZodString;
19
+ inputPlaceholder: z.ZodString;
20
+ toastSuccessMessage: z.ZodString;
21
+ toastFailedMessage: z.ZodString;
22
+ }, z.core.$strip>;
23
+ export type IChatWidgetConfig = z.infer<typeof ChatWidgetConfigSchema>;