@theia/vsx-registry 1.34.2 → 1.34.3
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/LICENSE +641 -641
- package/README.md +36 -36
- package/lib/browser/recommended-extensions/preference-provider-overrides.d.ts +17 -17
- package/lib/browser/recommended-extensions/preference-provider-overrides.js +95 -95
- package/lib/browser/recommended-extensions/recommended-extensions-json-schema.d.ts +14 -14
- package/lib/browser/recommended-extensions/recommended-extensions-json-schema.js +94 -94
- package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.d.ts +11 -11
- package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js +59 -59
- package/lib/browser/vsx-extension-commands.d.ts +13 -13
- package/lib/browser/vsx-extension-commands.js +63 -63
- package/lib/browser/vsx-extension-editor-manager.d.ts +9 -9
- package/lib/browser/vsx-extension-editor-manager.js +49 -49
- package/lib/browser/vsx-extension-editor.d.ts +21 -21
- package/lib/browser/vsx-extension-editor.js +109 -109
- package/lib/browser/vsx-extension.d.ts +141 -141
- package/lib/browser/vsx-extension.js +581 -581
- package/lib/browser/vsx-extensions-contribution.d.ts +54 -54
- package/lib/browser/vsx-extensions-contribution.js +328 -328
- package/lib/browser/vsx-extensions-model.d.ts +67 -67
- package/lib/browser/vsx-extensions-model.js +368 -368
- package/lib/browser/vsx-extensions-search-bar.d.ts +14 -14
- package/lib/browser/vsx-extensions-search-bar.js +75 -75
- package/lib/browser/vsx-extensions-search-model.d.ts +21 -21
- package/lib/browser/vsx-extensions-search-model.js +70 -70
- package/lib/browser/vsx-extensions-source.d.ts +19 -19
- package/lib/browser/vsx-extensions-source.js +102 -102
- package/lib/browser/vsx-extensions-view-container.d.ts +49 -49
- package/lib/browser/vsx-extensions-view-container.js +179 -179
- package/lib/browser/vsx-extensions-widget.d.ts +29 -29
- package/lib/browser/vsx-extensions-widget.js +143 -143
- package/lib/browser/vsx-language-quick-pick-service.d.ts +13 -13
- package/lib/browser/vsx-language-quick-pick-service.js +103 -103
- package/lib/browser/vsx-registry-frontend-module.d.ts +4 -4
- package/lib/browser/vsx-registry-frontend-module.js +101 -101
- package/lib/common/ovsx-client-provider.d.ts +6 -6
- package/lib/common/ovsx-client-provider.js +28 -28
- package/lib/common/vsx-environment.d.ts +7 -7
- package/lib/common/vsx-environment.js +20 -20
- package/lib/common/vsx-extension-uri.d.ts +3 -3
- package/lib/common/vsx-extension-uri.js +20 -20
- package/lib/node/vsx-environment-impl.d.ts +10 -10
- package/lib/node/vsx-environment-impl.js +53 -53
- package/lib/node/vsx-extension-resolver.d.ts +17 -17
- package/lib/node/vsx-extension-resolver.js +137 -137
- package/lib/node/vsx-registry-backend-module.d.ts +3 -3
- package/lib/node/vsx-registry-backend-module.js +35 -35
- package/lib/package.spec.js +25 -25
- package/package.json +10 -10
- 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 +354 -354
- package/src/browser/vsx-extension-commands.ts +63 -63
- 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 +662 -662
- package/src/browser/vsx-extensions-contribution.ts +315 -315
- package/src/browser/vsx-extensions-model.ts +366 -366
- package/src/browser/vsx-extensions-search-bar.tsx +69 -69
- 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 +138 -138
- package/src/browser/vsx-language-quick-pick-service.ts +97 -97
- package/src/browser/vsx-registry-frontend-module.ts +113 -113
- package/src/common/ovsx-client-provider.ts +30 -30
- package/src/common/vsx-environment.ts +24 -24
- package/src/common/vsx-extension-uri.ts +20 -20
- package/src/node/vsx-environment-impl.ts +41 -41
- package/src/node/vsx-extension-resolver.ts +111 -111
- package/src/node/vsx-registry-backend-module.ts +37 -37
- package/src/package.spec.ts +29 -29
|
@@ -1,179 +1,179 @@
|
|
|
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 WITH Classpath-exception-2.0
|
|
15
|
-
*******************************************************************************‚*/
|
|
16
|
-
|
|
17
|
-
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ViewContainer, PanelLayout, ViewContainerPart, Message, codicon } from '@theia/core/lib/browser';
|
|
19
|
-
import { VSXExtensionsSearchBar } from './vsx-extensions-search-bar';
|
|
20
|
-
import { VSXExtensionsModel } from './vsx-extensions-model';
|
|
21
|
-
import { VSXSearchMode } from './vsx-extensions-search-model';
|
|
22
|
-
import { generateExtensionWidgetId } from './vsx-extensions-widget';
|
|
23
|
-
import { VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
24
|
-
import { VSXExtensionsCommands } from './vsx-extension-commands';
|
|
25
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
26
|
-
|
|
27
|
-
@injectable()
|
|
28
|
-
export class VSXExtensionsViewContainer extends ViewContainer {
|
|
29
|
-
|
|
30
|
-
static ID = 'vsx-extensions-view-container';
|
|
31
|
-
static LABEL = nls.localizeByDefault('Extensions');
|
|
32
|
-
|
|
33
|
-
override disableDNDBetweenContainers = true;
|
|
34
|
-
|
|
35
|
-
@inject(VSXExtensionsSearchBar)
|
|
36
|
-
protected readonly searchBar: VSXExtensionsSearchBar;
|
|
37
|
-
|
|
38
|
-
@inject(VSXExtensionsModel)
|
|
39
|
-
protected readonly model: VSXExtensionsModel;
|
|
40
|
-
|
|
41
|
-
@postConstruct()
|
|
42
|
-
protected override init(): void {
|
|
43
|
-
super.init();
|
|
44
|
-
this.id = VSXExtensionsViewContainer.ID;
|
|
45
|
-
this.addClass('theia-vsx-extensions-view-container');
|
|
46
|
-
|
|
47
|
-
this.setTitleOptions({
|
|
48
|
-
label: VSXExtensionsViewContainer.LABEL,
|
|
49
|
-
iconClass: codicon('extensions'),
|
|
50
|
-
closeable: true
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
protected override onActivateRequest(msg: Message): void {
|
|
55
|
-
this.searchBar.activate();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected override onAfterAttach(msg: Message): void {
|
|
59
|
-
super.onBeforeAttach(msg);
|
|
60
|
-
this.updateMode();
|
|
61
|
-
this.toDisposeOnDetach.push(this.model.search.onDidChangeQuery(() => this.updateMode()));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
protected override configureLayout(layout: PanelLayout): void {
|
|
65
|
-
layout.addWidget(this.searchBar);
|
|
66
|
-
super.configureLayout(layout);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
protected currentMode: VSXSearchMode = VSXSearchMode.Initial;
|
|
70
|
-
protected readonly lastModeState = new Map<VSXSearchMode, ViewContainer.State>();
|
|
71
|
-
|
|
72
|
-
protected updateMode(): void {
|
|
73
|
-
const currentMode = this.model.search.getModeForQuery();
|
|
74
|
-
if (currentMode === this.currentMode) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (this.currentMode !== VSXSearchMode.Initial) {
|
|
78
|
-
this.lastModeState.set(this.currentMode, super.doStoreState());
|
|
79
|
-
}
|
|
80
|
-
this.currentMode = currentMode;
|
|
81
|
-
const lastState = this.lastModeState.get(currentMode);
|
|
82
|
-
if (lastState) {
|
|
83
|
-
super.doRestoreState(lastState);
|
|
84
|
-
} else {
|
|
85
|
-
for (const part of this.getParts()) {
|
|
86
|
-
this.applyModeToPart(part);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const specialWidgets = this.getWidgetsForMode();
|
|
91
|
-
if (specialWidgets?.length) {
|
|
92
|
-
const widgetChecker = new Set(specialWidgets);
|
|
93
|
-
const relevantParts = this.getParts().filter(part => widgetChecker.has(part.wrapped.id));
|
|
94
|
-
relevantParts.forEach(part => {
|
|
95
|
-
part.collapsed = false;
|
|
96
|
-
part.show();
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
protected override registerPart(part: ViewContainerPart): void {
|
|
102
|
-
super.registerPart(part);
|
|
103
|
-
this.applyModeToPart(part);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
protected applyModeToPart(part: ViewContainerPart): void {
|
|
107
|
-
if (this.shouldShowWidget(part)) {
|
|
108
|
-
part.show();
|
|
109
|
-
} else {
|
|
110
|
-
part.hide();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
protected shouldShowWidget(part: ViewContainerPart): boolean {
|
|
115
|
-
const widgetsToShow = this.getWidgetsForMode();
|
|
116
|
-
if (widgetsToShow.length) {
|
|
117
|
-
return widgetsToShow.includes(part.wrapped.id);
|
|
118
|
-
}
|
|
119
|
-
return part.wrapped.id !== generateExtensionWidgetId(VSXExtensionsSourceOptions.SEARCH_RESULT);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
protected getWidgetsForMode(): string[] {
|
|
123
|
-
switch (this.currentMode) {
|
|
124
|
-
case VSXSearchMode.Builtin:
|
|
125
|
-
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.BUILT_IN)];
|
|
126
|
-
case VSXSearchMode.Installed:
|
|
127
|
-
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.INSTALLED)];
|
|
128
|
-
case VSXSearchMode.Recommended:
|
|
129
|
-
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.RECOMMENDED)];
|
|
130
|
-
case VSXSearchMode.Search:
|
|
131
|
-
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.SEARCH_RESULT)];
|
|
132
|
-
default:
|
|
133
|
-
return [];
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
-
protected override doStoreState(): any {
|
|
139
|
-
const modes: VSXExtensionsViewContainer.State['modes'] = {};
|
|
140
|
-
for (const mode of this.lastModeState.keys()) {
|
|
141
|
-
modes[mode] = this.lastModeState.get(mode);
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
query: this.model.search.query,
|
|
145
|
-
modes
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
-
protected override doRestoreState(state: any): void {
|
|
151
|
-
// eslint-disable-next-line guard-for-in
|
|
152
|
-
for (const key in state.modes) {
|
|
153
|
-
const mode = Number(key) as VSXSearchMode;
|
|
154
|
-
const modeState = state.modes[mode];
|
|
155
|
-
if (modeState) {
|
|
156
|
-
this.lastModeState.set(mode, modeState);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
this.model.search.query = state.query;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
protected override updateToolbarItems(allParts: ViewContainerPart[]): void {
|
|
163
|
-
super.updateToolbarItems(allParts);
|
|
164
|
-
this.registerToolbarItem(VSXExtensionsCommands.INSTALL_FROM_VSIX.id, { tooltip: VSXExtensionsCommands.INSTALL_FROM_VSIX.label, group: 'other_1' });
|
|
165
|
-
this.registerToolbarItem(VSXExtensionsCommands.CLEAR_ALL.id, { tooltip: VSXExtensionsCommands.CLEAR_ALL.label, priority: 1, onDidChange: this.model.onDidChange });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
protected override getToggleVisibilityGroupLabel(): string {
|
|
169
|
-
return 'a/' + nls.localizeByDefault('Views');
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
export namespace VSXExtensionsViewContainer {
|
|
173
|
-
export interface State {
|
|
174
|
-
query: string;
|
|
175
|
-
modes: {
|
|
176
|
-
[mode: number]: ViewContainer.State | undefined
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
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 WITH Classpath-exception-2.0
|
|
15
|
+
*******************************************************************************‚*/
|
|
16
|
+
|
|
17
|
+
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
|
+
import { ViewContainer, PanelLayout, ViewContainerPart, Message, codicon } from '@theia/core/lib/browser';
|
|
19
|
+
import { VSXExtensionsSearchBar } from './vsx-extensions-search-bar';
|
|
20
|
+
import { VSXExtensionsModel } from './vsx-extensions-model';
|
|
21
|
+
import { VSXSearchMode } from './vsx-extensions-search-model';
|
|
22
|
+
import { generateExtensionWidgetId } from './vsx-extensions-widget';
|
|
23
|
+
import { VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
24
|
+
import { VSXExtensionsCommands } from './vsx-extension-commands';
|
|
25
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
26
|
+
|
|
27
|
+
@injectable()
|
|
28
|
+
export class VSXExtensionsViewContainer extends ViewContainer {
|
|
29
|
+
|
|
30
|
+
static ID = 'vsx-extensions-view-container';
|
|
31
|
+
static LABEL = nls.localizeByDefault('Extensions');
|
|
32
|
+
|
|
33
|
+
override disableDNDBetweenContainers = true;
|
|
34
|
+
|
|
35
|
+
@inject(VSXExtensionsSearchBar)
|
|
36
|
+
protected readonly searchBar: VSXExtensionsSearchBar;
|
|
37
|
+
|
|
38
|
+
@inject(VSXExtensionsModel)
|
|
39
|
+
protected readonly model: VSXExtensionsModel;
|
|
40
|
+
|
|
41
|
+
@postConstruct()
|
|
42
|
+
protected override init(): void {
|
|
43
|
+
super.init();
|
|
44
|
+
this.id = VSXExtensionsViewContainer.ID;
|
|
45
|
+
this.addClass('theia-vsx-extensions-view-container');
|
|
46
|
+
|
|
47
|
+
this.setTitleOptions({
|
|
48
|
+
label: VSXExtensionsViewContainer.LABEL,
|
|
49
|
+
iconClass: codicon('extensions'),
|
|
50
|
+
closeable: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected override onActivateRequest(msg: Message): void {
|
|
55
|
+
this.searchBar.activate();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected override onAfterAttach(msg: Message): void {
|
|
59
|
+
super.onBeforeAttach(msg);
|
|
60
|
+
this.updateMode();
|
|
61
|
+
this.toDisposeOnDetach.push(this.model.search.onDidChangeQuery(() => this.updateMode()));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected override configureLayout(layout: PanelLayout): void {
|
|
65
|
+
layout.addWidget(this.searchBar);
|
|
66
|
+
super.configureLayout(layout);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
protected currentMode: VSXSearchMode = VSXSearchMode.Initial;
|
|
70
|
+
protected readonly lastModeState = new Map<VSXSearchMode, ViewContainer.State>();
|
|
71
|
+
|
|
72
|
+
protected updateMode(): void {
|
|
73
|
+
const currentMode = this.model.search.getModeForQuery();
|
|
74
|
+
if (currentMode === this.currentMode) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (this.currentMode !== VSXSearchMode.Initial) {
|
|
78
|
+
this.lastModeState.set(this.currentMode, super.doStoreState());
|
|
79
|
+
}
|
|
80
|
+
this.currentMode = currentMode;
|
|
81
|
+
const lastState = this.lastModeState.get(currentMode);
|
|
82
|
+
if (lastState) {
|
|
83
|
+
super.doRestoreState(lastState);
|
|
84
|
+
} else {
|
|
85
|
+
for (const part of this.getParts()) {
|
|
86
|
+
this.applyModeToPart(part);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const specialWidgets = this.getWidgetsForMode();
|
|
91
|
+
if (specialWidgets?.length) {
|
|
92
|
+
const widgetChecker = new Set(specialWidgets);
|
|
93
|
+
const relevantParts = this.getParts().filter(part => widgetChecker.has(part.wrapped.id));
|
|
94
|
+
relevantParts.forEach(part => {
|
|
95
|
+
part.collapsed = false;
|
|
96
|
+
part.show();
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
protected override registerPart(part: ViewContainerPart): void {
|
|
102
|
+
super.registerPart(part);
|
|
103
|
+
this.applyModeToPart(part);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
protected applyModeToPart(part: ViewContainerPart): void {
|
|
107
|
+
if (this.shouldShowWidget(part)) {
|
|
108
|
+
part.show();
|
|
109
|
+
} else {
|
|
110
|
+
part.hide();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
protected shouldShowWidget(part: ViewContainerPart): boolean {
|
|
115
|
+
const widgetsToShow = this.getWidgetsForMode();
|
|
116
|
+
if (widgetsToShow.length) {
|
|
117
|
+
return widgetsToShow.includes(part.wrapped.id);
|
|
118
|
+
}
|
|
119
|
+
return part.wrapped.id !== generateExtensionWidgetId(VSXExtensionsSourceOptions.SEARCH_RESULT);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
protected getWidgetsForMode(): string[] {
|
|
123
|
+
switch (this.currentMode) {
|
|
124
|
+
case VSXSearchMode.Builtin:
|
|
125
|
+
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.BUILT_IN)];
|
|
126
|
+
case VSXSearchMode.Installed:
|
|
127
|
+
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.INSTALLED)];
|
|
128
|
+
case VSXSearchMode.Recommended:
|
|
129
|
+
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.RECOMMENDED)];
|
|
130
|
+
case VSXSearchMode.Search:
|
|
131
|
+
return [generateExtensionWidgetId(VSXExtensionsSourceOptions.SEARCH_RESULT)];
|
|
132
|
+
default:
|
|
133
|
+
return [];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
138
|
+
protected override doStoreState(): any {
|
|
139
|
+
const modes: VSXExtensionsViewContainer.State['modes'] = {};
|
|
140
|
+
for (const mode of this.lastModeState.keys()) {
|
|
141
|
+
modes[mode] = this.lastModeState.get(mode);
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
query: this.model.search.query,
|
|
145
|
+
modes
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
|
+
protected override doRestoreState(state: any): void {
|
|
151
|
+
// eslint-disable-next-line guard-for-in
|
|
152
|
+
for (const key in state.modes) {
|
|
153
|
+
const mode = Number(key) as VSXSearchMode;
|
|
154
|
+
const modeState = state.modes[mode];
|
|
155
|
+
if (modeState) {
|
|
156
|
+
this.lastModeState.set(mode, modeState);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
this.model.search.query = state.query;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
protected override updateToolbarItems(allParts: ViewContainerPart[]): void {
|
|
163
|
+
super.updateToolbarItems(allParts);
|
|
164
|
+
this.registerToolbarItem(VSXExtensionsCommands.INSTALL_FROM_VSIX.id, { tooltip: VSXExtensionsCommands.INSTALL_FROM_VSIX.label, group: 'other_1' });
|
|
165
|
+
this.registerToolbarItem(VSXExtensionsCommands.CLEAR_ALL.id, { tooltip: VSXExtensionsCommands.CLEAR_ALL.label, priority: 1, onDidChange: this.model.onDidChange });
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
protected override getToggleVisibilityGroupLabel(): string {
|
|
169
|
+
return 'a/' + nls.localizeByDefault('Views');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export namespace VSXExtensionsViewContainer {
|
|
173
|
+
export interface State {
|
|
174
|
+
query: string;
|
|
175
|
+
modes: {
|
|
176
|
+
[mode: number]: ViewContainer.State | undefined
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -1,138 +1,138 @@
|
|
|
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 WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, interfaces, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
18
|
-
import { 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
|
-
@inject(VSXExtensionsWidgetOptions)
|
|
56
|
-
protected readonly options: VSXExtensionsWidgetOptions;
|
|
57
|
-
|
|
58
|
-
@inject(VSXExtensionsSource)
|
|
59
|
-
protected readonly extensionsSource: VSXExtensionsSource;
|
|
60
|
-
|
|
61
|
-
@postConstruct()
|
|
62
|
-
protected override init(): void {
|
|
63
|
-
super.init();
|
|
64
|
-
this.addClass('theia-vsx-extensions');
|
|
65
|
-
|
|
66
|
-
this.id = generateExtensionWidgetId(this.options.id);
|
|
67
|
-
|
|
68
|
-
this.toDispose.push(this.extensionsSource);
|
|
69
|
-
this.source = this.extensionsSource;
|
|
70
|
-
|
|
71
|
-
const title = this.options.title ?? this.computeTitle();
|
|
72
|
-
this.title.label = title;
|
|
73
|
-
this.title.caption = title;
|
|
74
|
-
|
|
75
|
-
this.toDispose.push(this.source.onDidChange(async () => {
|
|
76
|
-
this.badge = await this.resolveCount();
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
get onDidChangeBadge(): Event<void> {
|
|
81
|
-
return this.onDidChangeBadgeEmitter.event;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
get badge(): number | undefined {
|
|
85
|
-
return this._badge;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
set badge(count: number | undefined) {
|
|
89
|
-
this._badge = count;
|
|
90
|
-
this.onDidChangeBadgeEmitter.fire();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
protected computeTitle(): string {
|
|
94
|
-
switch (this.options.id) {
|
|
95
|
-
case VSXExtensionsSourceOptions.INSTALLED:
|
|
96
|
-
return nls.localizeByDefault('Installed');
|
|
97
|
-
case VSXExtensionsSourceOptions.BUILT_IN:
|
|
98
|
-
return nls.localizeByDefault('Built-in');
|
|
99
|
-
case VSXExtensionsSourceOptions.RECOMMENDED:
|
|
100
|
-
return nls.localizeByDefault('Recommended');
|
|
101
|
-
case VSXExtensionsSourceOptions.SEARCH_RESULT:
|
|
102
|
-
return 'Open VSX Registry';
|
|
103
|
-
default:
|
|
104
|
-
return '';
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
protected async resolveCount(): Promise<number | undefined> {
|
|
109
|
-
if (this.options.id !== VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
110
|
-
const elements = await this.source?.getElements() || [];
|
|
111
|
-
return [...elements].length;
|
|
112
|
-
}
|
|
113
|
-
return undefined;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
protected override tapNode(node?: TreeNode): void {
|
|
117
|
-
super.tapNode(node);
|
|
118
|
-
this.model.openNode(node);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
protected override handleDblClickEvent(): void {
|
|
122
|
-
// Don't open the editor view on a double click.
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
protected override renderTree(model: TreeModel): React.ReactNode {
|
|
126
|
-
if (this.options.id === VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
127
|
-
const searchError = this.extensionsSource.getModel().searchError;
|
|
128
|
-
if (!!searchError) {
|
|
129
|
-
const message = nls.localize('theia/vsx-registry/errorFetching', 'Error fetching extensions.');
|
|
130
|
-
return <AlertMessage
|
|
131
|
-
type='ERROR'
|
|
132
|
-
header={`${message} ${searchError}`}
|
|
133
|
-
/>;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return super.renderTree(model);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
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 WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, interfaces, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
18
|
+
import { 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
|
+
@inject(VSXExtensionsWidgetOptions)
|
|
56
|
+
protected readonly options: VSXExtensionsWidgetOptions;
|
|
57
|
+
|
|
58
|
+
@inject(VSXExtensionsSource)
|
|
59
|
+
protected readonly extensionsSource: VSXExtensionsSource;
|
|
60
|
+
|
|
61
|
+
@postConstruct()
|
|
62
|
+
protected override init(): void {
|
|
63
|
+
super.init();
|
|
64
|
+
this.addClass('theia-vsx-extensions');
|
|
65
|
+
|
|
66
|
+
this.id = generateExtensionWidgetId(this.options.id);
|
|
67
|
+
|
|
68
|
+
this.toDispose.push(this.extensionsSource);
|
|
69
|
+
this.source = this.extensionsSource;
|
|
70
|
+
|
|
71
|
+
const title = this.options.title ?? this.computeTitle();
|
|
72
|
+
this.title.label = title;
|
|
73
|
+
this.title.caption = title;
|
|
74
|
+
|
|
75
|
+
this.toDispose.push(this.source.onDidChange(async () => {
|
|
76
|
+
this.badge = await this.resolveCount();
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
get onDidChangeBadge(): Event<void> {
|
|
81
|
+
return this.onDidChangeBadgeEmitter.event;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get badge(): number | undefined {
|
|
85
|
+
return this._badge;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set badge(count: number | undefined) {
|
|
89
|
+
this._badge = count;
|
|
90
|
+
this.onDidChangeBadgeEmitter.fire();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected computeTitle(): string {
|
|
94
|
+
switch (this.options.id) {
|
|
95
|
+
case VSXExtensionsSourceOptions.INSTALLED:
|
|
96
|
+
return nls.localizeByDefault('Installed');
|
|
97
|
+
case VSXExtensionsSourceOptions.BUILT_IN:
|
|
98
|
+
return nls.localizeByDefault('Built-in');
|
|
99
|
+
case VSXExtensionsSourceOptions.RECOMMENDED:
|
|
100
|
+
return nls.localizeByDefault('Recommended');
|
|
101
|
+
case VSXExtensionsSourceOptions.SEARCH_RESULT:
|
|
102
|
+
return 'Open VSX Registry';
|
|
103
|
+
default:
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
protected async resolveCount(): Promise<number | undefined> {
|
|
109
|
+
if (this.options.id !== VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
110
|
+
const elements = await this.source?.getElements() || [];
|
|
111
|
+
return [...elements].length;
|
|
112
|
+
}
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
protected override tapNode(node?: TreeNode): void {
|
|
117
|
+
super.tapNode(node);
|
|
118
|
+
this.model.openNode(node);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
protected override handleDblClickEvent(): void {
|
|
122
|
+
// Don't open the editor view on a double click.
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
protected override renderTree(model: TreeModel): React.ReactNode {
|
|
126
|
+
if (this.options.id === VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
127
|
+
const searchError = this.extensionsSource.getModel().searchError;
|
|
128
|
+
if (!!searchError) {
|
|
129
|
+
const message = nls.localize('theia/vsx-registry/errorFetching', 'Error fetching extensions.');
|
|
130
|
+
return <AlertMessage
|
|
131
|
+
type='ERROR'
|
|
132
|
+
header={`${message} ${searchError}`}
|
|
133
|
+
/>;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return super.renderTree(model);
|
|
137
|
+
}
|
|
138
|
+
}
|