@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,175 +1,177 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 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 {
18
- PreferenceDataProperty,
19
- PreferenceScope,
20
- TreeNode as BaseTreeNode,
21
- ExpandableTreeNode,
22
- SelectableTreeNode,
23
- PreferenceInspection,
24
- CommonCommands,
25
- } from '@theia/core/lib/browser';
26
- import { Command, MenuPath } from '@theia/core';
27
- import { JSONValue } from '@theia/core/shared/@phosphor/coreutils';
28
- import { JsonType } from '@theia/core/lib/common/json-schema';
29
-
30
- export namespace Preference {
31
-
32
- export interface EditorCommandArgs {
33
- id: string;
34
- value: string | undefined;
35
- }
36
-
37
- export namespace EditorCommandArgs {
38
- export function is(prefObject: EditorCommandArgs): prefObject is EditorCommandArgs {
39
- return !!prefObject && 'id' in prefObject && 'value' in prefObject;
40
- }
41
- }
42
-
43
- export const Node = Symbol('Preference.Node');
44
- export type Node = TreeNode;
45
-
46
- export type TreeNode = CompositeTreeNode | LeafNode;
47
-
48
- export namespace TreeNode {
49
- export const is = (node: BaseTreeNode | TreeNode): node is TreeNode => 'depth' in node;
50
- export const isTopLevel = (node: BaseTreeNode): boolean => {
51
- const { group, id } = getGroupAndIdFromNodeId(node.id);
52
- return group === id;
53
- };
54
- export const getGroupAndIdFromNodeId = (nodeId: string): { group: string; id: string } => {
55
- const separator = nodeId.indexOf('@');
56
- const group = nodeId.substring(0, separator);
57
- const id = nodeId.substring(separator + 1, nodeId.length);
58
- return { group, id };
59
- };
60
- }
61
-
62
- export interface CompositeTreeNode extends ExpandableTreeNode, SelectableTreeNode {
63
- depth: number;
64
- label?: string;
65
- }
66
-
67
- export namespace CompositeTreeNode {
68
- export const is = (node: TreeNode): node is CompositeTreeNode => !LeafNode.is(node);
69
- }
70
-
71
- export interface LeafNode extends BaseTreeNode {
72
- depth: number;
73
- preference: { data: PreferenceDataProperty };
74
- preferenceId: string;
75
- }
76
-
77
- export namespace LeafNode {
78
- export const is = (node: BaseTreeNode | LeafNode): node is LeafNode => 'preference' in node && !!node.preference.data;
79
-
80
- export const getType = (node: BaseTreeNode | LeafNode): JsonType | undefined => is(node)
81
- ? Array.isArray(node.preference.data.type) ? node.preference.data.type[0] : node.preference.data.type
82
- : undefined;
83
- }
84
-
85
- export const getValueInScope = <T extends JSONValue>(preferenceInfo: PreferenceInspection<T> | undefined, scope: number): T | undefined => {
86
- if (!preferenceInfo) {
87
- return undefined;
88
- }
89
- switch (scope) {
90
- case PreferenceScope.User:
91
- return preferenceInfo.globalValue;
92
- case PreferenceScope.Workspace:
93
- return preferenceInfo.workspaceValue;
94
- case PreferenceScope.Folder:
95
- return preferenceInfo.workspaceFolderValue;
96
- default:
97
- return undefined;
98
- }
99
- };
100
-
101
- export interface SelectedScopeDetails {
102
- scope: number;
103
- uri: string | undefined;
104
- activeScopeIsFolder: boolean;
105
- };
106
-
107
- export const DEFAULT_SCOPE: SelectedScopeDetails = {
108
- scope: PreferenceScope.User,
109
- uri: undefined,
110
- activeScopeIsFolder: false
111
- };
112
-
113
- }
114
-
115
- export namespace PreferencesCommands {
116
- export const OPEN_PREFERENCES_JSON_TOOLBAR: Command = {
117
- id: 'preferences:openJson.toolbar',
118
- iconClass: 'codicon codicon-json'
119
- };
120
- export const COPY_JSON_NAME = Command.toDefaultLocalizedCommand({
121
- id: 'preferences:copyJson.name',
122
- label: 'Copy Setting ID'
123
- });
124
- export const RESET_PREFERENCE = Command.toDefaultLocalizedCommand({
125
- id: 'preferences:reset',
126
- label: 'Reset Setting'
127
- });
128
-
129
- export const COPY_JSON_VALUE = Command.toDefaultLocalizedCommand({
130
- id: 'preferences:copyJson.value',
131
- label: 'Copy Setting as JSON',
132
- });
133
-
134
- export const OPEN_USER_PREFERENCES = Command.toDefaultLocalizedCommand({
135
- id: 'workbench.action.openGlobalSettings',
136
- category: CommonCommands.PREFERENCES_CATEGORY,
137
- label: 'Open User Settings',
138
- });
139
-
140
- export const OPEN_WORKSPACE_PREFERENCES = Command.toDefaultLocalizedCommand({
141
- id: 'workbench.action.openWorkspaceSettings',
142
- category: CommonCommands.PREFERENCES_CATEGORY,
143
- label: 'Open Workspace Settings',
144
- });
145
-
146
- export const OPEN_FOLDER_PREFERENCES = Command.toDefaultLocalizedCommand({
147
- id: 'workbench.action.openFolderSettings',
148
- category: CommonCommands.PREFERENCES_CATEGORY,
149
- label: 'Open Folder Settings'
150
- });
151
-
152
- export const OPEN_USER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
153
- id: 'workbench.action.openSettingsJson',
154
- category: CommonCommands.PREFERENCES_CATEGORY,
155
- label: 'Open Settings (JSON)'
156
- });
157
-
158
- export const OPEN_WORKSPACE_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
159
- id: 'workbench.action.openWorkspaceSettingsFile',
160
- category: CommonCommands.PREFERENCES_CATEGORY,
161
- label: 'Open Workspace Settings (JSON)',
162
- });
163
-
164
- export const OPEN_FOLDER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
165
- id: 'workbench.action.openFolderSettingsFile',
166
- category: CommonCommands.PREFERENCES_CATEGORY,
167
- label: 'Open Folder Settings (JSON)',
168
- });
169
- }
170
-
171
- export namespace PreferenceMenus {
172
- export const PREFERENCE_EDITOR_CONTEXT_MENU: MenuPath = ['preferences:editor.contextMenu'];
173
- export const PREFERENCE_EDITOR_COPY_ACTIONS: MenuPath = [...PREFERENCE_EDITOR_CONTEXT_MENU, 'preferences:editor.contextMenu.copy'];
174
- export const FOLDER_SCOPE_MENU_PATH = ['preferences:scope.menu'];
175
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 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 {
18
+ PreferenceDataProperty,
19
+ PreferenceScope,
20
+ TreeNode as BaseTreeNode,
21
+ CompositeTreeNode as BaseCompositeTreeNode,
22
+ SelectableTreeNode,
23
+ PreferenceInspection,
24
+ CommonCommands,
25
+ } from '@theia/core/lib/browser';
26
+ import { Command, MenuPath } from '@theia/core';
27
+ import { JSONValue } from '@theia/core/shared/@phosphor/coreutils';
28
+ import { JsonType } from '@theia/core/lib/common/json-schema';
29
+
30
+ export namespace Preference {
31
+
32
+ export interface EditorCommandArgs {
33
+ id: string;
34
+ value: string | undefined;
35
+ }
36
+
37
+ export namespace EditorCommandArgs {
38
+ export function is(prefObject: EditorCommandArgs): prefObject is EditorCommandArgs {
39
+ return !!prefObject && 'id' in prefObject && 'value' in prefObject;
40
+ }
41
+ }
42
+
43
+ export const Node = Symbol('Preference.Node');
44
+ export type Node = TreeNode;
45
+
46
+ export type TreeNode = CompositeTreeNode | LeafNode;
47
+
48
+ export namespace TreeNode {
49
+ export const is = (node: BaseTreeNode | TreeNode): node is TreeNode => 'depth' in node;
50
+ export const isTopLevel = (node: BaseTreeNode): boolean => {
51
+ const { group, id } = getGroupAndIdFromNodeId(node.id);
52
+ return group === id;
53
+ };
54
+ export const getGroupAndIdFromNodeId = (nodeId: string): { group: string; id: string } => {
55
+ const separator = nodeId.indexOf('@');
56
+ const group = nodeId.substring(0, separator);
57
+ const id = nodeId.substring(separator + 1, nodeId.length);
58
+ return { group, id };
59
+ };
60
+ }
61
+
62
+ export interface CompositeTreeNode extends BaseCompositeTreeNode, SelectableTreeNode {
63
+ expanded?: boolean;
64
+ depth: number;
65
+ label?: string;
66
+ }
67
+
68
+ export namespace CompositeTreeNode {
69
+ export const is = (node: TreeNode): node is CompositeTreeNode => !LeafNode.is(node);
70
+ }
71
+
72
+ export interface LeafNode extends BaseTreeNode {
73
+ label?: string;
74
+ depth: number;
75
+ preference: { data: PreferenceDataProperty };
76
+ preferenceId: string;
77
+ }
78
+
79
+ export namespace LeafNode {
80
+ export const is = (node: BaseTreeNode | LeafNode): node is LeafNode => 'preference' in node && !!node.preference.data;
81
+
82
+ export const getType = (node: BaseTreeNode | LeafNode): JsonType | undefined => is(node)
83
+ ? Array.isArray(node.preference.data.type) ? node.preference.data.type[0] : node.preference.data.type
84
+ : undefined;
85
+ }
86
+
87
+ export const getValueInScope = <T extends JSONValue>(preferenceInfo: PreferenceInspection<T> | undefined, scope: number): T | undefined => {
88
+ if (!preferenceInfo) {
89
+ return undefined;
90
+ }
91
+ switch (scope) {
92
+ case PreferenceScope.User:
93
+ return preferenceInfo.globalValue;
94
+ case PreferenceScope.Workspace:
95
+ return preferenceInfo.workspaceValue;
96
+ case PreferenceScope.Folder:
97
+ return preferenceInfo.workspaceFolderValue;
98
+ default:
99
+ return undefined;
100
+ }
101
+ };
102
+
103
+ export interface SelectedScopeDetails {
104
+ scope: number;
105
+ uri: string | undefined;
106
+ activeScopeIsFolder: boolean;
107
+ };
108
+
109
+ export const DEFAULT_SCOPE: SelectedScopeDetails = {
110
+ scope: PreferenceScope.User,
111
+ uri: undefined,
112
+ activeScopeIsFolder: false
113
+ };
114
+
115
+ }
116
+
117
+ export namespace PreferencesCommands {
118
+ export const OPEN_PREFERENCES_JSON_TOOLBAR: Command = {
119
+ id: 'preferences:openJson.toolbar',
120
+ iconClass: 'codicon codicon-json'
121
+ };
122
+ export const COPY_JSON_NAME = Command.toDefaultLocalizedCommand({
123
+ id: 'preferences:copyJson.name',
124
+ label: 'Copy Setting ID'
125
+ });
126
+ export const RESET_PREFERENCE = Command.toDefaultLocalizedCommand({
127
+ id: 'preferences:reset',
128
+ label: 'Reset Setting'
129
+ });
130
+
131
+ export const COPY_JSON_VALUE = Command.toDefaultLocalizedCommand({
132
+ id: 'preferences:copyJson.value',
133
+ label: 'Copy Setting as JSON',
134
+ });
135
+
136
+ export const OPEN_USER_PREFERENCES = Command.toDefaultLocalizedCommand({
137
+ id: 'workbench.action.openGlobalSettings',
138
+ category: CommonCommands.PREFERENCES_CATEGORY,
139
+ label: 'Open User Settings',
140
+ });
141
+
142
+ export const OPEN_WORKSPACE_PREFERENCES = Command.toDefaultLocalizedCommand({
143
+ id: 'workbench.action.openWorkspaceSettings',
144
+ category: CommonCommands.PREFERENCES_CATEGORY,
145
+ label: 'Open Workspace Settings',
146
+ });
147
+
148
+ export const OPEN_FOLDER_PREFERENCES = Command.toDefaultLocalizedCommand({
149
+ id: 'workbench.action.openFolderSettings',
150
+ category: CommonCommands.PREFERENCES_CATEGORY,
151
+ label: 'Open Folder Settings'
152
+ });
153
+
154
+ export const OPEN_USER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
155
+ id: 'workbench.action.openSettingsJson',
156
+ category: CommonCommands.PREFERENCES_CATEGORY,
157
+ label: 'Open Settings (JSON)'
158
+ });
159
+
160
+ export const OPEN_WORKSPACE_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
161
+ id: 'workbench.action.openWorkspaceSettingsFile',
162
+ category: CommonCommands.PREFERENCES_CATEGORY,
163
+ label: 'Open Workspace Settings (JSON)',
164
+ });
165
+
166
+ export const OPEN_FOLDER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
167
+ id: 'workbench.action.openFolderSettingsFile',
168
+ category: CommonCommands.PREFERENCES_CATEGORY,
169
+ label: 'Open Folder Settings (JSON)',
170
+ });
171
+ }
172
+
173
+ export namespace PreferenceMenus {
174
+ export const PREFERENCE_EDITOR_CONTEXT_MENU: MenuPath = ['preferences:editor.contextMenu'];
175
+ export const PREFERENCE_EDITOR_COPY_ACTIONS: MenuPath = [...PREFERENCE_EDITOR_CONTEXT_MENU, 'preferences:editor.contextMenu.copy'];
176
+ export const FOLDER_SCOPE_MENU_PATH = ['preferences:scope.menu'];
177
+ }