@marketrix.ai/widget 3.8.142 → 3.8.144

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 (45) hide show
  1. package/dist/src/components/base/Card.d.ts +0 -4
  2. package/dist/src/components/base/Flex.d.ts +0 -9
  3. package/dist/src/components/base/icons.d.ts +0 -8
  4. package/dist/src/components/blocks/HeaderBar.d.ts +0 -1
  5. package/dist/src/components/navigation/ViewTransition.d.ts +0 -6
  6. package/dist/src/components/ui/StateMessage.d.ts +0 -4
  7. package/dist/src/components/views/ChatView.d.ts +0 -1
  8. package/dist/src/context/ChatContext.d.ts +0 -14
  9. package/dist/src/context/UIStateContext.d.ts +0 -1
  10. package/dist/src/context/WidgetProviders.d.ts +0 -11
  11. package/dist/src/context/sseReducer.d.ts +0 -17
  12. package/dist/src/design-system/semantic-tokens.d.ts +0 -7
  13. package/dist/src/design-system/shadows.d.ts +0 -6
  14. package/dist/src/hooks/useFocusTrap.d.ts +0 -5
  15. package/dist/src/hooks/useScrollLock.d.ts +0 -5
  16. package/dist/src/hooks/useWidget.d.ts +0 -5
  17. package/dist/src/index.d.ts +0 -17
  18. package/dist/src/sdk/contracts/common.d.ts +0 -3
  19. package/dist/src/sdk/contracts/entities.d.ts +3 -9
  20. package/dist/src/sdk/contracts/widget.d.ts +2 -5
  21. package/dist/src/services/ApiService.d.ts +2 -10
  22. package/dist/src/services/BrowserToolService.d.ts +1 -5
  23. package/dist/src/services/ChatService.d.ts +3 -13
  24. package/dist/src/services/ChatSessionManager.d.ts +1 -13
  25. package/dist/src/services/ConfigManager.d.ts +1 -5
  26. package/dist/src/services/DomService.d.ts +8 -33
  27. package/dist/src/services/RrwebSessionRecorder.d.ts +5 -18
  28. package/dist/src/services/ScreenShareService.d.ts +1 -9
  29. package/dist/src/services/StorageService.d.ts +8 -31
  30. package/dist/src/services/ValidationService.d.ts +3 -9
  31. package/dist/src/services/WidgetService.d.ts +1 -9
  32. package/dist/src/test/a11y-utils.d.ts +0 -5
  33. package/dist/src/test/fixtures.d.ts +0 -4
  34. package/dist/src/types/browserTools.d.ts +0 -7
  35. package/dist/src/types/index.d.ts +2 -18
  36. package/dist/src/utils/apiUtils.d.ts +0 -4
  37. package/dist/src/utils/bootstrap.d.ts +0 -28
  38. package/dist/src/utils/chat.d.ts +0 -38
  39. package/dist/src/utils/color.d.ts +0 -7
  40. package/dist/src/utils/dom.d.ts +0 -6
  41. package/dist/src/utils/logger.d.ts +0 -6
  42. package/dist/src/utils/validation.d.ts +0 -6
  43. package/dist/widget.mjs +3 -3
  44. package/dist/widget.mjs.map +1 -1
  45. package/package.json +1 -1
@@ -1,24 +1,12 @@
1
1
  /**
2
- * StorageService - Unified localStorage management for widget
2
+ * Unified widget localStorage under a single key (`marketrix_chat_context`): chat_id, messages, widget state, config.
3
3
  *
4
- * Consolidates all widget localStorage into a single key: marketrix_chat_context
5
- * Contains: chat_id, messages, widget state, and config
6
- *
7
- * **Canonical implementation.** This file is the source of truth for the
8
- * `StorageService` mirror pair. The matching `app/src/services/StorageService.ts`
9
- * in the dashboard repo should be byte-identical to this file (modulo its
10
- * own `'../types'` import path). When updating storage semantics, change
11
- * this file first and copy the result over to the app mirror.
12
- *
13
- * Why widget is canonical: the chat context object (chat_id, messages,
14
- * task progress, widget config) originates in the embeddable widget — the
15
- * widget owns the read/write lifecycle, and the dashboard only ever reads
16
- * the same shape for parity.
4
+ * **Canonical implementation** of the `StorageService` mirror pair the widget owns the read/write
5
+ * lifecycle; `app/src/services/StorageService.ts` must stay byte-identical (modulo its `'../types'`
6
+ * import path). Change storage semantics here first, then copy over to the app mirror.
17
7
  */
18
8
  import type { ChatMessage, InstructionType, MarketrixConfig } from '../types';
19
- /**
20
- * Serializable version of ChatMessage (timestamp as string, no videoStream)
21
- */
9
+ /** Serializable ChatMessage: timestamp as string, no videoStream. */
22
10
  type StoredMessage = Omit<ChatMessage, 'videoStream' | 'timestamp'> & {
23
11
  timestamp: string;
24
12
  };
@@ -34,12 +22,7 @@ export interface MarketrixChatContext {
34
22
  config: MarketrixConfig | null;
35
23
  timestamp: number;
36
24
  }
37
- /**
38
- * Singleton wrapper around `localStorage` for the unified widget chat context.
39
- *
40
- * Canonical implementation — see file header. Mirror in `app/src/services/StorageService.ts`
41
- * must be byte-identical (modulo the relative path of the `../types` import).
42
- */
25
+ /** Singleton wrapper around `localStorage` for the unified widget chat context. Canonical — see file header. */
43
26
  declare class StorageService {
44
27
  private static instance;
45
28
  private context;
@@ -50,15 +33,9 @@ declare class StorageService {
50
33
  getContext(): MarketrixChatContext;
51
34
  updateContext(updates: Partial<MarketrixChatContext>): void;
52
35
  private isValidChatId;
53
- /**
54
- * Get chat_id with window.name fallback for cross-page navigation
55
- * Priority: window.name (if valid) -> localStorage
56
- */
36
+ /** window.name takes priority over localStorage — it persists across page navigations. */
57
37
  getChatId(): string | null;
58
- /**
59
- * Set chat_id in both localStorage and window.name.
60
- * Dispatches a 'marketrix:chatid' event so other services (e.g. RrwebSessionRecorder) can react.
61
- */
38
+ /** Dispatches a 'marketrix:chatid' event so other services (e.g. RrwebSessionRecorder) can react. */
62
39
  setChatId(chatId: string | null): void;
63
40
  getMessages(): StoredMessage[];
64
41
  setMessages(messages: StoredMessage[]): void;
@@ -7,18 +7,12 @@ export interface WidgetValidationResult {
7
7
  application?: ApplicationData;
8
8
  }
9
9
  /**
10
- * ValidationService
11
- *
12
- * Validates widget configuration by checking:
13
- * 1. Widget exists (via marketrix_id and marketrix_key) and its application exists, OR
14
- * 2. The application ID exists
10
+ * Validates widget config: either the widget (marketrix_id + marketrix_key) and its application exist,
11
+ * or the application id exists.
15
12
  */
16
13
  export declare class ValidationService {
17
14
  private config?;
18
- /**
19
- * Validate widget configuration
20
- * Handles both mtxId+mtxKey and mtxApp cases
21
- */
15
+ /** Handles both the mtxId+mtxKey and mtxApp cases. */
22
16
  validateConfig(config: MarketrixConfig): Promise<WidgetValidationResult>;
23
17
  private validateByMarketrixId;
24
18
  private validateByApplication;
@@ -4,15 +4,7 @@ export declare class WidgetService {
4
4
  private mtxKey?;
5
5
  private mtxApp?;
6
6
  constructor(mtxId?: string, mtxKey?: string, mtxApp?: number);
7
- /**
8
- * Fetch widget settings from the API
9
- * Always returns default settings merged with existing widget settings if found
10
- * Returns null if no credentials provided (for preview mode)
11
- */
7
+ /** Default settings merged with the matched widget's settings; null with no credentials (preview mode). */
12
8
  widgetSettingsGet(): Promise<WidgetData | null>;
13
- /**
14
- * Get widget settings from widget data
15
- * Settings are always objects (current API format)
16
- */
17
9
  getWidgetSettings(widget: WidgetData): WidgetSettingsData | null;
18
10
  }
@@ -1,6 +1 @@
1
- /**
2
- * Run axe-core on a container and assert no a11y violations.
3
- * Use in tests: await assertNoA11yViolations(container);
4
- * Color-contrast is disabled in jsdom (no canvas).
5
- */
6
1
  export declare function assertNoA11yViolations(container: Element): Promise<void>;
@@ -1,6 +1,2 @@
1
1
  import type { MarketrixConfig } from '../types';
2
- /**
3
- * Minimal valid widget config for tests (satisfies WidgetSettingsDataSchema).
4
- * Use with WidgetProviders previewMode to avoid network calls.
5
- */
6
2
  export declare function getMockWidgetConfig(overrides?: Partial<MarketrixConfig>): MarketrixConfig;
@@ -1,10 +1,3 @@
1
- /**
2
- * Browser Use Tools - widget tool registry.
3
- *
4
- * IMPORTANT: This file is the single source of truth for widget tool metadata.
5
- * ALLOWED_TOOLS in ChatContext.tsx and TOOL_NAME_MAPPING in chat.ts are
6
- * derived from BROWSER_TOOLS below.
7
- */
8
1
  interface BrowserToolMetadata {
9
2
  id: string;
10
3
  name: string;
@@ -1,21 +1,5 @@
1
1
  import type { InstructionType, WidgetSettingsData } from '../sdk';
2
2
  export type { ApplicationData, InstructionType, UserData, WidgetChip, WidgetData, WidgetSettingsData, WorkspaceData, } from '../sdk';
3
- /**
4
- * MarketrixConfig - Single source of truth for all widget configuration
5
- *
6
- * This type extends WidgetSettingsData (with all fields optional) with additional
7
- * widget-specific fields, allowing API settings to be spread directly:
8
- * { ...config, ...apiSettings }
9
- *
10
- * All fields are at the top level for easy merging and access.
11
- *
12
- * Component-level defaults (not in config):
13
- * - Input placeholder: 'Ask anything'
14
- * - Live agent header: 'Live Agent'
15
- * - Live agent body: 'A live agent will be with you shortly.'
16
- * - Position offset default: { x: 20, y: 20 }
17
- * - Z-index default: 40
18
- */
19
3
  export type MarketrixConfig = Partial<WidgetSettingsData> & {
20
4
  mtxId?: string;
21
5
  mtxKey?: string;
@@ -28,9 +12,9 @@ export type MarketrixConfig = Partial<WidgetSettingsData> & {
28
12
  };
29
13
  widget_position_z_index?: number;
30
14
  isPreviewMode?: boolean;
31
- /** Controls visual rendering of the widget. When false, widget initializes fully but UI is hidden. Default: true */
15
+ /** When false, widget initializes fully but UI is hidden. Default: true */
32
16
  show_widget?: boolean;
33
- /** Controls screen sharing prompts and button. When false, screen access requests are auto-denied and Share Screen button is hidden. Default: true */
17
+ /** When false, screen access requests are auto-denied and Share Screen button is hidden. Default: true */
34
18
  use_screenshare?: boolean;
35
19
  };
36
20
  export interface ChatMessage {
@@ -1,9 +1,5 @@
1
1
  /** Error-handling helpers for API calls. */
2
2
  import type { MarketrixConfig } from '../types';
3
- /**
4
- * Extract error message from unknown error type
5
- * Consolidates error instanceof Error ? error.message : String(error)
6
- */
7
3
  export declare function extractErrorMessage(error: unknown, fallback?: string): string;
8
4
  export declare function handleApiError(error: unknown, context?: string, config?: Partial<MarketrixConfig>): {
9
5
  isValid: false;
@@ -1,29 +1,10 @@
1
- /**
2
- * Widget Initialization, Lifecycle, and Loader Utilities
3
- *
4
- * Handles widget container creation, shadow DOM setup, mounting, lifecycle management,
5
- * and loader display. Consolidates all widget-related DOM manipulation and state management.
6
- */
7
1
  import { type Root } from 'react-dom/client';
8
2
  import type { MarketrixConfig } from '../types';
9
- /**
10
- * Create widget container and shadow DOM
11
- * Returns the container element and shadow root
12
- * @param parentContainer - Optional parent container to mount within. If provided, shadow DOM will be created within this container.
13
- * @param containerId - Optional unique container ID. If not provided, a unique ID will be generated.
14
- */
15
3
  export declare const createWidgetContainer: (parentContainer?: HTMLElement, containerId?: string) => {
16
4
  container: HTMLElement;
17
5
  shadowRoot: ShadowRoot;
18
6
  mountEl: HTMLElement;
19
7
  };
20
- /**
21
- * Mount widget component to the provided mount element
22
- * Returns the React root instance
23
- * @param mountEl - The mount element inside shadow DOM
24
- * @param config - Widget configuration
25
- * @param previewMode - If true, disables network operations (for integration previews)
26
- */
27
8
  export declare const mountWidgetToContainer: (mountEl: HTMLElement, config: MarketrixConfig, previewMode?: boolean) => Root;
28
9
  export declare const destroyWidgetContainer: (container: HTMLElement) => void;
29
10
  export declare const getWidgetInstance: () => Root | null;
@@ -36,14 +17,5 @@ export declare const setProgrammaticInitInProgress: (inProgress: boolean) => voi
36
17
  export declare const isProgrammaticInitInProgress: () => boolean;
37
18
  export declare const showWidgetSettingsLoader: (message?: string) => void;
38
19
  export declare const hideWidgetSettingsLoader: () => void;
39
- /**
40
- * Auto-initialize widget from script tag attributes
41
- * Retries if script tag not found to handle timing issues with ES module loading
42
- */
43
20
  export declare const autoInitializeWidget: (retryCount?: number) => void;
44
- /**
45
- * Register the widget initialization function and set up auto-initialization
46
- *
47
- * @param initWidget - Function to initialize the widget (passed to avoid circular dependency)
48
- */
49
21
  export declare const registerAutoInit: (initWidget: (config: MarketrixConfig) => Promise<void>) => void;
@@ -1,60 +1,22 @@
1
- /**
2
- * Message Content Utilities
3
- *
4
- * Centralized utilities for message content transformation, including:
5
- * - Removing thinking markers
6
- */
7
1
  import type { ChatMessage, InstructionType } from '../types';
8
2
  export declare function removeThinkingMarkers(content: string): string;
9
3
  export declare function removeThinkingMarkerFromEnd(content: string): string;
10
4
  export declare function hasThinkingMarker(content: string): boolean;
11
5
  export declare function addThinkingMarker(content: string): string;
12
- /**
13
- * Message Finder Utility
14
- *
15
- * Centralized logic for finding messages in the chat that should receive
16
- * progress updates, tool call results, or errors. Eliminates duplicate
17
- * message finding code across stream handlers.
18
- */
19
6
  export interface FindMessageOptions {
20
7
  messages: ChatMessage[];
21
8
  isSimulationRunning: boolean;
22
9
  currentMode: InstructionType;
23
10
  requireContent?: boolean;
24
11
  }
25
- /**
26
- * Find the message that should receive progress updates
27
- * ALWAYS returns the LAST (most recent) matching message by searching backwards.
28
- * Priority order for active show/do tasks:
29
- * 1. Placeholder message in show/do mode that has content (the "Let me try this" message)
30
- * 2. Placeholder message in show/do mode (even without content yet)
31
- * 3. Non-placeholder agent message in show/do mode
32
- * For other cases:
33
- * 4. Last placeholder message
34
- * 5. Last task message
35
- * 6. Any agent message as fallback
36
- */
37
12
  export declare function findMessageForProgress(options: FindMessageOptions): {
38
13
  index: number;
39
14
  message: ChatMessage;
40
15
  } | null;
41
- /**
42
- * Tools that, in `show` mode, pause for the user to perform the action
43
- * themselves (DOM-mutating "mouse and keyboard" actions, minus `scroll`).
44
- * Also the set that requires element highlighting in BrowserToolService.
45
- */
46
16
  export declare const WAIT_FOR_USER_TOOLS: Set<string>;
47
17
  export declare function addProgressLine(message: ChatMessage, browserToolName: string, explanation: string): ChatMessage;
48
18
  export declare function markProgressLineComplete(message: ChatMessage, browserToolName?: string): ChatMessage;
49
19
  export declare function markProgressLineFailed(message: ChatMessage, browserToolName: string, error: string): ChatMessage;
50
20
  export declare function updateThinkingMarker(message: ChatMessage, isSimulationRunning: boolean, currentMode: 'show' | 'tell' | 'do', isWaitingForUser?: boolean): ChatMessage;
51
- /**
52
- * Tool Name Mapping — derived from BROWSER_TOOLS (single source of truth).
53
- * Provides friendly display names for technical tool names.
54
- */
55
21
  export declare const TOOL_NAME_MAPPING: Record<string, string>;
56
- /**
57
- * Get a friendly display name for a tool
58
- * Converts snake_case to Title Case if no mapping exists
59
- */
60
22
  export declare function getFriendlyToolName(browserToolName: string): string;
@@ -1,16 +1,9 @@
1
- /**
2
- * Color utility functions for widget theming
3
- */
4
1
  export declare function hexToRgb(hex: string): {
5
2
  r: number;
6
3
  g: number;
7
4
  b: number;
8
5
  } | null;
9
6
  export declare function getContrastingColor(color: string): string;
10
- /**
11
- * Adds opacity to a color
12
- * Supports hex colors (with or without #) and rgb/rgba strings
13
- */
14
7
  export declare function addOpacity(color: string, opacity: number): string;
15
8
  export declare function darkenColor(color: string, amount: number): string;
16
9
  export declare const formatMessageTime: (date: Date | undefined) => string;
@@ -1,7 +1 @@
1
- /**
2
- * DOM Manipulation Utilities
3
- *
4
- * Centralized utilities for common DOM operations to reduce code duplication
5
- * and ensure consistent error handling.
6
- */
7
1
  export declare function isInteractable(el: Element | null): boolean;
@@ -1,9 +1,3 @@
1
- /**
2
- * Logger Utility
3
- *
4
- * Centralized logging utility with log levels and environment-based filtering.
5
- * Only logs in development mode to reduce noise in production.
6
- */
7
1
  export declare function createLogger(prefix: string): {
8
2
  debug: (message: string, ...args: unknown[]) => void;
9
3
  info: (message: string, ...args: unknown[]) => void;
@@ -1,9 +1,3 @@
1
- /**
2
- * Type Guard Utilities
3
- *
4
- * Generic type guard functions for data validation and type checking.
5
- * These are shared utilities used across the codebase.
6
- */
7
1
  import type { WidgetSettingsData } from '../sdk';
8
2
  export declare function isWidgetSettingsData(data: unknown): data is WidgetSettingsData;
9
3
  export declare function isHTMLElement(element: Element | null): element is HTMLElement;