@theia/vsx-registry 1.45.0 → 1.46.0-next.72

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.
Files changed (100) hide show
  1. package/README.md +45 -45
  2. package/lib/browser/recommended-extensions/preference-provider-overrides.d.ts +17 -17
  3. package/lib/browser/recommended-extensions/preference-provider-overrides.js +95 -95
  4. package/lib/browser/recommended-extensions/recommended-extensions-json-schema.d.ts +14 -14
  5. package/lib/browser/recommended-extensions/recommended-extensions-json-schema.js +94 -94
  6. package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.d.ts +11 -11
  7. package/lib/browser/recommended-extensions/recommended-extensions-preference-contribution.js +59 -59
  8. package/lib/browser/vsx-extension-commands.d.ts +14 -13
  9. package/lib/browser/vsx-extension-commands.d.ts.map +1 -1
  10. package/lib/browser/vsx-extension-commands.js +68 -63
  11. package/lib/browser/vsx-extension-commands.js.map +1 -1
  12. package/lib/browser/vsx-extension-editor-manager.d.ts +9 -9
  13. package/lib/browser/vsx-extension-editor-manager.js +49 -49
  14. package/lib/browser/vsx-extension-editor.d.ts +21 -21
  15. package/lib/browser/vsx-extension-editor.js +109 -109
  16. package/lib/browser/vsx-extension.d.ts +146 -143
  17. package/lib/browser/vsx-extension.d.ts.map +1 -1
  18. package/lib/browser/vsx-extension.js +616 -596
  19. package/lib/browser/vsx-extension.js.map +1 -1
  20. package/lib/browser/vsx-extensions-contribution.d.ts +70 -60
  21. package/lib/browser/vsx-extensions-contribution.d.ts.map +1 -1
  22. package/lib/browser/vsx-extensions-contribution.js +375 -344
  23. package/lib/browser/vsx-extensions-contribution.js.map +1 -1
  24. package/lib/browser/vsx-extensions-model.d.ts +75 -72
  25. package/lib/browser/vsx-extensions-model.d.ts.map +1 -1
  26. package/lib/browser/vsx-extensions-model.js +437 -391
  27. package/lib/browser/vsx-extensions-model.js.map +1 -1
  28. package/lib/browser/vsx-extensions-preferences.d.ts +12 -0
  29. package/lib/browser/vsx-extensions-preferences.d.ts.map +1 -0
  30. package/lib/browser/vsx-extensions-preferences.js +47 -0
  31. package/lib/browser/vsx-extensions-preferences.js.map +1 -0
  32. package/lib/browser/vsx-extensions-search-bar.d.ts +22 -14
  33. package/lib/browser/vsx-extensions-search-bar.d.ts.map +1 -1
  34. package/lib/browser/vsx-extensions-search-bar.js +106 -75
  35. package/lib/browser/vsx-extensions-search-bar.js.map +1 -1
  36. package/lib/browser/vsx-extensions-search-model.d.ts +21 -21
  37. package/lib/browser/vsx-extensions-search-model.js +70 -70
  38. package/lib/browser/vsx-extensions-source.d.ts +19 -19
  39. package/lib/browser/vsx-extensions-source.js +102 -102
  40. package/lib/browser/vsx-extensions-view-container.d.ts +49 -49
  41. package/lib/browser/vsx-extensions-view-container.js +179 -179
  42. package/lib/browser/vsx-extensions-widget.d.ts +35 -34
  43. package/lib/browser/vsx-extensions-widget.d.ts.map +1 -1
  44. package/lib/browser/vsx-extensions-widget.js +164 -156
  45. package/lib/browser/vsx-extensions-widget.js.map +1 -1
  46. package/lib/browser/vsx-language-quick-pick-service.d.ts +15 -15
  47. package/lib/browser/vsx-language-quick-pick-service.js +121 -121
  48. package/lib/browser/vsx-registry-frontend-module.d.ts +4 -4
  49. package/lib/browser/vsx-registry-frontend-module.d.ts.map +1 -1
  50. package/lib/browser/vsx-registry-frontend-module.js +99 -97
  51. package/lib/browser/vsx-registry-frontend-module.js.map +1 -1
  52. package/lib/common/index.d.ts +3 -3
  53. package/lib/common/index.js +25 -25
  54. package/lib/common/ovsx-client-provider.d.ts +13 -13
  55. package/lib/common/ovsx-client-provider.js +29 -29
  56. package/lib/common/vsx-environment.d.ts +9 -9
  57. package/lib/common/vsx-environment.js +20 -20
  58. package/lib/common/vsx-extension-uri.d.ts +3 -3
  59. package/lib/common/vsx-extension-uri.js +20 -20
  60. package/lib/common/vsx-registry-common-module.d.ts +3 -3
  61. package/lib/common/vsx-registry-common-module.js +57 -57
  62. package/lib/node/vsx-cli.d.ts +9 -9
  63. package/lib/node/vsx-cli.js +41 -41
  64. package/lib/node/vsx-environment-impl.d.ts +14 -14
  65. package/lib/node/vsx-environment-impl.js +61 -61
  66. package/lib/node/vsx-extension-resolver.d.ts +20 -20
  67. package/lib/node/vsx-extension-resolver.js +154 -154
  68. package/lib/node/vsx-registry-backend-module.d.ts +3 -3
  69. package/lib/node/vsx-registry-backend-module.js +35 -35
  70. package/lib/package.spec.js +25 -25
  71. package/package.json +12 -12
  72. package/src/browser/recommended-extensions/preference-provider-overrides.ts +99 -99
  73. package/src/browser/recommended-extensions/recommended-extensions-json-schema.ts +74 -74
  74. package/src/browser/recommended-extensions/recommended-extensions-preference-contribution.ts +68 -68
  75. package/src/browser/style/extensions.svg +4 -4
  76. package/src/browser/style/index.css +436 -373
  77. package/src/browser/vsx-extension-commands.ts +68 -63
  78. package/src/browser/vsx-extension-editor-manager.ts +42 -42
  79. package/src/browser/vsx-extension-editor.tsx +96 -96
  80. package/src/browser/vsx-extension.tsx +704 -675
  81. package/src/browser/vsx-extensions-contribution.ts +361 -327
  82. package/src/browser/vsx-extensions-model.ts +436 -389
  83. package/src/browser/vsx-extensions-preferences.ts +58 -0
  84. package/src/browser/vsx-extensions-search-bar.tsx +107 -69
  85. package/src/browser/vsx-extensions-search-model.ts +61 -61
  86. package/src/browser/vsx-extensions-source.ts +83 -83
  87. package/src/browser/vsx-extensions-view-container.ts +179 -179
  88. package/src/browser/vsx-extensions-widget.tsx +165 -156
  89. package/src/browser/vsx-language-quick-pick-service.ts +110 -110
  90. package/src/browser/vsx-registry-frontend-module.ts +108 -106
  91. package/src/common/index.ts +19 -19
  92. package/src/common/ovsx-client-provider.ts +35 -35
  93. package/src/common/vsx-environment.ts +27 -27
  94. package/src/common/vsx-extension-uri.ts +20 -20
  95. package/src/common/vsx-registry-common-module.ts +63 -63
  96. package/src/node/vsx-cli.ts +38 -38
  97. package/src/node/vsx-environment-impl.ts +50 -50
  98. package/src/node/vsx-extension-resolver.ts +125 -125
  99. package/src/node/vsx-registry-backend-module.ts +35 -35
  100. package/src/package.spec.ts +29 -29
@@ -0,0 +1,58 @@
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 { interfaces } from '@theia/core/shared/inversify';
18
+ import {
19
+ createPreferenceProxy,
20
+ PreferenceProxy,
21
+ PreferenceService,
22
+ PreferenceSchema,
23
+ PreferenceContribution
24
+ } from '@theia/core/lib/browser/preferences';
25
+ import { nls } from '@theia/core';
26
+
27
+ export const VsxExtensionsPreferenceSchema: PreferenceSchema = {
28
+ 'type': 'object',
29
+ properties: {
30
+ 'extensions.onlyShowVerifiedExtensions': {
31
+ type: 'boolean',
32
+ default: false,
33
+ description: nls.localize('theia/vsx-registry/onlyShowVerifiedExtensionsDescription', 'This allows the {0} to only show verified extensions.', 'Open VSX Registry')
34
+ },
35
+ }
36
+ };
37
+
38
+ export interface VsxExtensionsConfiguration {
39
+ 'extensions.onlyShowVerifiedExtensions': boolean;
40
+ }
41
+
42
+ export const VsxExtensionsPreferenceContribution = Symbol('VsxExtensionsPreferenceContribution');
43
+ export const VsxExtensionsPreferences = Symbol('VsxExtensionsPreferences');
44
+ export type VsxExtensionsPreferences = PreferenceProxy<VsxExtensionsConfiguration>;
45
+
46
+ export function createVsxExtensionsPreferences(preferences: PreferenceService, schema: PreferenceSchema = VsxExtensionsPreferenceSchema): VsxExtensionsPreferences {
47
+ return createPreferenceProxy(preferences, schema);
48
+ }
49
+
50
+ export function bindVsxExtensionsPreferences(bind: interfaces.Bind): void {
51
+ bind(VsxExtensionsPreferences).toDynamicValue(ctx => {
52
+ const preferences = ctx.container.get<PreferenceService>(PreferenceService);
53
+ const contribution = ctx.container.get<PreferenceContribution>(VsxExtensionsPreferenceContribution);
54
+ return createVsxExtensionsPreferences(preferences, contribution.schema);
55
+ }).inSingletonScope();
56
+ bind(VsxExtensionsPreferenceContribution).toConstantValue({ schema: VsxExtensionsPreferenceSchema });
57
+ bind(PreferenceContribution).toService(VsxExtensionsPreferenceContribution);
58
+ }
@@ -1,69 +1,107 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import * 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-only 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, codicon } from '@theia/core/lib/browser/widgets';
20
+ import { PreferenceService } from '@theia/core/lib/browser';
21
+ import { VSXExtensionsSearchModel } from './vsx-extensions-search-model';
22
+ import { VSXExtensionsModel } from './vsx-extensions-model';
23
+ import { nls } from '@theia/core/lib/common/nls';
24
+
25
+ @injectable()
26
+ export class VSXExtensionsSearchBar extends ReactWidget {
27
+
28
+ @inject(VSXExtensionsModel)
29
+ protected readonly extensionsModel: VSXExtensionsModel;
30
+
31
+ @inject(VSXExtensionsSearchModel)
32
+ protected readonly searchModel: VSXExtensionsSearchModel;
33
+
34
+ @inject(PreferenceService)
35
+ protected readonly preferenceService: PreferenceService;
36
+
37
+ protected input: HTMLInputElement | undefined;
38
+ protected onlyShowVerifiedExtensions: boolean | undefined;
39
+
40
+ @postConstruct()
41
+ protected init(): void {
42
+ this.onlyShowVerifiedExtensions = this.preferenceService.get('extensions.onlyShowVerifiedExtensions');
43
+ this.id = 'vsx-extensions-search-bar';
44
+ this.addClass('theia-vsx-extensions-search-bar');
45
+ this.searchModel.onDidChangeQuery((query: string) => this.updateSearchTerm(query));
46
+ this.preferenceService.onPreferenceChanged(change => {
47
+ if (change.preferenceName === 'extensions.onlyShowVerifiedExtensions') {
48
+ this.extensionsModel.setOnlyShowVerifiedExtensions(!!change.newValue);
49
+ this.onlyShowVerifiedExtensions = change.newValue;
50
+ this.update();
51
+ }
52
+ });
53
+ }
54
+
55
+ protected render(): React.ReactNode {
56
+ return <div className='vsx-search-container'>
57
+ <input type='text'
58
+ ref={input => this.input = input || undefined}
59
+ defaultValue={this.searchModel.query}
60
+ spellCheck={false}
61
+ className='theia-input'
62
+ placeholder={nls.localize('theia/vsx-registry/searchPlaceholder', 'Search Extensions in {0}', 'Open VSX Registry')}
63
+ onChange={this.updateQuery}>
64
+ </input>
65
+ {this.renderOptionContainer()}
66
+ </div>;
67
+ }
68
+
69
+ protected updateQuery = (e: React.ChangeEvent<HTMLInputElement>) => this.searchModel.query = e.target.value;
70
+
71
+ protected updateSearchTerm(term: string): void {
72
+ if (this.input) {
73
+ this.input.value = term;
74
+ }
75
+ }
76
+
77
+ protected renderOptionContainer(): React.ReactNode {
78
+ const showVerifiedExtensions = this.renderShowVerifiedExtensions();
79
+ return <div className='option-buttons'>{showVerifiedExtensions}</div>;
80
+ }
81
+
82
+ protected renderShowVerifiedExtensions(): React.ReactNode {
83
+ return <span
84
+ className={`${codicon('verified')} option action-label ${this.onlyShowVerifiedExtensions ? 'enabled' : ''}`}
85
+ title={nls.localize('theia/vsx-registry/onlyShowVerifiedExtensionsTitle', 'Only Show Verified Extensions')}
86
+ onClick={() => this.handleShowVerifiedExtensionsClick()}>
87
+ </span>;
88
+ }
89
+
90
+ protected handleShowVerifiedExtensionsClick(): void {
91
+ this.extensionsModel.setOnlyShowVerifiedExtensions(!this.onlyShowVerifiedExtensions);
92
+ this.update();
93
+ }
94
+
95
+ protected override onActivateRequest(msg: Message): void {
96
+ super.onActivateRequest(msg);
97
+ if (this.input) {
98
+ this.input.focus();
99
+ }
100
+ }
101
+
102
+ protected override onAfterAttach(msg: Message): void {
103
+ super.onAfterAttach(msg);
104
+ this.update();
105
+ }
106
+
107
+ }
@@ -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-only 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-only 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-only 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 init(): 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-only 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 init(): 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
+ }