@theia/plugin-ext 1.28.0-next.2 → 1.28.0-next.26

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 (102) hide show
  1. package/lib/common/plugin-api-rpc-model.d.ts +1 -0
  2. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  3. package/lib/common/plugin-api-rpc-model.js.map +1 -1
  4. package/lib/common/plugin-api-rpc.d.ts +1 -0
  5. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  6. package/lib/common/plugin-api-rpc.js.map +1 -1
  7. package/lib/common/plugin-protocol.d.ts +4 -0
  8. package/lib/common/plugin-protocol.d.ts.map +1 -1
  9. package/lib/common/plugin-protocol.js.map +1 -1
  10. package/lib/hosted/node/hosted-plugin-deployer-handler.d.ts.map +1 -1
  11. package/lib/hosted/node/hosted-plugin-deployer-handler.js +1 -0
  12. package/lib/hosted/node/hosted-plugin-deployer-handler.js.map +1 -1
  13. package/lib/hosted/node/hosted-plugin-localization-service.d.ts +15 -2
  14. package/lib/hosted/node/hosted-plugin-localization-service.d.ts.map +1 -1
  15. package/lib/hosted/node/hosted-plugin-localization-service.js +33 -3
  16. package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -1
  17. package/lib/hosted/node/plugin-ext-hosted-backend-module.d.ts.map +1 -1
  18. package/lib/hosted/node/plugin-ext-hosted-backend-module.js +1 -0
  19. package/lib/hosted/node/plugin-ext-hosted-backend-module.js.map +1 -1
  20. package/lib/hosted/node/scanners/scanner-theia.d.ts +5 -1
  21. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  22. package/lib/hosted/node/scanners/scanner-theia.js +22 -15
  23. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  24. package/lib/main/browser/comments/comment-thread-widget.js +5 -5
  25. package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
  26. package/lib/main/browser/debug/plugin-debug-service.d.ts +2 -0
  27. package/lib/main/browser/debug/plugin-debug-service.d.ts.map +1 -1
  28. package/lib/main/browser/debug/plugin-debug-service.js +5 -1
  29. package/lib/main/browser/debug/plugin-debug-service.js.map +1 -1
  30. package/lib/main/browser/languages-main.d.ts.map +1 -1
  31. package/lib/main/browser/languages-main.js.map +1 -1
  32. package/lib/main/browser/menus/menus-contribution-handler.d.ts +24 -88
  33. package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
  34. package/lib/main/browser/menus/menus-contribution-handler.js +108 -518
  35. package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
  36. package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts +44 -0
  37. package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts.map +1 -0
  38. package/lib/main/browser/menus/plugin-menu-command-adapter.js +274 -0
  39. package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -0
  40. package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +18 -0
  41. package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts.map +1 -0
  42. package/lib/main/browser/menus/vscode-theia-menu-mappings.js +88 -0
  43. package/lib/main/browser/menus/vscode-theia-menu-mappings.js.map +1 -0
  44. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  45. package/lib/main/browser/plugin-contribution-handler.js +9 -4
  46. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  47. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  48. package/lib/main/browser/plugin-ext-frontend-module.js +4 -1
  49. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  50. package/lib/main/browser/plugin-shared-style.d.ts.map +1 -1
  51. package/lib/main/browser/plugin-shared-style.js +0 -1
  52. package/lib/main/browser/plugin-shared-style.js.map +1 -1
  53. package/lib/main/browser/scm-main.d.ts +1 -0
  54. package/lib/main/browser/scm-main.d.ts.map +1 -1
  55. package/lib/main/browser/scm-main.js +7 -0
  56. package/lib/main/browser/scm-main.js.map +1 -1
  57. package/lib/main/browser/terminal-main.d.ts.map +1 -1
  58. package/lib/main/browser/terminal-main.js +4 -1
  59. package/lib/main/browser/terminal-main.js.map +1 -1
  60. package/lib/main/browser/view/tree-view-widget.js +2 -2
  61. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  62. package/lib/plugin/languages/signature.d.ts.map +1 -1
  63. package/lib/plugin/languages/signature.js +5 -1
  64. package/lib/plugin/languages/signature.js.map +1 -1
  65. package/lib/plugin/quick-open.d.ts.map +1 -1
  66. package/lib/plugin/quick-open.js +1 -0
  67. package/lib/plugin/quick-open.js.map +1 -1
  68. package/lib/plugin/scm.d.ts +3 -0
  69. package/lib/plugin/scm.d.ts.map +1 -1
  70. package/lib/plugin/scm.js +8 -0
  71. package/lib/plugin/scm.js.map +1 -1
  72. package/lib/plugin/type-converters.d.ts.map +1 -1
  73. package/lib/plugin/type-converters.js +4 -2
  74. package/lib/plugin/type-converters.js.map +1 -1
  75. package/lib/plugin/types-impl.d.ts +1 -0
  76. package/lib/plugin/types-impl.d.ts.map +1 -1
  77. package/lib/plugin/types-impl.js.map +1 -1
  78. package/package.json +26 -26
  79. package/src/common/plugin-api-rpc-model.ts +1 -0
  80. package/src/common/plugin-api-rpc.ts +1 -0
  81. package/src/common/plugin-protocol.ts +4 -0
  82. package/src/hosted/node/hosted-plugin-deployer-handler.ts +1 -0
  83. package/src/hosted/node/hosted-plugin-localization-service.ts +39 -5
  84. package/src/hosted/node/plugin-ext-hosted-backend-module.ts +1 -0
  85. package/src/hosted/node/scanners/scanner-theia.ts +21 -15
  86. package/src/main/browser/comments/comment-thread-widget.tsx +5 -5
  87. package/src/main/browser/debug/plugin-debug-service.ts +6 -1
  88. package/src/main/browser/languages-main.ts +5 -0
  89. package/src/main/browser/menus/menus-contribution-handler.ts +104 -578
  90. package/src/main/browser/menus/plugin-menu-command-adapter.ts +259 -0
  91. package/src/main/browser/menus/vscode-theia-menu-mappings.ts +85 -0
  92. package/src/main/browser/plugin-contribution-handler.ts +3 -1
  93. package/src/main/browser/plugin-ext-frontend-module.ts +4 -1
  94. package/src/main/browser/plugin-shared-style.ts +0 -1
  95. package/src/main/browser/scm-main.ts +10 -0
  96. package/src/main/browser/terminal-main.ts +4 -1
  97. package/src/main/browser/view/tree-view-widget.tsx +2 -2
  98. package/src/plugin/languages/signature.ts +3 -1
  99. package/src/plugin/quick-open.ts +1 -0
  100. package/src/plugin/scm.ts +11 -0
  101. package/src/plugin/type-converters.ts +4 -2
  102. package/src/plugin/types-impl.ts +1 -0
@@ -19,9 +19,12 @@ import * as fs from '@theia/core/shared/fs-extra';
19
19
  import { LocalizationProvider } from '@theia/core/lib/node/i18n/localization-provider';
20
20
  import { Localization } from '@theia/core/lib/common/i18n/localization';
21
21
  import { inject, injectable } from '@theia/core/shared/inversify';
22
- import { DeployedPlugin, Localization as PluginLocalization } from '../../common';
22
+ import { DeployedPlugin, Localization as PluginLocalization, PluginIdentifiers } from '../../common';
23
23
  import { URI } from '@theia/core/shared/vscode-uri';
24
24
  import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
25
+ import { BackendApplicationContribution } from '@theia/core/lib/node';
26
+ import { Disposable } from '@theia/core';
27
+ import { Deferred } from '@theia/core/lib/common/promise-util';
25
28
 
26
29
  export interface VSCodeNlsConfig {
27
30
  locale: string
@@ -34,7 +37,7 @@ export interface VSCodeNlsConfig {
34
37
  }
35
38
 
36
39
  @injectable()
37
- export class HostedPluginLocalizationService {
40
+ export class HostedPluginLocalizationService implements BackendApplicationContribution {
38
41
 
39
42
  @inject(LocalizationProvider)
40
43
  protected readonly localizationProvider: LocalizationProvider;
@@ -42,14 +45,39 @@ export class HostedPluginLocalizationService {
42
45
  @inject(EnvVariablesServer)
43
46
  protected readonly envVariables: EnvVariablesServer;
44
47
 
48
+ protected localizationDisposeMap = new Map<string, Disposable>();
45
49
  protected translationConfigFiles: Map<string, string> = new Map();
46
50
 
51
+ protected readonly _ready = new Deferred();
52
+
53
+ /**
54
+ * This promise resolves when the cache has been cleaned up after starting the backend server.
55
+ * Once resolved, the service allows to cache localization files for plugins.
56
+ */
57
+ ready = this._ready.promise;
58
+
59
+ async initialize(): Promise<void> {
60
+ const cacheDir = await this.getLocalizationCacheDir();
61
+ await fs.emptyDir(cacheDir);
62
+ this._ready.resolve();
63
+ }
64
+
47
65
  deployLocalizations(plugin: DeployedPlugin): void {
48
66
  if (plugin.contributes?.localizations) {
49
- this.localizationProvider.addLocalizations(...buildLocalizations(plugin.contributes.localizations));
67
+ const localizations = buildLocalizations(plugin.contributes.localizations);
68
+ const versionedId = PluginIdentifiers.componentsToVersionedId(plugin.metadata.model);
69
+ this.localizationDisposeMap.set(versionedId, Disposable.create(() => {
70
+ this.localizationProvider.removeLocalizations(...localizations);
71
+ this.localizationDisposeMap.delete(versionedId);
72
+ }));
73
+ this.localizationProvider.addLocalizations(...localizations);
50
74
  }
51
75
  }
52
76
 
77
+ undeployLocalizations(plugin: PluginIdentifiers.VersionedId): void {
78
+ this.localizationDisposeMap.get(plugin)?.dispose();
79
+ }
80
+
53
81
  async localizePlugin(plugin: DeployedPlugin): Promise<DeployedPlugin> {
54
82
  const currentLanguage = this.localizationProvider.getCurrentLanguage();
55
83
  const localization = this.localizationProvider.loadLocalization(currentLanguage);
@@ -85,8 +113,8 @@ export class HostedPluginLocalizationService {
85
113
  }
86
114
 
87
115
  async buildTranslationConfig(plugins: DeployedPlugin[]): Promise<void> {
88
- const configDir = URI.parse(await this.envVariables.getConfigDirUri()).fsPath;
89
- const cacheDir = path.join(configDir, 'localization-cache');
116
+ await this.ready;
117
+ const cacheDir = await this.getLocalizationCacheDir();
90
118
  const configs = new Map<string, Record<string, string>>();
91
119
  for (const plugin of plugins) {
92
120
  if (plugin.contributes?.localizations) {
@@ -110,6 +138,12 @@ export class HostedPluginLocalizationService {
110
138
  await fs.writeJson(configFile, config);
111
139
  }
112
140
  }
141
+
142
+ protected async getLocalizationCacheDir(): Promise<string> {
143
+ const configDir = URI.parse(await this.envVariables.getConfigDirUri()).fsPath;
144
+ const cacheDir = path.join(configDir, 'localization-cache');
145
+ return cacheDir;
146
+ }
113
147
  }
114
148
 
115
149
  function buildLocalizations(localizations: PluginLocalization[]): Localization[] {
@@ -60,6 +60,7 @@ export function bindCommonHostedBackend(bind: interfaces.Bind): void {
60
60
  bind(BackendApplicationContribution).toService(HostedPluginReader);
61
61
 
62
62
  bind(HostedPluginLocalizationService).toSelf().inSingletonScope();
63
+ bind(BackendApplicationContribution).toService(HostedPluginLocalizationService);
63
64
  bind(HostedPluginDeployerHandler).toSelf().inSingletonScope();
64
65
  bind(PluginDeployerHandler).toService(HostedPluginDeployerHandler);
65
66
 
@@ -190,7 +190,7 @@ export class TheiaPluginScanner implements PluginScanner {
190
190
 
191
191
  try {
192
192
  if (rawPlugin.contributes!.submenus) {
193
- contributions.submenus = this.readSubmenus(rawPlugin.contributes.submenus!);
193
+ contributions.submenus = this.readSubmenus(rawPlugin.contributes.submenus!, rawPlugin);
194
194
  }
195
195
  } catch (err) {
196
196
  console.error(`Could not read '${rawPlugin.name}' contribution 'submenus'.`, rawPlugin.contributes!.submenus, err);
@@ -390,23 +390,27 @@ export class TheiaPluginScanner implements PluginScanner {
390
390
  }
391
391
 
392
392
  protected readCommand({ command, title, original, category, icon, enablement }: PluginPackageCommand, pck: PluginPackage): PluginCommand {
393
- let themeIcon: string | undefined;
394
- let iconUrl: IconUrl | undefined;
395
- if (icon) {
396
- if (typeof icon === 'string') {
397
- if (icon.startsWith('$(')) {
398
- themeIcon = icon;
393
+ const { themeIcon, iconUrl } = this.transformIconUrl(pck, icon) ?? {};
394
+ return { command, title, originalTitle: original, category, iconUrl, themeIcon, enablement };
395
+ }
396
+
397
+ protected transformIconUrl(plugin: PluginPackage, original?: IconUrl): { iconUrl?: IconUrl; themeIcon?: string } | undefined {
398
+ if (original) {
399
+ if (typeof original === 'string') {
400
+ if (original.startsWith('$(')) {
401
+ return { themeIcon: original };
399
402
  } else {
400
- iconUrl = this.toPluginUrl(pck, icon);
403
+ return { iconUrl: this.toPluginUrl(plugin, original) };
401
404
  }
402
405
  } else {
403
- iconUrl = {
404
- light: this.toPluginUrl(pck, icon.light),
405
- dark: this.toPluginUrl(pck, icon.dark)
406
+ return {
407
+ iconUrl: {
408
+ light: this.toPluginUrl(plugin, original.light),
409
+ dark: this.toPluginUrl(plugin, original.dark)
410
+ }
406
411
  };
407
412
  }
408
413
  }
409
- return { command, title, originalTitle: original, category, iconUrl, themeIcon, enablement };
410
414
  }
411
415
 
412
416
  protected toPluginUrl(pck: PluginPackage, relativePath: string): string {
@@ -629,12 +633,14 @@ export class TheiaPluginScanner implements PluginScanner {
629
633
  return rawLanguages.map(language => this.readLanguage(language, pluginPath));
630
634
  }
631
635
 
632
- private readSubmenus(rawSubmenus: PluginPackageSubmenu[]): Submenu[] {
633
- return rawSubmenus.map(submenu => this.readSubmenu(submenu));
636
+ private readSubmenus(rawSubmenus: PluginPackageSubmenu[], plugin: PluginPackage): Submenu[] {
637
+ return rawSubmenus.map(submenu => this.readSubmenu(submenu, plugin));
634
638
  }
635
639
 
636
- private readSubmenu(rawSubmenu: PluginPackageSubmenu): Submenu {
640
+ private readSubmenu(rawSubmenu: PluginPackageSubmenu, plugin: PluginPackage): Submenu {
641
+ const icon = this.transformIconUrl(plugin, rawSubmenu.icon);
637
642
  return {
643
+ icon: icon?.iconUrl ?? icon?.themeIcon,
638
644
  id: rawSubmenu.id,
639
645
  label: rawSubmenu.label
640
646
  };
@@ -96,7 +96,7 @@ export class CommentThreadWidget extends BaseWidget {
96
96
  }
97
97
  }));
98
98
  this.contextMenu = this.menus.getMenu(COMMENT_THREAD_CONTEXT);
99
- this.contextMenu.children.map(node => node instanceof ActionMenuNode && node.action.when).forEach(exp => {
99
+ this.contextMenu.children.map(node => node instanceof ActionMenuNode && node.when).forEach(exp => {
100
100
  if (typeof exp === 'string') {
101
101
  this.contextKeyService.setExpression(exp);
102
102
  }
@@ -377,7 +377,7 @@ export class CommentForm<P extends CommentForm.Props = CommentForm.Props> extend
377
377
  };
378
378
 
379
379
  this.menu = this.props.menus.getMenu(COMMENT_THREAD_CONTEXT);
380
- this.menu.children.map(node => node instanceof ActionMenuNode && node.action.when).forEach(exp => {
380
+ this.menu.children.map(node => node instanceof ActionMenuNode && node.when).forEach(exp => {
381
381
  if (typeof exp === 'string') {
382
382
  this.props.contextKeyService.setExpression(exp);
383
383
  }
@@ -597,7 +597,7 @@ namespace CommentsInlineAction {
597
597
  export class CommentsInlineAction extends React.Component<CommentsInlineAction.Props> {
598
598
  override render(): React.ReactNode {
599
599
  const { node, commands, contextKeyService, commentThread, commentUniqueId } = this.props;
600
- if (node.action.when && !contextKeyService.match(node.action.when)) {
600
+ if (node.when && !contextKeyService.match(node.when)) {
601
601
  return false;
602
602
  }
603
603
  return <div className='theia-comments-inline-action'>
@@ -657,10 +657,10 @@ export class CommentAction extends React.Component<CommentAction.Props> {
657
657
  override render(): React.ReactNode {
658
658
  const classNames = ['comments-button', 'comments-text-button', 'theia-button'];
659
659
  const { node, commands, contextKeyService, onClick } = this.props;
660
- if (node.action.when && !contextKeyService.match(node.action.when)) {
660
+ if (node.when && !contextKeyService.match(node.when)) {
661
661
  return false;
662
662
  }
663
- const isEnabled = commands.isEnabled(node.action.commandId);
663
+ const isEnabled = commands.isEnabled(node.command);
664
664
  if (!isEnabled) {
665
665
  classNames.push(DISABLED_CLASS);
666
666
  }
@@ -37,10 +37,15 @@ import * as theia from '@theia/plugin';
37
37
  @injectable()
38
38
  export class PluginDebugService implements DebugService {
39
39
 
40
+ protected readonly onDidChangeDebuggersEmitter = new Emitter<void>();
41
+ get onDidChangeDebuggers(): Event<void> {
42
+ return this.onDidChangeDebuggersEmitter.event;
43
+ }
44
+
40
45
  protected readonly debuggers: DebuggerContribution[] = [];
41
46
  protected readonly contributors = new Map<string, PluginDebugAdapterContribution>();
42
47
  protected readonly configurationProviders = new Map<number, PluginDebugConfigurationProvider>();
43
- protected readonly toDispose = new DisposableCollection();
48
+ protected readonly toDispose = new DisposableCollection(this.onDidChangeDebuggersEmitter);
44
49
 
45
50
  protected readonly onDidChangeDebugConfigurationProvidersEmitter = new Emitter<void>();
46
51
  get onDidChangeDebugConfigurationProviders(): Event<void> {
@@ -67,6 +67,11 @@ import { IRelativePattern } from '@theia/monaco-editor-core/esm/vs/base/common/g
67
67
  import { EditorLanguageStatusService, LanguageStatus as EditorLanguageStatus } from '@theia/editor/lib/browser/language-status/editor-language-status-service';
68
68
  import { LanguageSelector, RelativePattern } from '@theia/editor/lib/common/language-selector';
69
69
 
70
+ /**
71
+ * @monaco-uplift The public API declares these functions as (languageId: string, service).
72
+ * Confirm that the functions delegate to a handler that accepts a LanguageSelector rather than just a string.
73
+ * Relevant code in node_modules/@theia/monaco-editor-core/src/vs/editor/standalone/browser/standaloneLanguages.ts
74
+ */
70
75
  interface RegistrationFunction<T> {
71
76
  (languageId: MonacoLanguageSelector.LanguageSelector, service: T): Disposable;
72
77
  }