@aiden-voice/widget 0.8.0 → 0.9.1
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 +53 -12
- package/dist/components/Composer.d.ts +3 -1
- package/dist/components/MessageFeedback.d.ts +2 -1
- package/dist/components/MessageList.d.ts +6 -1
- package/dist/config.d.ts +1 -0
- package/dist/controller.d.ts +10 -0
- package/dist/i18n/index.d.ts +6 -0
- package/dist/i18n/messages.d.ts +2 -0
- package/dist/markdown/render.d.ts +5 -1
- package/dist/storage.d.ts +2 -0
- package/dist/types.d.ts +24 -0
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +873 -655
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,10 +96,15 @@ across renewals.
|
|
|
96
96
|
})
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
Without it, or when it
|
|
100
|
-
"This chat session has expired. Reload the page to continue."
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
Without it, or when it returns an empty or already expired token, the
|
|
100
|
+
visitor sees "This chat session has expired. Reload the page to continue."
|
|
101
|
+
When it throws or takes longer than 15 seconds, the failure may pass, so the
|
|
102
|
+
visitor sees "Something went wrong, please try again." and can send again,
|
|
103
|
+
which asks `getSessionToken` once more. Either way their message is put back
|
|
104
|
+
in the message box. A page served with an already
|
|
105
|
+
expired `sessionToken` also tries `getSessionToken` before giving up, and
|
|
106
|
+
shows no chat button until it answers (at most 15 seconds: a renewal that
|
|
107
|
+
takes longer counts as failed).
|
|
103
108
|
|
|
104
109
|
Branding (`color`, `inkColor`, `accentColor`, `name`) follows one rule in
|
|
105
110
|
both modes: **a value you pass to `init()` always wins**, anything you leave
|
|
@@ -129,6 +134,7 @@ throws synchronously, at call time, if you pass both or neither.
|
|
|
129
134
|
| `getSessionToken` | `sessionToken` mode only: a function returning a fresh session token (or a promise of one) from your backend, called when the current one has run out or is refused. Without it an expired session ends the chat until the page is reloaded. Ignored, with a warning, with `publishableKey` or when not a function. | none |
|
|
130
135
|
| `language` | Language of the widget's own text, as a BCP 47 tag (`'fr'`, `'pt-BR'`, `'zh-CN'`). Without it the widget follows the page's `<html lang>`, then English. See [Language](#language). | the page's language, else `'en'` |
|
|
131
136
|
| `messages` | Replaces individual built-in strings in the active language, e.g. `{ newConversation: 'Start over' }`. See [Language](#language). | none |
|
|
137
|
+
| `contentLanguage` | The language of the conversation's content (replies, the visitor's messages, and your `greeting`, `title`, `name` and image text), as a BCP 47 tag, so screen readers read it with the right voice. Separate from `language`, which only sets the widget's own text; `language` counts only for a page with no `<html lang>`. See [Language](#language). | the page's `<html lang>`, else `language`, else unknown |
|
|
132
138
|
| `position` | Launcher/panel corner: `'bottom-right'` or `'bottom-left'`. | `'bottom-right'` |
|
|
133
139
|
| `color` | Primary accent color (any valid CSS color). Overrides the color configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'#4f46e5'` |
|
|
134
140
|
| `inkColor` | Body text color (chat title and replies). Darkened automatically if needed to stay readable. Overrides the color configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'#111111'` |
|
|
@@ -136,18 +142,41 @@ throws synchronously, at call time, if you pass both or neither.
|
|
|
136
142
|
| `name` | Agent name for the panel header and the dialog's screen-reader label ("Chat with {name}"). Overrides the name configured in whoo-aiden; omit it to use that one. | whoo-aiden's, else `'Aiden'` |
|
|
137
143
|
| `title` | Full panel title, used for the header heading and the dialog's screen-reader label. Replaces the whole "Chat with {name}" string (e.g. `'Ask our concierge'`), with surrounding whitespace trimmed; the agent's messages are still labelled with its name. A blank value is ignored. | `'Chat with {name}'` |
|
|
138
144
|
| `greeting` | Welcome text shown in the panel before the first message. | none |
|
|
145
|
+
| `notice` | A notice, such as a disclaimer or terms of use, pinned at the top of the conversation. Unlike `greeting` it stays after the visitor writes, and comes back after "New conversation". Screen readers read it with the panel's title when the panel opens, until the visitor sends a first message. Supports `**bold**`, `_italic_`, `[links](https://...)` and `- ` lists; raw HTML shows as text. Blank values are ignored. See [Notice](#notice). | none |
|
|
146
|
+
| `requireNoticeAgreement` | Ask the visitor to agree to `notice` before chatting: an "I agree" button (the `agreeToNotice` message) replaces the message field until they do. Remembered for the tab session, and asked again if the notice text changes. Ignored, with a console warning, without a `notice`. See [Notice](#notice). | `false` |
|
|
139
147
|
| `launcherIconUrl` | Image shown on the launcher bubble instead of the default chat icon. `https:` or `data:image/` only. Until it loads, and permanently if it fails, the default icon shows. Alias of `theme.launcher.iconUrl`. | none (default icon) |
|
|
140
148
|
| `theme` | Colors, font and launcher icons. See [Theming](#theming). | defaults |
|
|
141
149
|
| `layout` | Launcher position and size, and panel size. See [Layout](#layout). | defaults |
|
|
142
150
|
| `emptyStateImageUrl` | Image (e.g. a brand lockup) shown above the greeting while the conversation is empty. `https:` or `data:image/` only. Removed if it fails to load. | none |
|
|
143
151
|
| `emptyStateImageAlt` | Alt text for `emptyStateImageUrl`. Set it when the image carries meaning (e.g. your brand name); omit it for a purely decorative image. | none (decorative) |
|
|
144
152
|
| `showFeedback` | Show thumbs up/down controls under each reply so visitors can rate answers (a thumbs-down opens an optional correction form). | `false` (hidden) |
|
|
145
|
-
| `zIndex` | Stacking level of the launcher and panel over your page. The default sits above carousels, sticky headers and most overlays, while leaving room above it for a cookie or consent modal. Lower it if one of your own layers should cover the chat (see the accessibility note below). While the panel fills the screen (a viewport 400px wide or less, or 420px tall or less), it is a modal dialog
|
|
153
|
+
| `zIndex` | Stacking level of the launcher and panel over your page. The default sits above carousels, sticky headers and most overlays, while leaving room above it for a cookie or consent modal. Lower it if one of your own layers should cover the chat (see the accessibility note below). While the panel fills the screen (a viewport 400px wide or less, or 420px tall or less), it is a modal dialog in the browser's top layer: it sits above your page's layers whatever `zIndex` says, and the rest of the page, including page-level accessibility toolbars, can't be reached until it closes. A modal dialog your own page opens afterwards sits above it. An invalid value logs a warning and uses the default. | `2147483000` |
|
|
146
154
|
| `apiBaseUrl` | Override the whoo-aiden API host the widget talks to. | `'https://api.aidenvoice.com'` |
|
|
147
155
|
|
|
148
156
|
### When something else already owns the corner
|
|
149
157
|
|
|
150
|
-
Some third-party overlays (accessibility toolbars, chat or cookie widgets) sit at the maximum possible z-index, `2147483647`, in the same corner. No `zIndex` value can beat that: at an equal level, whichever element comes later in the page wins, and those overlays are usually injected after the widget. Move the widget to the other corner with `position: 'bottom-left'` instead.
|
|
158
|
+
Some third-party overlays (accessibility toolbars, chat or cookie widgets) sit at the maximum possible z-index, `2147483647`, in the same corner. No `zIndex` value can beat that: at an equal level, whichever element comes later in the page wins, and those overlays are usually injected after the widget. Move the widget to the other corner with `position: 'bottom-left'` instead. (None of this applies while the panel fills the screen; see `zIndex`.)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
## Notice
|
|
162
|
+
|
|
163
|
+
Use `notice` for text every visitor must be shown before chatting, such as a disclaimer, and `requireNoticeAgreement` to have them agree to it first:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
init({
|
|
167
|
+
publishableKey: 'pk_...',
|
|
168
|
+
notice:
|
|
169
|
+
"**Welcome to Ask Aiden, our Guest Assistant!**\n\nAll information provided is for informational purposes only. By selecting \"I agree\", you accept our [Website Terms of Use](https://example.com/terms).",
|
|
170
|
+
requireNoticeAgreement: true,
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
- **Where it shows:** above the conversation (below `emptyStateImageUrl`, above `greeting`), outlined rather than in a chat bubble, since it isn't something the agent said. It never leaves the transcript. The panel opens scrolled to its first line until the visitor writes.
|
|
175
|
+
- **Screen readers:** the panel is described by the notice, so it's read with the title when the panel opens, until the visitor sends a first message (after that it would repeat on every open). It stays reachable as the first item of the conversation.
|
|
176
|
+
- **It isn't sent to the agent** and isn't saved with the conversation.
|
|
177
|
+
- **Agreement (`requireNoticeAgreement: true`):** until the visitor agrees, an "I agree" button takes the message field's place, and nothing can be sent. When the panel opens, focus is on the button, which the notice describes, so screen readers read the title, "I agree, button" and the notice; after agreeing, focus moves to the message field. The agreement lasts for the tab session (like the conversation), survives "New conversation", and is asked for again if you change the notice text. Change the label with `messages: { agreeToNotice: '...' }`; if you do, make the notice text match it.
|
|
178
|
+
- **No record is kept.** The agreement lives only in the visitor's browser (`sessionStorage`); the widget doesn't send it to whoo-aiden, so it is no proof of consent. Whether that, and the wording, is enough is a question for your legal counsel.
|
|
179
|
+
- **Write it in your content language,** like `greeting`. It's not translated.
|
|
151
180
|
|
|
152
181
|
## Language
|
|
153
182
|
|
|
@@ -157,11 +186,12 @@ The widget's own text (buttons, labels, status and error messages, and what scre
|
|
|
157
186
|
- **Regional tags** match their language: `fr-CA` is French, any `pt-*` gets Brazilian Portuguese, any `es-*` gets Latin American Spanish. Simplified Chinese matches `zh`, `zh-CN`, `zh-SG` and `zh-Hans`. Traditional Chinese (`zh-TW`, `zh-HK`, `zh-Hant`) is not supported and falls back to English.
|
|
158
187
|
- **Decided once, at `init()`.** If your single-page app changes `<html lang>` later, pass `language` (unmount and `init()` again to switch).
|
|
159
188
|
- **Arabic is right to left:** the panel's layout mirrors (the visitor's messages on the left). The corner set by `position` doesn't change.
|
|
160
|
-
- **Not translated:** the agent's replies (the model answers in whatever language it does), and `greeting`, `title` and `name`, which you write in the language you want.
|
|
189
|
+
- **Not translated:** the agent's replies (the model answers in whatever language it does), and `greeting`, `notice`, `title` and `name`, which you write in the language you want. These are marked with the **content language**, not the widget's: `contentLanguage` if you pass it, else your page's `<html lang>` (any language, not just the eleven), else `language` if the page has no `lang`, else unknown. So on a Dutch page the widget's buttons are English, while replies and your Dutch greeting are read with a Dutch voice.
|
|
190
|
+
- **Direction:** each paragraph and list item of a message takes its direction from its own first letter, so an English reply in an Arabic widget, or the reverse, still reads correctly. A paragraph that starts with a Latin name ("Aiden …") in Arabic text is laid out left to right, as the bidi standard decides.
|
|
161
191
|
- **The widget marks its own language** (`lang` and `dir` on its root, naming the variant it ships: `pt-BR`, `es-419`, `zh-Hans`), so screen readers pronounce it correctly even on a page in another language.
|
|
162
|
-
- **Upgrading from a version before 0.8.0:** a page whose `<html lang>` is one of these languages now gets the widget in that language, where it was English before. Pass `language: 'en'` to keep it in English.
|
|
192
|
+
- **Upgrading from a version before 0.8.0:** a page whose `<html lang>` is one of these languages now gets the widget in that language, where it was English before. Pass `language: 'en'` to keep it in English; replies and your own text keep your page's language for screen readers either way.
|
|
163
193
|
|
|
164
|
-
**Changing the wording.** `messages` replaces any built-in string in the active language. Write overrides in that language, or set `language` to the language of your overrides. `chatWith` takes `{name}`, the agent's name. Unknown keys, and values that aren't non-blank strings, are ignored with a console warning.
|
|
194
|
+
**Changing the wording.** `messages` replaces any built-in string in the active language. Write overrides in that language, or set `language` to the language of your overrides. `chatWith` takes `{name}`, the agent's name. Unknown keys, and values that aren't non-blank strings (invisible characters such as a zero-width space count as blank), are ignored with a console warning. Overrides are marked with the widget's language: an override in another language (an English brand phrase in a French widget) is read with the widget's voice.
|
|
165
195
|
|
|
166
196
|
```js
|
|
167
197
|
window.whooAidenWidget.init({
|
|
@@ -199,6 +229,8 @@ window.whooAidenWidget.init({
|
|
|
199
229
|
| `conversationCleared` | Conversation cleared | screen-reader announcement |
|
|
200
230
|
| `genericError` | Something went wrong, please try again. | error alert |
|
|
201
231
|
| `sessionExpired` | This chat session has expired. Reload the page to continue. | error alert |
|
|
232
|
+
| `opensInNewTab` | (opens in new tab) | screen readers only, after each link in a reply: every link in a reply opens in a new tab |
|
|
233
|
+
| `agreeToNotice` | I agree | button the visitor presses to agree to the `notice`, with `requireNoticeAgreement` |
|
|
202
234
|
|
|
203
235
|
**About the translations:** they were machine-drafted and cross-checked by independent AI agents (back-translation, critique, and rendering checks), not reviewed by native speakers. [docs/translation-verification.md](docs/translation-verification.md) records every check. If any wording reads wrong, override it with `messages`, and please tell us.
|
|
204
236
|
|
|
@@ -562,9 +594,18 @@ The widget distinguishes two deliberately different error tiers:
|
|
|
562
594
|
response from the server) show a short, non-technical inline message in the
|
|
563
595
|
chat panel itself (e.g. "Something went wrong, please try again"), leaving
|
|
564
596
|
any partial response already rendered in place above it. A session that
|
|
565
|
-
runs out while the page is open is renewed (see Usage);
|
|
566
|
-
|
|
567
|
-
|
|
597
|
+
runs out while the page is open is renewed (see Usage); when the session is
|
|
598
|
+
refused the panel says "This chat session has expired. Reload the page to
|
|
599
|
+
continue." instead. When renewing fails for a reason that may pass (offline,
|
|
600
|
+
the key's daily limit, `getSessionToken` throwing or taking over 15
|
|
601
|
+
seconds), it says "Something went wrong, please try again", because a reload
|
|
602
|
+
wouldn't help. Either way the visitor's message goes back into the message
|
|
603
|
+
box, and leaves the transcript (so a retry doesn't show it twice). Closing
|
|
604
|
+
the panel cancels a pending reply silently; the message is handed back only
|
|
605
|
+
if it never reached the server (the widget was still renewing the session).
|
|
606
|
+
A session refused after the widget is already showing (the start-up check
|
|
607
|
+
outlived its 3-second wait) no longer removes it: the panel says the session
|
|
608
|
+
expired instead.
|
|
568
609
|
|
|
569
610
|
How a bad `sessionToken` is caught at start-up, without the widget ever
|
|
570
611
|
holding a key to check its signature:
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RefObject } from 'preact';
|
|
2
2
|
import { WidgetMessages } from '../i18n/messages';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function isComposing(event: KeyboardEvent): boolean;
|
|
4
|
+
export declare function Composer({ value, onChange, onSend, disabled, inputRef, text, contentLanguage, }: {
|
|
4
5
|
value: string;
|
|
5
6
|
onChange: (value: string) => void;
|
|
6
7
|
onSend: () => void;
|
|
7
8
|
disabled: boolean;
|
|
8
9
|
inputRef?: RefObject<HTMLInputElement | null>;
|
|
9
10
|
text?: WidgetMessages;
|
|
11
|
+
contentLanguage?: string;
|
|
10
12
|
}): import('preact').JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RefObject } from 'preact';
|
|
2
2
|
import { FeedbackCategory, MessageFeedbackState } from '../controller';
|
|
3
3
|
import { WidgetMessages } from '../i18n/messages';
|
|
4
|
-
export declare function MessageFeedback({ state, containerRef, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancel, text, }: {
|
|
4
|
+
export declare function MessageFeedback({ state, containerRef, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancel, text, contentLanguage, }: {
|
|
5
5
|
state: MessageFeedbackState;
|
|
6
6
|
containerRef?: RefObject<HTMLElement>;
|
|
7
7
|
onThumbsUp: () => void;
|
|
@@ -10,4 +10,5 @@ export declare function MessageFeedback({ state, containerRef, onThumbsUp, onThu
|
|
|
10
10
|
onSubmitDetailed: (correction: string, category: '' | FeedbackCategory) => void;
|
|
11
11
|
onCancel: () => void;
|
|
12
12
|
text?: WidgetMessages;
|
|
13
|
+
contentLanguage?: string;
|
|
13
14
|
}): import('preact').JSX.Element;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FeedbackCategory, Message, MessageFeedbackState } from '../controller';
|
|
2
2
|
import { WidgetMessages } from '../i18n/messages';
|
|
3
|
+
export declare const NOTICE_ID = "whoo-widget-notice";
|
|
3
4
|
type DraftChangeHandler = (messageId: string, correction: string, category: '' | FeedbackCategory) => void;
|
|
4
5
|
type SubmitHandler = (messageId: string, correction: string, category: '' | FeedbackCategory) => void;
|
|
5
|
-
export declare function MessageList({ messages, messageFeedback, announcement, emptyStateImage, agentName, showFeedback, isStreaming, isSlowResponse, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancelFeedback, text, }: {
|
|
6
|
+
export declare function MessageList({ messages, messageFeedback, announcement, emptyStateImage, notice, agentName, showFeedback, isStreaming, isSlowResponse, onThumbsUp, onThumbsDown, onDraftChange, onSubmitDetailed, onCancelFeedback, text, contentLanguage, languageTag, announcementIsContent, }: {
|
|
6
7
|
messages: Message[];
|
|
7
8
|
messageFeedback: Record<string, MessageFeedbackState>;
|
|
8
9
|
announcement: string | null;
|
|
@@ -10,6 +11,7 @@ export declare function MessageList({ messages, messageFeedback, announcement, e
|
|
|
10
11
|
url: string;
|
|
11
12
|
alt: string;
|
|
12
13
|
};
|
|
14
|
+
notice?: string;
|
|
13
15
|
agentName?: string;
|
|
14
16
|
showFeedback?: boolean;
|
|
15
17
|
isStreaming?: boolean;
|
|
@@ -20,5 +22,8 @@ export declare function MessageList({ messages, messageFeedback, announcement, e
|
|
|
20
22
|
onSubmitDetailed: SubmitHandler;
|
|
21
23
|
onCancelFeedback: (messageId: string) => void;
|
|
22
24
|
text?: WidgetMessages;
|
|
25
|
+
contentLanguage?: string;
|
|
26
|
+
languageTag?: string;
|
|
27
|
+
announcementIsContent?: boolean;
|
|
23
28
|
}): import('preact').JSX.Element;
|
|
24
29
|
export {};
|
package/dist/config.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const DEFAULT_Z_INDEX = 2147483000;
|
|
|
6
6
|
export declare function resolveZIndex(zIndex: unknown): number;
|
|
7
7
|
export declare const DEFAULT_AGENT_NAME = "Aiden";
|
|
8
8
|
export declare function trimmedName(name: unknown): string;
|
|
9
|
+
export declare function isBlankText(text: string): boolean;
|
|
9
10
|
export declare function validateConfig(config: WidgetConfig): void;
|
|
10
11
|
export declare function normalizeGetSessionToken(config: WidgetConfig): (() => string | Promise<string>) | undefined;
|
|
11
12
|
export declare function normalizeMessages(value: unknown): Partial<WidgetMessages>;
|
package/dist/controller.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { WidgetConfig } from './types';
|
|
|
5
5
|
export declare const SLOW_RESPONSE_DELAY_MS = 8000;
|
|
6
6
|
export declare const BRANDING_LOOKUP_WAIT_MS = 3000;
|
|
7
7
|
export declare const TOKEN_RENEWAL_MARGIN_MS = 60000;
|
|
8
|
+
export declare const RENEWAL_TIMEOUT_MS = 15000;
|
|
8
9
|
export interface Message {
|
|
9
10
|
role: 'user' | 'assistant';
|
|
10
11
|
content: string;
|
|
@@ -30,7 +31,9 @@ export interface WidgetState {
|
|
|
30
31
|
accentColor: string | null;
|
|
31
32
|
inkColor: string | null;
|
|
32
33
|
announcement: string | null;
|
|
34
|
+
announcementIsContent: boolean;
|
|
33
35
|
isSlowResponse: boolean;
|
|
36
|
+
noticeAgreed: boolean;
|
|
34
37
|
draft: string;
|
|
35
38
|
}
|
|
36
39
|
type Listener = (state: WidgetState) => void;
|
|
@@ -41,6 +44,8 @@ export declare class WidgetController {
|
|
|
41
44
|
private sessionToken;
|
|
42
45
|
private sessionTokenExpiresAt;
|
|
43
46
|
private tokenRenewal;
|
|
47
|
+
private renewalGeneration;
|
|
48
|
+
private sendEpoch;
|
|
44
49
|
private readonly getSessionToken;
|
|
45
50
|
private conversationId;
|
|
46
51
|
private readonly storageIdentifier;
|
|
@@ -51,10 +56,13 @@ export declare class WidgetController {
|
|
|
51
56
|
readonly launcherIconUrl: string | undefined;
|
|
52
57
|
readonly emptyStateImageUrl: string | undefined;
|
|
53
58
|
readonly emptyStateImageAlt: string;
|
|
59
|
+
readonly notice: string;
|
|
60
|
+
readonly requireNoticeAgreement: boolean;
|
|
54
61
|
readonly showFeedback: boolean;
|
|
55
62
|
readonly text: WidgetMessages;
|
|
56
63
|
readonly language: SupportedLanguage;
|
|
57
64
|
readonly languageTag: string;
|
|
65
|
+
readonly contentLanguage: string;
|
|
58
66
|
readonly dir: 'ltr' | 'rtl';
|
|
59
67
|
constructor(config: WidgetConfig);
|
|
60
68
|
getState(): WidgetState;
|
|
@@ -66,6 +74,7 @@ export declare class WidgetController {
|
|
|
66
74
|
private loadBranding;
|
|
67
75
|
open(): void;
|
|
68
76
|
resetConversation(): void;
|
|
77
|
+
agreeToNotice(): void;
|
|
69
78
|
setDraft(draft: string): void;
|
|
70
79
|
close(): void;
|
|
71
80
|
sendMessage(text: string): Promise<void>;
|
|
@@ -76,6 +85,7 @@ export declare class WidgetController {
|
|
|
76
85
|
private currentToken;
|
|
77
86
|
private renewToken;
|
|
78
87
|
private fetchNewToken;
|
|
88
|
+
private obtainToken;
|
|
79
89
|
private withSession;
|
|
80
90
|
}
|
|
81
91
|
export {};
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export declare function resolveLanguage(option: unknown, pageLang: unknown): {
|
|
|
20
20
|
tag: string;
|
|
21
21
|
dir: 'ltr' | 'rtl';
|
|
22
22
|
};
|
|
23
|
+
export declare function resolveContentLanguage(option: unknown, pageLang: unknown, languageOption?: unknown): string;
|
|
24
|
+
export declare function templateParts(template: string): {
|
|
25
|
+
before: string;
|
|
26
|
+
after: string;
|
|
27
|
+
hasName: boolean;
|
|
28
|
+
};
|
|
23
29
|
export declare function format(template: string, values: {
|
|
24
30
|
name: string;
|
|
25
31
|
}): string;
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface WidgetMessages {
|
|
|
25
25
|
conversationCleared: string;
|
|
26
26
|
genericError: string;
|
|
27
27
|
sessionExpired: string;
|
|
28
|
+
opensInNewTab: string;
|
|
29
|
+
agreeToNotice: string;
|
|
28
30
|
}
|
|
29
31
|
export declare const ENGLISH: WidgetMessages;
|
|
30
32
|
export declare const MESSAGE_KEYS: (keyof WidgetMessages)[];
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { ComponentChildren } from 'preact';
|
|
2
|
-
export
|
|
2
|
+
export interface RenderOptions {
|
|
3
|
+
linkCue?: string;
|
|
4
|
+
linkCueLang?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function renderMarkdown(source: string, options?: RenderOptions): ComponentChildren;
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare function getStoredConversationId(identifier: string): string | null;
|
|
2
2
|
export declare function setStoredConversationId(identifier: string, conversationId: string): void;
|
|
3
|
+
export declare function hasAgreedToNotice(identifier: string, notice: string): boolean;
|
|
4
|
+
export declare function setAgreedToNotice(identifier: string, notice: string): void;
|
|
3
5
|
export declare function clearStoredConversationId(identifier: string): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -94,6 +94,15 @@ export interface WidgetConfig {
|
|
|
94
94
|
* Unknown keys and blank or non-string values are ignored with a warning.
|
|
95
95
|
*/
|
|
96
96
|
messages?: Partial<WidgetMessages>;
|
|
97
|
+
/**
|
|
98
|
+
* The language of the conversation's content (replies, the visitor's
|
|
99
|
+
* messages, and your greeting, notice, title, name and image text), as a BCP 47
|
|
100
|
+
* tag, so screen readers read it with the right voice. Defaults to the
|
|
101
|
+
* page's <html lang>, then to `language` when the page has none, else
|
|
102
|
+
* unknown. Separate from `language`, which only sets the widget's own
|
|
103
|
+
* buttons and messages.
|
|
104
|
+
*/
|
|
105
|
+
contentLanguage?: string;
|
|
97
106
|
position?: 'bottom-right' | 'bottom-left';
|
|
98
107
|
/**
|
|
99
108
|
* Primary accent color. Overrides the color configured in whoo-aiden, in
|
|
@@ -113,6 +122,21 @@ export interface WidgetConfig {
|
|
|
113
122
|
name?: string;
|
|
114
123
|
title?: string;
|
|
115
124
|
greeting?: string;
|
|
125
|
+
/**
|
|
126
|
+
* A notice (e.g. a disclaimer or terms of use) pinned at the top of the
|
|
127
|
+
* conversation. Unlike `greeting` it stays after the visitor sends a
|
|
128
|
+
* message, and screen readers read it when the panel opens until then.
|
|
129
|
+
* Supports **bold**, _italic_ and [links](https://...). Blank or non-string
|
|
130
|
+
* values are ignored.
|
|
131
|
+
*/
|
|
132
|
+
notice?: string;
|
|
133
|
+
/**
|
|
134
|
+
* Require the visitor to agree to `notice` before chatting: the panel shows
|
|
135
|
+
* an "I agree" button (the `agreeToNotice` message) in place of the message
|
|
136
|
+
* field until they do. Remembered for the tab session, and asked again if
|
|
137
|
+
* the notice text changes. Ignored without a `notice`. Off by default.
|
|
138
|
+
*/
|
|
139
|
+
requireNoticeAgreement?: boolean;
|
|
116
140
|
/** Image shown on the launcher bubble instead of the default chat icon. Alias of `theme.launcher.iconUrl`, which wins if both are set. */
|
|
117
141
|
launcherIconUrl?: string;
|
|
118
142
|
/** Image shown above the greeting while the conversation is empty. */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const WIDGET_VERSION = "0.
|
|
1
|
+
export declare const WIDGET_VERSION = "0.9.1";
|