@elia-assistant/chatui 1.0.26 → 2.0.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 +111 -17
- 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-DzpdfGcd.js} +41 -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 +10 -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
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import e from "react";
|
|
2
|
+
//#region src/lib/storage.ts
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return t ? `${e}-${t}` : e;
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
2
7
|
//#region node_modules/zustand/esm/vanilla.mjs
|
|
3
|
-
var
|
|
8
|
+
var n = (e) => {
|
|
4
9
|
let t, n = /* @__PURE__ */ new Set(), r = (e, r) => {
|
|
5
10
|
let i = typeof e == "function" ? e(t) : e;
|
|
6
11
|
if (!Object.is(i, t)) {
|
|
@@ -14,18 +19,18 @@ var t = (e) => {
|
|
|
14
19
|
subscribe: (e) => (n.add(e), () => n.delete(e))
|
|
15
20
|
}, o = t = e(r, i, a);
|
|
16
21
|
return a;
|
|
17
|
-
},
|
|
18
|
-
function
|
|
19
|
-
let
|
|
20
|
-
return e.useDebugValue(
|
|
22
|
+
}, r = ((e) => e ? n(e) : n), i = (e) => e;
|
|
23
|
+
function a(t, n = i) {
|
|
24
|
+
let r = e.useSyncExternalStore(t.subscribe, e.useCallback(() => n(t.getState()), [t, n]), e.useCallback(() => n(t.getInitialState()), [t, n]));
|
|
25
|
+
return e.useDebugValue(r), r;
|
|
21
26
|
}
|
|
22
|
-
var
|
|
23
|
-
let t =
|
|
24
|
-
return Object.assign(
|
|
25
|
-
},
|
|
27
|
+
var o = (e) => {
|
|
28
|
+
let t = r(e), n = (e) => a(t, e);
|
|
29
|
+
return Object.assign(n, t), n;
|
|
30
|
+
}, s = ((e) => e ? o(e) : o);
|
|
26
31
|
//#endregion
|
|
27
32
|
//#region node_modules/zustand/esm/middleware.mjs
|
|
28
|
-
function
|
|
33
|
+
function c(e, t) {
|
|
29
34
|
let n;
|
|
30
35
|
try {
|
|
31
36
|
n = e();
|
|
@@ -41,12 +46,12 @@ function s(e, t) {
|
|
|
41
46
|
removeItem: (e) => n.removeItem(e)
|
|
42
47
|
};
|
|
43
48
|
}
|
|
44
|
-
var
|
|
49
|
+
var l = (e) => (t) => {
|
|
45
50
|
try {
|
|
46
51
|
let n = e(t);
|
|
47
52
|
return n instanceof Promise ? n : {
|
|
48
53
|
then(e) {
|
|
49
|
-
return
|
|
54
|
+
return l(e)(n);
|
|
50
55
|
},
|
|
51
56
|
catch(e) {
|
|
52
57
|
return this;
|
|
@@ -58,13 +63,13 @@ var c = (e) => (t) => {
|
|
|
58
63
|
return this;
|
|
59
64
|
},
|
|
60
65
|
catch(t) {
|
|
61
|
-
return
|
|
66
|
+
return l(t)(e);
|
|
62
67
|
}
|
|
63
68
|
};
|
|
64
69
|
}
|
|
65
|
-
},
|
|
70
|
+
}, u = (e, t) => (n, r, i) => {
|
|
66
71
|
let a = {
|
|
67
|
-
storage:
|
|
72
|
+
storage: c(() => window.localStorage),
|
|
68
73
|
partialize: (e) => e,
|
|
69
74
|
version: 0,
|
|
70
75
|
merge: (e, t) => ({
|
|
@@ -72,7 +77,7 @@ var c = (e) => (t) => {
|
|
|
72
77
|
...e
|
|
73
78
|
}),
|
|
74
79
|
...t
|
|
75
|
-
}, o = !1,
|
|
80
|
+
}, o = !1, s = 0, u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = a.storage;
|
|
76
81
|
if (!f) return e((...e) => {
|
|
77
82
|
console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`), n(...e);
|
|
78
83
|
}, r, i);
|
|
@@ -88,10 +93,10 @@ var c = (e) => (t) => {
|
|
|
88
93
|
i.getInitialState = () => h;
|
|
89
94
|
let g, _ = () => {
|
|
90
95
|
if (!f) return;
|
|
91
|
-
let e = ++
|
|
96
|
+
let e = ++s;
|
|
92
97
|
o = !1, u.forEach((e) => e(r() ?? h));
|
|
93
98
|
let t = a.onRehydrateStorage?.call(a, r() ?? h) || void 0;
|
|
94
|
-
return
|
|
99
|
+
return l(f.getItem.bind(f))(a.name).then((e) => {
|
|
95
100
|
if (e) if (typeof e.version == "number" && e.version !== a.version) {
|
|
96
101
|
if (a.migrate) {
|
|
97
102
|
let t = a.migrate(e.state, e.version);
|
|
@@ -101,13 +106,13 @@ var c = (e) => (t) => {
|
|
|
101
106
|
} else return [!1, e.state];
|
|
102
107
|
return [!1, void 0];
|
|
103
108
|
}).then((t) => {
|
|
104
|
-
if (e !==
|
|
109
|
+
if (e !== s) return;
|
|
105
110
|
let [i, o] = t;
|
|
106
111
|
if (g = a.merge(o, r() ?? h), n(g, !0), i) return p();
|
|
107
112
|
}).then(() => {
|
|
108
|
-
e ===
|
|
113
|
+
e === s && (t?.(r(), void 0), g = r(), o = !0, d.forEach((e) => e(g)));
|
|
109
114
|
}).catch((n) => {
|
|
110
|
-
e ===
|
|
115
|
+
e === s && t?.(void 0, n);
|
|
111
116
|
});
|
|
112
117
|
};
|
|
113
118
|
return i.persist = {
|
|
@@ -132,6 +137,6 @@ var c = (e) => (t) => {
|
|
|
132
137
|
}, a.skipHydration || _(), g || h;
|
|
133
138
|
};
|
|
134
139
|
//#endregion
|
|
135
|
-
export {
|
|
140
|
+
export { s as n, t as r, u as t };
|
|
136
141
|
|
|
137
|
-
//# sourceMappingURL=middleware-
|
|
142
|
+
//# sourceMappingURL=middleware-BG8DEvI8.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as e, t } from "./middleware-
|
|
1
|
+
import { n as e, r as t, t as n } from "./middleware-BG8DEvI8.js";
|
|
2
2
|
//#region src/themes.ts
|
|
3
|
-
var
|
|
3
|
+
var r = [
|
|
4
4
|
{
|
|
5
5
|
id: "sunrise",
|
|
6
6
|
label: "Sunrise",
|
|
@@ -97,13 +97,13 @@ var n = [
|
|
|
97
97
|
baseColor: "#0f1117",
|
|
98
98
|
accentColor: "#6366f1"
|
|
99
99
|
}
|
|
100
|
-
],
|
|
101
|
-
function
|
|
102
|
-
return
|
|
100
|
+
], i = "midnight";
|
|
101
|
+
function a(e) {
|
|
102
|
+
return r.find((t) => t.id === e) ?? r[0];
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
105
|
//#region src/store/settingsStore.ts
|
|
106
|
-
var
|
|
106
|
+
var o = {
|
|
107
107
|
webhookUrl: "",
|
|
108
108
|
chatInputKey: "chatInput",
|
|
109
109
|
chatSessionKey: "sessionId",
|
|
@@ -128,39 +128,40 @@ var a = {
|
|
|
128
128
|
ctaText: "Dobrý deň! Ako vám môžem pomôcť?"
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}), {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}));
|
|
131
|
+
};
|
|
132
|
+
function s(r, a) {
|
|
133
|
+
return e()(n((e) => ({
|
|
134
|
+
config: o,
|
|
135
|
+
activeTheme: i,
|
|
136
|
+
language: "en",
|
|
137
|
+
setConfig(t) {
|
|
138
|
+
e((e) => ({ config: {
|
|
139
|
+
...e.config,
|
|
140
|
+
...t
|
|
141
|
+
} }));
|
|
142
|
+
},
|
|
143
|
+
setTheme(t) {
|
|
144
|
+
e({ activeTheme: t });
|
|
145
|
+
},
|
|
146
|
+
setLanguage(t) {
|
|
147
|
+
e({ language: t }), r.changeLanguage(t);
|
|
148
|
+
}
|
|
149
|
+
}), {
|
|
150
|
+
name: t("chatui-settings", a),
|
|
151
|
+
merge: (e, t) => {
|
|
152
|
+
let n = e;
|
|
153
|
+
return {
|
|
154
|
+
...t,
|
|
155
|
+
...n,
|
|
156
|
+
config: {
|
|
157
|
+
...t.config,
|
|
158
|
+
...n.config ?? {}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
163
164
|
//#endregion
|
|
164
|
-
export {
|
|
165
|
+
export { a as n, r, s as t };
|
|
165
166
|
|
|
166
|
-
//# sourceMappingURL=settingsStore-
|
|
167
|
+
//# sourceMappingURL=settingsStore-DzpdfGcd.js.map
|
package/dist/createChat.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { i18n as I18nInstance } from 'i18next';
|
|
1
2
|
import type { ChatConfig } from './types/index.ts';
|
|
2
3
|
export interface CreateChatOptions extends Partial<ChatConfig> {
|
|
3
4
|
/** CSS selector or DOM element where the chat will mount.
|
|
@@ -7,9 +8,25 @@ export interface CreateChatOptions extends Partial<ChatConfig> {
|
|
|
7
8
|
target?: string | HTMLElement;
|
|
8
9
|
/** Initial UI language code (e.g. 'en', 'sk'). Applied immediately via `setLanguage()`. */
|
|
9
10
|
language?: string;
|
|
11
|
+
/** Isolates this instance's persisted settings/session storage (and in-memory config/theme/
|
|
12
|
+
* conversation state) from any other chatui instance mounted on the same page - e.g. a
|
|
13
|
+
* host's own floating widget alongside a page's embedded demo. Only needed when multiple
|
|
14
|
+
* instances can be mounted simultaneously; a single instance per page can omit it. */
|
|
15
|
+
storageNamespace?: string;
|
|
10
16
|
}
|
|
11
17
|
export interface ChatInstance {
|
|
12
18
|
/** Unmount the chat and detach React. */
|
|
13
19
|
unmount(): void;
|
|
20
|
+
/** Update the config without remounting. */
|
|
21
|
+
setConfig(patch: Partial<ChatConfig>): void;
|
|
22
|
+
/** Switch the active theme without remounting. */
|
|
23
|
+
setTheme(id: string): void;
|
|
24
|
+
/** Switch the UI language without remounting. */
|
|
25
|
+
setLanguage(lang: string): void;
|
|
26
|
+
/** This instance's i18next instance, for registering extra UI languages at runtime via
|
|
27
|
+
* `addResourceBundle()`. The widget does not read the global i18next singleton, so a bundle
|
|
28
|
+
* registered there will not reach it - use this. `undefined` until the instance has mounted
|
|
29
|
+
* (only possible when createChat() was called before DOMContentLoaded). */
|
|
30
|
+
readonly i18n: I18nInstance | undefined;
|
|
14
31
|
}
|
|
15
32
|
export declare function createChat(opts: CreateChatOptions): ChatInstance;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import i18n from 'i18next';
|
|
2
|
-
|
|
1
|
+
import { type i18n as I18nInstance } from 'i18next';
|
|
2
|
+
/**
|
|
3
|
+
* Creates one createChat() instance's i18next instance (UI chrome strings: input placeholder,
|
|
4
|
+
* "Powered by", etc. - not the host-supplied bot content in config.i18n). Each instance gets
|
|
5
|
+
* its own so simultaneous instances on the same page don't force each other's UI language when
|
|
6
|
+
* one switches (see StoreContext.tsx for the equivalent settings/chat store isolation).
|
|
7
|
+
*/
|
|
8
|
+
export declare function createChatI18n(namespace?: string): I18nInstance;
|
package/dist/iife.d.ts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export { App } from './App.tsx';
|
|
2
|
-
export { createChat } from './createChat.
|
|
3
|
-
export type { CreateChatOptions, ChatInstance } from './createChat.
|
|
2
|
+
export { createChat } from './createChat.tsx';
|
|
3
|
+
export type { CreateChatOptions, ChatInstance } from './createChat.tsx';
|
|
4
|
+
export { StoreProvider } from './store/StoreContext.tsx';
|
|
5
|
+
export { createSettingsStore } from './store/settingsStore.ts';
|
|
6
|
+
export { createChatStore } from './store/chatStore.ts';
|
|
7
|
+
export { createChatI18n } from './i18n.ts';
|
|
8
|
+
export type { SettingsState } from './store/settingsStore.ts';
|
|
9
|
+
export type { ChatState } from './store/chatStore.ts';
|
|
4
10
|
export type { ChatConfig, LangOverride, Message, Session, ThemeDef, NotificationItem, NotificationTag, NotificationTagVariant, FaqItem, Attachment, } from './types/index.ts';
|