@theia/plugin-ext 1.32.0-next.8 → 1.32.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.
Files changed (78) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +3 -3
  2. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc.d.ts +3 -3
  4. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  5. package/lib/common/plugin-api-rpc.js +3 -3
  6. package/lib/common/plugin-api-rpc.js.map +1 -1
  7. package/lib/hosted/node/hosted-plugin-localization-service.d.ts +2 -2
  8. package/lib/hosted/node/hosted-plugin-localization-service.d.ts.map +1 -1
  9. package/lib/hosted/node/hosted-plugin-localization-service.js +4 -4
  10. package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -1
  11. package/lib/main/browser/authentication-main.js +2 -2
  12. package/lib/main/browser/authentication-main.js.map +1 -1
  13. package/lib/main/browser/languages-main.d.ts +5 -2
  14. package/lib/main/browser/languages-main.d.ts.map +1 -1
  15. package/lib/main/browser/languages-main.js +20 -11
  16. package/lib/main/browser/languages-main.js.map +1 -1
  17. package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts.map +1 -1
  18. package/lib/main/browser/menus/plugin-menu-command-adapter.js +3 -1
  19. package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -1
  20. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  21. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  22. package/lib/main/browser/text-editor-main.d.ts.map +1 -1
  23. package/lib/main/browser/text-editor-main.js +3 -2
  24. package/lib/main/browser/text-editor-main.js.map +1 -1
  25. package/lib/main/browser/theme-icon-override.js +31 -0
  26. package/lib/main/browser/theme-icon-override.js.map +1 -1
  27. package/lib/main/browser/view/plugin-tree-view-node-label-provider.js +1 -1
  28. package/lib/main/browser/view/plugin-tree-view-node-label-provider.js.map +1 -1
  29. package/lib/main/browser/view/tree-view-widget.d.ts +3 -5
  30. package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
  31. package/lib/main/browser/view/tree-view-widget.js +59 -35
  32. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  33. package/lib/main/browser/view/tree-views-main.d.ts.map +1 -1
  34. package/lib/main/browser/view/tree-views-main.js +0 -7
  35. package/lib/main/browser/view/tree-views-main.js.map +1 -1
  36. package/lib/plugin/languages.d.ts.map +1 -1
  37. package/lib/plugin/languages.js.map +1 -1
  38. package/lib/plugin/plugin-context.d.ts +2 -5
  39. package/lib/plugin/plugin-context.d.ts.map +1 -1
  40. package/lib/plugin/plugin-context.js +26 -8
  41. package/lib/plugin/plugin-context.js.map +1 -1
  42. package/lib/plugin/preference-registry.d.ts.map +1 -1
  43. package/lib/plugin/preference-registry.js +3 -3
  44. package/lib/plugin/preference-registry.js.map +1 -1
  45. package/lib/plugin/quick-open.d.ts.map +1 -1
  46. package/lib/plugin/quick-open.js +15 -10
  47. package/lib/plugin/quick-open.js.map +1 -1
  48. package/lib/plugin/terminal-ext.d.ts +1 -1
  49. package/lib/plugin/terminal-ext.d.ts.map +1 -1
  50. package/lib/plugin/terminal-ext.js.map +1 -1
  51. package/lib/plugin/type-converters.d.ts.map +1 -1
  52. package/lib/plugin/type-converters.js +14 -2
  53. package/lib/plugin/type-converters.js.map +1 -1
  54. package/lib/plugin/types-impl.d.ts +4 -0
  55. package/lib/plugin/types-impl.d.ts.map +1 -1
  56. package/lib/plugin/types-impl.js +8 -3
  57. package/lib/plugin/types-impl.js.map +1 -1
  58. package/package.json +28 -28
  59. package/src/common/plugin-api-rpc-model.ts +3 -3
  60. package/src/common/plugin-api-rpc.ts +6 -6
  61. package/src/hosted/node/hosted-plugin-localization-service.ts +5 -5
  62. package/src/main/browser/authentication-main.ts +2 -2
  63. package/src/main/browser/languages-main.ts +46 -28
  64. package/src/main/browser/menus/plugin-menu-command-adapter.ts +3 -1
  65. package/src/main/browser/plugin-contribution-handler.ts +2 -1
  66. package/src/main/browser/style/index.css +11 -6
  67. package/src/main/browser/text-editor-main.ts +3 -2
  68. package/src/main/browser/theme-icon-override.ts +31 -0
  69. package/src/main/browser/view/plugin-tree-view-node-label-provider.ts +1 -1
  70. package/src/main/browser/view/tree-view-widget.tsx +63 -42
  71. package/src/main/browser/view/tree-views-main.ts +0 -7
  72. package/src/plugin/languages.ts +2 -1
  73. package/src/plugin/plugin-context.ts +32 -13
  74. package/src/plugin/preference-registry.ts +11 -3
  75. package/src/plugin/quick-open.ts +15 -9
  76. package/src/plugin/terminal-ext.ts +4 -1
  77. package/src/plugin/type-converters.ts +14 -2
  78. package/src/plugin/types-impl.ts +5 -0
@@ -158,7 +158,8 @@ import {
158
158
  TestRunProfileKind,
159
159
  TestTag,
160
160
  TestRunRequest,
161
- TestMessage
161
+ TestMessage,
162
+ ExtensionKind
162
163
  } from './types-impl';
163
164
  import { AuthenticationExtImpl } from './authentication-ext';
164
165
  import { SymbolKind } from '../common/plugin-api-rpc-model';
@@ -180,7 +181,6 @@ import { ConnectionImpl } from '../common/connection';
180
181
  import { TasksExtImpl } from './tasks/tasks';
181
182
  import { DebugExtImpl } from './debug/debug-ext';
182
183
  import { FileSystemExtImpl } from './file-system-ext-impl';
183
- import { QuickPick, QuickPickItem, ResourceLabelFormatter, LineChange } from '@theia/plugin';
184
184
  import { ScmExtImpl } from './scm';
185
185
  import { DecorationsExtImpl } from './decorations';
186
186
  import { TextEditorExt } from './text-editor';
@@ -308,7 +308,7 @@ export function createAPIFactory(
308
308
  getCommands(filterInternal: boolean = false): PromiseLike<string[]> {
309
309
  return commandRegistry.getCommands(filterInternal);
310
310
  },
311
- registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable {
311
+ registerDiffInformationCommand(command: string, callback: (diff: theia.LineChange[], ...args: any[]) => any, thisArg?: any): Disposable {
312
312
  // Dummy implementation.
313
313
  return new Disposable(() => { });
314
314
  }
@@ -385,7 +385,7 @@ export function createAPIFactory(
385
385
  showQuickPick(items: any, options?: theia.QuickPickOptions, token?: theia.CancellationToken): any {
386
386
  return quickOpenExt.showQuickPick(items, options, token);
387
387
  },
388
- createQuickPick<T extends QuickPickItem>(): QuickPick<T> {
388
+ createQuickPick<T extends theia.QuickPickItem>(): theia.QuickPick<T> {
389
389
  return quickOpenExt.createQuickPick(plugin);
390
390
  },
391
391
  showWorkspaceFolderPick(options?: theia.WorkspaceFolderPickOptions): PromiseLike<theia.WorkspaceFolder | undefined> {
@@ -461,7 +461,7 @@ export function createAPIFactory(
461
461
  },
462
462
  createTerminal(nameOrOptions: theia.TerminalOptions | theia.PseudoTerminalOptions | theia.ExtensionTerminalOptions | (string | undefined),
463
463
  shellPath?: string,
464
- shellArgs?: string[]): theia.Terminal {
464
+ shellArgs?: string[] | string): theia.Terminal {
465
465
  return terminalExt.createTerminal(nameOrOptions, shellPath, shellArgs);
466
466
  },
467
467
  onDidChangeTerminalState,
@@ -476,6 +476,10 @@ export function createAPIFactory(
476
476
  createTreeView<T>(viewId: string, options: { treeDataProvider: theia.TreeDataProvider<T> }): theia.TreeView<T> {
477
477
  return treeViewsExt.createTreeView(plugin, viewId, options);
478
478
  },
479
+ withScmProgress<R>(task: (progress: theia.Progress<number>) => Thenable<R>) {
480
+ const options: ProgressOptions = { location: ProgressLocation.SourceControl };
481
+ return notificationExt.withProgress(options, () => task({ report() { /* noop */ } }));
482
+ },
479
483
  withProgress<R>(
480
484
  options: ProgressOptions,
481
485
  task: (progress: Progress<{ message?: string; increment?: number }>, token: theia.CancellationToken) => PromiseLike<R>
@@ -610,7 +614,7 @@ export function createAPIFactory(
610
614
  registerTaskProvider(type: string, provider: theia.TaskProvider): theia.Disposable {
611
615
  return tasks.registerTaskProvider(type, provider);
612
616
  },
613
- registerResourceLabelFormatter(formatter: ResourceLabelFormatter): theia.Disposable {
617
+ registerResourceLabelFormatter(formatter: theia.ResourceLabelFormatter): theia.Disposable {
614
618
  return labelServiceExt.$registerResourceLabelFormatter(formatter);
615
619
  },
616
620
  registerTimelineProvider(scheme: string | string[], provider: theia.TimelineProvider): theia.Disposable {
@@ -667,6 +671,24 @@ export function createAPIFactory(
667
671
  get onDidChangeLogLevel(): theia.Event<theia.LogLevel> { return onDidChangeLogLevel.event; }
668
672
  });
669
673
 
674
+ const extensions: typeof theia.extensions = Object.freeze({
675
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
676
+ getExtension<T = any>(extensionId: string): theia.Extension<T> | undefined {
677
+ const plg = pluginManager.getPluginById(extensionId.toLowerCase());
678
+ if (plg) {
679
+ return new PluginExt(pluginManager, plg);
680
+ }
681
+ return undefined;
682
+ },
683
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
684
+ get all(): readonly theia.Extension<any>[] {
685
+ return pluginManager.getAllPlugins().map(plg => new PluginExt(pluginManager, plg));
686
+ },
687
+ get onDidChange(): theia.Event<void> {
688
+ return pluginManager.onDidChange;
689
+ }
690
+ });
691
+
670
692
  const languages: typeof theia.languages = {
671
693
  getLanguages(): PromiseLike<string[]> {
672
694
  return languagesExt.getLanguages();
@@ -967,6 +989,7 @@ export function createAPIFactory(
967
989
  window,
968
990
  workspace,
969
991
  env,
992
+ extensions,
970
993
  languages,
971
994
  plugins,
972
995
  debug,
@@ -1100,16 +1123,12 @@ export function createAPIFactory(
1100
1123
  TestRunProfileKind,
1101
1124
  TestTag,
1102
1125
  TestRunRequest,
1103
- TestMessage
1126
+ TestMessage,
1127
+ ExtensionKind
1104
1128
  };
1105
1129
  };
1106
1130
  }
1107
1131
 
1108
- export enum ExtensionKind {
1109
- UI = 1,
1110
- Workspace = 2
1111
- }
1112
-
1113
1132
  /**
1114
1133
  * Represents a Theia plugin as well as a VSCode extension.
1115
1134
  */
@@ -1131,7 +1150,7 @@ export interface ExtensionPlugin<T> extends theia.Plugin<T> {
1131
1150
  * is defined in the `package.json`-file of extensions. When no remote extension host exists,
1132
1151
  * the value is {@linkcode ExtensionKind.UI}.
1133
1152
  */
1134
- extensionKind: ExtensionKind;
1153
+ extensionKind: theia.ExtensionKind;
1135
1154
  }
1136
1155
 
1137
1156
  export class Plugin<T> implements theia.Plugin<T> {
@@ -17,13 +17,13 @@
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
 
19
19
  import { Emitter, Event } from '@theia/core/lib/common/event';
20
+ import { isOSX, isWindows } from '@theia/core/lib/common/os';
20
21
  import { URI } from '@theia/core/shared/vscode-uri';
21
22
  import { ResourceMap } from '@theia/monaco-editor-core/esm/vs/base/common/map';
22
23
  import { IConfigurationOverrides, IOverrides } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
23
24
  import { Configuration, ConfigurationModel } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configurationModels';
24
25
  import { Workspace, WorkspaceFolder } from '@theia/monaco-editor-core/esm/vs/platform/workspace/common/workspace';
25
26
  import * as theia from '@theia/plugin';
26
- import { platform } from 'os';
27
27
  import { v4 } from 'uuid';
28
28
  import {
29
29
  PLUGIN_RPC_CONTEXT, PreferenceChangeExt, PreferenceData, PreferenceRegistryExt,
@@ -74,7 +74,7 @@ function lookUp(tree: any, key: string): any {
74
74
  export class TheiaWorkspace extends Workspace {
75
75
  constructor(ext: WorkspaceExtImpl) {
76
76
  const folders = (ext.workspaceFolders ?? []).map(folder => new WorkspaceFolder(folder));
77
- super(v4(), folders, false, ext.workspaceFile ?? null, () => ['win32', 'darwin'].includes(platform()));
77
+ super(v4(), folders, false, ext.workspaceFile ?? null, () => isOSX || isWindows);
78
78
  }
79
79
  }
80
80
 
@@ -239,7 +239,15 @@ export class PreferenceRegistryExtImpl implements PreferenceRegistryExt {
239
239
  Object.keys(data[PreferenceScope.Folder]).forEach(resource => {
240
240
  folderConfigurations.set(URI.parse(resource), this.getConfigurationModel(data[PreferenceScope.Folder][resource]));
241
241
  });
242
- return new Configuration(defaultConfiguration, userConfiguration, undefined, workspaceConfiguration, folderConfigurations);
242
+ return new Configuration(
243
+ defaultConfiguration,
244
+ new ConfigurationModel(), /** policy configuration. */
245
+ new ConfigurationModel(), /** application configuration. */
246
+ userConfiguration,
247
+ new ConfigurationModel(), /** remote configuration. */
248
+ workspaceConfiguration,
249
+ folderConfigurations
250
+ );
243
251
  }
244
252
 
245
253
  private getConfigurationModel(data: { [key: string]: any }): ConfigurationModel {
@@ -635,16 +635,18 @@ export class QuickPickExt<T extends theia.QuickPickItem> extends QuickInputExt i
635
635
  this._handlesToItems.set(i, item);
636
636
  this._itemsToHandles.set(item, i);
637
637
  });
638
- this.update({
639
- items: items.map((item, i) => {
640
- if (item.kind === QuickPickItemKind.Separator) {
641
- return { kind: item.kind, label: item.label };
642
- }
643
- return {
638
+
639
+ const pickItems: TransferQuickPickItems[] = [];
640
+ for (let handle = 0; handle < items.length; handle++) {
641
+ const item = items[handle];
642
+ if (item.kind === QuickPickItemKind.Separator) {
643
+ pickItems.push({ type: 'separator', label: item.label, handle });
644
+ } else {
645
+ pickItems.push({
644
646
  kind: item.kind,
645
647
  label: item.label,
646
648
  description: item.description,
647
- handle: i,
649
+ handle,
648
650
  detail: item.detail,
649
651
  picked: item.picked,
650
652
  alwaysShow: item.alwaysShow,
@@ -654,8 +656,12 @@ export class QuickPickExt<T extends theia.QuickPickItem> extends QuickInputExt i
654
656
  tooltip: button.tooltip,
655
657
  handle: button === QuickInputButtons.Back ? -1 : index,
656
658
  }))
657
- };
658
- })
659
+ });
660
+ }
661
+ }
662
+
663
+ this.update({
664
+ items: pickItems,
659
665
  });
660
666
  }
661
667
 
@@ -61,7 +61,10 @@ export class TerminalServiceExtImpl implements TerminalServiceExt {
61
61
  return [...this._terminals.values()];
62
62
  }
63
63
 
64
- createTerminal(nameOrOptions: TerminalOptions | PseudoTerminalOptions | ExtensionTerminalOptions | (string | undefined), shellPath?: string, shellArgs?: string[]): Terminal {
64
+ createTerminal(
65
+ nameOrOptions: TerminalOptions | PseudoTerminalOptions | ExtensionTerminalOptions | (string | undefined),
66
+ shellPath?: string, shellArgs?: string[] | string
67
+ ): Terminal {
65
68
  let options: TerminalOptions;
66
69
  let pseudoTerminal: theia.Pseudoterminal | undefined = undefined;
67
70
  const id = `plugin-terminal-${UUID.uuid4()}`;
@@ -565,10 +565,22 @@ export function fromWorkspaceEdit(value: theia.WorkspaceEdit, documents?: any):
565
565
  if (Array.isArray(uriOrEdits)) {
566
566
  // text edits
567
567
  const doc = documents ? documents.getDocument(uri.toString()) : undefined;
568
- result.edits.push(<WorkspaceTextEditDto>{ resource: uri, modelVersionId: doc && doc.version, edit: uriOrEdits.map(fromTextEdit)[0], metadata: entry[2] });
568
+ const workspaceTextEditDto: WorkspaceTextEditDto = {
569
+ resource: uri,
570
+ modelVersionId: doc?.version,
571
+ textEdit: uriOrEdits.map(fromTextEdit)[0],
572
+ metadata: entry[2] as types.WorkspaceEditMetadata
573
+ };
574
+ result.edits.push(workspaceTextEditDto);
569
575
  } else {
570
576
  // resource edits
571
- result.edits.push(<WorkspaceFileEditDto>{ oldUri: uri, newUri: uriOrEdits, options: entry[2], metadata: entry[3] });
577
+ const workspaceFileEditDto: WorkspaceFileEditDto = {
578
+ oldResource: uri,
579
+ newResource: uriOrEdits,
580
+ options: entry[2] as types.FileOperationOptions,
581
+ metadata: entry[3]
582
+ };
583
+ result.edits.push(workspaceFileEditDto);
572
584
  }
573
585
  }
574
586
  return result;
@@ -213,6 +213,11 @@ export enum ExtensionMode {
213
213
  Test = 3,
214
214
  }
215
215
 
216
+ export enum ExtensionKind {
217
+ UI = 1,
218
+ Workspace = 2
219
+ }
220
+
216
221
  /**
217
222
  * Represents the validation type of the Source Control input.
218
223
  */