@botfabrik/engine-webclient 4.66.1 → 4.66.3
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/dist/client/index.html
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="theme-color" content="#000000" />
|
|
8
8
|
<meta name="google" content="notranslate" />
|
|
9
9
|
<title>Bubble Chat Client</title>
|
|
10
|
-
<script type="module" crossorigin src="./assets/index-
|
|
10
|
+
<script type="module" crossorigin src="./assets/index-DTiiiazw.js"></script>
|
|
11
11
|
<link rel="stylesheet" crossorigin href="./assets/index-Bv7hr1lr.css">
|
|
12
12
|
</head>
|
|
13
13
|
|
package/dist/index.js
CHANGED
|
@@ -123,14 +123,19 @@ const serveStaticOptions = {
|
|
|
123
123
|
},
|
|
124
124
|
};
|
|
125
125
|
const isFabVisible = ({ fabVisible = true }) => fabVisible;
|
|
126
|
-
const onStartChat = (socket, props, bot, clientName, environment, logger) => async ({ sessionId:
|
|
126
|
+
const onStartChat = (socket, props, bot, clientName, environment, logger) => async ({ sessionId: sessionIdFromClient, sessionIdToTerminate, // passed if the user wants to restart the chat
|
|
127
|
+
userId: defaultUserId, }) => {
|
|
127
128
|
const locale = (0, extractLocale_1.default)(socket.handshake.query, socket.request.headers['accept-language']);
|
|
128
129
|
const sessionsCollection = bot.store.db.collection('sessions');
|
|
129
|
-
const { sessionId, sessionInfo: defaultSessionInfo, isNew, } = await (0, requestSessionData_1.default)(
|
|
130
|
+
const { sessionId, sessionInfo: defaultSessionInfo, isNew, } = await (0, requestSessionData_1.default)(sessionIdFromClient, socket.handshake.query, sessionsCollection, clientName, locale, props);
|
|
130
131
|
// create a channel for each session
|
|
131
132
|
socket.join(sessionId);
|
|
132
133
|
const sessionInfo = await (0, createSessionInfo_1.default)(socket, clientName, environment, defaultSessionInfo, defaultUserId, locale, props)();
|
|
133
134
|
const session = await bot.createSession(sessionId, sessionInfo);
|
|
135
|
+
if (sessionIdToTerminate) {
|
|
136
|
+
socket.leave(sessionIdToTerminate);
|
|
137
|
+
await session.dispatch((0, engine_domain_1.guestDisconnected)(sessionIdToTerminate));
|
|
138
|
+
}
|
|
134
139
|
// sending persisted state to client
|
|
135
140
|
const previousConversations = await (0, loadPreviousConversation_1.default)(bot.store, sessionId);
|
|
136
141
|
socket.emit('restore-client-state', {
|
|
@@ -155,25 +160,20 @@ const onStartChat = (socket, props, bot, clientName, environment, logger) => asy
|
|
|
155
160
|
devices: props.expandChatWindowAtStart,
|
|
156
161
|
});
|
|
157
162
|
}
|
|
158
|
-
|
|
159
|
-
socket.on('action', async (action) => {
|
|
163
|
+
registerListener(socket, 'action', async (action) => {
|
|
160
164
|
await session.dispatch(JSON.parse(action));
|
|
161
165
|
});
|
|
162
|
-
socket
|
|
166
|
+
registerListener(socket, 'disconnect', async () => {
|
|
163
167
|
await session.dispatch((0, engine_domain_1.guestDisconnected)(sessionId));
|
|
164
168
|
});
|
|
165
|
-
socket
|
|
166
|
-
sessionsCollection.updateOne({ _id: sessionId }, {
|
|
167
|
-
$set: {
|
|
168
|
-
'sessionInfo.client.payload.conversationRating': rating,
|
|
169
|
-
},
|
|
170
|
-
});
|
|
169
|
+
registerListener(socket, 'conversation-rating', async (rating) => {
|
|
170
|
+
sessionsCollection.updateOne({ _id: sessionId }, { $set: { 'sessionInfo.client.payload.conversationRating': rating } });
|
|
171
171
|
session.dispatch({
|
|
172
172
|
type: engine_domain_1.ActionTypes.CONVERSATION_RATING_FROM_GUEST,
|
|
173
173
|
payload: { rating },
|
|
174
174
|
});
|
|
175
175
|
});
|
|
176
|
-
socket
|
|
176
|
+
registerListener(socket, 'audio-message', async (buffer) => {
|
|
177
177
|
if (props.speech) {
|
|
178
178
|
try {
|
|
179
179
|
const text = await (0, speechToText_1.default)(props.speech, session.translator.locale, buffer);
|
|
@@ -188,6 +188,11 @@ const onStartChat = (socket, props, bot, clientName, environment, logger) => asy
|
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
190
|
};
|
|
191
|
+
const registerListener = (socket, event, listener) => {
|
|
192
|
+
// remove all listeners for the event to avoid multiple listeners
|
|
193
|
+
socket.removeAllListeners(event);
|
|
194
|
+
socket.on(event, listener);
|
|
195
|
+
};
|
|
191
196
|
const sendConfigurationToClient = (socket, props, bot, clientName) => {
|
|
192
197
|
// sending active language and translations to client
|
|
193
198
|
const locale = (0, extractLocale_1.default)(socket.handshake.query, socket.request.headers['accept-language']);
|
|
@@ -214,7 +219,6 @@ const sendConfigurationToClient = (socket, props, bot, clientName) => {
|
|
|
214
219
|
socket.emit('show-general-conditions');
|
|
215
220
|
}
|
|
216
221
|
// inform client whether to use start screen
|
|
217
|
-
|
|
218
|
-
socket.emit('set-use-start-screen', true);
|
|
222
|
+
socket.emit('set-use-start-screen', !!props.useStartScreen);
|
|
219
223
|
};
|
|
220
224
|
exports.CLIENT_TYPE = 'webclient';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botfabrik/engine-webclient",
|
|
3
|
-
"version": "4.66.
|
|
3
|
+
"version": "4.66.3",
|
|
4
4
|
"description": "Webclient for Botfabriks Bot Engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"tsx": "^4.16.2",
|
|
41
41
|
"typescript": "5.1.6"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "81b624663cd7588f17a1bec536a4c872fe50dc37"
|
|
44
44
|
}
|