Skip to content

Commit b105ee8

Browse files
authored
Merge pull request #221 from GleapSDK/types/missing-declarations
fix(types): declare the SDK methods the docs use
2 parents a66df38 + 1584c3e commit b105ee8

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎index.d.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export namespace Gleap {
8787
function hideAiChatbar(): void;
8888
function askAI(question: string, showBackButton?: boolean): void;
8989
function setAiChatbarQuickActions(quickActions: string[]): void;
90+
function setAiChatbarPlaceholder(placeholder: string): void;
9091
function startAgent(
9192
agentId: string,
9293
options?: { context?: any; initialQuestion?: string; initialMessage?: string }
@@ -308,6 +309,8 @@ export namespace Gleap {
308309
function openChecklists(showBackButton?: boolean): void;
309310
function openChecklist(checklistId: string, showBackButton?: boolean): void;
310311
function startChecklist(outboundId: string, showBackButton?: boolean, sharedKey?: string): void;
312+
/** The full data of a checklist; listen to the `checklist-*` events with `Gleap.on` for updates. */
313+
function getChecklistData(outboundId: string, sharedKey?: string): Promise<any>;
311314
function openNews(showBackButton?: boolean): void;
312315
function openNewsArticle(id: string, showBackButton?: boolean): void;
313316
function openConversations(showBackButton?: boolean): void;
@@ -330,13 +333,16 @@ export namespace Gleap {
330333
): void;
331334
function searchHelpCenter(term: string, showBackButton?: boolean): void;
332335
function openFeatureRequests(showBackButton?: boolean): void;
333-
function close(): void;
336+
/** Close the widget. With `resetRoutes`, the messenger also goes back to its start screen. */
337+
function close(resetRoutes?: boolean): void;
334338
function hide(): void;
335339
function setUseCookies(useCookies: boolean): void;
340+
/** Treat the site as not reachable from the internet, like localhost: screenshots embed its CSS and images instead of loading them from the site later. */
341+
function setOfflineMode(offlineMode: boolean): void;
336342
/**
337-
* Sets the widget's color scheme, overriding the dashboard's "Color scheme"
338-
* setting, which applies until this is called. Only takes effect when "Adapt
339-
* to dark / light mode" is enabled in the dashboard; while it is disabled the
343+
* Sets the widget's color scheme, overriding the dashboard's setting, which
344+
* applies until this is called. Only takes effect when "Match light and dark
345+
* mode" is on (Settings → Widget → Look); while it is off the
340346
* widget is never themed. "auto" follows the host app's dark/light mode (theme
341347
* classes/attributes like `class="dark"` or `data-theme="dark"`, the CSS
342348
* color-scheme, the page background, then the OS preference) and switches
@@ -506,11 +512,15 @@ export namespace Gleap {
506512
onError?: (error: any) => void;
507513
/** Called when a new conversation is created. */
508514
onConversationCreated?: (conversationId: string) => void;
515+
/** Called for every streamed piece of the reply; `content` is the new text. */
516+
onToken?: (data: { content?: string; [key: string]: any }) => void;
509517
}
510518

511519
interface AgentChatInstance {
512520
/** Send a message to the agent. */
513521
sendMessage(content: string): Promise<void>;
522+
/** Stop the reply that is streaming; the text received so far stays. */
523+
cancelStream(): void;
514524
/** Clear all messages and start a new conversation. */
515525
clearMessages(): void;
516526
/** Update the context sent with future messages. */

‎src/Gleap.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -972,10 +972,10 @@ class Gleap {
972972
}
973973

974974
/**
975-
* Sets the widget's color scheme, overriding the "Color scheme" setting in the dashboard.
975+
* Sets the widget's color scheme, overriding the dashboard's setting.
976976
* Until this is called, the dashboard setting applies.
977-
* Only takes effect when "Adapt to dark / light mode" is enabled in the dashboard;
978-
* while it is disabled the widget is never themed, whatever is set here.
977+
* Only takes effect when "Match light and dark mode" is on (Settings → Widget → Look);
978+
* while it is off the widget is never themed, whatever is set here.
979979
* - 'auto': follows the host app's dark/light mode (theme classes/attributes such as
980980
* `class="dark"` or `data-theme="dark"`, the CSS color-scheme, the page background,
981981
* then the OS preference) and switches live when it changes.

0 commit comments

Comments
 (0)