@theia/vsx-registry 1.53.0-next.5 → 1.53.0-next.55
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.
- package/README.md +45 -45
- package/lib/common/vsx-environment.d.ts +1 -0
- package/lib/common/vsx-environment.d.ts.map +1 -1
- package/lib/common/vsx-registry-common-module.d.ts.map +1 -1
- package/lib/common/vsx-registry-common-module.js +9 -3
- package/lib/common/vsx-registry-common-module.js.map +1 -1
- package/lib/node/vsx-cli.d.ts +1 -0
- package/lib/node/vsx-cli.d.ts.map +1 -1
- package/lib/node/vsx-cli.js +4 -0
- package/lib/node/vsx-cli.js.map +1 -1
- package/lib/node/vsx-environment-impl.d.ts +1 -0
- package/lib/node/vsx-environment-impl.d.ts.map +1 -1
- package/lib/node/vsx-environment-impl.js +3 -0
- package/lib/node/vsx-environment-impl.js.map +1 -1
- package/lib/node/vsx-extension-resolver.js +3 -3
- package/lib/node/vsx-extension-resolver.js.map +1 -1
- package/package.json +12 -11
- package/src/browser/recommended-extensions/preference-provider-overrides.ts +99 -99
- package/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +74 -74
- package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +68 -68
- package/src/browser/style/extensions.svg +4 -4
- package/src/browser/style/index.css +436 -436
- package/src/browser/vsx-extension-argument-processor.ts +32 -32
- package/src/browser/vsx-extension-commands.ts +68 -68
- package/src/browser/vsx-extension-editor-manager.ts +42 -42
- package/src/browser/vsx-extension-editor.tsx +96 -96
- package/src/browser/vsx-extension.tsx +710 -710
- package/src/browser/vsx-extensions-contribution.ts +373 -373
- package/src/browser/vsx-extensions-model.ts +456 -456
- package/src/browser/vsx-extensions-preferences.ts +58 -58
- package/src/browser/vsx-extensions-search-bar.tsx +107 -107
- package/src/browser/vsx-extensions-search-model.ts +61 -61
- package/src/browser/vsx-extensions-source.ts +83 -83
- package/src/browser/vsx-extensions-view-container.ts +179 -179
- package/src/browser/vsx-extensions-widget.tsx +165 -165
- package/src/browser/vsx-language-quick-pick-service.ts +112 -112
- package/src/browser/vsx-registry-frontend-module.ts +113 -113
- package/src/common/index.ts +19 -19
- package/src/common/ovsx-client-provider.ts +35 -35
- package/src/common/vsx-environment.ts +28 -27
- package/src/common/vsx-extension-uri.ts +20 -20
- package/src/common/vsx-registry-common-module.ts +85 -78
- package/src/node/vsx-cli-deployer-participant.ts +46 -46
- package/src/node/vsx-cli.ts +55 -51
- package/src/node/vsx-environment-impl.ts +54 -50
- package/src/node/vsx-extension-resolver.ts +134 -134
- package/src/node/vsx-registry-backend-module.ts +38 -38
- package/src/node/vsx-remote-cli.ts +39 -39
- package/src/package.spec.ts +29 -29
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 TypeFox 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 { injectable, interfaces, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { Message, TreeModel, TreeNode } from '@theia/core/lib/browser';
|
|
19
|
-
import { SourceTreeWidget } from '@theia/core/lib/browser/source-tree';
|
|
20
|
-
import { VSXExtensionsSource, VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
21
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
22
|
-
import { BadgeWidget } from '@theia/core/lib/browser/view-container';
|
|
23
|
-
import { Emitter, Event } from '@theia/core/lib/common';
|
|
24
|
-
import { AlertMessage } from '@theia/core/lib/browser/widgets/alert-message';
|
|
25
|
-
import * as React from '@theia/core/shared/react';
|
|
26
|
-
|
|
27
|
-
@injectable()
|
|
28
|
-
export class VSXExtensionsWidgetOptions extends VSXExtensionsSourceOptions {
|
|
29
|
-
title?: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const generateExtensionWidgetId = (widgetId: string): string => VSXExtensionsWidget.ID + ':' + widgetId;
|
|
33
|
-
|
|
34
|
-
@injectable()
|
|
35
|
-
export class VSXExtensionsWidget extends SourceTreeWidget implements BadgeWidget {
|
|
36
|
-
|
|
37
|
-
static ID = 'vsx-extensions';
|
|
38
|
-
|
|
39
|
-
static createWidget(parent: interfaces.Container, options: VSXExtensionsWidgetOptions): VSXExtensionsWidget {
|
|
40
|
-
const child = SourceTreeWidget.createContainer(parent, {
|
|
41
|
-
virtualized: false,
|
|
42
|
-
scrollIfActive: true
|
|
43
|
-
});
|
|
44
|
-
child.bind(VSXExtensionsSourceOptions).toConstantValue(options);
|
|
45
|
-
child.bind(VSXExtensionsSource).toSelf();
|
|
46
|
-
child.unbind(SourceTreeWidget);
|
|
47
|
-
child.bind(VSXExtensionsWidgetOptions).toConstantValue(options);
|
|
48
|
-
child.bind(VSXExtensionsWidget).toSelf();
|
|
49
|
-
return child.get(VSXExtensionsWidget);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected _badge?: number;
|
|
53
|
-
protected onDidChangeBadgeEmitter = new Emitter<void>();
|
|
54
|
-
|
|
55
|
-
protected _badgeTooltip?: string;
|
|
56
|
-
protected onDidChangeBadgeTooltipEmitter = new Emitter<void>();
|
|
57
|
-
|
|
58
|
-
@inject(VSXExtensionsWidgetOptions)
|
|
59
|
-
protected readonly options: VSXExtensionsWidgetOptions;
|
|
60
|
-
|
|
61
|
-
@inject(VSXExtensionsSource)
|
|
62
|
-
protected readonly extensionsSource: VSXExtensionsSource;
|
|
63
|
-
|
|
64
|
-
@postConstruct()
|
|
65
|
-
protected override init(): void {
|
|
66
|
-
super.init();
|
|
67
|
-
this.addClass('theia-vsx-extensions');
|
|
68
|
-
|
|
69
|
-
this.id = generateExtensionWidgetId(this.options.id);
|
|
70
|
-
|
|
71
|
-
this.toDispose.push(this.extensionsSource);
|
|
72
|
-
this.source = this.extensionsSource;
|
|
73
|
-
|
|
74
|
-
const title = this.options.title ?? this.computeTitle();
|
|
75
|
-
this.title.label = title;
|
|
76
|
-
this.title.caption = title;
|
|
77
|
-
|
|
78
|
-
this.toDispose.push(this.source.onDidChange(async () => {
|
|
79
|
-
this.badge = await this.resolveCount();
|
|
80
|
-
}));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get onDidChangeBadge(): Event<void> {
|
|
84
|
-
return this.onDidChangeBadgeEmitter.event;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get badge(): number | undefined {
|
|
88
|
-
return this._badge;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
set badge(count: number | undefined) {
|
|
92
|
-
this._badge = count;
|
|
93
|
-
this.onDidChangeBadgeEmitter.fire();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
get onDidChangeBadgeTooltip(): Event<void> {
|
|
97
|
-
return this.onDidChangeBadgeTooltipEmitter.event;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
get badgeTooltip(): string | undefined {
|
|
101
|
-
return this._badgeTooltip;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
set badgeTooltip(tooltip: string | undefined) {
|
|
105
|
-
this._badgeTooltip = tooltip;
|
|
106
|
-
this.onDidChangeBadgeTooltipEmitter.fire();
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
protected computeTitle(): string {
|
|
110
|
-
switch (this.options.id) {
|
|
111
|
-
case VSXExtensionsSourceOptions.INSTALLED:
|
|
112
|
-
return nls.localizeByDefault('Installed');
|
|
113
|
-
case VSXExtensionsSourceOptions.BUILT_IN:
|
|
114
|
-
return nls.localizeByDefault('Built-in');
|
|
115
|
-
case VSXExtensionsSourceOptions.RECOMMENDED:
|
|
116
|
-
return nls.localizeByDefault('Recommended');
|
|
117
|
-
case VSXExtensionsSourceOptions.SEARCH_RESULT:
|
|
118
|
-
return 'Open VSX Registry';
|
|
119
|
-
default:
|
|
120
|
-
return '';
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
protected async resolveCount(): Promise<number | undefined> {
|
|
125
|
-
if (this.options.id !== VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
126
|
-
const elements = await this.source?.getElements() || [];
|
|
127
|
-
return [...elements].length;
|
|
128
|
-
}
|
|
129
|
-
return undefined;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
protected override tapNode(node?: TreeNode): void {
|
|
133
|
-
super.tapNode(node);
|
|
134
|
-
this.model.openNode(node);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected override handleDblClickEvent(): void {
|
|
138
|
-
// Don't open the editor view on a double click.
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
protected override renderTree(model: TreeModel): React.ReactNode {
|
|
142
|
-
if (this.options.id === VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
143
|
-
const searchError = this.extensionsSource.getModel().searchError;
|
|
144
|
-
if (!!searchError) {
|
|
145
|
-
const message = nls.localize('theia/vsx-registry/errorFetching', 'Error fetching extensions.');
|
|
146
|
-
const configurationHint = nls.localize('theia/vsx-registry/errorFetchingConfigurationHint', 'This could be caused by network configuration issues.');
|
|
147
|
-
const hint = searchError.includes('ENOTFOUND') ? configurationHint : '';
|
|
148
|
-
return <AlertMessage
|
|
149
|
-
type='ERROR'
|
|
150
|
-
header={`${message} ${searchError} ${hint}`}
|
|
151
|
-
/>;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return super.renderTree(model);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
protected override onAfterShow(msg: Message): void {
|
|
158
|
-
super.onAfterShow(msg);
|
|
159
|
-
if (this.options.id === VSXExtensionsSourceOptions.INSTALLED) {
|
|
160
|
-
// This is needed when an Extension was installed outside of the extension view.
|
|
161
|
-
// E.g. using explorer context menu.
|
|
162
|
-
this.doUpdateRows();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 TypeFox 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 { injectable, interfaces, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { Message, TreeModel, TreeNode } from '@theia/core/lib/browser';
|
|
19
|
+
import { SourceTreeWidget } from '@theia/core/lib/browser/source-tree';
|
|
20
|
+
import { VSXExtensionsSource, VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
21
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
22
|
+
import { BadgeWidget } from '@theia/core/lib/browser/view-container';
|
|
23
|
+
import { Emitter, Event } from '@theia/core/lib/common';
|
|
24
|
+
import { AlertMessage } from '@theia/core/lib/browser/widgets/alert-message';
|
|
25
|
+
import * as React from '@theia/core/shared/react';
|
|
26
|
+
|
|
27
|
+
@injectable()
|
|
28
|
+
export class VSXExtensionsWidgetOptions extends VSXExtensionsSourceOptions {
|
|
29
|
+
title?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const generateExtensionWidgetId = (widgetId: string): string => VSXExtensionsWidget.ID + ':' + widgetId;
|
|
33
|
+
|
|
34
|
+
@injectable()
|
|
35
|
+
export class VSXExtensionsWidget extends SourceTreeWidget implements BadgeWidget {
|
|
36
|
+
|
|
37
|
+
static ID = 'vsx-extensions';
|
|
38
|
+
|
|
39
|
+
static createWidget(parent: interfaces.Container, options: VSXExtensionsWidgetOptions): VSXExtensionsWidget {
|
|
40
|
+
const child = SourceTreeWidget.createContainer(parent, {
|
|
41
|
+
virtualized: false,
|
|
42
|
+
scrollIfActive: true
|
|
43
|
+
});
|
|
44
|
+
child.bind(VSXExtensionsSourceOptions).toConstantValue(options);
|
|
45
|
+
child.bind(VSXExtensionsSource).toSelf();
|
|
46
|
+
child.unbind(SourceTreeWidget);
|
|
47
|
+
child.bind(VSXExtensionsWidgetOptions).toConstantValue(options);
|
|
48
|
+
child.bind(VSXExtensionsWidget).toSelf();
|
|
49
|
+
return child.get(VSXExtensionsWidget);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected _badge?: number;
|
|
53
|
+
protected onDidChangeBadgeEmitter = new Emitter<void>();
|
|
54
|
+
|
|
55
|
+
protected _badgeTooltip?: string;
|
|
56
|
+
protected onDidChangeBadgeTooltipEmitter = new Emitter<void>();
|
|
57
|
+
|
|
58
|
+
@inject(VSXExtensionsWidgetOptions)
|
|
59
|
+
protected readonly options: VSXExtensionsWidgetOptions;
|
|
60
|
+
|
|
61
|
+
@inject(VSXExtensionsSource)
|
|
62
|
+
protected readonly extensionsSource: VSXExtensionsSource;
|
|
63
|
+
|
|
64
|
+
@postConstruct()
|
|
65
|
+
protected override init(): void {
|
|
66
|
+
super.init();
|
|
67
|
+
this.addClass('theia-vsx-extensions');
|
|
68
|
+
|
|
69
|
+
this.id = generateExtensionWidgetId(this.options.id);
|
|
70
|
+
|
|
71
|
+
this.toDispose.push(this.extensionsSource);
|
|
72
|
+
this.source = this.extensionsSource;
|
|
73
|
+
|
|
74
|
+
const title = this.options.title ?? this.computeTitle();
|
|
75
|
+
this.title.label = title;
|
|
76
|
+
this.title.caption = title;
|
|
77
|
+
|
|
78
|
+
this.toDispose.push(this.source.onDidChange(async () => {
|
|
79
|
+
this.badge = await this.resolveCount();
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get onDidChangeBadge(): Event<void> {
|
|
84
|
+
return this.onDidChangeBadgeEmitter.event;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
get badge(): number | undefined {
|
|
88
|
+
return this._badge;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
set badge(count: number | undefined) {
|
|
92
|
+
this._badge = count;
|
|
93
|
+
this.onDidChangeBadgeEmitter.fire();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get onDidChangeBadgeTooltip(): Event<void> {
|
|
97
|
+
return this.onDidChangeBadgeTooltipEmitter.event;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get badgeTooltip(): string | undefined {
|
|
101
|
+
return this._badgeTooltip;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
set badgeTooltip(tooltip: string | undefined) {
|
|
105
|
+
this._badgeTooltip = tooltip;
|
|
106
|
+
this.onDidChangeBadgeTooltipEmitter.fire();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
protected computeTitle(): string {
|
|
110
|
+
switch (this.options.id) {
|
|
111
|
+
case VSXExtensionsSourceOptions.INSTALLED:
|
|
112
|
+
return nls.localizeByDefault('Installed');
|
|
113
|
+
case VSXExtensionsSourceOptions.BUILT_IN:
|
|
114
|
+
return nls.localizeByDefault('Built-in');
|
|
115
|
+
case VSXExtensionsSourceOptions.RECOMMENDED:
|
|
116
|
+
return nls.localizeByDefault('Recommended');
|
|
117
|
+
case VSXExtensionsSourceOptions.SEARCH_RESULT:
|
|
118
|
+
return 'Open VSX Registry';
|
|
119
|
+
default:
|
|
120
|
+
return '';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
protected async resolveCount(): Promise<number | undefined> {
|
|
125
|
+
if (this.options.id !== VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
126
|
+
const elements = await this.source?.getElements() || [];
|
|
127
|
+
return [...elements].length;
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
protected override tapNode(node?: TreeNode): void {
|
|
133
|
+
super.tapNode(node);
|
|
134
|
+
this.model.openNode(node);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
protected override handleDblClickEvent(): void {
|
|
138
|
+
// Don't open the editor view on a double click.
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
protected override renderTree(model: TreeModel): React.ReactNode {
|
|
142
|
+
if (this.options.id === VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
143
|
+
const searchError = this.extensionsSource.getModel().searchError;
|
|
144
|
+
if (!!searchError) {
|
|
145
|
+
const message = nls.localize('theia/vsx-registry/errorFetching', 'Error fetching extensions.');
|
|
146
|
+
const configurationHint = nls.localize('theia/vsx-registry/errorFetchingConfigurationHint', 'This could be caused by network configuration issues.');
|
|
147
|
+
const hint = searchError.includes('ENOTFOUND') ? configurationHint : '';
|
|
148
|
+
return <AlertMessage
|
|
149
|
+
type='ERROR'
|
|
150
|
+
header={`${message} ${searchError} ${hint}`}
|
|
151
|
+
/>;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return super.renderTree(model);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
protected override onAfterShow(msg: Message): void {
|
|
158
|
+
super.onAfterShow(msg);
|
|
159
|
+
if (this.options.id === VSXExtensionsSourceOptions.INSTALLED) {
|
|
160
|
+
// This is needed when an Extension was installed outside of the extension view.
|
|
161
|
+
// E.g. using explorer context menu.
|
|
162
|
+
this.doUpdateRows();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2022 TypeFox 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 { LanguageQuickPickItem, LanguageQuickPickService } from '@theia/core/lib/browser/i18n/language-quick-pick-service';
|
|
18
|
-
import { RequestContext, RequestService } from '@theia/core/shared/@theia/request';
|
|
19
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
-
import { LanguageInfo } from '@theia/core/lib/common/i18n/localization';
|
|
21
|
-
import { PluginPackage, PluginServer } from '@theia/plugin-ext';
|
|
22
|
-
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
23
|
-
import { VSXSearchEntry } from '@theia/ovsx-client';
|
|
24
|
-
import { VSCodeExtensionUri } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-uri';
|
|
25
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
26
|
-
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
27
|
-
|
|
28
|
-
@injectable()
|
|
29
|
-
export class VSXLanguageQuickPickService extends LanguageQuickPickService {
|
|
30
|
-
|
|
31
|
-
@inject(OVSXClientProvider)
|
|
32
|
-
protected readonly clientProvider: OVSXClientProvider;
|
|
33
|
-
|
|
34
|
-
@inject(RequestService)
|
|
35
|
-
protected readonly requestService: RequestService;
|
|
36
|
-
|
|
37
|
-
@inject(PluginServer)
|
|
38
|
-
protected readonly pluginServer: PluginServer;
|
|
39
|
-
|
|
40
|
-
@inject(MessageService)
|
|
41
|
-
protected readonly messageService: MessageService;
|
|
42
|
-
|
|
43
|
-
protected override async getAvailableLanguages(): Promise<LanguageQuickPickItem[]> {
|
|
44
|
-
const client = await this.clientProvider();
|
|
45
|
-
try {
|
|
46
|
-
const searchResult = await client.search({
|
|
47
|
-
category: 'Language Packs',
|
|
48
|
-
sortBy: 'downloadCount',
|
|
49
|
-
sortOrder: 'desc',
|
|
50
|
-
size: 20
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const extensionLanguages = await Promise.all(
|
|
54
|
-
searchResult.extensions.map(async extension => ({
|
|
55
|
-
extension,
|
|
56
|
-
languages: await this.loadExtensionLanguages(extension)
|
|
57
|
-
}))
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const languages = new Map<string, LanguageQuickPickItem>();
|
|
61
|
-
|
|
62
|
-
for (const extension of extensionLanguages) {
|
|
63
|
-
for (const localizationContribution of extension.languages) {
|
|
64
|
-
if (!languages.has(localizationContribution.languageId)) {
|
|
65
|
-
languages.set(localizationContribution.languageId, {
|
|
66
|
-
...this.createLanguageQuickPickItem(localizationContribution),
|
|
67
|
-
execute: async () => {
|
|
68
|
-
const progress = await this.messageService.showProgress({
|
|
69
|
-
text: nls.localizeByDefault('Installing {0} language support...',
|
|
70
|
-
localizationContribution.localizedLanguageName ?? localizationContribution.languageName ?? localizationContribution.languageId),
|
|
71
|
-
});
|
|
72
|
-
try {
|
|
73
|
-
const extensionUri = VSCodeExtensionUri.fromId(`${extension.extension.namespace}.${extension.extension.name}`).toString();
|
|
74
|
-
await this.pluginServer.deploy(extensionUri);
|
|
75
|
-
} finally {
|
|
76
|
-
progress.cancel();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return Array.from(languages.values());
|
|
84
|
-
} catch (error) {
|
|
85
|
-
console.error(error);
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
protected async loadExtensionLanguages(extension: VSXSearchEntry): Promise<LanguageInfo[]> {
|
|
91
|
-
// When searching for extensions on ovsx, we don't receive the `manifest` property.
|
|
92
|
-
// This property is only set when querying a specific extension.
|
|
93
|
-
// To improve performance, we assume that a manifest exists at `/package.json`.
|
|
94
|
-
const downloadUrl = extension.files.download;
|
|
95
|
-
const parentUrl = downloadUrl.substring(0, downloadUrl.lastIndexOf('/'));
|
|
96
|
-
const manifestUrl = parentUrl + '/package.json';
|
|
97
|
-
try {
|
|
98
|
-
const manifestRequest = await this.requestService.request({ url: manifestUrl });
|
|
99
|
-
const manifestContent = RequestContext.asJson<PluginPackage>(manifestRequest);
|
|
100
|
-
const localizations = manifestContent.contributes?.localizations ?? [];
|
|
101
|
-
return localizations.map(e => ({
|
|
102
|
-
languageId: e.languageId,
|
|
103
|
-
languageName: e.languageName,
|
|
104
|
-
localizedLanguageName: e.localizedLanguageName,
|
|
105
|
-
languagePack: true
|
|
106
|
-
}));
|
|
107
|
-
} catch {
|
|
108
|
-
// The `package.json` file might not actually exist, simply return an empty array
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 TypeFox 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 { LanguageQuickPickItem, LanguageQuickPickService } from '@theia/core/lib/browser/i18n/language-quick-pick-service';
|
|
18
|
+
import { RequestContext, RequestService } from '@theia/core/shared/@theia/request';
|
|
19
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
20
|
+
import { LanguageInfo } from '@theia/core/lib/common/i18n/localization';
|
|
21
|
+
import { PluginPackage, PluginServer } from '@theia/plugin-ext';
|
|
22
|
+
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
23
|
+
import { VSXSearchEntry } from '@theia/ovsx-client';
|
|
24
|
+
import { VSCodeExtensionUri } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-uri';
|
|
25
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
26
|
+
import { MessageService } from '@theia/core/lib/common/message-service';
|
|
27
|
+
|
|
28
|
+
@injectable()
|
|
29
|
+
export class VSXLanguageQuickPickService extends LanguageQuickPickService {
|
|
30
|
+
|
|
31
|
+
@inject(OVSXClientProvider)
|
|
32
|
+
protected readonly clientProvider: OVSXClientProvider;
|
|
33
|
+
|
|
34
|
+
@inject(RequestService)
|
|
35
|
+
protected readonly requestService: RequestService;
|
|
36
|
+
|
|
37
|
+
@inject(PluginServer)
|
|
38
|
+
protected readonly pluginServer: PluginServer;
|
|
39
|
+
|
|
40
|
+
@inject(MessageService)
|
|
41
|
+
protected readonly messageService: MessageService;
|
|
42
|
+
|
|
43
|
+
protected override async getAvailableLanguages(): Promise<LanguageQuickPickItem[]> {
|
|
44
|
+
const client = await this.clientProvider();
|
|
45
|
+
try {
|
|
46
|
+
const searchResult = await client.search({
|
|
47
|
+
category: 'Language Packs',
|
|
48
|
+
sortBy: 'downloadCount',
|
|
49
|
+
sortOrder: 'desc',
|
|
50
|
+
size: 20
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const extensionLanguages = await Promise.all(
|
|
54
|
+
searchResult.extensions.map(async extension => ({
|
|
55
|
+
extension,
|
|
56
|
+
languages: await this.loadExtensionLanguages(extension)
|
|
57
|
+
}))
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const languages = new Map<string, LanguageQuickPickItem>();
|
|
61
|
+
|
|
62
|
+
for (const extension of extensionLanguages) {
|
|
63
|
+
for (const localizationContribution of extension.languages) {
|
|
64
|
+
if (!languages.has(localizationContribution.languageId)) {
|
|
65
|
+
languages.set(localizationContribution.languageId, {
|
|
66
|
+
...this.createLanguageQuickPickItem(localizationContribution),
|
|
67
|
+
execute: async () => {
|
|
68
|
+
const progress = await this.messageService.showProgress({
|
|
69
|
+
text: nls.localizeByDefault('Installing {0} language support...',
|
|
70
|
+
localizationContribution.localizedLanguageName ?? localizationContribution.languageName ?? localizationContribution.languageId),
|
|
71
|
+
});
|
|
72
|
+
try {
|
|
73
|
+
const extensionUri = VSCodeExtensionUri.fromId(`${extension.extension.namespace}.${extension.extension.name}`).toString();
|
|
74
|
+
await this.pluginServer.deploy(extensionUri);
|
|
75
|
+
} finally {
|
|
76
|
+
progress.cancel();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return Array.from(languages.values());
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error);
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
protected async loadExtensionLanguages(extension: VSXSearchEntry): Promise<LanguageInfo[]> {
|
|
91
|
+
// When searching for extensions on ovsx, we don't receive the `manifest` property.
|
|
92
|
+
// This property is only set when querying a specific extension.
|
|
93
|
+
// To improve performance, we assume that a manifest exists at `/package.json`.
|
|
94
|
+
const downloadUrl = extension.files.download;
|
|
95
|
+
const parentUrl = downloadUrl.substring(0, downloadUrl.lastIndexOf('/'));
|
|
96
|
+
const manifestUrl = parentUrl + '/package.json';
|
|
97
|
+
try {
|
|
98
|
+
const manifestRequest = await this.requestService.request({ url: manifestUrl });
|
|
99
|
+
const manifestContent = RequestContext.asJson<PluginPackage>(manifestRequest);
|
|
100
|
+
const localizations = manifestContent.contributes?.localizations ?? [];
|
|
101
|
+
return localizations.map(e => ({
|
|
102
|
+
languageId: e.languageId,
|
|
103
|
+
languageName: e.languageName,
|
|
104
|
+
localizedLanguageName: e.localizedLanguageName,
|
|
105
|
+
languagePack: true
|
|
106
|
+
}));
|
|
107
|
+
} catch {
|
|
108
|
+
// The `package.json` file might not actually exist, simply return an empty array
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|