@lvce-editor/test-worker 14.9.0 → 14.11.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/api.d.ts CHANGED
@@ -86,6 +86,12 @@ export interface DroppedFileHandle {
86
86
  readonly id: number;
87
87
  }
88
88
 
89
+ export interface MockErrorResponse {
90
+ readonly code: string;
91
+ readonly error: string;
92
+ readonly statusCode: number;
93
+ }
94
+
89
95
  export interface MockResponseOptions {
90
96
  readonly text: string;
91
97
  }
@@ -128,6 +134,12 @@ export interface Dirent {
128
134
  readonly type: number;
129
135
  }
130
136
 
137
+ export interface LayoutExpectation extends LayoutExpectationObject {
138
+ readonly activeGroupIndex?: number;
139
+ readonly direction?: LayoutDirection;
140
+ readonly groups?: readonly LayoutExpectationObject[];
141
+ }
142
+
131
143
  export interface SelectItem2Options {
132
144
  readonly callbackCommand: string;
133
145
  readonly label: string;
@@ -137,6 +149,29 @@ export type ChatDebugInputName = "closeDetails" | "eventCategoryFilter" | "filte
137
149
 
138
150
  export type TokenRow = readonly string[];
139
151
 
152
+ export type LayoutDirection = "horizontal" | "vertical" | number;
153
+
154
+ export type LayoutExpectationValue = string | number | boolean | RegExp | null | readonly LayoutExpectationValue[] | LayoutExpectationObject;
155
+
156
+ export type LayoutExpectationObject = {
157
+ readonly [key: string]: LayoutExpectationValue | undefined;
158
+ };
159
+
160
+ export type LayoutGroupState = {
161
+ readonly id?: number | string;
162
+ readonly [key: string]: unknown;
163
+ };
164
+
165
+ export type LayoutState = {
166
+ readonly activeGroupId?: number | string;
167
+ readonly groups?: readonly LayoutGroupState[];
168
+ readonly [key: string]: unknown;
169
+ };
170
+
171
+ export type SavedState = {
172
+ readonly layout?: LayoutState;
173
+ };
174
+
140
175
  export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
141
176
 
142
177
  interface Workspace {
@@ -210,6 +245,7 @@ interface Chat {
210
245
  readonly handleProjectListContextMenu: (id: number, x: number, y: number) => Promise<void>;
211
246
  readonly handleSubmit: () => Promise<void>;
212
247
  readonly mockBackendAuthResponse: (response: any) => Promise<void>;
248
+ readonly mockBackendSetHttpErrorResponse: (response: MockErrorResponse) => Promise<void>;
213
249
  readonly mockOpenAiResponse: (options: MockOpenAiResponseOptions) => Promise<void>;
214
250
  readonly mockOpenApiRequestGetAll: () => Promise<readonly any[]>;
215
251
  readonly mockOpenApiRequestReset: () => Promise<void>;
@@ -217,6 +253,7 @@ interface Chat {
217
253
  readonly mockOpenApiStreamPushChunk: (chunk: string) => Promise<void>;
218
254
  readonly mockOpenApiStreamReset: () => Promise<void>;
219
255
  readonly openAgentModePicker: () => Promise<void>;
256
+ readonly openDebugView: () => Promise<void>;
220
257
  readonly openGitBranchPicker: () => Promise<void>;
221
258
  readonly openMockSession: (sessionId: string, messages: readonly any[]) => Promise<void>;
222
259
  readonly openModelPicker: () => Promise<void>;
@@ -236,6 +273,7 @@ interface Chat {
236
273
  readonly setSearchEnabled: (enabled: boolean) => Promise<void>;
237
274
  readonly setShowChatListTime: (showTime: boolean) => Promise<any>;
238
275
  readonly setStreamingEnabled: (enabled: boolean) => Promise<void>;
276
+ readonly setUseOwnBackend: (enabled: boolean) => Promise<void>;
239
277
  readonly shouldHaveComposerSelection: (start: number, end: number) => Promise<void>;
240
278
  readonly show: () => Promise<void>;
241
279
  readonly showComposerAttachmentPreviewOverlay: (attachmentId: string) => Promise<void>;
@@ -246,13 +284,25 @@ interface ChatDebug {
246
284
  readonly appendStoredEventForTest: (event: any) => Promise<void>;
247
285
  readonly closeDetails: () => Promise<void>;
248
286
  readonly handleClickRefresh: () => Promise<void>;
287
+ readonly handleHeaderContextMenu: (x: number, y: number) => Promise<void>;
249
288
  readonly handleInput: (name: ChatDebugInputName, value: string, checked: boolean) => Promise<void>;
289
+ readonly handlePreviewTextPointerDown: (x: number, y: number) => Promise<void>;
290
+ readonly handleRootContextMenu: () => Promise<void>;
291
+ readonly handleTableBodyContextMenu: (x: number, y: number) => Promise<void>;
292
+ readonly handleTableFocus: () => Promise<void>;
293
+ readonly handleTimelineDoubleClick: () => Promise<void>;
294
+ readonly handleTimelinePointerDown: (name: string, x: number, y: number) => Promise<void>;
295
+ readonly handleTimelinePointerMove: (x: number) => Promise<void>;
296
+ readonly handleTimelinePointerUp: (x: number) => Promise<void>;
250
297
  readonly open: (sessionId: string) => Promise<void>;
251
298
  readonly open2: ({ events, sessionId, useDevtoolsLayout }: OpenChatDebugOptions) => Promise<void>;
299
+ readonly openTab: (id: string) => Promise<void>;
300
+ readonly openTabHeaders: () => Promise<void>;
252
301
  readonly openTabPayload: () => Promise<void>;
253
302
  readonly openTabPreview: () => Promise<void>;
254
303
  readonly openTabResponse: () => Promise<void>;
255
304
  readonly openTabTiming: () => Promise<void>;
305
+ readonly openTabTokens: () => Promise<void>;
256
306
  readonly resetIndexedDbSupportForTest: () => Promise<void>;
257
307
  readonly selectEventRow: (index: number) => Promise<void>;
258
308
  readonly setEventCategoryFilter: (value: string) => Promise<void>;
@@ -264,6 +314,7 @@ interface ChatDebug {
264
314
  readonly setShowInputEvents: (enabled: boolean) => Promise<void>;
265
315
  readonly setShowResponsePartEvents: (enabled: boolean) => Promise<void>;
266
316
  readonly setTimelineRangePreset: (value: string) => Promise<void>;
317
+ readonly toggleHeadersSection: (sectionId: string) => Promise<void>;
267
318
  readonly useDevtoolsLayout: () => Promise<void>;
268
319
  }
269
320
 
@@ -603,6 +654,9 @@ interface LanguageModels {
603
654
 
604
655
  interface Layout {
605
656
  readonly handleWorkspaceRefresh: () => Promise<void>;
657
+ readonly hideSecondarySideBar: () => Promise<void>;
658
+ readonly hideSideBar: () => Promise<void>;
659
+ readonly showSecondarySideBar: () => Promise<void>;
606
660
  readonly showSideBar: () => Promise<void>;
607
661
  }
608
662
 
@@ -627,8 +681,9 @@ interface Main {
627
681
  readonly openUri: (uri: string) => Promise<void>;
628
682
  readonly save: () => Promise<void>;
629
683
  readonly saveAll: () => Promise<void>;
630
- readonly saveState: (uid: number) => Promise<any>;
684
+ readonly saveState: (uid: number) => Promise<SavedState>;
631
685
  readonly selectTab: (groupIndex: number, tabIndex: number) => Promise<void>;
686
+ readonly shouldHaveLayout: (expectedLayout: LayoutExpectation, uid?: number) => Promise<void>;
632
687
  readonly splitDown: () => Promise<void>;
633
688
  readonly splitRight: () => Promise<void>;
634
689
  }
@@ -1864,6 +1864,9 @@ const handleChatListContextMenu = async (eventX, eventY) => {
1864
1864
  const setBackendUrl = async url => {
1865
1865
  await invoke('Chat.setBackendUrl', url);
1866
1866
  };
1867
+ const setUseOwnBackend = async enabled => {
1868
+ await invoke('Chat.setUseOwnBackend', enabled);
1869
+ };
1867
1870
  const handleClickBack = async () => {
1868
1871
  await invoke('Chat.handleClickBack');
1869
1872
  };
@@ -1937,6 +1940,9 @@ const mockOpenApiStreamPushChunk = async chunk => {
1937
1940
  const openMockSession = async (sessionId, messages) => {
1938
1941
  await invoke('Chat.openMockSession', sessionId, messages);
1939
1942
  };
1943
+ const mockBackendSetHttpErrorResponse = async response => {
1944
+ await invoke('Chat.mockBackendSetHttpErrorResponse', response.statusCode, response);
1945
+ };
1940
1946
  const registerMockResponse = async options => {
1941
1947
  await invoke('Chat.registerMockResponse', options);
1942
1948
  };
@@ -2024,6 +2030,9 @@ const mockOpenAiResponse = async options => {
2024
2030
  const handleInputFocus = async () => {
2025
2031
  return execute$1('Chat.handleInputFocus', 'chat-list');
2026
2032
  };
2033
+ const openDebugView = async () => {
2034
+ return execute$1('Chat.openDebugViw');
2035
+ };
2027
2036
  const chatListFocusPrevious = async () => {
2028
2037
  return execute$1('Chat.chatListFocusPrevious');
2029
2038
  };
@@ -2084,6 +2093,7 @@ const Chat = {
2084
2093
  handleProjectListContextMenu,
2085
2094
  handleSubmit,
2086
2095
  mockBackendAuthResponse,
2096
+ mockBackendSetHttpErrorResponse,
2087
2097
  mockOpenAiResponse,
2088
2098
  mockOpenApiRequestGetAll,
2089
2099
  mockOpenApiRequestReset,
@@ -2091,6 +2101,7 @@ const Chat = {
2091
2101
  mockOpenApiStreamPushChunk,
2092
2102
  mockOpenApiStreamReset,
2093
2103
  openAgentModePicker,
2104
+ openDebugView,
2094
2105
  openGitBranchPicker,
2095
2106
  openMockSession,
2096
2107
  openModelPicker,
@@ -2110,6 +2121,7 @@ const Chat = {
2110
2121
  setSearchEnabled,
2111
2122
  setShowChatListTime,
2112
2123
  setStreamingEnabled,
2124
+ setUseOwnBackend,
2113
2125
  shouldHaveComposerSelection,
2114
2126
  show: show$7,
2115
2127
  showComposerAttachmentPreviewOverlay,
@@ -2132,12 +2144,21 @@ const open2 = async ({
2132
2144
  await handleInput$7('useDevtoolsLayout', '', true);
2133
2145
  }
2134
2146
  };
2147
+ const handleTimelineDoubleClick = async () => {
2148
+ await invoke('ChatDebug.handleTimelineDoubleClick');
2149
+ };
2135
2150
  const setEvents = async events => {
2136
2151
  await invoke('ChatDebug.setEvents', events);
2137
2152
  };
2153
+ const toggleHeadersSection = async sectionId => {
2154
+ await invoke('ChatDebug.handleInput', 'toggleHeadersSection', sectionId, false);
2155
+ };
2138
2156
  const setIndexedDbSupportForTest = async supported => {
2139
2157
  await invoke('ChatDebug.setIndexedDbSupportForTest', supported);
2140
2158
  };
2159
+ const handleRootContextMenu = async () => {
2160
+ await invoke('ChatDebug.handleRootContextMenu');
2161
+ };
2141
2162
  const resetIndexedDbSupportForTest = async () => {
2142
2163
  await invoke('ChatDebug.setIndexedDbSupportForTest');
2143
2164
  };
@@ -2150,9 +2171,15 @@ const handleInput$7 = async (name, value, checked) => {
2150
2171
  const useDevtoolsLayout = async () => {
2151
2172
  await handleInput$7('useDevtoolsLayout', '', true);
2152
2173
  };
2174
+ const handleHeaderContextMenu = async (x, y) => {
2175
+ await invoke('ChatDebug.handleHeaderContextMenu', x, y);
2176
+ };
2153
2177
  const setFilter = async value => {
2154
2178
  await handleInput$7('filter', value, false);
2155
2179
  };
2180
+ const handlePreviewTextPointerDown = async (x, y) => {
2181
+ await invoke('ChatDebug.handlePreviewTextPointerDown', x, y);
2182
+ };
2156
2183
  const setEventCategoryFilter = async value => {
2157
2184
  await handleInput$7('eventCategoryFilter', value, false);
2158
2185
  };
@@ -2165,23 +2192,44 @@ const setShowInputEvents = async enabled => {
2165
2192
  const setShowResponsePartEvents = async enabled => {
2166
2193
  await handleInput$7('showResponsePartEvents', '', enabled);
2167
2194
  };
2195
+ const handleTableFocus = async () => {
2196
+ await invoke('ChatDebug.handleTableFocus');
2197
+ };
2168
2198
  const setShowEventStreamFinishedEvents = async enabled => {
2169
2199
  await handleInput$7('showEventStreamFinishedEvents', '', enabled);
2170
2200
  };
2171
2201
  const closeDetails = async () => {
2172
2202
  await handleInput$7('closeDetails', 'close', false);
2173
2203
  };
2204
+ const openTab = async id => {
2205
+ await invoke('ChatDebug.handleInput', 'detailTab', id, false);
2206
+ };
2174
2207
  const openTabPreview = async () => {
2175
- await invoke('ChatDebug.handleInput', 'detailTab', 'preview', false);
2208
+ await openTab('preview');
2176
2209
  };
2177
2210
  const openTabPayload = async () => {
2178
- await invoke('ChatDebug.handleInput', 'detailTab', 'payload', false);
2211
+ await openTab('payload');
2179
2212
  };
2180
2213
  const openTabResponse = async () => {
2181
- await invoke('ChatDebug.handleInput', 'detailTab', 'response', false);
2214
+ await openTab('response');
2215
+ };
2216
+ const handleTimelinePointerDown = async (name, x, y) => {
2217
+ await invoke('ChatDebug.handleTimelinePointerDown', name, x, y);
2218
+ };
2219
+ const handleTimelinePointerMove = async x => {
2220
+ await invoke('ChatDebug.handleTimelinePointerMove', x);
2221
+ };
2222
+ const handleTimelinePointerUp = async x => {
2223
+ await invoke('ChatDebug.handleTimelinePointerUp', x);
2224
+ };
2225
+ const openTabTokens = async () => {
2226
+ await openTab('tokens');
2182
2227
  };
2183
2228
  const openTabTiming = async () => {
2184
- await invoke('ChatDebug.handleInput', 'detailTab', 'timing', false);
2229
+ await openTab('timing');
2230
+ };
2231
+ const openTabHeaders = async () => {
2232
+ await openTab('headers');
2185
2233
  };
2186
2234
  const setSessionId = async sessionId => {
2187
2235
  await invoke('ChatDebug.setSessionId', sessionId);
@@ -2192,18 +2240,33 @@ const appendStoredEventForTest = async event => {
2192
2240
  const handleClickRefresh = async () => {
2193
2241
  await invoke('ChatDebug.handleClickRefresh');
2194
2242
  };
2243
+ const handleTableBodyContextMenu = async (x, y) => {
2244
+ await invoke('ChatDebug.handleTableBodyContextMenu', x, y);
2245
+ };
2195
2246
 
2196
2247
  const ChatDebug = {
2197
2248
  appendStoredEventForTest,
2198
2249
  closeDetails,
2199
2250
  handleClickRefresh,
2251
+ handleHeaderContextMenu,
2200
2252
  handleInput: handleInput$7,
2253
+ handlePreviewTextPointerDown,
2254
+ handleRootContextMenu,
2255
+ handleTableBodyContextMenu,
2256
+ handleTableFocus,
2257
+ handleTimelineDoubleClick,
2258
+ handleTimelinePointerDown,
2259
+ handleTimelinePointerMove,
2260
+ handleTimelinePointerUp,
2201
2261
  open: open$a,
2202
2262
  open2,
2263
+ openTab,
2264
+ openTabHeaders,
2203
2265
  openTabPayload,
2204
2266
  openTabPreview,
2205
2267
  openTabResponse,
2206
2268
  openTabTiming,
2269
+ openTabTokens,
2207
2270
  resetIndexedDbSupportForTest,
2208
2271
  selectEventRow,
2209
2272
  setEventCategoryFilter,
@@ -2215,6 +2278,7 @@ const ChatDebug = {
2215
2278
  setShowInputEvents,
2216
2279
  setShowResponsePartEvents,
2217
2280
  setTimelineRangePreset,
2281
+ toggleHeadersSection,
2218
2282
  useDevtoolsLayout
2219
2283
  };
2220
2284
 
@@ -2344,12 +2408,92 @@ const Dialog = {
2344
2408
  showSaveFilePicker
2345
2409
  };
2346
2410
 
2411
+ const defaultMainAreaUid = 2;
2412
+ const directionMap = {
2413
+ horizontal: 1,
2414
+ vertical: 2
2415
+ };
2416
+ const isObject$1 = value => {
2417
+ return typeof value === 'object' && value !== null && !Array.isArray(value) && !(value instanceof RegExp);
2418
+ };
2419
+ const matchesExpectedArray = (actual, expected) => {
2420
+ if (!Array.isArray(actual) || actual.length !== expected.length) {
2421
+ return false;
2422
+ }
2423
+ for (let i = 0; i < expected.length; i++) {
2424
+ if (!matchesExpected(actual[i], expected[i])) {
2425
+ return false;
2426
+ }
2427
+ }
2428
+ return true;
2429
+ };
2430
+ const matchesExpectedObject = (actual, expected) => {
2431
+ if (!isObject$1(actual)) {
2432
+ return false;
2433
+ }
2434
+ for (const [childKey, childExpectedValue] of Object.entries(expected)) {
2435
+ if (childExpectedValue === undefined) {
2436
+ continue;
2437
+ }
2438
+ if (!matchesExpected(actual[childKey], childExpectedValue, childKey)) {
2439
+ return false;
2440
+ }
2441
+ }
2442
+ return true;
2443
+ };
2444
+ const matchesExpected = (actual, expected, key = '') => {
2445
+ if (key === 'direction' && typeof expected === 'string' && expected in directionMap) {
2446
+ return Object.is(actual, directionMap[expected]);
2447
+ }
2448
+ if (expected instanceof RegExp) {
2449
+ return typeof actual === 'string' && expected.test(actual);
2450
+ }
2451
+ if (Array.isArray(expected)) {
2452
+ return matchesExpectedArray(actual, expected);
2453
+ }
2454
+ if (isObject$1(expected)) {
2455
+ return matchesExpectedObject(actual, expected);
2456
+ }
2457
+ return Object.is(actual, expected);
2458
+ };
2459
+ const matchesActiveGroupIndex = (layout, activeGroupIndex) => {
2460
+ const groups = layout.groups || [];
2461
+ const group = groups[activeGroupIndex];
2462
+ if (!group) {
2463
+ return false;
2464
+ }
2465
+ return layout.activeGroupId === group.id;
2466
+ };
2467
+ const serializeForError = value => {
2468
+ return JSON.stringify(value, (_key, currentValue) => {
2469
+ if (currentValue instanceof RegExp) {
2470
+ return currentValue.toString();
2471
+ }
2472
+ return currentValue;
2473
+ });
2474
+ };
2347
2475
  const openUri = async uri => {
2348
2476
  await invoke('Main.openUri', uri);
2349
2477
  };
2350
2478
  const saveState = async uid => {
2351
2479
  return invoke('Main.saveState', uid);
2352
2480
  };
2481
+ const shouldHaveLayout = async (expectedLayout, uid = defaultMainAreaUid) => {
2482
+ const state = await saveState(uid);
2483
+ const actualLayout = state.layout;
2484
+ if (!actualLayout) {
2485
+ throw new AssertionError(`expected main layout to exist but state was ${serializeForError(state)}`);
2486
+ }
2487
+ const {
2488
+ activeGroupIndex,
2489
+ ...partialExpectedLayout
2490
+ } = expectedLayout;
2491
+ const matchesLayout = matchesExpected(actualLayout, partialExpectedLayout);
2492
+ const matchesActiveGroup = activeGroupIndex === undefined || matchesActiveGroupIndex(actualLayout, activeGroupIndex);
2493
+ if (!matchesLayout || !matchesActiveGroup) {
2494
+ throw new AssertionError(`expected main layout to match ${serializeForError(expectedLayout)} but was ${serializeForError(actualLayout)}`);
2495
+ }
2496
+ };
2353
2497
  const splitRight = async () => {
2354
2498
  await invoke('Main.splitRight');
2355
2499
  };
@@ -2440,6 +2584,7 @@ const Main = {
2440
2584
  saveAll,
2441
2585
  saveState,
2442
2586
  selectTab: selectTab$2,
2587
+ shouldHaveLayout,
2443
2588
  splitDown,
2444
2589
  splitRight
2445
2590
  };
@@ -3804,12 +3949,24 @@ const LanguageModels = {
3804
3949
  const showSideBar = async () => {
3805
3950
  await execute$1('Layout.showSideBar');
3806
3951
  };
3952
+ const hideSideBar = async () => {
3953
+ await execute$1('Layout.hideSideBar');
3954
+ };
3955
+ const showSecondarySideBar = async () => {
3956
+ await execute$1('Layout.showSecondarySideBar');
3957
+ };
3958
+ const hideSecondarySideBar = async () => {
3959
+ await execute$1('Layout.hideSecondarySideBar');
3960
+ };
3807
3961
  const handleWorkspaceRefresh = async () => {
3808
3962
  await invoke('Layout.handleWorkspaceRefresh');
3809
3963
  };
3810
3964
 
3811
3965
  const Layout = {
3812
3966
  handleWorkspaceRefresh,
3967
+ hideSecondarySideBar,
3968
+ hideSideBar,
3969
+ showSecondarySideBar,
3813
3970
  showSideBar
3814
3971
  };
3815
3972
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "14.9.0",
3
+ "version": "14.11.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",