@lvce-editor/test-worker 15.10.0 → 16.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/api.d.ts +37 -1
- package/dist/testWorkerMain.js +85 -25
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -145,9 +145,35 @@ export interface Diagnostic {
|
|
|
145
145
|
readonly endRowIndex: number;
|
|
146
146
|
readonly message: string;
|
|
147
147
|
readonly rowIndex: number;
|
|
148
|
+
readonly source?: string;
|
|
148
149
|
readonly type: "error" | "warning";
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
export interface FormattingTextDocument {
|
|
153
|
+
readonly documentId?: number;
|
|
154
|
+
readonly languageId: string;
|
|
155
|
+
readonly text?: string;
|
|
156
|
+
readonly uri?: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface CompletionTextDocument {
|
|
160
|
+
readonly documentId?: number;
|
|
161
|
+
readonly languageId: string;
|
|
162
|
+
readonly text?: string;
|
|
163
|
+
readonly uri?: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface FormattingEdit {
|
|
167
|
+
readonly endOffset: number;
|
|
168
|
+
readonly inserted: string;
|
|
169
|
+
readonly startOffset: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface CompletionItem {
|
|
173
|
+
readonly label: string;
|
|
174
|
+
readonly [key: string]: unknown;
|
|
175
|
+
}
|
|
176
|
+
|
|
151
177
|
export interface FileSystemTmpDirOptions {
|
|
152
178
|
readonly scheme?: string;
|
|
153
179
|
}
|
|
@@ -183,6 +209,10 @@ export interface LayoutExpectation extends LayoutExpectationObject {
|
|
|
183
209
|
readonly groups?: readonly LayoutExpectationObject[];
|
|
184
210
|
}
|
|
185
211
|
|
|
212
|
+
export interface SelectItemOptions {
|
|
213
|
+
readonly waitUntil?: SelectItemWaitUntil;
|
|
214
|
+
}
|
|
215
|
+
|
|
186
216
|
export interface SelectItem2Options {
|
|
187
217
|
readonly callbackCommand: string;
|
|
188
218
|
readonly label: string;
|
|
@@ -233,6 +263,8 @@ export type SavedState = {
|
|
|
233
263
|
readonly layout?: LayoutState;
|
|
234
264
|
};
|
|
235
265
|
|
|
266
|
+
export type SelectItemWaitUntil = "done" | "quickPick" | "none";
|
|
267
|
+
|
|
236
268
|
export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
|
|
237
269
|
|
|
238
270
|
interface Workspace {
|
|
@@ -400,6 +432,7 @@ interface ColorPicker {
|
|
|
400
432
|
|
|
401
433
|
interface Command {
|
|
402
434
|
readonly execute: (id: string, ...args: readonly any[]) => Promise<any>;
|
|
435
|
+
readonly executeExtensionCommand: (commandId: string, ...args: readonly any[]) => Promise<unknown>;
|
|
403
436
|
}
|
|
404
437
|
|
|
405
438
|
interface ContextMenu {
|
|
@@ -505,6 +538,7 @@ interface Editor {
|
|
|
505
538
|
readonly setDeltaY: (deltaY: number) => Promise<void>;
|
|
506
539
|
readonly setSelections: (selections: any) => Promise<void>;
|
|
507
540
|
readonly setText: (text: string) => Promise<void>;
|
|
541
|
+
readonly shouldHaveDiagnosticProviderResult: (expectedDiagnostics: readonly Diagnostic[], editorId?: number) => Promise<void>;
|
|
508
542
|
readonly shouldHaveDiagnostics: (expectedDiagnostics: readonly Diagnostic[]) => Promise<void>;
|
|
509
543
|
readonly shouldHaveSelections: (expectedSelections: Uint32Array) => Promise<void>;
|
|
510
544
|
readonly shouldHaveText: (expectedText: string) => Promise<void>;
|
|
@@ -591,6 +625,8 @@ interface Explorer {
|
|
|
591
625
|
interface Extension {
|
|
592
626
|
readonly addNodeExtension: (relativePath: string) => Promise<void>;
|
|
593
627
|
readonly addWebExtension: (relativePath: string) => Promise<void>;
|
|
628
|
+
readonly executeCompletionProvider: (textDocument: CompletionTextDocument, ...args: readonly unknown[]) => Promise<readonly CompletionItem[]>;
|
|
629
|
+
readonly executeFormattingProvider: (textDocument: FormattingTextDocument, ...args: readonly unknown[]) => Promise<readonly FormattingEdit[]>;
|
|
594
630
|
}
|
|
595
631
|
|
|
596
632
|
interface ExtensionDetail {
|
|
@@ -862,7 +898,7 @@ interface QuickPick {
|
|
|
862
898
|
readonly open: () => Promise<void>;
|
|
863
899
|
readonly selectCurrentIndex: () => Promise<void>;
|
|
864
900
|
readonly selectIndex: (index: number) => Promise<void>;
|
|
865
|
-
readonly selectItem: (label: string) => Promise<void>;
|
|
901
|
+
readonly selectItem: (label: string, { waitUntil }?: SelectItemOptions) => Promise<void>;
|
|
866
902
|
readonly selectItem2: ({ callbackCommand, label }: SelectItem2Options) => Promise<void>;
|
|
867
903
|
readonly setValue: (value: string) => Promise<void>;
|
|
868
904
|
}
|
package/dist/testWorkerMain.js
CHANGED
|
@@ -1091,7 +1091,7 @@ const createMockRpc = ({
|
|
|
1091
1091
|
};
|
|
1092
1092
|
|
|
1093
1093
|
const rpcs = Object.create(null);
|
|
1094
|
-
const set$
|
|
1094
|
+
const set$8 = (id, rpc) => {
|
|
1095
1095
|
rpcs[id] = rpc;
|
|
1096
1096
|
};
|
|
1097
1097
|
const get$2 = id => {
|
|
@@ -1124,7 +1124,7 @@ const create = rpcId => {
|
|
|
1124
1124
|
const mockRpc = createMockRpc({
|
|
1125
1125
|
commandMap
|
|
1126
1126
|
});
|
|
1127
|
-
set$
|
|
1127
|
+
set$8(rpcId, mockRpc);
|
|
1128
1128
|
// @ts-ignore
|
|
1129
1129
|
mockRpc[Symbol.dispose] = () => {
|
|
1130
1130
|
remove$1(rpcId);
|
|
@@ -1133,7 +1133,7 @@ const create = rpcId => {
|
|
|
1133
1133
|
return mockRpc;
|
|
1134
1134
|
},
|
|
1135
1135
|
set(rpc) {
|
|
1136
|
-
set$
|
|
1136
|
+
set$8(rpcId, rpc);
|
|
1137
1137
|
}
|
|
1138
1138
|
};
|
|
1139
1139
|
};
|
|
@@ -1147,16 +1147,22 @@ const Web = 1;
|
|
|
1147
1147
|
const Remote = 3;
|
|
1148
1148
|
|
|
1149
1149
|
const EditorWorker = 99;
|
|
1150
|
+
const ErrorWorker = 3308;
|
|
1150
1151
|
const ExtensionHostWorker = 44;
|
|
1151
1152
|
const ExtensionManagementWorker = 9006;
|
|
1152
1153
|
const OpenerWorker = 4561;
|
|
1153
1154
|
const RendererWorker = 1;
|
|
1154
1155
|
const TestWorker = 9001;
|
|
1155
1156
|
|
|
1157
|
+
const {
|
|
1158
|
+
invoke: invoke$4,
|
|
1159
|
+
set: set$7
|
|
1160
|
+
} = create(EditorWorker);
|
|
1161
|
+
|
|
1156
1162
|
const {
|
|
1157
1163
|
invoke: invoke$3,
|
|
1158
1164
|
set: set$6
|
|
1159
|
-
} = create(
|
|
1165
|
+
} = create(ErrorWorker);
|
|
1160
1166
|
|
|
1161
1167
|
const {
|
|
1162
1168
|
set: set$5
|
|
@@ -1185,6 +1191,10 @@ const sendMessagePortToOpenerWorker = async (port, rpcId) => {
|
|
|
1185
1191
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1186
1192
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
|
|
1187
1193
|
};
|
|
1194
|
+
const sendMessagePortToErrorWorker = async (port, rpcId) => {
|
|
1195
|
+
const command = 'Errors.handleMessagePort';
|
|
1196
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1197
|
+
};
|
|
1188
1198
|
const readFile$1 = async uri => {
|
|
1189
1199
|
return invoke('FileSystem.readFile', uri);
|
|
1190
1200
|
};
|
|
@@ -1200,10 +1210,21 @@ const getPreference = async key => {
|
|
|
1200
1210
|
return await invoke('Preferences.get', key);
|
|
1201
1211
|
};
|
|
1202
1212
|
|
|
1203
|
-
const send$
|
|
1213
|
+
const send$4 = async port => {
|
|
1204
1214
|
await sendMessagePortToEditorWorker(port, TestWorker);
|
|
1205
1215
|
};
|
|
1206
1216
|
const initializeEditorWorker = async () => {
|
|
1217
|
+
const rpc = await create$3({
|
|
1218
|
+
commandMap: {},
|
|
1219
|
+
send: send$4
|
|
1220
|
+
});
|
|
1221
|
+
set$7(rpc);
|
|
1222
|
+
};
|
|
1223
|
+
|
|
1224
|
+
const send$3 = async port => {
|
|
1225
|
+
await sendMessagePortToErrorWorker(port, TestWorker);
|
|
1226
|
+
};
|
|
1227
|
+
const initializeErrorWorker = async () => {
|
|
1207
1228
|
const rpc = await create$3({
|
|
1208
1229
|
commandMap: {},
|
|
1209
1230
|
send: send$3
|
|
@@ -1900,9 +1921,13 @@ const ActivityBar = {
|
|
|
1900
1921
|
const execute$1 = async (id, ...args) => {
|
|
1901
1922
|
return invoke(id, ...args);
|
|
1902
1923
|
};
|
|
1924
|
+
const executeExtensionCommand = async (commandId, ...args) => {
|
|
1925
|
+
return invoke('ExtensionHost.executeCommand', commandId, ...args);
|
|
1926
|
+
};
|
|
1903
1927
|
|
|
1904
1928
|
const Command = {
|
|
1905
|
-
execute: execute$1
|
|
1929
|
+
execute: execute$1,
|
|
1930
|
+
executeExtensionCommand
|
|
1906
1931
|
};
|
|
1907
1932
|
|
|
1908
1933
|
const setReasoningPickerEnabled = async enabled => {
|
|
@@ -2778,7 +2803,7 @@ const DiffView = {
|
|
|
2778
2803
|
};
|
|
2779
2804
|
|
|
2780
2805
|
const isDiagnosticEqual = (actual, expected) => {
|
|
2781
|
-
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;
|
|
2806
|
+
return actual.rowIndex === expected.rowIndex && actual.columnIndex === expected.columnIndex && actual.endRowIndex === expected.endRowIndex && actual.endColumnIndex === expected.endColumnIndex && actual.message === expected.message && actual.source === expected.source && actual.type === expected.type;
|
|
2782
2807
|
};
|
|
2783
2808
|
|
|
2784
2809
|
const areDiagnosticsEqual = (actual, expected) => {
|
|
@@ -2806,7 +2831,7 @@ const areSelectionsEqual = (a, b) => {
|
|
|
2806
2831
|
};
|
|
2807
2832
|
|
|
2808
2833
|
const getEditorKey = async () => {
|
|
2809
|
-
const keys = await invoke$
|
|
2834
|
+
const keys = await invoke$4('Editor.getKeys');
|
|
2810
2835
|
if (keys.length === 0) {
|
|
2811
2836
|
throw new Error(`no editor found`);
|
|
2812
2837
|
}
|
|
@@ -3072,11 +3097,11 @@ const growSelection = async () => {
|
|
|
3072
3097
|
};
|
|
3073
3098
|
const getSelections = async () => {
|
|
3074
3099
|
const key = await getEditorKey();
|
|
3075
|
-
return invoke$
|
|
3100
|
+
return invoke$4('Editor.getSelections', key);
|
|
3076
3101
|
};
|
|
3077
3102
|
const shouldHaveText = async expectedText => {
|
|
3078
3103
|
const key = await getEditorKey();
|
|
3079
|
-
const text = await invoke$
|
|
3104
|
+
const text = await invoke$4('Editor.getText', key);
|
|
3080
3105
|
if (text !== expectedText) {
|
|
3081
3106
|
throw new Error(`Expected editor to have text ${expectedText} but was ${text}`);
|
|
3082
3107
|
}
|
|
@@ -3101,7 +3126,7 @@ const areTokensEqual = (actual, expected) => {
|
|
|
3101
3126
|
};
|
|
3102
3127
|
const shouldHaveTokens = async expectedTokens => {
|
|
3103
3128
|
const key = await getEditorKey();
|
|
3104
|
-
const text = await invoke$
|
|
3129
|
+
const text = await invoke$4('Editor.getTokens', key);
|
|
3105
3130
|
if (!areTokensEqual(text, expectedTokens)) {
|
|
3106
3131
|
const stringifiedActual = JSON.stringify(text);
|
|
3107
3132
|
const stringifiedExpected = JSON.stringify(expectedTokens);
|
|
@@ -3110,26 +3135,34 @@ const shouldHaveTokens = async expectedTokens => {
|
|
|
3110
3135
|
};
|
|
3111
3136
|
const shouldHaveSelections = async expectedSelections => {
|
|
3112
3137
|
const key = await getEditorKey();
|
|
3113
|
-
const selections = await invoke$
|
|
3138
|
+
const selections = await invoke$4('Editor.getSelections', key);
|
|
3114
3139
|
if (!areSelectionsEqual(selections, expectedSelections)) {
|
|
3115
3140
|
throw new Error(`Expected editor to have selections ${expectedSelections} but was ${selections}`);
|
|
3116
3141
|
}
|
|
3117
3142
|
};
|
|
3118
3143
|
const undo = async () => {
|
|
3119
|
-
await invoke$
|
|
3144
|
+
await invoke$4('Editor.undo');
|
|
3120
3145
|
};
|
|
3121
3146
|
const redo = async () => {
|
|
3122
|
-
await invoke$
|
|
3147
|
+
await invoke$4('Editor.redo');
|
|
3123
3148
|
};
|
|
3124
3149
|
const shouldHaveDiagnostics = async expectedDiagnostics => {
|
|
3125
3150
|
const key = await getEditorKey();
|
|
3126
|
-
const diagnostics = await invoke$
|
|
3151
|
+
const diagnostics = await invoke$4('Editor.getDiagnostics', key);
|
|
3127
3152
|
if (!areDiagnosticsEqual(diagnostics, expectedDiagnostics)) {
|
|
3128
3153
|
const stringifiedActual = JSON.stringify(diagnostics);
|
|
3129
3154
|
const stringifiedExpected = JSON.stringify(expectedDiagnostics);
|
|
3130
3155
|
throw new Error(`Expected editor to have diagnostics ${stringifiedExpected} but was ${stringifiedActual}`);
|
|
3131
3156
|
}
|
|
3132
3157
|
};
|
|
3158
|
+
const shouldHaveDiagnosticProviderResult = async (expectedDiagnostics, editorId = 1) => {
|
|
3159
|
+
const diagnostics = await invoke('ExtensionHost.executeDiagnosticProvider', editorId);
|
|
3160
|
+
if (!areDiagnosticsEqual(diagnostics, expectedDiagnostics)) {
|
|
3161
|
+
const stringifiedActual = JSON.stringify(diagnostics);
|
|
3162
|
+
const stringifiedExpected = JSON.stringify(expectedDiagnostics);
|
|
3163
|
+
throw new Error(`Expected diagnostic provider result ${stringifiedExpected} but was ${stringifiedActual}`);
|
|
3164
|
+
}
|
|
3165
|
+
};
|
|
3133
3166
|
const enableCompletionsOnType = async () => {
|
|
3134
3167
|
await update$1({
|
|
3135
3168
|
'editor.completionsOnType': true
|
|
@@ -3226,6 +3259,7 @@ const Editor = {
|
|
|
3226
3259
|
setDeltaY: setDeltaY$1,
|
|
3227
3260
|
setSelections,
|
|
3228
3261
|
setText,
|
|
3262
|
+
shouldHaveDiagnosticProviderResult,
|
|
3229
3263
|
shouldHaveDiagnostics,
|
|
3230
3264
|
shouldHaveSelections,
|
|
3231
3265
|
shouldHaveText,
|
|
@@ -3479,6 +3513,12 @@ const addWebExtension = async relativePath => {
|
|
|
3479
3513
|
await invoke$2('Extensions.addWebExtension', absolutePath);
|
|
3480
3514
|
await invoke('ExtensionMeta.addWebExtension', absolutePath);
|
|
3481
3515
|
};
|
|
3516
|
+
const executeFormattingProvider = async (textDocument, ...args) => {
|
|
3517
|
+
return invoke$2('Extensions.executeFormattingProvider', textDocument, ...args);
|
|
3518
|
+
};
|
|
3519
|
+
const executeCompletionProvider = async (textDocument, ...args) => {
|
|
3520
|
+
return invoke$2('Extensions.executeCompletionProvider', textDocument, ...args);
|
|
3521
|
+
};
|
|
3482
3522
|
const addNodeExtension = async relativePath => {
|
|
3483
3523
|
// TODO compute absolutePath
|
|
3484
3524
|
const absolutePath = relativePath;
|
|
@@ -3487,7 +3527,9 @@ const addNodeExtension = async relativePath => {
|
|
|
3487
3527
|
|
|
3488
3528
|
const Extension = {
|
|
3489
3529
|
addNodeExtension,
|
|
3490
|
-
addWebExtension
|
|
3530
|
+
addWebExtension,
|
|
3531
|
+
executeCompletionProvider,
|
|
3532
|
+
executeFormattingProvider
|
|
3491
3533
|
};
|
|
3492
3534
|
|
|
3493
3535
|
const handleClickCategory = async categoryId => {
|
|
@@ -3963,10 +4005,6 @@ const FindWidget = {
|
|
|
3963
4005
|
toggleUseRegularExpression: toggleUseRegularExpression$1
|
|
3964
4006
|
};
|
|
3965
4007
|
|
|
3966
|
-
const executeExtensionCommand = async (commandId, ...args) => {
|
|
3967
|
-
return invoke('ExtensionHost.executeCommand', commandId, ...args);
|
|
3968
|
-
};
|
|
3969
|
-
|
|
3970
4008
|
const init = async (options = {}) => {
|
|
3971
4009
|
await executeExtensionCommand('git.init', options);
|
|
3972
4010
|
};
|
|
@@ -4609,8 +4647,21 @@ const focusIndex$2 = async index => {
|
|
|
4609
4647
|
const focusPrevious$2 = async () => {
|
|
4610
4648
|
await invoke('QuickPick.focusPrevious');
|
|
4611
4649
|
};
|
|
4612
|
-
const selectItem = async label
|
|
4613
|
-
|
|
4650
|
+
const selectItem = async (label, {
|
|
4651
|
+
waitUntil = 'done'
|
|
4652
|
+
} = {}) => {
|
|
4653
|
+
if (waitUntil === 'done') {
|
|
4654
|
+
await invoke('QuickPick.selectItem', label);
|
|
4655
|
+
return;
|
|
4656
|
+
}
|
|
4657
|
+
const visiblePromise = waitUntil === 'quickPick' ? invoke('QuickPick.waitUntilVisible') : undefined;
|
|
4658
|
+
const promise = Promise.resolve(invoke('QuickPick.selectItem', label));
|
|
4659
|
+
if (waitUntil === 'none') {
|
|
4660
|
+
void promise.catch(() => undefined);
|
|
4661
|
+
return;
|
|
4662
|
+
}
|
|
4663
|
+
void promise.catch(() => undefined);
|
|
4664
|
+
await visiblePromise;
|
|
4614
4665
|
};
|
|
4615
4666
|
const selectIndex$3 = async index => {
|
|
4616
4667
|
await invoke('QuickPick.selectIndex', index);
|
|
@@ -5302,9 +5353,18 @@ const printError = error => {
|
|
|
5302
5353
|
}
|
|
5303
5354
|
};
|
|
5304
5355
|
|
|
5356
|
+
const prepareError = 'Errors.prepare';
|
|
5357
|
+
const formatPreparedError = preparedError => {
|
|
5358
|
+
const codeFrame = preparedError.codeframe || preparedError.codeFrame;
|
|
5359
|
+
return [preparedError.message, codeFrame, preparedError.stack].filter(Boolean).join('\n');
|
|
5360
|
+
};
|
|
5305
5361
|
const printTestError = async error => {
|
|
5306
|
-
|
|
5307
|
-
|
|
5362
|
+
try {
|
|
5363
|
+
const preparedError = await invoke$3(prepareError, error);
|
|
5364
|
+
console.error(formatPreparedError(preparedError));
|
|
5365
|
+
} catch {
|
|
5366
|
+
printError(error);
|
|
5367
|
+
}
|
|
5308
5368
|
};
|
|
5309
5369
|
|
|
5310
5370
|
const now = () => {
|
|
@@ -5863,7 +5923,7 @@ const initializeRendererWorker = async () => {
|
|
|
5863
5923
|
};
|
|
5864
5924
|
|
|
5865
5925
|
const listen = async () => {
|
|
5866
|
-
await Promise.all([
|
|
5926
|
+
await Promise.all([initializeEditorWorker(), initializeErrorWorker(), initializeExtensionHostWorker(), initializeExtensionManagementWorker(), initializeOpenerWorker(), initializeRendererWorker()]);
|
|
5867
5927
|
};
|
|
5868
5928
|
|
|
5869
5929
|
const main = async () => {
|