@elia-assistant/chatui 1.0.26 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -18
- package/dist/App.d.ts +0 -1
- package/dist/chat-store.js +141 -139
- package/dist/chatui.iife.js +30 -31
- package/dist/chunks/{middleware-Brf3TxqP.js → middleware-BG8DEvI8.js} +28 -23
- package/dist/chunks/{settingsStore-JRogtJV3.js → settingsStore-C7relGs3.js} +48 -40
- package/dist/createChat.d.ts +17 -0
- package/dist/i18n.d.ts +8 -2
- package/dist/iife.d.ts +2 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +3664 -2257
- package/dist/lib/storage.d.ts +7 -3
- package/dist/store/StoreContext.d.ts +32 -0
- package/dist/store/chatStore.d.ts +8 -3
- package/dist/store/settingsStore.d.ts +11 -3
- package/dist/store.js +2 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunks/i18n-DS9aLar5.js +0 -1321
package/dist/lib/storage.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Builds a per-instance storage key. Every localStorage/sessionStorage key the widget writes
|
|
3
|
+
* must go through here: two createChat() instances on the same page share one Storage object,
|
|
4
|
+
* so an un-scoped key silently bleeds state between them. Omitting `namespace` keeps the bare
|
|
5
|
+
* key, which is the pre-multi-instance behaviour existing single-widget installs persist under.
|
|
6
|
+
*/
|
|
7
|
+
export declare function scopedKey(base: string, namespace?: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { StoreApi, UseBoundStore } from 'zustand';
|
|
3
|
+
import type { SettingsState } from './settingsStore.ts';
|
|
4
|
+
import type { ChatState } from './chatStore.ts';
|
|
5
|
+
export type SettingsStoreHook = UseBoundStore<StoreApi<SettingsState>>;
|
|
6
|
+
export type ChatStoreHook = UseBoundStore<StoreApi<ChatState>>;
|
|
7
|
+
/**
|
|
8
|
+
* Provides one createChat() instance's settings/chat stores to its React tree. Each mounted
|
|
9
|
+
* instance gets its own stores (created in createChat.tsx) so multiple widgets on the same
|
|
10
|
+
* page - e.g. a host's own floating widget alongside a page's embedded demo - never share
|
|
11
|
+
* config, theme, or conversation state.
|
|
12
|
+
*
|
|
13
|
+
* `storageNamespace` is the same value the stores were created with, exposed here for the
|
|
14
|
+
* component-local storage keys that don't live in a store (see useStorageNamespace).
|
|
15
|
+
*/
|
|
16
|
+
export declare function StoreProvider({ settingsStore, chatStore, storageNamespace, children, }: {
|
|
17
|
+
settingsStore: SettingsStoreHook;
|
|
18
|
+
chatStore: ChatStoreHook;
|
|
19
|
+
storageNamespace?: string;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* This instance's storage namespace, for keys written outside the zustand stores. Pair it with
|
|
24
|
+
* scopedKey() - a bare key would be shared with every other instance on the page.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useStorageNamespace(): string | undefined;
|
|
27
|
+
export declare function useSettingsStore(): SettingsState;
|
|
28
|
+
export declare function useSettingsStore<T>(selector: (state: SettingsState) => T): T;
|
|
29
|
+
export declare function useChatStore(): ChatState;
|
|
30
|
+
export declare function useChatStore<T>(selector: (state: ChatState) => T): T;
|
|
31
|
+
/** Imperative access (outside render, e.g. inside a callback) to the current chat store. */
|
|
32
|
+
export declare function useChatStoreApi(): ChatStoreHook;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Message, Session } from '../types/index.ts';
|
|
2
|
-
interface ChatState {
|
|
2
|
+
export interface ChatState {
|
|
3
3
|
sessions: Session[];
|
|
4
4
|
activeSessionId: string | null;
|
|
5
5
|
messages: Record<string, Message[]>;
|
|
@@ -22,7 +22,13 @@ interface ChatState {
|
|
|
22
22
|
renameSession(id: string, title: string): void;
|
|
23
23
|
clearMessages(sessionId: string): void;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Creates one createChat() instance's session/message store. Each instance gets its own store
|
|
27
|
+
* (see StoreContext.tsx) so simultaneous instances on the same page don't share conversations.
|
|
28
|
+
* `namespace` scopes the localStorage key for the same reason - omit it to keep the default
|
|
29
|
+
* key (matches pre-multi-instance behaviour for the common single-widget-per-page case).
|
|
30
|
+
*/
|
|
31
|
+
export declare function createChatStore(namespace?: string): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<ChatState>, "setState" | "persist"> & {
|
|
26
32
|
setState(partial: ChatState | Partial<ChatState> | ((state: ChatState) => ChatState | Partial<ChatState>), replace?: false | undefined): unknown;
|
|
27
33
|
setState(state: ChatState | ((state: ChatState) => ChatState), replace: true): unknown;
|
|
28
34
|
persist: {
|
|
@@ -43,4 +49,3 @@ export declare const useChatStore: import("zustand").UseBoundStore<Omit<import("
|
|
|
43
49
|
}, unknown>>;
|
|
44
50
|
};
|
|
45
51
|
}>;
|
|
46
|
-
export {};
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
+
import type { i18n as I18nInstance } from 'i18next';
|
|
1
2
|
import type { ChatConfig } from '../types/index.ts';
|
|
2
|
-
interface SettingsState {
|
|
3
|
+
export interface SettingsState {
|
|
3
4
|
config: ChatConfig;
|
|
4
5
|
activeTheme: string;
|
|
5
6
|
language: string;
|
|
6
7
|
setConfig(patch: Partial<ChatConfig>): void;
|
|
8
|
+
initConfig(opts: Partial<ChatConfig>): void;
|
|
7
9
|
setTheme(id: string): void;
|
|
8
10
|
setLanguage(lang: string): void;
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Creates one createChat() instance's settings store. Each instance gets its own store (see
|
|
14
|
+
* StoreContext.tsx) so simultaneous instances on the same page don't share config/theme.
|
|
15
|
+
* `namespace` scopes the localStorage key so simultaneous instances don't persist over each
|
|
16
|
+
* other either; omit it to keep the default key (matches pre-multi-instance behaviour for the
|
|
17
|
+
* common single-widget-per-page case).
|
|
18
|
+
*/
|
|
19
|
+
export declare function createSettingsStore(i18nInstance: I18nInstance, namespace?: string): import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SettingsState>, "setState" | "persist"> & {
|
|
11
20
|
setState(partial: SettingsState | Partial<SettingsState> | ((state: SettingsState) => SettingsState | Partial<SettingsState>), replace?: false | undefined): unknown;
|
|
12
21
|
setState(state: SettingsState | ((state: SettingsState) => SettingsState), replace: true): unknown;
|
|
13
22
|
persist: {
|
|
@@ -20,4 +29,3 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<impo
|
|
|
20
29
|
getOptions: () => Partial<import("zustand/middleware").PersistOptions<SettingsState, SettingsState, unknown>>;
|
|
21
30
|
};
|
|
22
31
|
}>;
|
|
23
|
-
export {};
|
package/dist/store.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./chunks/settingsStore-
|
|
2
|
-
export { e as
|
|
1
|
+
import { t as e } from "./chunks/settingsStore-C7relGs3.js";
|
|
2
|
+
export { e as createSettingsStore };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export interface ChatConfig {
|
|
|
67
67
|
theme?: string;
|
|
68
68
|
/** Override individual CSS variables on the widget root, e.g. { '--t-avatar-bg': '#ff0000' } */
|
|
69
69
|
cssVars?: Record<string, string>;
|
|
70
|
-
mode?: 'window' | 'fullscreen' | 'mixed';
|
|
70
|
+
mode?: 'window' | 'fullscreen' | 'mixed' | 'embedded';
|
|
71
71
|
showCta?: boolean;
|
|
72
72
|
ctaText?: string;
|
|
73
73
|
ctaDelay?: number;
|