@theia/preferences 1.53.0-next.4 → 1.53.0-next.55

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 (74) hide show
  1. package/README.md +81 -81
  2. package/lib/browser/preference-tree-model.d.ts.map +1 -1
  3. package/lib/browser/preference-tree-model.js +5 -2
  4. package/lib/browser/preference-tree-model.js.map +1 -1
  5. package/lib/browser/util/preference-layout.d.ts.map +1 -1
  6. package/lib/browser/util/preference-layout.js +4 -0
  7. package/lib/browser/util/preference-layout.js.map +1 -1
  8. package/lib/browser/util/preference-tree-generator.d.ts +14 -2
  9. package/lib/browser/util/preference-tree-generator.d.ts.map +1 -1
  10. package/lib/browser/util/preference-tree-generator.js +89 -26
  11. package/lib/browser/util/preference-tree-generator.js.map +1 -1
  12. package/lib/browser/util/preference-tree-label-provider.d.ts.map +1 -1
  13. package/lib/browser/util/preference-tree-label-provider.js +4 -11
  14. package/lib/browser/util/preference-tree-label-provider.js.map +1 -1
  15. package/lib/browser/util/preference-types.d.ts +4 -2
  16. package/lib/browser/util/preference-types.d.ts.map +1 -1
  17. package/lib/browser/util/preference-types.js.map +1 -1
  18. package/lib/browser/views/preference-tree-widget.d.ts +2 -0
  19. package/lib/browser/views/preference-tree-widget.d.ts.map +1 -1
  20. package/lib/browser/views/preference-tree-widget.js +10 -1
  21. package/lib/browser/views/preference-tree-widget.js.map +1 -1
  22. package/package.json +9 -9
  23. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  24. package/src/browser/abstract-resource-preference-provider.ts +232 -232
  25. package/src/browser/folder-preference-provider.ts +58 -58
  26. package/src/browser/folders-preferences-provider.ts +244 -244
  27. package/src/browser/index.ts +23 -23
  28. package/src/browser/monaco-jsonc-editor.ts +67 -67
  29. package/src/browser/package.spec.ts +28 -28
  30. package/src/browser/preference-bindings.ts +65 -65
  31. package/src/browser/preference-frontend-contribution.ts +38 -38
  32. package/src/browser/preference-frontend-module.ts +66 -66
  33. package/src/browser/preference-open-handler.ts +53 -53
  34. package/src/browser/preference-transaction-manager.ts +287 -287
  35. package/src/browser/preference-tree-model.ts +260 -257
  36. package/src/browser/preferences-contribution.ts +263 -263
  37. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  38. package/src/browser/preferences-monaco-contribution.ts +27 -27
  39. package/src/browser/section-preference-provider.ts +83 -83
  40. package/src/browser/style/index.css +506 -506
  41. package/src/browser/style/preference-array.css +94 -94
  42. package/src/browser/style/preference-context-menu.css +74 -74
  43. package/src/browser/style/preference-file.css +31 -31
  44. package/src/browser/style/preference-object.css +49 -49
  45. package/src/browser/style/search-input.css +66 -66
  46. package/src/browser/user-configs-preference-provider.ts +127 -127
  47. package/src/browser/user-preference-provider.ts +35 -35
  48. package/src/browser/util/preference-layout.ts +381 -377
  49. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  50. package/src/browser/util/preference-tree-generator.ts +260 -190
  51. package/src/browser/util/preference-tree-label-provider.spec.ts +110 -110
  52. package/src/browser/util/preference-tree-label-provider.ts +72 -78
  53. package/src/browser/util/preference-types.ts +177 -175
  54. package/src/browser/views/components/preference-array-input.ts +174 -174
  55. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  56. package/src/browser/views/components/preference-file-input.ts +104 -104
  57. package/src/browser/views/components/preference-json-input.ts +78 -78
  58. package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
  59. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  60. package/src/browser/views/components/preference-node-renderer.ts +477 -477
  61. package/src/browser/views/components/preference-number-input.ts +147 -147
  62. package/src/browser/views/components/preference-select-input.ts +131 -131
  63. package/src/browser/views/components/preference-string-input.ts +76 -76
  64. package/src/browser/views/preference-editor-widget.ts +349 -349
  65. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  66. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  67. package/src/browser/views/preference-tree-widget.tsx +102 -93
  68. package/src/browser/views/preference-widget-bindings.ts +102 -102
  69. package/src/browser/views/preference-widget.tsx +118 -118
  70. package/src/browser/workspace-file-preference-provider.ts +100 -100
  71. package/src/browser/workspace-preference-provider.ts +134 -134
  72. package/src/common/cli-preferences.ts +22 -22
  73. package/src/node/preference-backend-module.ts +33 -33
  74. package/src/node/preference-cli-contribution.ts +48 -48
@@ -1,127 +1,127 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 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
- /* eslint-disable @typescript-eslint/no-explicit-any */
18
-
19
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
20
- import URI from '@theia/core/lib/common/uri';
21
- import { PreferenceProvider, PreferenceResolveResult } from '@theia/core/lib/browser/preferences/preference-provider';
22
- import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
23
- import { UserStorageUri } from '@theia/userstorage/lib/browser';
24
- import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-preference-provider';
25
-
26
- /**
27
- * Binds together preference section prefs providers for user-level preferences.
28
- */
29
- @injectable()
30
- export class UserConfigsPreferenceProvider extends PreferenceProvider {
31
-
32
- @inject(UserPreferenceProviderFactory)
33
- protected readonly providerFactory: UserPreferenceProviderFactory;
34
-
35
- @inject(PreferenceConfigurations)
36
- protected readonly configurations: PreferenceConfigurations;
37
-
38
- protected readonly providers = new Map<string, UserPreferenceProvider>();
39
-
40
- @postConstruct()
41
- protected init(): void {
42
- this.doInit();
43
- }
44
-
45
- protected async doInit(): Promise<void> {
46
- this.createProviders();
47
-
48
- const readyPromises: Promise<void>[] = [];
49
- for (const provider of this.providers.values()) {
50
- readyPromises.push(provider.ready.catch(e => console.error(e)));
51
- }
52
- Promise.all(readyPromises).then(() => this._ready.resolve());
53
- }
54
-
55
- protected createProviders(): void {
56
- for (const configName of [...this.configurations.getSectionNames(), this.configurations.getConfigName()]) {
57
- const sectionUri = UserStorageUri.resolve(configName + '.json');
58
- const sectionKey = sectionUri.toString();
59
- if (!this.providers.has(sectionKey)) {
60
- const provider = this.createProvider(sectionUri, configName);
61
- this.providers.set(sectionKey, provider);
62
- }
63
- }
64
- }
65
-
66
- override getConfigUri(resourceUri?: string, sectionName: string = this.configurations.getConfigName()): URI | undefined {
67
- for (const provider of this.providers.values()) {
68
- const configUri = provider.getConfigUri(resourceUri);
69
- if (configUri && this.configurations.getName(configUri) === sectionName) {
70
- return configUri;
71
- }
72
- }
73
- return undefined;
74
- }
75
-
76
- override resolve<T>(preferenceName: string, resourceUri?: string): PreferenceResolveResult<T> {
77
- const result: PreferenceResolveResult<T> = {};
78
- for (const provider of this.providers.values()) {
79
- const { value, configUri } = provider.resolve<T>(preferenceName, resourceUri);
80
- if (configUri && value !== undefined) {
81
- result.configUri = configUri;
82
- result.value = PreferenceProvider.merge(result.value as any, value as any) as any;
83
- }
84
- }
85
- return result;
86
- }
87
-
88
- getPreferences(resourceUri?: string): { [p: string]: any } {
89
- let result = {};
90
- for (const provider of this.providers.values()) {
91
- const preferences = provider.getPreferences();
92
- result = PreferenceProvider.merge(result, preferences) as any;
93
- }
94
- return result;
95
- }
96
-
97
- async setPreference(preferenceName: string, value: any, resourceUri?: string): Promise<boolean> {
98
- const sectionName = preferenceName.split('.', 1)[0];
99
- const defaultConfigName = this.configurations.getConfigName();
100
- const configName = this.configurations.isSectionName(sectionName) ? sectionName : defaultConfigName;
101
-
102
- const setWithConfigName = async (name: string): Promise<boolean> => {
103
- for (const provider of this.providers.values()) {
104
- if (this.configurations.getName(provider.getConfigUri()) === name) {
105
- if (await provider.setPreference(preferenceName, value, resourceUri)) {
106
- return true;
107
- }
108
- }
109
- }
110
- return false;
111
- };
112
-
113
- if (await setWithConfigName(configName)) { // Try in the section we believe it belongs in.
114
- return true;
115
- } else if (configName !== defaultConfigName) { // Fall back to `settings.json` if that fails.
116
- return setWithConfigName(defaultConfigName);
117
- }
118
- return false;
119
- }
120
-
121
- protected createProvider(uri: URI, sectionName: string): UserPreferenceProvider {
122
- const provider = this.providerFactory(uri, sectionName);
123
- this.toDispose.push(provider);
124
- this.toDispose.push(provider.onDidPreferencesChanged(change => this.onDidPreferencesChangedEmitter.fire(change)));
125
- return provider;
126
- }
127
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 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
+ /* eslint-disable @typescript-eslint/no-explicit-any */
18
+
19
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
20
+ import URI from '@theia/core/lib/common/uri';
21
+ import { PreferenceProvider, PreferenceResolveResult } from '@theia/core/lib/browser/preferences/preference-provider';
22
+ import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
23
+ import { UserStorageUri } from '@theia/userstorage/lib/browser';
24
+ import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-preference-provider';
25
+
26
+ /**
27
+ * Binds together preference section prefs providers for user-level preferences.
28
+ */
29
+ @injectable()
30
+ export class UserConfigsPreferenceProvider extends PreferenceProvider {
31
+
32
+ @inject(UserPreferenceProviderFactory)
33
+ protected readonly providerFactory: UserPreferenceProviderFactory;
34
+
35
+ @inject(PreferenceConfigurations)
36
+ protected readonly configurations: PreferenceConfigurations;
37
+
38
+ protected readonly providers = new Map<string, UserPreferenceProvider>();
39
+
40
+ @postConstruct()
41
+ protected init(): void {
42
+ this.doInit();
43
+ }
44
+
45
+ protected async doInit(): Promise<void> {
46
+ this.createProviders();
47
+
48
+ const readyPromises: Promise<void>[] = [];
49
+ for (const provider of this.providers.values()) {
50
+ readyPromises.push(provider.ready.catch(e => console.error(e)));
51
+ }
52
+ Promise.all(readyPromises).then(() => this._ready.resolve());
53
+ }
54
+
55
+ protected createProviders(): void {
56
+ for (const configName of [...this.configurations.getSectionNames(), this.configurations.getConfigName()]) {
57
+ const sectionUri = UserStorageUri.resolve(configName + '.json');
58
+ const sectionKey = sectionUri.toString();
59
+ if (!this.providers.has(sectionKey)) {
60
+ const provider = this.createProvider(sectionUri, configName);
61
+ this.providers.set(sectionKey, provider);
62
+ }
63
+ }
64
+ }
65
+
66
+ override getConfigUri(resourceUri?: string, sectionName: string = this.configurations.getConfigName()): URI | undefined {
67
+ for (const provider of this.providers.values()) {
68
+ const configUri = provider.getConfigUri(resourceUri);
69
+ if (configUri && this.configurations.getName(configUri) === sectionName) {
70
+ return configUri;
71
+ }
72
+ }
73
+ return undefined;
74
+ }
75
+
76
+ override resolve<T>(preferenceName: string, resourceUri?: string): PreferenceResolveResult<T> {
77
+ const result: PreferenceResolveResult<T> = {};
78
+ for (const provider of this.providers.values()) {
79
+ const { value, configUri } = provider.resolve<T>(preferenceName, resourceUri);
80
+ if (configUri && value !== undefined) {
81
+ result.configUri = configUri;
82
+ result.value = PreferenceProvider.merge(result.value as any, value as any) as any;
83
+ }
84
+ }
85
+ return result;
86
+ }
87
+
88
+ getPreferences(resourceUri?: string): { [p: string]: any } {
89
+ let result = {};
90
+ for (const provider of this.providers.values()) {
91
+ const preferences = provider.getPreferences();
92
+ result = PreferenceProvider.merge(result, preferences) as any;
93
+ }
94
+ return result;
95
+ }
96
+
97
+ async setPreference(preferenceName: string, value: any, resourceUri?: string): Promise<boolean> {
98
+ const sectionName = preferenceName.split('.', 1)[0];
99
+ const defaultConfigName = this.configurations.getConfigName();
100
+ const configName = this.configurations.isSectionName(sectionName) ? sectionName : defaultConfigName;
101
+
102
+ const setWithConfigName = async (name: string): Promise<boolean> => {
103
+ for (const provider of this.providers.values()) {
104
+ if (this.configurations.getName(provider.getConfigUri()) === name) {
105
+ if (await provider.setPreference(preferenceName, value, resourceUri)) {
106
+ return true;
107
+ }
108
+ }
109
+ }
110
+ return false;
111
+ };
112
+
113
+ if (await setWithConfigName(configName)) { // Try in the section we believe it belongs in.
114
+ return true;
115
+ } else if (configName !== defaultConfigName) { // Fall back to `settings.json` if that fails.
116
+ return setWithConfigName(defaultConfigName);
117
+ }
118
+ return false;
119
+ }
120
+
121
+ protected createProvider(uri: URI, sectionName: string): UserPreferenceProvider {
122
+ const provider = this.providerFactory(uri, sectionName);
123
+ this.toDispose.push(provider);
124
+ this.toDispose.push(provider.onDidPreferencesChanged(change => this.onDidPreferencesChangedEmitter.fire(change)));
125
+ return provider;
126
+ }
127
+ }
@@ -1,35 +1,35 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 { injectable } from '@theia/core/shared/inversify';
18
- import URI from '@theia/core/lib/common/uri';
19
- import { PreferenceScope } from '@theia/core/lib/browser';
20
- import { SectionPreferenceProvider } from './section-preference-provider';
21
-
22
- export const UserPreferenceProviderFactory = Symbol('UserPreferenceProviderFactory');
23
- export interface UserPreferenceProviderFactory {
24
- (uri: URI, section: string): UserPreferenceProvider;
25
- };
26
-
27
- /**
28
- * A @SectionPreferenceProvider that targets the user-level settings
29
- */
30
- @injectable()
31
- export class UserPreferenceProvider extends SectionPreferenceProvider {
32
- getScope(): PreferenceScope {
33
- return PreferenceScope.User;
34
- }
35
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 { injectable } from '@theia/core/shared/inversify';
18
+ import URI from '@theia/core/lib/common/uri';
19
+ import { PreferenceScope } from '@theia/core/lib/browser';
20
+ import { SectionPreferenceProvider } from './section-preference-provider';
21
+
22
+ export const UserPreferenceProviderFactory = Symbol('UserPreferenceProviderFactory');
23
+ export interface UserPreferenceProviderFactory {
24
+ (uri: URI, section: string): UserPreferenceProvider;
25
+ };
26
+
27
+ /**
28
+ * A @SectionPreferenceProvider that targets the user-level settings
29
+ */
30
+ @injectable()
31
+ export class UserPreferenceProvider extends SectionPreferenceProvider {
32
+ getScope(): PreferenceScope {
33
+ return PreferenceScope.User;
34
+ }
35
+ }