@lvce-editor/test-worker 13.10.0 → 13.12.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
@@ -128,6 +128,34 @@ interface BaseUrl {
128
128
  readonly getBaseUrl: () => string;
129
129
  }
130
130
 
131
+ interface Chat {
132
+ readonly deleteSessionAtIndex: (index: number) => Promise<void>;
133
+ readonly enterNewLine: () => Promise<void>;
134
+ readonly getSelectedSessionId: () => Promise<string>;
135
+ readonly handleClickBack: () => Promise<void>;
136
+ readonly handleClickClose: () => Promise<void>;
137
+ readonly handleClickDelete: () => Promise<void>;
138
+ readonly handleClickNew: () => Promise<void>;
139
+ readonly handleClickSettings: () => Promise<void>;
140
+ readonly handleInput: (text: string) => Promise<void>;
141
+ readonly handleModelChange: (modelId: string) => Promise<void>;
142
+ readonly handleSubmit: () => Promise<void>;
143
+ readonly mockBackendAuthResponse: (response: any) => Promise<void>;
144
+ readonly mockOpenAiResponse: (options: MockOpenAiResponseOptions) => Promise<void>;
145
+ readonly mockOpenApiRequestGetAll: () => Promise<readonly any[]>;
146
+ readonly mockOpenApiRequestReset: () => Promise<void>;
147
+ readonly mockOpenApiStreamFinish: () => Promise<void>;
148
+ readonly mockOpenApiStreamPushChunk: (chunk: string) => Promise<void>;
149
+ readonly mockOpenApiStreamReset: () => Promise<void>;
150
+ readonly rerender: () => Promise<void>;
151
+ readonly reset: () => Promise<void>;
152
+ readonly selectIndex: (index: number) => Promise<void>;
153
+ readonly setAuthEnabled: (enabled: boolean) => Promise<void>;
154
+ readonly setStreamingEnabled: (enabled: boolean) => Promise<void>;
155
+ readonly show: () => Promise<void>;
156
+ readonly useMockApi: () => Promise<void>;
157
+ }
158
+
131
159
  interface ClipBoard {
132
160
  readonly disableMemoryClipBoard: () => Promise<void>;
133
161
  readonly enableMemoryClipBoard: () => Promise<void>;
@@ -167,29 +195,6 @@ interface Dialog {
167
195
  readonly showSaveFilePicker: () => Promise<void>;
168
196
  }
169
197
 
170
- interface Chat {
171
- readonly deleteSessionAtIndex: (index: number) => Promise<void>;
172
- readonly enterNewLine: () => Promise<void>;
173
- readonly getSelectedSessionId: () => Promise<string>;
174
- readonly handleClickBack: () => Promise<void>;
175
- readonly handleClickClose: () => Promise<void>;
176
- readonly handleClickDelete: () => Promise<void>;
177
- readonly handleClickNew: () => Promise<void>;
178
- readonly handleClickSettings: () => Promise<void>;
179
- readonly handleInput: (text: string) => Promise<void>;
180
- readonly handleModelChange: (modelId: string) => Promise<void>;
181
- readonly handleSubmit: () => Promise<void>;
182
- readonly mockOpenAiResponse: (options: MockOpenAiResponseOptions) => Promise<void>;
183
- readonly mockOpenApiStreamFinish: () => Promise<void>;
184
- readonly mockOpenApiStreamPushChunk: (chunk: string) => Promise<void>;
185
- readonly rerender: () => Promise<void>;
186
- readonly reset: () => Promise<void>;
187
- readonly selectIndex: (index: number) => Promise<void>;
188
- readonly setStreamingEnabled: (enabled: boolean) => Promise<void>;
189
- readonly show: () => Promise<void>;
190
- readonly useMockApi: () => Promise<void>;
191
- }
192
-
193
198
  interface Editor {
194
199
  readonly addAllMissingImports: () => Promise<void>;
195
200
  readonly cancelSelection: () => Promise<void>;
@@ -501,6 +506,12 @@ interface Main {
501
506
  readonly splitRight: () => Promise<void>;
502
507
  }
503
508
 
509
+ interface Open {
510
+ readonly disableMemoryOpener: () => Promise<void>;
511
+ readonly enableMemoryOpener: () => Promise<void>;
512
+ readonly shouldHaveUrl: (expectedText: string | RegExp) => Promise<void>;
513
+ }
514
+
504
515
  interface Output {
505
516
  readonly clear: () => Promise<void>;
506
517
  readonly handleFilterInput: (text: string) => Promise<void>;
@@ -697,13 +708,13 @@ export interface TestApi {
697
708
  readonly About: About
698
709
  readonly ActivityBar: ActivityBar
699
710
  readonly BaseUrl: BaseUrl
711
+ readonly Chat: Chat
700
712
  readonly ClipBoard: ClipBoard
701
713
  readonly ColorPicker: ColorPicker
702
714
  readonly Command: Command
703
715
  readonly ContextMenu: ContextMenu
704
716
  readonly Developer: Developer
705
717
  readonly Dialog: Dialog
706
- readonly Chat: Chat
707
718
  readonly Editor: Editor
708
719
  readonly EditorCompletion: EditorCompletion
709
720
  readonly EditorHover: EditorHover
@@ -721,6 +732,7 @@ export interface TestApi {
721
732
  readonly KeyBoard: KeyBoard
722
733
  readonly LanguageModels: LanguageModels
723
734
  readonly Main: Main
735
+ readonly Open: Open
724
736
  readonly Output: Output
725
737
  readonly Panel: Panel
726
738
  readonly Platform: Platform
@@ -1100,11 +1100,12 @@ const Web = 1;
1100
1100
  const Remote = 3;
1101
1101
 
1102
1102
  const EditorWorker = 99;
1103
+ const OpenerWorker = 4561;
1103
1104
  const RendererWorker = 1;
1104
1105
  const TestWorker = 9001;
1105
1106
 
1106
1107
  const rpcs = Object.create(null);
1107
- const set$3 = (id, rpc) => {
1108
+ const set$4 = (id, rpc) => {
1108
1109
  rpcs[id] = rpc;
1109
1110
  };
1110
1111
  const get$1 = id => {
@@ -1137,7 +1138,7 @@ const create = rpcId => {
1137
1138
  const mockRpc = createMockRpc({
1138
1139
  commandMap
1139
1140
  });
1140
- set$3(rpcId, mockRpc);
1141
+ set$4(rpcId, mockRpc);
1141
1142
  // @ts-ignore
1142
1143
  mockRpc[Symbol.dispose] = () => {
1143
1144
  remove$1(rpcId);
@@ -1146,25 +1147,29 @@ const create = rpcId => {
1146
1147
  return mockRpc;
1147
1148
  },
1148
1149
  set(rpc) {
1149
- set$3(rpcId, rpc);
1150
+ set$4(rpcId, rpc);
1150
1151
  }
1151
1152
  };
1152
1153
  };
1153
1154
 
1154
1155
  const {
1155
1156
  invoke: invoke$1,
1156
- set: set$2
1157
+ set: set$3
1157
1158
  } = create(EditorWorker);
1158
1159
 
1159
1160
  const {
1160
1161
  invoke,
1161
1162
  invokeAndTransfer,
1162
- set: set$1
1163
+ set: set$2
1163
1164
  } = create(RendererWorker);
1164
1165
  const sendMessagePortToEditorWorker = async (port, rpcId) => {
1165
1166
  const command = 'HandleMessagePort.handleMessagePort';
1166
1167
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1167
1168
  };
1169
+ const sendMessagePortToOpenerWorker = async (port, rpcId) => {
1170
+ const command = 'HandleMessagePort.handleMessagePort';
1171
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
1172
+ };
1168
1173
  const readFile$1 = async uri => {
1169
1174
  return invoke('FileSystem.readFile', uri);
1170
1175
  };
@@ -1172,15 +1177,30 @@ const getPreference = async key => {
1172
1177
  return await invoke('Preferences.get', key);
1173
1178
  };
1174
1179
 
1175
- const send = async port => {
1180
+ const {
1181
+ set: set$1
1182
+ } = create(OpenerWorker);
1183
+
1184
+ const send$1 = async port => {
1176
1185
  await sendMessagePortToEditorWorker(port, TestWorker);
1177
1186
  };
1178
1187
  const initializeEditorWorker = async () => {
1188
+ const rpc = await LazyTransferMessagePortRpcParent.create({
1189
+ commandMap: {},
1190
+ send: send$1
1191
+ });
1192
+ set$3(rpc);
1193
+ };
1194
+
1195
+ const send = async port => {
1196
+ await sendMessagePortToOpenerWorker(port, TestWorker);
1197
+ };
1198
+ const initializeOpenerWorker = async () => {
1179
1199
  const rpc = await LazyTransferMessagePortRpcParent.create({
1180
1200
  commandMap: {},
1181
1201
  send
1182
1202
  });
1183
- set$2(rpc);
1203
+ set$1(rpc);
1184
1204
  };
1185
1205
 
1186
1206
  class AssertionError extends Error {
@@ -1700,6 +1720,111 @@ const ActivityBar = {
1700
1720
  toggleActivityBarItem
1701
1721
  };
1702
1722
 
1723
+ const handleClickBack = async () => {
1724
+ await invoke('Chat.handleClickBack');
1725
+ };
1726
+ const handleClickSettings = async () => {
1727
+ await invoke('Chat.handleClickSettings');
1728
+ };
1729
+ const selectIndex$7 = async index => {
1730
+ await invoke('Chat.selectIndex', index);
1731
+ };
1732
+ const handleClickClose = async () => {
1733
+ await invoke('Chat.handleClickClose');
1734
+ };
1735
+ const handleClickNew = async () => {
1736
+ await invoke('Chat.handleClickNew');
1737
+ };
1738
+ const enterNewLine = async () => {
1739
+ await invoke('Chat.enterNewLine');
1740
+ };
1741
+ const show$6 = async () => {
1742
+ await invoke('Layout.showSecondarySideBar');
1743
+ await invoke('Chat.reset');
1744
+ };
1745
+ const getSelectedSessionId = async () => {
1746
+ return invoke('Chat.getSelectedSessionId');
1747
+ };
1748
+ const handleInput$7 = async text => {
1749
+ await invoke('Chat.handleInput', 'composer', text, 'script');
1750
+ };
1751
+ const reset = async () => {
1752
+ await invoke('Chat.reset');
1753
+ };
1754
+ const mockOpenApiStreamFinish = async () => {
1755
+ await invoke('Chat.mockOpenApiStreamFinish');
1756
+ };
1757
+ const mockOpenApiStreamPushChunk = async chunk => {
1758
+ await invoke('Chat.mockOpenApiStreamPushChunk', chunk);
1759
+ };
1760
+ const handleSubmit = async () => {
1761
+ await invoke('Chat.handleSubmit');
1762
+ };
1763
+ const setStreamingEnabled = async enabled => {
1764
+ await invoke('Chat.setStreamingEnabled', enabled);
1765
+ };
1766
+ const useMockApi = async () => {
1767
+ await invoke('Chat.useMockApi', true);
1768
+ };
1769
+ const setAuthEnabled = async enabled => {
1770
+ await invoke('Chat.setAuthEnabled', enabled);
1771
+ };
1772
+ const mockBackendAuthResponse = async response => {
1773
+ await invoke('Chat.mockBackendAuthResponse', response);
1774
+ };
1775
+ const mockOpenApiRequestGetAll = async () => {
1776
+ return invoke('Chat.mockOpenApiRequestGetAll');
1777
+ };
1778
+ const rerender = async () => {
1779
+ await invoke('Chat.rerender');
1780
+ };
1781
+ const mockOpenApiRequestReset = async () => {
1782
+ await invoke('Chat.mockOpenApiRequestReset');
1783
+ };
1784
+ const mockOpenApiStreamReset = async () => {
1785
+ await invoke('Chat.mockOpenApiStreamReset');
1786
+ };
1787
+ const handleClickDelete = async () => {
1788
+ await invoke('Chat.handleClickDelete');
1789
+ };
1790
+ const deleteSessionAtIndex = async index => {
1791
+ await invoke('Chat.deleteSessionAtIndex', index);
1792
+ };
1793
+ const handleModelChange = async modelId => {
1794
+ await invoke('Chat.handleModelChange', modelId);
1795
+ };
1796
+ const mockOpenAiResponse = async options => {
1797
+ return invoke('Chat.mockOpenAiResponse', options);
1798
+ };
1799
+
1800
+ const Chat = {
1801
+ deleteSessionAtIndex,
1802
+ enterNewLine,
1803
+ getSelectedSessionId,
1804
+ handleClickBack,
1805
+ handleClickClose,
1806
+ handleClickDelete,
1807
+ handleClickNew,
1808
+ handleClickSettings,
1809
+ handleInput: handleInput$7,
1810
+ handleModelChange,
1811
+ handleSubmit,
1812
+ mockBackendAuthResponse,
1813
+ mockOpenAiResponse,
1814
+ mockOpenApiRequestGetAll,
1815
+ mockOpenApiRequestReset,
1816
+ mockOpenApiStreamFinish,
1817
+ mockOpenApiStreamPushChunk,
1818
+ mockOpenApiStreamReset,
1819
+ rerender,
1820
+ reset,
1821
+ selectIndex: selectIndex$7,
1822
+ setAuthEnabled,
1823
+ setStreamingEnabled,
1824
+ show: show$6,
1825
+ useMockApi
1826
+ };
1827
+
1703
1828
  const readNativeFiles = async () => {
1704
1829
  await invoke('ClipBoard.readNativeFiles');
1705
1830
  };
@@ -1712,7 +1837,7 @@ const enableMemoryClipBoard = async () => {
1712
1837
  const disableMemoryClipBoard = async () => {
1713
1838
  await invoke('ClipBoard.disableMemoryClipBoard');
1714
1839
  };
1715
- const matchesExpectedText = (actualText, expectedText) => {
1840
+ const matchesExpectedText$1 = (actualText, expectedText) => {
1716
1841
  if (typeof expectedText === 'string') {
1717
1842
  return actualText === expectedText;
1718
1843
  }
@@ -1720,7 +1845,7 @@ const matchesExpectedText = (actualText, expectedText) => {
1720
1845
  };
1721
1846
  const shouldHaveText$1 = async expectedText => {
1722
1847
  const actualText = await invoke('ClipBoard.readMemoryText');
1723
- if (!matchesExpectedText(actualText, expectedText)) {
1848
+ if (!matchesExpectedText$1(actualText, expectedText)) {
1724
1849
  throw new AssertionError(`expected clipboard to have text "${expectedText}" but was "${actualText}"`);
1725
1850
  }
1726
1851
  };
@@ -1834,91 +1959,6 @@ const Dialog = {
1834
1959
  showSaveFilePicker
1835
1960
  };
1836
1961
 
1837
- const handleClickBack = async () => {
1838
- await invoke('Chat.handleClickBack');
1839
- };
1840
- const handleClickSettings = async () => {
1841
- await invoke('Chat.handleClickSettings');
1842
- };
1843
- const selectIndex$7 = async index => {
1844
- await invoke('Chat.selectIndex', index);
1845
- };
1846
- const handleClickClose = async () => {
1847
- await invoke('Chat.handleClickClose');
1848
- };
1849
- const handleClickNew = async () => {
1850
- await invoke('Chat.handleClickNew');
1851
- };
1852
- const enterNewLine = async () => {
1853
- await invoke('Chat.enterNewLine');
1854
- };
1855
- const show$6 = async () => {
1856
- await invoke('Layout.showSecondarySideBar');
1857
- await invoke('Chat.reset');
1858
- };
1859
- const getSelectedSessionId = async () => {
1860
- return invoke('Chat.getSelectedSessionId');
1861
- };
1862
- const handleInput$7 = async text => {
1863
- await invoke('Chat.handleInput', 'composer', text, 'script');
1864
- };
1865
- const reset = async () => {
1866
- await invoke('Chat.reset');
1867
- };
1868
- const mockOpenApiStreamFinish = async () => {
1869
- await invoke('Chat.mockOpenApiStreamFinish');
1870
- };
1871
- const mockOpenApiStreamPushChunk = async chunk => {
1872
- await invoke('Chat.mockOpenApiStreamPushChunk', chunk);
1873
- };
1874
- const handleSubmit = async () => {
1875
- await invoke('Chat.handleSubmit');
1876
- };
1877
- const setStreamingEnabled = async enabled => {
1878
- await invoke('Chat.setStreamingEnabled', enabled);
1879
- };
1880
- const useMockApi = async () => {
1881
- await invoke('Chat.useMockApi', true);
1882
- };
1883
- const rerender = async () => {
1884
- await invoke('Chat.rerender');
1885
- };
1886
- const handleClickDelete = async () => {
1887
- await invoke('Chat.handleClickDelete');
1888
- };
1889
- const deleteSessionAtIndex = async index => {
1890
- await invoke('Chat.deleteSessionAtIndex', index);
1891
- };
1892
- const handleModelChange = async modelId => {
1893
- await invoke('Chat.handleModelChange', modelId);
1894
- };
1895
- const mockOpenAiResponse = async options => {
1896
- return invoke('Chat.mockOpenAiResponse', options);
1897
- };
1898
-
1899
- const Chat = {
1900
- deleteSessionAtIndex,
1901
- enterNewLine,
1902
- getSelectedSessionId,
1903
- handleClickBack,
1904
- handleClickClose,
1905
- handleClickDelete,
1906
- handleClickNew,
1907
- handleClickSettings,
1908
- handleInput: handleInput$7,
1909
- handleModelChange,
1910
- handleSubmit,
1911
- mockOpenAiResponse,
1912
- mockOpenApiStreamFinish,
1913
- mockOpenApiStreamPushChunk,
1914
- rerender,
1915
- reset,
1916
- selectIndex: selectIndex$7,
1917
- setStreamingEnabled,
1918
- show: show$6,
1919
- useMockApi
1920
- };
1921
-
1922
1962
  const isDiagnosticEqual = (actual, expected) => {
1923
1963
  return actual.rowIndex === expected.rowIndex && actual.columnIndex === expected.columnIndex && actual.endRowIndex === expected.endRowIndex && actual.endColumnIndex === expected.endColumnIndex && actual.message === expected.message && actual.type === expected.type;
1924
1964
  };
@@ -3334,6 +3374,31 @@ const Main = {
3334
3374
  splitRight
3335
3375
  };
3336
3376
 
3377
+ const enableMemoryOpener = async () => {
3378
+ await invoke('Open.enableMemoryOpener');
3379
+ };
3380
+ const disableMemoryOpener = async () => {
3381
+ await invoke('Open.disableMemoryOpener');
3382
+ };
3383
+ const matchesExpectedText = (actualText, expectedText) => {
3384
+ if (typeof expectedText === 'string') {
3385
+ return actualText === expectedText;
3386
+ }
3387
+ return expectedText.test(actualText);
3388
+ };
3389
+ const shouldHaveUrl = async expectedText => {
3390
+ const actualText = await invoke('Open.readMemoryUrl');
3391
+ if (!matchesExpectedText(actualText, expectedText)) {
3392
+ throw new AssertionError(`expected opened url to be "${expectedText}" but was "${actualText}"`);
3393
+ }
3394
+ };
3395
+
3396
+ const Open = {
3397
+ disableMemoryOpener,
3398
+ enableMemoryOpener,
3399
+ shouldHaveUrl
3400
+ };
3401
+
3337
3402
  const open$3 = async id => {
3338
3403
  await invoke('Layout.showPanel', id);
3339
3404
  };
@@ -4126,6 +4191,7 @@ const createApi = (platform, assetDir) => {
4126
4191
  LanguageModels,
4127
4192
  Locator: createLocator,
4128
4193
  Main,
4194
+ Open,
4129
4195
  Output,
4130
4196
  Panel,
4131
4197
  Platform,
@@ -4400,11 +4466,11 @@ const initializeRendererWorker = async () => {
4400
4466
  const rpc = await WebWorkerRpcClient.create({
4401
4467
  commandMap: commandMap
4402
4468
  });
4403
- set$1(rpc);
4469
+ set$2(rpc);
4404
4470
  };
4405
4471
 
4406
4472
  const listen = async () => {
4407
- await Promise.all([initializeRendererWorker(), initializeEditorWorker()]);
4473
+ await Promise.all([initializeRendererWorker(), initializeEditorWorker(), initializeOpenerWorker()]);
4408
4474
  };
4409
4475
 
4410
4476
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "13.10.0",
3
+ "version": "13.12.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",