@codingame/monaco-vscode-user-data-profile-service-override 5.3.0 → 6.0.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.
Files changed (25) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.js +7 -9
  3. package/vscode/src/vs/platform/userDataSync/common/extensionsSync.js +21 -20
  4. package/vscode/src/vs/platform/userDataSync/common/globalStateSync.js +26 -25
  5. package/vscode/src/vs/platform/userDataSync/common/keybindingsSync.js +26 -25
  6. package/vscode/src/vs/platform/userDataSync/common/settingsSync.js +20 -18
  7. package/vscode/src/vs/platform/userDataSync/common/snippetsSync.js +40 -40
  8. package/vscode/src/vs/platform/userDataSync/common/tasksSync.js +14 -14
  9. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/media/userDataProfilesEditor.css.js +6 -0
  10. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js +4 -3
  11. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.js +91 -25
  12. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditor.js +943 -0
  13. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditorModel.js +481 -0
  14. package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +2 -1
  15. package/vscode/src/vs/workbench/services/userDataProfile/browser/extensionsResource.js +14 -8
  16. package/vscode/src/vs/workbench/services/userDataProfile/browser/globalStateResource.js +10 -8
  17. package/vscode/src/vs/workbench/services/userDataProfile/browser/keybindingsResource.js +5 -4
  18. package/vscode/src/vs/workbench/services/userDataProfile/browser/settingsResource.js +7 -6
  19. package/vscode/src/vs/workbench/services/userDataProfile/browser/snippetsResource.js +4 -3
  20. package/vscode/src/vs/workbench/services/userDataProfile/browser/tasksResource.js +5 -4
  21. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.js +119 -70
  22. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileInit.js +9 -7
  23. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.js +1 -0
  24. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileStorageService.js +4 -3
  25. package/vscode/src/vs/workbench/services/userDataSync/browser/userDataSyncInit.js +15 -13
@@ -0,0 +1,481 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { Action, Separator } from 'vscode/vscode/vs/base/common/actions';
3
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
4
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
5
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
6
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
7
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
8
+ import { ProfileResourceType, toUserDataProfile, isUserDataProfile } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
9
+ import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
10
+ import { IUserDataProfileService, IUserDataProfileManagementService, IUserDataProfileImportExportService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
11
+ import { Disposable, toDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
12
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
13
+ import { equals } from 'vscode/vscode/vs/base/common/objects';
14
+ import { EditorModel } from 'vscode/vscode/vs/workbench/common/editor/editorModel';
15
+ import { ExtensionsResourceExportTreeItem, ExtensionsResourceImportTreeItem } from '../../../services/userDataProfile/browser/extensionsResource.js';
16
+ import { SettingsResourceTreeItem, SettingsResource } from '../../../services/userDataProfile/browser/settingsResource.js';
17
+ import { KeybindingsResourceTreeItem, KeybindingsResource } from '../../../services/userDataProfile/browser/keybindingsResource.js';
18
+ import { TasksResourceTreeItem, TasksResource } from '../../../services/userDataProfile/browser/tasksResource.js';
19
+ import { SnippetsResourceTreeItem, SnippetsResource } from '../../../services/userDataProfile/browser/snippetsResource.js';
20
+ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
21
+ import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
22
+ import { InMemoryFileSystemProvider } from 'vscode/vscode/vs/platform/files/common/inMemoryFilesystemProvider';
23
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
24
+ import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
25
+ import { RunOnceScheduler } from 'vscode/vscode/vs/base/common/async';
26
+
27
+ var UserDataProfilesEditorModel_1;
28
+ const _moduleId = "vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditorModel";
29
+ let AbstractUserDataProfileElement = class AbstractUserDataProfileElement extends Disposable {
30
+ constructor(name, icon, flags, isActive, userDataProfilesService, instantiationService) {
31
+ super();
32
+ this.userDataProfilesService = userDataProfilesService;
33
+ this.instantiationService = instantiationService;
34
+ this._onDidChange = this._register(( (new Emitter())));
35
+ this.onDidChange = this._onDidChange.event;
36
+ this._name = '';
37
+ this._active = false;
38
+ this._name = name;
39
+ this._icon = icon;
40
+ this._flags = flags;
41
+ this._active = isActive;
42
+ this._register(this.onDidChange(e => {
43
+ if (!e.message) {
44
+ this.validate();
45
+ }
46
+ if (this.primaryAction) {
47
+ this.primaryAction.enabled = !this.message;
48
+ }
49
+ }));
50
+ }
51
+ get name() { return this._name; }
52
+ set name(label) {
53
+ if (this._name !== label) {
54
+ this._name = label;
55
+ this._onDidChange.fire({ name: true });
56
+ }
57
+ }
58
+ get icon() { return this._icon; }
59
+ set icon(icon) {
60
+ if (this._icon !== icon) {
61
+ this._icon = icon;
62
+ this._onDidChange.fire({ icon: true });
63
+ }
64
+ }
65
+ get flags() { return this._flags; }
66
+ set flags(flags) {
67
+ if (!equals(this._flags, flags)) {
68
+ this._flags = flags;
69
+ this._onDidChange.fire({ flags: true });
70
+ }
71
+ }
72
+ get active() { return this._active; }
73
+ set active(active) {
74
+ if (this._active !== active) {
75
+ this._active = active;
76
+ this._onDidChange.fire({ active: true });
77
+ }
78
+ }
79
+ get message() { return this._message; }
80
+ set message(message) {
81
+ if (this._message !== message) {
82
+ this._message = message;
83
+ this._onDidChange.fire({ message: true });
84
+ }
85
+ }
86
+ getFlag(key) {
87
+ return this.flags?.[key] ?? false;
88
+ }
89
+ setFlag(key, value) {
90
+ const flags = this.flags ? { ...this.flags } : {};
91
+ if (value) {
92
+ flags[key] = true;
93
+ }
94
+ else {
95
+ delete flags[key];
96
+ }
97
+ this.flags = flags;
98
+ }
99
+ validate() {
100
+ if (!this.name) {
101
+ this.message = ( localizeWithPath(_moduleId, 0, "Profile name is required."));
102
+ return;
103
+ }
104
+ if (this.name !== this.getInitialName() && ( (this.userDataProfilesService.profiles.some(p => p.name === this.name)))) {
105
+ this.message = ( localizeWithPath(_moduleId, 1, "Profile with name {0} already exists.", this.name));
106
+ return;
107
+ }
108
+ if (this.flags && this.flags.settings && this.flags.keybindings && this.flags.tasks && this.flags.snippets && this.flags.extensions) {
109
+ this.message = ( localizeWithPath(_moduleId, 2, "The profile should contain at least one configuration."));
110
+ return;
111
+ }
112
+ this.message = undefined;
113
+ }
114
+ async getChildren(resourceType) {
115
+ return [];
116
+ }
117
+ async getChildrenFromProfile(profile, resourceType) {
118
+ profile = this.getFlag(resourceType) ? this.userDataProfilesService.defaultProfile : profile;
119
+ switch (resourceType) {
120
+ case ProfileResourceType.Settings:
121
+ return this.instantiationService.createInstance(SettingsResourceTreeItem, profile).getChildren();
122
+ case ProfileResourceType.Keybindings:
123
+ return this.instantiationService.createInstance(KeybindingsResourceTreeItem, profile).getChildren();
124
+ case ProfileResourceType.Snippets:
125
+ return (await this.instantiationService.createInstance(SnippetsResourceTreeItem, profile).getChildren()) ?? [];
126
+ case ProfileResourceType.Tasks:
127
+ return this.instantiationService.createInstance(TasksResourceTreeItem, profile).getChildren();
128
+ case ProfileResourceType.Extensions:
129
+ return this.instantiationService.createInstance(ExtensionsResourceExportTreeItem, profile).getChildren();
130
+ }
131
+ return [];
132
+ }
133
+ getInitialName() {
134
+ return '';
135
+ }
136
+ };
137
+ AbstractUserDataProfileElement = ( (__decorate([
138
+ ( (__param(4, IUserDataProfilesService))),
139
+ ( (__param(5, IInstantiationService)))
140
+ ], AbstractUserDataProfileElement)));
141
+ let UserDataProfileElement = class UserDataProfileElement extends AbstractUserDataProfileElement {
142
+ get profile() { return this._profile; }
143
+ constructor(_profile, titleActions, contextMenuActions, userDataProfileService, userDataProfileManagementService, userDataProfilesService, instantiationService) {
144
+ super(_profile.name, _profile.icon, _profile.useDefaultFlags, userDataProfileService.currentProfile.id === _profile.id, userDataProfilesService, instantiationService);
145
+ this._profile = _profile;
146
+ this.titleActions = titleActions;
147
+ this.contextMenuActions = contextMenuActions;
148
+ this.userDataProfileService = userDataProfileService;
149
+ this.userDataProfileManagementService = userDataProfileManagementService;
150
+ this.primaryAction = undefined;
151
+ this.saveScheduler = this._register(( (new RunOnceScheduler(() => this.doSave(), 500))));
152
+ this._register(this.userDataProfileService.onDidChangeCurrentProfile(() => this.active = this.userDataProfileService.currentProfile.id === this.profile.id));
153
+ this._register(this.userDataProfilesService.onDidChangeProfiles(() => {
154
+ const profile = this.userDataProfilesService.profiles.find(p => p.id === this.profile.id);
155
+ if (profile) {
156
+ this._profile = profile;
157
+ this.name = profile.name;
158
+ this.icon = profile.icon;
159
+ this.flags = profile.useDefaultFlags;
160
+ }
161
+ }));
162
+ this._register(this.onDidChange(e => {
163
+ this.save();
164
+ }));
165
+ }
166
+ hasUnsavedChanges() {
167
+ if (this.name !== this.profile.name) {
168
+ return true;
169
+ }
170
+ if (this.icon !== this.profile.icon) {
171
+ return true;
172
+ }
173
+ if (!equals(this.flags ?? {}, this.profile.useDefaultFlags ?? {})) {
174
+ return true;
175
+ }
176
+ return false;
177
+ }
178
+ save() {
179
+ this.saveScheduler.schedule();
180
+ }
181
+ async doSave() {
182
+ if (!this.hasUnsavedChanges()) {
183
+ return;
184
+ }
185
+ this.validate();
186
+ if (this.message) {
187
+ return;
188
+ }
189
+ const useDefaultFlags = this.flags
190
+ ? this.flags.settings && this.flags.keybindings && this.flags.tasks && this.flags.globalState && this.flags.extensions ? undefined : this.flags
191
+ : undefined;
192
+ await this.userDataProfileManagementService.updateProfile(this.profile, {
193
+ name: this.name,
194
+ icon: this.icon,
195
+ useDefaultFlags: this.profile.useDefaultFlags && !useDefaultFlags ? {} : useDefaultFlags
196
+ });
197
+ }
198
+ async getChildren(resourceType) {
199
+ return this.getChildrenFromProfile(this.profile, resourceType);
200
+ }
201
+ getInitialName() {
202
+ return this.profile.name;
203
+ }
204
+ };
205
+ UserDataProfileElement = ( (__decorate([
206
+ ( (__param(3, IUserDataProfileService))),
207
+ ( (__param(4, IUserDataProfileManagementService))),
208
+ ( (__param(5, IUserDataProfilesService))),
209
+ ( (__param(6, IInstantiationService)))
210
+ ], UserDataProfileElement)));
211
+ const USER_DATA_PROFILE_TEMPLATE_PREVIEW_SCHEME = 'userdataprofiletemplatepreview';
212
+ let NewProfileElement = class NewProfileElement extends AbstractUserDataProfileElement {
213
+ constructor(name, copyFrom, primaryAction, titleActions, contextMenuActions, fileService, userDataProfileImportExportService, userDataProfilesService, instantiationService) {
214
+ super(name, undefined, undefined, false, userDataProfilesService, instantiationService);
215
+ this.primaryAction = primaryAction;
216
+ this.titleActions = titleActions;
217
+ this.contextMenuActions = contextMenuActions;
218
+ this.fileService = fileService;
219
+ this.userDataProfileImportExportService = userDataProfileImportExportService;
220
+ this._copyFrom = copyFrom;
221
+ this._copyFlags = this.getCopyFlagsFrom(copyFrom);
222
+ this._register(this.fileService.registerProvider(USER_DATA_PROFILE_TEMPLATE_PREVIEW_SCHEME, this._register(( (new InMemoryFileSystemProvider())))));
223
+ }
224
+ get copyFrom() { return this._copyFrom; }
225
+ set copyFrom(copyFrom) {
226
+ if (this._copyFrom !== copyFrom) {
227
+ this._copyFrom = copyFrom;
228
+ this._onDidChange.fire({ copyFrom: true });
229
+ this.flags = undefined;
230
+ this.copyFlags = this.getCopyFlagsFrom(copyFrom);
231
+ }
232
+ }
233
+ get copyFlags() { return this._copyFlags; }
234
+ set copyFlags(flags) {
235
+ if (!equals(this._copyFlags, flags)) {
236
+ this._copyFlags = flags;
237
+ this._onDidChange.fire({ copyFlags: true });
238
+ }
239
+ }
240
+ getCopyFlagsFrom(copyFrom) {
241
+ return copyFrom ? {
242
+ settings: true,
243
+ keybindings: true,
244
+ snippets: true,
245
+ tasks: true,
246
+ extensions: true
247
+ } : undefined;
248
+ }
249
+ getCopyFlag(key) {
250
+ return this.copyFlags?.[key] ?? false;
251
+ }
252
+ setCopyFlag(key, value) {
253
+ const flags = this.copyFlags ? { ...this.copyFlags } : {};
254
+ flags[key] = value;
255
+ this.copyFlags = flags;
256
+ }
257
+ async getChildren(resourceType) {
258
+ if (!this.getCopyFlag(resourceType)) {
259
+ return [];
260
+ }
261
+ if (this.copyFrom instanceof URI) {
262
+ const template = await this.userDataProfileImportExportService.resolveProfileTemplate(this.copyFrom);
263
+ if (!template) {
264
+ return [];
265
+ }
266
+ return this.getChildrenFromProfileTemplate(template, resourceType);
267
+ }
268
+ if (this.copyFrom) {
269
+ return this.getChildrenFromProfile(this.copyFrom, resourceType);
270
+ }
271
+ if (this.getFlag(resourceType)) {
272
+ return this.getChildrenFromProfile(this.userDataProfilesService.defaultProfile, resourceType);
273
+ }
274
+ return [];
275
+ }
276
+ async getChildrenFromProfileTemplate(profileTemplate, resourceType) {
277
+ const profile = toUserDataProfile(generateUuid(), this.name, URI.file('/root').with({ scheme: USER_DATA_PROFILE_TEMPLATE_PREVIEW_SCHEME }), URI.file('/cache').with({ scheme: USER_DATA_PROFILE_TEMPLATE_PREVIEW_SCHEME }));
278
+ switch (resourceType) {
279
+ case ProfileResourceType.Settings:
280
+ if (profileTemplate.settings) {
281
+ await this.instantiationService.createInstance(SettingsResource).apply(profileTemplate.settings, profile);
282
+ }
283
+ return this.getChildrenFromProfile(profile, resourceType);
284
+ case ProfileResourceType.Keybindings:
285
+ if (profileTemplate.keybindings) {
286
+ await this.instantiationService.createInstance(KeybindingsResource).apply(profileTemplate.keybindings, profile);
287
+ }
288
+ return this.getChildrenFromProfile(profile, resourceType);
289
+ case ProfileResourceType.Snippets:
290
+ if (profileTemplate.snippets) {
291
+ await this.instantiationService.createInstance(SnippetsResource).apply(profileTemplate.snippets, profile);
292
+ }
293
+ return this.getChildrenFromProfile(profile, resourceType);
294
+ case ProfileResourceType.Tasks:
295
+ if (profileTemplate.tasks) {
296
+ await this.instantiationService.createInstance(TasksResource).apply(profileTemplate.tasks, profile);
297
+ }
298
+ return this.getChildrenFromProfile(profile, resourceType);
299
+ case ProfileResourceType.Extensions:
300
+ if (profileTemplate.extensions) {
301
+ return this.instantiationService.createInstance(ExtensionsResourceImportTreeItem, profileTemplate.extensions).getChildren();
302
+ }
303
+ }
304
+ return [];
305
+ }
306
+ };
307
+ NewProfileElement = ( (__decorate([
308
+ ( (__param(5, IFileService))),
309
+ ( (__param(6, IUserDataProfileImportExportService))),
310
+ ( (__param(7, IUserDataProfilesService))),
311
+ ( (__param(8, IInstantiationService)))
312
+ ], NewProfileElement)));
313
+ let UserDataProfilesEditorModel = class UserDataProfilesEditorModel extends EditorModel {
314
+ static { UserDataProfilesEditorModel_1 = this; }
315
+ static getInstance(instantiationService) {
316
+ if (!UserDataProfilesEditorModel_1.INSTANCE) {
317
+ UserDataProfilesEditorModel_1.INSTANCE = instantiationService.createInstance(UserDataProfilesEditorModel_1);
318
+ }
319
+ return UserDataProfilesEditorModel_1.INSTANCE;
320
+ }
321
+ get profiles() {
322
+ return ( (this._profiles
323
+ .map(([profile]) => profile)))
324
+ .sort((a, b) => {
325
+ if (a instanceof NewProfileElement) {
326
+ return 1;
327
+ }
328
+ if (b instanceof NewProfileElement) {
329
+ return -1;
330
+ }
331
+ if (a instanceof UserDataProfileElement && a.profile.isDefault) {
332
+ return -1;
333
+ }
334
+ if (b instanceof UserDataProfileElement && b.profile.isDefault) {
335
+ return 1;
336
+ }
337
+ return a.name.localeCompare(b.name);
338
+ });
339
+ }
340
+ constructor(userDataProfileService, userDataProfilesService, userDataProfileManagementService, userDataProfileImportExportService, dialogService, telemetryService, instantiationService) {
341
+ super();
342
+ this.userDataProfileService = userDataProfileService;
343
+ this.userDataProfilesService = userDataProfilesService;
344
+ this.userDataProfileManagementService = userDataProfileManagementService;
345
+ this.userDataProfileImportExportService = userDataProfileImportExportService;
346
+ this.dialogService = dialogService;
347
+ this.telemetryService = telemetryService;
348
+ this.instantiationService = instantiationService;
349
+ this._profiles = [];
350
+ this._onDidChange = this._register(( (new Emitter())));
351
+ this.onDidChange = this._onDidChange.event;
352
+ for (const profile of userDataProfilesService.profiles) {
353
+ this._profiles.push(this.createProfileElement(profile));
354
+ }
355
+ this._register(toDisposable(() => ( (this._profiles.splice(0, this._profiles.length).map(([, disposables]) => disposables.dispose())))));
356
+ this._register(userDataProfilesService.onDidChangeProfiles(e => this.onDidChangeProfiles(e)));
357
+ }
358
+ onDidChangeProfiles(e) {
359
+ for (const profile of e.added) {
360
+ if (profile.name !== this.newProfileElement?.name) {
361
+ this._profiles.push(this.createProfileElement(profile));
362
+ }
363
+ }
364
+ for (const profile of e.removed) {
365
+ this._profiles.findIndex(([p]) => p instanceof UserDataProfileElement && p.profile.id === profile.id);
366
+ }
367
+ this._onDidChange.fire(undefined);
368
+ }
369
+ createProfileElement(profile) {
370
+ const disposables = ( (new DisposableStore()));
371
+ const activateAction = disposables.add(( (new Action('userDataProfile.activate', ( localizeWithPath(_moduleId, 3, "Activate")), ThemeIcon.asClassName(Codicon.check), true, () => this.userDataProfileManagementService.switchProfile(profile)))));
372
+ activateAction.checked = this.userDataProfileService.currentProfile.id === profile.id;
373
+ disposables.add(this.userDataProfileService.onDidChangeCurrentProfile(() => activateAction.checked = this.userDataProfileService.currentProfile.id === profile.id));
374
+ const copyFromProfileAction = disposables.add(( (new Action('userDataProfile.copyFromProfile', ( localizeWithPath(_moduleId, 4, "Save As...")), ThemeIcon.asClassName(Codicon.copy), true, () => this.createNewProfile(profile)))));
375
+ const exportAction = disposables.add(( (new Action('userDataProfile.export', ( localizeWithPath(_moduleId, 5, "Export...")), ThemeIcon.asClassName(Codicon.export), true, () => this.exportProfile(profile)))));
376
+ const deleteAction = disposables.add(( (new Action('userDataProfile.delete', ( localizeWithPath(_moduleId, 6, "Delete")), ThemeIcon.asClassName(Codicon.trash), true, () => this.removeProfile(profile)))));
377
+ const titlePrimaryActions = [];
378
+ titlePrimaryActions.push(activateAction);
379
+ titlePrimaryActions.push(exportAction);
380
+ if (!profile.isDefault) {
381
+ titlePrimaryActions.push(deleteAction);
382
+ }
383
+ const titleSecondaryActions = [];
384
+ titleSecondaryActions.push(copyFromProfileAction);
385
+ const secondaryActions = [];
386
+ secondaryActions.push(activateAction);
387
+ secondaryActions.push(( (new Separator())));
388
+ secondaryActions.push(copyFromProfileAction);
389
+ secondaryActions.push(exportAction);
390
+ if (!profile.isDefault) {
391
+ secondaryActions.push(( (new Separator())));
392
+ secondaryActions.push(deleteAction);
393
+ }
394
+ const profileElement = disposables.add(this.instantiationService.createInstance(UserDataProfileElement, profile, [titlePrimaryActions, titleSecondaryActions], secondaryActions));
395
+ return [profileElement, disposables];
396
+ }
397
+ createNewProfile(copyFrom) {
398
+ if (!this.newProfileElement) {
399
+ const disposables = ( (new DisposableStore()));
400
+ const discardAction = disposables.add(( (new Action('userDataProfile.discard', ( localizeWithPath(_moduleId, 7, "Discard")), ThemeIcon.asClassName(Codicon.close), true, () => {
401
+ this.removeNewProfile();
402
+ this._onDidChange.fire(undefined);
403
+ }))));
404
+ this.newProfileElement = disposables.add(this.instantiationService.createInstance(NewProfileElement, ( localizeWithPath(_moduleId, 8, "Untitled")), copyFrom, disposables.add(( (new Action('userDataProfile.create', ( localizeWithPath(_moduleId, 9, "Create & Apply")), undefined, true, () => this.saveNewProfile())))), [[discardAction], []], [discardAction]));
405
+ this._profiles.push([this.newProfileElement, disposables]);
406
+ this._onDidChange.fire(this.newProfileElement);
407
+ }
408
+ return this.newProfileElement;
409
+ }
410
+ revert() {
411
+ this.removeNewProfile();
412
+ this._onDidChange.fire(undefined);
413
+ }
414
+ removeNewProfile() {
415
+ if (this.newProfileElement) {
416
+ this._profiles.findIndex(([p]) => p === this.newProfileElement);
417
+ this.newProfileElement = undefined;
418
+ }
419
+ }
420
+ async saveNewProfile() {
421
+ if (!this.newProfileElement) {
422
+ return;
423
+ }
424
+ this.newProfileElement.validate();
425
+ if (this.newProfileElement.message) {
426
+ return;
427
+ }
428
+ const { flags, icon, name, copyFrom } = this.newProfileElement;
429
+ const useDefaultFlags = flags
430
+ ? flags.settings && flags.keybindings && flags.tasks && flags.globalState && flags.extensions ? undefined : flags
431
+ : undefined;
432
+ const createProfileTelemetryData = { source: copyFrom instanceof URI ? 'template' : isUserDataProfile(copyFrom) ? 'profile' : copyFrom ? 'external' : undefined };
433
+ if (copyFrom instanceof URI) {
434
+ this.telemetryService.publicLog2('userDataProfile.createFromTemplate', createProfileTelemetryData);
435
+ await this.userDataProfileImportExportService.importProfile(copyFrom, { mode: 'apply', name: name, useDefaultFlags, icon: icon ? icon : undefined, resourceTypeFlags: this.newProfileElement.copyFlags });
436
+ }
437
+ else if (isUserDataProfile(copyFrom)) {
438
+ this.telemetryService.publicLog2('userDataProfile.createFromProfile', createProfileTelemetryData);
439
+ await this.userDataProfileImportExportService.createFromProfile(copyFrom, name, { useDefaultFlags, icon: icon ? icon : undefined, resourceTypeFlags: this.newProfileElement.copyFlags });
440
+ }
441
+ else {
442
+ this.telemetryService.publicLog2('userDataProfile.createEmptyProfile', createProfileTelemetryData);
443
+ await this.userDataProfileManagementService.createAndEnterProfile(name, { useDefaultFlags, icon: icon ? icon : undefined });
444
+ }
445
+ this.removeNewProfile();
446
+ const profile = this.userDataProfilesService.profiles.find(p => p.name === name);
447
+ if (profile) {
448
+ this.onDidChangeProfiles({ added: [profile], removed: [], updated: [], all: this.userDataProfilesService.profiles });
449
+ }
450
+ }
451
+ async removeProfile(profile) {
452
+ const result = await this.dialogService.confirm({
453
+ type: 'info',
454
+ message: ( localizeWithPath(
455
+ _moduleId,
456
+ 10,
457
+ "Are you sure you want to delete the profile '{0}'?",
458
+ profile.name
459
+ )),
460
+ primaryButton: ( localizeWithPath(_moduleId, 6, "Delete")),
461
+ cancelButton: ( localizeWithPath(_moduleId, 11, "Cancel"))
462
+ });
463
+ if (result.confirmed) {
464
+ await this.userDataProfileManagementService.removeProfile(profile);
465
+ }
466
+ }
467
+ async exportProfile(profile) {
468
+ return this.userDataProfileImportExportService.exportProfile2(profile);
469
+ }
470
+ };
471
+ UserDataProfilesEditorModel = UserDataProfilesEditorModel_1 = ( (__decorate([
472
+ ( (__param(0, IUserDataProfileService))),
473
+ ( (__param(1, IUserDataProfilesService))),
474
+ ( (__param(2, IUserDataProfileManagementService))),
475
+ ( (__param(3, IUserDataProfileImportExportService))),
476
+ ( (__param(4, IDialogService))),
477
+ ( (__param(5, ITelemetryService))),
478
+ ( (__param(6, IInstantiationService)))
479
+ ], UserDataProfilesEditorModel)));
480
+
481
+ export { AbstractUserDataProfileElement, NewProfileElement, UserDataProfileElement, UserDataProfilesEditorModel };
@@ -2,6 +2,7 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
3
3
  import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
4
4
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
5
+ import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
5
6
  import { isWeb } from 'vscode/vscode/vs/base/common/platform';
6
7
  import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
7
8
  import { mark } from 'vscode/vscode/vs/base/common/performance';
@@ -56,7 +57,7 @@ InitializeOtherResourcesContribution = ( __decorate([
56
57
  ], InitializeOtherResourcesContribution));
57
58
  if (isWeb) {
58
59
  const workbenchRegistry = ( Registry.as(Extensions.Workbench));
59
- workbenchRegistry.registerWorkbenchContribution(InitializeOtherResourcesContribution, 3 );
60
+ workbenchRegistry.registerWorkbenchContribution(InitializeOtherResourcesContribution, LifecyclePhase.Restored);
60
61
  }
61
62
 
62
63
  export { UserDataInitializationService };
@@ -6,10 +6,12 @@ import { GlobalExtensionEnablementService } from 'vscode/vscode/vs/platform/exte
6
6
  import { EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement';
7
7
  import { IExtensionManagementService, IExtensionGalleryService, IGlobalExtensionEnablementService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
8
8
  import { areSameExtensions } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
9
+ import { ExtensionType } from 'vscode/vscode/vs/platform/extensions/common/extensions';
9
10
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
10
11
  import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
11
12
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
12
13
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
14
+ import { ProfileResourceType } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
13
15
  import { IUserDataProfileStorageService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfileStorageService.service';
14
16
  import { TreeItemCollapsibleState } from 'vscode/vscode/vs/workbench/common/views';
15
17
  import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
@@ -175,7 +177,7 @@ let ExtensionsResource = class ExtensionsResource {
175
177
  await this.extensionManagementService.copyExtensions(from.extensionsResource, to.extensionsResource);
176
178
  const extensionsToDisable = await this.withProfileScopedServices(from, async (extensionEnablementService) => extensionEnablementService.getDisabledExtensions());
177
179
  if (disableExtensions) {
178
- const extensions = await this.extensionManagementService.getInstalled(1 , to.extensionsResource);
180
+ const extensions = await this.extensionManagementService.getInstalled(ExtensionType.User, to.extensionsResource);
179
181
  for (const extension of extensions) {
180
182
  extensionsToDisable.push(extension.identifier);
181
183
  }
@@ -184,7 +186,7 @@ let ExtensionsResource = class ExtensionsResource {
184
186
  }
185
187
  async getLocalExtensions(profile) {
186
188
  return this.withProfileScopedServices(profile, async (extensionEnablementService) => {
187
- const result = [];
189
+ const result = ( (new Map()));
188
190
  const installedExtensions = await this.extensionManagementService.getInstalled(undefined, profile.extensionsResource);
189
191
  const disabledExtensions = extensionEnablementService.getDisabledExtensions();
190
192
  for (const extension of installedExtensions) {
@@ -198,6 +200,10 @@ let ExtensionsResource = class ExtensionsResource {
198
200
  continue;
199
201
  }
200
202
  }
203
+ const existing = result.get(identifier.id.toLowerCase());
204
+ if (existing?.disabled) {
205
+ result.delete(identifier.id.toLowerCase());
206
+ }
201
207
  const profileExtension = { identifier, displayName: extension.manifest.displayName };
202
208
  if (disabled) {
203
209
  profileExtension.disabled = true;
@@ -208,9 +214,9 @@ let ExtensionsResource = class ExtensionsResource {
208
214
  if (!profileExtension.version && preRelease) {
209
215
  profileExtension.preRelease = true;
210
216
  }
211
- result.push(profileExtension);
217
+ result.set(profileExtension.identifier.id.toLowerCase(), profileExtension);
212
218
  }
213
- return result;
219
+ return [...( (result.values()))];
214
220
  });
215
221
  }
216
222
  async getProfileExtensions(content) {
@@ -219,7 +225,7 @@ let ExtensionsResource = class ExtensionsResource {
219
225
  async withProfileScopedServices(profile, fn) {
220
226
  return this.userDataProfileStorageService.withProfileScopedStorageService(profile, async (storageService) => {
221
227
  const disposables = ( (new DisposableStore()));
222
- const instantiationService = this.instantiationService.createChild(( (new ServiceCollection([IStorageService, storageService]))));
228
+ const instantiationService = disposables.add(this.instantiationService.createChild(( (new ServiceCollection([IStorageService, storageService])))));
223
229
  const extensionEnablementService = disposables.add(instantiationService.createInstance(GlobalExtensionEnablementService));
224
230
  try {
225
231
  return await fn(extensionEnablementService);
@@ -239,11 +245,11 @@ ExtensionsResource = ( (__decorate([
239
245
  ], ExtensionsResource)));
240
246
  class ExtensionsResourceTreeItem {
241
247
  constructor() {
242
- this.type = "extensions" ;
243
- this.handle = "extensions" ;
248
+ this.type = ProfileResourceType.Extensions;
249
+ this.handle = ProfileResourceType.Extensions;
244
250
  this.label = { label: ( localizeWithPath(_moduleId, 0, "Extensions")) };
245
251
  this.collapsibleState = TreeItemCollapsibleState.Expanded;
246
- this.contextValue = "extensions" ;
252
+ this.contextValue = ProfileResourceType.Extensions;
247
253
  this.excludedExtensions = ( (new Set()));
248
254
  }
249
255
  async getChildren() {
@@ -2,8 +2,10 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
3
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
4
4
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
5
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
5
6
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
6
7
  import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
8
+ import { ProfileResourceType } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
7
9
  import { IUserDataProfileStorageService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfileStorageService.service';
8
10
  import { API_OPEN_EDITOR_COMMAND_ID } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorCommands';
9
11
  import { TreeItemCollapsibleState } from 'vscode/vscode/vs/workbench/common/views';
@@ -19,7 +21,7 @@ let GlobalStateResourceInitializer = class GlobalStateResourceInitializer {
19
21
  if (storageKeys.length) {
20
22
  const storageEntries = [];
21
23
  for (const key of storageKeys) {
22
- storageEntries.push({ key, value: globalState.storage[key], scope: 0 , target: 0 });
24
+ storageEntries.push({ key, value: globalState.storage[key], scope: StorageScope.PROFILE, target: StorageTarget.USER });
23
25
  }
24
26
  this.storageService.storeAll(storageEntries, true);
25
27
  }
@@ -46,7 +48,7 @@ let GlobalStateResource = class GlobalStateResource {
46
48
  const storage = {};
47
49
  const storageData = await this.userDataProfileStorageService.readStorageData(profile);
48
50
  for (const [key, value] of storageData) {
49
- if (value.value !== undefined && value.target === 0 ) {
51
+ if (value.value !== undefined && value.target === StorageTarget.USER) {
50
52
  storage[key] = value.value;
51
53
  }
52
54
  }
@@ -57,9 +59,9 @@ let GlobalStateResource = class GlobalStateResource {
57
59
  if (storageKeys.length) {
58
60
  const updatedStorage = ( (new Map()));
59
61
  const nonProfileKeys = [
60
- ...( (this.storageService.keys(-1, 1 ))),
61
- ...( (this.storageService.keys(1, 0 ))),
62
- ...( (this.storageService.keys(1, 1 ))),
62
+ ...( (this.storageService.keys(StorageScope.APPLICATION, StorageTarget.MACHINE))),
63
+ ...( (this.storageService.keys(StorageScope.WORKSPACE, StorageTarget.USER))),
64
+ ...( (this.storageService.keys(StorageScope.WORKSPACE, StorageTarget.MACHINE))),
63
65
  ];
64
66
  for (const key of storageKeys) {
65
67
  if (nonProfileKeys.includes(key)) {
@@ -69,7 +71,7 @@ let GlobalStateResource = class GlobalStateResource {
69
71
  updatedStorage.set(key, globalState.storage[key]);
70
72
  }
71
73
  }
72
- await this.userDataProfileStorageService.updateStorageData(profile, updatedStorage, 0 );
74
+ await this.userDataProfileStorageService.updateStorageData(profile, updatedStorage, StorageTarget.USER);
73
75
  }
74
76
  }
75
77
  };
@@ -82,8 +84,8 @@ class GlobalStateResourceTreeItem {
82
84
  constructor(resource, uriIdentityService) {
83
85
  this.resource = resource;
84
86
  this.uriIdentityService = uriIdentityService;
85
- this.type = "globalState" ;
86
- this.handle = "globalState" ;
87
+ this.type = ProfileResourceType.GlobalState;
88
+ this.handle = ProfileResourceType.GlobalState;
87
89
  this.label = { label: ( localizeWithPath(_moduleId, 0, "UI State")) };
88
90
  this.collapsibleState = TreeItemCollapsibleState.Collapsed;
89
91
  }