@lvce-editor/test-worker 16.0.0 → 16.2.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
@@ -145,6 +145,7 @@ 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
 
@@ -155,12 +156,24 @@ export interface FormattingTextDocument {
155
156
  readonly uri?: string;
156
157
  }
157
158
 
159
+ export interface CompletionTextDocument {
160
+ readonly documentId?: number;
161
+ readonly languageId: string;
162
+ readonly text?: string;
163
+ readonly uri?: string;
164
+ }
165
+
158
166
  export interface FormattingEdit {
159
167
  readonly endOffset: number;
160
168
  readonly inserted: string;
161
169
  readonly startOffset: number;
162
170
  }
163
171
 
172
+ export interface CompletionItem {
173
+ readonly label: string;
174
+ readonly [key: string]: unknown;
175
+ }
176
+
164
177
  export interface FileSystemTmpDirOptions {
165
178
  readonly scheme?: string;
166
179
  }
@@ -419,6 +432,7 @@ interface ColorPicker {
419
432
 
420
433
  interface Command {
421
434
  readonly execute: (id: string, ...args: readonly any[]) => Promise<any>;
435
+ readonly executeExtensionCommand: (commandId: string, ...args: readonly any[]) => Promise<unknown>;
422
436
  }
423
437
 
424
438
  interface ContextMenu {
@@ -524,6 +538,7 @@ interface Editor {
524
538
  readonly setDeltaY: (deltaY: number) => Promise<void>;
525
539
  readonly setSelections: (selections: any) => Promise<void>;
526
540
  readonly setText: (text: string) => Promise<void>;
541
+ readonly shouldHaveDiagnosticProviderResult: (expectedDiagnostics: readonly Diagnostic[], editorId?: number) => Promise<void>;
527
542
  readonly shouldHaveDiagnostics: (expectedDiagnostics: readonly Diagnostic[]) => Promise<void>;
528
543
  readonly shouldHaveSelections: (expectedSelections: Uint32Array) => Promise<void>;
529
544
  readonly shouldHaveText: (expectedText: string) => Promise<void>;
@@ -610,6 +625,7 @@ interface Explorer {
610
625
  interface Extension {
611
626
  readonly addNodeExtension: (relativePath: string) => Promise<void>;
612
627
  readonly addWebExtension: (relativePath: string) => Promise<void>;
628
+ readonly executeCompletionProvider: (textDocument: CompletionTextDocument, ...args: readonly unknown[]) => Promise<readonly CompletionItem[]>;
613
629
  readonly executeFormattingProvider: (textDocument: FormattingTextDocument, ...args: readonly unknown[]) => Promise<readonly FormattingEdit[]>;
614
630
  }
615
631
 
@@ -1921,9 +1921,13 @@ const ActivityBar = {
1921
1921
  const execute$1 = async (id, ...args) => {
1922
1922
  return invoke(id, ...args);
1923
1923
  };
1924
+ const executeExtensionCommand = async (commandId, ...args) => {
1925
+ return invoke('ExtensionHost.executeCommand', commandId, ...args);
1926
+ };
1924
1927
 
1925
1928
  const Command = {
1926
- execute: execute$1
1929
+ execute: execute$1,
1930
+ executeExtensionCommand
1927
1931
  };
1928
1932
 
1929
1933
  const setReasoningPickerEnabled = async enabled => {
@@ -2799,7 +2803,7 @@ const DiffView = {
2799
2803
  };
2800
2804
 
2801
2805
  const isDiagnosticEqual = (actual, expected) => {
2802
- 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;
2803
2807
  };
2804
2808
 
2805
2809
  const areDiagnosticsEqual = (actual, expected) => {
@@ -3151,6 +3155,14 @@ const shouldHaveDiagnostics = async expectedDiagnostics => {
3151
3155
  throw new Error(`Expected editor to have diagnostics ${stringifiedExpected} but was ${stringifiedActual}`);
3152
3156
  }
3153
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
+ };
3154
3166
  const enableCompletionsOnType = async () => {
3155
3167
  await update$1({
3156
3168
  'editor.completionsOnType': true
@@ -3247,6 +3259,7 @@ const Editor = {
3247
3259
  setDeltaY: setDeltaY$1,
3248
3260
  setSelections,
3249
3261
  setText,
3262
+ shouldHaveDiagnosticProviderResult,
3250
3263
  shouldHaveDiagnostics,
3251
3264
  shouldHaveSelections,
3252
3265
  shouldHaveText,
@@ -3503,6 +3516,9 @@ const addWebExtension = async relativePath => {
3503
3516
  const executeFormattingProvider = async (textDocument, ...args) => {
3504
3517
  return invoke$2('Extensions.executeFormattingProvider', textDocument, ...args);
3505
3518
  };
3519
+ const executeCompletionProvider = async (textDocument, ...args) => {
3520
+ return invoke$2('Extensions.executeCompletionProvider', textDocument, ...args);
3521
+ };
3506
3522
  const addNodeExtension = async relativePath => {
3507
3523
  // TODO compute absolutePath
3508
3524
  const absolutePath = relativePath;
@@ -3512,6 +3528,7 @@ const addNodeExtension = async relativePath => {
3512
3528
  const Extension = {
3513
3529
  addNodeExtension,
3514
3530
  addWebExtension,
3531
+ executeCompletionProvider,
3515
3532
  executeFormattingProvider
3516
3533
  };
3517
3534
 
@@ -3988,10 +4005,6 @@ const FindWidget = {
3988
4005
  toggleUseRegularExpression: toggleUseRegularExpression$1
3989
4006
  };
3990
4007
 
3991
- const executeExtensionCommand = async (commandId, ...args) => {
3992
- return invoke('ExtensionHost.executeCommand', commandId, ...args);
3993
- };
3994
-
3995
4008
  const init = async (options = {}) => {
3996
4009
  await executeExtensionCommand('git.init', options);
3997
4010
  };
@@ -5341,14 +5354,18 @@ const printError = error => {
5341
5354
  };
5342
5355
 
5343
5356
  const prepareError = 'Errors.prepare';
5357
+ const ignoredCodeFrameStackLines = ['testWorkerMain.js', 'testWorkerMain.ts'];
5344
5358
  const formatPreparedError = preparedError => {
5345
5359
  const codeFrame = preparedError.codeframe || preparedError.codeFrame;
5346
5360
  return [preparedError.message, codeFrame, preparedError.stack].filter(Boolean).join('\n');
5347
5361
  };
5348
5362
  const printTestError = async error => {
5349
5363
  try {
5350
- const preparedError = await invoke$3(prepareError, error);
5351
- console.error(formatPreparedError(preparedError));
5364
+ const preparedError = await invoke$3(prepareError, error, {
5365
+ ignoredCodeFrameStackLines
5366
+ });
5367
+ const formatted = formatPreparedError(preparedError);
5368
+ console.error(formatted);
5352
5369
  } catch {
5353
5370
  printError(error);
5354
5371
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "16.0.0",
3
+ "version": "16.2.0",
4
4
  "description": "Test Worker",
5
5
  "repository": {
6
6
  "type": "git",