vanilla-agent 1.24.0 → 1.26.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.
- package/dist/index.cjs +24 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.global.js +67 -66
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +24 -23
- package/dist/index.js.map +1 -1
- package/dist/install.global.js +1 -1
- package/dist/install.global.js.map +1 -1
- package/dist/widget.css +0 -4
- package/package.json +1 -1
- package/src/components/feedback.ts +2 -0
- package/src/defaults.ts +86 -36
- package/src/index.ts +6 -1
- package/src/install.ts +72 -9
- package/src/styles/widget.css +0 -4
- package/src/types.ts +28 -0
- package/src/ui.ts +32 -1
- package/src/utils/code-generators.ts +318 -455
- package/src/utils/message-id.ts +2 -0
- package/src/utils/theme.ts +86 -6
package/dist/index.d.cts
CHANGED
|
@@ -1100,6 +1100,34 @@ type AgentWidgetConfig = {
|
|
|
1100
1100
|
sendButtonLabel?: string;
|
|
1101
1101
|
};
|
|
1102
1102
|
theme?: AgentWidgetTheme;
|
|
1103
|
+
/**
|
|
1104
|
+
* Theme colors for dark mode. Applied when dark mode is detected
|
|
1105
|
+
* (when colorScheme is 'dark' or 'auto' with dark mode active).
|
|
1106
|
+
* If not provided, falls back to `theme` colors.
|
|
1107
|
+
*
|
|
1108
|
+
* @example
|
|
1109
|
+
* ```typescript
|
|
1110
|
+
* config: {
|
|
1111
|
+
* theme: { primary: '#111827', surface: '#ffffff' },
|
|
1112
|
+
* darkTheme: { primary: '#f9fafb', surface: '#1f2937' },
|
|
1113
|
+
* colorScheme: 'auto'
|
|
1114
|
+
* }
|
|
1115
|
+
* ```
|
|
1116
|
+
*/
|
|
1117
|
+
darkTheme?: AgentWidgetTheme;
|
|
1118
|
+
/**
|
|
1119
|
+
* Color scheme mode for the widget.
|
|
1120
|
+
* - 'light': Always use light theme (default)
|
|
1121
|
+
* - 'dark': Always use dark theme
|
|
1122
|
+
* - 'auto': Automatically detect from page (HTML class or prefers-color-scheme)
|
|
1123
|
+
*
|
|
1124
|
+
* When 'auto', detection order:
|
|
1125
|
+
* 1. Check if `<html>` has 'dark' class
|
|
1126
|
+
* 2. Fall back to `prefers-color-scheme: dark` media query
|
|
1127
|
+
*
|
|
1128
|
+
* @default 'light'
|
|
1129
|
+
*/
|
|
1130
|
+
colorScheme?: 'auto' | 'light' | 'dark';
|
|
1103
1131
|
features?: AgentWidgetFeatureFlags;
|
|
1104
1132
|
launcher?: AgentWidgetLauncherConfig;
|
|
1105
1133
|
initialMessages?: AgentWidgetMessage[];
|
|
@@ -2054,6 +2082,14 @@ declare function hasComponentDirective(message: AgentWidgetMessage): boolean;
|
|
|
2054
2082
|
*/
|
|
2055
2083
|
declare function extractComponentDirectiveFromMessage(message: AgentWidgetMessage): ComponentDirective | null;
|
|
2056
2084
|
|
|
2085
|
+
/**
|
|
2086
|
+
* Default light theme colors
|
|
2087
|
+
*/
|
|
2088
|
+
declare const DEFAULT_LIGHT_THEME: AgentWidgetTheme;
|
|
2089
|
+
/**
|
|
2090
|
+
* Default dark theme colors
|
|
2091
|
+
*/
|
|
2092
|
+
declare const DEFAULT_DARK_THEME: AgentWidgetTheme;
|
|
2057
2093
|
/**
|
|
2058
2094
|
* Default widget configuration
|
|
2059
2095
|
* Single source of truth for all default values
|
|
@@ -2150,4 +2186,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
|
|
|
2150
2186
|
*/
|
|
2151
2187
|
declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
|
|
2152
2188
|
|
|
2153
|
-
export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };
|
|
2189
|
+
export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };
|
package/dist/index.d.ts
CHANGED
|
@@ -1100,6 +1100,34 @@ type AgentWidgetConfig = {
|
|
|
1100
1100
|
sendButtonLabel?: string;
|
|
1101
1101
|
};
|
|
1102
1102
|
theme?: AgentWidgetTheme;
|
|
1103
|
+
/**
|
|
1104
|
+
* Theme colors for dark mode. Applied when dark mode is detected
|
|
1105
|
+
* (when colorScheme is 'dark' or 'auto' with dark mode active).
|
|
1106
|
+
* If not provided, falls back to `theme` colors.
|
|
1107
|
+
*
|
|
1108
|
+
* @example
|
|
1109
|
+
* ```typescript
|
|
1110
|
+
* config: {
|
|
1111
|
+
* theme: { primary: '#111827', surface: '#ffffff' },
|
|
1112
|
+
* darkTheme: { primary: '#f9fafb', surface: '#1f2937' },
|
|
1113
|
+
* colorScheme: 'auto'
|
|
1114
|
+
* }
|
|
1115
|
+
* ```
|
|
1116
|
+
*/
|
|
1117
|
+
darkTheme?: AgentWidgetTheme;
|
|
1118
|
+
/**
|
|
1119
|
+
* Color scheme mode for the widget.
|
|
1120
|
+
* - 'light': Always use light theme (default)
|
|
1121
|
+
* - 'dark': Always use dark theme
|
|
1122
|
+
* - 'auto': Automatically detect from page (HTML class or prefers-color-scheme)
|
|
1123
|
+
*
|
|
1124
|
+
* When 'auto', detection order:
|
|
1125
|
+
* 1. Check if `<html>` has 'dark' class
|
|
1126
|
+
* 2. Fall back to `prefers-color-scheme: dark` media query
|
|
1127
|
+
*
|
|
1128
|
+
* @default 'light'
|
|
1129
|
+
*/
|
|
1130
|
+
colorScheme?: 'auto' | 'light' | 'dark';
|
|
1103
1131
|
features?: AgentWidgetFeatureFlags;
|
|
1104
1132
|
launcher?: AgentWidgetLauncherConfig;
|
|
1105
1133
|
initialMessages?: AgentWidgetMessage[];
|
|
@@ -2054,6 +2082,14 @@ declare function hasComponentDirective(message: AgentWidgetMessage): boolean;
|
|
|
2054
2082
|
*/
|
|
2055
2083
|
declare function extractComponentDirectiveFromMessage(message: AgentWidgetMessage): ComponentDirective | null;
|
|
2056
2084
|
|
|
2085
|
+
/**
|
|
2086
|
+
* Default light theme colors
|
|
2087
|
+
*/
|
|
2088
|
+
declare const DEFAULT_LIGHT_THEME: AgentWidgetTheme;
|
|
2089
|
+
/**
|
|
2090
|
+
* Default dark theme colors
|
|
2091
|
+
*/
|
|
2092
|
+
declare const DEFAULT_DARK_THEME: AgentWidgetTheme;
|
|
2057
2093
|
/**
|
|
2058
2094
|
* Default widget configuration
|
|
2059
2095
|
* Single source of truth for all default values
|
|
@@ -2150,4 +2186,4 @@ declare const getHeaderLayout: (layoutName: string) => HeaderLayoutRenderer;
|
|
|
2150
2186
|
*/
|
|
2151
2187
|
declare const buildHeaderWithLayout: (config: AgentWidgetConfig, layoutConfig?: AgentWidgetHeaderLayoutConfig, context?: Partial<HeaderLayoutContext>) => HeaderElements;
|
|
2152
2188
|
|
|
2153
|
-
export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };
|
|
2189
|
+
export { type AgentWidgetAvatarConfig, AgentWidgetClient, type AgentWidgetConfig, type AgentWidgetController, type AgentWidgetCustomFetch, type AgentWidgetEvent, type AgentWidgetFeatureFlags, type AgentWidgetHeaderLayoutConfig, type AgentWidgetHeadersFunction, type AgentWidgetInitHandle, type AgentWidgetInitOptions, type AgentWidgetLauncherConfig, type AgentWidgetLayoutConfig, type AgentWidgetMarkdownConfig, type AgentWidgetMarkdownOptions, type AgentWidgetMarkdownRendererOverrides, type AgentWidgetMessage, type AgentWidgetMessageActionsConfig, type AgentWidgetMessageFeedback, type AgentWidgetMessageLayoutConfig, type AgentWidgetPlugin, type AgentWidgetRequestPayload, type AgentWidgetSSEEventParser, type AgentWidgetSSEEventResult, AgentWidgetSession, type AgentWidgetSessionStatus, type AgentWidgetStreamParser, type AgentWidgetStreamParserResult, type AgentWidgetTheme, type AgentWidgetTimestampConfig, type CSATFeedbackOptions, type ClientChatRequest, type ClientFeedbackRequest, type ClientFeedbackType, type ClientInitResponse, type ClientSession, type CodeFormat, type ComponentContext, type ComponentDirective, type ComponentRenderer, type ComposerBuildContext, type ComposerElements, DEFAULT_DARK_THEME, DEFAULT_LIGHT_THEME, DEFAULT_WIDGET_CONFIG, type HeaderBuildContext, type HeaderElements, type HeaderLayoutContext, type HeaderLayoutRenderer, type HeaderRenderContext, type MarkdownProcessorOptions, type MessageActionCallbacks, type MessageRenderContext, type MessageTransform, type NPSFeedbackOptions, type SlotRenderContext, type SlotRenderer, type WidgetLayoutSlot, attachHeaderToContainer, buildComposer, buildDefaultHeader, buildExpandedHeader, buildHeader, buildHeaderWithLayout, buildMinimalHeader, componentRegistry, createActionManager, createAgentExperience, createBubbleWithLayout, createCSATFeedback, createComponentMiddleware, createComponentStreamParser, createDirectivePostprocessor, createFlexibleJsonStreamParser, createJsonStreamParser, createLocalStorageAdapter, createMarkdownProcessor, createMarkdownProcessorFromConfig, createMessageActions, createNPSFeedback, createPlainTextParser, createRegexJsonParser, createStandardBubble, createTypingIndicator, createXmlParser, initAgentWidget as default, defaultActionHandlers, defaultJsonActionParser, directivePostprocessor, escapeHtml, extractComponentDirectiveFromMessage, generateAssistantMessageId, generateCodeSnippet, generateMessageId, generateUserMessageId, getHeaderLayout, hasComponentDirective, headerLayouts, initAgentWidget, isComponentDirectiveType, markdownPostprocessor, mergeWithDefaults, pluginRegistry, renderComponentDirective };
|