@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,69 +1,69 @@
|
|
|
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 * as React from '@theia/core/shared/react';
|
|
18
|
-
import { injectable, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
19
|
-
import { ReactWidget, Message } from '@theia/core/lib/browser/widgets';
|
|
20
|
-
import { VSXExtensionsSearchModel } from './vsx-extensions-search-model';
|
|
21
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class VSXExtensionsSearchBar extends ReactWidget {
|
|
25
|
-
|
|
26
|
-
@inject(VSXExtensionsSearchModel)
|
|
27
|
-
protected readonly model: VSXExtensionsSearchModel;
|
|
28
|
-
|
|
29
|
-
@postConstruct()
|
|
30
|
-
protected init(): void {
|
|
31
|
-
this.id = 'vsx-extensions-search-bar';
|
|
32
|
-
this.addClass('theia-vsx-extensions-search-bar');
|
|
33
|
-
this.model.onDidChangeQuery((query: string) => this.updateSearchTerm(query));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
protected input: HTMLInputElement | undefined;
|
|
37
|
-
|
|
38
|
-
protected render(): React.ReactNode {
|
|
39
|
-
return <input type='text'
|
|
40
|
-
ref={input => this.input = input || undefined}
|
|
41
|
-
defaultValue={this.model.query}
|
|
42
|
-
spellCheck={false}
|
|
43
|
-
className='theia-input'
|
|
44
|
-
placeholder={nls.localize('theia/vsx-registry/searchPlaceholder', 'Search Extensions in {0}', 'Open VSX Registry')}
|
|
45
|
-
onChange={this.updateQuery}>
|
|
46
|
-
</input>;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
protected updateQuery = (e: React.ChangeEvent<HTMLInputElement>) => this.model.query = e.target.value;
|
|
50
|
-
|
|
51
|
-
protected updateSearchTerm(term: string): void {
|
|
52
|
-
if (this.input) {
|
|
53
|
-
this.input.value = term;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
protected override onActivateRequest(msg: Message): void {
|
|
58
|
-
super.onActivateRequest(msg);
|
|
59
|
-
if (this.input) {
|
|
60
|
-
this.input.focus();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
protected override onAfterAttach(msg: Message): void {
|
|
65
|
-
super.onAfterAttach(msg);
|
|
66
|
-
this.update();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
}
|
|
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 * as React from '@theia/core/shared/react';
|
|
18
|
+
import { injectable, postConstruct, inject } from '@theia/core/shared/inversify';
|
|
19
|
+
import { ReactWidget, Message } from '@theia/core/lib/browser/widgets';
|
|
20
|
+
import { VSXExtensionsSearchModel } from './vsx-extensions-search-model';
|
|
21
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class VSXExtensionsSearchBar extends ReactWidget {
|
|
25
|
+
|
|
26
|
+
@inject(VSXExtensionsSearchModel)
|
|
27
|
+
protected readonly model: VSXExtensionsSearchModel;
|
|
28
|
+
|
|
29
|
+
@postConstruct()
|
|
30
|
+
protected init(): void {
|
|
31
|
+
this.id = 'vsx-extensions-search-bar';
|
|
32
|
+
this.addClass('theia-vsx-extensions-search-bar');
|
|
33
|
+
this.model.onDidChangeQuery((query: string) => this.updateSearchTerm(query));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected input: HTMLInputElement | undefined;
|
|
37
|
+
|
|
38
|
+
protected render(): React.ReactNode {
|
|
39
|
+
return <input type='text'
|
|
40
|
+
ref={input => this.input = input || undefined}
|
|
41
|
+
defaultValue={this.model.query}
|
|
42
|
+
spellCheck={false}
|
|
43
|
+
className='theia-input'
|
|
44
|
+
placeholder={nls.localize('theia/vsx-registry/searchPlaceholder', 'Search Extensions in {0}', 'Open VSX Registry')}
|
|
45
|
+
onChange={this.updateQuery}>
|
|
46
|
+
</input>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
protected updateQuery = (e: React.ChangeEvent<HTMLInputElement>) => this.model.query = e.target.value;
|
|
50
|
+
|
|
51
|
+
protected updateSearchTerm(term: string): void {
|
|
52
|
+
if (this.input) {
|
|
53
|
+
this.input.value = term;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
protected override onActivateRequest(msg: Message): void {
|
|
58
|
+
super.onActivateRequest(msg);
|
|
59
|
+
if (this.input) {
|
|
60
|
+
this.input.focus();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
protected override onAfterAttach(msg: Message): void {
|
|
65
|
+
super.onAfterAttach(msg);
|
|
66
|
+
this.update();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
@@ -1,61 +1,61 @@
|
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
-
import { Emitter } from '@theia/core/lib/common/event';
|
|
19
|
-
|
|
20
|
-
export enum VSXSearchMode {
|
|
21
|
-
Initial,
|
|
22
|
-
None,
|
|
23
|
-
Search,
|
|
24
|
-
Installed,
|
|
25
|
-
Builtin,
|
|
26
|
-
Recommended,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const BUILTIN_QUERY = '@builtin';
|
|
30
|
-
export const INSTALLED_QUERY = '@installed';
|
|
31
|
-
export const RECOMMENDED_QUERY = '@recommended';
|
|
32
|
-
|
|
33
|
-
@injectable()
|
|
34
|
-
export class VSXExtensionsSearchModel {
|
|
35
|
-
|
|
36
|
-
protected readonly onDidChangeQueryEmitter = new Emitter<string>();
|
|
37
|
-
readonly onDidChangeQuery = this.onDidChangeQueryEmitter.event;
|
|
38
|
-
protected readonly specialQueries = new Map<string, VSXSearchMode>([
|
|
39
|
-
[BUILTIN_QUERY, VSXSearchMode.Builtin],
|
|
40
|
-
[INSTALLED_QUERY, VSXSearchMode.Installed],
|
|
41
|
-
[RECOMMENDED_QUERY, VSXSearchMode.Recommended],
|
|
42
|
-
]);
|
|
43
|
-
|
|
44
|
-
protected _query = '';
|
|
45
|
-
set query(query: string) {
|
|
46
|
-
if (this._query === query) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
this._query = query;
|
|
50
|
-
this.onDidChangeQueryEmitter.fire(this._query);
|
|
51
|
-
}
|
|
52
|
-
get query(): string {
|
|
53
|
-
return this._query;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
getModeForQuery(): VSXSearchMode {
|
|
57
|
-
return this.query
|
|
58
|
-
? this.specialQueries.get(this.query) ?? VSXSearchMode.Search
|
|
59
|
-
: VSXSearchMode.None;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
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 } from '@theia/core/shared/inversify';
|
|
18
|
+
import { Emitter } from '@theia/core/lib/common/event';
|
|
19
|
+
|
|
20
|
+
export enum VSXSearchMode {
|
|
21
|
+
Initial,
|
|
22
|
+
None,
|
|
23
|
+
Search,
|
|
24
|
+
Installed,
|
|
25
|
+
Builtin,
|
|
26
|
+
Recommended,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const BUILTIN_QUERY = '@builtin';
|
|
30
|
+
export const INSTALLED_QUERY = '@installed';
|
|
31
|
+
export const RECOMMENDED_QUERY = '@recommended';
|
|
32
|
+
|
|
33
|
+
@injectable()
|
|
34
|
+
export class VSXExtensionsSearchModel {
|
|
35
|
+
|
|
36
|
+
protected readonly onDidChangeQueryEmitter = new Emitter<string>();
|
|
37
|
+
readonly onDidChangeQuery = this.onDidChangeQueryEmitter.event;
|
|
38
|
+
protected readonly specialQueries = new Map<string, VSXSearchMode>([
|
|
39
|
+
[BUILTIN_QUERY, VSXSearchMode.Builtin],
|
|
40
|
+
[INSTALLED_QUERY, VSXSearchMode.Installed],
|
|
41
|
+
[RECOMMENDED_QUERY, VSXSearchMode.Recommended],
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
protected _query = '';
|
|
45
|
+
set query(query: string) {
|
|
46
|
+
if (this._query === query) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this._query = query;
|
|
50
|
+
this.onDidChangeQueryEmitter.fire(this._query);
|
|
51
|
+
}
|
|
52
|
+
get query(): string {
|
|
53
|
+
return this._query;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getModeForQuery(): VSXSearchMode {
|
|
57
|
+
return this.query
|
|
58
|
+
? this.specialQueries.get(this.query) ?? VSXSearchMode.Search
|
|
59
|
+
: VSXSearchMode.None;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,83 +1,83 @@
|
|
|
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 { TreeSource, TreeElement } from '@theia/core/lib/browser/source-tree';
|
|
19
|
-
import { VSXExtensionsModel } from './vsx-extensions-model';
|
|
20
|
-
import debounce = require('@theia/core/shared/lodash.debounce');
|
|
21
|
-
|
|
22
|
-
@injectable()
|
|
23
|
-
export class VSXExtensionsSourceOptions {
|
|
24
|
-
static INSTALLED = 'installed';
|
|
25
|
-
static BUILT_IN = 'builtin';
|
|
26
|
-
static SEARCH_RESULT = 'searchResult';
|
|
27
|
-
static RECOMMENDED = 'recommended';
|
|
28
|
-
readonly id: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@injectable()
|
|
32
|
-
export class VSXExtensionsSource extends TreeSource {
|
|
33
|
-
|
|
34
|
-
@inject(VSXExtensionsSourceOptions)
|
|
35
|
-
protected readonly options: VSXExtensionsSourceOptions;
|
|
36
|
-
|
|
37
|
-
@inject(VSXExtensionsModel)
|
|
38
|
-
protected readonly model: VSXExtensionsModel;
|
|
39
|
-
|
|
40
|
-
@postConstruct()
|
|
41
|
-
protected async init(): Promise<void> {
|
|
42
|
-
this.fireDidChange();
|
|
43
|
-
this.toDispose.push(this.model.onDidChange(() => this.scheduleFireDidChange()));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
protected scheduleFireDidChange = debounce(() => this.fireDidChange(), 100, { leading: false, trailing: true });
|
|
47
|
-
|
|
48
|
-
getModel(): VSXExtensionsModel {
|
|
49
|
-
return this.model;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
*getElements(): IterableIterator<TreeElement> {
|
|
53
|
-
for (const id of this.doGetElements()) {
|
|
54
|
-
const extension = this.model.getExtension(id);
|
|
55
|
-
if (!extension) {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (this.options.id === VSXExtensionsSourceOptions.RECOMMENDED) {
|
|
59
|
-
if (this.model.isInstalled(id)) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (this.options.id === VSXExtensionsSourceOptions.BUILT_IN) {
|
|
64
|
-
if (extension.builtin) {
|
|
65
|
-
yield extension;
|
|
66
|
-
}
|
|
67
|
-
} else if (!extension.builtin) {
|
|
68
|
-
yield extension;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
protected doGetElements(): IterableIterator<string> {
|
|
74
|
-
if (this.options.id === VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
75
|
-
return this.model.searchResult;
|
|
76
|
-
}
|
|
77
|
-
if (this.options.id === VSXExtensionsSourceOptions.RECOMMENDED) {
|
|
78
|
-
return this.model.recommended;
|
|
79
|
-
}
|
|
80
|
-
return this.model.installed;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
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 { TreeSource, TreeElement } from '@theia/core/lib/browser/source-tree';
|
|
19
|
+
import { VSXExtensionsModel } from './vsx-extensions-model';
|
|
20
|
+
import debounce = require('@theia/core/shared/lodash.debounce');
|
|
21
|
+
|
|
22
|
+
@injectable()
|
|
23
|
+
export class VSXExtensionsSourceOptions {
|
|
24
|
+
static INSTALLED = 'installed';
|
|
25
|
+
static BUILT_IN = 'builtin';
|
|
26
|
+
static SEARCH_RESULT = 'searchResult';
|
|
27
|
+
static RECOMMENDED = 'recommended';
|
|
28
|
+
readonly id: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@injectable()
|
|
32
|
+
export class VSXExtensionsSource extends TreeSource {
|
|
33
|
+
|
|
34
|
+
@inject(VSXExtensionsSourceOptions)
|
|
35
|
+
protected readonly options: VSXExtensionsSourceOptions;
|
|
36
|
+
|
|
37
|
+
@inject(VSXExtensionsModel)
|
|
38
|
+
protected readonly model: VSXExtensionsModel;
|
|
39
|
+
|
|
40
|
+
@postConstruct()
|
|
41
|
+
protected async init(): Promise<void> {
|
|
42
|
+
this.fireDidChange();
|
|
43
|
+
this.toDispose.push(this.model.onDidChange(() => this.scheduleFireDidChange()));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
protected scheduleFireDidChange = debounce(() => this.fireDidChange(), 100, { leading: false, trailing: true });
|
|
47
|
+
|
|
48
|
+
getModel(): VSXExtensionsModel {
|
|
49
|
+
return this.model;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
*getElements(): IterableIterator<TreeElement> {
|
|
53
|
+
for (const id of this.doGetElements()) {
|
|
54
|
+
const extension = this.model.getExtension(id);
|
|
55
|
+
if (!extension) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (this.options.id === VSXExtensionsSourceOptions.RECOMMENDED) {
|
|
59
|
+
if (this.model.isInstalled(id)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (this.options.id === VSXExtensionsSourceOptions.BUILT_IN) {
|
|
64
|
+
if (extension.builtin) {
|
|
65
|
+
yield extension;
|
|
66
|
+
}
|
|
67
|
+
} else if (!extension.builtin) {
|
|
68
|
+
yield extension;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected doGetElements(): IterableIterator<string> {
|
|
74
|
+
if (this.options.id === VSXExtensionsSourceOptions.SEARCH_RESULT) {
|
|
75
|
+
return this.model.searchResult;
|
|
76
|
+
}
|
|
77
|
+
if (this.options.id === VSXExtensionsSourceOptions.RECOMMENDED) {
|
|
78
|
+
return this.model.recommended;
|
|
79
|
+
}
|
|
80
|
+
return this.model.installed;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|