@customerhero/js 2.2.0 → 2.4.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/README.md +19 -0
- package/dist/index.cjs +221 -21
- package/dist/index.d.cts +181 -2
- package/dist/index.d.ts +181 -2
- package/dist/index.js +215 -21
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type" | "incident_dismiss" | "incident_default_link_label";
|
|
1
|
+
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type" | "attachment_open" | "attachment_image_alt" | "attachment_location" | "incident_dismiss" | "incident_default_link_label";
|
|
2
2
|
type Translations = Record<TranslationKey, string>;
|
|
3
3
|
|
|
4
4
|
declare const SUPPORTED_LOCALES: readonly ["en", "es", "pt-BR", "pt-PT", "fr", "de", "it", "nl", "pl", "tr", "ar", "ja", "ko", "zh-CN", "zh-TW"];
|
|
@@ -35,6 +35,52 @@ interface CustomerHeroChatConfig {
|
|
|
35
35
|
locale?: string;
|
|
36
36
|
/** Predefined quick-reply options shown before the user sends a message */
|
|
37
37
|
suggestedMessages?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Color scheme. `auto` follows the visitor's OS preference; `light` and
|
|
40
|
+
* `dark` force a fixed palette. Defaults to `light` when unset.
|
|
41
|
+
*/
|
|
42
|
+
colorScheme?: "auto" | "light" | "dark";
|
|
43
|
+
/** Primary color used in dark mode. Only honoured when the effective
|
|
44
|
+
* scheme resolves to dark; never auto-derived from `primaryColor`. */
|
|
45
|
+
primaryColorDark?: string;
|
|
46
|
+
/** Background color used in dark mode. Only honoured when the effective
|
|
47
|
+
* scheme resolves to dark; never auto-derived from `backgroundColor`. */
|
|
48
|
+
backgroundColorDark?: string;
|
|
49
|
+
/** Text color used in dark mode. Only honoured when the effective scheme
|
|
50
|
+
* resolves to dark; never auto-derived from `textColor`. */
|
|
51
|
+
textColorDark?: string;
|
|
52
|
+
/** Widget size preset. Affects launcher diameter, panel dimensions, and
|
|
53
|
+
* base font size. Defaults to `default`. */
|
|
54
|
+
size?: "compact" | "default" | "large";
|
|
55
|
+
/** Corner radius preset for the chat panel. `soft` ~ small radius,
|
|
56
|
+
* `rounded` ~ medium (default), `square` ~ 0. */
|
|
57
|
+
cornerStyle?: "soft" | "rounded" | "square";
|
|
58
|
+
/** Launcher (floating bubble) customization. Each field is optional. */
|
|
59
|
+
launcher?: {
|
|
60
|
+
/** Custom launcher icon URL. Replaces the default chat-bubble glyph. */
|
|
61
|
+
iconUrl?: string;
|
|
62
|
+
/** Optional CTA label shown next to the launcher (turns the bubble into
|
|
63
|
+
* a pill). Max 60 characters. */
|
|
64
|
+
label?: string;
|
|
65
|
+
/** When true, render a small green dot on the launcher to advertise
|
|
66
|
+
* agent availability. The host site is responsible for keeping
|
|
67
|
+
* business-hours state in sync; the SDK only renders the dot. */
|
|
68
|
+
showOnlineDot?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Pixel offsets so the widget can sit above sticky cookie bars or chat
|
|
71
|
+
* CTAs. Each axis defaults to 20 px when unset. Clamped to 0–1000. */
|
|
72
|
+
offset?: {
|
|
73
|
+
bottom?: number;
|
|
74
|
+
side?: number;
|
|
75
|
+
};
|
|
76
|
+
/** Z-index override for sites whose overlays clip the widget. Defaults
|
|
77
|
+
* to 99999. Capped at 2_000_000_000. */
|
|
78
|
+
zIndex?: number;
|
|
79
|
+
/** When false, the input's attach button is hidden so visitors can't
|
|
80
|
+
* even attempt an upload (the server enforces the same flag). Defaults
|
|
81
|
+
* to true. Per-chatbot, sourced from the public widget config endpoint
|
|
82
|
+
* but overrideable on the host. */
|
|
83
|
+
allowAttachments?: boolean;
|
|
38
84
|
}
|
|
39
85
|
|
|
40
86
|
interface ResolvedConfig {
|
|
@@ -51,6 +97,23 @@ interface ResolvedConfig {
|
|
|
51
97
|
suggestedMessages: string[];
|
|
52
98
|
/** Per-chatbot overrides for any translation key, optionally per-locale. */
|
|
53
99
|
stringOverrides?: StringOverrides;
|
|
100
|
+
colorScheme: "auto" | "light" | "dark";
|
|
101
|
+
primaryColorDark?: string;
|
|
102
|
+
backgroundColorDark?: string;
|
|
103
|
+
textColorDark?: string;
|
|
104
|
+
size: "compact" | "default" | "large";
|
|
105
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
106
|
+
launcher: {
|
|
107
|
+
iconUrl?: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
showOnlineDot: boolean;
|
|
110
|
+
};
|
|
111
|
+
offset: {
|
|
112
|
+
bottom: number;
|
|
113
|
+
side: number;
|
|
114
|
+
};
|
|
115
|
+
zIndex: number;
|
|
116
|
+
allowAttachments: boolean;
|
|
54
117
|
}
|
|
55
118
|
interface MessageSource {
|
|
56
119
|
index: number;
|
|
@@ -74,6 +137,27 @@ type ActionConfirmationBlock = {
|
|
|
74
137
|
};
|
|
75
138
|
type MessageBlock = QuickRepliesBlock | ActionConfirmationBlock;
|
|
76
139
|
type MessageStatus = "sending" | "sent" | "failed";
|
|
140
|
+
/**
|
|
141
|
+
* Attachment hung off a historical message. The widget only ever uploads
|
|
142
|
+
* `image` and `document` kinds, but inbox agents can attach `audio` /
|
|
143
|
+
* `video` / `location` from the dashboard, and the history endpoint returns
|
|
144
|
+
* everything the conversation has accumulated.
|
|
145
|
+
*/
|
|
146
|
+
interface MessageAttachment {
|
|
147
|
+
id: string;
|
|
148
|
+
kind: "image" | "document" | "audio" | "video" | "location";
|
|
149
|
+
mimeType: string | null;
|
|
150
|
+
filename: string | null;
|
|
151
|
+
sizeBytes: number | null;
|
|
152
|
+
/** Public R2 URL. Null for `location` attachments (use `location` instead). */
|
|
153
|
+
url: string | null;
|
|
154
|
+
/** Geo payload for `location` attachments. */
|
|
155
|
+
location: {
|
|
156
|
+
label?: string | null;
|
|
157
|
+
latitude: number;
|
|
158
|
+
longitude: number;
|
|
159
|
+
} | null;
|
|
160
|
+
}
|
|
77
161
|
interface ChatMessage {
|
|
78
162
|
/** Message ID from the API (only present for bot messages) */
|
|
79
163
|
id?: string;
|
|
@@ -88,6 +172,11 @@ interface ChatMessage {
|
|
|
88
172
|
* tappable chips under the most recent bot message only.
|
|
89
173
|
*/
|
|
90
174
|
suggestions?: string[];
|
|
175
|
+
/**
|
|
176
|
+
* Files / screenshots / locations attached to this message. Populated from
|
|
177
|
+
* the history endpoint on conversation reload.
|
|
178
|
+
*/
|
|
179
|
+
attachments?: MessageAttachment[];
|
|
91
180
|
/** True while this message is still receiving streaming tokens. */
|
|
92
181
|
streaming?: boolean;
|
|
93
182
|
/**
|
|
@@ -303,6 +392,10 @@ interface ChatState {
|
|
|
303
392
|
/** True when the visitor has dismissed the active banner this session.
|
|
304
393
|
* Reset whenever a new banner (different content) lands. */
|
|
305
394
|
incidentBannerDismissed: boolean;
|
|
395
|
+
/** When true, the chat input is disabled and `sendMessage` is a no-op.
|
|
396
|
+
* Used by the dashboard preview (and any other host that wants a
|
|
397
|
+
* visual-only render). Public API consumers should not set this. */
|
|
398
|
+
readOnly: boolean;
|
|
306
399
|
}
|
|
307
400
|
|
|
308
401
|
type Listener = (state: ChatState) => void;
|
|
@@ -314,6 +407,21 @@ declare class CustomerHeroChat {
|
|
|
314
407
|
private identityData;
|
|
315
408
|
t: TranslateFn;
|
|
316
409
|
constructor(config: CustomerHeroChatConfig);
|
|
410
|
+
/**
|
|
411
|
+
* Mark the config as loaded and put the client into read-only preview
|
|
412
|
+
* mode without hitting the API. Used by `@customerhero/react/preview` to
|
|
413
|
+
* render the widget against a host-supplied config (the dashboard preview
|
|
414
|
+
* pane). Public API consumers should not call this.
|
|
415
|
+
*
|
|
416
|
+
* Pass a config to re-resolve and update the rendered colors/size/launcher
|
|
417
|
+
* in place. Callers should reuse the same client instance across config
|
|
418
|
+
* changes so the open animation only fires once.
|
|
419
|
+
*
|
|
420
|
+
* @internal
|
|
421
|
+
*/
|
|
422
|
+
__seedForPreview(config?: CustomerHeroChatConfig, extras?: {
|
|
423
|
+
banner?: IncidentBanner | null;
|
|
424
|
+
}): void;
|
|
317
425
|
private triggersRuntime;
|
|
318
426
|
private preChatFormSubmitted;
|
|
319
427
|
private readStoredConsent;
|
|
@@ -400,7 +508,78 @@ declare const DEFAULTS: {
|
|
|
400
508
|
placeholderText: string;
|
|
401
509
|
welcomeMessage: string;
|
|
402
510
|
title: string;
|
|
511
|
+
colorScheme: "auto" | "light" | "dark";
|
|
512
|
+
primaryColorDark: string;
|
|
513
|
+
backgroundColorDark: string;
|
|
514
|
+
textColorDark: string;
|
|
515
|
+
size: "compact" | "default" | "large";
|
|
516
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
517
|
+
offsetBottom: number;
|
|
518
|
+
offsetSide: number;
|
|
519
|
+
zIndex: number;
|
|
520
|
+
};
|
|
521
|
+
declare const SIZE_PRESETS: {
|
|
522
|
+
readonly compact: {
|
|
523
|
+
readonly bubble: 48;
|
|
524
|
+
readonly width: 320;
|
|
525
|
+
readonly height: 480;
|
|
526
|
+
readonly fontSize: 13;
|
|
527
|
+
};
|
|
528
|
+
readonly default: {
|
|
529
|
+
readonly bubble: 56;
|
|
530
|
+
readonly width: 380;
|
|
531
|
+
readonly height: 520;
|
|
532
|
+
readonly fontSize: 14;
|
|
533
|
+
};
|
|
534
|
+
readonly large: {
|
|
535
|
+
readonly bubble: 64;
|
|
536
|
+
readonly width: 440;
|
|
537
|
+
readonly height: 600;
|
|
538
|
+
readonly fontSize: 15;
|
|
539
|
+
};
|
|
540
|
+
};
|
|
541
|
+
declare const CORNER_RADIUS: {
|
|
542
|
+
readonly soft: 8;
|
|
543
|
+
readonly rounded: 16;
|
|
544
|
+
readonly square: 0;
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
type EffectiveScheme = "light" | "dark";
|
|
548
|
+
/**
|
|
549
|
+
* Resolve the configured `colorScheme` against the visitor's OS preference.
|
|
550
|
+
* `prefersDark` is the live value of `matchMedia("(prefers-color-scheme: dark)")`
|
|
551
|
+
* (or `false` when not running in a browser). Kept as a pure function so the
|
|
552
|
+
* caller subscribes once and re-renders.
|
|
553
|
+
*/
|
|
554
|
+
declare function resolveScheme(colorScheme: ResolvedConfig["colorScheme"], prefersDark: boolean): EffectiveScheme;
|
|
555
|
+
/**
|
|
556
|
+
* Pick the colors that should drive the widget render right now. When the
|
|
557
|
+
* effective scheme is dark and a dark color is configured, use it; otherwise
|
|
558
|
+
* fall back to the light color (so half-configured dark mode still ships
|
|
559
|
+
* something readable rather than a white panel with white text).
|
|
560
|
+
*/
|
|
561
|
+
declare function effectiveColors(config: ResolvedConfig, scheme: EffectiveScheme): {
|
|
562
|
+
primary: string;
|
|
563
|
+
background: string;
|
|
564
|
+
text: string;
|
|
565
|
+
};
|
|
566
|
+
declare function sizePreset(size: ResolvedConfig["size"]): {
|
|
567
|
+
readonly bubble: 48;
|
|
568
|
+
readonly width: 320;
|
|
569
|
+
readonly height: 480;
|
|
570
|
+
readonly fontSize: 13;
|
|
571
|
+
} | {
|
|
572
|
+
readonly bubble: 56;
|
|
573
|
+
readonly width: 380;
|
|
574
|
+
readonly height: 520;
|
|
575
|
+
readonly fontSize: 14;
|
|
576
|
+
} | {
|
|
577
|
+
readonly bubble: 64;
|
|
578
|
+
readonly width: 440;
|
|
579
|
+
readonly height: 600;
|
|
580
|
+
readonly fontSize: 15;
|
|
403
581
|
};
|
|
582
|
+
declare function panelRadius(cornerStyle: ResolvedConfig["cornerStyle"]): 0 | 8 | 16;
|
|
404
583
|
|
|
405
584
|
declare class ScreenshotCancelled extends Error {
|
|
406
585
|
constructor(message?: string);
|
|
@@ -464,4 +643,4 @@ interface StartTriggersRuntimeOptions {
|
|
|
464
643
|
}
|
|
465
644
|
declare function startTriggersRuntime(options: StartTriggersRuntimeOptions): TriggersRuntimeHandle;
|
|
466
645
|
|
|
467
|
-
export { type ActionConfirmationBlock, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type IdentifyPayload, type IdentityData, type IncidentBanner, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, evaluate, isRtlLocale, pickFire, resolveLocale, startTriggersRuntime };
|
|
646
|
+
export { type ActionConfirmationBlock, CORNER_RADIUS, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type EffectiveScheme, type IdentifyPayload, type IdentityData, type IncidentBanner, type MessageAttachment, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SIZE_PRESETS, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, effectiveColors, evaluate, isRtlLocale, panelRadius, pickFire, resolveLocale, resolveScheme, sizePreset, startTriggersRuntime };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type" | "incident_dismiss" | "incident_default_link_label";
|
|
1
|
+
type TranslationKey = "online" | "typing" | "unable_to_load" | "powered_by" | "new_conversation" | "open_chat" | "close_chat" | "send_message" | "helpful" | "not_helpful" | "menu" | "action_approve" | "action_cancel" | "action_what_will_happen" | "action_already_resolved" | "action_failed" | "status_sending" | "status_sent" | "status_failed" | "screenshot_capture" | "attachment_remove" | "attach_menu_open" | "attach_photo" | "drop_files_here" | "attachment_unsupported_type" | "attachment_open" | "attachment_image_alt" | "attachment_location" | "incident_dismiss" | "incident_default_link_label";
|
|
2
2
|
type Translations = Record<TranslationKey, string>;
|
|
3
3
|
|
|
4
4
|
declare const SUPPORTED_LOCALES: readonly ["en", "es", "pt-BR", "pt-PT", "fr", "de", "it", "nl", "pl", "tr", "ar", "ja", "ko", "zh-CN", "zh-TW"];
|
|
@@ -35,6 +35,52 @@ interface CustomerHeroChatConfig {
|
|
|
35
35
|
locale?: string;
|
|
36
36
|
/** Predefined quick-reply options shown before the user sends a message */
|
|
37
37
|
suggestedMessages?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Color scheme. `auto` follows the visitor's OS preference; `light` and
|
|
40
|
+
* `dark` force a fixed palette. Defaults to `light` when unset.
|
|
41
|
+
*/
|
|
42
|
+
colorScheme?: "auto" | "light" | "dark";
|
|
43
|
+
/** Primary color used in dark mode. Only honoured when the effective
|
|
44
|
+
* scheme resolves to dark; never auto-derived from `primaryColor`. */
|
|
45
|
+
primaryColorDark?: string;
|
|
46
|
+
/** Background color used in dark mode. Only honoured when the effective
|
|
47
|
+
* scheme resolves to dark; never auto-derived from `backgroundColor`. */
|
|
48
|
+
backgroundColorDark?: string;
|
|
49
|
+
/** Text color used in dark mode. Only honoured when the effective scheme
|
|
50
|
+
* resolves to dark; never auto-derived from `textColor`. */
|
|
51
|
+
textColorDark?: string;
|
|
52
|
+
/** Widget size preset. Affects launcher diameter, panel dimensions, and
|
|
53
|
+
* base font size. Defaults to `default`. */
|
|
54
|
+
size?: "compact" | "default" | "large";
|
|
55
|
+
/** Corner radius preset for the chat panel. `soft` ~ small radius,
|
|
56
|
+
* `rounded` ~ medium (default), `square` ~ 0. */
|
|
57
|
+
cornerStyle?: "soft" | "rounded" | "square";
|
|
58
|
+
/** Launcher (floating bubble) customization. Each field is optional. */
|
|
59
|
+
launcher?: {
|
|
60
|
+
/** Custom launcher icon URL. Replaces the default chat-bubble glyph. */
|
|
61
|
+
iconUrl?: string;
|
|
62
|
+
/** Optional CTA label shown next to the launcher (turns the bubble into
|
|
63
|
+
* a pill). Max 60 characters. */
|
|
64
|
+
label?: string;
|
|
65
|
+
/** When true, render a small green dot on the launcher to advertise
|
|
66
|
+
* agent availability. The host site is responsible for keeping
|
|
67
|
+
* business-hours state in sync; the SDK only renders the dot. */
|
|
68
|
+
showOnlineDot?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Pixel offsets so the widget can sit above sticky cookie bars or chat
|
|
71
|
+
* CTAs. Each axis defaults to 20 px when unset. Clamped to 0–1000. */
|
|
72
|
+
offset?: {
|
|
73
|
+
bottom?: number;
|
|
74
|
+
side?: number;
|
|
75
|
+
};
|
|
76
|
+
/** Z-index override for sites whose overlays clip the widget. Defaults
|
|
77
|
+
* to 99999. Capped at 2_000_000_000. */
|
|
78
|
+
zIndex?: number;
|
|
79
|
+
/** When false, the input's attach button is hidden so visitors can't
|
|
80
|
+
* even attempt an upload (the server enforces the same flag). Defaults
|
|
81
|
+
* to true. Per-chatbot, sourced from the public widget config endpoint
|
|
82
|
+
* but overrideable on the host. */
|
|
83
|
+
allowAttachments?: boolean;
|
|
38
84
|
}
|
|
39
85
|
|
|
40
86
|
interface ResolvedConfig {
|
|
@@ -51,6 +97,23 @@ interface ResolvedConfig {
|
|
|
51
97
|
suggestedMessages: string[];
|
|
52
98
|
/** Per-chatbot overrides for any translation key, optionally per-locale. */
|
|
53
99
|
stringOverrides?: StringOverrides;
|
|
100
|
+
colorScheme: "auto" | "light" | "dark";
|
|
101
|
+
primaryColorDark?: string;
|
|
102
|
+
backgroundColorDark?: string;
|
|
103
|
+
textColorDark?: string;
|
|
104
|
+
size: "compact" | "default" | "large";
|
|
105
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
106
|
+
launcher: {
|
|
107
|
+
iconUrl?: string;
|
|
108
|
+
label?: string;
|
|
109
|
+
showOnlineDot: boolean;
|
|
110
|
+
};
|
|
111
|
+
offset: {
|
|
112
|
+
bottom: number;
|
|
113
|
+
side: number;
|
|
114
|
+
};
|
|
115
|
+
zIndex: number;
|
|
116
|
+
allowAttachments: boolean;
|
|
54
117
|
}
|
|
55
118
|
interface MessageSource {
|
|
56
119
|
index: number;
|
|
@@ -74,6 +137,27 @@ type ActionConfirmationBlock = {
|
|
|
74
137
|
};
|
|
75
138
|
type MessageBlock = QuickRepliesBlock | ActionConfirmationBlock;
|
|
76
139
|
type MessageStatus = "sending" | "sent" | "failed";
|
|
140
|
+
/**
|
|
141
|
+
* Attachment hung off a historical message. The widget only ever uploads
|
|
142
|
+
* `image` and `document` kinds, but inbox agents can attach `audio` /
|
|
143
|
+
* `video` / `location` from the dashboard, and the history endpoint returns
|
|
144
|
+
* everything the conversation has accumulated.
|
|
145
|
+
*/
|
|
146
|
+
interface MessageAttachment {
|
|
147
|
+
id: string;
|
|
148
|
+
kind: "image" | "document" | "audio" | "video" | "location";
|
|
149
|
+
mimeType: string | null;
|
|
150
|
+
filename: string | null;
|
|
151
|
+
sizeBytes: number | null;
|
|
152
|
+
/** Public R2 URL. Null for `location` attachments (use `location` instead). */
|
|
153
|
+
url: string | null;
|
|
154
|
+
/** Geo payload for `location` attachments. */
|
|
155
|
+
location: {
|
|
156
|
+
label?: string | null;
|
|
157
|
+
latitude: number;
|
|
158
|
+
longitude: number;
|
|
159
|
+
} | null;
|
|
160
|
+
}
|
|
77
161
|
interface ChatMessage {
|
|
78
162
|
/** Message ID from the API (only present for bot messages) */
|
|
79
163
|
id?: string;
|
|
@@ -88,6 +172,11 @@ interface ChatMessage {
|
|
|
88
172
|
* tappable chips under the most recent bot message only.
|
|
89
173
|
*/
|
|
90
174
|
suggestions?: string[];
|
|
175
|
+
/**
|
|
176
|
+
* Files / screenshots / locations attached to this message. Populated from
|
|
177
|
+
* the history endpoint on conversation reload.
|
|
178
|
+
*/
|
|
179
|
+
attachments?: MessageAttachment[];
|
|
91
180
|
/** True while this message is still receiving streaming tokens. */
|
|
92
181
|
streaming?: boolean;
|
|
93
182
|
/**
|
|
@@ -303,6 +392,10 @@ interface ChatState {
|
|
|
303
392
|
/** True when the visitor has dismissed the active banner this session.
|
|
304
393
|
* Reset whenever a new banner (different content) lands. */
|
|
305
394
|
incidentBannerDismissed: boolean;
|
|
395
|
+
/** When true, the chat input is disabled and `sendMessage` is a no-op.
|
|
396
|
+
* Used by the dashboard preview (and any other host that wants a
|
|
397
|
+
* visual-only render). Public API consumers should not set this. */
|
|
398
|
+
readOnly: boolean;
|
|
306
399
|
}
|
|
307
400
|
|
|
308
401
|
type Listener = (state: ChatState) => void;
|
|
@@ -314,6 +407,21 @@ declare class CustomerHeroChat {
|
|
|
314
407
|
private identityData;
|
|
315
408
|
t: TranslateFn;
|
|
316
409
|
constructor(config: CustomerHeroChatConfig);
|
|
410
|
+
/**
|
|
411
|
+
* Mark the config as loaded and put the client into read-only preview
|
|
412
|
+
* mode without hitting the API. Used by `@customerhero/react/preview` to
|
|
413
|
+
* render the widget against a host-supplied config (the dashboard preview
|
|
414
|
+
* pane). Public API consumers should not call this.
|
|
415
|
+
*
|
|
416
|
+
* Pass a config to re-resolve and update the rendered colors/size/launcher
|
|
417
|
+
* in place. Callers should reuse the same client instance across config
|
|
418
|
+
* changes so the open animation only fires once.
|
|
419
|
+
*
|
|
420
|
+
* @internal
|
|
421
|
+
*/
|
|
422
|
+
__seedForPreview(config?: CustomerHeroChatConfig, extras?: {
|
|
423
|
+
banner?: IncidentBanner | null;
|
|
424
|
+
}): void;
|
|
317
425
|
private triggersRuntime;
|
|
318
426
|
private preChatFormSubmitted;
|
|
319
427
|
private readStoredConsent;
|
|
@@ -400,7 +508,78 @@ declare const DEFAULTS: {
|
|
|
400
508
|
placeholderText: string;
|
|
401
509
|
welcomeMessage: string;
|
|
402
510
|
title: string;
|
|
511
|
+
colorScheme: "auto" | "light" | "dark";
|
|
512
|
+
primaryColorDark: string;
|
|
513
|
+
backgroundColorDark: string;
|
|
514
|
+
textColorDark: string;
|
|
515
|
+
size: "compact" | "default" | "large";
|
|
516
|
+
cornerStyle: "soft" | "rounded" | "square";
|
|
517
|
+
offsetBottom: number;
|
|
518
|
+
offsetSide: number;
|
|
519
|
+
zIndex: number;
|
|
520
|
+
};
|
|
521
|
+
declare const SIZE_PRESETS: {
|
|
522
|
+
readonly compact: {
|
|
523
|
+
readonly bubble: 48;
|
|
524
|
+
readonly width: 320;
|
|
525
|
+
readonly height: 480;
|
|
526
|
+
readonly fontSize: 13;
|
|
527
|
+
};
|
|
528
|
+
readonly default: {
|
|
529
|
+
readonly bubble: 56;
|
|
530
|
+
readonly width: 380;
|
|
531
|
+
readonly height: 520;
|
|
532
|
+
readonly fontSize: 14;
|
|
533
|
+
};
|
|
534
|
+
readonly large: {
|
|
535
|
+
readonly bubble: 64;
|
|
536
|
+
readonly width: 440;
|
|
537
|
+
readonly height: 600;
|
|
538
|
+
readonly fontSize: 15;
|
|
539
|
+
};
|
|
540
|
+
};
|
|
541
|
+
declare const CORNER_RADIUS: {
|
|
542
|
+
readonly soft: 8;
|
|
543
|
+
readonly rounded: 16;
|
|
544
|
+
readonly square: 0;
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
type EffectiveScheme = "light" | "dark";
|
|
548
|
+
/**
|
|
549
|
+
* Resolve the configured `colorScheme` against the visitor's OS preference.
|
|
550
|
+
* `prefersDark` is the live value of `matchMedia("(prefers-color-scheme: dark)")`
|
|
551
|
+
* (or `false` when not running in a browser). Kept as a pure function so the
|
|
552
|
+
* caller subscribes once and re-renders.
|
|
553
|
+
*/
|
|
554
|
+
declare function resolveScheme(colorScheme: ResolvedConfig["colorScheme"], prefersDark: boolean): EffectiveScheme;
|
|
555
|
+
/**
|
|
556
|
+
* Pick the colors that should drive the widget render right now. When the
|
|
557
|
+
* effective scheme is dark and a dark color is configured, use it; otherwise
|
|
558
|
+
* fall back to the light color (so half-configured dark mode still ships
|
|
559
|
+
* something readable rather than a white panel with white text).
|
|
560
|
+
*/
|
|
561
|
+
declare function effectiveColors(config: ResolvedConfig, scheme: EffectiveScheme): {
|
|
562
|
+
primary: string;
|
|
563
|
+
background: string;
|
|
564
|
+
text: string;
|
|
565
|
+
};
|
|
566
|
+
declare function sizePreset(size: ResolvedConfig["size"]): {
|
|
567
|
+
readonly bubble: 48;
|
|
568
|
+
readonly width: 320;
|
|
569
|
+
readonly height: 480;
|
|
570
|
+
readonly fontSize: 13;
|
|
571
|
+
} | {
|
|
572
|
+
readonly bubble: 56;
|
|
573
|
+
readonly width: 380;
|
|
574
|
+
readonly height: 520;
|
|
575
|
+
readonly fontSize: 14;
|
|
576
|
+
} | {
|
|
577
|
+
readonly bubble: 64;
|
|
578
|
+
readonly width: 440;
|
|
579
|
+
readonly height: 600;
|
|
580
|
+
readonly fontSize: 15;
|
|
403
581
|
};
|
|
582
|
+
declare function panelRadius(cornerStyle: ResolvedConfig["cornerStyle"]): 0 | 8 | 16;
|
|
404
583
|
|
|
405
584
|
declare class ScreenshotCancelled extends Error {
|
|
406
585
|
constructor(message?: string);
|
|
@@ -464,4 +643,4 @@ interface StartTriggersRuntimeOptions {
|
|
|
464
643
|
}
|
|
465
644
|
declare function startTriggersRuntime(options: StartTriggersRuntimeOptions): TriggersRuntimeHandle;
|
|
466
645
|
|
|
467
|
-
export { type ActionConfirmationBlock, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type IdentifyPayload, type IdentityData, type IncidentBanner, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, evaluate, isRtlLocale, pickFire, resolveLocale, startTriggersRuntime };
|
|
646
|
+
export { type ActionConfirmationBlock, CORNER_RADIUS, type ChatMessage, type ChatState, type ConsentSettings, CustomerHeroChat, type CustomerHeroChatConfig, DEFAULTS, type EffectiveScheme, type IdentifyPayload, type IdentityData, type IncidentBanner, type MessageAttachment, type MessageBlock, type MessageRating, type MessageSource, type MessageStatus, type PreChatField, type PreChatFieldKind, type PreChatFormConfig, type PreChatSubmission, type QuickRepliesBlock, type ResolvedConfig, SIZE_PRESETS, SUPPORTED_LOCALES, ScreenshotCancelled, ScreenshotUnavailable, type StringOverrides, type SupportedLocale, type TranslateFn, type TranslationKey, type Translations, type TriggerAction, type TriggerConditionLeaf, type TriggerConditionNode, type TriggerDefinition, type TriggerFrequency, type TriggersRuntimeHandle, type VisitorContext, canCaptureScreenshot, captureScreenshot, createTranslator, detectLocale, effectiveColors, evaluate, isRtlLocale, panelRadius, pickFire, resolveLocale, resolveScheme, sizePreset, startTriggersRuntime };
|