@theia/vsx-registry 1.45.1 → 1.46.0-next.72

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 (100) hide show
  1. package/README.md +45 -45
  2. package/lib/browser/recommended-extensions/preference-provider-overrides.d.ts +17 -17
  3. package/lib/browser/recommended-extensions/preference-provider-overrides.js +95 -95
  4. package/lib/browser/recommended-extensions/recommended-extensions-json-schema.d.ts +14 -14
  5. package/lib/browser/recommended-extensions/recommended-extensions-json-schema.js +94 -94
  6. package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.d.ts +11 -11
  7. package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js +59 -59
  8. package/lib/browser/vsx-extension-commands.d.ts +14 -13
  9. package/lib/browser/vsx-extension-commands.d.ts.map +1 -1
  10. package/lib/browser/vsx-extension-commands.js +68 -63
  11. package/lib/browser/vsx-extension-commands.js.map +1 -1
  12. package/lib/browser/vsx-extension-editor-manager.d.ts +9 -9
  13. package/lib/browser/vsx-extension-editor-manager.js +49 -49
  14. package/lib/browser/vsx-extension-editor.d.ts +21 -21
  15. package/lib/browser/vsx-extension-editor.js +109 -109
  16. package/lib/browser/vsx-extension.d.ts +146 -143
  17. package/lib/browser/vsx-extension.d.ts.map +1 -1
  18. package/lib/browser/vsx-extension.js +616 -596
  19. package/lib/browser/vsx-extension.js.map +1 -1
  20. package/lib/browser/vsx-extensions-contribution.d.ts +70 -60
  21. package/lib/browser/vsx-extensions-contribution.d.ts.map +1 -1
  22. package/lib/browser/vsx-extensions-contribution.js +375 -344
  23. package/lib/browser/vsx-extensions-contribution.js.map +1 -1
  24. package/lib/browser/vsx-extensions-model.d.ts +75 -72
  25. package/lib/browser/vsx-extensions-model.d.ts.map +1 -1
  26. package/lib/browser/vsx-extensions-model.js +437 -391
  27. package/lib/browser/vsx-extensions-model.js.map +1 -1
  28. package/lib/browser/vsx-extensions-preferences.d.ts +12 -0
  29. package/lib/browser/vsx-extensions-preferences.d.ts.map +1 -0
  30. package/lib/browser/vsx-extensions-preferences.js +47 -0
  31. package/lib/browser/vsx-extensions-preferences.js.map +1 -0
  32. package/lib/browser/vsx-extensions-search-bar.d.ts +22 -14
  33. package/lib/browser/vsx-extensions-search-bar.d.ts.map +1 -1
  34. package/lib/browser/vsx-extensions-search-bar.js +106 -75
  35. package/lib/browser/vsx-extensions-search-bar.js.map +1 -1
  36. package/lib/browser/vsx-extensions-search-model.d.ts +21 -21
  37. package/lib/browser/vsx-extensions-search-model.js +70 -70
  38. package/lib/browser/vsx-extensions-source.d.ts +19 -19
  39. package/lib/browser/vsx-extensions-source.js +102 -102
  40. package/lib/browser/vsx-extensions-view-container.d.ts +49 -49
  41. package/lib/browser/vsx-extensions-view-container.js +179 -179
  42. package/lib/browser/vsx-extensions-widget.d.ts +35 -34
  43. package/lib/browser/vsx-extensions-widget.d.ts.map +1 -1
  44. package/lib/browser/vsx-extensions-widget.js +164 -156
  45. package/lib/browser/vsx-extensions-widget.js.map +1 -1
  46. package/lib/browser/vsx-language-quick-pick-service.d.ts +15 -15
  47. package/lib/browser/vsx-language-quick-pick-service.js +121 -121
  48. package/lib/browser/vsx-registry-frontend-module.d.ts +4 -4
  49. package/lib/browser/vsx-registry-frontend-module.d.ts.map +1 -1
  50. package/lib/browser/vsx-registry-frontend-module.js +99 -97
  51. package/lib/browser/vsx-registry-frontend-module.js.map +1 -1
  52. package/lib/common/index.d.ts +3 -3
  53. package/lib/common/index.js +25 -25
  54. package/lib/common/ovsx-client-provider.d.ts +13 -13
  55. package/lib/common/ovsx-client-provider.js +29 -29
  56. package/lib/common/vsx-environment.d.ts +9 -9
  57. package/lib/common/vsx-environment.js +20 -20
  58. package/lib/common/vsx-extension-uri.d.ts +3 -3
  59. package/lib/common/vsx-extension-uri.js +20 -20
  60. package/lib/common/vsx-registry-common-module.d.ts +3 -3
  61. package/lib/common/vsx-registry-common-module.js +57 -57
  62. package/lib/node/vsx-cli.d.ts +9 -9
  63. package/lib/node/vsx-cli.js +41 -41
  64. package/lib/node/vsx-environment-impl.d.ts +14 -14
  65. package/lib/node/vsx-environment-impl.js +61 -61
  66. package/lib/node/vsx-extension-resolver.d.ts +20 -20
  67. package/lib/node/vsx-extension-resolver.js +154 -154
  68. package/lib/node/vsx-registry-backend-module.d.ts +3 -3
  69. package/lib/node/vsx-registry-backend-module.js +35 -35
  70. package/lib/package.spec.js +25 -25
  71. package/package.json +12 -12
  72. package/src/browser/recommended-extensions/preference-provider-overrides.ts +99 -99
  73. package/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +74 -74
  74. package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +68 -68
  75. package/src/browser/style/extensions.svg +4 -4
  76. package/src/browser/style/index.css +436 -373
  77. package/src/browser/vsx-extension-commands.ts +68 -63
  78. package/src/browser/vsx-extension-editor-manager.ts +42 -42
  79. package/src/browser/vsx-extension-editor.tsx +96 -96
  80. package/src/browser/vsx-extension.tsx +704 -675
  81. package/src/browser/vsx-extensions-contribution.ts +361 -327
  82. package/src/browser/vsx-extensions-model.ts +436 -389
  83. package/src/browser/vsx-extensions-preferences.ts +58 -0
  84. package/src/browser/vsx-extensions-search-bar.tsx +107 -69
  85. package/src/browser/vsx-extensions-search-model.ts +61 -61
  86. package/src/browser/vsx-extensions-source.ts +83 -83
  87. package/src/browser/vsx-extensions-view-container.ts +179 -179
  88. package/src/browser/vsx-extensions-widget.tsx +165 -156
  89. package/src/browser/vsx-language-quick-pick-service.ts +110 -110
  90. package/src/browser/vsx-registry-frontend-module.ts +108 -106
  91. package/src/common/index.ts +19 -19
  92. package/src/common/ovsx-client-provider.ts +35 -35
  93. package/src/common/vsx-environment.ts +27 -27
  94. package/src/common/vsx-extension-uri.ts +20 -20
  95. package/src/common/vsx-registry-common-module.ts +63 -63
  96. package/src/node/vsx-cli.ts +38 -38
  97. package/src/node/vsx-environment-impl.ts +50 -50
  98. package/src/node/vsx-extension-resolver.ts +125 -125
  99. package/src/node/vsx-registry-backend-module.ts +35 -35
  100. package/src/package.spec.ts +29 -29
@@ -1,345 +1,376 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2020 TypeFox and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.VSXExtensionsContribution = exports.VSXCommands = void 0;
28
- const luxon_1 = require("luxon");
29
- const inversify_1 = require("@theia/core/shared/inversify");
30
- const debounce = require("@theia/core/shared/lodash.debounce");
31
- const command_1 = require("@theia/core/lib/common/command");
32
- const view_contribution_1 = require("@theia/core/lib/browser/shell/view-contribution");
33
- const vsx_extensions_view_container_1 = require("./vsx-extensions-view-container");
34
- const vsx_extensions_model_1 = require("./vsx-extensions-model");
35
- const color_1 = require("@theia/core/lib/common/color");
36
- const common_1 = require("@theia/core/lib/common");
37
- const browser_1 = require("@theia/filesystem/lib/browser");
38
- const browser_2 = require("@theia/core/lib/browser");
39
- const plugin_vscode_commands_contribution_1 = require("@theia/plugin-ext-vscode/lib/browser/plugin-vscode-commands-contribution");
40
- const vsx_extension_1 = require("./vsx-extension");
41
- const clipboard_service_1 = require("@theia/core/lib/browser/clipboard-service");
42
- const vsx_extensions_search_model_1 = require("./vsx-extensions-search-model");
43
- const recommended_extensions_preference_contribution_1 = require("./recommended-extensions/recommended-extensions-preference-contribution");
44
- const vsx_extension_commands_1 = require("./vsx-extension-commands");
45
- const ovsx_client_1 = require("@theia/ovsx-client");
46
- const ovsx_client_provider_1 = require("../common/ovsx-client-provider");
47
- var VSXCommands;
48
- (function (VSXCommands) {
49
- VSXCommands.TOGGLE_EXTENSIONS = {
50
- id: 'vsxExtensions.toggle',
51
- };
52
- })(VSXCommands = exports.VSXCommands || (exports.VSXCommands = {}));
53
- let VSXExtensionsContribution = class VSXExtensionsContribution extends view_contribution_1.AbstractViewContribution {
54
- constructor() {
55
- super({
56
- widgetId: vsx_extensions_view_container_1.VSXExtensionsViewContainer.ID,
57
- widgetName: vsx_extensions_view_container_1.VSXExtensionsViewContainer.LABEL,
58
- defaultWidgetOptions: {
59
- area: 'left',
60
- rank: 500
61
- },
62
- toggleCommandId: VSXCommands.TOGGLE_EXTENSIONS.id,
63
- toggleKeybinding: 'ctrlcmd+shift+x'
64
- });
65
- }
66
- init() {
67
- const oneShotDisposable = this.model.onDidChange(debounce(() => {
68
- this.showRecommendedToast();
69
- oneShotDisposable.dispose();
70
- }, 5000, { trailing: true }));
71
- }
72
- async initializeLayout(app) {
73
- await this.openView({ activate: false });
74
- }
75
- registerCommands(commands) {
76
- super.registerCommands(commands);
77
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.CLEAR_ALL, {
78
- execute: () => this.model.search.query = '',
79
- isEnabled: () => !!this.model.search.query,
80
- isVisible: () => true,
81
- });
82
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_FROM_VSIX, {
83
- execute: () => this.installFromVSIX()
84
- });
85
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_ANOTHER_VERSION, {
86
- // Check downloadUrl to ensure we have an idea of where to look for other versions.
87
- isEnabled: (extension) => !extension.builtin && !!extension.downloadUrl,
88
- execute: async (extension) => this.installAnotherVersion(extension),
89
- });
90
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.COPY, {
91
- execute: (extension) => this.copy(extension)
92
- });
93
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.COPY_EXTENSION_ID, {
94
- execute: (extension) => this.copyExtensionId(extension)
95
- });
96
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.SHOW_BUILTINS, {
97
- execute: () => this.showBuiltinExtensions()
98
- });
99
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.SHOW_INSTALLED, {
100
- execute: () => this.showInstalledExtensions()
101
- });
102
- commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.SHOW_RECOMMENDATIONS, {
103
- execute: () => this.showRecommendedExtensions()
104
- });
105
- }
106
- registerMenus(menus) {
107
- super.registerMenus(menus);
108
- menus.registerMenuAction(browser_2.CommonMenus.MANAGE_SETTINGS, {
109
- commandId: VSXCommands.TOGGLE_EXTENSIONS.id,
110
- label: common_1.nls.localizeByDefault('Extensions'),
111
- order: 'a20'
112
- });
113
- menus.registerMenuAction(vsx_extension_1.VSXExtensionsContextMenu.COPY, {
114
- commandId: vsx_extension_commands_1.VSXExtensionsCommands.COPY.id,
115
- label: common_1.nls.localizeByDefault('Copy'),
116
- order: '0'
117
- });
118
- menus.registerMenuAction(vsx_extension_1.VSXExtensionsContextMenu.COPY, {
119
- commandId: vsx_extension_commands_1.VSXExtensionsCommands.COPY_EXTENSION_ID.id,
120
- label: common_1.nls.localizeByDefault('Copy Extension ID'),
121
- order: '1'
122
- });
123
- menus.registerMenuAction(vsx_extension_1.VSXExtensionsContextMenu.INSTALL, {
124
- commandId: vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_ANOTHER_VERSION.id,
125
- label: common_1.nls.localizeByDefault('Install Another Version...'),
126
- });
127
- }
128
- registerColors(colors) {
129
- // VS Code colors should be aligned with https://code.visualstudio.com/api/references/theme-color#extensions
130
- colors.register({
131
- id: 'extensionButton.prominentBackground', defaults: {
132
- dark: '#327e36',
133
- light: '#327e36'
134
- }, description: 'Button background color for actions extension that stand out (e.g. install button).'
135
- }, {
136
- id: 'extensionButton.prominentForeground', defaults: {
137
- dark: color_1.Color.white,
138
- light: color_1.Color.white
139
- }, description: 'Button foreground color for actions extension that stand out (e.g. install button).'
140
- }, {
141
- id: 'extensionButton.prominentHoverBackground', defaults: {
142
- dark: '#28632b',
143
- light: '#28632b'
144
- }, description: 'Button background hover color for actions extension that stand out (e.g. install button).'
145
- }, {
146
- id: 'extensionEditor.tableHeadBorder', defaults: {
147
- dark: color_1.Color.transparent('#ffffff', 0.7),
148
- light: color_1.Color.transparent('#000000', 0.7),
149
- hcDark: color_1.Color.white,
150
- hcLight: color_1.Color.black
151
- }, description: 'Border color for the table head row of the extension editor view'
152
- }, {
153
- id: 'extensionEditor.tableCellBorder', defaults: {
154
- dark: color_1.Color.transparent('#ffffff', 0.2),
155
- light: color_1.Color.transparent('#000000', 0.2),
156
- hcDark: color_1.Color.white,
157
- hcLight: color_1.Color.black
158
- }, description: 'Border color for a table row of the extension editor view'
159
- });
160
- }
161
- /**
162
- * Installs a local .vsix file after prompting the `Open File` dialog. Resolves to the URI of the file.
163
- */
164
- async installFromVSIX() {
165
- const props = {
166
- title: vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_FROM_VSIX.dialogLabel,
167
- openLabel: common_1.nls.localizeByDefault('Install from VSIX'),
168
- filters: { 'VSIX Extensions (*.vsix)': ['vsix'] },
169
- canSelectMany: false
170
- };
171
- const extensionUri = await this.fileDialogService.showOpenDialog(props);
172
- if (extensionUri) {
173
- if (extensionUri.path.ext === '.vsix') {
174
- const extensionName = this.labelProvider.getName(extensionUri);
175
- try {
176
- await this.commandRegistry.executeCommand(plugin_vscode_commands_contribution_1.VscodeCommands.INSTALL_FROM_VSIX.id, extensionUri);
177
- this.messageService.info(common_1.nls.localizeByDefault('Completed installing {0} extension from VSIX.', extensionName));
178
- }
179
- catch (e) {
180
- this.messageService.error(common_1.nls.localize('theia/vsx-registry/failedInstallingVSIX', 'Failed to install {0} from VSIX.', extensionName));
181
- console.warn(e);
182
- }
183
- }
184
- else {
185
- this.messageService.error(common_1.nls.localize('theia/vsx-registry/invalidVSIX', 'The selected file is not a valid "*.vsix" plugin.'));
186
- }
187
- }
188
- }
189
- /**
190
- * Given an extension, displays a quick pick of other compatible versions and installs the selected version.
191
- *
192
- * @param extension a VSX extension.
193
- */
194
- async installAnotherVersion(extension) {
195
- const extensionId = extension.id;
196
- const currentVersion = extension.version;
197
- const client = await this.clientProvider();
198
- const { extensions } = await client.query({ extensionId, includeAllVersions: true });
199
- const latestCompatible = this.vsxApiFilter.getLatestCompatibleExtension(extensions);
200
- let compatibleExtensions = [];
201
- let activeItem = undefined;
202
- if (latestCompatible) {
203
- compatibleExtensions = extensions.slice(extensions.findIndex(ext => ext.version === latestCompatible.version));
204
- }
205
- const items = compatibleExtensions.map(ext => {
206
- var _a;
207
- const item = {
208
- label: ext.version,
209
- description: (_a = luxon_1.DateTime.fromISO(ext.timestamp).toRelative({ locale: common_1.nls.locale })) !== null && _a !== void 0 ? _a : ''
210
- };
211
- if (currentVersion === ext.version) {
212
- item.description += ` (${common_1.nls.localizeByDefault('Current')})`;
213
- activeItem = item;
214
- }
215
- return item;
216
- });
217
- const selectedItem = await this.quickInput.showQuickPick(items, {
218
- placeholder: common_1.nls.localizeByDefault('Select Version to Install'),
219
- runIfSingle: false,
220
- activeItem
221
- });
222
- if (selectedItem) {
223
- const selectedExtension = this.model.getExtension(extensionId);
224
- if (selectedExtension) {
225
- await this.updateVersion(selectedExtension, selectedItem.label);
226
- }
227
- }
228
- }
229
- async copy(extension) {
230
- this.clipboardService.writeText(await extension.serialize());
231
- }
232
- copyExtensionId(extension) {
233
- this.clipboardService.writeText(extension.id);
234
- }
235
- /**
236
- * Updates an extension to a specific version.
237
- *
238
- * @param extension the extension to update.
239
- * @param updateToVersion the version to update to.
240
- * @param revertToVersion the version to revert to (in case of failure).
241
- */
242
- async updateVersion(extension, updateToVersion) {
243
- try {
244
- await extension.install({ version: updateToVersion, ignoreOtherVersions: true });
245
- }
246
- catch {
247
- this.messageService.warn(common_1.nls.localize('theia/vsx-registry/vsx-extensions-contribution/update-version-version-error', 'Failed to install version {0} of {1}.', updateToVersion, extension.displayName));
248
- return;
249
- }
250
- try {
251
- if (extension.version !== updateToVersion) {
252
- await extension.uninstall();
253
- }
254
- }
255
- catch {
256
- this.messageService.warn(common_1.nls.localize('theia/vsx-registry/vsx-extensions-contribution/update-version-uninstall-error', 'Error while removing the extension: {0}.', extension.displayName));
257
- }
258
- }
259
- async showRecommendedToast() {
260
- var _a;
261
- if (!this.preferenceService.get(recommended_extensions_preference_contribution_1.IGNORE_RECOMMENDATIONS_ID, false)) {
262
- const recommended = new Set([...this.model.recommended]);
263
- for (const installed of this.model.installed) {
264
- recommended.delete(installed);
265
- }
266
- if (recommended.size) {
267
- const install = common_1.nls.localizeByDefault('Install');
268
- const showRecommendations = common_1.nls.localizeByDefault('Show Recommendations');
269
- const userResponse = await this.messageService.info(common_1.nls.localize('theia/vsx-registry/recommendedExtensions', 'Do you want to install the recommended extensions for this repository?'), install, showRecommendations);
270
- if (userResponse === install) {
271
- for (const recommendation of recommended) {
272
- (_a = this.model.getExtension(recommendation)) === null || _a === void 0 ? void 0 : _a.install();
273
- }
274
- }
275
- else if (userResponse === showRecommendations) {
276
- await this.showRecommendedExtensions();
277
- }
278
- }
279
- }
280
- }
281
- async showBuiltinExtensions() {
282
- await this.openView({ activate: true });
283
- this.model.search.query = vsx_extensions_search_model_1.BUILTIN_QUERY;
284
- }
285
- async showInstalledExtensions() {
286
- await this.openView({ activate: true });
287
- this.model.search.query = vsx_extensions_search_model_1.INSTALLED_QUERY;
288
- }
289
- async showRecommendedExtensions() {
290
- await this.openView({ activate: true });
291
- this.model.search.query = vsx_extensions_search_model_1.RECOMMENDED_QUERY;
292
- }
293
- };
294
- __decorate([
295
- (0, inversify_1.inject)(vsx_extensions_model_1.VSXExtensionsModel),
296
- __metadata("design:type", vsx_extensions_model_1.VSXExtensionsModel)
297
- ], VSXExtensionsContribution.prototype, "model", void 0);
298
- __decorate([
299
- (0, inversify_1.inject)(command_1.CommandRegistry),
300
- __metadata("design:type", command_1.CommandRegistry)
301
- ], VSXExtensionsContribution.prototype, "commandRegistry", void 0);
302
- __decorate([
303
- (0, inversify_1.inject)(browser_1.FileDialogService),
304
- __metadata("design:type", Object)
305
- ], VSXExtensionsContribution.prototype, "fileDialogService", void 0);
306
- __decorate([
307
- (0, inversify_1.inject)(common_1.MessageService),
308
- __metadata("design:type", common_1.MessageService)
309
- ], VSXExtensionsContribution.prototype, "messageService", void 0);
310
- __decorate([
311
- (0, inversify_1.inject)(browser_2.LabelProvider),
312
- __metadata("design:type", browser_2.LabelProvider)
313
- ], VSXExtensionsContribution.prototype, "labelProvider", void 0);
314
- __decorate([
315
- (0, inversify_1.inject)(clipboard_service_1.ClipboardService),
316
- __metadata("design:type", Object)
317
- ], VSXExtensionsContribution.prototype, "clipboardService", void 0);
318
- __decorate([
319
- (0, inversify_1.inject)(browser_2.PreferenceService),
320
- __metadata("design:type", Object)
321
- ], VSXExtensionsContribution.prototype, "preferenceService", void 0);
322
- __decorate([
323
- (0, inversify_1.inject)(ovsx_client_provider_1.OVSXClientProvider),
324
- __metadata("design:type", Function)
325
- ], VSXExtensionsContribution.prototype, "clientProvider", void 0);
326
- __decorate([
327
- (0, inversify_1.inject)(ovsx_client_1.OVSXApiFilter),
328
- __metadata("design:type", Object)
329
- ], VSXExtensionsContribution.prototype, "vsxApiFilter", void 0);
330
- __decorate([
331
- (0, inversify_1.inject)(browser_2.QuickInputService),
332
- __metadata("design:type", Object)
333
- ], VSXExtensionsContribution.prototype, "quickInput", void 0);
334
- __decorate([
335
- (0, inversify_1.postConstruct)(),
336
- __metadata("design:type", Function),
337
- __metadata("design:paramtypes", []),
338
- __metadata("design:returntype", void 0)
339
- ], VSXExtensionsContribution.prototype, "init", null);
340
- VSXExtensionsContribution = __decorate([
341
- (0, inversify_1.injectable)(),
342
- __metadata("design:paramtypes", [])
343
- ], VSXExtensionsContribution);
344
- exports.VSXExtensionsContribution = VSXExtensionsContribution;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2020 TypeFox and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.VSXExtensionsContribution = exports.VSXCommands = void 0;
28
+ const browser_1 = require("@theia/core/lib/browser");
29
+ const clipboard_service_1 = require("@theia/core/lib/browser/clipboard-service");
30
+ const view_contribution_1 = require("@theia/core/lib/browser/shell/view-contribution");
31
+ const common_1 = require("@theia/core/lib/common");
32
+ const color_1 = require("@theia/core/lib/common/color");
33
+ const command_1 = require("@theia/core/lib/common/command");
34
+ const uri_command_handler_1 = require("@theia/core/lib/common/uri-command-handler");
35
+ const inversify_1 = require("@theia/core/shared/inversify");
36
+ const browser_2 = require("@theia/filesystem/lib/browser");
37
+ const navigator_contribution_1 = require("@theia/navigator/lib/browser/navigator-contribution");
38
+ const ovsx_client_1 = require("@theia/ovsx-client");
39
+ const plugin_vscode_commands_contribution_1 = require("@theia/plugin-ext-vscode/lib/browser/plugin-vscode-commands-contribution");
40
+ const luxon_1 = require("luxon");
41
+ const ovsx_client_provider_1 = require("../common/ovsx-client-provider");
42
+ const recommended_extensions_preference_contribution_1 = require("./recommended-extensions/recommended-extensions-preference-contribution");
43
+ const vsx_extension_1 = require("./vsx-extension");
44
+ const vsx_extension_commands_1 = require("./vsx-extension-commands");
45
+ const vsx_extensions_model_1 = require("./vsx-extensions-model");
46
+ const vsx_extensions_search_model_1 = require("./vsx-extensions-search-model");
47
+ const vsx_extensions_view_container_1 = require("./vsx-extensions-view-container");
48
+ const debounce = require("@theia/core/shared/lodash.debounce");
49
+ var VSXCommands;
50
+ (function (VSXCommands) {
51
+ VSXCommands.TOGGLE_EXTENSIONS = {
52
+ id: 'vsxExtensions.toggle',
53
+ };
54
+ })(VSXCommands = exports.VSXCommands || (exports.VSXCommands = {}));
55
+ let VSXExtensionsContribution = class VSXExtensionsContribution extends view_contribution_1.AbstractViewContribution {
56
+ constructor() {
57
+ super({
58
+ widgetId: vsx_extensions_view_container_1.VSXExtensionsViewContainer.ID,
59
+ widgetName: vsx_extensions_view_container_1.VSXExtensionsViewContainer.LABEL,
60
+ defaultWidgetOptions: {
61
+ area: 'left',
62
+ rank: 500
63
+ },
64
+ toggleCommandId: VSXCommands.TOGGLE_EXTENSIONS.id,
65
+ toggleKeybinding: 'ctrlcmd+shift+x'
66
+ });
67
+ }
68
+ init() {
69
+ const oneShotDisposable = this.model.onDidChange(debounce(() => {
70
+ this.showRecommendedToast();
71
+ oneShotDisposable.dispose();
72
+ }, 5000, { trailing: true }));
73
+ }
74
+ async initializeLayout(app) {
75
+ await this.openView({ activate: false });
76
+ }
77
+ registerCommands(commands) {
78
+ super.registerCommands(commands);
79
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.CLEAR_ALL, {
80
+ execute: () => this.model.search.query = '',
81
+ isEnabled: () => !!this.model.search.query,
82
+ isVisible: () => true,
83
+ });
84
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_FROM_VSIX, {
85
+ execute: () => this.installFromVSIX()
86
+ });
87
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_VSIX_FILE, uri_command_handler_1.UriAwareCommandHandler.MonoSelect(this.selectionService, {
88
+ execute: fileURI => this.installVsixFile(fileURI),
89
+ isEnabled: fileURI => fileURI.scheme === 'file' && fileURI.path.ext === '.vsix'
90
+ }));
91
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_ANOTHER_VERSION, {
92
+ // Check downloadUrl to ensure we have an idea of where to look for other versions.
93
+ isEnabled: (extension) => !extension.builtin && !!extension.downloadUrl,
94
+ execute: async (extension) => this.installAnotherVersion(extension),
95
+ });
96
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.COPY, {
97
+ execute: (extension) => this.copy(extension)
98
+ });
99
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.COPY_EXTENSION_ID, {
100
+ execute: (extension) => this.copyExtensionId(extension)
101
+ });
102
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.SHOW_BUILTINS, {
103
+ execute: () => this.showBuiltinExtensions()
104
+ });
105
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.SHOW_INSTALLED, {
106
+ execute: () => this.showInstalledExtensions()
107
+ });
108
+ commands.registerCommand(vsx_extension_commands_1.VSXExtensionsCommands.SHOW_RECOMMENDATIONS, {
109
+ execute: () => this.showRecommendedExtensions()
110
+ });
111
+ }
112
+ registerMenus(menus) {
113
+ super.registerMenus(menus);
114
+ menus.registerMenuAction(browser_1.CommonMenus.MANAGE_SETTINGS, {
115
+ commandId: VSXCommands.TOGGLE_EXTENSIONS.id,
116
+ label: common_1.nls.localizeByDefault('Extensions'),
117
+ order: 'a20'
118
+ });
119
+ menus.registerMenuAction(vsx_extension_1.VSXExtensionsContextMenu.COPY, {
120
+ commandId: vsx_extension_commands_1.VSXExtensionsCommands.COPY.id,
121
+ label: common_1.nls.localizeByDefault('Copy'),
122
+ order: '0'
123
+ });
124
+ menus.registerMenuAction(vsx_extension_1.VSXExtensionsContextMenu.COPY, {
125
+ commandId: vsx_extension_commands_1.VSXExtensionsCommands.COPY_EXTENSION_ID.id,
126
+ label: common_1.nls.localizeByDefault('Copy Extension ID'),
127
+ order: '1'
128
+ });
129
+ menus.registerMenuAction(vsx_extension_1.VSXExtensionsContextMenu.INSTALL, {
130
+ commandId: vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_ANOTHER_VERSION.id,
131
+ label: common_1.nls.localizeByDefault('Install Another Version...'),
132
+ });
133
+ menus.registerMenuAction(navigator_contribution_1.NAVIGATOR_CONTEXT_MENU, {
134
+ commandId: vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_VSIX_FILE.id,
135
+ label: vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_VSIX_FILE.label,
136
+ when: 'resourceScheme == file && resourceExtname == .vsix'
137
+ });
138
+ }
139
+ registerColors(colors) {
140
+ // VS Code colors should be aligned with https://code.visualstudio.com/api/references/theme-color#extensions
141
+ colors.register({
142
+ id: 'extensionButton.prominentBackground', defaults: {
143
+ dark: '#327e36',
144
+ light: '#327e36'
145
+ }, description: 'Button background color for actions extension that stand out (e.g. install button).'
146
+ }, {
147
+ id: 'extensionButton.prominentForeground', defaults: {
148
+ dark: color_1.Color.white,
149
+ light: color_1.Color.white
150
+ }, description: 'Button foreground color for actions extension that stand out (e.g. install button).'
151
+ }, {
152
+ id: 'extensionButton.prominentHoverBackground', defaults: {
153
+ dark: '#28632b',
154
+ light: '#28632b'
155
+ }, description: 'Button background hover color for actions extension that stand out (e.g. install button).'
156
+ }, {
157
+ id: 'extensionEditor.tableHeadBorder', defaults: {
158
+ dark: color_1.Color.transparent('#ffffff', 0.7),
159
+ light: color_1.Color.transparent('#000000', 0.7),
160
+ hcDark: color_1.Color.white,
161
+ hcLight: color_1.Color.black
162
+ }, description: 'Border color for the table head row of the extension editor view'
163
+ }, {
164
+ id: 'extensionEditor.tableCellBorder', defaults: {
165
+ dark: color_1.Color.transparent('#ffffff', 0.2),
166
+ light: color_1.Color.transparent('#000000', 0.2),
167
+ hcDark: color_1.Color.white,
168
+ hcLight: color_1.Color.black
169
+ }, description: 'Border color for a table row of the extension editor view'
170
+ }, {
171
+ id: 'extensionIcon.verifiedForeground', defaults: {
172
+ dark: '#40a6ff',
173
+ light: '#40a6ff'
174
+ }, description: 'The icon color for extension verified publisher.'
175
+ });
176
+ }
177
+ /**
178
+ * Installs a local .vsix file after prompting the `Open File` dialog. Resolves to the URI of the file.
179
+ */
180
+ async installFromVSIX() {
181
+ const props = {
182
+ title: vsx_extension_commands_1.VSXExtensionsCommands.INSTALL_FROM_VSIX.dialogLabel,
183
+ openLabel: common_1.nls.localizeByDefault('Install from VSIX'),
184
+ filters: { 'VSIX Extensions (*.vsix)': ['vsix'] },
185
+ canSelectMany: false,
186
+ canSelectFiles: true
187
+ };
188
+ const extensionUri = await this.fileDialogService.showOpenDialog(props);
189
+ if (extensionUri) {
190
+ if (extensionUri.path.ext === '.vsix') {
191
+ await this.installVsixFile(extensionUri);
192
+ }
193
+ else {
194
+ this.messageService.error(common_1.nls.localize('theia/vsx-registry/invalidVSIX', 'The selected file is not a valid "*.vsix" plugin.'));
195
+ }
196
+ }
197
+ }
198
+ /**
199
+ * Installs a local vs-code extension file.
200
+ * The implementation doesn't check if the file is a valid VSIX file, or the URI has a *.vsix extension.
201
+ * The caller should ensure the file is a valid VSIX file.
202
+ *
203
+ * @param fileURI the URI of the file to install.
204
+ */
205
+ async installVsixFile(fileURI) {
206
+ const extensionName = this.labelProvider.getName(fileURI);
207
+ try {
208
+ await this.commandRegistry.executeCommand(plugin_vscode_commands_contribution_1.VscodeCommands.INSTALL_FROM_VSIX.id, fileURI);
209
+ this.messageService.info(common_1.nls.localizeByDefault('Completed installing {0} extension from VSIX.', extensionName));
210
+ }
211
+ catch (e) {
212
+ this.messageService.error(common_1.nls.localize('theia/vsx-registry/failedInstallingVSIX', 'Failed to install {0} from VSIX.', extensionName));
213
+ console.warn(e);
214
+ }
215
+ }
216
+ /**
217
+ * Given an extension, displays a quick pick of other compatible versions and installs the selected version.
218
+ *
219
+ * @param extension a VSX extension.
220
+ */
221
+ async installAnotherVersion(extension) {
222
+ const extensionId = extension.id;
223
+ const currentVersion = extension.version;
224
+ const client = await this.clientProvider();
225
+ const { extensions } = await client.query({ extensionId, includeAllVersions: true });
226
+ const latestCompatible = this.vsxApiFilter.getLatestCompatibleExtension(extensions);
227
+ let compatibleExtensions = [];
228
+ let activeItem = undefined;
229
+ if (latestCompatible) {
230
+ compatibleExtensions = extensions.slice(extensions.findIndex(ext => ext.version === latestCompatible.version));
231
+ }
232
+ const items = compatibleExtensions.map(ext => {
233
+ var _a;
234
+ const item = {
235
+ label: ext.version,
236
+ description: (_a = luxon_1.DateTime.fromISO(ext.timestamp).toRelative({ locale: common_1.nls.locale })) !== null && _a !== void 0 ? _a : ''
237
+ };
238
+ if (currentVersion === ext.version) {
239
+ item.description += ` (${common_1.nls.localizeByDefault('Current')})`;
240
+ activeItem = item;
241
+ }
242
+ return item;
243
+ });
244
+ const selectedItem = await this.quickInput.showQuickPick(items, {
245
+ placeholder: common_1.nls.localizeByDefault('Select Version to Install'),
246
+ runIfSingle: false,
247
+ activeItem
248
+ });
249
+ if (selectedItem) {
250
+ const selectedExtension = this.model.getExtension(extensionId);
251
+ if (selectedExtension) {
252
+ await this.updateVersion(selectedExtension, selectedItem.label);
253
+ }
254
+ }
255
+ }
256
+ async copy(extension) {
257
+ this.clipboardService.writeText(await extension.serialize());
258
+ }
259
+ copyExtensionId(extension) {
260
+ this.clipboardService.writeText(extension.id);
261
+ }
262
+ /**
263
+ * Updates an extension to a specific version.
264
+ *
265
+ * @param extension the extension to update.
266
+ * @param updateToVersion the version to update to.
267
+ * @param revertToVersion the version to revert to (in case of failure).
268
+ */
269
+ async updateVersion(extension, updateToVersion) {
270
+ try {
271
+ await extension.install({ version: updateToVersion, ignoreOtherVersions: true });
272
+ }
273
+ catch {
274
+ this.messageService.warn(common_1.nls.localize('theia/vsx-registry/vsx-extensions-contribution/update-version-version-error', 'Failed to install version {0} of {1}.', updateToVersion, extension.displayName));
275
+ return;
276
+ }
277
+ try {
278
+ if (extension.version !== updateToVersion) {
279
+ await extension.uninstall();
280
+ }
281
+ }
282
+ catch {
283
+ this.messageService.warn(common_1.nls.localize('theia/vsx-registry/vsx-extensions-contribution/update-version-uninstall-error', 'Error while removing the extension: {0}.', extension.displayName));
284
+ }
285
+ }
286
+ async showRecommendedToast() {
287
+ var _a;
288
+ if (!this.preferenceService.get(recommended_extensions_preference_contribution_1.IGNORE_RECOMMENDATIONS_ID, false)) {
289
+ const recommended = new Set([...this.model.recommended]);
290
+ for (const installed of this.model.installed) {
291
+ recommended.delete(installed);
292
+ }
293
+ if (recommended.size) {
294
+ const install = common_1.nls.localizeByDefault('Install');
295
+ const showRecommendations = common_1.nls.localizeByDefault('Show Recommendations');
296
+ const userResponse = await this.messageService.info(common_1.nls.localize('theia/vsx-registry/recommendedExtensions', 'Do you want to install the recommended extensions for this repository?'), install, showRecommendations);
297
+ if (userResponse === install) {
298
+ for (const recommendation of recommended) {
299
+ (_a = this.model.getExtension(recommendation)) === null || _a === void 0 ? void 0 : _a.install();
300
+ }
301
+ }
302
+ else if (userResponse === showRecommendations) {
303
+ await this.showRecommendedExtensions();
304
+ }
305
+ }
306
+ }
307
+ }
308
+ async showBuiltinExtensions() {
309
+ await this.openView({ activate: true });
310
+ this.model.search.query = vsx_extensions_search_model_1.BUILTIN_QUERY;
311
+ }
312
+ async showInstalledExtensions() {
313
+ await this.openView({ activate: true });
314
+ this.model.search.query = vsx_extensions_search_model_1.INSTALLED_QUERY;
315
+ }
316
+ async showRecommendedExtensions() {
317
+ await this.openView({ activate: true });
318
+ this.model.search.query = vsx_extensions_search_model_1.RECOMMENDED_QUERY;
319
+ }
320
+ };
321
+ __decorate([
322
+ (0, inversify_1.inject)(vsx_extensions_model_1.VSXExtensionsModel),
323
+ __metadata("design:type", vsx_extensions_model_1.VSXExtensionsModel)
324
+ ], VSXExtensionsContribution.prototype, "model", void 0);
325
+ __decorate([
326
+ (0, inversify_1.inject)(command_1.CommandRegistry),
327
+ __metadata("design:type", command_1.CommandRegistry)
328
+ ], VSXExtensionsContribution.prototype, "commandRegistry", void 0);
329
+ __decorate([
330
+ (0, inversify_1.inject)(browser_2.FileDialogService),
331
+ __metadata("design:type", Object)
332
+ ], VSXExtensionsContribution.prototype, "fileDialogService", void 0);
333
+ __decorate([
334
+ (0, inversify_1.inject)(common_1.MessageService),
335
+ __metadata("design:type", common_1.MessageService)
336
+ ], VSXExtensionsContribution.prototype, "messageService", void 0);
337
+ __decorate([
338
+ (0, inversify_1.inject)(browser_1.LabelProvider),
339
+ __metadata("design:type", browser_1.LabelProvider)
340
+ ], VSXExtensionsContribution.prototype, "labelProvider", void 0);
341
+ __decorate([
342
+ (0, inversify_1.inject)(clipboard_service_1.ClipboardService),
343
+ __metadata("design:type", Object)
344
+ ], VSXExtensionsContribution.prototype, "clipboardService", void 0);
345
+ __decorate([
346
+ (0, inversify_1.inject)(browser_1.PreferenceService),
347
+ __metadata("design:type", Object)
348
+ ], VSXExtensionsContribution.prototype, "preferenceService", void 0);
349
+ __decorate([
350
+ (0, inversify_1.inject)(ovsx_client_provider_1.OVSXClientProvider),
351
+ __metadata("design:type", Function)
352
+ ], VSXExtensionsContribution.prototype, "clientProvider", void 0);
353
+ __decorate([
354
+ (0, inversify_1.inject)(ovsx_client_1.OVSXApiFilter),
355
+ __metadata("design:type", Object)
356
+ ], VSXExtensionsContribution.prototype, "vsxApiFilter", void 0);
357
+ __decorate([
358
+ (0, inversify_1.inject)(browser_1.QuickInputService),
359
+ __metadata("design:type", Object)
360
+ ], VSXExtensionsContribution.prototype, "quickInput", void 0);
361
+ __decorate([
362
+ (0, inversify_1.inject)(common_1.SelectionService),
363
+ __metadata("design:type", common_1.SelectionService)
364
+ ], VSXExtensionsContribution.prototype, "selectionService", void 0);
365
+ __decorate([
366
+ (0, inversify_1.postConstruct)(),
367
+ __metadata("design:type", Function),
368
+ __metadata("design:paramtypes", []),
369
+ __metadata("design:returntype", void 0)
370
+ ], VSXExtensionsContribution.prototype, "init", null);
371
+ VSXExtensionsContribution = __decorate([
372
+ (0, inversify_1.injectable)(),
373
+ __metadata("design:paramtypes", [])
374
+ ], VSXExtensionsContribution);
375
+ exports.VSXExtensionsContribution = VSXExtensionsContribution;
345
376
  //# sourceMappingURL=vsx-extensions-contribution.js.map