@codingame/monaco-vscode-configuration-service-override 3.2.3 → 4.1.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.
@@ -1,595 +0,0 @@
1
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
2
- import { deepClone } from 'vscode/vscode/vs/base/common/objects';
3
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
4
- import { ExtensionsRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
5
- import { Extensions as Extensions$1, configurationDefaultsSchemaId, OVERRIDE_PROPERTY_REGEX, validateProperty, getDefaultValue } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
6
- import { Extensions } from 'vscode/vscode/vs/platform/jsonschemas/common/jsonContributionRegistry';
7
- import { workspaceSettingsSchemaId, launchSchemaId, tasksSchemaId } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration';
8
- import { isObject, isUndefined } from 'vscode/vscode/vs/base/common/types';
9
- import { ExtensionIdentifierMap } from 'vscode/vscode/vs/platform/extensions/common/extensions';
10
- import { Extensions as Extensions$2 } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
11
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
12
- import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
13
- import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
14
-
15
- const jsonRegistry = ( Registry.as(Extensions.JSONContribution));
16
- const configurationRegistry = ( Registry.as(Extensions$1.Configuration));
17
- const configurationEntrySchema = {
18
- type: 'object',
19
- defaultSnippets: [{ body: { title: '', properties: {} } }],
20
- properties: {
21
- title: {
22
- description: ( localizeWithPath(
23
- 'vs/workbench/api/common/configurationExtensionPoint',
24
- 'vscode.extension.contributes.configuration.title',
25
- 'A title for the current category of settings. This label will be rendered in the Settings editor as a subheading. If the title is the same as the extension display name, then the category will be grouped under the main extension heading.'
26
- )),
27
- type: 'string'
28
- },
29
- order: {
30
- description: ( localizeWithPath(
31
- 'vs/workbench/api/common/configurationExtensionPoint',
32
- 'vscode.extension.contributes.configuration.order',
33
- 'When specified, gives the order of this category of settings relative to other categories.'
34
- )),
35
- type: 'integer'
36
- },
37
- properties: {
38
- description: ( localizeWithPath(
39
- 'vs/workbench/api/common/configurationExtensionPoint',
40
- 'vscode.extension.contributes.configuration.properties',
41
- 'Description of the configuration properties.'
42
- )),
43
- type: 'object',
44
- propertyNames: {
45
- pattern: '\\S+',
46
- patternErrorMessage: ( localizeWithPath(
47
- 'vs/workbench/api/common/configurationExtensionPoint',
48
- 'vscode.extension.contributes.configuration.property.empty',
49
- 'Property should not be empty.'
50
- )),
51
- },
52
- additionalProperties: {
53
- anyOf: [
54
- {
55
- title: ( localizeWithPath(
56
- 'vs/workbench/api/common/configurationExtensionPoint',
57
- 'vscode.extension.contributes.configuration.properties.schema',
58
- 'Schema of the configuration property.'
59
- )),
60
- $ref: 'http://json-schema.org/draft-07/schema#'
61
- },
62
- {
63
- type: 'object',
64
- properties: {
65
- scope: {
66
- type: 'string',
67
- enum: ['application', 'machine', 'window', 'resource', 'language-overridable', 'machine-overridable'],
68
- default: 'window',
69
- enumDescriptions: [
70
- ( localizeWithPath(
71
- 'vs/workbench/api/common/configurationExtensionPoint',
72
- 'scope.application.description',
73
- "Configuration that can be configured only in the user settings."
74
- )),
75
- ( localizeWithPath(
76
- 'vs/workbench/api/common/configurationExtensionPoint',
77
- 'scope.machine.description',
78
- "Configuration that can be configured only in the user settings or only in the remote settings."
79
- )),
80
- ( localizeWithPath(
81
- 'vs/workbench/api/common/configurationExtensionPoint',
82
- 'scope.window.description',
83
- "Configuration that can be configured in the user, remote or workspace settings."
84
- )),
85
- ( localizeWithPath(
86
- 'vs/workbench/api/common/configurationExtensionPoint',
87
- 'scope.resource.description',
88
- "Configuration that can be configured in the user, remote, workspace or folder settings."
89
- )),
90
- ( localizeWithPath(
91
- 'vs/workbench/api/common/configurationExtensionPoint',
92
- 'scope.language-overridable.description',
93
- "Resource configuration that can be configured in language specific settings."
94
- )),
95
- ( localizeWithPath(
96
- 'vs/workbench/api/common/configurationExtensionPoint',
97
- 'scope.machine-overridable.description',
98
- "Machine configuration that can be configured also in workspace or folder settings."
99
- ))
100
- ],
101
- markdownDescription: ( localizeWithPath(
102
- 'vs/workbench/api/common/configurationExtensionPoint',
103
- 'scope.description',
104
- "Scope in which the configuration is applicable. Available scopes are `application`, `machine`, `window`, `resource`, and `machine-overridable`."
105
- ))
106
- },
107
- enumDescriptions: {
108
- type: 'array',
109
- items: {
110
- type: 'string',
111
- },
112
- description: ( localizeWithPath(
113
- 'vs/workbench/api/common/configurationExtensionPoint',
114
- 'scope.enumDescriptions',
115
- 'Descriptions for enum values'
116
- ))
117
- },
118
- markdownEnumDescriptions: {
119
- type: 'array',
120
- items: {
121
- type: 'string',
122
- },
123
- description: ( localizeWithPath(
124
- 'vs/workbench/api/common/configurationExtensionPoint',
125
- 'scope.markdownEnumDescriptions',
126
- 'Descriptions for enum values in the markdown format.'
127
- ))
128
- },
129
- enumItemLabels: {
130
- type: 'array',
131
- items: {
132
- type: 'string'
133
- },
134
- markdownDescription: ( localizeWithPath(
135
- 'vs/workbench/api/common/configurationExtensionPoint',
136
- 'scope.enumItemLabels',
137
- 'Labels for enum values to be displayed in the Settings editor. When specified, the {0} values still show after the labels, but less prominently.',
138
- '`enum`'
139
- ))
140
- },
141
- markdownDescription: {
142
- type: 'string',
143
- description: ( localizeWithPath(
144
- 'vs/workbench/api/common/configurationExtensionPoint',
145
- 'scope.markdownDescription',
146
- 'The description in the markdown format.'
147
- ))
148
- },
149
- deprecationMessage: {
150
- type: 'string',
151
- description: ( localizeWithPath(
152
- 'vs/workbench/api/common/configurationExtensionPoint',
153
- 'scope.deprecationMessage',
154
- 'If set, the property is marked as deprecated and the given message is shown as an explanation.'
155
- ))
156
- },
157
- markdownDeprecationMessage: {
158
- type: 'string',
159
- description: ( localizeWithPath(
160
- 'vs/workbench/api/common/configurationExtensionPoint',
161
- 'scope.markdownDeprecationMessage',
162
- 'If set, the property is marked as deprecated and the given message is shown as an explanation in the markdown format.'
163
- ))
164
- },
165
- editPresentation: {
166
- type: 'string',
167
- enum: ['singlelineText', 'multilineText'],
168
- enumDescriptions: [
169
- ( localizeWithPath(
170
- 'vs/workbench/api/common/configurationExtensionPoint',
171
- 'scope.singlelineText.description',
172
- 'The value will be shown in an inputbox.'
173
- )),
174
- ( localizeWithPath(
175
- 'vs/workbench/api/common/configurationExtensionPoint',
176
- 'scope.multilineText.description',
177
- 'The value will be shown in a textarea.'
178
- ))
179
- ],
180
- default: 'singlelineText',
181
- description: ( localizeWithPath(
182
- 'vs/workbench/api/common/configurationExtensionPoint',
183
- 'scope.editPresentation',
184
- 'When specified, controls the presentation format of the string setting.'
185
- ))
186
- },
187
- order: {
188
- type: 'integer',
189
- description: ( localizeWithPath(
190
- 'vs/workbench/api/common/configurationExtensionPoint',
191
- 'scope.order',
192
- 'When specified, gives the order of this setting relative to other settings within the same category. Settings with an order property will be placed before settings without this property set.'
193
- ))
194
- },
195
- ignoreSync: {
196
- type: 'boolean',
197
- description: ( localizeWithPath(
198
- 'vs/workbench/api/common/configurationExtensionPoint',
199
- 'scope.ignoreSync',
200
- 'When enabled, Settings Sync will not sync the user value of this configuration by default.'
201
- ))
202
- },
203
- }
204
- }
205
- ]
206
- }
207
- }
208
- }
209
- };
210
- let _configDelta;
211
- const defaultConfigurationExtPoint = ExtensionsRegistry.registerExtensionPoint({
212
- extensionPoint: 'configurationDefaults',
213
- jsonSchema: {
214
- $ref: configurationDefaultsSchemaId,
215
- }
216
- });
217
- defaultConfigurationExtPoint.setHandler((extensions, { added, removed }) => {
218
- if (_configDelta) {
219
- configurationRegistry.deltaConfiguration(_configDelta);
220
- }
221
- const configNow = _configDelta = {};
222
- queueMicrotask(() => {
223
- if (_configDelta === configNow) {
224
- configurationRegistry.deltaConfiguration(_configDelta);
225
- _configDelta = undefined;
226
- }
227
- });
228
- if (removed.length) {
229
- const removedDefaultConfigurations = ( removed.map(
230
- extension => ({ overrides: deepClone(extension.value), source: { id: extension.description.identifier.value, displayName: extension.description.displayName } })
231
- ));
232
- _configDelta.removedDefaults = removedDefaultConfigurations;
233
- }
234
- if (added.length) {
235
- const registeredProperties = configurationRegistry.getConfigurationProperties();
236
- const allowedScopes = [6 , 3 , 4 , 5 ];
237
- const addedDefaultConfigurations = ( added.map(extension => {
238
- const overrides = deepClone(extension.value);
239
- for (const key of ( Object.keys(overrides))) {
240
- if (!OVERRIDE_PROPERTY_REGEX.test(key)) {
241
- const registeredPropertyScheme = registeredProperties[key];
242
- if (registeredPropertyScheme?.scope && !allowedScopes.includes(registeredPropertyScheme.scope)) {
243
- extension.collector.warn(( localizeWithPath(
244
- 'vs/workbench/api/common/configurationExtensionPoint',
245
- 'config.property.defaultConfiguration.warning',
246
- "Cannot register configuration defaults for '{0}'. Only defaults for machine-overridable, window, resource and language overridable scoped settings are supported.",
247
- key
248
- )));
249
- delete overrides[key];
250
- }
251
- }
252
- }
253
- return { overrides, source: { id: extension.description.identifier.value, displayName: extension.description.displayName } };
254
- }));
255
- _configDelta.addedDefaults = addedDefaultConfigurations;
256
- }
257
- });
258
- const configurationExtPoint = ExtensionsRegistry.registerExtensionPoint({
259
- extensionPoint: 'configuration',
260
- deps: [defaultConfigurationExtPoint],
261
- jsonSchema: {
262
- description: ( localizeWithPath(
263
- 'vs/workbench/api/common/configurationExtensionPoint',
264
- 'vscode.extension.contributes.configuration',
265
- 'Contributes configuration settings.'
266
- )),
267
- oneOf: [
268
- configurationEntrySchema,
269
- {
270
- type: 'array',
271
- items: configurationEntrySchema
272
- }
273
- ]
274
- }
275
- });
276
- const extensionConfigurations = ( new ExtensionIdentifierMap());
277
- configurationExtPoint.setHandler((extensions, { added, removed }) => {
278
- _configDelta ??= {};
279
- if (removed.length) {
280
- const removedConfigurations = [];
281
- for (const extension of removed) {
282
- removedConfigurations.push(...(extensionConfigurations.get(extension.description.identifier) || []));
283
- extensionConfigurations.delete(extension.description.identifier);
284
- }
285
- _configDelta.removedConfigurations = removedConfigurations;
286
- }
287
- const seenProperties = ( new Set());
288
- function handleConfiguration(node, extension) {
289
- const configurations = [];
290
- const configuration = deepClone(node);
291
- if (configuration.title && (typeof configuration.title !== 'string')) {
292
- extension.collector.error(( localizeWithPath(
293
- 'vs/workbench/api/common/configurationExtensionPoint',
294
- 'invalid.title',
295
- "'configuration.title' must be a string"
296
- )));
297
- }
298
- validateProperties(configuration, extension);
299
- configuration.id = node.id || extension.description.identifier.value;
300
- configuration.extensionInfo = { id: extension.description.identifier.value, displayName: extension.description.displayName };
301
- configuration.restrictedProperties = extension.description.capabilities?.untrustedWorkspaces?.supported === 'limited' ? extension.description.capabilities?.untrustedWorkspaces.restrictedConfigurations : undefined;
302
- configuration.title = configuration.title || extension.description.displayName || extension.description.identifier.value;
303
- configurations.push(configuration);
304
- return configurations;
305
- }
306
- function validateProperties(configuration, extension) {
307
- const properties = configuration.properties;
308
- if (properties) {
309
- if (typeof properties !== 'object') {
310
- extension.collector.error(( localizeWithPath(
311
- 'vs/workbench/api/common/configurationExtensionPoint',
312
- 'invalid.properties',
313
- "'configuration.properties' must be an object"
314
- )));
315
- configuration.properties = {};
316
- }
317
- for (const key in properties) {
318
- const propertyConfiguration = properties[key];
319
- const message = validateProperty(key, propertyConfiguration);
320
- if (message) {
321
- delete properties[key];
322
- extension.collector.warn(message);
323
- continue;
324
- }
325
- if (( seenProperties.has(key))) {
326
- delete properties[key];
327
- extension.collector.warn(( localizeWithPath(
328
- 'vs/workbench/api/common/configurationExtensionPoint',
329
- 'config.property.duplicate',
330
- "Cannot register '{0}'. This property is already registered.",
331
- key
332
- )));
333
- continue;
334
- }
335
- if (!isObject(propertyConfiguration)) {
336
- delete properties[key];
337
- extension.collector.error(( localizeWithPath(
338
- 'vs/workbench/api/common/configurationExtensionPoint',
339
- 'invalid.property',
340
- "configuration.properties property '{0}' must be an object",
341
- key
342
- )));
343
- continue;
344
- }
345
- seenProperties.add(key);
346
- if (propertyConfiguration.scope) {
347
- if (( propertyConfiguration.scope.toString()) === 'application') {
348
- propertyConfiguration.scope = 1 ;
349
- }
350
- else if (( propertyConfiguration.scope.toString()) === 'machine') {
351
- propertyConfiguration.scope = 2 ;
352
- }
353
- else if (( propertyConfiguration.scope.toString()) === 'resource') {
354
- propertyConfiguration.scope = 4 ;
355
- }
356
- else if (( propertyConfiguration.scope.toString()) === 'machine-overridable') {
357
- propertyConfiguration.scope = 6 ;
358
- }
359
- else if (( propertyConfiguration.scope.toString()) === 'language-overridable') {
360
- propertyConfiguration.scope = 5 ;
361
- }
362
- else {
363
- propertyConfiguration.scope = 3 ;
364
- }
365
- }
366
- else {
367
- propertyConfiguration.scope = 3 ;
368
- }
369
- }
370
- }
371
- const subNodes = configuration.allOf;
372
- if (subNodes) {
373
- extension.collector.error(( localizeWithPath(
374
- 'vs/workbench/api/common/configurationExtensionPoint',
375
- 'invalid.allOf',
376
- "'configuration.allOf' is deprecated and should no longer be used. Instead, pass multiple configuration sections as an array to the 'configuration' contribution point."
377
- )));
378
- for (const node of subNodes) {
379
- validateProperties(node, extension);
380
- }
381
- }
382
- }
383
- if (added.length) {
384
- const addedConfigurations = [];
385
- for (const extension of added) {
386
- const configurations = [];
387
- const value = extension.value;
388
- if (Array.isArray(value)) {
389
- value.forEach(v => configurations.push(...handleConfiguration(v, extension)));
390
- }
391
- else {
392
- configurations.push(...handleConfiguration(value, extension));
393
- }
394
- extensionConfigurations.set(extension.description.identifier, configurations);
395
- addedConfigurations.push(...configurations);
396
- }
397
- _configDelta.addedConfigurations = addedConfigurations;
398
- }
399
- configurationRegistry.deltaConfiguration(_configDelta);
400
- _configDelta = undefined;
401
- });
402
- jsonRegistry.registerSchema('vscode://schemas/workspaceConfig', {
403
- allowComments: true,
404
- allowTrailingCommas: true,
405
- default: {
406
- folders: [
407
- {
408
- path: ''
409
- }
410
- ],
411
- settings: {}
412
- },
413
- required: ['folders'],
414
- properties: {
415
- 'folders': {
416
- minItems: 0,
417
- uniqueItems: true,
418
- description: ( localizeWithPath(
419
- 'vs/workbench/api/common/configurationExtensionPoint',
420
- 'workspaceConfig.folders.description',
421
- "List of folders to be loaded in the workspace."
422
- )),
423
- items: {
424
- type: 'object',
425
- defaultSnippets: [{ body: { path: '$1' } }],
426
- oneOf: [{
427
- properties: {
428
- path: {
429
- type: 'string',
430
- description: ( localizeWithPath(
431
- 'vs/workbench/api/common/configurationExtensionPoint',
432
- 'workspaceConfig.path.description',
433
- "A file path. e.g. `/root/folderA` or `./folderA` for a relative path that will be resolved against the location of the workspace file."
434
- ))
435
- },
436
- name: {
437
- type: 'string',
438
- description: ( localizeWithPath(
439
- 'vs/workbench/api/common/configurationExtensionPoint',
440
- 'workspaceConfig.name.description',
441
- "An optional name for the folder. "
442
- ))
443
- }
444
- },
445
- required: ['path']
446
- }, {
447
- properties: {
448
- uri: {
449
- type: 'string',
450
- description: ( localizeWithPath(
451
- 'vs/workbench/api/common/configurationExtensionPoint',
452
- 'workspaceConfig.uri.description',
453
- "URI of the folder"
454
- ))
455
- },
456
- name: {
457
- type: 'string',
458
- description: ( localizeWithPath(
459
- 'vs/workbench/api/common/configurationExtensionPoint',
460
- 'workspaceConfig.name.description',
461
- "An optional name for the folder. "
462
- ))
463
- }
464
- },
465
- required: ['uri']
466
- }]
467
- }
468
- },
469
- 'settings': {
470
- type: 'object',
471
- default: {},
472
- description: ( localizeWithPath(
473
- 'vs/workbench/api/common/configurationExtensionPoint',
474
- 'workspaceConfig.settings.description',
475
- "Workspace settings"
476
- )),
477
- $ref: workspaceSettingsSchemaId
478
- },
479
- 'launch': {
480
- type: 'object',
481
- default: { configurations: [], compounds: [] },
482
- description: ( localizeWithPath(
483
- 'vs/workbench/api/common/configurationExtensionPoint',
484
- 'workspaceConfig.launch.description',
485
- "Workspace launch configurations"
486
- )),
487
- $ref: launchSchemaId
488
- },
489
- 'tasks': {
490
- type: 'object',
491
- default: { version: '2.0.0', tasks: [] },
492
- description: ( localizeWithPath(
493
- 'vs/workbench/api/common/configurationExtensionPoint',
494
- 'workspaceConfig.tasks.description',
495
- "Workspace task configurations"
496
- )),
497
- $ref: tasksSchemaId
498
- },
499
- 'extensions': {
500
- type: 'object',
501
- default: {},
502
- description: ( localizeWithPath(
503
- 'vs/workbench/api/common/configurationExtensionPoint',
504
- 'workspaceConfig.extensions.description',
505
- "Workspace extensions"
506
- )),
507
- $ref: 'vscode://schemas/extensions'
508
- },
509
- 'remoteAuthority': {
510
- type: 'string',
511
- doNotSuggest: true,
512
- description: ( localizeWithPath(
513
- 'vs/workbench/api/common/configurationExtensionPoint',
514
- 'workspaceConfig.remoteAuthority',
515
- "The remote server where the workspace is located."
516
- )),
517
- },
518
- 'transient': {
519
- type: 'boolean',
520
- doNotSuggest: true,
521
- description: ( localizeWithPath(
522
- 'vs/workbench/api/common/configurationExtensionPoint',
523
- 'workspaceConfig.transient',
524
- "A transient workspace will disappear when restarting or reloading."
525
- )),
526
- }
527
- },
528
- errorMessage: ( localizeWithPath(
529
- 'vs/workbench/api/common/configurationExtensionPoint',
530
- 'unknownWorkspaceProperty',
531
- "Unknown workspace configuration property"
532
- ))
533
- });
534
- class SettingsTableRenderer extends Disposable {
535
- constructor() {
536
- super(...arguments);
537
- this.type = 'table';
538
- }
539
- shouldRender(manifest) {
540
- return !!manifest.contributes?.configuration;
541
- }
542
- render(manifest) {
543
- const configuration = manifest.contributes?.configuration;
544
- let properties = {};
545
- if (Array.isArray(configuration)) {
546
- configuration.forEach(config => {
547
- properties = { ...properties, ...config.properties };
548
- });
549
- }
550
- else if (configuration) {
551
- properties = configuration.properties;
552
- }
553
- const contrib = properties ? ( Object.keys(properties)) : [];
554
- const headers = [( localizeWithPath(
555
- 'vs/workbench/api/common/configurationExtensionPoint',
556
- 'setting name',
557
- "ID"
558
- )), ( localizeWithPath(
559
- 'vs/workbench/api/common/configurationExtensionPoint',
560
- 'description',
561
- "Description"
562
- )), ( localizeWithPath(
563
- 'vs/workbench/api/common/configurationExtensionPoint',
564
- 'default',
565
- "Default"
566
- ))];
567
- const rows = ( contrib.sort((a, b) => a.localeCompare(b))
568
- .map(key => {
569
- return [
570
- ( new MarkdownString()).appendMarkdown(`\`${key}\``),
571
- properties[key].markdownDescription ? ( new MarkdownString(properties[key].markdownDescription, false)) : properties[key].description ?? '',
572
- ( new MarkdownString()).appendCodeblock('json', JSON.stringify(isUndefined(properties[key].default) ? getDefaultValue(properties[key].type) : properties[key].default, null, 2)),
573
- ];
574
- }));
575
- return {
576
- data: {
577
- headers,
578
- rows
579
- },
580
- dispose: () => { }
581
- };
582
- }
583
- }
584
- ( Registry.as(Extensions$2.ExtensionFeaturesRegistry)).registerExtensionFeature({
585
- id: 'configuration',
586
- label: ( localizeWithPath(
587
- 'vs/workbench/api/common/configurationExtensionPoint',
588
- 'settings',
589
- "Settings"
590
- )),
591
- access: {
592
- canToggle: false
593
- },
594
- renderer: ( new SyncDescriptor(SettingsTableRenderer)),
595
- });