@lvce-editor/chat-debug-view 2.2.0 → 2.4.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.
|
@@ -1028,12 +1028,13 @@ const diff2 = uid => {
|
|
|
1028
1028
|
return diff(oldState, newState);
|
|
1029
1029
|
};
|
|
1030
1030
|
|
|
1031
|
-
const Filter = 'filter';
|
|
1032
|
-
const ShowInputEvents = 'showInputEvents';
|
|
1033
|
-
|
|
1034
1031
|
const getBoolean = value => {
|
|
1035
1032
|
return value === true || value === 'true' || value === 'on' || value === '1';
|
|
1036
1033
|
};
|
|
1034
|
+
|
|
1035
|
+
const Filter = 'filter';
|
|
1036
|
+
const ShowInputEvents = 'showInputEvents';
|
|
1037
|
+
|
|
1037
1038
|
const handleInput = (state, name, value, checked) => {
|
|
1038
1039
|
if (name === Filter) {
|
|
1039
1040
|
return {
|
|
@@ -1241,6 +1242,11 @@ const getCss = () => {
|
|
|
1241
1242
|
opacity: 0.8;
|
|
1242
1243
|
}
|
|
1243
1244
|
|
|
1245
|
+
.ChatDebugViewEventCount {
|
|
1246
|
+
font-size: 12px;
|
|
1247
|
+
opacity: 0.8;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1244
1250
|
.ChatDebugViewEvents {
|
|
1245
1251
|
overflow: auto;
|
|
1246
1252
|
scrollbar-width: thin;
|
|
@@ -1450,8 +1456,9 @@ const getChatDebugViewDom = (sessionId, errorMessage, filterValue, showInputEven
|
|
|
1450
1456
|
}, text(errorMessage)];
|
|
1451
1457
|
}
|
|
1452
1458
|
const eventNodes = events.flatMap(getEventNode);
|
|
1459
|
+
const eventCountText = `${events.length} event${events.length === 1 ? '' : 's'}`;
|
|
1453
1460
|
return [{
|
|
1454
|
-
childCount:
|
|
1461
|
+
childCount: 4,
|
|
1455
1462
|
className: 'ChatDebugView',
|
|
1456
1463
|
type: Div
|
|
1457
1464
|
}, {
|
|
@@ -1478,6 +1485,10 @@ const getChatDebugViewDom = (sessionId, errorMessage, filterValue, showInputEven
|
|
|
1478
1485
|
onChange: HandleInput,
|
|
1479
1486
|
type: Input
|
|
1480
1487
|
}, text('Show input events'), {
|
|
1488
|
+
childCount: 1,
|
|
1489
|
+
className: 'ChatDebugViewEventCount',
|
|
1490
|
+
type: Div
|
|
1491
|
+
}, text(eventCountText), {
|
|
1481
1492
|
childCount: 1,
|
|
1482
1493
|
className: 'ChatDebugViewSession',
|
|
1483
1494
|
type: Div
|
|
@@ -1507,8 +1518,17 @@ const getFilteredEvents = (events, filterValue, showInputEvents) => {
|
|
|
1507
1518
|
return visibleEvents.filter(event => JSON.stringify(event).toLowerCase().includes(normalizedFilter));
|
|
1508
1519
|
};
|
|
1509
1520
|
|
|
1521
|
+
const withSessionEventIds = events => {
|
|
1522
|
+
return events.map((event, index) => {
|
|
1523
|
+
return {
|
|
1524
|
+
...event,
|
|
1525
|
+
eventId: index + 1
|
|
1526
|
+
};
|
|
1527
|
+
});
|
|
1528
|
+
};
|
|
1510
1529
|
const renderItems = (oldState, newState) => {
|
|
1511
|
-
const
|
|
1530
|
+
const eventsWithIds = withSessionEventIds(newState.events);
|
|
1531
|
+
const filteredEvents = getFilteredEvents(eventsWithIds, newState.filterValue, newState.showInputEvents);
|
|
1512
1532
|
const dom = getChatDebugViewDom(newState.sessionId, newState.errorMessage, newState.filterValue, newState.showInputEvents, filteredEvents);
|
|
1513
1533
|
return [SetDom2, newState.uid, dom];
|
|
1514
1534
|
};
|
|
@@ -1584,6 +1604,15 @@ const saveState = state => {
|
|
|
1584
1604
|
};
|
|
1585
1605
|
};
|
|
1586
1606
|
|
|
1607
|
+
const setEvents = (state, events) => {
|
|
1608
|
+
return {
|
|
1609
|
+
...state,
|
|
1610
|
+
errorMessage: '',
|
|
1611
|
+
events,
|
|
1612
|
+
initial: false
|
|
1613
|
+
};
|
|
1614
|
+
};
|
|
1615
|
+
|
|
1587
1616
|
const setSessionId = async (state, sessionId) => {
|
|
1588
1617
|
const events = await listChatViewEvents(sessionId, state.databaseName, state.dataBaseVersion, state.eventStoreName, state.sessionIdIndexName);
|
|
1589
1618
|
return {
|
|
@@ -1608,6 +1637,7 @@ const commandMap = {
|
|
|
1608
1637
|
'ChatDebug.rerender': wrapCommand(rerender),
|
|
1609
1638
|
'ChatDebug.resize': wrapCommand(resize),
|
|
1610
1639
|
'ChatDebug.saveState': wrapGetter(saveState),
|
|
1640
|
+
'ChatDebug.setEvents': wrapCommand(setEvents),
|
|
1611
1641
|
'ChatDebug.setSessionId': wrapCommand(setSessionId),
|
|
1612
1642
|
'ChatDebug.terminate': terminate
|
|
1613
1643
|
};
|