@theia/vsx-registry 1.39.0-next.9 → 1.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/lib/browser/recommended-extensions/preference-provider-overrides.js +1 -1
- package/lib/browser/recommended-extensions/preference-provider-overrides.js.map +1 -1
- package/lib/browser/recommended-extensions/recommended-extensions-json-schema.js +1 -1
- package/lib/browser/recommended-extensions/recommended-extensions-json-schema.js.map +1 -1
- package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js +1 -1
- package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js.map +1 -1
- package/lib/browser/vsx-extension-commands.d.ts.map +1 -1
- package/lib/browser/vsx-extension-commands.js +3 -3
- package/lib/browser/vsx-extension-commands.js.map +1 -1
- package/lib/browser/vsx-extension-editor-manager.js +1 -1
- package/lib/browser/vsx-extension-editor-manager.js.map +1 -1
- package/lib/browser/vsx-extension-editor.js +1 -1
- package/lib/browser/vsx-extension-editor.js.map +1 -1
- package/lib/browser/vsx-extension.d.ts +2 -0
- package/lib/browser/vsx-extension.d.ts.map +1 -1
- package/lib/browser/vsx-extension.js +18 -3
- package/lib/browser/vsx-extension.js.map +1 -1
- package/lib/browser/vsx-extensions-contribution.d.ts +11 -9
- package/lib/browser/vsx-extensions-contribution.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-contribution.js +11 -6
- package/lib/browser/vsx-extensions-contribution.js.map +1 -1
- package/lib/browser/vsx-extensions-model.d.ts +25 -21
- package/lib/browser/vsx-extensions-model.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-model.js +83 -63
- package/lib/browser/vsx-extensions-model.js.map +1 -1
- package/lib/browser/vsx-extensions-search-bar.js +1 -1
- package/lib/browser/vsx-extensions-search-bar.js.map +1 -1
- package/lib/browser/vsx-extensions-search-model.js +1 -1
- package/lib/browser/vsx-extensions-search-model.js.map +1 -1
- package/lib/browser/vsx-extensions-source.js +1 -1
- package/lib/browser/vsx-extensions-source.js.map +1 -1
- package/lib/browser/vsx-extensions-view-container.d.ts +1 -1
- package/lib/browser/vsx-extensions-view-container.js +1 -1
- package/lib/browser/vsx-extensions-widget.js +1 -1
- package/lib/browser/vsx-extensions-widget.js.map +1 -1
- package/lib/browser/vsx-language-quick-pick-service.js +7 -4
- package/lib/browser/vsx-language-quick-pick-service.js.map +1 -1
- package/lib/browser/vsx-registry-frontend-module.d.ts.map +1 -1
- package/lib/browser/vsx-registry-frontend-module.js +5 -9
- package/lib/browser/vsx-registry-frontend-module.js.map +1 -1
- package/lib/common/index.d.ts +4 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +26 -0
- package/lib/common/index.js.map +1 -0
- package/lib/common/ovsx-client-provider.d.ts +9 -2
- package/lib/common/ovsx-client-provider.d.ts.map +1 -1
- package/lib/common/ovsx-client-provider.js +8 -7
- package/lib/common/ovsx-client-provider.js.map +1 -1
- package/lib/common/vsx-environment.d.ts +2 -0
- package/lib/common/vsx-environment.d.ts.map +1 -1
- package/lib/common/vsx-environment.js +1 -1
- package/lib/common/vsx-environment.js.map +1 -1
- package/lib/common/vsx-extension-uri.js +1 -1
- package/lib/common/vsx-extension-uri.js.map +1 -1
- package/lib/common/vsx-registry-common-module.d.ts +4 -0
- package/lib/common/vsx-registry-common-module.d.ts.map +1 -0
- package/lib/common/vsx-registry-common-module.js +58 -0
- package/lib/common/vsx-registry-common-module.js.map +1 -0
- package/lib/node/vsx-cli.d.ts +10 -0
- package/lib/node/vsx-cli.d.ts.map +1 -0
- package/lib/node/vsx-cli.js +42 -0
- package/lib/node/vsx-cli.js.map +1 -0
- package/lib/node/vsx-environment-impl.d.ts +4 -0
- package/lib/node/vsx-environment-impl.d.ts.map +1 -1
- package/lib/node/vsx-environment-impl.js +10 -2
- package/lib/node/vsx-environment-impl.js.map +1 -1
- package/lib/node/vsx-extension-resolver.d.ts +2 -1
- package/lib/node/vsx-extension-resolver.d.ts.map +1 -1
- package/lib/node/vsx-extension-resolver.js +10 -3
- package/lib/node/vsx-extension-resolver.js.map +1 -1
- package/lib/node/vsx-registry-backend-module.d.ts.map +1 -1
- package/lib/node/vsx-registry-backend-module.js +10 -10
- package/lib/node/vsx-registry-backend-module.js.map +1 -1
- package/lib/package.spec.js +1 -1
- package/lib/package.spec.js.map +1 -1
- package/package.json +15 -11
- package/src/browser/recommended-extensions/preference-provider-overrides.ts +1 -1
- package/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +1 -1
- package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +1 -1
- package/src/browser/style/index.css +173 -154
- package/src/browser/vsx-extension-commands.ts +3 -3
- package/src/browser/vsx-extension-editor-manager.ts +1 -1
- package/src/browser/vsx-extension-editor.tsx +1 -1
- package/src/browser/vsx-extension.tsx +17 -4
- package/src/browser/vsx-extensions-contribution.ts +16 -16
- package/src/browser/vsx-extensions-model.ts +98 -79
- package/src/browser/vsx-extensions-search-bar.tsx +1 -1
- package/src/browser/vsx-extensions-search-model.ts +1 -1
- package/src/browser/vsx-extensions-source.ts +1 -1
- package/src/browser/vsx-extensions-view-container.ts +1 -1
- package/src/browser/vsx-extensions-widget.tsx +1 -1
- package/src/browser/vsx-language-quick-pick-service.ts +1 -1
- package/src/browser/vsx-registry-frontend-module.ts +5 -12
- package/src/common/index.ts +19 -0
- package/src/common/ovsx-client-provider.ts +14 -9
- package/src/common/vsx-environment.ts +4 -1
- package/src/common/vsx-extension-uri.ts +1 -1
- package/src/common/vsx-registry-common-module.ts +63 -0
- package/src/node/vsx-cli.ts +38 -0
- package/src/node/vsx-environment-impl.ts +11 -2
- package/src/node/vsx-extension-resolver.ts +7 -4
- package/src/node/vsx-registry-backend-module.ts +10 -12
- package/src/package.spec.ts +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { DateTime } from 'luxon';
|
|
@@ -34,22 +34,22 @@ import { ClipboardService } from '@theia/core/lib/browser/clipboard-service';
|
|
|
34
34
|
import { BUILTIN_QUERY, INSTALLED_QUERY, RECOMMENDED_QUERY } from './vsx-extensions-search-model';
|
|
35
35
|
import { IGNORE_RECOMMENDATIONS_ID } from './recommended-extensions/recommended-extensions-preference-contribution';
|
|
36
36
|
import { VSXExtensionsCommands } from './vsx-extension-commands';
|
|
37
|
-
import { VSXExtensionRaw } from '@theia/ovsx-client';
|
|
37
|
+
import { VSXExtensionRaw, OVSXApiFilter } from '@theia/ovsx-client';
|
|
38
38
|
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
39
39
|
|
|
40
40
|
@injectable()
|
|
41
|
-
export class VSXExtensionsContribution extends AbstractViewContribution<VSXExtensionsViewContainer>
|
|
42
|
-
implements ColorContribution, FrontendApplicationContribution {
|
|
41
|
+
export class VSXExtensionsContribution extends AbstractViewContribution<VSXExtensionsViewContainer> implements ColorContribution, FrontendApplicationContribution {
|
|
43
42
|
|
|
44
|
-
@inject(VSXExtensionsModel) protected
|
|
45
|
-
@inject(CommandRegistry) protected
|
|
46
|
-
@inject(FileDialogService) protected
|
|
47
|
-
@inject(MessageService) protected
|
|
48
|
-
@inject(LabelProvider) protected
|
|
49
|
-
@inject(ClipboardService) protected
|
|
50
|
-
@inject(PreferenceService) protected
|
|
51
|
-
@inject(OVSXClientProvider) protected
|
|
52
|
-
@inject(
|
|
43
|
+
@inject(VSXExtensionsModel) protected model: VSXExtensionsModel;
|
|
44
|
+
@inject(CommandRegistry) protected commandRegistry: CommandRegistry;
|
|
45
|
+
@inject(FileDialogService) protected fileDialogService: FileDialogService;
|
|
46
|
+
@inject(MessageService) protected messageService: MessageService;
|
|
47
|
+
@inject(LabelProvider) protected labelProvider: LabelProvider;
|
|
48
|
+
@inject(ClipboardService) protected clipboardService: ClipboardService;
|
|
49
|
+
@inject(PreferenceService) protected preferenceService: PreferenceService;
|
|
50
|
+
@inject(OVSXClientProvider) protected clientProvider: OVSXClientProvider;
|
|
51
|
+
@inject(OVSXApiFilter) protected vsxApiFilter: OVSXApiFilter;
|
|
52
|
+
@inject(QuickInputService) protected quickInput: QuickInputService;
|
|
53
53
|
|
|
54
54
|
constructor() {
|
|
55
55
|
super({
|
|
@@ -209,8 +209,8 @@ export class VSXExtensionsContribution extends AbstractViewContribution<VSXExten
|
|
|
209
209
|
const extensionId = extension.id;
|
|
210
210
|
const currentVersion = extension.version;
|
|
211
211
|
const client = await this.clientProvider();
|
|
212
|
-
const extensions = await client.
|
|
213
|
-
const latestCompatible =
|
|
212
|
+
const { extensions } = await client.query({ extensionId, includeAllVersions: true });
|
|
213
|
+
const latestCompatible = this.vsxApiFilter.getLatestCompatibleExtension(extensions);
|
|
214
214
|
let compatibleExtensions: VSXExtensionRaw[] = [];
|
|
215
215
|
let activeItem = undefined;
|
|
216
216
|
if (latestCompatible) {
|
|
@@ -283,7 +283,7 @@ export class VSXExtensionsContribution extends AbstractViewContribution<VSXExten
|
|
|
283
283
|
const install = nls.localizeByDefault('Install');
|
|
284
284
|
const showRecommendations = nls.localizeByDefault('Show Recommendations');
|
|
285
285
|
const userResponse = await this.messageService.info(
|
|
286
|
-
nls.
|
|
286
|
+
nls.localize('theia/vsx-registry/recommendedExtensions', 'Do you want to install the recommended extensions for this repository?'),
|
|
287
287
|
install,
|
|
288
288
|
showRecommendations
|
|
289
289
|
);
|
|
@@ -11,32 +11,47 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
18
|
import debounce from 'p-debounce';
|
|
19
19
|
import * as markdownit from '@theia/core/shared/markdown-it';
|
|
20
20
|
import * as DOMPurify from '@theia/core/shared/dompurify';
|
|
21
|
-
import { Emitter } from '@theia/core/lib/common/event';
|
|
21
|
+
import { Emitter, Event } from '@theia/core/lib/common/event';
|
|
22
22
|
import { CancellationToken, CancellationTokenSource } from '@theia/core/lib/common/cancellation';
|
|
23
23
|
import { HostedPluginSupport } from '@theia/plugin-ext/lib/hosted/browser/hosted-plugin';
|
|
24
24
|
import { VSXExtension, VSXExtensionFactory } from './vsx-extension';
|
|
25
25
|
import { ProgressService } from '@theia/core/lib/common/progress-service';
|
|
26
26
|
import { VSXExtensionsSearchModel } from './vsx-extensions-search-model';
|
|
27
|
-
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
28
27
|
import { PreferenceInspectionScope, PreferenceService } from '@theia/core/lib/browser';
|
|
29
28
|
import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
30
29
|
import { RecommendedExtensions } from './recommended-extensions/recommended-extensions-preference-contribution';
|
|
31
30
|
import URI from '@theia/core/lib/common/uri';
|
|
32
|
-
import { VSXResponseError,
|
|
31
|
+
import { VSXExtensionRaw, VSXResponseError, VSXSearchOptions } from '@theia/ovsx-client/lib/ovsx-types';
|
|
33
32
|
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
33
|
+
import { RequestContext, RequestService } from '@theia/core/shared/@theia/request';
|
|
34
|
+
import { OVSXApiFilter } from '@theia/ovsx-client';
|
|
34
35
|
|
|
35
36
|
@injectable()
|
|
36
37
|
export class VSXExtensionsModel {
|
|
37
38
|
|
|
39
|
+
protected initialized: Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Single source for all extensions
|
|
42
|
+
*/
|
|
43
|
+
protected readonly extensions = new Map<string, VSXExtension>();
|
|
38
44
|
protected readonly onDidChangeEmitter = new Emitter<void>();
|
|
39
|
-
|
|
45
|
+
protected _installed = new Set<string>();
|
|
46
|
+
protected _recommended = new Set<string>();
|
|
47
|
+
protected _searchResult = new Set<string>();
|
|
48
|
+
protected _searchError?: string;
|
|
49
|
+
|
|
50
|
+
protected searchCancellationTokenSource = new CancellationTokenSource();
|
|
51
|
+
protected updateSearchResult = debounce(async () => {
|
|
52
|
+
const { token } = this.resetSearchCancellationTokenSource();
|
|
53
|
+
await this.doUpdateSearchResult({ query: this.search.query, includeAllVersions: true }, token);
|
|
54
|
+
}, 500);
|
|
40
55
|
|
|
41
56
|
@inject(OVSXClientProvider)
|
|
42
57
|
protected clientProvider: OVSXClientProvider;
|
|
@@ -59,11 +74,15 @@ export class VSXExtensionsModel {
|
|
|
59
74
|
@inject(VSXExtensionsSearchModel)
|
|
60
75
|
readonly search: VSXExtensionsSearchModel;
|
|
61
76
|
|
|
62
|
-
|
|
77
|
+
@inject(RequestService)
|
|
78
|
+
protected request: RequestService;
|
|
79
|
+
|
|
80
|
+
@inject(OVSXApiFilter)
|
|
81
|
+
protected vsxApiFilter: OVSXApiFilter;
|
|
63
82
|
|
|
64
83
|
@postConstruct()
|
|
65
84
|
protected init(): void {
|
|
66
|
-
this.doInit();
|
|
85
|
+
this.initialized = this.doInit().catch(console.error);
|
|
67
86
|
}
|
|
68
87
|
|
|
69
88
|
protected async doInit(): Promise<void> {
|
|
@@ -72,7 +91,56 @@ export class VSXExtensionsModel {
|
|
|
72
91
|
this.initSearchResult(),
|
|
73
92
|
this.initRecommended(),
|
|
74
93
|
]);
|
|
75
|
-
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
get onDidChange(): Event<void> {
|
|
97
|
+
return this.onDidChangeEmitter.event;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get installed(): IterableIterator<string> {
|
|
101
|
+
return this._installed.values();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get searchError(): string | undefined {
|
|
105
|
+
return this._searchError;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
get searchResult(): IterableIterator<string> {
|
|
109
|
+
return this._searchResult.values();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
get recommended(): IterableIterator<string> {
|
|
113
|
+
return this._recommended.values();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
isInstalled(id: string): boolean {
|
|
117
|
+
return this._installed.has(id);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
getExtension(id: string): VSXExtension | undefined {
|
|
121
|
+
return this.extensions.get(id);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
resolve(id: string): Promise<VSXExtension> {
|
|
125
|
+
return this.doChange(async () => {
|
|
126
|
+
await this.initialized;
|
|
127
|
+
const extension = await this.refresh(id);
|
|
128
|
+
if (!extension) {
|
|
129
|
+
throw new Error(`Failed to resolve ${id} extension.`);
|
|
130
|
+
}
|
|
131
|
+
if (extension.readmeUrl) {
|
|
132
|
+
try {
|
|
133
|
+
const rawReadme = RequestContext.asText(await this.request.request({ url: extension.readmeUrl }));
|
|
134
|
+
const readme = this.compileReadme(rawReadme);
|
|
135
|
+
extension.update({ readme });
|
|
136
|
+
} catch (e) {
|
|
137
|
+
if (!VSXResponseError.is(e) || e.statusCode !== 404) {
|
|
138
|
+
console.error(`[${id}]: failed to compile readme, reason:`, e);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return extension;
|
|
143
|
+
});
|
|
76
144
|
}
|
|
77
145
|
|
|
78
146
|
protected async initInstalled(): Promise<void> {
|
|
@@ -108,37 +176,9 @@ export class VSXExtensionsModel {
|
|
|
108
176
|
}
|
|
109
177
|
}
|
|
110
178
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
protected readonly extensions = new Map<string, VSXExtension>();
|
|
115
|
-
|
|
116
|
-
protected _installed = new Set<string>();
|
|
117
|
-
get installed(): IterableIterator<string> {
|
|
118
|
-
return this._installed.values();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
isInstalled(id: string): boolean {
|
|
122
|
-
return this._installed.has(id);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
protected _searchError?: string;
|
|
126
|
-
get searchError(): string | undefined {
|
|
127
|
-
return this._searchError;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
protected _searchResult = new Set<string>();
|
|
131
|
-
get searchResult(): IterableIterator<string> {
|
|
132
|
-
return this._searchResult.values();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
protected _recommended = new Set<string>();
|
|
136
|
-
get recommended(): IterableIterator<string> {
|
|
137
|
-
return this._recommended.values();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
getExtension(id: string): VSXExtension | undefined {
|
|
141
|
-
return this.extensions.get(id);
|
|
179
|
+
protected resetSearchCancellationTokenSource(): CancellationTokenSource {
|
|
180
|
+
this.searchCancellationTokenSource.cancel();
|
|
181
|
+
return this.searchCancellationTokenSource = new CancellationTokenSource();
|
|
142
182
|
}
|
|
143
183
|
|
|
144
184
|
protected setExtension(id: string): VSXExtension {
|
|
@@ -155,25 +195,18 @@ export class VSXExtensionsModel {
|
|
|
155
195
|
protected doChange<T>(task: () => Promise<T>, token: CancellationToken = CancellationToken.None): Promise<T | undefined> {
|
|
156
196
|
return this.progressService.withProgress('', 'extensions', async () => {
|
|
157
197
|
if (token && token.isCancellationRequested) {
|
|
158
|
-
return
|
|
198
|
+
return;
|
|
159
199
|
}
|
|
160
200
|
const result = await task();
|
|
161
201
|
if (token && token.isCancellationRequested) {
|
|
162
|
-
return
|
|
202
|
+
return;
|
|
163
203
|
}
|
|
164
|
-
this.onDidChangeEmitter.fire(
|
|
204
|
+
this.onDidChangeEmitter.fire();
|
|
165
205
|
return result;
|
|
166
206
|
});
|
|
167
207
|
}
|
|
168
208
|
|
|
169
|
-
protected
|
|
170
|
-
protected updateSearchResult = debounce(() => {
|
|
171
|
-
this.searchCancellationTokenSource.cancel();
|
|
172
|
-
this.searchCancellationTokenSource = new CancellationTokenSource();
|
|
173
|
-
const query = this.search.query;
|
|
174
|
-
return this.doUpdateSearchResult({ query, includeAllVersions: true }, this.searchCancellationTokenSource.token);
|
|
175
|
-
}, 500);
|
|
176
|
-
protected doUpdateSearchResult(param: VSXSearchParam, token: CancellationToken): Promise<void> {
|
|
209
|
+
protected doUpdateSearchResult(param: VSXSearchOptions, token: CancellationToken): Promise<void> {
|
|
177
210
|
return this.doChange(async () => {
|
|
178
211
|
const searchResult = new Set<string>();
|
|
179
212
|
if (!param.query) {
|
|
@@ -188,8 +221,8 @@ export class VSXExtensionsModel {
|
|
|
188
221
|
}
|
|
189
222
|
for (const data of result.extensions) {
|
|
190
223
|
const id = data.namespace.toLowerCase() + '.' + data.name.toLowerCase();
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
224
|
+
const allVersions = this.vsxApiFilter.getLatestCompatibleVersion(data);
|
|
225
|
+
if (!allVersions) {
|
|
193
226
|
continue;
|
|
194
227
|
}
|
|
195
228
|
this.setExtension(id).update(Object.assign(data, {
|
|
@@ -198,7 +231,7 @@ export class VSXExtensionsModel {
|
|
|
198
231
|
iconUrl: data.files.icon,
|
|
199
232
|
readmeUrl: data.files.readme,
|
|
200
233
|
licenseUrl: data.files.license,
|
|
201
|
-
version:
|
|
234
|
+
version: allVersions.version
|
|
202
235
|
}));
|
|
203
236
|
searchResult.add(id);
|
|
204
237
|
}
|
|
@@ -268,29 +301,6 @@ export class VSXExtensionsModel {
|
|
|
268
301
|
};
|
|
269
302
|
}
|
|
270
303
|
|
|
271
|
-
resolve(id: string): Promise<VSXExtension> {
|
|
272
|
-
return this.doChange(async () => {
|
|
273
|
-
await this.initialized.promise;
|
|
274
|
-
const extension = await this.refresh(id);
|
|
275
|
-
if (!extension) {
|
|
276
|
-
throw new Error(`Failed to resolve ${id} extension.`);
|
|
277
|
-
}
|
|
278
|
-
if (extension.readmeUrl) {
|
|
279
|
-
try {
|
|
280
|
-
const client = await this.clientProvider();
|
|
281
|
-
const rawReadme = await client.fetchText(extension.readmeUrl);
|
|
282
|
-
const readme = this.compileReadme(rawReadme);
|
|
283
|
-
extension.update({ readme });
|
|
284
|
-
} catch (e) {
|
|
285
|
-
if (!VSXResponseError.is(e) || e.statusCode !== 404) {
|
|
286
|
-
console.error(`[${id}]: failed to compile readme, reason:`, e);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
return extension;
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
304
|
protected compileReadme(readmeMarkdown: string): string {
|
|
295
305
|
const readmeHtml = markdownit({ html: true }).render(readmeMarkdown);
|
|
296
306
|
return DOMPurify.sanitize(readmeHtml);
|
|
@@ -303,9 +313,18 @@ export class VSXExtensionsModel {
|
|
|
303
313
|
return extension;
|
|
304
314
|
}
|
|
305
315
|
const client = await this.clientProvider();
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
316
|
+
let data: VSXExtensionRaw | undefined;
|
|
317
|
+
if (version === undefined) {
|
|
318
|
+
const { extensions } = await client.query({ extensionId: id, includeAllVersions: true });
|
|
319
|
+
if (extensions?.length) {
|
|
320
|
+
data = this.vsxApiFilter.getLatestCompatibleExtension(extensions);
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
const { extensions } = await client.query({ extensionId: id, extensionVersion: version, includeAllVersions: true });
|
|
324
|
+
if (extensions?.length) {
|
|
325
|
+
data = extensions?.[0];
|
|
326
|
+
}
|
|
327
|
+
}
|
|
309
328
|
if (!data) {
|
|
310
329
|
return;
|
|
311
330
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import * as React from '@theia/core/shared/react';
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable } from '@theia/core/shared/inversify';
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* with the GNU Classpath Exception which is available at
|
|
12
12
|
* https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
*
|
|
14
|
-
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
*******************************************************************************‚*/
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, interfaces, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { LanguageQuickPickItem, LanguageQuickPickService } from '@theia/core/lib/browser/i18n/language-quick-pick-service';
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import '../../src/browser/style/index.css';
|
|
@@ -33,21 +33,14 @@ import { VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
|
33
33
|
import { VSXExtensionsSearchModel } from './vsx-extensions-search-model';
|
|
34
34
|
import { bindExtensionPreferences } from './recommended-extensions/recommended-extensions-preference-contribution';
|
|
35
35
|
import { bindPreferenceProviderOverrides } from './recommended-extensions/preference-provider-overrides';
|
|
36
|
-
import { OVSXClientProvider, createOVSXClient } from '../common/ovsx-client-provider';
|
|
37
36
|
import { VSXEnvironment, VSX_ENVIRONMENT_PATH } from '../common/vsx-environment';
|
|
38
|
-
import { RequestService } from '@theia/core/shared/@theia/request';
|
|
39
37
|
import { LanguageQuickPickService } from '@theia/core/lib/browser/i18n/language-quick-pick-service';
|
|
40
38
|
import { VSXLanguageQuickPickService } from './vsx-language-quick-pick-service';
|
|
41
39
|
|
|
42
|
-
export default new ContainerModule((bind, unbind,
|
|
43
|
-
bind
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}).inSingletonScope();
|
|
47
|
-
bind(VSXEnvironment).toDynamicValue(
|
|
48
|
-
ctx => WebSocketConnectionProvider.createProxy(ctx.container, VSX_ENVIRONMENT_PATH)
|
|
49
|
-
).inSingletonScope();
|
|
50
|
-
|
|
40
|
+
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
41
|
+
bind(VSXEnvironment)
|
|
42
|
+
.toDynamicValue(ctx => WebSocketConnectionProvider.createProxy(ctx.container, VSX_ENVIRONMENT_PATH))
|
|
43
|
+
.inSingletonScope();
|
|
51
44
|
bind(VSXExtension).toSelf();
|
|
52
45
|
bind(VSXExtensionFactory).toFactory(ctx => (option: VSXExtensionOptions) => {
|
|
53
46
|
const child = ctx.container.createChild();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
export { OVSXClientProvider, OVSXUrlResolver } from './ovsx-client-provider';
|
|
18
|
+
export { VSXEnvironment } from './vsx-environment';
|
|
19
|
+
export { VSXExtensionUri } from './vsx-extension-uri';
|
|
@@ -11,20 +11,25 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
+
import { MaybePromise } from '@theia/core/lib/common';
|
|
17
18
|
import { RequestService } from '@theia/core/shared/@theia/request';
|
|
18
|
-
import {
|
|
19
|
+
import type { interfaces } from '@theia/core/shared/inversify';
|
|
20
|
+
import { OVSXClient, OVSXHttpClient } from '@theia/ovsx-client';
|
|
19
21
|
import { VSXEnvironment } from './vsx-environment';
|
|
20
22
|
|
|
21
|
-
export const
|
|
22
|
-
export type
|
|
23
|
+
export const OVSXUrlResolver = Symbol('OVSXUrlResolver') as symbol & interfaces.Abstract<OVSXUrlResolver>;
|
|
24
|
+
export type OVSXUrlResolver = (value: string) => MaybePromise<string>;
|
|
23
25
|
|
|
26
|
+
export const OVSXClientProvider = Symbol('OVSXClientProvider') as symbol & interfaces.Abstract<OVSXClientProvider>;
|
|
27
|
+
export type OVSXClientProvider = () => MaybePromise<OVSXClient>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated since 1.32.0
|
|
31
|
+
*/
|
|
24
32
|
export async function createOVSXClient(vsxEnvironment: VSXEnvironment, requestService: RequestService): Promise<OVSXClient> {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
vsxEnvironment.getRegistryApiUri()
|
|
28
|
-
]);
|
|
29
|
-
return new OVSXClient({ apiVersion, apiUrl: apiUrl.toString() }, requestService);
|
|
33
|
+
const apiUrl = await vsxEnvironment.getRegistryApiUri();
|
|
34
|
+
return new OVSXHttpClient(apiUrl, requestService);
|
|
30
35
|
}
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
+
import type { OVSXRouterConfig } from '@theia/ovsx-client';
|
|
18
|
+
|
|
17
19
|
export const VSX_ENVIRONMENT_PATH = '/services/vsx-environment';
|
|
18
20
|
|
|
19
21
|
export const VSXEnvironment = Symbol('VSXEnvironment');
|
|
@@ -21,4 +23,5 @@ export interface VSXEnvironment {
|
|
|
21
23
|
getRegistryUri(): Promise<string>;
|
|
22
24
|
getRegistryApiUri(): Promise<string>;
|
|
23
25
|
getVscodeApiVersion(): Promise<string>;
|
|
26
|
+
getOvsxRouterConfig?(): Promise<OVSXRouterConfig | undefined>;
|
|
24
27
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// with the GNU Classpath Exception which is available at
|
|
12
12
|
// https://www.gnu.org/software/classpath/license.html.
|
|
13
13
|
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { VSCodeExtensionUri as VSXExtensionUri } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-uri';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
|
+
import { OVSXClientProvider, OVSXUrlResolver } from '../common';
|
|
19
|
+
import { RequestService } from '@theia/core/shared/@theia/request';
|
|
20
|
+
import { ExtensionIdMatchesFilterFactory, OVSXApiFilter, OVSXApiFilterImpl, OVSXClient, OVSXHttpClient, OVSXRouterClient, RequestContainsFilterFactory } from '@theia/ovsx-client';
|
|
21
|
+
import { VSXEnvironment } from './vsx-environment';
|
|
22
|
+
|
|
23
|
+
export default new ContainerModule(bind => {
|
|
24
|
+
bind(OVSXUrlResolver)
|
|
25
|
+
.toFunction(url => url);
|
|
26
|
+
bind(OVSXClientProvider)
|
|
27
|
+
.toDynamicValue(ctx => {
|
|
28
|
+
const vsxEnvironment = ctx.container.get<VSXEnvironment>(VSXEnvironment);
|
|
29
|
+
const requestService = ctx.container.get<RequestService>(RequestService);
|
|
30
|
+
const urlResolver = ctx.container.get(OVSXUrlResolver);
|
|
31
|
+
const clientPromise = Promise
|
|
32
|
+
.all([
|
|
33
|
+
vsxEnvironment.getRegistryApiUri(),
|
|
34
|
+
vsxEnvironment.getOvsxRouterConfig?.(),
|
|
35
|
+
])
|
|
36
|
+
.then<OVSXClient>(async ([apiUrl, ovsxRouterConfig]) => {
|
|
37
|
+
if (ovsxRouterConfig) {
|
|
38
|
+
const clientFactory = OVSXHttpClient.createClientFactory(requestService);
|
|
39
|
+
return OVSXRouterClient.FromConfig(
|
|
40
|
+
ovsxRouterConfig,
|
|
41
|
+
async url => clientFactory(await urlResolver(url)),
|
|
42
|
+
[RequestContainsFilterFactory, ExtensionIdMatchesFilterFactory]
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return new OVSXHttpClient(
|
|
46
|
+
await urlResolver(apiUrl),
|
|
47
|
+
requestService
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
// reuse the promise for subsequent calls to this provider
|
|
51
|
+
return () => clientPromise;
|
|
52
|
+
})
|
|
53
|
+
.inSingletonScope();
|
|
54
|
+
bind(OVSXApiFilter)
|
|
55
|
+
.toDynamicValue(ctx => {
|
|
56
|
+
const vsxEnvironment = ctx.container.get<VSXEnvironment>(VSXEnvironment);
|
|
57
|
+
const apiFilter = new OVSXApiFilterImpl('-- temporary invalid version value --');
|
|
58
|
+
vsxEnvironment.getVscodeApiVersion()
|
|
59
|
+
.then(apiVersion => apiFilter.supportedApiVersion = apiVersion);
|
|
60
|
+
return apiFilter;
|
|
61
|
+
})
|
|
62
|
+
.inSingletonScope();
|
|
63
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { CliContribution } from '@theia/core/lib/node';
|
|
18
|
+
import { injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { Argv } from '@theia/core/shared/yargs';
|
|
20
|
+
import { OVSXRouterConfig } from '@theia/ovsx-client';
|
|
21
|
+
import * as fs from 'fs';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class VsxCli implements CliContribution {
|
|
25
|
+
|
|
26
|
+
ovsxRouterConfig: OVSXRouterConfig | undefined;
|
|
27
|
+
|
|
28
|
+
configure(conf: Argv<{}>): void {
|
|
29
|
+
conf.option('ovsx-router-config', { description: 'JSON configuration file for the OVSX router client', type: 'string' });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async setArguments(args: Record<string, unknown>): Promise<void> {
|
|
33
|
+
const { 'ovsx-router-config': ovsxRouterConfig } = args;
|
|
34
|
+
if (typeof ovsxRouterConfig === 'string') {
|
|
35
|
+
this.ovsxRouterConfig = JSON.parse(await fs.promises.readFile(ovsxRouterConfig, 'utf8'));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|