@lvce-editor/test-worker 15.9.0 → 16.0.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 +29 -1
- package/dist/testWorkerMain.js +98 -19
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -148,6 +148,19 @@ export interface Diagnostic {
|
|
|
148
148
|
readonly type: "error" | "warning";
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
export interface FormattingTextDocument {
|
|
152
|
+
readonly documentId?: number;
|
|
153
|
+
readonly languageId: string;
|
|
154
|
+
readonly text?: string;
|
|
155
|
+
readonly uri?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface FormattingEdit {
|
|
159
|
+
readonly endOffset: number;
|
|
160
|
+
readonly inserted: string;
|
|
161
|
+
readonly startOffset: number;
|
|
162
|
+
}
|
|
163
|
+
|
|
151
164
|
export interface FileSystemTmpDirOptions {
|
|
152
165
|
readonly scheme?: string;
|
|
153
166
|
}
|
|
@@ -183,6 +196,10 @@ export interface LayoutExpectation extends LayoutExpectationObject {
|
|
|
183
196
|
readonly groups?: readonly LayoutExpectationObject[];
|
|
184
197
|
}
|
|
185
198
|
|
|
199
|
+
export interface SelectItemOptions {
|
|
200
|
+
readonly waitUntil?: SelectItemWaitUntil;
|
|
201
|
+
}
|
|
202
|
+
|
|
186
203
|
export interface SelectItem2Options {
|
|
187
204
|
readonly callbackCommand: string;
|
|
188
205
|
readonly label: string;
|
|
@@ -233,6 +250,8 @@ export type SavedState = {
|
|
|
233
250
|
readonly layout?: LayoutState;
|
|
234
251
|
};
|
|
235
252
|
|
|
253
|
+
export type SelectItemWaitUntil = "done" | "quickPick" | "none";
|
|
254
|
+
|
|
236
255
|
export type SearchInputType = "SearchValue" | "ReplaceValue" | "IncludeValue" | "ExcludeValue";
|
|
237
256
|
|
|
238
257
|
interface Workspace {
|
|
@@ -591,6 +610,7 @@ interface Explorer {
|
|
|
591
610
|
interface Extension {
|
|
592
611
|
readonly addNodeExtension: (relativePath: string) => Promise<void>;
|
|
593
612
|
readonly addWebExtension: (relativePath: string) => Promise<void>;
|
|
613
|
+
readonly executeFormattingProvider: (textDocument: FormattingTextDocument, ...args: readonly unknown[]) => Promise<readonly FormattingEdit[]>;
|
|
594
614
|
}
|
|
595
615
|
|
|
596
616
|
interface ExtensionDetail {
|
|
@@ -675,15 +695,20 @@ interface Git {
|
|
|
675
695
|
readonly add: (pathSpec: string) => Promise<void>;
|
|
676
696
|
readonly addAll: () => Promise<void>;
|
|
677
697
|
readonly addRemote: (name: string, remoteUrl: string) => Promise<void>;
|
|
698
|
+
readonly applyStash: () => Promise<void>;
|
|
678
699
|
readonly branch: (name: string) => Promise<void>;
|
|
679
700
|
readonly checkout: (ref: string) => Promise<void>;
|
|
680
701
|
readonly cherryPick: (commitHash: string) => Promise<void>;
|
|
702
|
+
readonly cleanAll: () => Promise<void>;
|
|
681
703
|
readonly clone: (repositoryUrl: string, cwd: string) => Promise<void>;
|
|
682
704
|
readonly commit: (message: string) => Promise<void>;
|
|
705
|
+
readonly commitStaged: (message: string) => Promise<void>;
|
|
683
706
|
readonly config: (values: Record<string, string>) => Promise<void>;
|
|
684
707
|
readonly createTag: (name: string) => Promise<void>;
|
|
708
|
+
readonly createWorktree: (path: string, ref: string) => Promise<void>;
|
|
685
709
|
readonly deleteBranch: (name: string) => Promise<void>;
|
|
686
710
|
readonly deleteTag: (name: string) => Promise<void>;
|
|
711
|
+
readonly deleteWorktree: (path: string) => Promise<void>;
|
|
687
712
|
readonly fetch: (remote: string) => Promise<void>;
|
|
688
713
|
readonly fetchAll: () => Promise<void>;
|
|
689
714
|
readonly fetchPrune: () => Promise<void>;
|
|
@@ -701,8 +726,11 @@ interface Git {
|
|
|
701
726
|
readonly setUpstream: (remoteUrl: string) => Promise<void>;
|
|
702
727
|
readonly shouldHaveCommit: (message: string) => Promise<void>;
|
|
703
728
|
readonly shouldHaveInvocations: (invocations: readonly GitInvocation[]) => Promise<void>;
|
|
729
|
+
readonly stage: (pathSpec: string) => Promise<void>;
|
|
704
730
|
readonly stash: (message?: string) => Promise<void>;
|
|
705
731
|
readonly status: () => Promise<unknown>;
|
|
732
|
+
readonly undoLastCommit: () => Promise<void>;
|
|
733
|
+
readonly unstage: (pathSpec: string) => Promise<void>;
|
|
706
734
|
readonly unstash: () => Promise<void>;
|
|
707
735
|
}
|
|
708
736
|
|
|
@@ -854,7 +882,7 @@ interface QuickPick {
|
|
|
854
882
|
readonly open: () => Promise<void>;
|
|
855
883
|
readonly selectCurrentIndex: () => Promise<void>;
|
|
856
884
|
readonly selectIndex: (index: number) => Promise<void>;
|
|
857
|
-
readonly selectItem: (label: string) => Promise<void>;
|
|
885
|
+
readonly selectItem: (label: string, { waitUntil }?: SelectItemOptions) => Promise<void>;
|
|
858
886
|
readonly selectItem2: ({ callbackCommand, label }: SelectItem2Options) => Promise<void>;
|
|
859
887
|
readonly setValue: (value: string) => Promise<void>;
|
|
860
888
|
}
|
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
|
|
@@ -2806,7 +2827,7 @@ const areSelectionsEqual = (a, b) => {
|
|
|
2806
2827
|
};
|
|
2807
2828
|
|
|
2808
2829
|
const getEditorKey = async () => {
|
|
2809
|
-
const keys = await invoke$
|
|
2830
|
+
const keys = await invoke$4('Editor.getKeys');
|
|
2810
2831
|
if (keys.length === 0) {
|
|
2811
2832
|
throw new Error(`no editor found`);
|
|
2812
2833
|
}
|
|
@@ -3072,11 +3093,11 @@ const growSelection = async () => {
|
|
|
3072
3093
|
};
|
|
3073
3094
|
const getSelections = async () => {
|
|
3074
3095
|
const key = await getEditorKey();
|
|
3075
|
-
return invoke$
|
|
3096
|
+
return invoke$4('Editor.getSelections', key);
|
|
3076
3097
|
};
|
|
3077
3098
|
const shouldHaveText = async expectedText => {
|
|
3078
3099
|
const key = await getEditorKey();
|
|
3079
|
-
const text = await invoke$
|
|
3100
|
+
const text = await invoke$4('Editor.getText', key);
|
|
3080
3101
|
if (text !== expectedText) {
|
|
3081
3102
|
throw new Error(`Expected editor to have text ${expectedText} but was ${text}`);
|
|
3082
3103
|
}
|
|
@@ -3101,7 +3122,7 @@ const areTokensEqual = (actual, expected) => {
|
|
|
3101
3122
|
};
|
|
3102
3123
|
const shouldHaveTokens = async expectedTokens => {
|
|
3103
3124
|
const key = await getEditorKey();
|
|
3104
|
-
const text = await invoke$
|
|
3125
|
+
const text = await invoke$4('Editor.getTokens', key);
|
|
3105
3126
|
if (!areTokensEqual(text, expectedTokens)) {
|
|
3106
3127
|
const stringifiedActual = JSON.stringify(text);
|
|
3107
3128
|
const stringifiedExpected = JSON.stringify(expectedTokens);
|
|
@@ -3110,20 +3131,20 @@ const shouldHaveTokens = async expectedTokens => {
|
|
|
3110
3131
|
};
|
|
3111
3132
|
const shouldHaveSelections = async expectedSelections => {
|
|
3112
3133
|
const key = await getEditorKey();
|
|
3113
|
-
const selections = await invoke$
|
|
3134
|
+
const selections = await invoke$4('Editor.getSelections', key);
|
|
3114
3135
|
if (!areSelectionsEqual(selections, expectedSelections)) {
|
|
3115
3136
|
throw new Error(`Expected editor to have selections ${expectedSelections} but was ${selections}`);
|
|
3116
3137
|
}
|
|
3117
3138
|
};
|
|
3118
3139
|
const undo = async () => {
|
|
3119
|
-
await invoke$
|
|
3140
|
+
await invoke$4('Editor.undo');
|
|
3120
3141
|
};
|
|
3121
3142
|
const redo = async () => {
|
|
3122
|
-
await invoke$
|
|
3143
|
+
await invoke$4('Editor.redo');
|
|
3123
3144
|
};
|
|
3124
3145
|
const shouldHaveDiagnostics = async expectedDiagnostics => {
|
|
3125
3146
|
const key = await getEditorKey();
|
|
3126
|
-
const diagnostics = await invoke$
|
|
3147
|
+
const diagnostics = await invoke$4('Editor.getDiagnostics', key);
|
|
3127
3148
|
if (!areDiagnosticsEqual(diagnostics, expectedDiagnostics)) {
|
|
3128
3149
|
const stringifiedActual = JSON.stringify(diagnostics);
|
|
3129
3150
|
const stringifiedExpected = JSON.stringify(expectedDiagnostics);
|
|
@@ -3479,6 +3500,9 @@ const addWebExtension = async relativePath => {
|
|
|
3479
3500
|
await invoke$2('Extensions.addWebExtension', absolutePath);
|
|
3480
3501
|
await invoke('ExtensionMeta.addWebExtension', absolutePath);
|
|
3481
3502
|
};
|
|
3503
|
+
const executeFormattingProvider = async (textDocument, ...args) => {
|
|
3504
|
+
return invoke$2('Extensions.executeFormattingProvider', textDocument, ...args);
|
|
3505
|
+
};
|
|
3482
3506
|
const addNodeExtension = async relativePath => {
|
|
3483
3507
|
// TODO compute absolutePath
|
|
3484
3508
|
const absolutePath = relativePath;
|
|
@@ -3487,7 +3511,8 @@ const addNodeExtension = async relativePath => {
|
|
|
3487
3511
|
|
|
3488
3512
|
const Extension = {
|
|
3489
3513
|
addNodeExtension,
|
|
3490
|
-
addWebExtension
|
|
3514
|
+
addWebExtension,
|
|
3515
|
+
executeFormattingProvider
|
|
3491
3516
|
};
|
|
3492
3517
|
|
|
3493
3518
|
const handleClickCategory = async categoryId => {
|
|
@@ -3979,9 +4004,18 @@ const add = async pathSpec => {
|
|
|
3979
4004
|
const addAll = async () => {
|
|
3980
4005
|
await add('.');
|
|
3981
4006
|
};
|
|
4007
|
+
const stage = async pathSpec => {
|
|
4008
|
+
await executeExtensionCommand('git.stage', pathSpec);
|
|
4009
|
+
};
|
|
4010
|
+
const unstage = async pathSpec => {
|
|
4011
|
+
await executeExtensionCommand('git.unstage', pathSpec);
|
|
4012
|
+
};
|
|
3982
4013
|
const commit = async message => {
|
|
3983
4014
|
await executeExtensionCommand('git.commit', message);
|
|
3984
4015
|
};
|
|
4016
|
+
const commitStaged = async message => {
|
|
4017
|
+
await executeExtensionCommand('git.commitStaged', message);
|
|
4018
|
+
};
|
|
3985
4019
|
const push$1 = async (remoteOrOptions, branch) => {
|
|
3986
4020
|
if (typeof remoteOrOptions === 'string') {
|
|
3987
4021
|
await executeExtensionCommand('git.push', {
|
|
@@ -4013,6 +4047,9 @@ const stash = async message => {
|
|
|
4013
4047
|
const unstash = async () => {
|
|
4014
4048
|
await executeExtensionCommand('git.unstash');
|
|
4015
4049
|
};
|
|
4050
|
+
const applyStash = async () => {
|
|
4051
|
+
await executeExtensionCommand('git.applystash');
|
|
4052
|
+
};
|
|
4016
4053
|
const checkout = async ref => {
|
|
4017
4054
|
await executeExtensionCommand('git.checkout', ref);
|
|
4018
4055
|
};
|
|
@@ -4040,6 +4077,18 @@ const createTag = async name => {
|
|
|
4040
4077
|
const deleteTag = async name => {
|
|
4041
4078
|
await executeExtensionCommand('git.deleteTag', name);
|
|
4042
4079
|
};
|
|
4080
|
+
const undoLastCommit = async () => {
|
|
4081
|
+
await executeExtensionCommand('git.undoLastCommit');
|
|
4082
|
+
};
|
|
4083
|
+
const cleanAll = async () => {
|
|
4084
|
+
await executeExtensionCommand('git.cleanAll');
|
|
4085
|
+
};
|
|
4086
|
+
const createWorktree = async (path, ref) => {
|
|
4087
|
+
await executeExtensionCommand('git.createWorktree', path, ref);
|
|
4088
|
+
};
|
|
4089
|
+
const deleteWorktree = async path => {
|
|
4090
|
+
await executeExtensionCommand('git.deleteWorktree', path);
|
|
4091
|
+
};
|
|
4043
4092
|
const status = async () => {
|
|
4044
4093
|
return executeExtensionCommand('git.status');
|
|
4045
4094
|
};
|
|
@@ -4090,15 +4139,20 @@ const Git = {
|
|
|
4090
4139
|
add,
|
|
4091
4140
|
addAll,
|
|
4092
4141
|
addRemote,
|
|
4142
|
+
applyStash,
|
|
4093
4143
|
branch,
|
|
4094
4144
|
checkout,
|
|
4095
4145
|
cherryPick,
|
|
4146
|
+
cleanAll,
|
|
4096
4147
|
clone,
|
|
4097
4148
|
commit,
|
|
4149
|
+
commitStaged,
|
|
4098
4150
|
config,
|
|
4099
4151
|
createTag,
|
|
4152
|
+
createWorktree,
|
|
4100
4153
|
deleteBranch,
|
|
4101
4154
|
deleteTag,
|
|
4155
|
+
deleteWorktree,
|
|
4102
4156
|
fetch: fetch$1,
|
|
4103
4157
|
fetchAll,
|
|
4104
4158
|
fetchPrune,
|
|
@@ -4116,8 +4170,11 @@ const Git = {
|
|
|
4116
4170
|
setUpstream,
|
|
4117
4171
|
shouldHaveCommit,
|
|
4118
4172
|
shouldHaveInvocations,
|
|
4173
|
+
stage,
|
|
4119
4174
|
stash,
|
|
4120
4175
|
status,
|
|
4176
|
+
undoLastCommit,
|
|
4177
|
+
unstage,
|
|
4121
4178
|
unstash
|
|
4122
4179
|
};
|
|
4123
4180
|
|
|
@@ -4577,8 +4634,21 @@ const focusIndex$2 = async index => {
|
|
|
4577
4634
|
const focusPrevious$2 = async () => {
|
|
4578
4635
|
await invoke('QuickPick.focusPrevious');
|
|
4579
4636
|
};
|
|
4580
|
-
const selectItem = async label
|
|
4581
|
-
|
|
4637
|
+
const selectItem = async (label, {
|
|
4638
|
+
waitUntil = 'done'
|
|
4639
|
+
} = {}) => {
|
|
4640
|
+
if (waitUntil === 'done') {
|
|
4641
|
+
await invoke('QuickPick.selectItem', label);
|
|
4642
|
+
return;
|
|
4643
|
+
}
|
|
4644
|
+
const visiblePromise = waitUntil === 'quickPick' ? invoke('QuickPick.waitUntilVisible') : undefined;
|
|
4645
|
+
const promise = Promise.resolve(invoke('QuickPick.selectItem', label));
|
|
4646
|
+
if (waitUntil === 'none') {
|
|
4647
|
+
void promise.catch(() => undefined);
|
|
4648
|
+
return;
|
|
4649
|
+
}
|
|
4650
|
+
void promise.catch(() => undefined);
|
|
4651
|
+
await visiblePromise;
|
|
4582
4652
|
};
|
|
4583
4653
|
const selectIndex$3 = async index => {
|
|
4584
4654
|
await invoke('QuickPick.selectIndex', index);
|
|
@@ -5270,9 +5340,18 @@ const printError = error => {
|
|
|
5270
5340
|
}
|
|
5271
5341
|
};
|
|
5272
5342
|
|
|
5343
|
+
const prepareError = 'Errors.prepare';
|
|
5344
|
+
const formatPreparedError = preparedError => {
|
|
5345
|
+
const codeFrame = preparedError.codeframe || preparedError.codeFrame;
|
|
5346
|
+
return [preparedError.message, codeFrame, preparedError.stack].filter(Boolean).join('\n');
|
|
5347
|
+
};
|
|
5273
5348
|
const printTestError = async error => {
|
|
5274
|
-
|
|
5275
|
-
|
|
5349
|
+
try {
|
|
5350
|
+
const preparedError = await invoke$3(prepareError, error);
|
|
5351
|
+
console.error(formatPreparedError(preparedError));
|
|
5352
|
+
} catch {
|
|
5353
|
+
printError(error);
|
|
5354
|
+
}
|
|
5276
5355
|
};
|
|
5277
5356
|
|
|
5278
5357
|
const now = () => {
|
|
@@ -5831,7 +5910,7 @@ const initializeRendererWorker = async () => {
|
|
|
5831
5910
|
};
|
|
5832
5911
|
|
|
5833
5912
|
const listen = async () => {
|
|
5834
|
-
await Promise.all([
|
|
5913
|
+
await Promise.all([initializeEditorWorker(), initializeErrorWorker(), initializeExtensionHostWorker(), initializeExtensionManagementWorker(), initializeOpenerWorker(), initializeRendererWorker()]);
|
|
5835
5914
|
};
|
|
5836
5915
|
|
|
5837
5916
|
const main = async () => {
|