@theia/vsx-registry 1.18.0 → 1.19.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/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.d.ts.map +1 -1
- package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js +3 -2
- 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 +16 -11
- package/lib/browser/vsx-extension-commands.js.map +1 -1
- package/lib/browser/vsx-extension.d.ts +4 -1
- package/lib/browser/vsx-extension.d.ts.map +1 -1
- package/lib/browser/vsx-extension.js +34 -6
- package/lib/browser/vsx-extension.js.map +1 -1
- package/lib/browser/vsx-extensions-model.d.ts +2 -2
- package/lib/browser/vsx-extensions-model.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-model.js +16 -14
- package/lib/browser/vsx-extensions-model.js.map +1 -1
- package/lib/browser/vsx-extensions-view-container.d.ts +1 -0
- package/lib/browser/vsx-extensions-view-container.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-view-container.js +4 -2
- package/lib/browser/vsx-extensions-view-container.js.map +1 -1
- package/lib/browser/vsx-extensions-widget.d.ts.map +1 -1
- package/lib/browser/vsx-extensions-widget.js +5 -4
- package/lib/browser/vsx-extensions-widget.js.map +1 -1
- package/lib/browser/vsx-registry-frontend-module.d.ts.map +1 -1
- package/lib/browser/vsx-registry-frontend-module.js +6 -12
- package/lib/browser/vsx-registry-frontend-module.js.map +1 -1
- package/lib/common/ovsx-client-provider.d.ts +21 -0
- package/lib/common/ovsx-client-provider.d.ts.map +1 -0
- package/lib/{browser/ovsx-async-client.js → common/ovsx-client-provider.js} +11 -16
- package/lib/common/ovsx-client-provider.js.map +1 -0
- package/lib/common/vsx-environment.d.ts +6 -9
- package/lib/common/vsx-environment.d.ts.map +1 -1
- package/lib/common/vsx-environment.js +4 -43
- package/lib/common/vsx-environment.js.map +1 -1
- package/lib/node/vsx-environment-impl.d.ts +26 -0
- package/lib/node/vsx-environment-impl.d.ts.map +1 -0
- package/lib/node/vsx-environment-impl.js +54 -0
- package/lib/node/vsx-environment-impl.js.map +1 -0
- package/lib/node/vsx-extension-resolver.d.ts +2 -2
- package/lib/node/vsx-extension-resolver.d.ts.map +1 -1
- package/lib/node/vsx-extension-resolver.js +6 -5
- 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 -9
- package/lib/node/vsx-registry-backend-module.js.map +1 -1
- package/package.json +12 -12
- package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +3 -2
- package/src/browser/vsx-extension-commands.ts +15 -11
- package/src/browser/vsx-extension.tsx +42 -6
- package/src/browser/vsx-extensions-model.ts +15 -13
- package/src/browser/vsx-extensions-view-container.ts +5 -2
- package/src/browser/vsx-extensions-widget.ts +5 -4
- package/src/browser/vsx-registry-frontend-module.ts +11 -13
- package/{lib/browser/ovsx-async-client.d.ts → src/common/ovsx-client-provider.ts} +13 -14
- package/src/{browser/ovsx-async-client.ts → common/vsx-environment.ts} +6 -21
- package/src/node/vsx-environment-impl.ts +41 -0
- package/src/node/vsx-extension-resolver.ts +5 -4
- package/src/node/vsx-registry-backend-module.ts +12 -10
- package/lib/browser/ovsx-async-client.d.ts.map +0 -1
- package/lib/browser/ovsx-async-client.js.map +0 -1
- package/src/common/vsx-environment.tsx +0 -51
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
+
import * as markdownit from 'markdown-it';
|
|
17
18
|
import * as React from '@theia/core/shared/react';
|
|
18
19
|
import * as DOMPurify from '@theia/core/shared/dompurify';
|
|
19
20
|
import { injectable, inject } from '@theia/core/shared/inversify';
|
|
@@ -28,7 +29,7 @@ import { Endpoint } from '@theia/core/lib/browser/endpoint';
|
|
|
28
29
|
import { VSXEnvironment } from '../common/vsx-environment';
|
|
29
30
|
import { VSXExtensionsSearchModel } from './vsx-extensions-search-model';
|
|
30
31
|
import { MenuPath } from '@theia/core/lib/common';
|
|
31
|
-
import { codicon, ContextMenuRenderer } from '@theia/core/lib/browser';
|
|
32
|
+
import { codicon, ContextMenuRenderer, TooltipService } from '@theia/core/lib/browser';
|
|
32
33
|
import { VSXExtensionNamespaceAccess, VSXUser } from '@theia/ovsx-client/lib/ovsx-types';
|
|
33
34
|
|
|
34
35
|
export const EXTENSIONS_CONTEXT_MENU: MenuPath = ['extensions_context_menu'];
|
|
@@ -112,6 +113,9 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
|
|
|
112
113
|
@inject(VSXExtensionsSearchModel)
|
|
113
114
|
readonly search: VSXExtensionsSearchModel;
|
|
114
115
|
|
|
116
|
+
@inject(TooltipService)
|
|
117
|
+
readonly tooltipService: TooltipService;
|
|
118
|
+
|
|
115
119
|
protected readonly data: Partial<VSXExtensionData> = {};
|
|
116
120
|
|
|
117
121
|
get uri(): URI {
|
|
@@ -183,7 +187,14 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
|
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
get version(): string | undefined {
|
|
186
|
-
|
|
190
|
+
let version = this.getData('version');
|
|
191
|
+
|
|
192
|
+
// Ensure version begins with a 'v'
|
|
193
|
+
if (version && !version.startsWith('v')) {
|
|
194
|
+
version = `v${version}`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return version;
|
|
187
198
|
}
|
|
188
199
|
|
|
189
200
|
get averageRating(): number | undefined {
|
|
@@ -244,6 +255,28 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
|
|
|
244
255
|
return this.getData('publishedBy');
|
|
245
256
|
}
|
|
246
257
|
|
|
258
|
+
get tooltipId(): string {
|
|
259
|
+
return this.tooltipService.tooltipId;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
get tooltip(): string {
|
|
263
|
+
let md = `__${this.displayName}__ ${this.version}\n\n${this.description}\n_____\n\nPublisher: ${this.publisher}`;
|
|
264
|
+
|
|
265
|
+
if (this.license) {
|
|
266
|
+
md += ` \rLicense: ${this.license}`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (this.downloadCount) {
|
|
270
|
+
md += ` \rDownload count: ${downloadCompactFormatter.format(this.downloadCount)}`;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (this.averageRating) {
|
|
274
|
+
md += ` \rAverage Rating: ${this.averageRating.toFixed(1)}`;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return markdownit().render(md);
|
|
278
|
+
}
|
|
279
|
+
|
|
247
280
|
protected _busy = 0;
|
|
248
281
|
get busy(): boolean {
|
|
249
282
|
return !!this._busy;
|
|
@@ -289,7 +322,7 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
|
|
|
289
322
|
* @returns the registry link for the given extension at the path.
|
|
290
323
|
*/
|
|
291
324
|
async getRegistryLink(path = ''): Promise<URI> {
|
|
292
|
-
const uri = await this.environment.getRegistryUri();
|
|
325
|
+
const uri = new URI(await this.environment.getRegistryUri());
|
|
293
326
|
return uri.resolve('extension/' + this.id.replace('.', '/')).resolve(path);
|
|
294
327
|
}
|
|
295
328
|
|
|
@@ -316,7 +349,9 @@ export class VSXExtension implements VSXExtensionData, TreeElement {
|
|
|
316
349
|
}
|
|
317
350
|
|
|
318
351
|
render(): React.ReactNode {
|
|
319
|
-
|
|
352
|
+
const node = <VSXExtensionComponent extension={this} />;
|
|
353
|
+
this.tooltipService.update();
|
|
354
|
+
return node;
|
|
320
355
|
}
|
|
321
356
|
}
|
|
322
357
|
|
|
@@ -379,8 +414,9 @@ const downloadCompactFormatter = new Intl.NumberFormat(undefined, { notation: 'c
|
|
|
379
414
|
|
|
380
415
|
export class VSXExtensionComponent extends AbstractVSXExtensionComponent {
|
|
381
416
|
render(): React.ReactNode {
|
|
382
|
-
const { iconUrl, publisher, displayName, description, version, downloadCount, averageRating } = this.props.extension;
|
|
383
|
-
|
|
417
|
+
const { iconUrl, publisher, displayName, description, version, downloadCount, averageRating, tooltipId, tooltip } = this.props.extension;
|
|
418
|
+
|
|
419
|
+
return <div className='theia-vsx-extension' data-for={tooltipId} data-tip={tooltip}>
|
|
384
420
|
{iconUrl ?
|
|
385
421
|
<img className='theia-vsx-extension-icon' src={iconUrl} /> :
|
|
386
422
|
<div className='theia-vsx-extension-icon placeholder' />}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
18
18
|
import debounce from 'p-debounce';
|
|
19
19
|
import * as showdown from 'showdown';
|
|
20
|
-
import * as
|
|
20
|
+
import * as DOMPurify from '@theia/core/shared/dompurify';
|
|
21
21
|
import { Emitter } 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';
|
|
@@ -30,7 +30,7 @@ import { WorkspaceService } from '@theia/workspace/lib/browser';
|
|
|
30
30
|
import { RecommendedExtensions } from './recommended-extensions/recommended-extensions-preference-contribution';
|
|
31
31
|
import URI from '@theia/core/lib/common/uri';
|
|
32
32
|
import { VSXResponseError, VSXSearchParam } from '@theia/ovsx-client/lib/ovsx-types';
|
|
33
|
-
import {
|
|
33
|
+
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
34
34
|
|
|
35
35
|
@injectable()
|
|
36
36
|
export class VSXExtensionsModel {
|
|
@@ -38,8 +38,8 @@ export class VSXExtensionsModel {
|
|
|
38
38
|
protected readonly onDidChangeEmitter = new Emitter<void>();
|
|
39
39
|
readonly onDidChange = this.onDidChangeEmitter.event;
|
|
40
40
|
|
|
41
|
-
@inject(
|
|
42
|
-
protected
|
|
41
|
+
@inject(OVSXClientProvider)
|
|
42
|
+
protected clientProvider: OVSXClientProvider;
|
|
43
43
|
|
|
44
44
|
@inject(HostedPluginSupport)
|
|
45
45
|
protected readonly pluginSupport: HostedPluginSupport;
|
|
@@ -63,7 +63,6 @@ export class VSXExtensionsModel {
|
|
|
63
63
|
|
|
64
64
|
@postConstruct()
|
|
65
65
|
protected async init(): Promise<void> {
|
|
66
|
-
await this.client.ready;
|
|
67
66
|
await Promise.all([
|
|
68
67
|
this.initInstalled(),
|
|
69
68
|
this.initSearchResult(),
|
|
@@ -167,14 +166,15 @@ export class VSXExtensionsModel {
|
|
|
167
166
|
}, 150);
|
|
168
167
|
protected doUpdateSearchResult(param: VSXSearchParam, token: CancellationToken): Promise<void> {
|
|
169
168
|
return this.doChange(async () => {
|
|
170
|
-
const
|
|
169
|
+
const client = await this.clientProvider();
|
|
170
|
+
const result = await client.search(param);
|
|
171
171
|
if (token.isCancellationRequested) {
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
174
174
|
const searchResult = new Set<string>();
|
|
175
175
|
for (const data of result.extensions) {
|
|
176
176
|
const id = data.namespace.toLowerCase() + '.' + data.name.toLowerCase();
|
|
177
|
-
const extension =
|
|
177
|
+
const extension = client.getLatestCompatibleVersion(data);
|
|
178
178
|
if (!extension) {
|
|
179
179
|
continue;
|
|
180
180
|
}
|
|
@@ -260,7 +260,8 @@ export class VSXExtensionsModel {
|
|
|
260
260
|
}
|
|
261
261
|
if (extension.readmeUrl) {
|
|
262
262
|
try {
|
|
263
|
-
const
|
|
263
|
+
const client = await this.clientProvider();
|
|
264
|
+
const rawReadme = await client.fetchText(extension.readmeUrl);
|
|
264
265
|
const readme = this.compileReadme(rawReadme);
|
|
265
266
|
extension.update({ readme });
|
|
266
267
|
} catch (e) {
|
|
@@ -275,15 +276,15 @@ export class VSXExtensionsModel {
|
|
|
275
276
|
|
|
276
277
|
protected compileReadme(readmeMarkdown: string): string {
|
|
277
278
|
const markdownConverter = new showdown.Converter({
|
|
279
|
+
headerLevelStart: 2,
|
|
278
280
|
noHeaderId: true,
|
|
279
281
|
strikethrough: true,
|
|
280
|
-
|
|
282
|
+
tables: true,
|
|
283
|
+
underline: true
|
|
281
284
|
});
|
|
282
285
|
|
|
283
286
|
const readmeHtml = markdownConverter.makeHtml(readmeMarkdown);
|
|
284
|
-
return sanitize(readmeHtml
|
|
285
|
-
allowedTags: sanitize.defaults.allowedTags.concat(['h1', 'h2', 'img'])
|
|
286
|
-
});
|
|
287
|
+
return DOMPurify.sanitize(readmeHtml);
|
|
287
288
|
}
|
|
288
289
|
|
|
289
290
|
protected async refresh(id: string): Promise<VSXExtension | undefined> {
|
|
@@ -292,7 +293,8 @@ export class VSXExtensionsModel {
|
|
|
292
293
|
if (!this.shouldRefresh(extension)) {
|
|
293
294
|
return extension;
|
|
294
295
|
}
|
|
295
|
-
const
|
|
296
|
+
const client = await this.clientProvider();
|
|
297
|
+
const data = await client.getLatestCompatibleExtensionVersion(id);
|
|
296
298
|
if (!data) {
|
|
297
299
|
return;
|
|
298
300
|
}
|
|
@@ -22,12 +22,15 @@ import { VSXSearchMode } from './vsx-extensions-search-model';
|
|
|
22
22
|
import { generateExtensionWidgetId } from './vsx-extensions-widget';
|
|
23
23
|
import { VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
24
24
|
import { VSXExtensionsCommands } from './vsx-extension-commands';
|
|
25
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
25
26
|
|
|
26
27
|
@injectable()
|
|
27
28
|
export class VSXExtensionsViewContainer extends ViewContainer {
|
|
28
29
|
|
|
29
30
|
static ID = 'vsx-extensions-view-container';
|
|
30
|
-
static LABEL = 'Extensions';
|
|
31
|
+
static LABEL = nls.localize('vscode/settingsLayout/extensions', 'Extensions');
|
|
32
|
+
|
|
33
|
+
disableDNDBetweenContainers = true;
|
|
31
34
|
|
|
32
35
|
@inject(VSXExtensionsSearchBar)
|
|
33
36
|
protected readonly searchBar: VSXExtensionsSearchBar;
|
|
@@ -163,7 +166,7 @@ export class VSXExtensionsViewContainer extends ViewContainer {
|
|
|
163
166
|
}
|
|
164
167
|
|
|
165
168
|
protected getToggleVisibilityGroupLabel(): string {
|
|
166
|
-
return 'a/Views';
|
|
169
|
+
return 'a/' + nls.localize('vscode/viewPaneContainer/views', 'Views');
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
export namespace VSXExtensionsViewContainer {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { injectable, interfaces, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
18
18
|
import { SourceTreeWidget } from '@theia/core/lib/browser/source-tree';
|
|
19
19
|
import { VSXExtensionsSource, VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
20
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
20
21
|
|
|
21
22
|
@injectable()
|
|
22
23
|
export class VSXExtensionsWidgetOptions extends VSXExtensionsSourceOptions {
|
|
@@ -66,13 +67,13 @@ export class VSXExtensionsWidget extends SourceTreeWidget {
|
|
|
66
67
|
protected computeTitle(): string {
|
|
67
68
|
switch (this.options.id) {
|
|
68
69
|
case VSXExtensionsSourceOptions.INSTALLED:
|
|
69
|
-
return 'Installed';
|
|
70
|
+
return nls.localize('vscode/extensions.contribution/installed filter', 'Installed');
|
|
70
71
|
case VSXExtensionsSourceOptions.BUILT_IN:
|
|
71
|
-
return 'Built-in';
|
|
72
|
+
return nls.localize('vscode/extensions.contribution/builtin filter', 'Built-in');
|
|
72
73
|
case VSXExtensionsSourceOptions.RECOMMENDED:
|
|
73
|
-
return 'Recommended';
|
|
74
|
+
return nls.localize('vscode/extensions.contribution/most popular recommended', 'Recommended');
|
|
74
75
|
case VSXExtensionsSourceOptions.SEARCH_RESULT:
|
|
75
|
-
return 'Open VSX Registry';
|
|
76
|
+
return nls.localize('theia/vsx-registry/openVSX', 'Open VSX Registry');
|
|
76
77
|
default:
|
|
77
78
|
return '';
|
|
78
79
|
}
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
import '../../src/browser/style/index.css';
|
|
18
18
|
|
|
19
19
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
WidgetFactory, bindViewContribution, FrontendApplicationContribution, ViewContainerIdentifier, OpenHandler, WidgetManager, WebSocketConnectionProvider
|
|
22
|
+
} from '@theia/core/lib/browser';
|
|
21
23
|
import { VSXExtensionsViewContainer } from './vsx-extensions-view-container';
|
|
22
24
|
import { VSXExtensionsContribution } from './vsx-extensions-contribution';
|
|
23
25
|
import { VSXExtensionsSearchBar } from './vsx-extensions-search-bar';
|
|
@@ -28,24 +30,20 @@ import { VSXExtensionFactory, VSXExtension, VSXExtensionOptions } from './vsx-ex
|
|
|
28
30
|
import { VSXExtensionEditor } from './vsx-extension-editor';
|
|
29
31
|
import { VSXExtensionEditorManager } from './vsx-extension-editor-manager';
|
|
30
32
|
import { VSXExtensionsSourceOptions } from './vsx-extensions-source';
|
|
31
|
-
import { VSXEnvironment } from '../common/vsx-environment';
|
|
32
33
|
import { VSXExtensionsSearchModel } from './vsx-extensions-search-model';
|
|
33
34
|
import { bindExtensionPreferences } from './recommended-extensions/recommended-extensions-preference-contribution';
|
|
34
35
|
import { bindPreferenceProviderOverrides } from './recommended-extensions/preference-provider-overrides';
|
|
35
|
-
import {
|
|
36
|
+
import { OVSXClientProvider, createOVSXClient } from '../common/ovsx-client-provider';
|
|
37
|
+
import { VSXEnvironment, VSX_ENVIRONMENT_PATH } from '../common/vsx-environment';
|
|
36
38
|
|
|
37
39
|
export default new ContainerModule((bind, unbind) => {
|
|
38
|
-
bind(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return new OVSXAsyncClient(Promise.all([
|
|
42
|
-
vsxEnvironment.getVscodeApiVersion(),
|
|
43
|
-
vsxEnvironment.getRegistryApiUri()
|
|
44
|
-
]).then(([apiVersion, apiUri]) => ({
|
|
45
|
-
apiVersion,
|
|
46
|
-
apiUrl: apiUri.toString()
|
|
47
|
-
})));
|
|
40
|
+
bind<OVSXClientProvider>(OVSXClientProvider).toDynamicValue(ctx => {
|
|
41
|
+
const clientPromise = createOVSXClient(ctx.container.get(VSXEnvironment));
|
|
42
|
+
return () => clientPromise;
|
|
48
43
|
}).inSingletonScope();
|
|
44
|
+
bind(VSXEnvironment).toDynamicValue(
|
|
45
|
+
ctx => WebSocketConnectionProvider.createProxy(ctx.container, VSX_ENVIRONMENT_PATH)
|
|
46
|
+
).inSingletonScope();
|
|
49
47
|
|
|
50
48
|
bind(VSXExtension).toSelf();
|
|
51
49
|
bind(VSXExtensionFactory).toFactory(ctx => (option: VSXExtensionOptions) => {
|
|
@@ -13,18 +13,17 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
|
|
17
|
+
import { OVSXClient } from '@theia/ovsx-client';
|
|
18
|
+
import { VSXEnvironment } from './vsx-environment';
|
|
19
|
+
|
|
20
|
+
export const OVSXClientProvider = Symbol('OVSXClientProvider');
|
|
21
|
+
export type OVSXClientProvider = () => Promise<OVSXClient>;
|
|
22
|
+
|
|
23
|
+
export async function createOVSXClient(vsxEnvironment: VSXEnvironment): Promise<OVSXClient> {
|
|
24
|
+
const [apiVersion, apiUrl] = await Promise.all([
|
|
25
|
+
vsxEnvironment.getVscodeApiVersion(),
|
|
26
|
+
vsxEnvironment.getRegistryApiUri()
|
|
27
|
+
]);
|
|
28
|
+
return new OVSXClient({ apiVersion, apiUrl: apiUrl.toString() });
|
|
29
29
|
}
|
|
30
|
-
//# sourceMappingURL=ovsx-async-client.d.ts.map
|
|
@@ -14,26 +14,11 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
export const VSX_ENVIRONMENT_PATH = '/services/vsx-environment';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Resolves once the initial asynchronous options are resolved.
|
|
27
|
-
*
|
|
28
|
-
* Calling methods before this promise is resolved will throw errors.
|
|
29
|
-
*/
|
|
30
|
-
readonly ready: Promise<OVSXAsyncClient>;
|
|
31
|
-
|
|
32
|
-
constructor(asyncOptions: Promise<OVSXClientOptions>) {
|
|
33
|
-
super(undefined!); // hack: using methods at this point will fail.
|
|
34
|
-
this.ready = asyncOptions.then(options => {
|
|
35
|
-
(this.options as OVSXClientOptions) = options;
|
|
36
|
-
return this;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
19
|
+
export const VSXEnvironment = Symbol('VSXEnvironment');
|
|
20
|
+
export interface VSXEnvironment {
|
|
21
|
+
getRegistryUri(): Promise<string>;
|
|
22
|
+
getRegistryApiUri(): Promise<string>;
|
|
23
|
+
getVscodeApiVersion(): Promise<string>;
|
|
39
24
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
+
import URI from '@theia/core/lib/common/uri';
|
|
19
|
+
import { PluginVsCodeCliContribution } from '@theia/plugin-ext-vscode/lib/node/plugin-vscode-cli-contribution';
|
|
20
|
+
import { VSXEnvironment } from '../common/vsx-environment';
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class VSXEnvironmentImpl implements VSXEnvironment {
|
|
24
|
+
|
|
25
|
+
protected _registryUri = new URI(process.env['VSX_REGISTRY_URL']?.trim() || 'https://open-vsx.org');
|
|
26
|
+
|
|
27
|
+
@inject(PluginVsCodeCliContribution)
|
|
28
|
+
protected readonly pluginVscodeCli: PluginVsCodeCliContribution;
|
|
29
|
+
|
|
30
|
+
async getRegistryUri(): Promise<string> {
|
|
31
|
+
return this._registryUri.toString(true);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async getRegistryApiUri(): Promise<string> {
|
|
35
|
+
return this._registryUri.resolve('api').toString(true);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async getVscodeApiVersion(): Promise<string> {
|
|
39
|
+
return this.pluginVscodeCli.vsCodeApiVersionPromise;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -23,13 +23,13 @@ import { injectable, inject } from '@theia/core/shared/inversify';
|
|
|
23
23
|
import URI from '@theia/core/lib/common/uri';
|
|
24
24
|
import { PluginDeployerResolver, PluginDeployerResolverContext } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
25
25
|
import { VSXExtensionUri } from '../common/vsx-extension-uri';
|
|
26
|
-
import {
|
|
26
|
+
import { OVSXClientProvider } from '../common/ovsx-client-provider';
|
|
27
27
|
|
|
28
28
|
@injectable()
|
|
29
29
|
export class VSXExtensionResolver implements PluginDeployerResolver {
|
|
30
30
|
|
|
31
|
-
@inject(
|
|
32
|
-
protected
|
|
31
|
+
@inject(OVSXClientProvider)
|
|
32
|
+
protected clientProvider: OVSXClientProvider;
|
|
33
33
|
|
|
34
34
|
protected readonly downloadPath: string;
|
|
35
35
|
|
|
@@ -49,7 +49,8 @@ export class VSXExtensionResolver implements PluginDeployerResolver {
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
console.log(`[${id}]: trying to resolve latest version...`);
|
|
52
|
-
const
|
|
52
|
+
const client = await this.clientProvider();
|
|
53
|
+
const extension = await client.getLatestCompatibleExtensionVersion(id);
|
|
53
54
|
if (!extension) {
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
@@ -17,18 +17,20 @@
|
|
|
17
17
|
import { ContainerModule } from '@theia/core/shared/inversify';
|
|
18
18
|
import { VSXExtensionResolver } from './vsx-extension-resolver';
|
|
19
19
|
import { PluginDeployerResolver } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { OVSXClientProvider, createOVSXClient } from '../common/ovsx-client-provider';
|
|
21
|
+
import { VSXEnvironment, VSX_ENVIRONMENT_PATH } from '../common/vsx-environment';
|
|
22
|
+
import { VSXEnvironmentImpl } from './vsx-environment-impl';
|
|
23
|
+
import { ConnectionHandler, JsonRpcConnectionHandler } from '@theia/core';
|
|
22
24
|
|
|
23
25
|
export default new ContainerModule(bind => {
|
|
24
|
-
bind(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}));
|
|
26
|
+
bind<OVSXClientProvider>(OVSXClientProvider).toDynamicValue(ctx => {
|
|
27
|
+
const clientPromise = createOVSXClient(ctx.container.get(VSXEnvironment));
|
|
28
|
+
return () => clientPromise;
|
|
29
|
+
}).inSingletonScope();
|
|
30
|
+
bind(VSXEnvironment).to(VSXEnvironmentImpl).inSingletonScope();
|
|
31
|
+
bind(ConnectionHandler).toDynamicValue(
|
|
32
|
+
ctx => new JsonRpcConnectionHandler(VSX_ENVIRONMENT_PATH, () => ctx.container.get(VSXEnvironment))
|
|
33
|
+
).inSingletonScope();
|
|
28
34
|
bind(VSXExtensionResolver).toSelf().inSingletonScope();
|
|
29
35
|
bind(PluginDeployerResolver).toService(VSXExtensionResolver);
|
|
30
36
|
});
|
|
31
|
-
|
|
32
|
-
function resolveRegistryUrl(): string {
|
|
33
|
-
return process.env['VSX_REGISTRY_URL'] || VSX_REGISTRY_URL_DEFAULT;
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ovsx-async-client.d.ts","sourceRoot":"","sources":["../../src/browser/ovsx-async-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAE3C;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;gBAE7B,YAAY,EAAE,OAAO,CAAC,iBAAiB,CAAC;CAOvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ovsx-async-client.js","sourceRoot":"","sources":["../../src/browser/ovsx-async-client.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,gDAAuE;AAEvE;;;GAGG;AACH,MAAa,eAAgB,SAAQ,gBAAU;IAS3C,YAAY,YAAwC;QAChD,KAAK,CAAC,SAAU,CAAC,CAAC,CAAC,+CAA+C;QAClE,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YACpC,IAAI,CAAC,OAA6B,GAAG,OAAO,CAAC;YAC9C,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAhBD,0CAgBC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
-
import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
|
|
19
|
-
import URI from '@theia/core/lib/common/uri';
|
|
20
|
-
import { VSCODE_DEFAULT_API_VERSION } from '@theia/plugin-ext-vscode/lib/common/plugin-vscode-types';
|
|
21
|
-
|
|
22
|
-
@injectable()
|
|
23
|
-
export class VSXEnvironment {
|
|
24
|
-
|
|
25
|
-
@inject(EnvVariablesServer)
|
|
26
|
-
protected readonly environments: EnvVariablesServer;
|
|
27
|
-
|
|
28
|
-
protected _registryUri: URI | undefined;
|
|
29
|
-
async getRegistryUri(): Promise<URI> {
|
|
30
|
-
if (!this._registryUri) {
|
|
31
|
-
const vsxRegistryUrl = await this.environments.getValue('VSX_REGISTRY_URL');
|
|
32
|
-
this._registryUri = new URI(vsxRegistryUrl && vsxRegistryUrl.value || 'https://open-vsx.org');
|
|
33
|
-
}
|
|
34
|
-
return this._registryUri;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async getRegistryApiUri(): Promise<URI> {
|
|
38
|
-
const registryUri = await this.getRegistryUri();
|
|
39
|
-
return registryUri.resolve('api');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected _apiVersion: string | undefined;
|
|
43
|
-
async getVscodeApiVersion(): Promise<string> {
|
|
44
|
-
if (!this._apiVersion) {
|
|
45
|
-
const apiVersion = await this.environments.getValue('VSCODE_API_VERSION');
|
|
46
|
-
this._apiVersion = apiVersion?.value || VSCODE_DEFAULT_API_VERSION;
|
|
47
|
-
}
|
|
48
|
-
return this._apiVersion;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
}
|