@lvce-editor/chat-debug-view 7.0.0 → 7.1.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/dist/chatDebugViewWorkerMain.js +139 -66
- package/package.json +1 -1
|
@@ -1128,6 +1128,7 @@ const Text = 12;
|
|
|
1128
1128
|
const Th = 13;
|
|
1129
1129
|
const THead = 14;
|
|
1130
1130
|
const Tr = 15;
|
|
1131
|
+
const Section = 41;
|
|
1131
1132
|
const Search = 42;
|
|
1132
1133
|
const Label = 66;
|
|
1133
1134
|
const Reference = 100;
|
|
@@ -1286,6 +1287,41 @@ const terminate = () => {
|
|
|
1286
1287
|
globalThis.close();
|
|
1287
1288
|
};
|
|
1288
1289
|
|
|
1290
|
+
const appendEvent = async event => {
|
|
1291
|
+
return invoke$1('ChatStorage.appendEvent', event);
|
|
1292
|
+
};
|
|
1293
|
+
const listChatViewEvents$1 = async sessionId => {
|
|
1294
|
+
return invoke$1('ChatStorage.listChatViewEvents', sessionId);
|
|
1295
|
+
};
|
|
1296
|
+
const loadSelectedEvent$1 = async (sessionId, eventId, type) => {
|
|
1297
|
+
return invoke$1('ChatStorage.loadSelectedEvent', sessionId, eventId, type);
|
|
1298
|
+
};
|
|
1299
|
+
|
|
1300
|
+
const appendStoredEventForTestDependencies = {
|
|
1301
|
+
appendEvent: appendEvent
|
|
1302
|
+
};
|
|
1303
|
+
const appendStoredEventForTest = async (state, event) => {
|
|
1304
|
+
await appendStoredEventForTestDependencies.appendEvent(event);
|
|
1305
|
+
return state;
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1308
|
+
const Response = 'response';
|
|
1309
|
+
const Preview = 'preview';
|
|
1310
|
+
const Timing = 'timing';
|
|
1311
|
+
const detailTabs = [Preview, Response, Timing];
|
|
1312
|
+
const isDetailTab = value => {
|
|
1313
|
+
return value === Response || value === Preview || value === Timing;
|
|
1314
|
+
};
|
|
1315
|
+
const getDetailTabLabel = value => {
|
|
1316
|
+
if (value === Preview) {
|
|
1317
|
+
return 'Preview';
|
|
1318
|
+
}
|
|
1319
|
+
if (value === Timing) {
|
|
1320
|
+
return 'Timing';
|
|
1321
|
+
}
|
|
1322
|
+
return 'Response';
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1289
1325
|
const createEventCategoryFilterOptions = () => {
|
|
1290
1326
|
return [{
|
|
1291
1327
|
label: 'All',
|
|
@@ -1345,6 +1381,34 @@ const parseFilterValue = filterValue => {
|
|
|
1345
1381
|
};
|
|
1346
1382
|
};
|
|
1347
1383
|
|
|
1384
|
+
const validEventCategoryFilters = new Set([All, Network, Stream, Tools, Ui]);
|
|
1385
|
+
const isSavedState = value => {
|
|
1386
|
+
return typeof value === 'object' && value !== null;
|
|
1387
|
+
};
|
|
1388
|
+
const getRestoredEventCategoryFilter = (savedState, currentEventCategoryFilter) => {
|
|
1389
|
+
if (typeof savedState.eventCategoryFilter === 'string' && validEventCategoryFilters.has(savedState.eventCategoryFilter)) {
|
|
1390
|
+
return savedState.eventCategoryFilter;
|
|
1391
|
+
}
|
|
1392
|
+
if (typeof savedState.filterValue === 'string') {
|
|
1393
|
+
return parseFilterValue(savedState.filterValue).eventCategoryFilter;
|
|
1394
|
+
}
|
|
1395
|
+
return currentEventCategoryFilter;
|
|
1396
|
+
};
|
|
1397
|
+
const restoreSavedState = (state, savedState) => {
|
|
1398
|
+
if (!isSavedState(savedState)) {
|
|
1399
|
+
return state;
|
|
1400
|
+
}
|
|
1401
|
+
return {
|
|
1402
|
+
...state,
|
|
1403
|
+
eventCategoryFilter: getRestoredEventCategoryFilter(savedState, state.eventCategoryFilter),
|
|
1404
|
+
filterValue: typeof savedState.filterValue === 'string' ? savedState.filterValue : state.filterValue,
|
|
1405
|
+
selectedDetailTab: typeof savedState.selectedDetailTab === 'string' && isDetailTab(savedState.selectedDetailTab) ? savedState.selectedDetailTab : state.selectedDetailTab,
|
|
1406
|
+
selectedEventId: typeof savedState.selectedEventId === 'number' || savedState.selectedEventId === null ? savedState.selectedEventId : state.selectedEventId,
|
|
1407
|
+
timelineEndSeconds: typeof savedState.timelineEndSeconds === 'string' ? savedState.timelineEndSeconds : state.timelineEndSeconds,
|
|
1408
|
+
timelineStartSeconds: typeof savedState.timelineStartSeconds === 'string' ? savedState.timelineStartSeconds : state.timelineStartSeconds
|
|
1409
|
+
};
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1348
1412
|
const {
|
|
1349
1413
|
get,
|
|
1350
1414
|
getCommandIds,
|
|
@@ -1354,23 +1418,6 @@ const {
|
|
|
1354
1418
|
wrapGetter
|
|
1355
1419
|
} = create$1();
|
|
1356
1420
|
|
|
1357
|
-
const Response = 'response';
|
|
1358
|
-
const Preview = 'preview';
|
|
1359
|
-
const Timing = 'timing';
|
|
1360
|
-
const detailTabs = [Preview, Response, Timing];
|
|
1361
|
-
const isDetailTab = value => {
|
|
1362
|
-
return value === Response || value === Preview || value === Timing;
|
|
1363
|
-
};
|
|
1364
|
-
const getDetailTabLabel = value => {
|
|
1365
|
-
if (value === Preview) {
|
|
1366
|
-
return 'Preview';
|
|
1367
|
-
}
|
|
1368
|
-
if (value === Timing) {
|
|
1369
|
-
return 'Timing';
|
|
1370
|
-
}
|
|
1371
|
-
return 'Response';
|
|
1372
|
-
};
|
|
1373
|
-
|
|
1374
1421
|
const defaultTableWidth = 480;
|
|
1375
1422
|
const minTableWidth = 240;
|
|
1376
1423
|
const minDetailsWidth = 280;
|
|
@@ -1436,43 +1483,19 @@ const createDefaultState = () => {
|
|
|
1436
1483
|
};
|
|
1437
1484
|
};
|
|
1438
1485
|
|
|
1439
|
-
const validEventCategoryFilters = new Set([All, Network, Stream, Tools, Ui]);
|
|
1440
|
-
const getRestoredEventCategoryFilter = savedState => {
|
|
1441
|
-
if (typeof savedState.eventCategoryFilter === 'string' && validEventCategoryFilters.has(savedState.eventCategoryFilter)) {
|
|
1442
|
-
return savedState.eventCategoryFilter;
|
|
1443
|
-
}
|
|
1444
|
-
if (typeof savedState.filterValue === 'string') {
|
|
1445
|
-
return parseFilterValue(savedState.filterValue).eventCategoryFilter;
|
|
1446
|
-
}
|
|
1447
|
-
return All;
|
|
1448
|
-
};
|
|
1449
1486
|
const create = (uid, uri, x, y, width, height, platform, assetDir, sessionId = '', databaseName = 'lvce-chat-view-sessions', dataBaseVersion = 2, eventStoreName = 'chat-view-events', sessionIdIndexName = 'sessionId', savedState = {}) => {
|
|
1450
1487
|
const defaultState = createDefaultState();
|
|
1451
|
-
const {
|
|
1452
|
-
filterValue,
|
|
1453
|
-
selectedEventId,
|
|
1454
|
-
tableWidth,
|
|
1455
|
-
timelineEndSeconds,
|
|
1456
|
-
timelineStartSeconds
|
|
1457
|
-
} = savedState;
|
|
1458
|
-
const restoredEventCategoryFilter = getRestoredEventCategoryFilter(savedState);
|
|
1459
1488
|
const state = {
|
|
1460
|
-
...defaultState,
|
|
1489
|
+
...restoreSavedState(defaultState, savedState),
|
|
1461
1490
|
assetDir,
|
|
1462
1491
|
databaseName,
|
|
1463
1492
|
dataBaseVersion,
|
|
1464
|
-
eventCategoryFilter: restoredEventCategoryFilter,
|
|
1465
1493
|
eventStoreName,
|
|
1466
|
-
filterValue: filterValue ?? defaultState.filterValue,
|
|
1467
1494
|
height,
|
|
1468
1495
|
initial: true,
|
|
1469
1496
|
platform,
|
|
1470
|
-
selectedEventId: selectedEventId ?? defaultState.selectedEventId,
|
|
1471
1497
|
sessionId,
|
|
1472
1498
|
sessionIdIndexName,
|
|
1473
|
-
tableWidth: tableWidth ?? defaultState.tableWidth,
|
|
1474
|
-
timelineEndSeconds: timelineEndSeconds ?? defaultState.timelineEndSeconds,
|
|
1475
|
-
timelineStartSeconds: timelineStartSeconds ?? defaultState.timelineStartSeconds,
|
|
1476
1499
|
uid,
|
|
1477
1500
|
uri,
|
|
1478
1501
|
width,
|
|
@@ -1861,13 +1884,6 @@ const getTimelineInfo = (events, startValue, endValue) => {
|
|
|
1861
1884
|
};
|
|
1862
1885
|
};
|
|
1863
1886
|
|
|
1864
|
-
const listChatViewEvents$1 = async sessionId => {
|
|
1865
|
-
return invoke$1('ChatStorage.listChatViewEvents', sessionId);
|
|
1866
|
-
};
|
|
1867
|
-
const loadSelectedEvent$1 = async (sessionId, eventId, type) => {
|
|
1868
|
-
return invoke$1('ChatStorage.loadSelectedEvent', sessionId, eventId, type);
|
|
1869
|
-
};
|
|
1870
|
-
|
|
1871
1887
|
const listChatViewEventsDependencies = {
|
|
1872
1888
|
listChatViewEventsFromWorker: listChatViewEvents$1
|
|
1873
1889
|
};
|
|
@@ -2631,8 +2647,8 @@ const handleShowResponsePartEvents = (state, checked) => {
|
|
|
2631
2647
|
return withPreservedSelection$1(state, nextState);
|
|
2632
2648
|
};
|
|
2633
2649
|
|
|
2634
|
-
const loadContent = async state => {
|
|
2635
|
-
return loadEventsFromUri(state);
|
|
2650
|
+
const loadContent = async (state, savedState) => {
|
|
2651
|
+
return loadEventsFromUri(restoreSavedState(state, savedState));
|
|
2636
2652
|
};
|
|
2637
2653
|
|
|
2638
2654
|
const getCss = state => {
|
|
@@ -2656,9 +2672,58 @@ const getCss = state => {
|
|
|
2656
2672
|
contain: strict;
|
|
2657
2673
|
}
|
|
2658
2674
|
|
|
2675
|
+
.ChatDebugViewDetailsBottom {
|
|
2676
|
+
display: flex;
|
|
2677
|
+
contain: strict;
|
|
2678
|
+
flex:1
|
|
2679
|
+
|
|
2680
|
+
}
|
|
2659
2681
|
.ChatDebugViewEvent {
|
|
2660
2682
|
contain: content
|
|
2661
2683
|
}
|
|
2684
|
+
|
|
2685
|
+
.row {
|
|
2686
|
+
flex-shrink: 0;
|
|
2687
|
+
}
|
|
2688
|
+
|
|
2689
|
+
.ChatDebugViewRefreshButton {
|
|
2690
|
+
display: inline-flex;
|
|
2691
|
+
align-items: center;
|
|
2692
|
+
justify-content: center;
|
|
2693
|
+
flex: none;
|
|
2694
|
+
min-height: 28px;
|
|
2695
|
+
padding: 0 10px;
|
|
2696
|
+
border: 1px solid rgba(255, 255, 255, 0.16);
|
|
2697
|
+
border-radius: 6px;
|
|
2698
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
|
|
2699
|
+
color: inherit;
|
|
2700
|
+
font: inherit;
|
|
2701
|
+
font-size: 12px;
|
|
2702
|
+
font-weight: 500;
|
|
2703
|
+
line-height: 1;
|
|
2704
|
+
white-space: nowrap;
|
|
2705
|
+
cursor: pointer;
|
|
2706
|
+
transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
.ChatDebugViewRefreshButton:hover {
|
|
2710
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
|
|
2711
|
+
border-color: rgba(255, 255, 255, 0.24);
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
.ChatDebugViewRefreshButton:active {
|
|
2715
|
+
transform: translateY(1px);
|
|
2716
|
+
}
|
|
2717
|
+
|
|
2718
|
+
.ChatDebugViewRefreshButton:focus-visible {
|
|
2719
|
+
outline: 2px solid rgba(255, 255, 255, 0.4);
|
|
2720
|
+
outline-offset: 1px;
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
.ChatDebugViewEventRow:hover {
|
|
2724
|
+
background: var(--ListHoverBackground);
|
|
2725
|
+
color: var(--ListHoverForeground);
|
|
2726
|
+
}
|
|
2662
2727
|
`;
|
|
2663
2728
|
};
|
|
2664
2729
|
|
|
@@ -2997,6 +3062,7 @@ const ChatDebugViewTable = 'ChatDebugViewTable';
|
|
|
2997
3062
|
const ChatDebugViewTableBody = 'ChatDebugViewTableBody';
|
|
2998
3063
|
const ChatDebugViewTableHeader = 'ChatDebugViewTableHeader';
|
|
2999
3064
|
const ChatDebugViewTableHeaderRow = 'ChatDebugViewTableHeaderRow';
|
|
3065
|
+
const TableRowEven = 'TableRowEven';
|
|
3000
3066
|
const ChatDebugViewTimeline = 'ChatDebugViewTimeline';
|
|
3001
3067
|
const ChatDebugViewTimelineBucket = 'ChatDebugViewTimelineBucket';
|
|
3002
3068
|
const ChatDebugViewTimelineBucketBar = 'ChatDebugViewTimelineBucketBar';
|
|
@@ -3221,7 +3287,7 @@ const getDetailsDom = (previewEventNodes, responseEventNodes = previewEventNodes
|
|
|
3221
3287
|
return [{
|
|
3222
3288
|
childCount: 2,
|
|
3223
3289
|
className: ChatDebugViewDetails,
|
|
3224
|
-
type:
|
|
3290
|
+
type: Section
|
|
3225
3291
|
}, {
|
|
3226
3292
|
childCount: 2,
|
|
3227
3293
|
className: ChatDebugViewDetailsTop,
|
|
@@ -3334,12 +3400,13 @@ const getStatusText = event => {
|
|
|
3334
3400
|
|
|
3335
3401
|
const getDevtoolsRows = (events, selectedEventIndex) => {
|
|
3336
3402
|
return events.flatMap((event, i) => {
|
|
3403
|
+
const isEvenRow = i % 2 === 1;
|
|
3337
3404
|
const isSelected = selectedEventIndex === i;
|
|
3338
3405
|
const isErrorStatus = hasErrorStatus(event);
|
|
3339
3406
|
const rowIndex = String(i);
|
|
3340
3407
|
return [{
|
|
3341
3408
|
childCount: 3,
|
|
3342
|
-
className: joinClassNames(ChatDebugViewEventRow, isSelected && ChatDebugViewEventRowSelected),
|
|
3409
|
+
className: joinClassNames(ChatDebugViewEventRow, isEvenRow && TableRowEven, isSelected && ChatDebugViewEventRowSelected),
|
|
3343
3410
|
'data-index': rowIndex,
|
|
3344
3411
|
type: Tr
|
|
3345
3412
|
}, {
|
|
@@ -3784,7 +3851,7 @@ const getTimelineNodes = (timelineEvents, timelineStartSeconds, timelineEndSecon
|
|
|
3784
3851
|
return [{
|
|
3785
3852
|
childCount: 2,
|
|
3786
3853
|
className: ChatDebugViewTimeline,
|
|
3787
|
-
type:
|
|
3854
|
+
type: Section
|
|
3788
3855
|
}, {
|
|
3789
3856
|
childCount: 1,
|
|
3790
3857
|
className: ChatDebugViewTimelineTop,
|
|
@@ -3825,10 +3892,12 @@ const getDevtoolsDom = (events, selectedEvent, selectedEventIndex, timelineEvent
|
|
|
3825
3892
|
return [{
|
|
3826
3893
|
childCount: mainChildCount,
|
|
3827
3894
|
className: ChatDebugViewDevtoolsMain,
|
|
3895
|
+
role: 'none',
|
|
3828
3896
|
type: Div
|
|
3829
3897
|
}, ...timelineNodes, {
|
|
3830
3898
|
childCount: splitChildCount,
|
|
3831
3899
|
className: ChatDebugViewDevtoolsSplit,
|
|
3900
|
+
role: 'none',
|
|
3832
3901
|
type: Div
|
|
3833
3902
|
}, {
|
|
3834
3903
|
childCount: 1,
|
|
@@ -3988,12 +4057,20 @@ const render2 = (uid, diffResult) => {
|
|
|
3988
4057
|
|
|
3989
4058
|
const renderEventListeners = () => {
|
|
3990
4059
|
return [{
|
|
4060
|
+
name: HandleHeaderContextMenu,
|
|
4061
|
+
params: ['handleHeaderContextMenu'],
|
|
4062
|
+
preventDefault: true
|
|
4063
|
+
}, {
|
|
3991
4064
|
name: HandleEventRowClick,
|
|
3992
4065
|
params: ['handleEventRowClick', 'event.target.dataset.index', Button]
|
|
3993
4066
|
}, {
|
|
3994
4067
|
name: HandleTableBodyContextMenu,
|
|
3995
4068
|
params: ['handleTableBodyContextMenu', ClientX, ClientY],
|
|
3996
4069
|
preventDefault: true
|
|
4070
|
+
}, {
|
|
4071
|
+
name: HandleDetailsContextMenu,
|
|
4072
|
+
params: ['handleDetailsContextMenu'],
|
|
4073
|
+
preventDefault: true
|
|
3997
4074
|
}, {
|
|
3998
4075
|
name: HandleFilterInput,
|
|
3999
4076
|
params: ['handleInput', TargetName, TargetValue]
|
|
@@ -4012,6 +4089,9 @@ const renderEventListeners = () => {
|
|
|
4012
4089
|
}, {
|
|
4013
4090
|
name: HandleClickRefresh,
|
|
4014
4091
|
params: ['handleClickRefresh']
|
|
4092
|
+
}, {
|
|
4093
|
+
name: HandleTableKeyDown,
|
|
4094
|
+
params: ['handleTableKeyDown', 'event.key']
|
|
4015
4095
|
}, {
|
|
4016
4096
|
name: HandleSashPointerDown,
|
|
4017
4097
|
params: ['handleSashPointerDown', ClientX, ClientY],
|
|
@@ -4067,28 +4147,20 @@ const saveState = state => {
|
|
|
4067
4147
|
const {
|
|
4068
4148
|
eventCategoryFilter,
|
|
4069
4149
|
filterValue,
|
|
4070
|
-
|
|
4150
|
+
selectedDetailTab,
|
|
4071
4151
|
selectedEventId,
|
|
4072
4152
|
sessionId,
|
|
4073
|
-
tableWidth,
|
|
4074
4153
|
timelineEndSeconds,
|
|
4075
|
-
timelineStartSeconds
|
|
4076
|
-
width,
|
|
4077
|
-
x,
|
|
4078
|
-
y
|
|
4154
|
+
timelineStartSeconds
|
|
4079
4155
|
} = state;
|
|
4080
4156
|
return {
|
|
4081
4157
|
eventCategoryFilter,
|
|
4082
4158
|
filterValue,
|
|
4083
|
-
|
|
4159
|
+
selectedDetailTab,
|
|
4084
4160
|
selectedEventId,
|
|
4085
4161
|
sessionId,
|
|
4086
|
-
tableWidth,
|
|
4087
4162
|
timelineEndSeconds,
|
|
4088
|
-
timelineStartSeconds
|
|
4089
|
-
width,
|
|
4090
|
-
x,
|
|
4091
|
-
y
|
|
4163
|
+
timelineStartSeconds
|
|
4092
4164
|
};
|
|
4093
4165
|
};
|
|
4094
4166
|
|
|
@@ -4137,6 +4209,7 @@ const setSessionId = async (state, sessionId) => {
|
|
|
4137
4209
|
};
|
|
4138
4210
|
|
|
4139
4211
|
const commandMap = {
|
|
4212
|
+
'ChatDebug.appendStoredEventForTest': wrapCommand(appendStoredEventForTest),
|
|
4140
4213
|
'ChatDebug.create': create,
|
|
4141
4214
|
'ChatDebug.diff2': diff2,
|
|
4142
4215
|
'ChatDebug.getCommandIds': getCommandIds,
|