@codingame/monaco-vscode-api 1.69.5 → 1.69.8

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,24 +1,28 @@
1
- import { _ as __decorate, a as __param } from './contextkey.js';
2
- import { h as IPolicyService, j as IUserDataProfilesService, E as Emitter, k as NullPolicyService, U as UserSettings } from './missing-services.js';
1
+ import { b as __decorate, d as __param } from './contextkey.js';
2
+ import { E as Emitter, U as UserSettings } from './polyfill.js';
3
+ import { e as IPolicyService, N as NullPolicyService, f as IUserDataProfilesService } from './missing-services.js';
3
4
  import { b as isEmptyObject } from './types.js';
4
5
  import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
5
6
  import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
6
- import { Extensions, machineOverridableSettings, windowSettings, resourceSettings, allSettings, OVERRIDE_PROPERTY_PATTERN, resourceLanguageSettingsSchemaId, applicationSettings, machineSettings, OVERRIDE_PROPERTY_REGEX, overrideIdentifiersFromKey } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
7
+ import { Extensions, OVERRIDE_PROPERTY_REGEX, overrideIdentifiersFromKey, machineOverridableSettings, windowSettings, resourceSettings, allSettings, OVERRIDE_PROPERTY_PATTERN, resourceLanguageSettingsSchemaId, applicationSettings, machineSettings } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
7
8
  import { ConfigurationModel, Configuration, ConfigurationChangeEvent } from 'monaco-editor/esm/vs/platform/configuration/common/configurationModels.js';
8
- import { IConfigurationService, addToValueTree, toValuesTree } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
9
+ import { addToValueTree, toValuesTree, IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
9
10
  import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
10
11
  import { coalesce } from 'monaco-editor/esm/vs/base/common/arrays.js';
11
12
  import { equals } from 'monaco-editor/esm/vs/base/common/objects.js';
12
13
  import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
13
14
  import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
14
- import { isArray } from 'monaco-editor/esm/vs/base/common/types.js';
15
+ import { isArray, isUndefined } from 'monaco-editor/esm/vs/base/common/types.js';
15
16
  import { extUriBiasedIgnorePathCase } from 'monaco-editor/esm/vs/base/common/resources.js';
16
17
  import { RunOnceScheduler } from 'monaco-editor/esm/vs/base/common/async.js';
17
- import { bf as Position$2, bg as configurationDefaultsSchemaId } from './extHost.js';
18
- export { bh as ConfigurationScope } from './extHost.js';
18
+ import { bf as Position, bg as getTelemetryLevel, bh as configurationDefaultsSchemaId } from './extHost.js';
19
+ export { bi as ConfigurationScope } from './extHost.js';
19
20
  import { IModelService } from 'monaco-editor/esm/vs/editor/common/services/model.js';
20
21
  import { ILanguageService } from 'monaco-editor/esm/vs/editor/common/languages/language.js';
21
- import { g as IWorkbenchEnvironmentService, I as IFileService } from './services2.js';
22
+ import { e as IWorkbenchEnvironmentService, d as IFileService } from './services2.js';
23
+ import { onUnexpectedError } from 'monaco-editor/esm/vs/base/common/errors.js';
24
+ import { language } from 'monaco-editor/esm/vs/base/common/platform.js';
25
+ import { createDecorator } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
22
26
  import { localize } from 'monaco-editor/esm/vs/nls.js';
23
27
  import { IWorkspaceContextService } from 'monaco-editor/esm/vs/platform/workspace/common/workspace.js';
24
28
  import { IWorkspaceTrustManagementService } from 'monaco-editor/esm/vs/platform/workspace/common/workspaceTrust.js';
@@ -46,18 +50,18 @@ function isConfigurationUpdateOverrides(thing) {
46
50
  class DefaultConfiguration extends Disposable {
47
51
  constructor() {
48
52
  super(...arguments);
49
- this._onDidChangeConfiguration = this._register(( (new Emitter())));
53
+ this._onDidChangeConfiguration = this._register(( new Emitter()));
50
54
  this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
51
55
  }
52
56
  get configurationModel() {
53
57
  if (!this._configurationModel) {
54
- this._configurationModel = ( (new DefaultConfigurationModel(this.getConfigurationDefaultOverrides())));
58
+ this._configurationModel = ( new DefaultConfigurationModel(this.getConfigurationDefaultOverrides()));
55
59
  }
56
60
  return this._configurationModel;
57
61
  }
58
62
  async initialize() {
59
63
  this._configurationModel = undefined;
60
- this._register(( (Registry.as(Extensions.Configuration))).onDidUpdateConfiguration(({ properties, defaultsOverrides }) => this.onDidUpdateConfiguration(properties, defaultsOverrides)));
64
+ this._register(( Registry.as(Extensions.Configuration)).onDidUpdateConfiguration(({ properties, defaultsOverrides }) => this.onDidUpdateConfiguration(properties, defaultsOverrides)));
61
65
  return this.configurationModel;
62
66
  }
63
67
  reload() {
@@ -74,8 +78,8 @@ class DefaultConfiguration extends Disposable {
74
78
  }
75
79
  class DefaultConfigurationModel extends ConfigurationModel {
76
80
  constructor(configurationDefaultsOverrides = {}) {
77
- const properties = ( (Registry.as(Extensions.Configuration))).getConfigurationProperties();
78
- const keys = ( (Object.keys(properties)));
81
+ const properties = ( Registry.as(Extensions.Configuration)).getConfigurationProperties();
82
+ const keys = ( Object.keys(properties));
79
83
  const contents = Object.create(null);
80
84
  const overrides = [];
81
85
  for (const key in properties) {
@@ -83,11 +87,11 @@ class DefaultConfigurationModel extends ConfigurationModel {
83
87
  const value = defaultOverrideValue !== undefined ? defaultOverrideValue : properties[key].default;
84
88
  addToValueTree(contents, key, value, message => console.error(`Conflict in default settings: ${message}`));
85
89
  }
86
- for (const key of ( (Object.keys(contents)))) {
90
+ for (const key of ( Object.keys(contents))) {
87
91
  if (OVERRIDE_PROPERTY_REGEX.test(key)) {
88
92
  overrides.push({
89
93
  identifiers: overrideIdentifiersFromKey(key),
90
- keys: ( (Object.keys(contents[key]))),
94
+ keys: ( Object.keys(contents[key])),
91
95
  contents: toValuesTree(contents[key], message => console.error(`Conflict in default settings file: ${message}`)),
92
96
  });
93
97
  }
@@ -98,7 +102,7 @@ class DefaultConfigurationModel extends ConfigurationModel {
98
102
  class NullPolicyConfiguration {
99
103
  constructor() {
100
104
  this.onDidChangeConfiguration = Event.None;
101
- this.configurationModel = ( (new ConfigurationModel()));
105
+ this.configurationModel = ( new ConfigurationModel());
102
106
  }
103
107
  async initialize() { return this.configurationModel; }
104
108
  }
@@ -108,9 +112,9 @@ let PolicyConfiguration = class PolicyConfiguration extends Disposable {
108
112
  this.defaultConfiguration = defaultConfiguration;
109
113
  this.policyService = policyService;
110
114
  this.logService = logService;
111
- this._onDidChangeConfiguration = this._register(( (new Emitter())));
115
+ this._onDidChangeConfiguration = this._register(( new Emitter()));
112
116
  this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
113
- this._configurationModel = ( (new ConfigurationModel()));
117
+ this._configurationModel = ( new ConfigurationModel());
114
118
  }
115
119
  get configurationModel() { return this._configurationModel; }
116
120
  async initialize() {
@@ -122,7 +126,7 @@ let PolicyConfiguration = class PolicyConfiguration extends Disposable {
122
126
  async registerPolicyDefinitions(properties) {
123
127
  const policyDefinitions = {};
124
128
  const keys = [];
125
- const configurationProperties = ( (Registry.as(Extensions.Configuration))).getConfigurationProperties();
129
+ const configurationProperties = ( Registry.as(Extensions.Configuration)).getConfigurationProperties();
126
130
  for (const key of properties) {
127
131
  const config = configurationProperties[key];
128
132
  if (!config) {
@@ -144,12 +148,12 @@ let PolicyConfiguration = class PolicyConfiguration extends Disposable {
144
148
  return keys;
145
149
  }
146
150
  onDidChangePolicies(policyNames) {
147
- const policyConfigurations = ( (Registry.as(Extensions.Configuration))).getPolicyConfigurations();
151
+ const policyConfigurations = ( Registry.as(Extensions.Configuration)).getPolicyConfigurations();
148
152
  const keys = coalesce(policyNames.map(policyName => policyConfigurations.get(policyName)));
149
153
  this.update(keys, true);
150
154
  }
151
155
  update(keys, trigger) {
152
- const configurationProperties = ( (Registry.as(Extensions.Configuration))).getConfigurationProperties();
156
+ const configurationProperties = ( Registry.as(Extensions.Configuration)).getConfigurationProperties();
153
157
  const changed = [];
154
158
  const wasEmpty = this._configurationModel.isEmpty();
155
159
  for (const key of keys) {
@@ -168,7 +172,7 @@ let PolicyConfiguration = class PolicyConfiguration extends Disposable {
168
172
  }
169
173
  if (changed.length) {
170
174
  const old = this._configurationModel;
171
- this._configurationModel = ( (new ConfigurationModel()));
175
+ this._configurationModel = ( new ConfigurationModel());
172
176
  for (const key of old.keys) {
173
177
  this._configurationModel.setValue(key, old.getValue(key));
174
178
  }
@@ -186,38 +190,33 @@ let PolicyConfiguration = class PolicyConfiguration extends Disposable {
186
190
  }
187
191
  }
188
192
  };
189
- PolicyConfiguration = ( (__decorate([
190
- ( (__param(1, IPolicyService))),
191
- ( (__param(2, ILogService)))
192
- ], PolicyConfiguration)));
193
+ PolicyConfiguration = ( __decorate([
194
+ ( __param(1, IPolicyService)),
195
+ ( __param(2, ILogService))
196
+ ], PolicyConfiguration));
193
197
  class ConfigurationService extends Disposable {
194
198
  constructor(settingsResource, fileService, policyService, logService) {
195
199
  super();
196
200
  this.settingsResource = settingsResource;
197
- this._onDidChangeConfiguration = this._register(( (new Emitter())));
201
+ this._onDidChangeConfiguration = this._register(( new Emitter()));
198
202
  this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
199
- this.defaultConfiguration = this._register(( (new DefaultConfiguration())));
200
- this.policyConfiguration = policyService instanceof NullPolicyService ? ( (new NullPolicyConfiguration())) : this._register(( (new PolicyConfiguration(this.defaultConfiguration, policyService, logService))));
201
- this.userConfiguration = this._register(( (new UserSettings(this.settingsResource, undefined, extUriBiasedIgnorePathCase, fileService))));
202
- this.configuration = ( (new Configuration(
203
+ this.defaultConfiguration = this._register(( new DefaultConfiguration()));
204
+ this.policyConfiguration = policyService instanceof NullPolicyService ? ( new NullPolicyConfiguration()) : this._register(( new PolicyConfiguration(this.defaultConfiguration, policyService, logService)));
205
+ this.userConfiguration = this._register(( new UserSettings(this.settingsResource, undefined, extUriBiasedIgnorePathCase, fileService)));
206
+ this.configuration = ( new Configuration(
203
207
  this.defaultConfiguration.configurationModel,
204
208
  this.policyConfiguration.configurationModel,
205
- (new ConfigurationModel()),
206
- (new ConfigurationModel())
207
- )));
208
- this.reloadConfigurationScheduler = this._register(( (new RunOnceScheduler(() => this.reloadConfiguration(), 50))));
209
+ ( new ConfigurationModel()),
210
+ ( new ConfigurationModel())
211
+ ));
212
+ this.reloadConfigurationScheduler = this._register(( new RunOnceScheduler(() => this.reloadConfiguration(), 50)));
209
213
  this._register(this.defaultConfiguration.onDidChangeConfiguration(({ defaults, properties }) => this.onDidDefaultConfigurationChange(defaults, properties)));
210
214
  this._register(this.policyConfiguration.onDidChangeConfiguration(model => this.onDidPolicyConfigurationChange(model)));
211
215
  this._register(this.userConfiguration.onDidChange(() => this.reloadConfigurationScheduler.schedule()));
212
216
  }
213
217
  async initialize() {
214
218
  const [defaultModel, policyModel, userModel] = await Promise.all([this.defaultConfiguration.initialize(), this.policyConfiguration.initialize(), this.userConfiguration.loadConfiguration()]);
215
- this.configuration = ( (new Configuration(
216
- defaultModel,
217
- policyModel,
218
- (new ConfigurationModel()),
219
- userModel
220
- )));
219
+ this.configuration = ( new Configuration(defaultModel, policyModel, ( new ConfigurationModel()), userModel));
221
220
  }
222
221
  getConfigurationData() {
223
222
  return this.configuration.toData();
@@ -228,15 +227,13 @@ class ConfigurationService extends Disposable {
228
227
  return this.configuration.getValue(section, overrides, undefined);
229
228
  }
230
229
  updateValue(key, value, arg3, arg4) {
231
- return Promise.reject(( (new Error('not supported'))));
230
+ return Promise.reject(( new Error('not supported')));
232
231
  }
233
232
  inspect(key) {
234
233
  return this.configuration.inspect(key, {}, undefined);
235
234
  }
236
235
  keys() {
237
- return (
238
- (this.configuration.keys(undefined))
239
- );
236
+ return ( this.configuration.keys(undefined));
240
237
  }
241
238
  async reloadConfiguration() {
242
239
  const configurationModel = await this.userConfiguration.loadConfiguration();
@@ -258,7 +255,7 @@ class ConfigurationService extends Disposable {
258
255
  this.trigger(change, previous, 7 );
259
256
  }
260
257
  trigger(configurationChange, previous, source) {
261
- const event = ( (new ConfigurationChangeEvent(configurationChange, { data: previous }, this.configuration)));
258
+ const event = ( new ConfigurationChangeEvent(configurationChange, { data: previous }, this.configuration));
262
259
  event.source = source;
263
260
  event.sourceConfig = this.getTargetConfiguration(source);
264
261
  this._onDidChangeConfiguration.fire(event);
@@ -279,13 +276,13 @@ let TextResourceConfigurationService = class TextResourceConfigurationService ex
279
276
  this.configurationService = configurationService;
280
277
  this.modelService = modelService;
281
278
  this.languageService = languageService;
282
- this._onDidChangeConfiguration = this._register(( (new Emitter())));
279
+ this._onDidChangeConfiguration = this._register(( new Emitter()));
283
280
  this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
284
281
  this._register(this.configurationService.onDidChangeConfiguration(e => this._onDidChangeConfiguration.fire(this.toResourceConfigurationChangeEvent(e))));
285
282
  }
286
283
  getValue(resource, arg2, arg3) {
287
284
  if (typeof arg3 === 'string') {
288
- return this._getValue(resource, Position$2.isIPosition(arg2) ? arg2 : null, arg3);
285
+ return this._getValue(resource, Position.isIPosition(arg2) ? arg2 : null, arg3);
289
286
  }
290
287
  return this._getValue(resource, null, typeof arg2 === 'string' ? arg2 : undefined);
291
288
  }
@@ -372,11 +369,11 @@ let TextResourceConfigurationService = class TextResourceConfigurationService ex
372
369
  };
373
370
  }
374
371
  };
375
- TextResourceConfigurationService = ( (__decorate([
376
- ( (__param(0, IConfigurationService))),
377
- ( (__param(1, IModelService))),
378
- ( (__param(2, ILanguageService)))
379
- ], TextResourceConfigurationService)));
372
+ TextResourceConfigurationService = ( __decorate([
373
+ ( __param(0, IConfigurationService)),
374
+ ( __param(1, IModelService)),
375
+ ( __param(2, ILanguageService))
376
+ ], TextResourceConfigurationService));
380
377
  const FOLDER_CONFIG_FOLDER_NAME = '.vscode';
381
378
  const defaultSettingsSchemaId = 'vscode://schemas/settings/default';
382
379
  const userSettingsSchemaId = 'vscode://schemas/settings/user';
@@ -391,6 +388,283 @@ WORKSPACE_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${FOLDER_CONFIG_
391
388
  WORKSPACE_STANDALONE_CONFIGURATIONS[LAUNCH_CONFIGURATION_KEY] = `${FOLDER_CONFIG_FOLDER_NAME}/${LAUNCH_CONFIGURATION_KEY}.json`;
392
389
  const USER_STANDALONE_CONFIGURATIONS = Object.create(null);
393
390
  USER_STANDALONE_CONFIGURATIONS[TASKS_CONFIGURATION_KEY] = `${TASKS_CONFIGURATION_KEY}.json`;
391
+ class Memento {
392
+ constructor(id, storageService) {
393
+ this.storageService = storageService;
394
+ this.id = Memento.COMMON_PREFIX + id;
395
+ }
396
+ getMemento(scope, target) {
397
+ switch (scope) {
398
+ case 1 : {
399
+ let workspaceMemento = Memento.workspaceMementos.get(this.id);
400
+ if (!workspaceMemento) {
401
+ workspaceMemento = ( new ScopedMemento(this.id, scope, target, this.storageService));
402
+ Memento.workspaceMementos.set(this.id, workspaceMemento);
403
+ }
404
+ return workspaceMemento.getMemento();
405
+ }
406
+ case 0 : {
407
+ let profileMemento = Memento.profileMementos.get(this.id);
408
+ if (!profileMemento) {
409
+ profileMemento = ( new ScopedMemento(this.id, scope, target, this.storageService));
410
+ Memento.profileMementos.set(this.id, profileMemento);
411
+ }
412
+ return profileMemento.getMemento();
413
+ }
414
+ case -1 : {
415
+ let applicationMemento = Memento.applicationMementos.get(this.id);
416
+ if (!applicationMemento) {
417
+ applicationMemento = ( new ScopedMemento(this.id, scope, target, this.storageService));
418
+ Memento.applicationMementos.set(this.id, applicationMemento);
419
+ }
420
+ return applicationMemento.getMemento();
421
+ }
422
+ }
423
+ }
424
+ saveMemento() {
425
+ Memento.workspaceMementos.get(this.id)?.save();
426
+ Memento.profileMementos.get(this.id)?.save();
427
+ Memento.applicationMementos.get(this.id)?.save();
428
+ }
429
+ static clear(scope) {
430
+ switch (scope) {
431
+ case 1 :
432
+ Memento.workspaceMementos.clear();
433
+ break;
434
+ case 0 :
435
+ Memento.profileMementos.clear();
436
+ break;
437
+ case -1 :
438
+ Memento.applicationMementos.clear();
439
+ break;
440
+ }
441
+ }
442
+ }
443
+ Memento.applicationMementos = ( new Map());
444
+ Memento.profileMementos = ( new Map());
445
+ Memento.workspaceMementos = ( new Map());
446
+ Memento.COMMON_PREFIX = 'memento/';
447
+ class ScopedMemento {
448
+ constructor(id, scope, target, storageService) {
449
+ this.id = id;
450
+ this.scope = scope;
451
+ this.target = target;
452
+ this.storageService = storageService;
453
+ this.mementoObj = this.load();
454
+ }
455
+ getMemento() {
456
+ return this.mementoObj;
457
+ }
458
+ load() {
459
+ const memento = this.storageService.get(this.id, this.scope);
460
+ if (memento) {
461
+ try {
462
+ return JSON.parse(memento);
463
+ }
464
+ catch (error) {
465
+ onUnexpectedError(`[memento]: failed to parse contents: ${error} (id: ${this.id}, scope: ${this.scope}, contents: ${memento})`);
466
+ }
467
+ }
468
+ return {};
469
+ }
470
+ save() {
471
+ if (!isEmptyObject(this.mementoObj)) {
472
+ this.storageService.store(this.id, JSON.stringify(this.mementoObj), this.scope, this.target);
473
+ }
474
+ else {
475
+ this.storageService.remove(this.id, this.scope);
476
+ }
477
+ }
478
+ }
479
+ const ASSIGNMENT_STORAGE_KEY = 'VSCode.ABExp.FeatureData';
480
+ const ASSIGNMENT_REFETCH_INTERVAL = 0;
481
+ var TargetPopulation;
482
+ ( (function(TargetPopulation) {
483
+ TargetPopulation["Team"] = "team";
484
+ TargetPopulation["Internal"] = "internal";
485
+ TargetPopulation["Insiders"] = "insider";
486
+ TargetPopulation["Public"] = "public";
487
+ })(TargetPopulation || (TargetPopulation = {})));
488
+ var Filters;
489
+ ( (function(Filters) {
490
+ Filters["Market"] = "X-MSEdge-Market";
491
+ Filters["CorpNet"] = "X-FD-Corpnet";
492
+ Filters["ApplicationVersion"] = "X-VSCode-AppVersion";
493
+ Filters["Build"] = "X-VSCode-Build";
494
+ Filters["ClientId"] = "X-MSEdge-ClientId";
495
+ Filters["ExtensionName"] = "X-VSCode-ExtensionName";
496
+ Filters["ExtensionVersion"] = "X-VSCode-ExtensionVersion";
497
+ Filters["Language"] = "X-VSCode-Language";
498
+ Filters["TargetPopulation"] = "X-VSCode-TargetPopulation";
499
+ })(Filters || (Filters = {})));
500
+ class AssignmentFilterProvider {
501
+ constructor(version, appName, machineId, targetPopulation) {
502
+ this.version = version;
503
+ this.appName = appName;
504
+ this.machineId = machineId;
505
+ this.targetPopulation = targetPopulation;
506
+ }
507
+ getFilterValue(filter) {
508
+ switch (filter) {
509
+ case Filters.ApplicationVersion:
510
+ return this.version;
511
+ case Filters.Build:
512
+ return this.appName;
513
+ case Filters.ClientId:
514
+ return this.machineId;
515
+ case Filters.Language:
516
+ return language;
517
+ case Filters.ExtensionName:
518
+ return 'vscode-core';
519
+ case Filters.ExtensionVersion:
520
+ return '999999.0';
521
+ case Filters.TargetPopulation:
522
+ return this.targetPopulation;
523
+ default:
524
+ return '';
525
+ }
526
+ }
527
+ getFilters() {
528
+ const filters = ( new Map());
529
+ const filterValues = ( Object.values(Filters));
530
+ for (const value of filterValues) {
531
+ filters.set(value, this.getFilterValue(value));
532
+ }
533
+ return filters;
534
+ }
535
+ }
536
+ class BaseAssignmentService {
537
+ constructor(getMachineId, configurationService, productService, telemetry, keyValueStorage) {
538
+ this.getMachineId = getMachineId;
539
+ this.configurationService = configurationService;
540
+ this.productService = productService;
541
+ this.telemetry = telemetry;
542
+ this.keyValueStorage = keyValueStorage;
543
+ this.networkInitialized = false;
544
+ if (productService.tasConfig && this.experimentsEnabled && getTelemetryLevel(this.configurationService) === 3 ) {
545
+ this.tasClient = this.setupTASClient();
546
+ }
547
+ const overrideDelaySetting = this.configurationService.getValue('experiments.overrideDelay');
548
+ const overrideDelay = typeof overrideDelaySetting === 'number' ? overrideDelaySetting : 0;
549
+ this.overrideInitDelay = ( new Promise(resolve => setTimeout(resolve, overrideDelay)));
550
+ }
551
+ get experimentsEnabled() {
552
+ return true;
553
+ }
554
+ async getTreatment(name) {
555
+ await this.overrideInitDelay;
556
+ const override = this.configurationService.getValue('experiments.override.' + name);
557
+ if (override !== undefined) {
558
+ return override;
559
+ }
560
+ if (!this.tasClient) {
561
+ return undefined;
562
+ }
563
+ if (!this.experimentsEnabled) {
564
+ return undefined;
565
+ }
566
+ let result;
567
+ const client = await this.tasClient;
568
+ if (this.networkInitialized) {
569
+ result = client.getTreatmentVariable('vscode', name);
570
+ }
571
+ else {
572
+ result = await client.getTreatmentVariableAsync('vscode', name, true);
573
+ }
574
+ result = client.getTreatmentVariable('vscode', name);
575
+ return result;
576
+ }
577
+ async setupTASClient() {
578
+ const targetPopulation = this.productService.quality === 'stable' ? TargetPopulation.Public : TargetPopulation.Insiders;
579
+ const machineId = await this.getMachineId();
580
+ const filterProvider = ( new AssignmentFilterProvider(
581
+ this.productService.version,
582
+ this.productService.nameLong,
583
+ machineId,
584
+ targetPopulation
585
+ ));
586
+ const tasConfig = this.productService.tasConfig;
587
+ const tasClient = new ((await import('tas-client-umd').then(module => module.default ?? module)).ExperimentationService)({
588
+ filterProviders: [filterProvider],
589
+ telemetry: this.telemetry,
590
+ storageKey: ASSIGNMENT_STORAGE_KEY,
591
+ keyValueStorage: this.keyValueStorage,
592
+ featuresTelemetryPropertyName: tasConfig.featuresTelemetryPropertyName,
593
+ assignmentContextTelemetryPropertyName: tasConfig.assignmentContextTelemetryPropertyName,
594
+ telemetryEventName: tasConfig.telemetryEventName,
595
+ endpoint: tasConfig.endpoint,
596
+ refetchInterval: ASSIGNMENT_REFETCH_INTERVAL,
597
+ });
598
+ await tasClient.initializePromise;
599
+ tasClient.initialFetch.then(() => this.networkInitialized = true);
600
+ return tasClient;
601
+ }
602
+ }
603
+ const IWorkbenchAssignmentService = ( createDecorator('WorkbenchAssignmentService'));
604
+ class MementoKeyValueStorage {
605
+ constructor(memento) {
606
+ this.memento = memento;
607
+ this.mementoObj = memento.getMemento(-1 , 1 );
608
+ }
609
+ async getValue(key, defaultValue) {
610
+ const value = await this.mementoObj[key];
611
+ return value || defaultValue;
612
+ }
613
+ setValue(key, value) {
614
+ this.mementoObj[key] = value;
615
+ this.memento.saveMemento();
616
+ }
617
+ }
618
+ class WorkbenchAssignmentServiceTelemetry {
619
+ constructor(telemetryService, productService) {
620
+ this.telemetryService = telemetryService;
621
+ this.productService = productService;
622
+ }
623
+ get assignmentContext() {
624
+ return this._lastAssignmentContext?.split(';');
625
+ }
626
+ setSharedProperty(name, value) {
627
+ if (name === this.productService.tasConfig?.assignmentContextTelemetryPropertyName) {
628
+ this._lastAssignmentContext = value;
629
+ }
630
+ this.telemetryService.setExperimentProperty(name, value);
631
+ }
632
+ postEvent(eventName, props) {
633
+ const data = {};
634
+ for (const [key, value] of props.entries()) {
635
+ data[key] = value;
636
+ }
637
+ this.telemetryService.publicLog(eventName, data);
638
+ }
639
+ }
640
+ (class WorkbenchAssignmentService extends BaseAssignmentService {
641
+ constructor(telemetryService, storageService, configurationService, productService) {
642
+ super(() => {
643
+ return telemetryService.getTelemetryInfo().then(telemetryInfo => {
644
+ return telemetryInfo.machineId;
645
+ });
646
+ }, configurationService, productService, ( new WorkbenchAssignmentServiceTelemetry(telemetryService, productService)), ( new MementoKeyValueStorage(( new Memento('experiment.service.memento', storageService)))));
647
+ this.telemetryService = telemetryService;
648
+ }
649
+ get experimentsEnabled() {
650
+ return this.configurationService.getValue('workbench.enableExperiments') === true;
651
+ }
652
+ async getTreatment(name) {
653
+ const result = await super.getTreatment(name);
654
+ this.telemetryService.publicLog2('tasClientReadTreatmentComplete', { treatmentName: name, treatmentValue: JSON.stringify(result) });
655
+ return result;
656
+ }
657
+ async getCurrentExperiments() {
658
+ if (!this.tasClient) {
659
+ return undefined;
660
+ }
661
+ if (!this.experimentsEnabled) {
662
+ return undefined;
663
+ }
664
+ await this.tasClient;
665
+ return this.telemetry?.assignmentContext;
666
+ }
667
+ });
394
668
  let RegisterConfigurationSchemasContribution = class RegisterConfigurationSchemasContribution extends Disposable {
395
669
  constructor(workspaceContextService, environmentService, workspaceTrustManagementService) {
396
670
  super();
@@ -398,13 +672,13 @@ let RegisterConfigurationSchemasContribution = class RegisterConfigurationSchema
398
672
  this.environmentService = environmentService;
399
673
  this.workspaceTrustManagementService = workspaceTrustManagementService;
400
674
  this.registerConfigurationSchemas();
401
- const configurationRegistry = ( (Registry.as(Extensions.Configuration)));
675
+ const configurationRegistry = ( Registry.as(Extensions.Configuration));
402
676
  this._register(configurationRegistry.onDidUpdateConfiguration(e => this.registerConfigurationSchemas()));
403
677
  this._register(configurationRegistry.onDidSchemaChange(e => this.registerConfigurationSchemas()));
404
678
  this._register(workspaceTrustManagementService.onDidChangeTrust(() => this.registerConfigurationSchemas()));
405
679
  }
406
680
  registerConfigurationSchemas() {
407
- const jsonRegistry = ( (Registry.as(Extensions$1.JSONContribution)));
681
+ const jsonRegistry = ( Registry.as(Extensions$1.JSONContribution));
408
682
  const allSettingsSchema = {
409
683
  properties: allSettings.properties,
410
684
  patternProperties: allSettings.patternProperties,
@@ -461,14 +735,14 @@ let RegisterConfigurationSchemasContribution = class RegisterConfigurationSchema
461
735
  allowComments: true
462
736
  };
463
737
  jsonRegistry.registerSchema(defaultSettingsSchemaId, {
464
- properties: ( (Object.keys(allSettings.properties))).reduce((result, key) => {
738
+ properties: ( Object.keys(allSettings.properties)).reduce((result, key) => {
465
739
  result[key] = {
466
740
  ...allSettings.properties[key],
467
741
  deprecationMessage: undefined
468
742
  };
469
743
  return result;
470
744
  }, {}),
471
- patternProperties: ( (Object.keys(allSettings.patternProperties))).reduce((result, key) => {
745
+ patternProperties: ( Object.keys(allSettings.patternProperties)).reduce((result, key) => {
472
746
  result[key] = {
473
747
  ...allSettings.patternProperties[key],
474
748
  deprecationMessage: undefined
@@ -502,10 +776,10 @@ let RegisterConfigurationSchemasContribution = class RegisterConfigurationSchema
502
776
  }
503
777
  jsonRegistry.registerSchema(configurationDefaultsSchemaId, {
504
778
  type: 'object',
505
- description: ( (localize(
779
+ description: ( localize(
506
780
  'configurationDefaults.description',
507
781
  'Contribute defaults for configurations'
508
- ))),
782
+ )),
509
783
  properties: {
510
784
  ...machineOverridableSettings.properties,
511
785
  ...windowSettings.properties,
@@ -534,16 +808,53 @@ let RegisterConfigurationSchemasContribution = class RegisterConfigurationSchema
534
808
  return result;
535
809
  }
536
810
  };
537
- RegisterConfigurationSchemasContribution = ( (__decorate([
538
- ( (__param(0, IWorkspaceContextService))),
539
- ( (__param(1, IWorkbenchEnvironmentService))),
540
- ( (__param(2, IWorkspaceTrustManagementService)))
541
- ], RegisterConfigurationSchemasContribution)));
811
+ RegisterConfigurationSchemasContribution = ( __decorate([
812
+ ( __param(0, IWorkspaceContextService)),
813
+ ( __param(1, IWorkbenchEnvironmentService)),
814
+ ( __param(2, IWorkspaceTrustManagementService))
815
+ ], RegisterConfigurationSchemasContribution));
816
+ let UpdateExperimentalSettingsDefaults = class UpdateExperimentalSettingsDefaults extends Disposable {
817
+ constructor(workbenchAssignmentService) {
818
+ super();
819
+ this.workbenchAssignmentService = workbenchAssignmentService;
820
+ this.processedExperimentalSettings = ( new Set());
821
+ this.configurationRegistry = ( Registry.as(Extensions.Configuration));
822
+ this.processExperimentalSettings(( Object.keys(this.configurationRegistry.getConfigurationProperties())));
823
+ this._register(this.configurationRegistry.onDidUpdateConfiguration(({ properties }) => this.processExperimentalSettings(properties)));
824
+ }
825
+ async processExperimentalSettings(properties) {
826
+ const overrides = {};
827
+ const allProperties = this.configurationRegistry.getConfigurationProperties();
828
+ for (const property of properties) {
829
+ const schema = allProperties[property];
830
+ if (!schema?.tags?.includes('experimental')) {
831
+ continue;
832
+ }
833
+ if (this.processedExperimentalSettings.has(property)) {
834
+ continue;
835
+ }
836
+ this.processedExperimentalSettings.add(property);
837
+ try {
838
+ const value = await this.workbenchAssignmentService.getTreatment(`config.${property}`);
839
+ if (!isUndefined(value) && !equals(value, schema.default)) {
840
+ overrides[property] = value;
841
+ }
842
+ }
843
+ catch (error) { }
844
+ }
845
+ if (( Object.keys(overrides)).length) {
846
+ this.configurationRegistry.registerDefaultConfigurations([{ overrides, source: ( localize('experimental', "Experiments")) }]);
847
+ }
848
+ }
849
+ };
850
+ UpdateExperimentalSettingsDefaults = ( __decorate([
851
+ ( __param(0, IWorkbenchAssignmentService))
852
+ ], UpdateExperimentalSettingsDefaults));
542
853
  function updateUserConfiguration(configurationJson) {
543
854
  const userDataProfilesService = StandaloneServices.get(IUserDataProfilesService);
544
855
  void StandaloneServices.get(IFileService).writeFile(userDataProfilesService.defaultProfile.settingsResource, VSBuffer.fromString(configurationJson));
545
856
  }
546
- const configurationRegistry = ( Registry.as(Extensions.Configuration));
857
+ const configurationRegistry = Registry.as(Extensions.Configuration);
547
858
  let InjectedConfigurationService = class InjectedConfigurationService extends ConfigurationService {
548
859
  constructor(userDataProfilesService, fileService, policyService, logService) {
549
860
  super(userDataProfilesService.defaultProfile.settingsResource, fileService, policyService, logService);
@@ -562,12 +873,12 @@ let InjectedConfigurationService = class InjectedConfigurationService extends Co
562
873
  return Promise.reject(new Error('not supported'));
563
874
  }
564
875
  };
565
- InjectedConfigurationService = ( __decorate([
566
- ( __param(0, IUserDataProfilesService)),
567
- ( __param(1, IFileService)),
568
- ( __param(2, IPolicyService)),
569
- ( __param(3, ILogService))
570
- ], InjectedConfigurationService));
876
+ InjectedConfigurationService = __decorate([
877
+ __param(0, IUserDataProfilesService),
878
+ __param(1, IFileService),
879
+ __param(2, IPolicyService),
880
+ __param(3, ILogService)
881
+ ], InjectedConfigurationService);
571
882
  function initialize(instantiationService) {
572
883
  instantiationService.createInstance(RegisterConfigurationSchemasContribution);
573
884
  }
@@ -576,8 +887,8 @@ function getServiceOverride() {
576
887
  return {
577
888
  ...getServiceOverride$1(),
578
889
  ...getServiceOverride$2(),
579
- [( IConfigurationService.toString())]: new SyncDescriptor(InjectedConfigurationService),
580
- [( ITextResourceConfigurationService.toString())]: new SyncDescriptor(TextResourceConfigurationService)
890
+ [IConfigurationService.toString()]: new SyncDescriptor(InjectedConfigurationService),
891
+ [ITextResourceConfigurationService.toString()]: new SyncDescriptor(TextResourceConfigurationService)
581
892
  };
582
893
  }
583
894
  export { configurationRegistry, getServiceOverride as default, updateUserConfiguration };