@theia/plugin-ext 1.75.0-next.3 → 1.75.0-next.34

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 (191) hide show
  1. package/lib/common/errors.d.ts +1 -14
  2. package/lib/common/errors.d.ts.map +1 -1
  3. package/lib/common/errors.js +3 -16
  4. package/lib/common/errors.js.map +1 -1
  5. package/lib/common/plugin-api-rpc.d.ts +1 -1
  6. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  7. package/lib/common/plugin-protocol.d.ts +53 -648
  8. package/lib/common/plugin-protocol.d.ts.map +1 -1
  9. package/lib/common/plugin-protocol.js +11 -34
  10. package/lib/common/plugin-protocol.js.map +1 -1
  11. package/lib/hosted/browser/hosted-plugin.d.ts +2 -1
  12. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  13. package/lib/hosted/browser/hosted-plugin.js +8 -3
  14. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  15. package/lib/hosted/browser/worker/plugin-manifest-loader.d.ts.map +1 -1
  16. package/lib/hosted/browser/worker/plugin-manifest-loader.js +5 -36
  17. package/lib/hosted/browser/worker/plugin-manifest-loader.js.map +1 -1
  18. package/lib/hosted/browser/worker/worker-main.js +2 -1
  19. package/lib/hosted/browser/worker/worker-main.js.map +1 -1
  20. package/lib/hosted/common/hosted-plugin.js +10 -9
  21. package/lib/hosted/common/hosted-plugin.js.map +1 -1
  22. package/lib/hosted/common/hosted-plugin.spec.js +2 -0
  23. package/lib/hosted/common/hosted-plugin.spec.js.map +1 -1
  24. package/lib/hosted/node/hosted-plugin-localization-service.d.ts.map +1 -1
  25. package/lib/hosted/node/hosted-plugin-localization-service.js +4 -68
  26. package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -1
  27. package/lib/hosted/node/hosted-plugin-process.js +1 -0
  28. package/lib/hosted/node/hosted-plugin-process.js.map +1 -1
  29. package/lib/hosted/node/hosted-plugin.js +1 -0
  30. package/lib/hosted/node/hosted-plugin.js.map +1 -1
  31. package/lib/hosted/node/plugin-host-rpc.d.ts.map +1 -1
  32. package/lib/hosted/node/plugin-host-rpc.js +2 -2
  33. package/lib/hosted/node/plugin-host-rpc.js.map +1 -1
  34. package/lib/hosted/node/plugin-reader.d.ts.map +1 -1
  35. package/lib/hosted/node/plugin-reader.js +6 -4
  36. package/lib/hosted/node/plugin-reader.js.map +1 -1
  37. package/lib/hosted/node/plugin-service.js +1 -0
  38. package/lib/hosted/node/plugin-service.js.map +1 -1
  39. package/lib/hosted/node/scanners/grammars-reader.d.ts +3 -2
  40. package/lib/hosted/node/scanners/grammars-reader.d.ts.map +1 -1
  41. package/lib/hosted/node/scanners/grammars-reader.js +5 -23
  42. package/lib/hosted/node/scanners/grammars-reader.js.map +1 -1
  43. package/lib/hosted/node/scanners/scanner-theia.d.ts +38 -71
  44. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  45. package/lib/hosted/node/scanners/scanner-theia.js +117 -768
  46. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  47. package/lib/hosted/node/scanners/scanner-theia.spec.js +191 -0
  48. package/lib/hosted/node/scanners/scanner-theia.spec.js.map +1 -1
  49. package/lib/main/browser/comments/comments-service.d.ts +2 -0
  50. package/lib/main/browser/comments/comments-service.d.ts.map +1 -1
  51. package/lib/main/browser/comments/comments-service.js +7 -1
  52. package/lib/main/browser/comments/comments-service.js.map +1 -1
  53. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.d.ts +2 -1
  54. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.d.ts.map +1 -1
  55. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.js +6 -1
  56. package/lib/main/browser/custom-editors/plugin-custom-editor-registry.js.map +1 -1
  57. package/lib/main/browser/debug/plugin-debug-session-contribution-registry.d.ts +2 -0
  58. package/lib/main/browser/debug/plugin-debug-session-contribution-registry.d.ts.map +1 -1
  59. package/lib/main/browser/debug/plugin-debug-session-contribution-registry.js +7 -1
  60. package/lib/main/browser/debug/plugin-debug-session-contribution-registry.js.map +1 -1
  61. package/lib/main/browser/menus/menus-contribution-handler.d.ts +2 -1
  62. package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
  63. package/lib/main/browser/menus/menus-contribution-handler.js +9 -4
  64. package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
  65. package/lib/main/browser/plugin-contribution-handler.js +1 -1
  66. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  67. package/lib/main/browser/plugin-icon-service.d.ts.map +1 -1
  68. package/lib/main/browser/plugin-icon-service.js +2 -1
  69. package/lib/main/browser/plugin-icon-service.js.map +1 -1
  70. package/lib/main/browser/plugin-icon-theme-service.d.ts.map +1 -1
  71. package/lib/main/browser/plugin-icon-theme-service.js +2 -1
  72. package/lib/main/browser/plugin-icon-theme-service.js.map +1 -1
  73. package/lib/main/browser/plugin-shared-style.d.ts.map +1 -1
  74. package/lib/main/browser/plugin-shared-style.js +2 -1
  75. package/lib/main/browser/plugin-shared-style.js.map +1 -1
  76. package/lib/main/browser/scm-main.d.ts.map +1 -1
  77. package/lib/main/browser/scm-main.js +3 -1
  78. package/lib/main/browser/scm-main.js.map +1 -1
  79. package/lib/main/browser/text-editor-model-service.d.ts +2 -1
  80. package/lib/main/browser/text-editor-model-service.d.ts.map +1 -1
  81. package/lib/main/browser/text-editor-model-service.js +6 -1
  82. package/lib/main/browser/text-editor-model-service.js.map +1 -1
  83. package/lib/main/browser/view/plugin-view-registry.d.ts +2 -0
  84. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  85. package/lib/main/browser/view/plugin-view-registry.js +14 -9
  86. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  87. package/lib/main/browser/view/tree-view-widget.d.ts +3 -0
  88. package/lib/main/browser/view/tree-view-widget.d.ts.map +1 -1
  89. package/lib/main/browser/view/tree-view-widget.js +17 -6
  90. package/lib/main/browser/view/tree-view-widget.js.map +1 -1
  91. package/lib/main/browser/webview/webview.d.ts.map +1 -1
  92. package/lib/main/browser/webview/webview.js +4 -2
  93. package/lib/main/browser/webview/webview.js.map +1 -1
  94. package/lib/main/browser/webview-views/webview-views-main.d.ts.map +1 -1
  95. package/lib/main/browser/webview-views/webview-views-main.js +3 -2
  96. package/lib/main/browser/webview-views/webview-views-main.js.map +1 -1
  97. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts +2 -1
  98. package/lib/main/node/handlers/plugin-theia-directory-handler.d.ts.map +1 -1
  99. package/lib/main/node/handlers/plugin-theia-directory-handler.js +10 -4
  100. package/lib/main/node/handlers/plugin-theia-directory-handler.js.map +1 -1
  101. package/lib/main/node/handlers/plugin-theia-file-handler.d.ts +2 -0
  102. package/lib/main/node/handlers/plugin-theia-file-handler.d.ts.map +1 -1
  103. package/lib/main/node/handlers/plugin-theia-file-handler.js +9 -3
  104. package/lib/main/node/handlers/plugin-theia-file-handler.js.map +1 -1
  105. package/lib/main/node/paths/plugin-paths-service.js +1 -0
  106. package/lib/main/node/paths/plugin-paths-service.js.map +1 -1
  107. package/lib/main/node/plugin-deployer-contribution.js +1 -0
  108. package/lib/main/node/plugin-deployer-contribution.js.map +1 -1
  109. package/lib/main/node/plugin-deployer-impl.d.ts.map +1 -1
  110. package/lib/main/node/plugin-deployer-impl.js +16 -13
  111. package/lib/main/node/plugin-deployer-impl.js.map +1 -1
  112. package/lib/main/node/plugin-service.d.ts +2 -0
  113. package/lib/main/node/plugin-service.d.ts.map +1 -1
  114. package/lib/main/node/plugin-service.js +7 -1
  115. package/lib/main/node/plugin-service.js.map +1 -1
  116. package/lib/main/node/plugin-uninstallation-manager.d.ts +2 -1
  117. package/lib/main/node/plugin-uninstallation-manager.d.ts.map +1 -1
  118. package/lib/main/node/plugin-uninstallation-manager.js +6 -1
  119. package/lib/main/node/plugin-uninstallation-manager.js.map +1 -1
  120. package/lib/main/node/plugins-key-value-storage.d.ts +2 -0
  121. package/lib/main/node/plugins-key-value-storage.d.ts.map +1 -1
  122. package/lib/main/node/plugins-key-value-storage.js +9 -3
  123. package/lib/main/node/plugins-key-value-storage.js.map +1 -1
  124. package/lib/main/node/resolvers/local-plugin-deployer-resolver.d.ts +2 -0
  125. package/lib/main/node/resolvers/local-plugin-deployer-resolver.d.ts.map +1 -1
  126. package/lib/main/node/resolvers/local-plugin-deployer-resolver.js +7 -1
  127. package/lib/main/node/resolvers/local-plugin-deployer-resolver.js.map +1 -1
  128. package/lib/main/node/webview-backend-security-warnings.d.ts +2 -0
  129. package/lib/main/node/webview-backend-security-warnings.d.ts.map +1 -1
  130. package/lib/main/node/webview-backend-security-warnings.js +7 -1
  131. package/lib/main/node/webview-backend-security-warnings.js.map +1 -1
  132. package/lib/plugin/scm.js +1 -1
  133. package/lib/plugin/scm.js.map +1 -1
  134. package/package.json +31 -30
  135. package/src/common/errors.ts +1 -25
  136. package/src/common/plugin-api-rpc.ts +1 -1
  137. package/src/common/plugin-protocol.ts +203 -662
  138. package/src/hosted/browser/hosted-plugin.ts +8 -5
  139. package/src/hosted/browser/worker/plugin-manifest-loader.ts +8 -41
  140. package/src/hosted/browser/worker/worker-main.ts +2 -1
  141. package/src/hosted/common/hosted-plugin.spec.ts +2 -0
  142. package/src/hosted/common/hosted-plugin.ts +10 -10
  143. package/src/hosted/node/hosted-plugin-localization-service.ts +3 -82
  144. package/src/hosted/node/hosted-plugin-process.ts +1 -1
  145. package/src/hosted/node/hosted-plugin.ts +2 -2
  146. package/src/hosted/node/plugin-host-rpc.ts +3 -3
  147. package/src/hosted/node/plugin-reader.ts +7 -6
  148. package/src/hosted/node/plugin-service.ts +1 -1
  149. package/src/hosted/node/scanners/grammars-reader.ts +14 -23
  150. package/src/hosted/node/scanners/scanner-theia.spec.ts +225 -1
  151. package/src/hosted/node/scanners/scanner-theia.ts +204 -881
  152. package/src/main/browser/comments/comments-service.ts +6 -2
  153. package/src/main/browser/custom-editors/plugin-custom-editor-registry.ts +6 -3
  154. package/src/main/browser/debug/plugin-debug-session-contribution-registry.ts +5 -1
  155. package/src/main/browser/menus/menus-contribution-handler.ts +9 -6
  156. package/src/main/browser/plugin-contribution-handler.ts +1 -1
  157. package/src/main/browser/plugin-icon-service.ts +2 -1
  158. package/src/main/browser/plugin-icon-theme-service.ts +2 -1
  159. package/src/main/browser/plugin-shared-style.ts +2 -1
  160. package/src/main/browser/scm-main.ts +3 -1
  161. package/src/main/browser/text-editor-model-service.ts +6 -3
  162. package/src/main/browser/view/plugin-view-registry.ts +14 -11
  163. package/src/main/browser/view/tree-view-widget.tsx +14 -7
  164. package/src/main/browser/webview/webview.ts +4 -2
  165. package/src/main/browser/webview-views/webview-views-main.ts +4 -4
  166. package/src/main/node/handlers/plugin-theia-directory-handler.ts +9 -6
  167. package/src/main/node/handlers/plugin-theia-file-handler.ts +8 -5
  168. package/src/main/node/paths/plugin-paths-service.ts +2 -2
  169. package/src/main/node/plugin-deployer-contribution.ts +2 -2
  170. package/src/main/node/plugin-deployer-impl.ts +20 -14
  171. package/src/main/node/plugin-service.ts +6 -2
  172. package/src/main/node/plugin-uninstallation-manager.ts +7 -4
  173. package/src/main/node/plugins-key-value-storage.ts +8 -4
  174. package/src/main/node/resolvers/local-plugin-deployer-resolver.ts +7 -2
  175. package/src/main/node/webview-backend-security-warnings.ts +6 -2
  176. package/src/plugin/scm.ts +1 -1
  177. package/lib/hosted/node/plugin-activation-events.d.ts +0 -7
  178. package/lib/hosted/node/plugin-activation-events.d.ts.map +0 -1
  179. package/lib/hosted/node/plugin-activation-events.js +0 -95
  180. package/lib/hosted/node/plugin-activation-events.js.map +0 -1
  181. package/lib/hosted/node/plugin-manifest-loader.d.ts +0 -3
  182. package/lib/hosted/node/plugin-manifest-loader.d.ts.map +0 -1
  183. package/lib/hosted/node/plugin-manifest-loader.js +0 -34
  184. package/lib/hosted/node/plugin-manifest-loader.js.map +0 -1
  185. package/lib/main/node/errors.spec.d.ts +0 -2
  186. package/lib/main/node/errors.spec.d.ts.map +0 -1
  187. package/lib/main/node/errors.spec.js +0 -36
  188. package/lib/main/node/errors.spec.js.map +0 -1
  189. package/src/hosted/node/plugin-activation-events.ts +0 -112
  190. package/src/hosted/node/plugin-manifest-loader.ts +0 -32
  191. package/src/main/node/errors.spec.ts +0 -37
@@ -22,7 +22,7 @@
22
22
  /* eslint-disable @typescript-eslint/no-explicit-any */
23
23
 
24
24
  import { generateUuid } from '@theia/core/lib/common/uuid';
25
- import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
25
+ import { injectable, inject, postConstruct, named } from '@theia/core/shared/inversify';
26
26
  import { PluginWorker } from './plugin-worker';
27
27
  import { getPluginId, DeployedPlugin, HostedPluginServer } from '../../common/plugin-protocol';
28
28
  import { HostedPluginWatcher } from './hosted-plugin-watcher';
@@ -33,7 +33,7 @@ import {
33
33
  Disposable, DisposableCollection, isCancelled,
34
34
  CommandRegistry, WillExecuteCommandEvent,
35
35
  CancellationTokenSource, ProgressService, nls,
36
- RpcProxy
36
+ RpcProxy, ILogger
37
37
  } from '@theia/core';
38
38
  import { PreferenceServiceImpl, PreferenceProviderProvider } from '@theia/core/lib/common/preferences';
39
39
  import { WorkspaceService } from '@theia/workspace/lib/browser';
@@ -183,6 +183,9 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport<PluginManag
183
183
  @inject(WorkspaceTrustService)
184
184
  protected readonly workspaceTrustService: WorkspaceTrustService;
185
185
 
186
+ @inject(ILogger) @named('plugin-ext:HostedPluginSupport')
187
+ protected override readonly logger: ILogger;
188
+
186
189
  constructor() {
187
190
  super(generateUuid());
188
191
  }
@@ -290,7 +293,7 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport<PluginManag
290
293
  await this.viewRegistry.initWidgets();
291
294
  // remove restored plugin widgets which were not registered by contributions
292
295
  this.viewRegistry.removeStaleWidgets();
293
- }).catch(console.error);
296
+ }).catch(e => this.logger.error(e));
294
297
  this.workspaceTrustService.refreshRestrictedModeIndicator();
295
298
  }
296
299
 
@@ -583,7 +586,7 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport<PluginManag
583
586
  return result.length > 0;
584
587
  } catch (e) {
585
588
  if (!isCancelled(e)) {
586
- console.error(e);
589
+ this.logger.error(e);
587
590
  }
588
591
  return false;
589
592
  } finally {
@@ -644,7 +647,7 @@ export class HostedPluginSupport extends AbstractHostedPluginSupport<PluginManag
644
647
  webview.setHTML(this.getDeserializationFailedContents(`
645
648
  An error occurred while restoring '${webview.viewType}' view. Please check logs.
646
649
  `));
647
- console.error('Failed to restore the webview', e);
650
+ this.logger.error('Failed to restore the webview', e);
648
651
  }
649
652
  }
650
653
  }
@@ -16,11 +16,11 @@
16
16
 
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
 
19
- import { PluginIdentifiers, PluginModel, PluginPackage } from '../../../common/plugin-protocol';
19
+ import { PluginModel, PluginPackage } from '../../../common/plugin-protocol';
20
20
  import { Endpoint } from '@theia/core/lib/browser/endpoint';
21
21
  import URI from '@theia/core/lib/common/uri';
22
-
23
- const NLS_REGEX = /^%([\w\d.-]+)%$/i;
22
+ import { localizeWithResolver } from '@theia/plugin-utils/lib/common/package-nls';
23
+ import { prepareLoadedManifest } from '@theia/plugin-utils/lib/common/plugin-manifest';
24
24
 
25
25
  function getUri(pluginModel: PluginModel, relativePath: string): URI {
26
26
  const ownURI = new Endpoint().getRestUrl();
@@ -54,23 +54,18 @@ function readContents(uri: string): Promise<string> {
54
54
 
55
55
  async function readPluginJson(pluginModel: PluginModel, relativePath: string): Promise<any> {
56
56
  const content = await readPluginFile(pluginModel, relativePath);
57
- const json = JSON.parse(content) as PluginPackage;
58
- json.publisher ??= PluginIdentifiers.UNPUBLISHED;
59
- return json;
57
+ return JSON.parse(content);
60
58
  }
61
59
 
62
60
  export async function loadManifest(pluginModel: PluginModel): Promise<any> {
63
61
  const [manifest, translations] = await Promise.all([
64
- readPluginJson(pluginModel, 'package.json'),
62
+ readPluginJson(pluginModel, 'package.json').then(raw =>
63
+ prepareLoadedManifest(raw as PluginPackage, { updateActivationEvents: false })
64
+ ),
65
65
  loadTranslations(pluginModel)
66
66
  ]);
67
- // translate vscode builtins, as they are published with a prefix.
68
- const built_prefix = '@theia/vscode-builtin-';
69
- if (manifest && manifest.name && manifest.name.startsWith(built_prefix)) {
70
- manifest.name = manifest.name.substring(built_prefix.length);
71
- }
72
67
  return manifest && translations && Object.keys(translations).length ?
73
- localize(manifest, translations) :
68
+ localizeWithResolver(manifest, key => translations[key]) :
74
69
  manifest;
75
70
  }
76
71
 
@@ -84,31 +79,3 @@ async function loadTranslations(pluginModel: PluginModel): Promise<any> {
84
79
  return {};
85
80
  }
86
81
  }
87
-
88
- function localize(value: any, translations: {
89
- [key: string]: string
90
- }): any {
91
- if (typeof value === 'string') {
92
- const match = NLS_REGEX.exec(value);
93
- return match && translations[match[1]] || value;
94
- }
95
- if (Array.isArray(value)) {
96
- const result = [];
97
- for (const item of value) {
98
- result.push(localize(item, translations));
99
- }
100
- return result;
101
- }
102
- if (value === null) {
103
- return value;
104
- }
105
- if (typeof value === 'object') {
106
- const result: { [key: string]: any } = {};
107
- // eslint-disable-next-line guard-for-in
108
- for (const propertyName in value) {
109
- result[propertyName] = localize(value[propertyName], translations);
110
- }
111
- return result;
112
- }
113
- return value;
114
- }
@@ -35,6 +35,7 @@ import { EnvExtImpl } from '../../../plugin/env';
35
35
  import { DebugExtImpl } from '../../../plugin/debug/debug-ext';
36
36
  import { LocalizationExtImpl } from '../../../plugin/localization-ext';
37
37
  import pluginHostModule from './worker-plugin-module';
38
+ import { PLUGINS_BASE_PATH } from '@theia/plugin-utils/lib/common/constants';
38
39
 
39
40
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
41
  const ctx = self as any;
@@ -70,7 +71,7 @@ pluginManager.setPluginHost({
70
71
  ctx.frontendModuleName = plugin.lifecycle.frontendModuleName;
71
72
  }
72
73
 
73
- ctx.importScripts('./hostedPlugin/' + getPluginId(plugin.model) + '/' + plugin.pluginPath);
74
+ ctx.importScripts(`./${PLUGINS_BASE_PATH}/` + getPluginId(plugin.model) + '/' + plugin.pluginPath);
74
75
  }
75
76
  }
76
77
 
@@ -19,6 +19,7 @@ import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposa
19
19
  import { DeployedPlugin, PluginIdentifiers } from '../../common/plugin-protocol';
20
20
  import { AbstractHostedPluginSupport, PluginContributions } from './hosted-plugin';
21
21
  import { Measurement } from '@theia/core/lib/common/performance/measurement';
22
+ import { MockLogger } from '@theia/core/lib/common/test/mock-logger';
22
23
 
23
24
  /* eslint-disable @typescript-eslint/no-explicit-any */
24
25
 
@@ -64,6 +65,7 @@ function createNoopMeasurement(): Measurement {
64
65
  class TestHostedPluginSupport extends AbstractHostedPluginSupport<any, any> {
65
66
  constructor() {
66
67
  super('test-client');
68
+ (this as unknown as { logger: MockLogger }).logger = new MockLogger();
67
69
  }
68
70
 
69
71
  protected createTheiaReadyPromise(): Promise<unknown> {
@@ -54,7 +54,7 @@ export abstract class AbstractHostedPluginSupport<PM extends AbstractPluginManag
54
54
 
55
55
  protected container: interfaces.Container;
56
56
 
57
- @inject(ILogger)
57
+ @inject(ILogger) @named('plugin-ext:AbstractHostedPluginSupport')
58
58
  protected readonly logger: ILogger;
59
59
 
60
60
  @inject(HostedPluginServer)
@@ -147,7 +147,7 @@ export abstract class AbstractHostedPluginSupport<PM extends AbstractPluginManag
147
147
  try {
148
148
  await this.runOperation(() => this.doLoad());
149
149
  } catch (e) {
150
- console.error('Failed to load plugins:', e);
150
+ this.logger.error('Failed to load plugins:', e);
151
151
  // Resolve the startup deferreds so that clients awaiting `willStart` or `didStart`,
152
152
  // e.g. file system provider activations, do not hang forever on a failed load.
153
153
  this.deferredWillStart.resolve();
@@ -316,7 +316,7 @@ export abstract class AbstractHostedPluginSupport<PM extends AbstractPluginManag
316
316
  const loadPluginsMeasurement = this.measure('loadPlugins');
317
317
 
318
318
  const hostContributions = new Map<PluginHost, PluginContributions[]>();
319
- console.log(`[${this.clientId}] Loading plugin contributions`);
319
+ this.logger.info(`[${this.clientId}] Loading plugin contributions`);
320
320
  for (const contributions of this.contributions.values()) {
321
321
  if (!this.workspaceTrusted && contributions.plugin.metadata.model.untrustedWorkspacesSupport === false) {
322
322
  this._disabledByTrust.add(PluginIdentifiers.componentsToUnversionedId(contributions.plugin.metadata.model));
@@ -327,10 +327,10 @@ export abstract class AbstractHostedPluginSupport<PM extends AbstractPluginManag
327
327
  const pluginId = plugin.model.id;
328
328
  if (contributions.state === PluginContributions.State.INITIALIZING) {
329
329
  contributions.state = PluginContributions.State.LOADING;
330
- contributions.push(Disposable.create(() => console.log(`[${pluginId}]: Unloaded plugin.`)));
330
+ contributions.push(Disposable.create(() => this.logger.info(`[${pluginId}]: Unloaded plugin.`)));
331
331
  contributions.push(this.handleContributions(contributions.plugin));
332
332
  contributions.state = PluginContributions.State.LOADED;
333
- console.debug(`[${this.clientId}][${pluginId}]: Loaded contributions.`);
333
+ this.logger.debug(`[${this.clientId}][${pluginId}]: Loaded contributions.`);
334
334
  loaded++;
335
335
  }
336
336
 
@@ -342,7 +342,7 @@ export abstract class AbstractHostedPluginSupport<PM extends AbstractPluginManag
342
342
  hostContributions.set(host, dynamicContributions);
343
343
  toDisconnect.push(Disposable.create(() => {
344
344
  contributions!.state = PluginContributions.State.LOADED;
345
- console.debug(`[${this.clientId}][${pluginId}]: Disconnected.`);
345
+ this.logger.debug(`[${this.clientId}][${pluginId}]: Disconnected.`);
346
346
  }));
347
347
  }
348
348
  }
@@ -398,22 +398,22 @@ export abstract class AbstractHostedPluginSupport<PM extends AbstractPluginManag
398
398
  if (toDisconnect.disposed) {
399
399
  return;
400
400
  }
401
- console.log(`[${this.clientId}] Starting plugins.`);
401
+ this.logger.info(`[${this.clientId}] Starting plugins.`);
402
402
  for (const contributions of hostContributions) {
403
403
  started++;
404
404
  const plugin = contributions.plugin;
405
405
  const id = plugin.metadata.model.id;
406
406
  contributions.state = PluginContributions.State.STARTED;
407
- console.debug(`[${this.clientId}][${id}]: Started plugin.`);
407
+ this.logger.debug(`[${this.clientId}][${id}]: Started plugin.`);
408
408
  toDisconnect.push(contributions.push(Disposable.create(() => {
409
- console.debug(`[${this.clientId}][${id}]: Stopped plugin.`);
409
+ this.logger.debug(`[${this.clientId}][${id}]: Stopped plugin.`);
410
410
  manager.$stop(id);
411
411
  })));
412
412
 
413
413
  this.handlePluginStarted(manager, plugin);
414
414
  }
415
415
  } catch (e) {
416
- console.error(`Failed to start plugins for '${host}' host`, e);
416
+ this.logger.error(`Failed to start plugins for '${host}' host`, e);
417
417
  }
418
418
  })());
419
419
  }
@@ -22,9 +22,11 @@ import { inject, injectable, named } from '@theia/core/shared/inversify';
22
22
  import { DeployedPlugin, Localization as PluginLocalization, PluginIdentifiers, Translation } from '../../common';
23
23
  import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
24
24
  import { BackendApplicationContribution } from '@theia/core/lib/node';
25
- import { Disposable, DisposableCollection, isObject, MaybePromise, nls, Path, URI, ILogger } from '@theia/core';
25
+ import { Disposable, DisposableCollection, MaybePromise, nls, Path, URI, ILogger } from '@theia/core';
26
26
  import { Deferred } from '@theia/core/lib/common/promise-util';
27
27
  import { LanguagePackBundle, LanguagePackService } from '../../common/language-pack-service';
28
+ import { localizePackage } from '@theia/plugin-utils/lib/common/package-nls';
29
+ import { loadPackageTranslations } from '@theia/plugin-utils/lib/node/package-nls';
28
30
 
29
31
  export interface VSCodeNlsConfig {
30
32
  locale: string
@@ -327,84 +329,3 @@ async function loadTranslations(packagePath: Path, translations: Translation[]):
327
329
  function buildTranslationKey(pluginId: string, scope: string, key: string): string {
328
330
  return `${pluginId}/${Localization.transformKey(scope)}/${key}`;
329
331
  }
330
-
331
- // Localization logic for `package.json` entries
332
- // Extensions can use `package.nls.json` files to store translations for values in their package.json
333
- // This logic has not changed with the introduction of the vscode.l10n API
334
-
335
- interface PackageTranslation {
336
- translation?: Record<string, string>
337
- default?: Record<string, string>
338
- }
339
-
340
- async function loadPackageTranslations(pluginPath: string, locale: string): Promise<PackageTranslation> {
341
- const localizedPluginPath = path.join(pluginPath, `package.nls.${locale}.json`);
342
- try {
343
- const defaultValue = coerceLocalizations(await fs.readJson(path.join(pluginPath, 'package.nls.json')));
344
- if (await fs.pathExists(localizedPluginPath)) {
345
- return {
346
- translation: coerceLocalizations(await fs.readJson(localizedPluginPath)),
347
- default: defaultValue
348
- };
349
- }
350
- return {
351
- default: defaultValue
352
- };
353
- } catch (e) {
354
- if (e.code !== 'ENOENT') {
355
- throw e;
356
- }
357
- return {};
358
- }
359
- }
360
-
361
- interface LocalizeInfo {
362
- message: string
363
- comment?: string
364
- }
365
-
366
- function isLocalizeInfo(obj: unknown): obj is LocalizeInfo {
367
- return isObject(obj) && 'message' in obj || false;
368
- }
369
-
370
- function coerceLocalizations(translations: Record<string, string | LocalizeInfo>): Record<string, string> {
371
- for (const [key, value] of Object.entries(translations)) {
372
- if (isLocalizeInfo(value)) {
373
- translations[key] = value.message;
374
- } else if (typeof value !== 'string') {
375
- // Only strings or LocalizeInfo values are valid
376
- translations[key] = 'INVALID TRANSLATION VALUE';
377
- }
378
- }
379
- return translations as Record<string, string>;
380
- }
381
-
382
- function localizePackage(value: unknown, translations: PackageTranslation, callback: (key: string, defaultValue: string) => string): unknown {
383
- if (typeof value === 'string') {
384
- let result = value;
385
- if (value.length > 2 && value.startsWith('%') && value.endsWith('%')) {
386
- const key = value.slice(1, -1);
387
- if (translations.translation && key in translations.translation) {
388
- result = translations.translation[key];
389
- } else if (translations.default && key in translations.default) {
390
- result = callback(key, translations.default[key]);
391
- }
392
- }
393
- return result;
394
- }
395
- if (Array.isArray(value)) {
396
- const result = [];
397
- for (const item of value) {
398
- result.push(localizePackage(item, translations, callback));
399
- }
400
- return result;
401
- }
402
- if (isObject(value)) {
403
- const result: Record<string, unknown> = {};
404
- for (const [name, item] of Object.entries(value)) {
405
- result[name] = localizePackage(item, translations, callback);
406
- }
407
- return result;
408
- }
409
- return value;
410
- }
@@ -46,7 +46,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
46
46
  @inject(HostedPluginProcessConfiguration)
47
47
  protected configuration: HostedPluginProcessConfiguration;
48
48
 
49
- @inject(ILogger)
49
+ @inject(ILogger) @named('plugin-ext:HostedPluginProcess')
50
50
  protected readonly logger: ILogger;
51
51
 
52
52
  @inject(HostedPluginCliContribution)
@@ -14,7 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { injectable, inject, multiInject, postConstruct, optional } from '@theia/core/shared/inversify';
17
+ import { injectable, inject, multiInject, postConstruct, optional, named } from '@theia/core/shared/inversify';
18
18
  import { ILogger, ConnectionErrorHandler } from '@theia/core/lib/common';
19
19
  import { HostedPluginClient, PluginModel, ServerPluginRunner } from '../../common/plugin-protocol';
20
20
  import { LogPart } from '../../common/types';
@@ -32,7 +32,7 @@ export class HostedPluginSupport {
32
32
  private isPluginProcessRunning = false;
33
33
  private client: HostedPluginClient;
34
34
 
35
- @inject(ILogger)
35
+ @inject(ILogger) @named('plugin-ext:HostedPluginSupport')
36
36
  protected readonly logger: ILogger;
37
37
 
38
38
  @inject(HostedPluginProcess)
@@ -25,7 +25,7 @@ import {
25
25
  MAIN_RPC_CONTEXT, Plugin, PluginAPIFactory, PluginManager,
26
26
  LocalizationExt
27
27
  } from '../../common/plugin-api-rpc';
28
- import { PluginMetadata, PluginModel } from '../../common/plugin-protocol';
28
+ import { PluginMetadata, PluginModel, PluginPackage } from '../../common/plugin-protocol';
29
29
  import { createAPIFactory } from '../../plugin/plugin-context';
30
30
  import { EnvExtImpl } from '../../plugin/env';
31
31
  import { PreferenceRegistryExtImpl } from '../../plugin/preference-registry';
@@ -35,7 +35,7 @@ import { EditorsAndDocumentsExtImpl } from '../../plugin/editors-and-documents';
35
35
  import { WorkspaceExtImpl } from '../../plugin/workspace';
36
36
  import { MessageRegistryExt } from '../../plugin/message-registry';
37
37
  import { ClipboardExt } from '../../plugin/clipboard-ext';
38
- import { loadManifest } from './plugin-manifest-loader';
38
+ import { loadManifest } from '@theia/plugin-utils/lib/node/plugin-manifest';
39
39
  import { KeyValueStorageProxy } from '../../plugin/plugin-storage';
40
40
  import { WebviewsExtImpl } from '../../plugin/webviews';
41
41
  import { TerminalServiceExtImpl } from '../../plugin/terminal-ext';
@@ -214,7 +214,7 @@ export abstract class AbstractPluginHostRPC<PM extends AbstractPluginManagerExtI
214
214
  const pluginModel = plg.model;
215
215
  const pluginLifecycle = plg.lifecycle;
216
216
 
217
- const rawModel = await loadManifest(pluginModel.packagePath);
217
+ const rawModel = await loadManifest<PluginPackage>(pluginModel.packagePath);
218
218
  rawModel.packagePath = pluginModel.packagePath;
219
219
  if (pluginModel.entryPoint!.frontend) {
220
220
  foreign.push({
@@ -19,16 +19,17 @@ import * as express from '@theia/core/shared/express';
19
19
  import * as escape_html from 'escape-html';
20
20
  import { realpath, stat } from 'fs/promises';
21
21
  import { ILogger } from '@theia/core';
22
- import { inject, injectable, optional, multiInject } from '@theia/core/shared/inversify';
22
+ import { inject, injectable, optional, multiInject, named } from '@theia/core/shared/inversify';
23
23
  import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
24
24
  import { PluginMetadata, getPluginId, MetadataProcessor, PluginPackage, PluginContribution } from '../../common/plugin-protocol';
25
25
  import { MetadataScanner } from './metadata-scanner';
26
- import { loadManifest } from './plugin-manifest-loader';
26
+ import { loadManifest } from '@theia/plugin-utils/lib/node/plugin-manifest';
27
+ import { PLUGINS_BASE_PATH } from '@theia/plugin-utils/lib/common/constants';
27
28
 
28
29
  @injectable()
29
30
  export class HostedPluginReader implements BackendApplicationContribution {
30
31
 
31
- @inject(ILogger)
32
+ @inject(ILogger) @named('plugin-ext:HostedPluginReader')
32
33
  protected readonly logger: ILogger;
33
34
 
34
35
  @inject(MetadataScanner)
@@ -43,7 +44,7 @@ export class HostedPluginReader implements BackendApplicationContribution {
43
44
  protected pluginsIdsFiles: Map<string, string> = new Map();
44
45
 
45
46
  configure(app: express.Application): void {
46
- app.get('/hostedPlugin/:pluginId/:path(*)', async (req, res) => {
47
+ app.get(`/${PLUGINS_BASE_PATH}/:pluginId/:path(*)`, async (req, res) => {
47
48
  const pluginId = req.params.pluginId;
48
49
  const filePath = req.params.path;
49
50
 
@@ -59,7 +60,7 @@ export class HostedPluginReader implements BackendApplicationContribution {
59
60
  // the file was found and successfully transferred
60
61
  return;
61
62
  }
62
- console.error(`Could not transfer '${filePath}' file from '${pluginId}'`, e);
63
+ this.logger.error(`Could not transfer '${filePath}' file from '${pluginId}'`, e);
63
64
  if (res.headersSent) {
64
65
  // the request was already closed
65
66
  return;
@@ -141,7 +142,7 @@ export class HostedPluginReader implements BackendApplicationContribution {
141
142
  return undefined;
142
143
  }
143
144
  const resolvedPluginPath = await realpath(pluginPath);
144
- const manifest = await loadManifest(resolvedPluginPath);
145
+ const manifest = await loadManifest<PluginPackage>(resolvedPluginPath);
145
146
  if (!manifest) {
146
147
  return undefined;
147
148
  }
@@ -37,7 +37,7 @@ export type BackendPluginHostableFilter = (plugin: DeployedPlugin) => boolean;
37
37
  */
38
38
  @injectable()
39
39
  export class HostedPluginServerImpl implements HostedPluginServer {
40
- @inject(ILogger)
40
+ @inject(ILogger) @named('plugin-ext:HostedPluginServerImpl')
41
41
  protected readonly logger: ILogger;
42
42
 
43
43
  @inject(PluginDeployerHandlerImpl)
@@ -16,16 +16,20 @@
16
16
 
17
17
  import { injectable } from '@theia/core/shared/inversify';
18
18
  import { PluginPackageGrammarsContribution, GrammarsContribution } from '../../../common';
19
- import * as path from 'path';
20
- import * as fs from '@theia/core/shared/fs-extra';
19
+ import { readGrammarFromDisk } from '@theia/plugin-utils/lib/node/read-grammars';
20
+ import type { NormalizeContributionsContext } from '@theia/plugin-utils/lib/common/contribution-types';
21
21
 
22
22
  @injectable()
23
23
  export class GrammarsReader {
24
24
 
25
- async readGrammars(rawGrammars: PluginPackageGrammarsContribution[], pluginPath: string): Promise<GrammarsContribution[]> {
25
+ async readGrammars(
26
+ rawGrammars: readonly PluginPackageGrammarsContribution[],
27
+ pluginPath: string,
28
+ log?: Pick<NormalizeContributionsContext, 'onError'>
29
+ ): Promise<GrammarsContribution[]> {
26
30
  const result = new Array<GrammarsContribution>();
27
31
  for (const rawGrammar of rawGrammars) {
28
- const grammar = await this.readGrammar(rawGrammar, pluginPath);
32
+ const grammar = await this.readGrammar(rawGrammar, pluginPath, log);
29
33
  if (grammar) {
30
34
  result.push(grammar);
31
35
  }
@@ -34,24 +38,11 @@ export class GrammarsReader {
34
38
  return result;
35
39
  }
36
40
 
37
- private async readGrammar(rawGrammar: PluginPackageGrammarsContribution, pluginPath: string): Promise<GrammarsContribution | undefined> {
38
- // TODO: validate inputs
39
- let grammar: string | object;
40
-
41
- if (rawGrammar.path.endsWith('json')) {
42
- grammar = await fs.readJSON(path.resolve(pluginPath, rawGrammar.path));
43
- } else {
44
- grammar = await fs.readFile(path.resolve(pluginPath, rawGrammar.path), 'utf8');
45
- }
46
- return {
47
- language: rawGrammar.language,
48
- scope: rawGrammar.scopeName,
49
- format: rawGrammar.path.endsWith('json') ? 'json' : 'plist',
50
- grammar: grammar,
51
- grammarLocation: rawGrammar.path,
52
- injectTo: rawGrammar.injectTo,
53
- embeddedLanguages: rawGrammar.embeddedLanguages,
54
- tokenTypes: rawGrammar.tokenTypes
55
- };
41
+ protected async readGrammar(
42
+ rawGrammar: PluginPackageGrammarsContribution,
43
+ pluginPath: string,
44
+ log?: Pick<NormalizeContributionsContext, 'onError'>
45
+ ): Promise<GrammarsContribution | undefined> {
46
+ return readGrammarFromDisk(rawGrammar, pluginPath, log);
56
47
  }
57
48
  }