@theia/plugin-ext 1.42.0 → 1.43.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 (189) hide show
  1. package/lib/common/arrays.d.ts +4 -0
  2. package/lib/common/arrays.d.ts.map +1 -1
  3. package/lib/common/arrays.js +15 -1
  4. package/lib/common/arrays.js.map +1 -1
  5. package/lib/common/commands.d.ts +4 -0
  6. package/lib/common/commands.d.ts.map +1 -0
  7. package/lib/common/commands.js +17 -0
  8. package/lib/common/commands.js.map +1 -0
  9. package/lib/common/plugin-api-rpc-model.d.ts +1 -0
  10. package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
  11. package/lib/common/plugin-api-rpc-model.js.map +1 -1
  12. package/lib/common/plugin-api-rpc.d.ts +48 -6
  13. package/lib/common/plugin-api-rpc.d.ts.map +1 -1
  14. package/lib/common/plugin-api-rpc.js +3 -2
  15. package/lib/common/plugin-api-rpc.js.map +1 -1
  16. package/lib/common/plugin-protocol.d.ts +27 -3
  17. package/lib/common/plugin-protocol.d.ts.map +1 -1
  18. package/lib/common/plugin-protocol.js +8 -1
  19. package/lib/common/plugin-protocol.js.map +1 -1
  20. package/lib/common/test-types.d.ts +83 -0
  21. package/lib/common/test-types.d.ts.map +1 -0
  22. package/lib/common/test-types.js +40 -0
  23. package/lib/common/test-types.js.map +1 -0
  24. package/lib/hosted/browser/hosted-plugin.d.ts +4 -1
  25. package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
  26. package/lib/hosted/browser/hosted-plugin.js +11 -0
  27. package/lib/hosted/browser/hosted-plugin.js.map +1 -1
  28. package/lib/hosted/node/hosted-plugin-localization-service.d.ts.map +1 -1
  29. package/lib/hosted/node/hosted-plugin-localization-service.js +71 -33
  30. package/lib/hosted/node/hosted-plugin-localization-service.js.map +1 -1
  31. package/lib/hosted/node/plugin-reader.d.ts.map +1 -1
  32. package/lib/hosted/node/plugin-reader.js +4 -2
  33. package/lib/hosted/node/plugin-reader.js.map +1 -1
  34. package/lib/hosted/node/scanners/scanner-theia.d.ts +5 -4
  35. package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
  36. package/lib/hosted/node/scanners/scanner-theia.js +79 -19
  37. package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
  38. package/lib/main/browser/command-registry-main.d.ts +3 -0
  39. package/lib/main/browser/command-registry-main.d.ts.map +1 -1
  40. package/lib/main/browser/command-registry-main.js +11 -1
  41. package/lib/main/browser/command-registry-main.js.map +1 -1
  42. package/lib/main/browser/languages-main.d.ts.map +1 -1
  43. package/lib/main/browser/languages-main.js +7 -5
  44. package/lib/main/browser/languages-main.js.map +1 -1
  45. package/lib/main/browser/main-context.d.ts.map +1 -1
  46. package/lib/main/browser/main-context.js +3 -0
  47. package/lib/main/browser/main-context.js.map +1 -1
  48. package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +2 -2
  49. package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts.map +1 -1
  50. package/lib/main/browser/menus/vscode-theia-menu-mappings.js +3 -0
  51. package/lib/main/browser/menus/vscode-theia-menu-mappings.js.map +1 -1
  52. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js +2 -2
  53. package/lib/main/browser/notebooks/notebook-documents-and-editors-main.js.map +1 -1
  54. package/lib/main/browser/notebooks/notebook-documents-main.js +1 -1
  55. package/lib/main/browser/notebooks/notebook-documents-main.js.map +1 -1
  56. package/lib/main/browser/notebooks/notebook-dto.js +2 -2
  57. package/lib/main/browser/notebooks/notebook-dto.js.map +1 -1
  58. package/lib/main/browser/notebooks/notebook-kernels-main.d.ts.map +1 -1
  59. package/lib/main/browser/notebooks/notebook-kernels-main.js +4 -10
  60. package/lib/main/browser/notebooks/notebook-kernels-main.js.map +1 -1
  61. package/lib/main/browser/notebooks/notebook-renderers-main.js +1 -1
  62. package/lib/main/browser/notebooks/notebook-renderers-main.js.map +1 -1
  63. package/lib/main/browser/notebooks/notebooks-main.d.ts +2 -2
  64. package/lib/main/browser/notebooks/notebooks-main.d.ts.map +1 -1
  65. package/lib/main/browser/notebooks/notebooks-main.js +5 -5
  66. package/lib/main/browser/notebooks/notebooks-main.js.map +1 -1
  67. package/lib/main/browser/notebooks/renderers/cell-output-webview.d.ts.map +1 -1
  68. package/lib/main/browser/notebooks/renderers/cell-output-webview.js +3 -0
  69. package/lib/main/browser/notebooks/renderers/cell-output-webview.js.map +1 -1
  70. package/lib/main/browser/notebooks/renderers/output-webview-internal.d.ts.map +1 -1
  71. package/lib/main/browser/notebooks/renderers/output-webview-internal.js +4 -2
  72. package/lib/main/browser/notebooks/renderers/output-webview-internal.js.map +1 -1
  73. package/lib/main/browser/plugin-contribution-handler.d.ts +2 -0
  74. package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
  75. package/lib/main/browser/plugin-contribution-handler.js +19 -1
  76. package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
  77. package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
  78. package/lib/main/browser/plugin-ext-frontend-module.js +3 -0
  79. package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
  80. package/lib/main/browser/plugin-icon-service.d.ts +20 -0
  81. package/lib/main/browser/plugin-icon-service.d.ts.map +1 -0
  82. package/lib/main/browser/plugin-icon-service.js +156 -0
  83. package/lib/main/browser/plugin-icon-service.js.map +1 -0
  84. package/lib/main/browser/terminal-main.d.ts +2 -2
  85. package/lib/main/browser/terminal-main.d.ts.map +1 -1
  86. package/lib/main/browser/terminal-main.js +5 -9
  87. package/lib/main/browser/terminal-main.js.map +1 -1
  88. package/lib/main/browser/test-main.d.ts +141 -0
  89. package/lib/main/browser/test-main.d.ts.map +1 -0
  90. package/lib/main/browser/test-main.js +560 -0
  91. package/lib/main/browser/test-main.js.map +1 -0
  92. package/lib/main/browser/view/plugin-view-registry.d.ts +14 -3
  93. package/lib/main/browser/view/plugin-view-registry.d.ts.map +1 -1
  94. package/lib/main/browser/view/plugin-view-registry.js +108 -56
  95. package/lib/main/browser/view/plugin-view-registry.js.map +1 -1
  96. package/lib/main/browser/webview-views/webview-views-main.d.ts.map +1 -1
  97. package/lib/main/browser/webview-views/webview-views-main.js +5 -2
  98. package/lib/main/browser/webview-views/webview-views-main.js.map +1 -1
  99. package/lib/main/browser/webview-views/webview-views.d.ts +1 -0
  100. package/lib/main/browser/webview-views/webview-views.d.ts.map +1 -1
  101. package/lib/main/node/plugin-service.d.ts +2 -0
  102. package/lib/main/node/plugin-service.d.ts.map +1 -1
  103. package/lib/main/node/plugin-service.js +14 -1
  104. package/lib/main/node/plugin-service.js.map +1 -1
  105. package/lib/plugin/command-registry.d.ts +1 -3
  106. package/lib/plugin/command-registry.d.ts.map +1 -1
  107. package/lib/plugin/command-registry.js.map +1 -1
  108. package/lib/plugin/notebook/notebook-kernels.d.ts.map +1 -1
  109. package/lib/plugin/notebook/notebook-kernels.js +1 -0
  110. package/lib/plugin/notebook/notebook-kernels.js.map +1 -1
  111. package/lib/plugin/notebook/notebooks.d.ts.map +1 -1
  112. package/lib/plugin/notebook/notebooks.js +2 -2
  113. package/lib/plugin/notebook/notebooks.js.map +1 -1
  114. package/lib/plugin/plugin-context.d.ts.map +1 -1
  115. package/lib/plugin/plugin-context.js +9 -18
  116. package/lib/plugin/plugin-context.js.map +1 -1
  117. package/lib/plugin/telemetry-ext.js +1 -1
  118. package/lib/plugin/telemetry-ext.js.map +1 -1
  119. package/lib/plugin/terminal-ext.d.ts +11 -9
  120. package/lib/plugin/terminal-ext.d.ts.map +1 -1
  121. package/lib/plugin/terminal-ext.js +37 -25
  122. package/lib/plugin/terminal-ext.js.map +1 -1
  123. package/lib/plugin/test-item.d.ts +47 -0
  124. package/lib/plugin/test-item.d.ts.map +1 -0
  125. package/lib/plugin/test-item.js +196 -0
  126. package/lib/plugin/test-item.js.map +1 -0
  127. package/lib/plugin/tests.d.ts +117 -0
  128. package/lib/plugin/tests.d.ts.map +1 -0
  129. package/lib/plugin/tests.js +402 -0
  130. package/lib/plugin/tests.js.map +1 -0
  131. package/lib/plugin/tree/tree-views.d.ts.map +1 -1
  132. package/lib/plugin/tree/tree-views.js +2 -1
  133. package/lib/plugin/tree/tree-views.js.map +1 -1
  134. package/lib/plugin/type-converters.d.ts +10 -1
  135. package/lib/plugin/type-converters.d.ts.map +1 -1
  136. package/lib/plugin/type-converters.js +74 -2
  137. package/lib/plugin/type-converters.js.map +1 -1
  138. package/lib/plugin/types-impl.d.ts +29 -4
  139. package/lib/plugin/types-impl.d.ts.map +1 -1
  140. package/lib/plugin/types-impl.js +30 -8
  141. package/lib/plugin/types-impl.js.map +1 -1
  142. package/package.json +30 -29
  143. package/src/common/arrays.ts +16 -0
  144. package/src/common/commands.ts +19 -0
  145. package/src/common/plugin-api-rpc-model.ts +1 -0
  146. package/src/common/plugin-api-rpc.ts +69 -7
  147. package/src/common/plugin-protocol.ts +31 -3
  148. package/src/common/test-types.ts +133 -0
  149. package/src/hosted/browser/hosted-plugin.ts +13 -1
  150. package/src/hosted/node/hosted-plugin-localization-service.ts +72 -37
  151. package/src/hosted/node/plugin-reader.ts +4 -2
  152. package/src/hosted/node/scanners/scanner-theia.ts +85 -20
  153. package/src/main/browser/command-registry-main.ts +14 -1
  154. package/src/main/browser/languages-main.ts +7 -5
  155. package/src/main/browser/main-context.ts +4 -0
  156. package/src/main/browser/menus/vscode-theia-menu-mappings.ts +3 -0
  157. package/src/main/browser/notebooks/notebook-documents-and-editors-main.ts +2 -2
  158. package/src/main/browser/notebooks/notebook-documents-main.ts +1 -1
  159. package/src/main/browser/notebooks/notebook-dto.ts +2 -2
  160. package/src/main/browser/notebooks/notebook-kernels-main.ts +6 -11
  161. package/src/main/browser/notebooks/notebook-renderers-main.ts +1 -1
  162. package/src/main/browser/notebooks/notebooks-main.ts +6 -6
  163. package/src/main/browser/notebooks/renderers/cell-output-webview.tsx +3 -0
  164. package/src/main/browser/notebooks/renderers/output-webview-internal.ts +3 -2
  165. package/src/main/browser/plugin-contribution-handler.ts +19 -2
  166. package/src/main/browser/plugin-ext-frontend-module.ts +4 -0
  167. package/src/main/browser/plugin-icon-service.ts +156 -0
  168. package/src/main/browser/terminal-main.ts +7 -11
  169. package/src/main/browser/test-main.ts +618 -0
  170. package/src/main/browser/view/plugin-view-registry.ts +114 -56
  171. package/src/main/browser/webview-views/webview-views-main.ts +5 -2
  172. package/src/main/browser/webview-views/webview-views.ts +1 -0
  173. package/src/main/node/plugin-service.ts +12 -1
  174. package/src/plugin/command-registry.ts +1 -5
  175. package/src/plugin/notebook/notebook-kernels.ts +3 -1
  176. package/src/plugin/notebook/notebooks.ts +1 -3
  177. package/src/plugin/plugin-context.ts +13 -32
  178. package/src/plugin/telemetry-ext.ts +1 -1
  179. package/src/plugin/terminal-ext.ts +40 -26
  180. package/src/plugin/test-item.ts +174 -0
  181. package/src/plugin/tests.ts +482 -0
  182. package/src/plugin/tree/tree-views.ts +2 -1
  183. package/src/plugin/type-converters.ts +87 -3
  184. package/src/plugin/types-impl.ts +36 -5
  185. package/lib/plugin/stubs/tests-api.d.ts +0 -25
  186. package/lib/plugin/stubs/tests-api.d.ts.map +0 -1
  187. package/lib/plugin/stubs/tests-api.js +0 -70
  188. package/lib/plugin/stubs/tests-api.js.map +0 -1
  189. package/src/plugin/stubs/tests-api.ts +0 -102
@@ -0,0 +1,156 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { asCSSPropertyValue } from '@theia/monaco-editor-core/esm/vs/base/browser/dom';
18
+ import { Endpoint } from '@theia/core/lib/browser';
19
+ import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
20
+ import { getIconRegistry } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/iconRegistry';
21
+ import { inject, injectable } from '@theia/core/shared/inversify';
22
+ import { URI } from '@theia/core/shared/vscode-uri';
23
+ import { IconFontDefinition, IconContribution as Icon } from '@theia/core/lib/browser/icon-registry';
24
+ import { MonacoIconRegistry } from '@theia/monaco/lib/browser/monaco-icon-registry';
25
+ import * as path from 'path';
26
+ import { IconContribution, DeployedPlugin, IconDefinition } from '../../common/plugin-protocol';
27
+ import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
28
+ import { UnthemedProductIconTheme } from '@theia/monaco-editor-core/esm/vs/platform/theme/browser/iconsStyleSheet';
29
+
30
+ @injectable()
31
+ export class PluginIconService implements Disposable {
32
+
33
+ @inject(MonacoIconRegistry)
34
+ protected readonly iconRegistry: MonacoIconRegistry;
35
+
36
+ protected readonly toDispose = new DisposableCollection();
37
+
38
+ styleSheet: string = '';
39
+ styleElement: HTMLStyleElement;
40
+
41
+ register(contribution: IconContribution, plugin: DeployedPlugin): Disposable {
42
+ const defaultIcon = contribution.defaults;
43
+ if (IconContribution.isIconDefinition(defaultIcon)) {
44
+ this.registerFontIcon(contribution, defaultIcon);
45
+ } else {
46
+ this.registerRegularIcon(contribution, defaultIcon.id);
47
+ }
48
+ this.updateStyle(contribution);
49
+ return Disposable.NULL;
50
+ }
51
+
52
+ updateStyle(contribution: IconContribution): void {
53
+ this.updateStyleElement();
54
+ const css = this.getCSS(contribution);
55
+ if (css) {
56
+ this.styleElement.innerText = css;
57
+ }
58
+ const toRemoveStyleElement = Disposable.create(() => this.styleElement.remove());
59
+ this.toDispose.push(toRemoveStyleElement);
60
+ }
61
+
62
+ dispose(): void {
63
+ this.toDispose.dispose();
64
+ }
65
+
66
+ protected registerFontIcon(contribution: IconContribution, defaultIcon: IconDefinition): void {
67
+ const location = defaultIcon.location;
68
+ const format = getFileExtension(location);
69
+ const fontId = getFontId(contribution.extensionId, location);
70
+ const definition = this.iconRegistry.registerIconFont(fontId, { src: [{ location: URI.file(location), format }] });
71
+ this.iconRegistry.registerIcon(contribution.id, {
72
+ fontCharacter: defaultIcon.fontCharacter,
73
+ font: {
74
+ id: fontId,
75
+ definition
76
+ }
77
+ }, contribution.description);
78
+ }
79
+
80
+ protected registerRegularIcon(contribution: IconContribution, defaultIconId: string): void {
81
+ this.iconRegistry.registerIcon(contribution.id, { id: defaultIconId }, contribution.description);
82
+ }
83
+
84
+ protected updateStyleElement(): void {
85
+ if (!this.styleElement) {
86
+ const styleElement = document.createElement('style');
87
+ styleElement.type = 'text/css';
88
+ styleElement.media = 'screen';
89
+ styleElement.id = 'contributedIconsStyles';
90
+ document.head.appendChild(styleElement);
91
+ this.styleElement = styleElement;
92
+ }
93
+ }
94
+ protected getCSS(iconContribution: IconContribution, themeService?: IThemeService): string | undefined {
95
+ const iconRegistry = getIconRegistry();
96
+ const productIconTheme = themeService ? themeService.getProductIconTheme() : new UnthemedProductIconTheme();
97
+ const usedFontIds: { [id: string]: IconFontDefinition } = {};
98
+ const formatIconRule = (contribution: Icon): string | undefined => {
99
+ const definition = productIconTheme.getIcon(contribution);
100
+ if (!definition) {
101
+ return undefined;
102
+ }
103
+ const fontContribution = definition.font;
104
+ if (fontContribution) {
105
+ usedFontIds[fontContribution.id] = fontContribution.definition;
106
+ return `.codicon-${contribution.id}:before { content: '${definition.fontCharacter}'; font-family: ${asCSSPropertyValue(iconContribution.extensionId)}; }`;
107
+ }
108
+ // default font (codicon)
109
+ return `.codicon-${contribution.id}:before { content: '${definition.fontCharacter}'; }`;
110
+ };
111
+
112
+ const rules = [];
113
+ for (const contribution of iconRegistry.getIcons()) {
114
+ const rule = formatIconRule(contribution);
115
+ if (rule) {
116
+ rules.push(rule);
117
+ }
118
+ }
119
+ for (const id in usedFontIds) {
120
+ if (id) {
121
+ const definition = usedFontIds[id];
122
+ const fontWeight = definition.weight ? `font-weight: ${definition.weight};` : '';
123
+ const fontStyle = definition.style ? `font-style: ${definition.style};` : '';
124
+ const src = definition.src.map(icon =>
125
+ `${this.toPluginUrl(iconContribution.extensionId, getIconRelativePath(icon.location.path))} format('${icon.format}')`)
126
+ .join(', ');
127
+ rules.push(`@font-face { src: ${src}; font-family: ${asCSSPropertyValue(iconContribution.extensionId)};${fontWeight}${fontStyle} font-display: block; }`);
128
+ }
129
+ }
130
+ return rules.join('\n');
131
+ }
132
+
133
+ protected toPluginUrl(id: string, relativePath: string): string {
134
+ return `url('${new Endpoint({
135
+ path: `hostedPlugin/${this.formatExtensionId(id)}/${encodeURIComponent(relativePath)}`
136
+ }).getRestUrl().toString()}')`;
137
+ }
138
+
139
+ protected formatExtensionId(id: string): string {
140
+ return id.replace(/\W/g, '_');
141
+ }
142
+ }
143
+
144
+ function getIconRelativePath(iconPath: string): string {
145
+ const index = iconPath.indexOf('extension');
146
+ return index === -1 ? '' : iconPath.substring(index + 'extension'.length + 1);
147
+ }
148
+
149
+ function getFontId(extensionId: string, fontPath: string): string {
150
+ return path.join(extensionId, fontPath);
151
+ }
152
+
153
+ function getFileExtension(filePath: string): string {
154
+ const index = filePath.lastIndexOf('.');
155
+ return index === -1 ? '' : filePath.substring(index + 1);
156
+ }
@@ -22,8 +22,7 @@ import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-servi
22
22
  import { TerminalServiceMain, TerminalServiceExt, MAIN_RPC_CONTEXT } from '../../common/plugin-api-rpc';
23
23
  import { RPCProtocol } from '../../common/rpc-protocol';
24
24
  import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable';
25
- import { SerializableEnvironmentVariableCollection, SerializableExtensionEnvironmentVariableCollection } from '@theia/terminal/lib/common/base-terminal-protocol';
26
- import { ShellTerminalServerProxy } from '@theia/terminal/lib/common/shell-terminal-protocol';
25
+ import { SerializableEnvironmentVariableCollection, ShellTerminalServerProxy } from '@theia/terminal/lib/common/shell-terminal-protocol';
27
26
  import { TerminalLink, TerminalLinkProvider } from '@theia/terminal/lib/browser/terminal-link-provider';
28
27
  import { URI } from '@theia/core/lib/common/uri';
29
28
  import { getIconClass } from '../../plugin/terminal-ext';
@@ -59,11 +58,8 @@ export class TerminalServiceMainImpl implements TerminalServiceMain, TerminalLin
59
58
  }
60
59
  this.toDispose.push(this.terminals.onDidChangeCurrentTerminal(() => this.updateCurrentTerminal()));
61
60
  this.updateCurrentTerminal();
62
- if (this.shellTerminalServer.collections.size > 0) {
63
- const collectionAsArray = [...this.shellTerminalServer.collections.entries()];
64
- const serializedCollections: [string, SerializableEnvironmentVariableCollection][] = collectionAsArray.map(e => [e[0], [...e[1].map.entries()]]);
65
- this.extProxy.$initEnvironmentVariableCollections(serializedCollections);
66
- }
61
+
62
+ this.shellTerminalServer.getEnvVarCollections().then(collections => this.extProxy.$initEnvironmentVariableCollections(collections));
67
63
 
68
64
  this.pluginTerminalRegistry.startCallback = id => this.startProfile(id);
69
65
 
@@ -75,11 +71,11 @@ export class TerminalServiceMainImpl implements TerminalServiceMain, TerminalLin
75
71
  return this.extProxy.$startProfile(id, CancellationToken.None);
76
72
  }
77
73
 
78
- $setEnvironmentVariableCollection(persistent: boolean, collection: SerializableExtensionEnvironmentVariableCollection): void {
79
- if (collection.collection) {
80
- this.shellTerminalServer.setCollection(collection.extensionIdentifier, persistent, collection.collection, collection.description);
74
+ $setEnvironmentVariableCollection(persistent: boolean, extensionIdentifier: string, rootUri: string, collection: SerializableEnvironmentVariableCollection): void {
75
+ if (collection) {
76
+ this.shellTerminalServer.setCollection(extensionIdentifier, rootUri, persistent, collection, collection.description);
81
77
  } else {
82
- this.shellTerminalServer.deleteCollection(collection.extensionIdentifier);
78
+ this.shellTerminalServer.deleteCollection(extensionIdentifier);
83
79
  }
84
80
  }
85
81