@askly/widget 2.11.0 → 3.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.
- package/MIGRATION-3.0.md +58 -0
- package/README.md +131 -3
- package/dist/app/HelpTab-BrWJK4wa.js +1 -0
- package/dist/app/VoiceRecorder-rdqySW9p.js +1 -0
- package/dist/app/ar-V_LzQrur.js +1 -0
- package/dist/app/askly-app.js +1 -0
- package/dist/app/de-BN3nFgQz.js +1 -0
- package/dist/app/es-BvfGFMIb.js +1 -0
- package/dist/app/fr-DNlpcnFv.js +1 -0
- package/dist/app/hi-C81tFu4P.js +1 -0
- package/dist/app/pt-nxDVHThV.js +1 -0
- package/dist/app/shared-Cp0FX5Ux.js +1 -0
- package/dist/app/speech-8iAgRQFA.js +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/loader.js +1 -0
- package/dist/types/app.d.ts +3 -0
- package/dist/types/core/api.d.ts +34 -0
- package/dist/types/core/config.d.ts +52 -0
- package/dist/{core → types/core}/events.d.ts +10 -0
- package/dist/types/core/format.d.ts +2 -0
- package/dist/types/core/html.d.ts +2 -0
- package/dist/{core → types/core}/speech.d.ts +2 -7
- package/dist/{core → types/core}/types.d.ts +8 -0
- package/dist/types/core/voice.d.ts +6 -0
- package/dist/types/i18n/en.d.ts +144 -0
- package/dist/types/i18n/index.d.ts +32 -0
- package/dist/types/i18n/locales/ar.d.ts +3 -0
- package/dist/types/i18n/locales/de.d.ts +3 -0
- package/dist/types/i18n/locales/es.d.ts +3 -0
- package/dist/types/i18n/locales/fr.d.ts +3 -0
- package/dist/types/i18n/locales/hi.d.ts +3 -0
- package/dist/types/i18n/locales/pt.d.ts +3 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/loader/attrs.d.ts +4 -0
- package/dist/types/loader/core.d.ts +26 -0
- package/dist/types/ui/ChatTerms.d.ts +5 -0
- package/dist/{ui → types/ui}/GreetingBubble.d.ts +4 -0
- package/dist/{ui → types/ui}/Launcher.d.ts +5 -0
- package/dist/{ui → types/ui}/MessageList.d.ts +5 -0
- package/dist/types/widget-entry.d.ts +1 -0
- package/dist/types/widget.d.ts +3 -0
- package/dist/widget.js +1 -10
- package/package.json +33 -21
- package/dist/core/format.d.ts +0 -2
- package/dist/index.d.ts +0 -124
- package/dist/ui/ChatTerms.d.ts +0 -3
- package/dist/widget.d.ts +0 -4
- /package/dist/{core → types/core}/greeting.d.ts +0 -0
- /package/dist/{core → types/core}/session.d.ts +0 -0
- /package/dist/{core → types/core}/storage.d.ts +0 -0
- /package/dist/{icons.d.ts → types/icons.d.ts} +0 -0
- /package/dist/{identity.d.ts → types/identity.d.ts} +0 -0
- /package/dist/{markdown.d.ts → types/markdown.d.ts} +0 -0
- /package/dist/{pathRules.d.ts → types/pathRules.d.ts} +0 -0
- /package/dist/{realtime.d.ts → types/realtime.d.ts} +0 -0
- /package/dist/{ui → types/ui}/Composer.d.ts +0 -0
- /package/dist/{ui → types/ui}/ConversationList.d.ts +0 -0
- /package/dist/{ui → types/ui}/ExploreTab.d.ts +0 -0
- /package/dist/{ui → types/ui}/HelpTab.d.ts +0 -0
- /package/dist/{ui → types/ui}/NavTabs.d.ts +0 -0
- /package/dist/{ui → types/ui}/PanelHeader.d.ts +0 -0
- /package/dist/{ui → types/ui}/VoiceRecorder.d.ts +0 -0
|
@@ -6,6 +6,13 @@ export interface ChatWidgetProps {
|
|
|
6
6
|
themeColor?: string;
|
|
7
7
|
theme?: "light" | "dark" | "auto";
|
|
8
8
|
position?: "left" | "right";
|
|
9
|
+
offset?: {
|
|
10
|
+
bottom?: number;
|
|
11
|
+
side?: number;
|
|
12
|
+
};
|
|
13
|
+
hideLauncher?: boolean;
|
|
14
|
+
customLauncherSelector?: string;
|
|
15
|
+
locale?: string;
|
|
9
16
|
orgServerRoute: string;
|
|
10
17
|
voiceInput?: false | "review" | "auto-send";
|
|
11
18
|
/** @deprecated use `voiceInput`. `false` turns voice input off for this embed. */
|
|
@@ -34,6 +41,7 @@ export interface ChatWidgetProps {
|
|
|
34
41
|
includePaths?: string[];
|
|
35
42
|
configOverride?: Record<string, any>;
|
|
36
43
|
resetGeneration?: number;
|
|
44
|
+
greetingStartedAt?: number;
|
|
37
45
|
onMessageSent?: (message: string) => void;
|
|
38
46
|
onMessageReceived?: (reply: string) => void;
|
|
39
47
|
onChatOpened?: () => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type VoiceInputMode = "off" | "review" | "auto-send";
|
|
2
|
+
/** Why voice input could not start or finish. */
|
|
3
|
+
export type VoiceErrorCode = "insecure" | "unsupported" | "denied" | "no-microphone" | "no-speech" | "no-audio" | "limit" | "disabled" | "network" | "failed";
|
|
4
|
+
export declare function normalizeVoiceInputMode(value: any): VoiceInputMode | undefined;
|
|
5
|
+
/** What to tell the visitor. */
|
|
6
|
+
export declare function voiceErrorMessage(code: VoiceErrorCode): string;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string the widget shows, in English. Other locales live in ./locales and may leave
|
|
3
|
+
* keys out; English fills the gaps. `{name}` marks a value filled in at runtime. Keys ending
|
|
4
|
+
* in `_one` / `_other` are plural forms chosen with Intl.PluralRules.
|
|
5
|
+
*/
|
|
6
|
+
declare const en: {
|
|
7
|
+
launcher_open: string;
|
|
8
|
+
launcher_close: string;
|
|
9
|
+
launcher_open_unread_one: string;
|
|
10
|
+
launcher_open_unread_other: string;
|
|
11
|
+
launcher_unread_overflow: string;
|
|
12
|
+
panel_label: string;
|
|
13
|
+
header_messages: string;
|
|
14
|
+
header_help_center: string;
|
|
15
|
+
header_back_to_conversations: string;
|
|
16
|
+
header_expand: string;
|
|
17
|
+
header_collapse: string;
|
|
18
|
+
header_close: string;
|
|
19
|
+
conversation_label: string;
|
|
20
|
+
sending_to_team: string;
|
|
21
|
+
uploading_attachment: string;
|
|
22
|
+
new_messages_one: string;
|
|
23
|
+
new_messages_other: string;
|
|
24
|
+
reaction_helpful: string;
|
|
25
|
+
reaction_not_helpful: string;
|
|
26
|
+
copy_message: string;
|
|
27
|
+
copied: string;
|
|
28
|
+
message_from_agent: string;
|
|
29
|
+
message_from_you: string;
|
|
30
|
+
terms_notice: string;
|
|
31
|
+
terms_link: string;
|
|
32
|
+
powered_by: string;
|
|
33
|
+
tab_explore: string;
|
|
34
|
+
tab_messages: string;
|
|
35
|
+
tab_help: string;
|
|
36
|
+
tabs_label: string;
|
|
37
|
+
conversations_empty_title: string;
|
|
38
|
+
conversations_empty_desc: string;
|
|
39
|
+
conversation_no_messages: string;
|
|
40
|
+
conversation_title: string;
|
|
41
|
+
start_new_chat: string;
|
|
42
|
+
composer_label: string;
|
|
43
|
+
composer_placeholder: string;
|
|
44
|
+
composer_placeholder_lead_required: string;
|
|
45
|
+
composer_placeholder_security_check: string;
|
|
46
|
+
composer_hint: string;
|
|
47
|
+
attach_file: string;
|
|
48
|
+
insert_emoji: string;
|
|
49
|
+
emoji_picker_label: string;
|
|
50
|
+
send_message: string;
|
|
51
|
+
attachment_image_alt: string;
|
|
52
|
+
attachment_file_label: string;
|
|
53
|
+
notice_security_check_required: string;
|
|
54
|
+
voice_start: string;
|
|
55
|
+
voice_finish: string;
|
|
56
|
+
voice_status_waiting: string;
|
|
57
|
+
voice_status_listening: string;
|
|
58
|
+
voice_status_transcribing: string;
|
|
59
|
+
voice_seconds_left_one: string;
|
|
60
|
+
voice_seconds_left_other: string;
|
|
61
|
+
voice_countdown: string;
|
|
62
|
+
voice_cancel: string;
|
|
63
|
+
voice_stop: string;
|
|
64
|
+
voice_retry: string;
|
|
65
|
+
voice_error_insecure: string;
|
|
66
|
+
voice_error_unsupported: string;
|
|
67
|
+
voice_error_denied: string;
|
|
68
|
+
voice_error_no_microphone: string;
|
|
69
|
+
voice_error_no_speech: string;
|
|
70
|
+
voice_error_no_audio: string;
|
|
71
|
+
voice_error_limit: string;
|
|
72
|
+
voice_error_disabled: string;
|
|
73
|
+
voice_error_network: string;
|
|
74
|
+
voice_error_failed: string;
|
|
75
|
+
lead_prompt: string;
|
|
76
|
+
lead_email_placeholder: string;
|
|
77
|
+
lead_email_label: string;
|
|
78
|
+
lead_save: string;
|
|
79
|
+
lead_saving: string;
|
|
80
|
+
lead_dismiss: string;
|
|
81
|
+
lead_error_invalid_email: string;
|
|
82
|
+
lead_error_save_failed: string;
|
|
83
|
+
greeting_default: string;
|
|
84
|
+
greeting_default_persona: string;
|
|
85
|
+
greeting_dismiss: string;
|
|
86
|
+
welcome_default: string;
|
|
87
|
+
explore_hero_title: string;
|
|
88
|
+
explore_hero_subtitle: string;
|
|
89
|
+
explore_search_placeholder: string;
|
|
90
|
+
explore_cta_title: string;
|
|
91
|
+
explore_cta_sub: string;
|
|
92
|
+
explore_tile_help_title: string;
|
|
93
|
+
explore_tile_help_sub: string;
|
|
94
|
+
explore_tile_messages_title: string;
|
|
95
|
+
explore_tile_messages_sub: string;
|
|
96
|
+
explore_popular_questions: string;
|
|
97
|
+
explore_ask_ai_about_this: string;
|
|
98
|
+
explore_recommended_reading: string;
|
|
99
|
+
help_search_placeholder: string;
|
|
100
|
+
help_search_label: string;
|
|
101
|
+
help_searching: string;
|
|
102
|
+
help_search_no_results: string;
|
|
103
|
+
help_all_collections: string;
|
|
104
|
+
help_back_to_articles: string;
|
|
105
|
+
help_document_type_fallback: string;
|
|
106
|
+
help_written_by: string;
|
|
107
|
+
help_updated_recently: string;
|
|
108
|
+
help_read_time_one: string;
|
|
109
|
+
help_read_time_other: string;
|
|
110
|
+
help_feedback_title: string;
|
|
111
|
+
help_feedback_thanks: string;
|
|
112
|
+
help_feedback_yes: string;
|
|
113
|
+
help_feedback_somewhat: string;
|
|
114
|
+
help_feedback_no: string;
|
|
115
|
+
help_handoff_title: string;
|
|
116
|
+
help_handoff_desc: string;
|
|
117
|
+
help_handoff_prefill: string;
|
|
118
|
+
help_collection_articles: string;
|
|
119
|
+
help_article_count_one: string;
|
|
120
|
+
help_article_count_other: string;
|
|
121
|
+
help_empty_title: string;
|
|
122
|
+
help_empty_desc: string;
|
|
123
|
+
help_collection_guide_title: string;
|
|
124
|
+
help_collection_guide_desc: string;
|
|
125
|
+
help_collection_faq_title: string;
|
|
126
|
+
help_collection_faq_desc: string;
|
|
127
|
+
help_collection_troubleshooting_title: string;
|
|
128
|
+
help_collection_troubleshooting_desc: string;
|
|
129
|
+
help_collection_other_title: string;
|
|
130
|
+
help_collection_other_desc: string;
|
|
131
|
+
help_featured_article: string;
|
|
132
|
+
help_untitled_article: string;
|
|
133
|
+
help_unavailable: string;
|
|
134
|
+
link_opens_new_tab: string;
|
|
135
|
+
error_search_rate_limited: string;
|
|
136
|
+
error_search_unavailable: string;
|
|
137
|
+
error_send_rate_limited: string;
|
|
138
|
+
error_send_failed: string;
|
|
139
|
+
error_attachment_rejected: string;
|
|
140
|
+
error_attachment_upload_failed: string;
|
|
141
|
+
};
|
|
142
|
+
export type Messages = typeof en;
|
|
143
|
+
export type MessageKey = keyof Messages;
|
|
144
|
+
export default en;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translations. English is built in; other locales are chunks fetched on demand. The host
|
|
3
|
+
* page can override any string with `Askly.updateTexts()`, and the portal can set the
|
|
4
|
+
* tenant's locale, which wins over the browser's.
|
|
5
|
+
*/
|
|
6
|
+
import { type Messages, type MessageKey } from "./en";
|
|
7
|
+
export type { Messages, MessageKey };
|
|
8
|
+
export declare const SUPPORTED_LOCALES: string[];
|
|
9
|
+
/** The language tag in use, e.g. "en", "pt-BR". */
|
|
10
|
+
export declare function getLocale(): string;
|
|
11
|
+
/** Text direction for the current locale. */
|
|
12
|
+
export declare function getDirection(): "ltr" | "rtl";
|
|
13
|
+
/** The shipped pack that best matches a requested tag: exact, then its language. */
|
|
14
|
+
export declare function resolveLocale(requested: string | undefined | null): string;
|
|
15
|
+
/**
|
|
16
|
+
* Switch locale. Resolves once the pack is in place (immediately for English or a pack
|
|
17
|
+
* already fetched). An unknown locale falls back to English; a pack that fails to load
|
|
18
|
+
* leaves English in place rather than failing.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setLocale(requested: string | undefined | null): Promise<string>;
|
|
21
|
+
/** Replace any strings with the host's own wording, in whatever locale is active. */
|
|
22
|
+
export declare function updateTexts(texts: Partial<Record<MessageKey, string>>): void;
|
|
23
|
+
/** Re-render on locale or text changes. Returns the unsubscribe. */
|
|
24
|
+
export declare function onTextsChange(listener: () => void): () => void;
|
|
25
|
+
type Params = Record<string, string | number>;
|
|
26
|
+
/** A string in the current locale, with `{name}` placeholders filled in. */
|
|
27
|
+
export declare function t(key: MessageKey, params?: Params): string;
|
|
28
|
+
/** A plural string: `key_one` / `key_other` (and `_zero`, `_two`, `_few`, `_many` when a pack has them). */
|
|
29
|
+
export declare function tn(key: string, count: number, params?: Params): string;
|
|
30
|
+
export declare function formatNumber(n: number): string;
|
|
31
|
+
/** A clock time (today) or a short date (earlier) in the visitor's locale. */
|
|
32
|
+
export declare function formatTime(dateAny: any): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AsklyApi } from "./core/api";
|
|
2
|
+
declare const Askly: AsklyApi;
|
|
3
|
+
export default Askly;
|
|
4
|
+
export type { AsklyApi } from "./core/api";
|
|
5
|
+
export type { AsklyConfig } from "./core/config";
|
|
6
|
+
export type { AsklyIdentity } from "./identity";
|
|
7
|
+
export type { AsklyEventMap, AsklyEventName, AsklyEventHandler, AsklySpace } from "./core/events";
|
|
8
|
+
export type { MessageKey as AsklyTextKey } from "./i18n/en";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** `data-*` attributes on the script tag, as init() options. */
|
|
2
|
+
import type { AsklyConfig } from "../core/config";
|
|
3
|
+
export declare function appIdFromScript(script: Element | null): string | undefined;
|
|
4
|
+
export declare function configFromScript(currentScript: Element, autoAppId: string): AsklyConfig;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const ASKLY_API_BASE = "https://api.askly.co.in";
|
|
2
|
+
export declare const APP_FILE = "app/askly-app.js";
|
|
3
|
+
export interface LoaderOptions {
|
|
4
|
+
/** URL of the app module (`app/askly-app.js`). */
|
|
5
|
+
appUrl: string;
|
|
6
|
+
/** Tried when `appUrl` cannot be fetched (the versioned CDN copy). */
|
|
7
|
+
fallbackUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
/** The queue the app replays. `v` lets a future app recognise an older stub. */
|
|
10
|
+
export interface AsklyStub {
|
|
11
|
+
q: Array<[string, any[]]> | null;
|
|
12
|
+
v: number;
|
|
13
|
+
_r: Array<() => void>;
|
|
14
|
+
_t: number;
|
|
15
|
+
_unpaint?: () => void;
|
|
16
|
+
[method: string]: any;
|
|
17
|
+
}
|
|
18
|
+
export declare function createLoader(initial: LoaderOptions): AsklyStub;
|
|
19
|
+
/**
|
|
20
|
+
* Where the loader's script came from, as the place to fetch the app from. A floating CDN
|
|
21
|
+
* tag (`@3`, `@latest`, none) is pinned to this exact version so the app and its chunks
|
|
22
|
+
* always come from one immutable path.
|
|
23
|
+
*/
|
|
24
|
+
export declare function appUrlFromScript(src: string | null | undefined, version: string, fallback: string): string;
|
|
25
|
+
/** The <script> that loaded this file: `document.currentScript`, else the tag that names it. */
|
|
26
|
+
export declare function findLoaderScript(): HTMLScriptElement | null;
|
|
@@ -4,9 +4,13 @@ export interface GreetingBubbleProps {
|
|
|
4
4
|
accentVars: React.CSSProperties;
|
|
5
5
|
aiAnswering: boolean;
|
|
6
6
|
aiAvatarUrl: string | null;
|
|
7
|
+
/** Text direction of the current locale, set on the root. */
|
|
8
|
+
dir: "ltr" | "rtl";
|
|
7
9
|
dismissGreeting: () => void;
|
|
8
10
|
faqs: Faq[];
|
|
9
11
|
greetingText: string;
|
|
12
|
+
/** Language tag of the current locale, for screen readers' pronunciation. */
|
|
13
|
+
lang: string;
|
|
10
14
|
openFromGreeting: (question?: string) => void;
|
|
11
15
|
organizationLogo: string | undefined;
|
|
12
16
|
position: "left" | "right";
|
|
@@ -6,11 +6,16 @@ export interface LauncherProps {
|
|
|
6
6
|
buttonIcon: string;
|
|
7
7
|
buttonShape: "round" | "square";
|
|
8
8
|
buttonStyle: React.CSSProperties;
|
|
9
|
+
/** Text direction of the current locale, set on the root so the badge and glyph follow it. */
|
|
10
|
+
dir: "ltr" | "rtl";
|
|
11
|
+
/** Language tag of the current locale, for screen readers' pronunciation. */
|
|
12
|
+
lang: string;
|
|
9
13
|
launcherUnread: number;
|
|
10
14
|
resolvedTheme: string;
|
|
11
15
|
setActiveChatId: (chatId: string | null) => void;
|
|
12
16
|
setActiveTab: (tab: WidgetTab) => void;
|
|
13
17
|
unreadChatId: string | undefined;
|
|
18
|
+
launcherRef?: React.RefObject<HTMLButtonElement>;
|
|
14
19
|
}
|
|
15
20
|
/** The floating button that opens and closes the panel, with the unread badge. */
|
|
16
21
|
export declare function Launcher(props: LauncherProps): React.JSX.Element;
|
|
@@ -7,6 +7,11 @@ export interface MessageListProps {
|
|
|
7
7
|
setCopiedMsgIndex: React.Dispatch<React.SetStateAction<number | null>>;
|
|
8
8
|
setMsgReactions: React.Dispatch<React.SetStateAction<Record<number, "up" | "down">>>;
|
|
9
9
|
showTimestamp: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Bumped by the widget whenever the locale or the host's text overrides change. The list is
|
|
12
|
+
* memoised on its props, so without this a text change would leave stale labels on screen.
|
|
13
|
+
*/
|
|
14
|
+
textsVersion: number;
|
|
10
15
|
}
|
|
11
16
|
/** The messages of the chat on screen. */
|
|
12
17
|
declare function MessageListView(props: MessageListProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ChatWidgetProps } from "./core/types";
|
|
3
|
+
export declare const ChatWidget: ({ orgId, organizationName: initialOrganizationName, themeColor: initialThemeColor, theme: initialTheme, position, offset, hideLauncher, customLauncherSelector, orgServerRoute, enableVoiceChat: initialEnableVoiceChat, voiceInput: initialVoiceInput, welcomeMessage: initialWelcomeMessage, placeholderText, locale: localeProp, organizationLogo: initialOrganizationLogo, buttonIcon, buttonShape: initialButtonShape, autoOpen, greeting, showTimestamp, soundEnabled, soundVolume, poweredBy, userId, timestamp, signature, turnstileSiteKey, excludePaths, includePaths, configOverride, resetGeneration: initResetGeneration, greetingStartedAt, onMessageSent, onMessageReceived, onChatOpened, onChatClosed, onEscalation, }: ChatWidgetProps) => React.JSX.Element | null;
|