@hachther/akilio-widget 0.5.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 +301 -0
- package/dist/AkilioWidget.d.ts +4 -0
- package/dist/akilio-widget.css +1 -0
- package/dist/akilio-widget.min.js +45 -0
- package/dist/components/BrandLogo.d.ts +6 -0
- package/dist/components/ChatPanel.d.ts +28 -0
- package/dist/components/Icons.d.ts +9 -0
- package/dist/components/Launcher.d.ts +4 -0
- package/dist/components/MarkdownAnswer.d.ts +3 -0
- package/dist/components/MessageBubble.d.ts +12 -0
- package/dist/components/ProductCards.d.ts +10 -0
- package/dist/driver.js-CVJgNCO-.js +534 -0
- package/dist/hooks/responsive.d.ts +2 -0
- package/dist/hooks/storage.d.ts +18 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.min.js +26479 -0
- package/dist/index.umd.min.cjs +37 -0
- package/dist/lib/client.d.ts +42 -0
- package/dist/lib/copy.d.ts +9 -0
- package/dist/logos/AkilioMark.d.ts +7 -0
- package/dist/logos/AkilioWordmark.d.ts +8 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +289 -0
- package/dist/vanilla.d.ts +30 -0
- package/package.json +70 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AkilioAuthConfig, AkilioChatRequest, AkilioChatResponse, AkilioCommerceEvent, AkilioConversationResponse, AkilioFeedbackRating, AkilioProjectConfig } from '../types';
|
|
2
|
+
export interface AkilioClientOptions {
|
|
3
|
+
apiBaseUrl: string;
|
|
4
|
+
auth?: AkilioAuthConfig;
|
|
5
|
+
fetchImpl?: typeof fetch;
|
|
6
|
+
}
|
|
7
|
+
export declare class AkilioClient {
|
|
8
|
+
private apiBaseUrl;
|
|
9
|
+
private fetchImpl;
|
|
10
|
+
private auth?;
|
|
11
|
+
private widgetToken;
|
|
12
|
+
private widgetTokenPromise;
|
|
13
|
+
private widgetTokenPromiseKey;
|
|
14
|
+
constructor(options: AkilioClientOptions);
|
|
15
|
+
private hasHostManagedToken;
|
|
16
|
+
private hostManagedToken;
|
|
17
|
+
private tokenIsUsable;
|
|
18
|
+
private clearWidgetToken;
|
|
19
|
+
private issueWidgetToken;
|
|
20
|
+
private ensureWidgetToken;
|
|
21
|
+
private baseHeaders;
|
|
22
|
+
private execute;
|
|
23
|
+
private publicRequest;
|
|
24
|
+
private authenticatedRequest;
|
|
25
|
+
getProjectConfig(projectKey: string): Promise<AkilioProjectConfig>;
|
|
26
|
+
prepareWidgetToken(projectKey: string, subject?: string): Promise<void>;
|
|
27
|
+
sendMessage(projectKey: string, subject: string | undefined, request: AkilioChatRequest): Promise<AkilioChatResponse>;
|
|
28
|
+
getConversation(projectKey: string, subject: string | undefined, conversationId: string): Promise<AkilioConversationResponse>;
|
|
29
|
+
deleteConversation(projectKey: string, subject: string | undefined, conversationId: string): Promise<void>;
|
|
30
|
+
sendCommerceEvent(projectKey: string, subject: string | undefined, event: AkilioCommerceEvent): Promise<void>;
|
|
31
|
+
sendFeedback(params: {
|
|
32
|
+
projectKey: string;
|
|
33
|
+
subject?: string;
|
|
34
|
+
messageId: string;
|
|
35
|
+
rating: AkilioFeedbackRating;
|
|
36
|
+
comment?: string;
|
|
37
|
+
metadata?: Record<string, unknown>;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
ok: boolean;
|
|
40
|
+
feedback_id: string;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AkilioCopyOverrides, AkilioProjectConfig } from '../types';
|
|
2
|
+
export interface AkilioResolvedCopy extends Required<Omit<AkilioCopyOverrides, never>> {
|
|
3
|
+
suggestions: string[];
|
|
4
|
+
}
|
|
5
|
+
export declare function resolveCopy(params: {
|
|
6
|
+
locale?: string;
|
|
7
|
+
projectConfig?: AkilioProjectConfig | null;
|
|
8
|
+
overrides?: AkilioCopyOverrides;
|
|
9
|
+
}): AkilioResolvedCopy;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface AkilioWordmarkProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
primaryColor?: string;
|
|
5
|
+
secondaryColor?: string;
|
|
6
|
+
}
|
|
7
|
+
declare function AkilioWordmark({ className, primaryColor, secondaryColor }: AkilioWordmarkProps): React.JSX.Element;
|
|
8
|
+
export default AkilioWordmark;
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.driver-popover{all:unset;font-family:var(--driver-popover-font-family,"Helvetica Neue", Inter, ui-sans-serif, "Apple Color Emoji", Helvetica, Arial, sans-serif);box-sizing:border-box;color:#2d2d2d;z-index:1000000000;background-color:#fff;border-radius:5px;min-width:250px;max-width:300px;margin:0;padding:15px;position:fixed;top:0;right:0;box-shadow:0 1px 10px #0006}.driver-popover-title{zoom:1;margin:0;font-size:19px;font-weight:700;line-height:1.5;display:block;position:relative}.driver-popover-close-btn{all:unset;cursor:pointer;color:#d2d2d2;z-index:1;text-align:center;width:32px;height:28px;font-size:18px;font-weight:500;transition:color .2s;position:absolute;top:0;right:0}.driver-popover-close-btn:hover,.driver-popover-close-btn:focus{color:#2d2d2d}.driver-popover-title[style*=block]+.driver-popover-description{margin-top:5px}.driver-popover-description{zoom:1;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.5}.driver-popover-footer{text-align:right;zoom:1;justify-content:space-between;align-items:center;margin-top:15px;display:flex}.driver-popover-progress-text{color:#727272;zoom:1;font-size:13px;font-weight:400}.driver-popover-footer-btn{all:unset;box-sizing:border-box;color:#2d2d2d;cursor:pointer;zoom:1;background-color:#fff;border:1px solid #ccc;border-radius:3px;outline:0;padding:3px 7px;font-size:12px;line-height:1.3;text-decoration:none;display:inline-block}.driver-popover-footer .driver-popover-btn-disabled{opacity:.5;pointer-events:none}.driver-popover-footer-btn:hover,.driver-popover-footer-btn:focus{background-color:#f7f7f7}.driver-popover-navigation-btns{flex-grow:1;justify-content:flex-end;display:flex}.driver-popover-navigation-btns button+button{margin-left:4px}.driver-popover-arrow{content:"";border:5px solid #fff;position:absolute}.driver-popover-arrow-side-over{display:none}.driver-popover-arrow-side-left{border-top-color:#0000;border-bottom-color:#0000;border-right-color:#0000;left:100%}.driver-popover-arrow-side-right{border-top-color:#0000;border-bottom-color:#0000;border-left-color:#0000;right:100%}.driver-popover-arrow-side-top{border-bottom-color:#0000;border-left-color:#0000;border-right-color:#0000;top:100%}.driver-popover-arrow-side-bottom{border-top-color:#0000;border-left-color:#0000;border-right-color:#0000;bottom:100%}.driver-popover-arrow-side-center,.driver-popover-arrow-none{display:none}.driver-active .driver-overlay{pointer-events:none}.driver-active.driver-no-scroll{overflow:hidden}.driver-active *{pointer-events:none}.driver-active .driver-active-element,.driver-active .driver-active-element *,.driver-popover,.driver-popover *{pointer-events:auto}@keyframes animate-fade-in{0%{opacity:0}to{opacity:1}}.driver-fade .driver-overlay{animation:animate-fade-in var(--driver-animation-duration,.4s) ease-in-out}.driver-fade .driver-popover{animation:animate-fade-in var(--driver-animation-duration,.4s)}.driver-active-element-parent-no-scroll{overflow:hidden!important}.driver-no-interaction,.driver-no-interaction *{pointer-events:none!important}:root{--akilio-primary: #0891b2;--akilio-primary-foreground: #ffffff;--akilio-accent: #2563eb;--akilio-radius: 22px;--akilio-panel-width: 440px;--akilio-z-index: 2147483000}@media(min-width:1280px){html.akilio-panel-open body{padding-right:var(--akilio-panel-width);transition:padding-right .26s ease}html.akilio-panel-open #akilio-launcher{transform:translate(calc(-1 * var(--akilio-panel-width)))}}.akilio-root,.akilio-root *{box-sizing:border-box}.akilio-root{color:#18181b;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.akilio-launcher{position:fixed;right:22px;bottom:22px;z-index:calc(var(--akilio-z-index) - 10);display:inline-flex;align-items:center;gap:10px;border:1px solid rgba(255,255,255,.22);border-radius:999px;background:linear-gradient(135deg,#09090b,#27272a);color:#fff;padding:11px 16px 11px 12px;cursor:pointer;box-shadow:0 24px 60px #18181b40,0 0 0 1px #09090b14;transition:transform .26s ease,box-shadow .18s ease,background .18s ease}.akilio-launcher:hover{transform:translateY(-2px);box-shadow:0 28px 70px #0891b240,0 0 0 1px #09090b14}.akilio-launcher span{display:grid;width:30px;height:30px;place-items:center;overflow:hidden;border-radius:999px;background:#fff}.akilio-launcher-logo{display:block;width:22px;height:22px;object-fit:contain}.akilio-launcher strong{font-size:14px;font-weight:750;letter-spacing:-.01em}.akilio-overlay{position:fixed;inset:0;z-index:calc(var(--akilio-z-index) - 2);border:0;background:#09090b75;-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);cursor:default}.akilio-panel{position:fixed;top:0;right:0;z-index:var(--akilio-z-index);display:flex;width:min(100vw,var(--akilio-panel-width));height:100dvh;transform:translate(103%);flex-direction:column;overflow:hidden;border-left:1px solid rgba(212,212,216,.9);background:#f8fafc;box-shadow:-30px 0 90px #0f172a3d;transition:transform .26s cubic-bezier(.2,.8,.2,1)}.akilio-panel--open{transform:translate(0)}.akilio-root[data-akilio-mode=floating] .akilio-panel{top:auto;right:22px;bottom:88px;width:min(400px,calc(100vw - 32px));height:min(650px,calc(100dvh - 116px));min-height:420px;transform:translateY(18px) scale(.98);transform-origin:right bottom;border:1px solid rgba(212,212,216,.9);border-radius:var(--akilio-radius);box-shadow:0 28px 80px #0f172a3d;opacity:0;visibility:hidden;pointer-events:none;transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,visibility .18s ease}.akilio-root[data-akilio-mode=floating] .akilio-panel--open{transform:translateY(0) scale(1);opacity:1;visibility:visible;pointer-events:auto}.akilio-panel-glow{position:absolute;inset:0 0 auto;height:185px;pointer-events:none;background:radial-gradient(circle at 0% 0%,color-mix(in srgb,var(--akilio-primary) 35%,transparent),transparent 36%),radial-gradient(circle at 100% 0%,rgba(37,99,235,.22),transparent 34%)}.akilio-panel-header{position:relative;display:flex;align-items:flex-start;gap:12px;border-bottom:1px solid rgba(212,212,216,.82);background:#ffffffc7;padding:16px;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px)}.akilio-logo,.akilio-empty-icon{display:grid;flex-shrink:0;place-items:center}.akilio-logo{width:94px;height:34px}.akilio-logo img{display:block;width:100%;height:100%;object-fit:contain;object-position:left center}.akilio-empty-icon{width:64px;height:64px;border:1px solid rgba(124,58,237,.12);border-radius:calc(var(--akilio-radius) - 4px);background:#ffffffe0;box-shadow:0 18px 42px #6d28d929}.akilio-empty-icon img{display:block;width:42px;height:42px;object-fit:contain}.akilio-header-content{min-width:0;flex:1}.akilio-header-topline{display:flex;min-width:0;align-items:center;justify-content:space-between;gap:10px}.akilio-header-title{display:flex;min-width:0;align-items:center;gap:8px}.akilio-header-title h2{overflow:hidden;margin:0;color:#09090b;font-size:14px;font-weight:800;letter-spacing:-.015em;text-overflow:ellipsis;white-space:nowrap}.akilio-online{display:inline-flex;align-items:center;gap:5px;border-radius:999px;background:#10b9811f;color:#047857;padding:3px 8px;font-size:10px;font-weight:800;white-space:nowrap}.akilio-online i{width:6px;height:6px;border-radius:999px;background:#10b981}.akilio-header-description{display:-webkit-box;margin:6px 0 0;overflow:hidden;color:#71717a;font-size:12px;line-height:1.55;-webkit-box-orient:vertical;-webkit-line-clamp:3}.akilio-header-actions{display:flex;flex-shrink:0;align-items:center;gap:4px}.akilio-header-actions button{display:grid;width:36px;height:36px;place-items:center;border:0;border-radius:999px;background:transparent;color:#71717a;cursor:pointer;transition:background .16s ease,color .16s ease}.akilio-header-actions button:hover{background:#f4f4f5;color:#09090b}.akilio-header-actions svg{width:18px;height:18px}.akilio-thread{position:relative;display:flex;flex:1;flex-direction:column;gap:14px;overflow-y:auto;padding:18px 16px 22px}.akilio-message-row{display:flex;width:100%}.akilio-message-row--user{justify-content:flex-end}.akilio-message-row--assistant{justify-content:flex-start}.akilio-bubble{max-width:88%;overflow:hidden;border:1px solid rgba(212,212,216,.86);border-radius:26px 26px 26px 8px;background:#fffffff0;color:#27272a;padding:13px 15px;box-shadow:0 10px 28px #0f172a12}.akilio-bubble--user{border-color:#ffffff26;border-bottom-right-radius:8px;border-bottom-left-radius:26px;background:linear-gradient(135deg,#09090b,#27272a);color:#fff}.akilio-bubble--error{border-color:#f8717159;background:#fef2f2;color:#991b1b}.akilio-bubble-meta{display:flex;align-items:center;gap:7px;margin-bottom:8px;color:var(--akilio-primary);font-size:10px;font-weight:850;letter-spacing:.15em;text-transform:uppercase}.akilio-mini-icon{width:14px;height:14px}.akilio-confidence{margin-left:auto;border-radius:999px;background:color-mix(in srgb,var(--akilio-primary) 11%,transparent);padding:2px 7px;color:var(--akilio-primary);letter-spacing:0;text-transform:none}.akilio-answer{color:inherit;font-size:14px;line-height:1.7}.akilio-answer p{margin:.5rem 0}.akilio-answer p:first-child{margin-top:0}.akilio-answer p:last-child{margin-bottom:0}.akilio-answer ul,.akilio-answer ol{margin:.625rem 0 .625rem 1.25rem;padding-left:.75rem}.akilio-answer ul{list-style:disc}.akilio-answer ol{list-style:decimal}.akilio-answer li{margin:.25rem 0}.akilio-answer a{color:var(--akilio-primary);font-weight:700;text-decoration:underline;text-underline-offset:3px}.akilio-answer code{border-radius:7px;background:#0f172a14;padding:.12rem .35rem;font-size:.86em}.akilio-answer pre{margin:.75rem 0;overflow-x:auto;border:1px solid rgba(148,163,184,.2);border-radius:16px;background:#020617;padding:13px}.akilio-answer pre code{background:transparent;color:#e2e8f0;padding:0}.akilio-answer .hljs-keyword,.akilio-answer .hljs-selector-tag,.akilio-answer .hljs-built_in{color:#f0abfc}.akilio-answer .hljs-string,.akilio-answer .hljs-attr,.akilio-answer .hljs-symbol{color:#86efac}.akilio-answer .hljs-number,.akilio-answer .hljs-literal{color:#fcd34d}.akilio-answer .hljs-comment{color:#64748b;font-style:italic}.akilio-answer .hljs-title,.akilio-answer .hljs-function{color:#7dd3fc}.akilio-answer .hljs-variable{color:#fdba74}.akilio-answer--user{white-space:pre-wrap}.akilio-answer--user code{background:#ffffff29}.akilio-sources{margin-top:11px;overflow:hidden;border:1px solid rgba(212,212,216,.85);border-radius:16px;background:#f4f4f5c7}.akilio-sources summary{cursor:pointer;padding:9px 11px;color:#52525b;font-size:12px;font-weight:800}.akilio-sources-list{display:grid;gap:8px;border-top:1px solid rgba(212,212,216,.85);padding:8px}.akilio-source-card{display:grid;gap:3px;border:1px solid rgba(212,212,216,.82);border-radius:13px;background:#fff;padding:8px;font-size:12px}.akilio-source-card strong{color:#18181b}.akilio-source-card span{color:#71717a}.akilio-source-card a{overflow:hidden;color:var(--akilio-primary);text-overflow:ellipsis;white-space:nowrap}.akilio-feedback{display:flex;align-items:center;gap:7px;margin-top:11px;color:#71717a;font-size:11px}.akilio-feedback span{margin-right:auto}.akilio-feedback button{display:grid;width:28px;height:28px;place-items:center;border:1px solid rgba(212,212,216,.9);border-radius:999px;background:#fff;color:#71717a;cursor:pointer}.akilio-feedback button:hover,.akilio-feedback .akilio-feedback-active{border-color:color-mix(in srgb,var(--akilio-primary) 35%,#d4d4d8);color:var(--akilio-primary)}.akilio-feedback svg{width:14px;height:14px}.akilio-dots{display:flex;gap:6px;padding:2px 0}.akilio-dots span{width:8px;height:8px;border-radius:999px;background:var(--akilio-primary);animation:akilio-bounce .9s infinite ease-in-out}.akilio-dots span:nth-child(2){animation-delay:.1s}.akilio-dots span:nth-child(3){animation-delay:.2s}@keyframes akilio-bounce{0%,80%,to{transform:translateY(0);opacity:.45}40%{transform:translateY(-4px);opacity:1}}.akilio-empty{margin:auto;display:flex;max-width:340px;flex-direction:column;align-items:center;padding:34px 0;text-align:center}.akilio-empty-icon{width:58px;height:58px;margin-bottom:16px}.akilio-empty h3{margin:0;color:#09090b;font-size:17px;font-weight:850;letter-spacing:-.02em}.akilio-empty p{margin:8px 0 0;color:#71717a;font-size:14px;line-height:1.65}.akilio-suggestions{display:grid;width:100%;gap:9px;margin-top:18px}.akilio-suggestions button{border:1px solid rgba(212,212,216,.9);border-radius:16px;background:#fff;color:#3f3f46;cursor:pointer;padding:10px 12px;text-align:left;font-size:12px;font-weight:700;box-shadow:0 5px 14px #0f172a0a;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease}.akilio-suggestions button:hover{transform:translateY(-1px);border-color:color-mix(in srgb,var(--akilio-primary) 35%,#d4d4d8);box-shadow:0 12px 22px #0f172a14}.akilio-composer{position:relative;border-top:1px solid rgba(212,212,216,.85);background:#ffffffdb;padding:12px;-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px)}.akilio-composer-box{border:1px solid rgba(212,212,216,.95);border-radius:24px;background:#f8fafc;padding:8px;box-shadow:inset 0 1px 2px #0f172a0a;transition:border-color .15s ease,background .15s ease,box-shadow .15s ease}.akilio-composer-box:focus-within{border-color:color-mix(in srgb,var(--akilio-primary) 55%,#d4d4d8);background:#fff;box-shadow:0 0 0 4px color-mix(in srgb,var(--akilio-primary) 13%,transparent),inset 0 1px 2px #0f172a08}.akilio-composer textarea{width:100%;min-height:48px;max-height:148px;resize:none;border:0;outline:0;background:transparent;color:#09090b;padding:8px 10px;font:inherit;font-size:14px;line-height:1.55}.akilio-composer textarea::placeholder{color:#a1a1aa}.akilio-composer-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 2px 2px 7px}.akilio-composer-footer span{color:#71717a;font-size:11px}.akilio-composer-footer button{display:inline-flex;align-items:center;gap:8px;border:0;border-radius:999px;background:#09090b;color:#fff;cursor:pointer;padding:10px 15px;font-size:12px;font-weight:850;box-shadow:0 10px 24px #0f172a24;transition:transform .15s ease,opacity .15s ease}.akilio-composer-footer button:hover:not(:disabled){transform:translateY(-1px)}.akilio-composer-footer button:disabled{cursor:not-allowed;opacity:.45}.akilio-composer-footer svg{width:15px;height:15px}.akilio-tour{max-width:360px;border-radius:18px!important}@media(max-width:640px){.akilio-launcher{right:16px;bottom:16px;padding:10px 12px}.akilio-launcher strong{display:none}.akilio-panel{width:100vw}.akilio-bubble{max-width:94%}.akilio-composer-footer span{display:none}}.akilio-root[data-akilio-mode=inline]{width:100%;height:100%;min-height:520px}.akilio-panel--inline{position:relative;inset:auto;width:100%;height:100%;min-height:520px;transform:none;border:1px solid rgba(212,212,216,.9);border-radius:var(--akilio-radius);box-shadow:0 18px 50px #0f172a1f}.akilio-privacy{display:grid;gap:8px;border-top:1px solid rgba(212,212,216,.82);background:#ffffffe6;padding:10px 14px;font-size:11px;line-height:1.45}.akilio-privacy strong{color:#18181b}.akilio-privacy p{margin:2px 0 0;color:#71717a}.akilio-privacy a{color:var(--akilio-primary);font-weight:700}.akilio-privacy label{display:flex;align-items:flex-start;gap:8px;color:#3f3f46;cursor:pointer}.akilio-privacy input{margin-top:2px;accent-color:var(--akilio-primary)}.akilio-composer textarea:disabled{cursor:not-allowed;opacity:.65}.akilio-root button:focus-visible,.akilio-root a:focus-visible,.akilio-root input:focus-visible{outline:3px solid color-mix(in srgb,var(--akilio-primary) 45%,transparent);outline-offset:2px}.akilio-root .akilio-composer textarea:focus,.akilio-root .akilio-composer textarea:focus-visible{border:0;outline:none;box-shadow:none}@media(prefers-reduced-motion:reduce){.akilio-root *,.akilio-root *:before,.akilio-root *:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}.akilio-root[data-akilio-color-mode=dark]{color:#e4e4e7}.akilio-root[data-akilio-color-mode=dark] .akilio-panel,.akilio-root[data-akilio-color-mode=dark] .akilio-panel--inline{background:var(--akilio-surface, #09090b);border-color:#27272a}.akilio-root[data-akilio-color-mode=dark] .akilio-panel-header,.akilio-root[data-akilio-color-mode=dark] .akilio-privacy{background:#18181beb;border-color:#3f3f46}.akilio-root[data-akilio-color-mode=dark] .akilio-header-title h2,.akilio-root[data-akilio-color-mode=dark] .akilio-empty h3,.akilio-root[data-akilio-color-mode=dark] .akilio-privacy strong{color:var(--akilio-text, #fafafa)}.akilio-root[data-akilio-color-mode=dark] .akilio-header-description,.akilio-root[data-akilio-color-mode=dark] .akilio-empty p,.akilio-root[data-akilio-color-mode=dark] .akilio-privacy p,.akilio-root[data-akilio-color-mode=dark] .akilio-privacy label{color:var(--akilio-muted, #a1a1aa)}.akilio-root[data-akilio-color-mode=dark] .akilio-bubble{background:#18181b;border-color:#3f3f46;color:#e4e4e7;box-shadow:none}.akilio-root[data-akilio-color-mode=dark] .akilio-bubble--user{background:linear-gradient(135deg,var(--akilio-primary),var(--akilio-accent));color:var(--akilio-primary-foreground)}.akilio-root[data-akilio-color-mode=dark] .akilio-sources{background:#09090b;border-color:#3f3f46}.akilio-root[data-akilio-color-mode=dark] .akilio-sources-list{border-color:#3f3f46}.akilio-root[data-akilio-color-mode=dark] .akilio-source-card,.akilio-root[data-akilio-color-mode=dark] .akilio-feedback button,.akilio-root[data-akilio-color-mode=dark] .akilio-composer-box{background:#18181b;border-color:#3f3f46;color:#e4e4e7}.akilio-root[data-akilio-color-mode=dark] .akilio-source-card strong{color:#fafafa}.akilio-root[data-akilio-color-mode=dark] .akilio-source-card span,.akilio-root[data-akilio-color-mode=dark] .akilio-feedback{color:#a1a1aa}@media(prefers-color-scheme:dark){.akilio-root[data-akilio-color-mode=system] .akilio-panel,.akilio-root[data-akilio-color-mode=system] .akilio-panel--inline{background:#09090b;border-color:#27272a}.akilio-root[data-akilio-color-mode=system] .akilio-panel-header,.akilio-root[data-akilio-color-mode=system] .akilio-privacy{background:#18181beb;border-color:#3f3f46}.akilio-root[data-akilio-color-mode=system] .akilio-header-title h2,.akilio-root[data-akilio-color-mode=system] .akilio-empty h3,.akilio-root[data-akilio-color-mode=system] .akilio-privacy strong{color:#fafafa}.akilio-root[data-akilio-color-mode=system] .akilio-header-description,.akilio-root[data-akilio-color-mode=system] .akilio-empty p,.akilio-root[data-akilio-color-mode=system] .akilio-privacy p,.akilio-root[data-akilio-color-mode=system] .akilio-privacy label{color:#a1a1aa}.akilio-root[data-akilio-color-mode=system] .akilio-bubble{background:#18181b;border-color:#3f3f46;color:#e4e4e7;box-shadow:none}.akilio-root[data-akilio-color-mode=system] .akilio-bubble--user{background:linear-gradient(135deg,var(--akilio-primary),var(--akilio-accent));color:var(--akilio-primary-foreground)}.akilio-root[data-akilio-color-mode=system] .akilio-source-card,.akilio-root[data-akilio-color-mode=system] .akilio-feedback button,.akilio-root[data-akilio-color-mode=system] .akilio-composer-box{background:#18181b;border-color:#3f3f46;color:#e4e4e7}}@media(max-width:640px){.akilio-launcher{right:14px;bottom:max(14px,env(safe-area-inset-bottom));padding:10px}.akilio-launcher strong{display:none}.akilio-panel{width:100vw;height:100dvh;border-left:0}.akilio-root[data-akilio-mode=floating] .akilio-panel{right:14px;bottom:calc(76px + env(safe-area-inset-bottom));width:calc(100vw - 28px);height:min(640px,calc(100dvh - 104px - env(safe-area-inset-bottom)));min-height:min(420px,calc(100dvh - 104px));border:1px solid rgba(212,212,216,.9);border-radius:18px}.akilio-panel-header{padding-top:max(14px,env(safe-area-inset-top))}.akilio-thread{padding-inline:12px}.akilio-bubble{max-width:94%}.akilio-composer{padding-bottom:max(10px,env(safe-area-inset-bottom))}.akilio-root[data-akilio-mode=inline]{min-height:480px}.akilio-panel--inline{min-height:480px;border-radius:16px}}.akilio-root[data-akilio-color-mode=dark] .akilio-composer{background:#18181beb;border-color:#3f3f46}.akilio-root[data-akilio-color-mode=dark] .akilio-composer textarea{color:var(--akilio-text, #fafafa);caret-color:var(--akilio-text, #fafafa);-webkit-text-fill-color:var(--akilio-text, #fafafa)}.akilio-root[data-akilio-color-mode=dark] .akilio-composer textarea::placeholder{color:var(--akilio-muted, #a1a1aa);-webkit-text-fill-color:var(--akilio-muted, #a1a1aa);opacity:1}.akilio-root[data-akilio-color-mode=dark] .akilio-composer-footer span{color:var(--akilio-muted, #a1a1aa)}.akilio-root[data-akilio-color-mode=dark] .akilio-composer-box:focus-within{background:#18181b}@media(max-width:420px){.akilio-logo{width:78px;height:30px}}.akilio-privacy-consent-copy{margin-top:6px!important}.akilio-privacy-actions{display:flex;justify-content:flex-end;gap:8px}.akilio-privacy-actions button{border:1px solid rgba(161,161,170,.65);border-radius:999px;padding:6px 12px;font:inherit;font-weight:700;cursor:pointer}.akilio-privacy-decline{background:transparent;color:#52525b}.akilio-privacy-accept{border-color:var(--akilio-primary)!important;background:var(--akilio-primary);color:#fff}.akilio-privacy-review{border:0;background:transparent;color:var(--akilio-primary);font:inherit;font-weight:700;text-decoration:underline;cursor:pointer;padding:0}.akilio-products{margin-top:14px;min-width:0}.akilio-products-heading{display:flex;align-items:center;justify-content:space-between;margin-bottom:9px;font-size:12px;color:#64748b}.akilio-products-heading span{display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;padding:0 7px;border-radius:999px;background:#eef2ff;color:#4338ca;font-weight:700}.akilio-product-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.akilio-product-card{min-width:0;overflow:hidden;border:1px solid #e2e8f0;border-radius:16px;background:#fff;box-shadow:0 6px 20px #0f172a0f}.akilio-product-media{position:relative;aspect-ratio:4 / 3;overflow:hidden;background:#f1f5f9}.akilio-product-media img{width:100%;height:100%;display:block;object-fit:cover;transition:transform .18s ease}.akilio-product-card:hover .akilio-product-media img{transform:scale(1.025)}.akilio-product-placeholder{width:100%;height:100%;display:grid;place-items:center;color:var(--akilio-primary);font-size:30px;font-weight:800;background:linear-gradient(145deg,#0891b21f,#2563eb14)}.akilio-stock{position:absolute;top:8px;right:8px;max-width:calc(100% - 16px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:4px 7px;border-radius:999px;background:#7f1d1de6;color:#fff;font-size:9px;font-weight:700}.akilio-stock--available{background:#065f46e6}.akilio-product-body{padding:11px}.akilio-product-vendor,.akilio-product-variant{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#64748b;font-size:10px}.akilio-product-card h4{margin:4px 0 8px;min-height:34px;overflow:hidden;color:#0f172a;font-size:13px;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}.akilio-product-price{min-height:37px;display:flex;flex-wrap:wrap;align-items:baseline;gap:5px;margin-bottom:9px}.akilio-product-price strong{color:#0f172a;font-size:14px}.akilio-product-price del{color:#94a3b8;font-size:10px}.akilio-product-action{width:100%;min-height:34px;display:inline-flex;align-items:center;justify-content:center;padding:7px 10px;border:0;border-radius:10px;background:var(--akilio-primary);color:var(--akilio-primary-foreground);font:inherit;font-size:11px;font-weight:700;text-decoration:none;cursor:pointer}.akilio-product-action:hover{filter:brightness(.96)}.akilio-product-action:focus-visible{outline:3px solid color-mix(in srgb,var(--akilio-primary) 28%,transparent);outline-offset:2px}.akilio-product-action:disabled{opacity:.55;cursor:not-allowed}.akilio-root[data-akilio-color-mode=dark] .akilio-products-heading{color:#94a3b8}.akilio-root[data-akilio-color-mode=dark] .akilio-products-heading span{background:#312e81;color:#e0e7ff}.akilio-root[data-akilio-color-mode=dark] .akilio-product-card{background:#111827;border-color:#334155;box-shadow:none}.akilio-root[data-akilio-color-mode=dark] .akilio-product-media{background:#1e293b}.akilio-root[data-akilio-color-mode=dark] .akilio-product-card h4,.akilio-root[data-akilio-color-mode=dark] .akilio-product-price strong{color:#f8fafc}.akilio-root[data-akilio-color-mode=dark] .akilio-product-vendor,.akilio-root[data-akilio-color-mode=dark] .akilio-product-variant{color:#94a3b8}@media(max-width:390px){.akilio-product-grid{grid-template-columns:1fr}.akilio-product-media{aspect-ratio:16 / 9}}.akilio-response-suggestions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}.akilio-response-suggestions button{appearance:none;border:1px solid color-mix(in srgb,var(--akilio-primary) 26%,#d4d4d8);border-radius:999px;background:color-mix(in srgb,var(--akilio-primary) 7%,#ffffff);color:color-mix(in srgb,var(--akilio-primary) 72%,#18181b);cursor:pointer;padding:8px 11px;text-align:left;font:inherit;font-size:12px;font-weight:700;line-height:1.35;transition:transform .15s ease,border-color .15s ease,background .15s ease}.akilio-response-suggestions button:hover{transform:translateY(-1px);border-color:color-mix(in srgb,var(--akilio-primary) 52%,#d4d4d8);background:color-mix(in srgb,var(--akilio-primary) 12%,#ffffff)}.akilio-response-suggestions button:focus-visible{outline:3px solid color-mix(in srgb,var(--akilio-primary) 24%,transparent);outline-offset:2px}.akilio-root[data-akilio-color-mode=dark] .akilio-response-suggestions button{border-color:color-mix(in srgb,var(--akilio-primary) 34%,#3f3f46);background:color-mix(in srgb,var(--akilio-primary) 14%,#18181b);color:#f4f4f5}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type AkilioMode = 'floating' | 'inline' | 'side-panel' | 'drawer' | 'hybrid';
|
|
3
|
+
export type AkilioColorMode = 'light' | 'dark' | 'system';
|
|
4
|
+
export type AkilioLocale = string;
|
|
5
|
+
export type AkilioMessageRole = 'user' | 'assistant';
|
|
6
|
+
export type AkilioFeedbackRating = 'up' | 'down';
|
|
7
|
+
export type AkilioAssistantMode = 'auto' | 'general' | 'knowledge' | 'ecommerce' | 'hybrid';
|
|
8
|
+
export type AkilioCommerceCapabilityType = 'product_search' | 'product_recommendation';
|
|
9
|
+
export type AkilioCommerceEventType = 'search' | 'recommendation' | 'compare' | 'add_to_cart' | 'checkout' | 'purchase';
|
|
10
|
+
export type AkilioCredentialsMode = 'omit' | 'same-origin' | 'include';
|
|
11
|
+
export type AkilioTokenProvider = () => string | null | undefined | Promise<string | null | undefined>;
|
|
12
|
+
export interface AkilioIssuedWidgetToken {
|
|
13
|
+
token: string;
|
|
14
|
+
tokenType: string;
|
|
15
|
+
expiresAt: number;
|
|
16
|
+
}
|
|
17
|
+
export interface AkilioAuthConfig {
|
|
18
|
+
/** Bearer token issued by the Akilio backend for this widget/session. */
|
|
19
|
+
accessToken?: string;
|
|
20
|
+
/** Async token resolver, useful when the host application refreshes short-lived tokens. */
|
|
21
|
+
getAccessToken?: AkilioTokenProvider;
|
|
22
|
+
/** Optional API/widget key for deployments using key-based authentication. */
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
/** Header used for apiKey. Defaults to X-Akilio-Key. */
|
|
25
|
+
apiKeyHeader?: string;
|
|
26
|
+
/** Authentication scheme used with accessToken. Defaults to Bearer. */
|
|
27
|
+
tokenScheme?: string;
|
|
28
|
+
credentials?: AkilioCredentialsMode;
|
|
29
|
+
headers?: Record<string, string>;
|
|
30
|
+
/** Automatically issue and refresh a short-lived widget token. Defaults to true when no host token is supplied. */
|
|
31
|
+
autoIssueWidgetToken?: boolean;
|
|
32
|
+
/** Refresh the widget token this many seconds before expiry. Defaults to 30 seconds. */
|
|
33
|
+
tokenRefreshLeewaySeconds?: number;
|
|
34
|
+
/** Called whenever the API issues or refreshes a widget token. */
|
|
35
|
+
onWidgetToken?: (token: AkilioIssuedWidgetToken) => void;
|
|
36
|
+
}
|
|
37
|
+
export interface AkilioThemeConfig {
|
|
38
|
+
primary?: string;
|
|
39
|
+
primaryForeground?: string;
|
|
40
|
+
accent?: string;
|
|
41
|
+
surface?: string;
|
|
42
|
+
text?: string;
|
|
43
|
+
muted?: string;
|
|
44
|
+
radius?: string;
|
|
45
|
+
launcherLabel?: string;
|
|
46
|
+
panelWidth?: number;
|
|
47
|
+
zIndex?: number;
|
|
48
|
+
logoUrl?: string;
|
|
49
|
+
brandName?: string;
|
|
50
|
+
colorMode?: AkilioColorMode;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
export interface AkilioPageContext {
|
|
54
|
+
url?: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
audience?: string;
|
|
57
|
+
productArea?: string;
|
|
58
|
+
channel?: string;
|
|
59
|
+
metadata?: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
export interface AkilioSource {
|
|
62
|
+
title?: string | null;
|
|
63
|
+
url?: string | null;
|
|
64
|
+
section_path?: unknown;
|
|
65
|
+
score?: number;
|
|
66
|
+
excerpt?: string | null;
|
|
67
|
+
}
|
|
68
|
+
export interface AkilioProductVariant {
|
|
69
|
+
id: string;
|
|
70
|
+
external_id: string;
|
|
71
|
+
title?: string;
|
|
72
|
+
sku?: string;
|
|
73
|
+
price: string;
|
|
74
|
+
compare_at_price?: string | null;
|
|
75
|
+
currency?: string;
|
|
76
|
+
inventory_quantity?: number;
|
|
77
|
+
options?: unknown;
|
|
78
|
+
available: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface AkilioProduct {
|
|
81
|
+
id: string;
|
|
82
|
+
external_id: string;
|
|
83
|
+
title: string;
|
|
84
|
+
description?: string;
|
|
85
|
+
vendor?: string;
|
|
86
|
+
product_type?: string;
|
|
87
|
+
url?: string;
|
|
88
|
+
image_url?: string;
|
|
89
|
+
tags?: unknown;
|
|
90
|
+
attributes?: unknown;
|
|
91
|
+
available: string;
|
|
92
|
+
variants: AkilioProductVariant[];
|
|
93
|
+
business_rule_decision?: Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
export interface AkilioCommerceCapability {
|
|
96
|
+
capability: AkilioCommerceCapabilityType;
|
|
97
|
+
products: AkilioProduct[];
|
|
98
|
+
}
|
|
99
|
+
export interface AkilioCommerceEvent {
|
|
100
|
+
event_type: AkilioCommerceEventType;
|
|
101
|
+
product_id?: string | null;
|
|
102
|
+
variant_id?: string | null;
|
|
103
|
+
conversation_id?: string | null;
|
|
104
|
+
external_user_id?: string;
|
|
105
|
+
value?: string | null;
|
|
106
|
+
currency?: string;
|
|
107
|
+
metadata?: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
export interface AkilioProjectConfig {
|
|
110
|
+
project_key: string;
|
|
111
|
+
name: string;
|
|
112
|
+
slug: string;
|
|
113
|
+
title: string;
|
|
114
|
+
placeholder: string;
|
|
115
|
+
starter_questions: string[];
|
|
116
|
+
theme_config: AkilioThemeConfig;
|
|
117
|
+
default_language: string;
|
|
118
|
+
supported_languages: string[];
|
|
119
|
+
privacy_notice?: string;
|
|
120
|
+
privacy_notice_url?: string;
|
|
121
|
+
require_consent?: boolean;
|
|
122
|
+
}
|
|
123
|
+
export interface AkilioChatRequest {
|
|
124
|
+
project_key: string;
|
|
125
|
+
conversation_id?: string;
|
|
126
|
+
message: string;
|
|
127
|
+
locale?: string;
|
|
128
|
+
channel?: string;
|
|
129
|
+
audience?: string;
|
|
130
|
+
product_area?: string;
|
|
131
|
+
assistant_mode?: AkilioAssistantMode | null;
|
|
132
|
+
page?: {
|
|
133
|
+
url?: string;
|
|
134
|
+
title?: string;
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
};
|
|
137
|
+
anonymous_id?: string;
|
|
138
|
+
external_user_id?: string;
|
|
139
|
+
consent?: {
|
|
140
|
+
granted: boolean;
|
|
141
|
+
granted_at?: string;
|
|
142
|
+
notice_version?: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
export interface AkilioWidgetTokenResponse {
|
|
146
|
+
token: string;
|
|
147
|
+
token_type?: string;
|
|
148
|
+
expires_in: number;
|
|
149
|
+
}
|
|
150
|
+
export interface AkilioChatResponse {
|
|
151
|
+
schema_version?: string;
|
|
152
|
+
conversation_id: string;
|
|
153
|
+
message_id: string;
|
|
154
|
+
response_type?: string;
|
|
155
|
+
content?: Record<string, unknown>;
|
|
156
|
+
answer?: string;
|
|
157
|
+
confidence?: string | number | null;
|
|
158
|
+
sources: AkilioSource[];
|
|
159
|
+
provider?: string;
|
|
160
|
+
model?: string;
|
|
161
|
+
cost_usd?: string;
|
|
162
|
+
commerce?: AkilioCommerceCapability | null;
|
|
163
|
+
suggestions?: string[];
|
|
164
|
+
warnings?: string[];
|
|
165
|
+
assistant_mode?: string;
|
|
166
|
+
active_route?: string;
|
|
167
|
+
}
|
|
168
|
+
export interface AkilioConversationMessageResponse {
|
|
169
|
+
id: string;
|
|
170
|
+
role: AkilioMessageRole;
|
|
171
|
+
content: string;
|
|
172
|
+
sources?: AkilioSource[];
|
|
173
|
+
confidence?: string | number | null;
|
|
174
|
+
metadata?: Record<string, unknown>;
|
|
175
|
+
structured_content?: string;
|
|
176
|
+
created_at: string;
|
|
177
|
+
}
|
|
178
|
+
export interface AkilioConversationResponse {
|
|
179
|
+
id: string;
|
|
180
|
+
locale: string;
|
|
181
|
+
page_url?: string | null;
|
|
182
|
+
page_title?: string;
|
|
183
|
+
metadata?: Record<string, unknown>;
|
|
184
|
+
created_at: string;
|
|
185
|
+
messages: AkilioConversationMessageResponse[];
|
|
186
|
+
}
|
|
187
|
+
export interface AkilioChatMessage {
|
|
188
|
+
id: string;
|
|
189
|
+
role: AkilioMessageRole;
|
|
190
|
+
content: string;
|
|
191
|
+
createdAt: string;
|
|
192
|
+
backendMessageId?: string;
|
|
193
|
+
conversationId?: string;
|
|
194
|
+
confidence?: string | number | null;
|
|
195
|
+
sources?: AkilioSource[];
|
|
196
|
+
provider?: string;
|
|
197
|
+
model?: string;
|
|
198
|
+
costUsd?: string;
|
|
199
|
+
commerce?: AkilioCommerceCapability | null;
|
|
200
|
+
suggestions?: string[];
|
|
201
|
+
error?: boolean;
|
|
202
|
+
feedback?: AkilioFeedbackRating;
|
|
203
|
+
}
|
|
204
|
+
export interface AkilioCopyOverrides {
|
|
205
|
+
launcher?: string;
|
|
206
|
+
title?: string;
|
|
207
|
+
description?: string;
|
|
208
|
+
placeholder?: string;
|
|
209
|
+
helper?: string;
|
|
210
|
+
submit?: string;
|
|
211
|
+
loading?: string;
|
|
212
|
+
emptyState?: string;
|
|
213
|
+
sources?: string;
|
|
214
|
+
confidence?: string;
|
|
215
|
+
clearHistory?: string;
|
|
216
|
+
close?: string;
|
|
217
|
+
online?: string;
|
|
218
|
+
feedbackQuestion?: string;
|
|
219
|
+
feedbackThanks?: string;
|
|
220
|
+
voteUp?: string;
|
|
221
|
+
voteDown?: string;
|
|
222
|
+
requestFailed?: string;
|
|
223
|
+
configFailed?: string;
|
|
224
|
+
newChat?: string;
|
|
225
|
+
privacyTitle?: string;
|
|
226
|
+
privacyAccept?: string;
|
|
227
|
+
privacyAcceptAction?: string;
|
|
228
|
+
privacyDecline?: string;
|
|
229
|
+
privacyReview?: string;
|
|
230
|
+
privacyRequired?: string;
|
|
231
|
+
privacyDefaultNotice?: string;
|
|
232
|
+
switchToLightMode?: string;
|
|
233
|
+
switchToDarkMode?: string;
|
|
234
|
+
products?: string;
|
|
235
|
+
viewProduct?: string;
|
|
236
|
+
fromPrice?: string;
|
|
237
|
+
unavailable?: string;
|
|
238
|
+
inStock?: string;
|
|
239
|
+
outOfStock?: string;
|
|
240
|
+
}
|
|
241
|
+
export interface AkilioLauncherRenderProps {
|
|
242
|
+
open: boolean;
|
|
243
|
+
openChat: () => void;
|
|
244
|
+
closeChat: () => void;
|
|
245
|
+
toggleChat: () => void;
|
|
246
|
+
}
|
|
247
|
+
export type AkilioLauncher = 'default' | 'hidden' | ((controls: AkilioLauncherRenderProps) => ReactNode);
|
|
248
|
+
export interface AkilioWidgetProps {
|
|
249
|
+
apiBaseUrl: string;
|
|
250
|
+
projectKey: string;
|
|
251
|
+
locale?: AkilioLocale;
|
|
252
|
+
mode?: AkilioMode;
|
|
253
|
+
colorMode?: AkilioColorMode;
|
|
254
|
+
/** Show a header control that lets visitors override the configured/system theme. */
|
|
255
|
+
allowColorModeToggle?: boolean;
|
|
256
|
+
defaultOpen?: boolean;
|
|
257
|
+
/** Controlled open state. Pair with onOpenChange. */
|
|
258
|
+
open?: boolean;
|
|
259
|
+
/** Built-in launcher, no launcher, or a custom React launcher renderer. */
|
|
260
|
+
launcher?: AkilioLauncher;
|
|
261
|
+
persistOpenState?: boolean;
|
|
262
|
+
enableTour?: boolean;
|
|
263
|
+
enableLocalHistory?: boolean;
|
|
264
|
+
enableServerHistorySync?: boolean;
|
|
265
|
+
anonymousId?: string;
|
|
266
|
+
externalUserId?: string;
|
|
267
|
+
channel?: string;
|
|
268
|
+
audience?: string;
|
|
269
|
+
productArea?: string;
|
|
270
|
+
/** Optional routing hint sent to the chat endpoint as assistant_mode. */
|
|
271
|
+
assistantMode?: AkilioAssistantMode;
|
|
272
|
+
pageContext?: AkilioPageContext | (() => AkilioPageContext);
|
|
273
|
+
auth?: AkilioAuthConfig;
|
|
274
|
+
/** Convenience alias for auth.accessToken. */
|
|
275
|
+
accessToken?: string;
|
|
276
|
+
privacyNotice?: string;
|
|
277
|
+
privacyNoticeUrl?: string;
|
|
278
|
+
requireConsent?: boolean;
|
|
279
|
+
consentNoticeVersion?: string;
|
|
280
|
+
initialConsent?: boolean;
|
|
281
|
+
onConsentChange?: (granted: boolean) => void;
|
|
282
|
+
copy?: AkilioCopyOverrides;
|
|
283
|
+
theme?: AkilioThemeConfig;
|
|
284
|
+
className?: string;
|
|
285
|
+
onOpenChange?: (open: boolean) => void;
|
|
286
|
+
onMessage?: (message: AkilioChatMessage) => void;
|
|
287
|
+
onProductClick?: (product: AkilioProduct, variant?: AkilioProductVariant) => void;
|
|
288
|
+
onError?: (error: Error) => void;
|
|
289
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Root } from 'react-dom/client';
|
|
2
|
+
import type { AkilioWidgetProps } from './types';
|
|
3
|
+
export interface AkilioVanillaOptions extends Omit<AkilioWidgetProps, 'pageContext'> {
|
|
4
|
+
target?: string | HTMLElement;
|
|
5
|
+
pageContext?: AkilioWidgetProps['pageContext'];
|
|
6
|
+
}
|
|
7
|
+
export interface AkilioVanillaInstance {
|
|
8
|
+
id: string;
|
|
9
|
+
element: HTMLElement;
|
|
10
|
+
root: Root;
|
|
11
|
+
open: () => void;
|
|
12
|
+
close: () => void;
|
|
13
|
+
toggle: () => void;
|
|
14
|
+
destroy: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface AkilioVanillaApi {
|
|
17
|
+
mount: (options: AkilioVanillaOptions) => AkilioVanillaInstance;
|
|
18
|
+
init: (options: AkilioVanillaOptions) => AkilioVanillaInstance;
|
|
19
|
+
destroy: (id: string) => void;
|
|
20
|
+
destroyAll: () => void;
|
|
21
|
+
}
|
|
22
|
+
declare global {
|
|
23
|
+
interface Window {
|
|
24
|
+
Akilio?: AkilioVanillaApi;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
declare function mount(options: AkilioVanillaOptions): AkilioVanillaInstance;
|
|
28
|
+
declare function destroy(id: string): void;
|
|
29
|
+
declare function destroyAll(): void;
|
|
30
|
+
export { destroy, destroyAll, mount };
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hachther/akilio-widget",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Embeddable React AI assistant widget for Akilio backend.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.umd.min.cjs",
|
|
8
|
+
"module": "dist/index.min.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"sideEffects": [
|
|
14
|
+
"dist/style.css",
|
|
15
|
+
"src/styles.css"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite --host 0.0.0.0",
|
|
19
|
+
"build": "npm run build:react && npm run build:vanilla",
|
|
20
|
+
"build:react": "vite build && tsc -p tsconfig.build.json",
|
|
21
|
+
"build:vanilla": "vite build --config vite.vanilla.config.ts",
|
|
22
|
+
"preview": "vite preview",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
25
|
+
"format": "prettier --check --ignore-path .gitignore .",
|
|
26
|
+
"format:fix": "prettier --write --ignore-path .gitignore ."
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
30
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"clsx": "^2.1.1",
|
|
34
|
+
"driver.js": "^1.8.0",
|
|
35
|
+
"react-markdown": "^10.1.0",
|
|
36
|
+
"rehype-highlight": "^7.0.2",
|
|
37
|
+
"remark-gfm": "^4.0.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^19.0.0",
|
|
41
|
+
"@types/react-dom": "^19.0.0",
|
|
42
|
+
"@vitejs/plugin-react": "^5.0.0",
|
|
43
|
+
"eslint-config-prettier": "^9.1.0",
|
|
44
|
+
"prettier": "^3.9.0",
|
|
45
|
+
"prettier-plugin-organize-imports": "^3.2.4",
|
|
46
|
+
"react": "^19.2.7",
|
|
47
|
+
"react-dom": "^19.2.7",
|
|
48
|
+
"typescript": "^5.8.0",
|
|
49
|
+
"vite": "^7.0.0"
|
|
50
|
+
},
|
|
51
|
+
"unpkg": "dist/akilio-widget.min.js",
|
|
52
|
+
"jsdelivr": "dist/akilio-widget.min.js",
|
|
53
|
+
"exports": {
|
|
54
|
+
".": {
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"import": "./dist/index.min.js",
|
|
57
|
+
"require": "./dist/index.umd.min.cjs"
|
|
58
|
+
},
|
|
59
|
+
"./style.css": "./dist/style.css",
|
|
60
|
+
"./vanilla": "./dist/akilio-widget.min.js"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"react": {
|
|
64
|
+
"optional": false
|
|
65
|
+
},
|
|
66
|
+
"react-dom": {
|
|
67
|
+
"optional": false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|