@smarter.sh/ui-chat 0.8.0 → 0.9.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 +328 -107
- package/dist/embed/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/embed/mermaid/abnfDiagram-VCTEODGH-1SbERmPs.js +89 -0
- package/dist/embed/mermaid/arc-VicTtbbz.js +82 -0
- package/dist/embed/mermaid/architecture-7GRP2DOG-D0nnNZ3B.js +2 -0
- package/dist/embed/mermaid/architectureDiagram-5GKGNRK7-CQABdiy9.js +4138 -0
- package/dist/embed/mermaid/array-CApNbSU9.js +6 -0
- package/dist/embed/mermaid/blockDiagram-I7D4REHJ-CtjOz0Jt.js +1911 -0
- package/dist/embed/mermaid/c4Diagram-7LVT6UL2-_qBudB6C.js +3010 -0
- package/dist/embed/mermaid/channel-BXMcYHk2.js +5 -0
- package/dist/embed/mermaid/chunk-2E4U76K2-CBll2dEU.js +346 -0
- package/dist/embed/mermaid/chunk-2Q5K7J3B-kzxEEeTu.js +15 -0
- package/dist/embed/mermaid/chunk-4HAMMTFA-Dhz0SVnN.js +4188 -0
- package/dist/embed/mermaid/chunk-5VM5RSS4-Cr17nBXp.js +5 -0
- package/dist/embed/mermaid/chunk-75Z2AOVW-BsWtLgfj.js +1330 -0
- package/dist/embed/mermaid/chunk-CLGD4ZFX-Bkjwlxy9.js +14 -0
- package/dist/embed/mermaid/chunk-DU6HZSFF-1zIarP1Q.js +3900 -0
- package/dist/embed/mermaid/chunk-F27PBJKO-CiOL12VY.js +61 -0
- package/dist/embed/mermaid/chunk-FOHPRMQF-DS9zEyR5.js +21447 -0
- package/dist/embed/mermaid/chunk-GMAD6QVW-Dc0gE_3Q.js +1804 -0
- package/dist/embed/mermaid/chunk-GVQU2GXP-CWFtOgtb.js +37 -0
- package/dist/embed/mermaid/chunk-IMKFNOWR-CLyTlLwx.js +2042 -0
- package/dist/embed/mermaid/chunk-JWPE2WC7-Ccb0QaC8.js +8 -0
- package/dist/embed/mermaid/chunk-L3NEJ4N5-DnkSrVO8.js +245 -0
- package/dist/embed/mermaid/chunk-LNGE3PJU-ByFTjlja.js +1517 -0
- package/dist/embed/mermaid/chunk-OSK3NFVY-B57tZZIG.js +672 -0
- package/dist/embed/mermaid/chunk-P2QGCYS3-BUVAOFF-.js +67 -0
- package/dist/embed/mermaid/chunk-POPQ4Y6H-BsUdeJ_J.js +26 -0
- package/dist/embed/mermaid/chunk-PWAF6VOD-Cb-w19aO.js +275 -0
- package/dist/embed/mermaid/chunk-SHT3W25Y-znBBpcIu.js +4183 -0
- package/dist/embed/mermaid/chunk-SVP7TREG-DrHUM-6R.js +490 -0
- package/dist/embed/mermaid/chunk-TICWLB2K-xlGqZZYJ.js +3357 -0
- package/dist/embed/mermaid/chunk-TLUHSLCS-COwDpXBa.js +59 -0
- package/dist/embed/mermaid/chunk-XXDRQBXY-pOp8MAr9.js +9 -0
- package/dist/embed/mermaid/chunk-Y2CYZVJY-i11wjrBe.js +12 -0
- package/dist/embed/mermaid/classDiagram-ZZMXUADV-C8BeuQnA.js +30 -0
- package/dist/embed/mermaid/classDiagram-v2-VYDZK3BY-B3jylZLr.js +30 -0
- package/dist/embed/mermaid/cose-bilkent-JH36ORCC-DFvJxZ7v.js +2240 -0
- package/dist/embed/mermaid/cynefin-OW5HDTMX-B6YJOAMM.js +2 -0
- package/dist/embed/mermaid/cynefinDiagram-5FMLGOSQ-CCm5IQBE.js +355 -0
- package/dist/embed/mermaid/cytoscape.esm-BstmGtAB.js +18047 -0
- package/dist/embed/mermaid/dagre-BwzzJJA_.js +1932 -0
- package/dist/embed/mermaid/dagre-GXQ25YYZ-B3d3iNF-.js +423 -0
- package/dist/embed/mermaid/defaultLocale-N-0uLSyg.js +198 -0
- package/dist/embed/mermaid/diagram-S7CK7UJ4-BeA5UJrt.js +293 -0
- package/dist/embed/mermaid/diagram-UQ7AKVKN-DK0uHb-2.js +214 -0
- package/dist/embed/mermaid/diagram-VSXAHHWV-D5JXip1B.js +432 -0
- package/dist/embed/mermaid/diagram-VX7I27RA-B1VysvG9.js +527 -0
- package/dist/embed/mermaid/diagram-Z3DM3KII-ZGUJaFq-.js +134 -0
- package/dist/embed/mermaid/dist-DRRwZ4Yi.js +59 -0
- package/dist/embed/mermaid/ebnfDiagram-PWID7BFC-BOahZhWx.js +100 -0
- package/dist/embed/mermaid/erDiagram-RLTQ6QDP-7cGpGRQo.js +1966 -0
- package/dist/embed/mermaid/eventmodeling-NTZA5JFV-C3kU50Cz.js +2 -0
- package/dist/embed/mermaid/flowDiagram-HODETNUW-D-eJN2AO.js +16 -0
- package/dist/embed/mermaid/ganttDiagram-EL5Y4UJY-s6Kx4KlU.js +3072 -0
- package/dist/embed/mermaid/gitGraph-4MIJSDKK-CqdlGRFk.js +2 -0
- package/dist/embed/mermaid/gitGraphDiagram-WWUBYQGX-Blwdy0b7.js +733 -0
- package/dist/embed/mermaid/graphlib-XW-Jr8pF.js +1267 -0
- package/dist/embed/mermaid/info-A6RAGUB7-2pwra5F3.js +2 -0
- package/dist/embed/mermaid/infoDiagram-27XIBGKW-CstzbQPb.js +20 -0
- package/dist/embed/mermaid/init-CsQUQz36.js +13 -0
- package/dist/embed/mermaid/ishikawaDiagram-5VMMS53U-C6y_w0kd.js +717 -0
- package/dist/embed/mermaid/journeyDiagram-3NMN7TZE-BHVux_z1.js +884 -0
- package/dist/embed/mermaid/kanban-definition-UXKFOSKX-Cgj-7IHi.js +976 -0
- package/dist/embed/mermaid/katex-DmPOayaq.js +21968 -0
- package/dist/embed/mermaid/line-brkWVSn0.js +34 -0
- package/dist/embed/mermaid/linear-CiZWLcTr.js +287 -0
- package/dist/embed/mermaid/mermaid-parser.core-BjLg_By9.js +632 -0
- package/dist/embed/mermaid/mermaid.js +1092 -0
- package/dist/embed/mermaid/mindmap-definition-YA3MSWOX-DRc-FzI_.js +1006 -0
- package/dist/embed/mermaid/ordinal-BubEveRk.js +65 -0
- package/dist/embed/mermaid/packet-AYTQ26CC-C3h9OoFk.js +2 -0
- package/dist/embed/mermaid/path-CnWkkRiY.js +84 -0
- package/dist/embed/mermaid/pegDiagram-XKGWAZYB-Cw-aYwaF.js +94 -0
- package/dist/embed/mermaid/pie-WAS4IAKB-CaECYpHT.js +2 -0
- package/dist/embed/mermaid/pieDiagram-E7YTZNPT-DoguGyzq.js +203 -0
- package/dist/embed/mermaid/quadrantDiagram-AXDQQJYC-Cu4dMFZL.js +2001 -0
- package/dist/embed/mermaid/radar-RG4KPBEZ-CoS7pnd_.js +2 -0
- package/dist/embed/mermaid/railroad-74A4TZTK-BjHa6MAk.js +2 -0
- package/dist/embed/mermaid/railroad-abnf-HS5TGJTU-Bm2YWqjG.js +2 -0
- package/dist/embed/mermaid/railroad-ebnf-LZEXJU2U-C7mPpgM3.js +2 -0
- package/dist/embed/mermaid/railroad-peg-WCYAUIDC-Cyp07M5x.js +2 -0
- package/dist/embed/mermaid/railroadDiagram-O6MQD6OU-DDX-9GRQ.js +76 -0
- package/dist/embed/mermaid/requirementDiagram-BXWQKSXE-z8PPo06M.js +2224 -0
- package/dist/embed/mermaid/rough.esm-DXYGHN3m.js +1361 -0
- package/dist/embed/mermaid/sankeyDiagram-P5KCCOFB-CeD0II3M.js +972 -0
- package/dist/embed/mermaid/sequenceDiagram-WJ2MYXX4-Cs-Wxyvw.js +4156 -0
- package/dist/embed/mermaid/sizeCapture-INFHLROL-DujrpAYz.js +46 -0
- package/dist/embed/mermaid/src-DbyMbLVK.js +2141 -0
- package/dist/embed/mermaid/stateDiagram-D77RDMKH-CqWtgHSc.js +220 -0
- package/dist/embed/mermaid/stateDiagram-v2-MP3YSRHH-CPideWIU.js +30 -0
- package/dist/embed/mermaid/swimlanes-42K2YHIH-MutR4uV4.js +4957 -0
- package/dist/embed/mermaid/swimlanesDiagram-VR7AAH4N-BC_o7pti.js +31 -0
- package/dist/embed/mermaid/timeline-definition-24CTP7MA-rZfNRFiT.js +1069 -0
- package/dist/embed/mermaid/treeView-Q6P3EWNA-C94eS7gV.js +2 -0
- package/dist/embed/mermaid/treemap-WGGIJYW6-DnrVJ1h3.js +2 -0
- package/dist/embed/mermaid/vennDiagram-4TSXK5OY-KwMHebDQ.js +1880 -0
- package/dist/embed/mermaid/wardley-WFR3VGLG-DRDACyIN.js +2 -0
- package/dist/embed/mermaid/wardleyDiagram-VM6X3IG4-C-Fm7GGB.js +645 -0
- package/dist/embed/mermaid/xychartDiagram-S5SC5T6Z-DZX43ay9.js +2210 -0
- package/dist/embed.js +903 -0
- package/dist/embed.js.map +1 -0
- package/dist/smarter-chat-library.es.js +2722 -2805
- package/dist/smarter-chat-library.es.js.map +1 -1
- package/dist/smarter-chat-library.umd.js +56 -56
- package/dist/smarter-chat-library.umd.js.map +1 -1
- package/dist/types/src/components/SmarterChat/Component.d.ts +1 -1
- package/dist/types/src/embed/EmbedApp.d.ts +10 -0
- package/dist/types/src/embed/assets.d.ts +7 -0
- package/dist/types/src/embed/autoMount.d.ts +18 -0
- package/dist/types/src/embed/css.d.ts +15 -0
- package/dist/types/src/embed/element.d.ts +19 -0
- package/dist/types/src/embed/index.d.ts +17 -0
- package/dist/types/src/embed/mermaid.d.ts +2 -0
- package/dist/types/src/embed/mermaidImport.d.ts +1 -0
- package/dist/types/src/embed/options.d.ts +69 -0
- package/dist/types/src/lib/cookie.d.ts +4 -3
- package/dist/types/src/lib/mermaidImport.d.ts +8 -0
- package/dist/types/src/types.d.ts +7 -0
- package/package.json +10 -4
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
import "@chatscope/chat-ui-kit-styles/dist/default/styles.min.css";
|
|
27
27
|
import type { SmarterChatProps } from "@/types";
|
|
28
28
|
import "@/components/SmarterChat/styles.css";
|
|
29
|
-
declare function SmarterChat({ apiUrl, apiKey, toggleMetadata, csrfCookieName, csrftoken, debugCookieName, debugCookieExpiration, debugMode, sessionCookieName, sessionCookieExpiration, showConsole, cookieDomain, smarterRequestId, logStreamUrl, streamProgress, }: SmarterChatProps): import("react").JSX.Element;
|
|
29
|
+
declare function SmarterChat({ apiUrl, apiKey, toggleMetadata, csrfCookieName, csrftoken, debugCookieName, debugCookieExpiration, debugMode, sessionCookieName, sessionCookieExpiration, cookiePath, showConsole, cookieDomain, smarterRequestId, logStreamUrl, streamProgress, }: SmarterChatProps): import("react").JSX.Element;
|
|
30
30
|
export default SmarterChat;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EmbedOptions } from "./options";
|
|
2
|
+
export declare const PANEL_ID = "smarter-chat-embed-panel";
|
|
3
|
+
export interface EmbedAppProps {
|
|
4
|
+
options: EmbedOptions;
|
|
5
|
+
/** Whether the launcher is open. The element owns this state, so that page scripts can open and close it. */
|
|
6
|
+
open: boolean;
|
|
7
|
+
onOpenChange: (open: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
declare function EmbedApp(props: EmbedAppProps): import("react").JSX.Element;
|
|
10
|
+
export default EmbedApp;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CDN_BASE_URL: string;
|
|
2
|
+
/** The url of the directory of a script, or of jsDelivr's copy of the package, if it has no url. */
|
|
3
|
+
export declare function scriptBaseUrl(script: Element | null | undefined): string;
|
|
4
|
+
/** Remembers the directory of the running script. Called once, by index.ts, when the script first runs. */
|
|
5
|
+
export declare function captureBaseUrl(script?: Element | null | undefined): string;
|
|
6
|
+
/** The url of one of the embed script's files, e.g. assetUrl("mermaid/mermaid.js"). */
|
|
7
|
+
export declare function assetUrl(path: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The attribute that marks the elements that the script added, with their chatbot's url. */
|
|
2
|
+
export declare const AUTO_ATTRIBUTE = "data-smarter-chat-auto";
|
|
3
|
+
export type EmbedConfig = Record<string, unknown>;
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
SmarterChatConfig?: EmbedConfig | EmbedConfig[];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** The configurations of the script tag's data- attributes and of window.SmarterChatConfig, as attributes. */
|
|
10
|
+
export declare function configurations(script: Element | null | undefined, globalConfig: EmbedConfig | EmbedConfig[] | null | undefined): Record<string, string>[];
|
|
11
|
+
/**
|
|
12
|
+
* Adds a <smarter-chat> element for a configuration, unless the page has one for its chatbot already.
|
|
13
|
+
*
|
|
14
|
+
* @returns The new element, or null if none was added.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mountChat(attributes: Record<string, string>, doc?: Document): HTMLElement | null;
|
|
17
|
+
/** Adds the configurations' elements once the page's body exists. */
|
|
18
|
+
export declare function autoMount(script: Element | null | undefined, globalConfig: EmbedConfig | EmbedConfig[] | null | undefined, doc?: Document): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const ASSETS_PLACEHOLDER = "__SMARTER_CHAT_ASSETS__/";
|
|
2
|
+
export declare const FONT_STYLE_ID = "smarter-chat-embed-fonts";
|
|
3
|
+
/** Adds css to the embed's stylesheet. Called by the modules that the embed build generates for css imports. */
|
|
4
|
+
export declare function addCss(css: string): void;
|
|
5
|
+
/** The embed's css, with the urls of its own files. */
|
|
6
|
+
export declare function embedCss(): string;
|
|
7
|
+
/** The @font-face rules of a stylesheet. */
|
|
8
|
+
export declare function fontFaceRules(css: string): string[];
|
|
9
|
+
/** Adds the @font-face rules of the css to the document's head, once. */
|
|
10
|
+
export declare function hoistFontFaces(css: string, doc?: Document): void;
|
|
11
|
+
/**
|
|
12
|
+
* Applies the css to a shadow root: as a constructable stylesheet, shared by every chat on the page, where the
|
|
13
|
+
* browser supports them, or else as a style element.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyCss(root: ShadowRoot, css: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EmbedOptionsResult } from "./options";
|
|
2
|
+
export declare const ELEMENT_NAME = "smarter-chat";
|
|
3
|
+
export declare const TOGGLE_EVENT = "smarter-chat-toggle";
|
|
4
|
+
export declare class SmarterChatElement extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
static observedAttributes: ("chatbot" | "color" | "label" | "open" | "debug" | "width" | "height" | "position" | "api-key" | "mode" | "z-index" | "session-cookie-name" | "cookie-path" | "stream-progress")[];
|
|
7
|
+
/** The element's options, from its attributes. */
|
|
8
|
+
get options(): EmbedOptionsResult;
|
|
9
|
+
/** Whether the launcher is open. */
|
|
10
|
+
get isOpen(): boolean;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
attributeChangedCallback(): void;
|
|
14
|
+
open(): void;
|
|
15
|
+
close(): void;
|
|
16
|
+
toggle(): void;
|
|
17
|
+
}
|
|
18
|
+
/** Defines <smarter-chat>, unless the page already has, e.g. with another copy of the embed script. */
|
|
19
|
+
export declare function defineElement(registry?: CustomElementRegistry): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type EmbedConfig } from "./autoMount";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
/** The api of window.SmarterChat. */
|
|
4
|
+
export interface SmarterChatEmbedApi {
|
|
5
|
+
version: string;
|
|
6
|
+
/** Opens the launchers, or the launcher of one chatbot, by its url. */
|
|
7
|
+
open: (chatbot?: string) => void;
|
|
8
|
+
close: (chatbot?: string) => void;
|
|
9
|
+
toggle: (chatbot?: string) => void;
|
|
10
|
+
/** Adds a chat to the page, as window.SmarterChatConfig does. */
|
|
11
|
+
mount: (config: EmbedConfig) => HTMLElement | null;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface Window {
|
|
15
|
+
SmarterChat?: SmarterChatEmbedApi;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const importMermaid: () => Promise<typeof import("mermaid")>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type EmbedMode = "launcher" | "inline";
|
|
2
|
+
export type EmbedPosition = "bottom-right" | "bottom-left";
|
|
3
|
+
export interface EmbedOptions {
|
|
4
|
+
/** The url of the deployed LLMClient, e.g. https://support.3141-5926-5359.api.example.com/ */
|
|
5
|
+
chatbot: string;
|
|
6
|
+
/** A Smarter api key, for LLMClients that require one. It is public, as is everything in a web page. */
|
|
7
|
+
apiKey: string | null;
|
|
8
|
+
/** "launcher": a button in a corner of the page that opens the chat. "inline": the chat, in the page. */
|
|
9
|
+
mode: EmbedMode;
|
|
10
|
+
/** The launcher's corner. */
|
|
11
|
+
position: EmbedPosition;
|
|
12
|
+
/** Whether the launcher starts open. */
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** The launcher's accessible name, and the chat panel's. */
|
|
15
|
+
label: string;
|
|
16
|
+
/** The launcher button's background color. */
|
|
17
|
+
color: string;
|
|
18
|
+
/** The width of the inline chat, or of the launcher's panel. */
|
|
19
|
+
width: string;
|
|
20
|
+
/** The height of the inline chat, or of the launcher's panel. */
|
|
21
|
+
height: string;
|
|
22
|
+
/** The launcher's z-index. */
|
|
23
|
+
zIndex: number;
|
|
24
|
+
/** The cookie in which the chat saves its session's key. */
|
|
25
|
+
sessionCookieName: string;
|
|
26
|
+
/** The path of the chat's cookies. "/" keeps one chat session across the website. */
|
|
27
|
+
cookiePath: string;
|
|
28
|
+
/** Display a running prompt's progress. */
|
|
29
|
+
streamProgress: boolean;
|
|
30
|
+
/** Log to the browser console. */
|
|
31
|
+
debug: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** The result of reading the options: the options, or why they can't be used. */
|
|
34
|
+
export type EmbedOptionsResult = {
|
|
35
|
+
options: EmbedOptions;
|
|
36
|
+
error: null;
|
|
37
|
+
} | {
|
|
38
|
+
options: null;
|
|
39
|
+
error: string;
|
|
40
|
+
};
|
|
41
|
+
/** The attributes that a <smarter-chat> element reads, in kebab-case. */
|
|
42
|
+
export declare const OPTION_ATTRIBUTES: readonly ["chatbot", "api-key", "mode", "position", "open", "label", "color", "width", "height", "z-index", "session-cookie-name", "cookie-path", "stream-progress", "debug"];
|
|
43
|
+
export declare const DEFAULT_LABEL = "Chat";
|
|
44
|
+
export declare const DEFAULT_COLOR = "#ff5733";
|
|
45
|
+
export declare const DEFAULT_Z_INDEX = 2147483000;
|
|
46
|
+
/** A boolean attribute: present and empty, or "true", is true. "false" is false. Missing is the default. */
|
|
47
|
+
export declare function booleanOption(value: string | null | undefined, defaultValue: boolean): boolean;
|
|
48
|
+
/** The url, if it is an http(s) url, normalized to end with a slash, else null. */
|
|
49
|
+
export declare function chatbotUrl(value: string | null | undefined): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* The default session cookie of a chatbot: one per chatbot host, so that two chatbots on one website keep separate
|
|
52
|
+
* chat sessions, e.g. smarter_chat_support_3141_5926_5359_api_example_com.
|
|
53
|
+
*/
|
|
54
|
+
export declare function defaultSessionCookieName(chatbot: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* The options of a <smarter-chat> element.
|
|
57
|
+
*
|
|
58
|
+
* @param get Returns the value of an attribute, by its kebab-case name, or null if it is missing.
|
|
59
|
+
* @param defaultMode The mode, if the attributes don't say: "inline" for an element in the page, and "launcher"
|
|
60
|
+
* for the element that the script tag adds.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseOptions(get: (name: (typeof OPTION_ATTRIBUTES)[number]) => string | null, defaultMode?: EmbedMode): EmbedOptionsResult;
|
|
63
|
+
/** A camelCase name in kebab-case, e.g. apiKey to api-key. */
|
|
64
|
+
export declare function kebabCase(name: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* The attributes of a configuration object, e.g. window.SmarterChatConfig's, or a script tag's dataset: kebab-case
|
|
67
|
+
* names, and string values. Values that are null, undefined, objects or functions are left out.
|
|
68
|
+
*/
|
|
69
|
+
export declare function configAttributes(config: Record<string, unknown>): Record<string, string>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cookie management for Smarter Chat: the Django CSRF cookie, which it reads, and the chat
|
|
3
3
|
* session and debug cookies, which it sets for the page's path, so that each LLMClient's
|
|
4
|
-
* workbench has its own chat session.
|
|
4
|
+
* workbench has its own chat session, or for the path that the cookie names, e.g. "/" for a chat
|
|
5
|
+
* that follows the visitor across a website.
|
|
5
6
|
*/
|
|
6
7
|
import type { CookieMeta } from "../types";
|
|
7
8
|
/**
|
|
@@ -12,6 +13,6 @@ import type { CookieMeta } from "../types";
|
|
|
12
13
|
export declare function inCookieDomain(hostname: string, domain: string | null | undefined): boolean;
|
|
13
14
|
/** The cookie's value: its preset value, else the browser's cookie, else defaultValue. */
|
|
14
15
|
export declare function getCookie(cookie: CookieMeta, defaultValue?: string | null): string | null;
|
|
15
|
-
/** Sets the cookie for the page's
|
|
16
|
+
/** Sets the cookie for its path (by default, the page's), or deletes it when value is empty. */
|
|
16
17
|
export declare function setCookie(cookie: CookieMeta, value: string | boolean | null | undefined): void;
|
|
17
|
-
export declare function cookieMetaFactory(name: string, expiration: number | null, domain: string | undefined, value?: string | null): CookieMeta;
|
|
18
|
+
export declare function cookieMetaFactory(name: string, expiration: number | null, domain: string | undefined, value?: string | null, path?: string | null): CookieMeta;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imports mermaid, which lib/mermaid.ts does the first time that a message has a diagram.
|
|
3
|
+
*
|
|
4
|
+
* In the npm package and the web console, the page's bundler splits mermaid into chunks, which are downloaded only
|
|
5
|
+
* then. The embed script, a single classic script, can't be split that way, so its build replaces this module with
|
|
6
|
+
* src/embed/mermaidImport.ts, which imports a separate build of mermaid from beside the script. See vite.config.ts.
|
|
7
|
+
*/
|
|
8
|
+
export declare const importMermaid: () => Promise<typeof import("mermaid")>;
|
|
@@ -54,6 +54,8 @@ export interface CookieMeta {
|
|
|
54
54
|
domain: string;
|
|
55
55
|
/** A value to use instead of the cookie's. */
|
|
56
56
|
value: string | null;
|
|
57
|
+
/** The path that Smarter Chat sets the cookie for. Empty or missing means the page's path. */
|
|
58
|
+
path?: string | null;
|
|
57
59
|
}
|
|
58
60
|
export interface ChatCookies {
|
|
59
61
|
csrfCookie: CookieMeta;
|
|
@@ -87,6 +89,11 @@ export interface SmarterChatProps {
|
|
|
87
89
|
/** The name of the cookie in which Smarter Chat saves the chat session's key. */
|
|
88
90
|
sessionCookieName?: string;
|
|
89
91
|
sessionCookieExpiration?: number;
|
|
92
|
+
/**
|
|
93
|
+
* The path of the session and debug cookies. By default, the page's path, so that each page has its own chat
|
|
94
|
+
* session. "/" keeps one chat session as the visitor moves from page to page of a website.
|
|
95
|
+
*/
|
|
96
|
+
cookiePath?: string | null;
|
|
90
97
|
/** @deprecated Not used. Django's session cookie is sent with each request, as is. */
|
|
91
98
|
authSessionCookieName?: string;
|
|
92
99
|
/** Show the Console, which displays the chat's configuration and history. */
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smarter.sh/ui-chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "chatbot React.js component for the https://smarter.sh declarative, plugin-based AI resource management platform.",
|
|
5
5
|
"homepage": "https://smarter.sh",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/smarter-chat-library.umd.js",
|
|
8
8
|
"module": "./dist/smarter-chat-library.es.js",
|
|
9
9
|
"types": "./dist/types/src/index.d.ts",
|
|
10
|
+
"jsdelivr": "./dist/embed.js",
|
|
11
|
+
"unpkg": "./dist/embed.js",
|
|
10
12
|
"exports": {
|
|
11
13
|
".": {
|
|
12
14
|
"types": "./dist/types/src/index.d.ts",
|
|
@@ -14,7 +16,9 @@
|
|
|
14
16
|
"require": "./dist/smarter-chat-library.umd.js"
|
|
15
17
|
},
|
|
16
18
|
"./dist/ui-chat.css": "./dist/ui-chat.css",
|
|
17
|
-
"./style.css": "./dist/ui-chat.css"
|
|
19
|
+
"./style.css": "./dist/ui-chat.css",
|
|
20
|
+
"./embed": "./dist/embed.js",
|
|
21
|
+
"./dist/embed.js": "./dist/embed.js"
|
|
18
22
|
},
|
|
19
23
|
"files": [
|
|
20
24
|
"dist"
|
|
@@ -61,10 +65,12 @@
|
|
|
61
65
|
"typecheck": "tsc -b",
|
|
62
66
|
"test": "vitest run",
|
|
63
67
|
"test:watch": "vitest",
|
|
64
|
-
"prepublishOnly": "npm run build:lib",
|
|
68
|
+
"prepublishOnly": "npm run build:lib && npm run build:embed",
|
|
65
69
|
"coverage": "vitest run --coverage --config vitest.coverage.config.ts",
|
|
66
70
|
"format": "prettier --write .",
|
|
67
|
-
"format:check": "prettier --check ."
|
|
71
|
+
"format:check": "prettier --check .",
|
|
72
|
+
"build:embed": "vite build --mode embed && vite build --mode embed-mermaid",
|
|
73
|
+
"check:dist": "node scripts/check-dist.mjs"
|
|
68
74
|
},
|
|
69
75
|
"dependencies": {
|
|
70
76
|
"@chatscope/chat-ui-kit-react": "^2.1.1",
|