@codingame/monaco-vscode-user-data-profile-service-override 5.3.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 (33) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +1 -0
  3. package/package.json +31 -0
  4. package/userDataProfile.js +118 -0
  5. package/vscode/src/vs/platform/userDataProfile/browser/userDataProfile.js +95 -0
  6. package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.js +84 -0
  7. package/vscode/src/vs/platform/userDataSync/common/extensionsMerge.js +331 -0
  8. package/vscode/src/vs/platform/userDataSync/common/extensionsSync.js +545 -0
  9. package/vscode/src/vs/platform/userDataSync/common/globalStateMerge.js +102 -0
  10. package/vscode/src/vs/platform/userDataSync/common/globalStateSync.js +431 -0
  11. package/vscode/src/vs/platform/userDataSync/common/keybindingsMerge.js +277 -0
  12. package/vscode/src/vs/platform/userDataSync/common/keybindingsSync.js +328 -0
  13. package/vscode/src/vs/platform/userDataSync/common/settingsSync.js +322 -0
  14. package/vscode/src/vs/platform/userDataSync/common/snippetsMerge.js +126 -0
  15. package/vscode/src/vs/platform/userDataSync/common/snippetsSync.js +478 -0
  16. package/vscode/src/vs/platform/userDataSync/common/tasksSync.js +245 -0
  17. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js +9 -0
  18. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.js +495 -0
  19. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfileActions.js +159 -0
  20. package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilePreview.js +24 -0
  21. package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +62 -0
  22. package/vscode/src/vs/workbench/services/userDataProfile/browser/extensionsResource.js +328 -0
  23. package/vscode/src/vs/workbench/services/userDataProfile/browser/globalStateResource.js +144 -0
  24. package/vscode/src/vs/workbench/services/userDataProfile/browser/keybindingsResource.js +119 -0
  25. package/vscode/src/vs/workbench/services/userDataProfile/browser/media/userDataProfileView.css.js +6 -0
  26. package/vscode/src/vs/workbench/services/userDataProfile/browser/settingsResource.js +140 -0
  27. package/vscode/src/vs/workbench/services/userDataProfile/browser/snippetsResource.js +155 -0
  28. package/vscode/src/vs/workbench/services/userDataProfile/browser/tasksResource.js +118 -0
  29. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.js +1453 -0
  30. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileInit.js +151 -0
  31. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.js +180 -0
  32. package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileStorageService.js +39 -0
  33. package/vscode/src/vs/workbench/services/userDataSync/browser/userDataSyncInit.js +448 -0
@@ -0,0 +1,1453 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import './media/userDataProfileView.css.js';
3
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
4
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
5
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
6
+ import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
7
+ import { Event, Emitter } from 'vscode/vscode/vs/base/common/event';
8
+ import { $, append, Dimension, addDisposableListener, EventType, EventHelper, getClientArea, clearNode } from 'vscode/vscode/vs/base/browser/dom';
9
+ import { IS_PROFILE_EXPORT_IN_PROGRESS_CONTEXT, IS_PROFILE_IMPORT_IN_PROGRESS_CONTEXT, PROFILES_TITLE, defaultUserDataProfileIcon, PROFILE_URL_AUTHORITY, PROFILES_CATEGORY, toUserDataProfileUri, PROFILE_FILTER, PROFILE_EXTENSION } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
10
+ import { IUserDataProfileService, IUserDataProfileManagementService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
11
+ import { Disposable, toDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
12
+ import { IDialogService, IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
13
+ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
14
+ import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
15
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
16
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
17
+ import { Extensions, TreeItemCollapsibleState } from 'vscode/vscode/vs/workbench/common/views';
18
+ import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
19
+ import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
20
+ import { isUserDataProfile, toUserDataProfile } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
21
+ import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
22
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
23
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
24
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
25
+ import { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
26
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
27
+ import { TreeView, TreeViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/treeView';
28
+ import { SettingsResource, SettingsResourceTreeItem } from './settingsResource.js';
29
+ import { KeybindingsResource, KeybindingsResourceTreeItem } from './keybindingsResource.js';
30
+ import { SnippetsResource, SnippetsResourceTreeItem } from './snippetsResource.js';
31
+ import { TasksResource, TasksResourceTreeItem } from './tasksResource.js';
32
+ import { ExtensionsResource, ExtensionsResourceTreeItem, ExtensionsResourceExportTreeItem, ExtensionsResourceImportTreeItem } from './extensionsResource.js';
33
+ import { GlobalStateResource, GlobalStateResourceTreeItem, GlobalStateResourceExportTreeItem, GlobalStateResourceImportTreeItem } from './globalStateResource.js';
34
+ import { InMemoryFileSystemProvider } from 'vscode/vscode/vs/platform/files/common/inMemoryFilesystemProvider';
35
+ import { Button } from 'vscode/vscode/vs/base/browser/ui/button/button';
36
+ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
37
+ import { IContextViewService, IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView.service';
38
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
39
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener.service';
40
+ import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
41
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
42
+ import { defaultInputBoxStyles, defaultSelectBoxStyles, defaultButtonStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
43
+ import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
44
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
45
+ import { getErrorMessage, onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
46
+ import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
47
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
48
+ import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
49
+ import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
50
+ import { joinPath } from 'vscode/vscode/vs/base/common/resources';
51
+ import { escapeRegExpCharacters } from 'vscode/vscode/vs/base/common/strings';
52
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
53
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
54
+ import Severity$1 from 'vscode/vscode/vs/base/common/severity';
55
+ import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService.service';
56
+ import { IURLService } from 'vscode/vscode/vs/platform/url/common/url.service';
57
+ import { asText } from 'vscode/vscode/vs/platform/request/common/request';
58
+ import { IRequestService } from 'vscode/vscode/vs/platform/request/common/request.service';
59
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
60
+ import { isUndefined } from 'vscode/vscode/vs/base/common/types';
61
+ import { Action, ActionRunner } from 'vscode/vscode/vs/base/common/actions';
62
+ import { isWeb } from 'vscode/vscode/vs/base/common/platform';
63
+ import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
64
+ import { getAllCodicons, Codicon } from 'vscode/vscode/vs/base/common/codicons';
65
+ import { Barrier } from 'vscode/vscode/vs/base/common/async';
66
+ import { IExtensionManagementService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
67
+ import { areSameExtensions } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
68
+ import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
69
+ import { renderMarkdown } from 'vscode/vscode/vs/base/browser/markdownRenderer';
70
+ import { showWindowLogActionId } from 'vscode/vscode/vs/workbench/services/log/common/logConstants';
71
+ import { SelectBox } from 'vscode/vscode/vs/base/browser/ui/selectBox/selectBox';
72
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
73
+ import { IHoverService } from 'vscode/vscode/vs/platform/hover/browser/hover.service';
74
+ import { DEFAULT_ICON, ICONS } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfileIcons';
75
+ import { WorkbenchIconSelectBox } from 'vscode/vscode/vs/workbench/services/userDataProfile/browser/iconSelectBox';
76
+ import { StandardKeyboardEvent } from 'vscode/vscode/vs/base/browser/keyboardEvent';
77
+ import { IAccessibleViewInformationService } from 'vscode/vscode/vs/workbench/services/accessibility/common/accessibleViewInformationService.service';
78
+
79
+ var UserDataProfileImportExportService_1;
80
+ const _moduleId = "vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService";
81
+ function isUserDataProfileTemplate(thing) {
82
+ const candidate = thing;
83
+ return !!(candidate && typeof candidate === 'object'
84
+ && (candidate.name && typeof candidate.name === 'string')
85
+ && (isUndefined(candidate.icon) || typeof candidate.icon === 'string')
86
+ && (isUndefined(candidate.settings) || typeof candidate.settings === 'string')
87
+ && (isUndefined(candidate.globalState) || typeof candidate.globalState === 'string')
88
+ && (isUndefined(candidate.extensions) || typeof candidate.extensions === 'string'));
89
+ }
90
+ const EXPORT_PROFILE_PREVIEW_VIEW = 'workbench.views.profiles.export.preview';
91
+ const IMPORT_PROFILE_PREVIEW_VIEW = 'workbench.views.profiles.import.preview';
92
+ let UserDataProfileImportExportService = class UserDataProfileImportExportService extends Disposable {
93
+ static { UserDataProfileImportExportService_1 = this; }
94
+ static { this.PROFILE_URL_AUTHORITY_PREFIX = 'profile-'; }
95
+ constructor(instantiationService, userDataProfileService, viewsService, editorService, contextKeyService, userDataProfileManagementService, userDataProfilesService, extensionService, extensionManagementService, quickInputService, notificationService, progressService, dialogService, clipboardService, openerService, requestService, urlService, productService, uriIdentityService, telemetryService, contextViewService, hoverService, logService) {
96
+ super();
97
+ this.instantiationService = instantiationService;
98
+ this.userDataProfileService = userDataProfileService;
99
+ this.viewsService = viewsService;
100
+ this.editorService = editorService;
101
+ this.userDataProfileManagementService = userDataProfileManagementService;
102
+ this.userDataProfilesService = userDataProfilesService;
103
+ this.extensionService = extensionService;
104
+ this.extensionManagementService = extensionManagementService;
105
+ this.quickInputService = quickInputService;
106
+ this.notificationService = notificationService;
107
+ this.progressService = progressService;
108
+ this.dialogService = dialogService;
109
+ this.clipboardService = clipboardService;
110
+ this.openerService = openerService;
111
+ this.requestService = requestService;
112
+ this.productService = productService;
113
+ this.uriIdentityService = uriIdentityService;
114
+ this.telemetryService = telemetryService;
115
+ this.contextViewService = contextViewService;
116
+ this.hoverService = hoverService;
117
+ this.logService = logService;
118
+ this.profileContentHandlers = ( (new Map()));
119
+ this.registerProfileContentHandler(Schemas.file, this.fileUserDataProfileContentHandler = instantiationService.createInstance(FileUserDataProfileContentHandler));
120
+ this.isProfileExportInProgressContextKey = IS_PROFILE_EXPORT_IN_PROGRESS_CONTEXT.bindTo(contextKeyService);
121
+ this.isProfileImportInProgressContextKey = IS_PROFILE_IMPORT_IN_PROGRESS_CONTEXT.bindTo(contextKeyService);
122
+ this.viewContainer = ( (Registry.as(Extensions.ViewContainersRegistry))).registerViewContainer({
123
+ id: 'userDataProfiles',
124
+ title: PROFILES_TITLE,
125
+ ctorDescriptor: ( (new SyncDescriptor(
126
+ ViewPaneContainer,
127
+ ['userDataProfiles', { mergeViewWithContainerWhenSingleView: true }]
128
+ ))),
129
+ icon: defaultUserDataProfileIcon,
130
+ hideIfEmpty: true,
131
+ }, 0 );
132
+ urlService.registerHandler(this);
133
+ }
134
+ isProfileURL(uri) {
135
+ return uri.authority === PROFILE_URL_AUTHORITY || ( (new RegExp(`^${UserDataProfileImportExportService_1.PROFILE_URL_AUTHORITY_PREFIX}`))).test(uri.authority);
136
+ }
137
+ async handleURL(uri) {
138
+ if (this.isProfileURL(uri)) {
139
+ try {
140
+ await this.importProfile(uri);
141
+ }
142
+ catch (error) {
143
+ this.notificationService.error(( localizeWithPath(_moduleId, 0, "Error while importing profile: {0}", getErrorMessage(error))));
144
+ }
145
+ return true;
146
+ }
147
+ return false;
148
+ }
149
+ registerProfileContentHandler(id, profileContentHandler) {
150
+ if (( (this.profileContentHandlers.has(id)))) {
151
+ throw ( (new Error(`Profile content handler with id '${id}' already registered.`)));
152
+ }
153
+ this.profileContentHandlers.set(id, profileContentHandler);
154
+ return toDisposable(() => this.unregisterProfileContentHandler(id));
155
+ }
156
+ unregisterProfileContentHandler(id) {
157
+ this.profileContentHandlers.delete(id);
158
+ }
159
+ async exportProfile() {
160
+ if (this.isProfileExportInProgressContextKey.get()) {
161
+ this.logService.warn('Profile export already in progress.');
162
+ return;
163
+ }
164
+ return this.showProfileContents();
165
+ }
166
+ async importProfile(uri, options) {
167
+ if (this.isProfileImportInProgressContextKey.get()) {
168
+ this.notificationService.warn('Profile import already in progress.');
169
+ return;
170
+ }
171
+ this.isProfileImportInProgressContextKey.set(true);
172
+ const disposables = ( (new DisposableStore()));
173
+ disposables.add(toDisposable(() => this.isProfileImportInProgressContextKey.set(false)));
174
+ try {
175
+ const mode = options?.mode ?? 'preview';
176
+ const profileTemplate = await this.progressService.withProgress({
177
+ location: 10 ,
178
+ command: showWindowLogActionId,
179
+ title: ( localizeWithPath(
180
+ _moduleId,
181
+ 1,
182
+ "{0}: Resolving profile content...",
183
+ options?.mode ? ( localizeWithPath(_moduleId, 2, "Preview Profile")) : ( localizeWithPath(_moduleId, 3, "Create Profile"))
184
+ )),
185
+ }, () => this.resolveProfileTemplate(uri, options));
186
+ if (!profileTemplate) {
187
+ return;
188
+ }
189
+ if (mode === 'preview') {
190
+ await this.previewProfile(profileTemplate, options);
191
+ }
192
+ else if (mode === 'apply') {
193
+ await this.createAndSwitch(profileTemplate, false, true, options, ( localizeWithPath(_moduleId, 4, "Create Profile")));
194
+ }
195
+ else if (mode === 'both') {
196
+ await this.importAndPreviewProfile(uri, profileTemplate, options);
197
+ }
198
+ }
199
+ finally {
200
+ disposables.dispose();
201
+ }
202
+ }
203
+ createProfile(from) {
204
+ return this.saveProfile(undefined, from);
205
+ }
206
+ editProfile(profile) {
207
+ return this.saveProfile(profile);
208
+ }
209
+ async saveProfile(profile, source) {
210
+ const createProfileTelemetryData = { source: source instanceof URI ? 'template' : isUserDataProfile(source) ? 'profile' : source ? 'external' : undefined };
211
+ if (profile) {
212
+ this.telemetryService.publicLog2('userDataProfile.startEdit');
213
+ }
214
+ else {
215
+ this.telemetryService.publicLog2('userDataProfile.startCreate', createProfileTelemetryData);
216
+ }
217
+ const disposables = ( (new DisposableStore()));
218
+ const title = profile ? ( localizeWithPath(_moduleId, 5, "Edit {0} Profile...", profile.name)) : ( localizeWithPath(_moduleId, 6, "Create New Profile..."));
219
+ const settings = { id: "settings" , label: ( localizeWithPath(_moduleId, 7, "Settings")), picked: !profile?.useDefaultFlags?.settings };
220
+ const keybindings = { id: "keybindings" , label: ( localizeWithPath(_moduleId, 8, "Keyboard Shortcuts")), picked: !profile?.useDefaultFlags?.keybindings };
221
+ const snippets = { id: "snippets" , label: ( localizeWithPath(_moduleId, 9, "User Snippets")), picked: !profile?.useDefaultFlags?.snippets };
222
+ const tasks = { id: "tasks" , label: ( localizeWithPath(_moduleId, 10, "User Tasks")), picked: !profile?.useDefaultFlags?.tasks };
223
+ const extensions = { id: "extensions" , label: ( localizeWithPath(_moduleId, 11, "Extensions")), picked: !profile?.useDefaultFlags?.extensions };
224
+ const resources = [settings, keybindings, snippets, tasks, extensions];
225
+ const quickPick = this.quickInputService.createQuickPick();
226
+ quickPick.title = title;
227
+ quickPick.placeholder = ( localizeWithPath(_moduleId, 12, "Profile name"));
228
+ quickPick.value = profile?.name ?? (isUserDataProfileTemplate(source) ? this.generateProfileName(source.name) : '');
229
+ quickPick.canSelectMany = true;
230
+ quickPick.matchOnDescription = false;
231
+ quickPick.matchOnDetail = false;
232
+ quickPick.matchOnLabel = false;
233
+ quickPick.sortByLabel = false;
234
+ quickPick.hideCountBadge = true;
235
+ quickPick.ok = false;
236
+ quickPick.customButton = true;
237
+ quickPick.hideCheckAll = true;
238
+ quickPick.ignoreFocusOut = true;
239
+ quickPick.customLabel = profile ? ( localizeWithPath(_moduleId, 13, "Save")) : ( localizeWithPath(_moduleId, 14, "Create"));
240
+ quickPick.description = ( localizeWithPath(_moduleId, 15, "Choose what to configure in your Profile:"));
241
+ quickPick.items = [...resources];
242
+ const update = () => {
243
+ quickPick.items = resources;
244
+ quickPick.selectedItems = resources.filter(item => item.picked);
245
+ };
246
+ update();
247
+ const validate = () => {
248
+ if (!profile && ( (this.userDataProfilesService.profiles.some(p => p.name === quickPick.value)))) {
249
+ quickPick.validationMessage = ( localizeWithPath(_moduleId, 16, "Profile with name {0} already exists.", quickPick.value));
250
+ quickPick.severity = Severity$1.Warning;
251
+ return;
252
+ }
253
+ if (resources.every(resource => !resource.picked)) {
254
+ quickPick.validationMessage = ( localizeWithPath(_moduleId, 17, "The profile should contain at least one configuration."));
255
+ quickPick.severity = Severity$1.Warning;
256
+ return;
257
+ }
258
+ quickPick.severity = Severity$1.Ignore;
259
+ quickPick.validationMessage = undefined;
260
+ };
261
+ disposables.add(quickPick.onDidChangeSelection(items => {
262
+ let needUpdate = false;
263
+ for (const resource of resources) {
264
+ resource.picked = items.includes(resource);
265
+ const description = resource.picked ? undefined : ( localizeWithPath(_moduleId, 18, "Using Default Profile"));
266
+ if (resource.description !== description) {
267
+ resource.description = description;
268
+ needUpdate = true;
269
+ }
270
+ }
271
+ if (needUpdate) {
272
+ update();
273
+ }
274
+ validate();
275
+ }));
276
+ disposables.add(quickPick.onDidChangeValue(validate));
277
+ let icon = DEFAULT_ICON;
278
+ if (profile?.icon) {
279
+ icon = ThemeIcon.fromId(profile.icon);
280
+ }
281
+ if (isUserDataProfileTemplate(source) && source.icon) {
282
+ icon = ThemeIcon.fromId(source.icon);
283
+ }
284
+ if (icon.id !== DEFAULT_ICON.id && !( (ICONS.some(({ id }) => id === icon.id))) && !( (getAllCodicons().some(({ id }) => id === icon.id)))) {
285
+ icon = DEFAULT_ICON;
286
+ }
287
+ let result;
288
+ disposables.add(Event.any(quickPick.onDidCustom, quickPick.onDidAccept)(() => {
289
+ const name = quickPick.value.trim();
290
+ if (!name) {
291
+ quickPick.validationMessage = ( localizeWithPath(_moduleId, 19, "Profile name is required and must be a non-empty value."));
292
+ quickPick.severity = Severity$1.Error;
293
+ }
294
+ if (quickPick.validationMessage) {
295
+ return;
296
+ }
297
+ result = { name, items: quickPick.selectedItems, icon: icon.id === DEFAULT_ICON.id ? null : icon.id };
298
+ quickPick.hide();
299
+ quickPick.severity = Severity$1.Ignore;
300
+ quickPick.validationMessage = undefined;
301
+ }));
302
+ const domNode = $('.profile-edit-widget');
303
+ const profileIconContainer = $('.profile-icon-container');
304
+ append(profileIconContainer, $('.profile-icon-label', undefined, ( localizeWithPath(_moduleId, 20, "Icon:"))));
305
+ const profileIconElement = append(profileIconContainer, $(`.profile-icon${ThemeIcon.asCSSSelector(icon)}`));
306
+ profileIconElement.tabIndex = 0;
307
+ profileIconElement.role = 'button';
308
+ profileIconElement.ariaLabel = ( localizeWithPath(_moduleId, 21, "Icon: {0}", icon.id));
309
+ const iconSelectBox = disposables.add(this.instantiationService.createInstance(WorkbenchIconSelectBox, { icons: ICONS, inputBoxStyles: defaultInputBoxStyles }));
310
+ const dimension = new Dimension(486, 260);
311
+ iconSelectBox.layout(dimension);
312
+ let hoverWidget;
313
+ const updateIcon = (updated) => {
314
+ icon = updated ?? DEFAULT_ICON;
315
+ profileIconElement.className = `profile-icon ${ThemeIcon.asClassName(icon)}`;
316
+ profileIconElement.ariaLabel = ( localizeWithPath(_moduleId, 21, "Icon: {0}", icon.id));
317
+ };
318
+ disposables.add(iconSelectBox.onDidSelect(selectedIcon => {
319
+ if (icon.id !== selectedIcon.id) {
320
+ updateIcon(selectedIcon);
321
+ }
322
+ hoverWidget?.dispose();
323
+ profileIconElement.focus();
324
+ }));
325
+ const showIconSelectBox = () => {
326
+ iconSelectBox.clearInput();
327
+ hoverWidget = this.hoverService.showHover({
328
+ content: iconSelectBox.domNode,
329
+ target: profileIconElement,
330
+ position: {
331
+ hoverPosition: 2 ,
332
+ },
333
+ persistence: {
334
+ sticky: true,
335
+ },
336
+ appearance: {
337
+ showPointer: true,
338
+ },
339
+ }, true);
340
+ if (hoverWidget) {
341
+ iconSelectBox.layout(dimension);
342
+ disposables.add(hoverWidget);
343
+ }
344
+ iconSelectBox.focus();
345
+ };
346
+ disposables.add(addDisposableListener(profileIconElement, EventType.CLICK, (e) => {
347
+ EventHelper.stop(e, true);
348
+ showIconSelectBox();
349
+ }));
350
+ disposables.add(addDisposableListener(profileIconElement, EventType.KEY_DOWN, e => {
351
+ const event = ( (new StandardKeyboardEvent(e)));
352
+ if (event.equals(3 ) || event.equals(10 )) {
353
+ EventHelper.stop(event, true);
354
+ showIconSelectBox();
355
+ }
356
+ }));
357
+ disposables.add(addDisposableListener(iconSelectBox.domNode, EventType.KEY_DOWN, e => {
358
+ const event = ( (new StandardKeyboardEvent(e)));
359
+ if (event.equals(9 )) {
360
+ EventHelper.stop(event, true);
361
+ hoverWidget?.dispose();
362
+ profileIconElement.focus();
363
+ }
364
+ }));
365
+ if (!profile && !isUserDataProfileTemplate(source)) {
366
+ const profileTypeContainer = append(domNode, $('.profile-type-container'));
367
+ append(profileTypeContainer, $('.profile-type-create-label', undefined, ( localizeWithPath(_moduleId, 22, "Copy from:"))));
368
+ const separator = { text: '\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500', isDisabled: true };
369
+ const profileOptions = [];
370
+ profileOptions.push({ text: ( localizeWithPath(_moduleId, 23, "None")) });
371
+ const templates = await this.userDataProfileManagementService.getBuiltinProfileTemplates();
372
+ if (templates.length) {
373
+ profileOptions.push({ ...separator, decoratorRight: ( localizeWithPath(_moduleId, 24, "Profile Templates")) });
374
+ for (const template of templates) {
375
+ profileOptions.push({ text: template.name, id: template.url, source: ( (URI.parse(template.url))) });
376
+ }
377
+ }
378
+ profileOptions.push({ ...separator, decoratorRight: ( localizeWithPath(_moduleId, 25, "Existing Profiles")) });
379
+ for (const profile of this.userDataProfilesService.profiles) {
380
+ profileOptions.push({ text: profile.name, id: profile.id, source: profile });
381
+ }
382
+ const findOptionIndex = () => {
383
+ const index = profileOptions.findIndex(option => {
384
+ if (source instanceof URI) {
385
+ return option.source instanceof URI && this.uriIdentityService.extUri.isEqual(option.source, source);
386
+ }
387
+ else if (isUserDataProfile(source)) {
388
+ return option.id === source.id;
389
+ }
390
+ return false;
391
+ });
392
+ return index > -1 ? index : 0;
393
+ };
394
+ const initialIndex = findOptionIndex();
395
+ const selectBox = disposables.add(this.instantiationService.createInstance(SelectBox, profileOptions, initialIndex, this.contextViewService, defaultSelectBoxStyles, {
396
+ useCustomDrawn: true,
397
+ ariaLabel: ( localizeWithPath(_moduleId, 26, "Copy profile from")),
398
+ }));
399
+ selectBox.render(append(profileTypeContainer, $('.profile-type-select-container')));
400
+ if (profileOptions[initialIndex].source) {
401
+ quickPick.value = this.generateProfileName(profileOptions[initialIndex].text);
402
+ }
403
+ const updateOptions = () => {
404
+ const option = profileOptions[findOptionIndex()];
405
+ for (const resource of resources) {
406
+ resource.picked = option.source && !(option.source instanceof URI) ? !option.source?.useDefaultFlags?.[resource.id] : true;
407
+ }
408
+ updateIcon(!(option.source instanceof URI) && option.source?.icon ? ThemeIcon.fromId(option.source.icon) : undefined);
409
+ update();
410
+ };
411
+ updateOptions();
412
+ disposables.add(selectBox.onDidSelect(({ index }) => {
413
+ source = profileOptions[index].source;
414
+ updateOptions();
415
+ }));
416
+ }
417
+ append(domNode, profileIconContainer);
418
+ quickPick.widget = domNode;
419
+ quickPick.show();
420
+ await ( (new Promise((c, e) => {
421
+ disposables.add(quickPick.onDidHide(() => {
422
+ disposables.dispose();
423
+ c();
424
+ }));
425
+ })));
426
+ if (!result) {
427
+ if (profile) {
428
+ this.telemetryService.publicLog2('userDataProfile.cancelEdit');
429
+ }
430
+ else {
431
+ this.telemetryService.publicLog2('userDataProfile.cancelCreate', createProfileTelemetryData);
432
+ }
433
+ return;
434
+ }
435
+ try {
436
+ const useDefaultFlags = result.items.length === resources.length
437
+ ? undefined
438
+ : {
439
+ settings: !result.items.includes(settings),
440
+ keybindings: !result.items.includes(keybindings),
441
+ snippets: !result.items.includes(snippets),
442
+ tasks: !result.items.includes(tasks),
443
+ extensions: !result.items.includes(extensions)
444
+ };
445
+ if (profile) {
446
+ await this.userDataProfileManagementService.updateProfile(profile, { name: result.name, icon: result.icon, useDefaultFlags: profile.useDefaultFlags && !useDefaultFlags ? {} : useDefaultFlags });
447
+ }
448
+ else {
449
+ if (source instanceof URI) {
450
+ this.telemetryService.publicLog2('userDataProfile.createFromTemplate', createProfileTelemetryData);
451
+ await this.importProfile(source, { mode: 'apply', name: result.name, useDefaultFlags, icon: result.icon ? result.icon : undefined });
452
+ }
453
+ else if (isUserDataProfile(source)) {
454
+ this.telemetryService.publicLog2('userDataProfile.createFromProfile', createProfileTelemetryData);
455
+ await this.createFromProfile(source, result.name, { useDefaultFlags, icon: result.icon ? result.icon : undefined });
456
+ }
457
+ else if (isUserDataProfileTemplate(source)) {
458
+ source.name = result.name;
459
+ this.telemetryService.publicLog2('userDataProfile.createFromExternalTemplate', createProfileTelemetryData);
460
+ await this.createAndSwitch(source, false, true, { useDefaultFlags, icon: result.icon ? result.icon : undefined }, ( localizeWithPath(_moduleId, 4, "Create Profile")));
461
+ }
462
+ else {
463
+ this.telemetryService.publicLog2('userDataProfile.createEmptyProfile', createProfileTelemetryData);
464
+ await this.userDataProfileManagementService.createAndEnterProfile(result.name, { useDefaultFlags, icon: result.icon ? result.icon : undefined });
465
+ }
466
+ }
467
+ }
468
+ catch (error) {
469
+ this.notificationService.error(error);
470
+ }
471
+ }
472
+ async showProfileContents() {
473
+ const view = this.viewsService.getViewWithId(EXPORT_PROFILE_PREVIEW_VIEW);
474
+ if (view) {
475
+ this.viewsService.openView(view.id, true);
476
+ return;
477
+ }
478
+ const disposables = ( (new DisposableStore()));
479
+ try {
480
+ const userDataProfilesExportState = disposables.add(this.instantiationService.createInstance(UserDataProfileExportState, this.userDataProfileService.currentProfile));
481
+ const barrier = ( (new Barrier()));
482
+ const exportAction = ( (new BarrierAction(barrier, (new Action('export', ( localizeWithPath(_moduleId, 27, "Export")), undefined, true, async () => {
483
+ exportAction.enabled = false;
484
+ try {
485
+ await this.doExportProfile(userDataProfilesExportState);
486
+ }
487
+ catch (error) {
488
+ exportAction.enabled = true;
489
+ this.notificationService.error(error);
490
+ throw error;
491
+ }
492
+ })), this.notificationService)));
493
+ const closeAction = ( (new BarrierAction(barrier, (new Action('close', ( localizeWithPath(_moduleId, 28, "Close")))), this.notificationService)));
494
+ await this.showProfilePreviewView(EXPORT_PROFILE_PREVIEW_VIEW, userDataProfilesExportState.profile.name, exportAction, closeAction, true, userDataProfilesExportState);
495
+ disposables.add(this.userDataProfileService.onDidChangeCurrentProfile(e => barrier.open()));
496
+ await barrier.wait();
497
+ await this.hideProfilePreviewView(EXPORT_PROFILE_PREVIEW_VIEW);
498
+ }
499
+ finally {
500
+ disposables.dispose();
501
+ }
502
+ }
503
+ async createFromProfile(profile, name, options) {
504
+ const userDataProfilesExportState = this.instantiationService.createInstance(UserDataProfileExportState, profile);
505
+ try {
506
+ const profileTemplate = await userDataProfilesExportState.getProfileTemplate(name, options?.icon);
507
+ await this.progressService.withProgress({
508
+ location: 15 ,
509
+ delay: 500,
510
+ sticky: true,
511
+ }, async (progress) => {
512
+ const reportProgress = (message) => progress.report({ message: ( localizeWithPath(_moduleId, 29, "Create Profile: {0}", message)) });
513
+ const createdProfile = await this.doCreateProfile(profileTemplate, false, false, { useDefaultFlags: options?.useDefaultFlags, icon: options?.icon }, reportProgress);
514
+ if (createdProfile) {
515
+ reportProgress(( localizeWithPath(_moduleId, 30, "Applying Extensions...")));
516
+ await this.instantiationService.createInstance(ExtensionsResource).copy(profile, createdProfile, false);
517
+ reportProgress(( localizeWithPath(_moduleId, 31, "Switching Profile...")));
518
+ await this.userDataProfileManagementService.switchProfile(createdProfile);
519
+ }
520
+ });
521
+ }
522
+ finally {
523
+ userDataProfilesExportState.dispose();
524
+ }
525
+ }
526
+ async createTroubleshootProfile() {
527
+ const userDataProfilesExportState = this.instantiationService.createInstance(UserDataProfileExportState, this.userDataProfileService.currentProfile);
528
+ try {
529
+ const profileTemplate = await userDataProfilesExportState.getProfileTemplate(( localizeWithPath(_moduleId, 32, "Troubleshoot Issue")), undefined);
530
+ await this.progressService.withProgress({
531
+ location: 15 ,
532
+ delay: 1000,
533
+ sticky: true,
534
+ }, async (progress) => {
535
+ const reportProgress = (message) => progress.report({ message: ( localizeWithPath(_moduleId, 33, "Setting up Troubleshoot Profile: {0}", message)) });
536
+ const profile = await this.doCreateProfile(profileTemplate, true, false, { useDefaultFlags: this.userDataProfileService.currentProfile.useDefaultFlags }, reportProgress);
537
+ if (profile) {
538
+ reportProgress(( localizeWithPath(_moduleId, 30, "Applying Extensions...")));
539
+ await this.instantiationService.createInstance(ExtensionsResource).copy(this.userDataProfileService.currentProfile, profile, true);
540
+ reportProgress(( localizeWithPath(_moduleId, 31, "Switching Profile...")));
541
+ await this.userDataProfileManagementService.switchProfile(profile);
542
+ }
543
+ });
544
+ }
545
+ finally {
546
+ userDataProfilesExportState.dispose();
547
+ }
548
+ }
549
+ async doExportProfile(userDataProfilesExportState) {
550
+ const profile = await userDataProfilesExportState.getProfileToExport();
551
+ if (!profile) {
552
+ return;
553
+ }
554
+ this.isProfileExportInProgressContextKey.set(true);
555
+ const disposables = ( (new DisposableStore()));
556
+ disposables.add(toDisposable(() => this.isProfileExportInProgressContextKey.set(false)));
557
+ try {
558
+ await this.progressService.withProgress({
559
+ location: EXPORT_PROFILE_PREVIEW_VIEW,
560
+ title: ( localizeWithPath(_moduleId, 34, "{0}: Exporting...", PROFILES_CATEGORY.value)),
561
+ }, async (progress) => {
562
+ const id = await this.pickProfileContentHandler(profile.name);
563
+ if (!id) {
564
+ return;
565
+ }
566
+ const profileContentHandler = this.profileContentHandlers.get(id);
567
+ if (!profileContentHandler) {
568
+ return;
569
+ }
570
+ const saveResult = await profileContentHandler.saveProfile(profile.name.replace('/', '-'), JSON.stringify(profile), CancellationToken.None);
571
+ if (!saveResult) {
572
+ return;
573
+ }
574
+ const message = ( localizeWithPath(_moduleId, 35, "Profile '{0}' was exported successfully.", profile.name));
575
+ if (profileContentHandler.extensionId) {
576
+ const buttons = [];
577
+ const link = this.productService.webUrl ? `${this.productService.webUrl}/${PROFILE_URL_AUTHORITY}/${id}/${saveResult.id}` : ( (toUserDataProfileUri(`/${id}/${saveResult.id}`, this.productService).toString()));
578
+ buttons.push({
579
+ label: ( localizeWithPath(_moduleId, 36, "&&Copy Link")),
580
+ run: () => this.clipboardService.writeText(link)
581
+ });
582
+ if (this.productService.webUrl) {
583
+ buttons.push({
584
+ label: ( localizeWithPath(_moduleId, 37, "&&Open Link")),
585
+ run: async () => {
586
+ await this.openerService.open(link);
587
+ }
588
+ });
589
+ }
590
+ else {
591
+ buttons.push({
592
+ label: ( localizeWithPath(_moduleId, 38, "&&Open in {0}", profileContentHandler.name)),
593
+ run: async () => {
594
+ await this.openerService.open(( (saveResult.link.toString())));
595
+ }
596
+ });
597
+ }
598
+ await this.dialogService.prompt({
599
+ type: Severity$1.Info,
600
+ message,
601
+ buttons,
602
+ cancelButton: ( localizeWithPath(_moduleId, 28, "Close"))
603
+ });
604
+ }
605
+ else {
606
+ await this.dialogService.info(message);
607
+ }
608
+ });
609
+ }
610
+ finally {
611
+ disposables.dispose();
612
+ }
613
+ }
614
+ async resolveProfileTemplate(uri, options) {
615
+ const profileContent = await this.resolveProfileContent(uri);
616
+ if (profileContent === null) {
617
+ return null;
618
+ }
619
+ const profileTemplate = JSON.parse(profileContent);
620
+ if (!isUserDataProfileTemplate(profileTemplate)) {
621
+ throw ( (new Error('Invalid profile content.')));
622
+ }
623
+ if (options?.name) {
624
+ profileTemplate.name = options.name;
625
+ }
626
+ if (options?.icon) {
627
+ profileTemplate.icon = options.icon;
628
+ }
629
+ return profileTemplate;
630
+ }
631
+ async importAndPreviewProfile(uri, profileTemplate, options) {
632
+ const disposables = ( (new DisposableStore()));
633
+ try {
634
+ const userDataProfileImportState = disposables.add(this.instantiationService.createInstance(UserDataProfileImportState, profileTemplate));
635
+ profileTemplate = await userDataProfileImportState.getProfileTemplateToImport();
636
+ const importedProfile = await this.createAndSwitch(profileTemplate, true, false, options, ( localizeWithPath(_moduleId, 2, "Preview Profile")));
637
+ if (!importedProfile) {
638
+ return;
639
+ }
640
+ const barrier = ( (new Barrier()));
641
+ const importAction = this.getCreateAction(barrier, userDataProfileImportState);
642
+ const primaryAction = isWeb
643
+ ? ( (new Action('importInDesktop', ( localizeWithPath(_moduleId, 39, "Create Profile in {0}", this.productService.nameLong)), undefined, true, async () => this.openerService.open(uri, { openExternal: true }))))
644
+ : importAction;
645
+ const secondaryAction = isWeb
646
+ ? importAction
647
+ : ( (new BarrierAction(barrier, (new Action('close', ( localizeWithPath(_moduleId, 28, "Close")))), this.notificationService)));
648
+ const view = await this.showProfilePreviewView(IMPORT_PROFILE_PREVIEW_VIEW, importedProfile.name, primaryAction, secondaryAction, false, userDataProfileImportState);
649
+ const message = ( (new MarkdownString()));
650
+ message.appendMarkdown(( localizeWithPath(
651
+ _moduleId,
652
+ 40,
653
+ "By default, extensions aren't installed when previewing a profile on the web. You can still install them manually before importing the profile. "
654
+ )));
655
+ message.appendMarkdown(`[${( localizeWithPath(_moduleId, 41, "Learn more"))}](https://aka.ms/vscode-extension-marketplace#_can-i-trust-extensions-from-the-marketplace).`);
656
+ view.setMessage(message);
657
+ const that = this;
658
+ const disposable = disposables.add(registerAction2(class extends Action2 {
659
+ constructor() {
660
+ super({
661
+ id: 'previewProfile.installExtensions',
662
+ title: ( localizeWithPath(_moduleId, 42, "Install Extensions")),
663
+ icon: Codicon.cloudDownload,
664
+ menu: {
665
+ id: MenuId.ViewItemContext,
666
+ group: 'inline',
667
+ when: ( (ContextKeyExpr.and(
668
+ (ContextKeyExpr.equals('view', IMPORT_PROFILE_PREVIEW_VIEW)),
669
+ (ContextKeyExpr.equals('viewItem', "extensions" ))
670
+ ))),
671
+ }
672
+ });
673
+ }
674
+ async run() {
675
+ return that.progressService.withProgress({
676
+ location: IMPORT_PROFILE_PREVIEW_VIEW,
677
+ }, async (progress) => {
678
+ view.setMessage(undefined);
679
+ const profileTemplate = await userDataProfileImportState.getProfileTemplateToImport();
680
+ if (profileTemplate.extensions) {
681
+ await that.instantiationService.createInstance(ExtensionsResource).apply(profileTemplate.extensions, importedProfile);
682
+ }
683
+ disposable.dispose();
684
+ });
685
+ }
686
+ }));
687
+ disposables.add(Event.debounce(this.extensionManagementService.onDidInstallExtensions, () => undefined, 100)(async () => {
688
+ const profileTemplate = await userDataProfileImportState.getProfileTemplateToImport();
689
+ if (profileTemplate.extensions) {
690
+ const profileExtensions = await that.instantiationService.createInstance(ExtensionsResource).getProfileExtensions(profileTemplate.extensions);
691
+ const installed = await this.extensionManagementService.getInstalled(1 );
692
+ if (profileExtensions.every(e => ( (installed.some(i => areSameExtensions(e.identifier, i.identifier)))))) {
693
+ disposable.dispose();
694
+ }
695
+ }
696
+ }));
697
+ await barrier.wait();
698
+ await this.hideProfilePreviewView(IMPORT_PROFILE_PREVIEW_VIEW);
699
+ }
700
+ finally {
701
+ disposables.dispose();
702
+ }
703
+ }
704
+ async previewProfile(profileTemplate, options) {
705
+ const disposables = ( (new DisposableStore()));
706
+ try {
707
+ const userDataProfileImportState = disposables.add(this.instantiationService.createInstance(UserDataProfileImportState, profileTemplate));
708
+ if (userDataProfileImportState.isEmpty()) {
709
+ await this.createAndSwitch(profileTemplate, false, true, options, ( localizeWithPath(_moduleId, 4, "Create Profile")));
710
+ }
711
+ else {
712
+ const barrier = ( (new Barrier()));
713
+ const cancelAction = ( (new BarrierAction(barrier, (new Action('cancel', ( localizeWithPath(_moduleId, 43, "Cancel")))), this.notificationService)));
714
+ const importAction = this.getCreateAction(barrier, userDataProfileImportState, cancelAction);
715
+ await this.showProfilePreviewView(IMPORT_PROFILE_PREVIEW_VIEW, profileTemplate.name, importAction, cancelAction, false, userDataProfileImportState);
716
+ await barrier.wait();
717
+ await this.hideProfilePreviewView(IMPORT_PROFILE_PREVIEW_VIEW);
718
+ }
719
+ }
720
+ finally {
721
+ disposables.dispose();
722
+ }
723
+ }
724
+ getCreateAction(barrier, userDataProfileImportState, cancelAction) {
725
+ const importAction = ( (new BarrierAction(barrier, (new Action('title', ( localizeWithPath(_moduleId, 44, "Create Profile")), undefined, true, async () => {
726
+ importAction.enabled = false;
727
+ if (cancelAction) {
728
+ cancelAction.enabled = false;
729
+ }
730
+ const profileTemplate = await userDataProfileImportState.getProfileTemplateToImport();
731
+ return this.saveProfile(undefined, profileTemplate);
732
+ })), this.notificationService)));
733
+ return importAction;
734
+ }
735
+ async createAndSwitch(profileTemplate, temporaryProfile, extensions, options, title) {
736
+ return this.progressService.withProgress({
737
+ location: 15 ,
738
+ delay: 500,
739
+ sticky: true,
740
+ }, async (progress) => {
741
+ title = `${title} (${profileTemplate.name})`;
742
+ progress.report({ message: title });
743
+ const reportProgress = (message) => progress.report({ message: `${title}: ${message}` });
744
+ const profile = await this.doCreateProfile(profileTemplate, temporaryProfile, extensions, options, reportProgress);
745
+ if (profile) {
746
+ reportProgress(( localizeWithPath(_moduleId, 31, "Switching Profile...")));
747
+ await this.userDataProfileManagementService.switchProfile(profile);
748
+ }
749
+ return profile;
750
+ });
751
+ }
752
+ async doCreateProfile(profileTemplate, temporaryProfile, extensions, options, progress) {
753
+ const profile = await this.getProfileToImport(profileTemplate, temporaryProfile, options);
754
+ if (!profile) {
755
+ return undefined;
756
+ }
757
+ if (profileTemplate.settings && !profile.useDefaultFlags?.settings) {
758
+ progress(( localizeWithPath(_moduleId, 45, "Applying Settings...")));
759
+ await this.instantiationService.createInstance(SettingsResource).apply(profileTemplate.settings, profile);
760
+ }
761
+ if (profileTemplate.keybindings && !profile.useDefaultFlags?.keybindings) {
762
+ progress(( localizeWithPath(_moduleId, 46, "Applying Keyboard Shortcuts...")));
763
+ await this.instantiationService.createInstance(KeybindingsResource).apply(profileTemplate.keybindings, profile);
764
+ }
765
+ if (profileTemplate.tasks && !profile.useDefaultFlags?.tasks) {
766
+ progress(( localizeWithPath(_moduleId, 47, "Applying Tasks...")));
767
+ await this.instantiationService.createInstance(TasksResource).apply(profileTemplate.tasks, profile);
768
+ }
769
+ if (profileTemplate.snippets && !profile.useDefaultFlags?.snippets) {
770
+ progress(( localizeWithPath(_moduleId, 48, "Applying Snippets...")));
771
+ await this.instantiationService.createInstance(SnippetsResource).apply(profileTemplate.snippets, profile);
772
+ }
773
+ if (profileTemplate.globalState && !profile.useDefaultFlags?.globalState) {
774
+ progress(( localizeWithPath(_moduleId, 49, "Applying State...")));
775
+ await this.instantiationService.createInstance(GlobalStateResource).apply(profileTemplate.globalState, profile);
776
+ }
777
+ if (profileTemplate.extensions && extensions && !profile.useDefaultFlags?.extensions) {
778
+ progress(( localizeWithPath(_moduleId, 30, "Applying Extensions...")));
779
+ await this.instantiationService.createInstance(ExtensionsResource).apply(profileTemplate.extensions, profile);
780
+ }
781
+ return profile;
782
+ }
783
+ async resolveProfileContent(resource) {
784
+ if (await this.fileUserDataProfileContentHandler.canHandle(resource)) {
785
+ return this.fileUserDataProfileContentHandler.readProfile(resource, CancellationToken.None);
786
+ }
787
+ if (this.isProfileURL(resource)) {
788
+ let handlerId, idOrUri;
789
+ if (resource.authority === PROFILE_URL_AUTHORITY) {
790
+ idOrUri = this.uriIdentityService.extUri.basename(resource);
791
+ handlerId = this.uriIdentityService.extUri.basename(this.uriIdentityService.extUri.dirname(resource));
792
+ }
793
+ else {
794
+ handlerId = resource.authority.substring(UserDataProfileImportExportService_1.PROFILE_URL_AUTHORITY_PREFIX.length);
795
+ idOrUri = ( (URI.parse(resource.path.substring(1))));
796
+ }
797
+ await this.extensionService.activateByEvent(`onProfile:${handlerId}`);
798
+ const profileContentHandler = this.profileContentHandlers.get(handlerId);
799
+ if (profileContentHandler) {
800
+ return profileContentHandler.readProfile(idOrUri, CancellationToken.None);
801
+ }
802
+ }
803
+ await this.extensionService.activateByEvent('onProfile');
804
+ for (const profileContentHandler of ( (this.profileContentHandlers.values()))) {
805
+ const content = await profileContentHandler.readProfile(resource, CancellationToken.None);
806
+ if (content !== null) {
807
+ return content;
808
+ }
809
+ }
810
+ const context = await this.requestService.request({ type: 'GET', url: ( (resource.toString(true))) }, CancellationToken.None);
811
+ if (context.res.statusCode === 200) {
812
+ return await asText(context);
813
+ }
814
+ else {
815
+ const message = await asText(context);
816
+ throw ( (new Error(
817
+ `Failed to get profile from URL: ${( (resource.toString()))}. Status code: ${context.res.statusCode}. Message: ${message}`
818
+ )));
819
+ }
820
+ }
821
+ async pickProfileContentHandler(name) {
822
+ await this.extensionService.activateByEvent('onProfile');
823
+ if (this.profileContentHandlers.size === 1) {
824
+ return ( (this.profileContentHandlers.keys())).next().value;
825
+ }
826
+ const options = [];
827
+ for (const [id, profileContentHandler] of this.profileContentHandlers) {
828
+ options.push({ id, label: profileContentHandler.name, description: profileContentHandler.description });
829
+ }
830
+ const result = await this.quickInputService.pick(options.reverse(), {
831
+ title: ( localizeWithPath(_moduleId, 50, "Export '{0}' profile as...", name)),
832
+ hideInput: true
833
+ });
834
+ return result?.id;
835
+ }
836
+ async getProfileToImport(profileTemplate, temp, options) {
837
+ const profileName = profileTemplate.name;
838
+ const profile = this.userDataProfilesService.profiles.find(p => p.name === profileName);
839
+ if (profile) {
840
+ if (temp) {
841
+ return this.userDataProfilesService.createNamedProfile(`${profileName} ${this.getProfileNameIndex(profileName)}`, { ...options, transient: temp });
842
+ }
843
+ let ImportProfileChoice;
844
+ ( ((function(ImportProfileChoice) {
845
+ ImportProfileChoice[ImportProfileChoice["Overwrite"] = 0] = "Overwrite";
846
+ ImportProfileChoice[ImportProfileChoice["CreateNew"] = 1] = "CreateNew";
847
+ ImportProfileChoice[ImportProfileChoice["Cancel"] = 2] = "Cancel";
848
+ })(ImportProfileChoice || (ImportProfileChoice = {}))));
849
+ const { result } = await this.dialogService.prompt({
850
+ type: Severity$1.Info,
851
+ message: ( localizeWithPath(
852
+ _moduleId,
853
+ 51,
854
+ "Profile with name '{0}' already exists. Do you want to overwrite it?",
855
+ profileName
856
+ )),
857
+ buttons: [
858
+ {
859
+ label: ( localizeWithPath(_moduleId, 52, "&&Overwrite")),
860
+ run: () => ImportProfileChoice.Overwrite
861
+ },
862
+ {
863
+ label: ( localizeWithPath(_moduleId, 53, "&&Create New Profile")),
864
+ run: () => ImportProfileChoice.CreateNew
865
+ },
866
+ ],
867
+ cancelButton: {
868
+ run: () => ImportProfileChoice.Cancel
869
+ }
870
+ });
871
+ if (result === ImportProfileChoice.Overwrite) {
872
+ return profile;
873
+ }
874
+ if (result === ImportProfileChoice.Cancel) {
875
+ return undefined;
876
+ }
877
+ const name = await this.quickInputService.input({
878
+ placeHolder: ( localizeWithPath(_moduleId, 54, "Profile name")),
879
+ title: ( localizeWithPath(_moduleId, 55, "Create New Profile")),
880
+ value: `${profileName} ${this.getProfileNameIndex(profileName)}`,
881
+ validateInput: async (value) => {
882
+ if (( (this.userDataProfilesService.profiles.some(p => p.name === value)))) {
883
+ return ( localizeWithPath(_moduleId, 16, "Profile with name {0} already exists.", value));
884
+ }
885
+ return undefined;
886
+ }
887
+ });
888
+ if (!name) {
889
+ return undefined;
890
+ }
891
+ return this.userDataProfilesService.createNamedProfile(name);
892
+ }
893
+ else {
894
+ return this.userDataProfilesService.createNamedProfile(profileName, { ...options, transient: temp });
895
+ }
896
+ }
897
+ generateProfileName(profileName) {
898
+ const existingProfile = this.userDataProfilesService.profiles.find(p => p.name === profileName);
899
+ return existingProfile ? `${profileName} ${this.getProfileNameIndex(profileName)}` : profileName;
900
+ }
901
+ getProfileNameIndex(name) {
902
+ const nameRegEx = ( (new RegExp(`${escapeRegExpCharacters(name)}\\s(\\d+)`)));
903
+ let nameIndex = 0;
904
+ for (const profile of this.userDataProfilesService.profiles) {
905
+ const matches = nameRegEx.exec(profile.name);
906
+ const index = matches ? parseInt(matches[1]) : 0;
907
+ nameIndex = index > nameIndex ? index : nameIndex;
908
+ }
909
+ return nameIndex + 1;
910
+ }
911
+ async showProfilePreviewView(id, name, primary, secondary, refreshAction, userDataProfilesData) {
912
+ const viewsRegistry = ( (Registry.as(Extensions.ViewsRegistry)));
913
+ const treeView = this.instantiationService.createInstance(TreeView, id, name);
914
+ if (refreshAction) {
915
+ treeView.showRefreshAction = true;
916
+ }
917
+ const actionRunner = ( (new ActionRunner()));
918
+ const descriptor = {
919
+ id,
920
+ name: { value: name, original: name },
921
+ ctorDescriptor: ( (new SyncDescriptor(
922
+ UserDataProfilePreviewViewPane,
923
+ [userDataProfilesData, primary, secondary, actionRunner]
924
+ ))),
925
+ canToggleVisibility: false,
926
+ canMoveView: false,
927
+ treeView,
928
+ collapsed: false,
929
+ };
930
+ viewsRegistry.registerViews([descriptor], this.viewContainer);
931
+ return (await this.viewsService.openView(id, true));
932
+ }
933
+ async hideProfilePreviewView(id) {
934
+ const viewsRegistry = ( (Registry.as(Extensions.ViewsRegistry)));
935
+ const viewDescriptor = viewsRegistry.getView(id);
936
+ if (viewDescriptor) {
937
+ viewDescriptor.treeView.dispose();
938
+ viewsRegistry.deregisterViews([viewDescriptor], this.viewContainer);
939
+ }
940
+ await this.closeAllImportExportPreviewEditors();
941
+ }
942
+ async closeAllImportExportPreviewEditors() {
943
+ const editorsToColse = this.editorService.getEditors(1 ).filter(({ editor }) => editor.resource?.scheme === USER_DATA_PROFILE_EXPORT_SCHEME || editor.resource?.scheme === USER_DATA_PROFILE_EXPORT_PREVIEW_SCHEME || editor.resource?.scheme === USER_DATA_PROFILE_IMPORT_PREVIEW_SCHEME);
944
+ if (editorsToColse.length) {
945
+ await this.editorService.closeEditors(editorsToColse);
946
+ }
947
+ }
948
+ async setProfile(profile) {
949
+ await this.progressService.withProgress({
950
+ location: 15 ,
951
+ title: ( localizeWithPath(_moduleId, 56, "{0}: Applying...", PROFILES_CATEGORY.value)),
952
+ }, async (progress) => {
953
+ if (profile.settings) {
954
+ await this.instantiationService.createInstance(SettingsResource).apply(profile.settings, this.userDataProfileService.currentProfile);
955
+ }
956
+ if (profile.globalState) {
957
+ await this.instantiationService.createInstance(GlobalStateResource).apply(profile.globalState, this.userDataProfileService.currentProfile);
958
+ }
959
+ if (profile.extensions) {
960
+ await this.instantiationService.createInstance(ExtensionsResource).apply(profile.extensions, this.userDataProfileService.currentProfile);
961
+ }
962
+ });
963
+ this.notificationService.info(( localizeWithPath(_moduleId, 57, "{0}: Applied successfully.", PROFILES_CATEGORY.value)));
964
+ }
965
+ };
966
+ UserDataProfileImportExportService = UserDataProfileImportExportService_1 = ( (__decorate([
967
+ ( (__param(0, IInstantiationService))),
968
+ ( (__param(1, IUserDataProfileService))),
969
+ ( (__param(2, IViewsService))),
970
+ ( (__param(3, IEditorService))),
971
+ ( (__param(4, IContextKeyService))),
972
+ ( (__param(5, IUserDataProfileManagementService))),
973
+ ( (__param(6, IUserDataProfilesService))),
974
+ ( (__param(7, IExtensionService))),
975
+ ( (__param(8, IExtensionManagementService))),
976
+ ( (__param(9, IQuickInputService))),
977
+ ( (__param(10, INotificationService))),
978
+ ( (__param(11, IProgressService))),
979
+ ( (__param(12, IDialogService))),
980
+ ( (__param(13, IClipboardService))),
981
+ ( (__param(14, IOpenerService))),
982
+ ( (__param(15, IRequestService))),
983
+ ( (__param(16, IURLService))),
984
+ ( (__param(17, IProductService))),
985
+ ( (__param(18, IUriIdentityService))),
986
+ ( (__param(19, ITelemetryService))),
987
+ ( (__param(20, IContextViewService))),
988
+ ( (__param(21, IHoverService))),
989
+ ( (__param(22, ILogService)))
990
+ ], UserDataProfileImportExportService)));
991
+ let FileUserDataProfileContentHandler = class FileUserDataProfileContentHandler {
992
+ constructor(fileDialogService, uriIdentityService, fileService, textFileService) {
993
+ this.fileDialogService = fileDialogService;
994
+ this.uriIdentityService = uriIdentityService;
995
+ this.fileService = fileService;
996
+ this.textFileService = textFileService;
997
+ this.name = ( localizeWithPath(_moduleId, 58, "Local"));
998
+ this.description = ( localizeWithPath(_moduleId, 59, "file"));
999
+ }
1000
+ async saveProfile(name, content, token) {
1001
+ const link = await this.fileDialogService.showSaveDialog({
1002
+ title: ( localizeWithPath(_moduleId, 60, "Save Profile")),
1003
+ filters: PROFILE_FILTER,
1004
+ defaultUri: this.uriIdentityService.extUri.joinPath(await this.fileDialogService.defaultFilePath(), `${name}.${PROFILE_EXTENSION}`),
1005
+ });
1006
+ if (!link) {
1007
+ return null;
1008
+ }
1009
+ await this.textFileService.create([{ resource: link, value: content, options: { overwrite: true } }]);
1010
+ return { link, id: ( (link.toString())) };
1011
+ }
1012
+ async canHandle(uri) {
1013
+ return uri.scheme !== Schemas.http && uri.scheme !== Schemas.https && (await this.fileService.canHandleResource(uri));
1014
+ }
1015
+ async readProfile(uri, token) {
1016
+ if (await this.canHandle(uri)) {
1017
+ return (
1018
+ ((await this.fileService.readFile(uri, undefined, token)).value.toString())
1019
+ );
1020
+ }
1021
+ return null;
1022
+ }
1023
+ async selectProfile() {
1024
+ const profileLocation = await this.fileDialogService.showOpenDialog({
1025
+ canSelectFolders: false,
1026
+ canSelectFiles: true,
1027
+ canSelectMany: false,
1028
+ filters: PROFILE_FILTER,
1029
+ title: ( localizeWithPath(_moduleId, 61, "Select Profile")),
1030
+ });
1031
+ return profileLocation ? profileLocation[0] : null;
1032
+ }
1033
+ };
1034
+ FileUserDataProfileContentHandler = ( (__decorate([
1035
+ ( (__param(0, IFileDialogService))),
1036
+ ( (__param(1, IUriIdentityService))),
1037
+ ( (__param(2, IFileService))),
1038
+ ( (__param(3, ITextFileService)))
1039
+ ], FileUserDataProfileContentHandler)));
1040
+ let UserDataProfilePreviewViewPane = class UserDataProfilePreviewViewPane extends TreeViewPane {
1041
+ constructor(userDataProfileData, primaryAction, secondaryAction, actionRunner, options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, notificationService, hoverService, accessibleViewService) {
1042
+ super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, notificationService, hoverService, accessibleViewService);
1043
+ this.userDataProfileData = userDataProfileData;
1044
+ this.primaryAction = primaryAction;
1045
+ this.secondaryAction = secondaryAction;
1046
+ this.actionRunner = actionRunner;
1047
+ this.totalTreeItemsCount = 0;
1048
+ this.renderDisposables = this._register(( (new DisposableStore())));
1049
+ }
1050
+ renderTreeView(container) {
1051
+ this.treeView.dataProvider = this.userDataProfileData;
1052
+ super.renderTreeView(append(container, $('.profile-view-tree-container')));
1053
+ this.messageContainer = append(container, $('.profile-view-message-container.hide'));
1054
+ this.createButtons(container);
1055
+ this._register(this.treeView.onDidChangeCheckboxState(() => this.updateConfirmButtonEnablement()));
1056
+ this.computeAndLayout();
1057
+ this._register(Event.any(this.userDataProfileData.onDidChangeRoots, this.treeView.onDidCollapseItem, this.treeView.onDidExpandItem)(() => this.computeAndLayout()));
1058
+ }
1059
+ async computeAndLayout() {
1060
+ const roots = await this.userDataProfileData.getRoots();
1061
+ const children = await Promise.all(( (roots.map(async (root) => {
1062
+ let expanded = root.collapsibleState === TreeItemCollapsibleState.Expanded;
1063
+ try {
1064
+ expanded = !this.treeView.isCollapsed(root);
1065
+ }
1066
+ catch (error) { }
1067
+ if (expanded) {
1068
+ const children = await root.getChildren();
1069
+ return children ?? [];
1070
+ }
1071
+ return [];
1072
+ }))));
1073
+ this.totalTreeItemsCount = roots.length + children.flat().length;
1074
+ this.updateConfirmButtonEnablement();
1075
+ if (this.dimension) {
1076
+ this.layoutTreeView(this.dimension.height, this.dimension.width);
1077
+ }
1078
+ }
1079
+ createButtons(container) {
1080
+ this.buttonsContainer = append(container, $('.profile-view-buttons-container'));
1081
+ this.primaryButton = this._register(( (new Button(this.buttonsContainer, { ...defaultButtonStyles }))));
1082
+ this.primaryButton.element.classList.add('profile-view-button');
1083
+ this.primaryButton.label = this.primaryAction.label;
1084
+ this.primaryButton.enabled = this.primaryAction.enabled;
1085
+ this._register(this.primaryButton.onDidClick(() => this.actionRunner.run(this.primaryAction)));
1086
+ this._register(this.primaryAction.onDidChange(e => {
1087
+ if (e.enabled !== undefined) {
1088
+ this.primaryButton.enabled = e.enabled;
1089
+ }
1090
+ }));
1091
+ this.secondaryButton = this._register(( (new Button(this.buttonsContainer, { secondary: true, ...defaultButtonStyles }))));
1092
+ this.secondaryButton.label = this.secondaryAction.label;
1093
+ this.secondaryButton.element.classList.add('profile-view-button');
1094
+ this.secondaryButton.enabled = this.secondaryAction.enabled;
1095
+ this._register(this.secondaryButton.onDidClick(() => this.actionRunner.run(this.secondaryAction)));
1096
+ this._register(this.secondaryAction.onDidChange(e => {
1097
+ if (e.enabled !== undefined) {
1098
+ this.secondaryButton.enabled = e.enabled;
1099
+ }
1100
+ }));
1101
+ }
1102
+ layoutTreeView(height, width) {
1103
+ this.dimension = new Dimension(width, height);
1104
+ let messageContainerHeight = 0;
1105
+ if (!this.messageContainer.classList.contains('hide')) {
1106
+ messageContainerHeight = getClientArea(this.messageContainer).height;
1107
+ }
1108
+ const buttonContainerHeight = 108;
1109
+ this.buttonsContainer.style.height = `${buttonContainerHeight}px`;
1110
+ this.buttonsContainer.style.width = `${width}px`;
1111
+ super.layoutTreeView(Math.min(height - buttonContainerHeight - messageContainerHeight, 22 * this.totalTreeItemsCount), width);
1112
+ }
1113
+ updateConfirmButtonEnablement() {
1114
+ this.primaryButton.enabled = this.primaryAction.enabled && this.userDataProfileData.isEnabled();
1115
+ }
1116
+ setMessage(message) {
1117
+ this.messageContainer.classList.toggle('hide', !message);
1118
+ clearNode(this.messageContainer);
1119
+ if (message) {
1120
+ this.renderDisposables.clear();
1121
+ const rendered = this.renderDisposables.add(renderMarkdown(message, {
1122
+ actionHandler: {
1123
+ callback: (content) => {
1124
+ this.openerService.open(content, { allowCommands: true }).catch(onUnexpectedError);
1125
+ },
1126
+ disposables: this.renderDisposables
1127
+ }
1128
+ }));
1129
+ append(this.messageContainer, rendered.element);
1130
+ }
1131
+ }
1132
+ refresh() {
1133
+ return this.treeView.refresh();
1134
+ }
1135
+ };
1136
+ UserDataProfilePreviewViewPane = ( (__decorate([
1137
+ ( (__param(5, IKeybindingService))),
1138
+ ( (__param(6, IContextMenuService))),
1139
+ ( (__param(7, IConfigurationService))),
1140
+ ( (__param(8, IContextKeyService))),
1141
+ ( (__param(9, IViewDescriptorService))),
1142
+ ( (__param(10, IInstantiationService))),
1143
+ ( (__param(11, IOpenerService))),
1144
+ ( (__param(12, IThemeService))),
1145
+ ( (__param(13, ITelemetryService))),
1146
+ ( (__param(14, INotificationService))),
1147
+ ( (__param(15, IHoverService))),
1148
+ ( (__param(16, IAccessibleViewInformationService)))
1149
+ ], UserDataProfilePreviewViewPane)));
1150
+ const USER_DATA_PROFILE_EXPORT_SCHEME = 'userdataprofileexport';
1151
+ const USER_DATA_PROFILE_EXPORT_PREVIEW_SCHEME = 'userdataprofileexportpreview';
1152
+ const USER_DATA_PROFILE_IMPORT_PREVIEW_SCHEME = 'userdataprofileimportpreview';
1153
+ let UserDataProfileImportExportState = class UserDataProfileImportExportState extends Disposable {
1154
+ constructor(quickInputService) {
1155
+ super();
1156
+ this.quickInputService = quickInputService;
1157
+ this._onDidChangeRoots = this._register(( (new Emitter())));
1158
+ this.onDidChangeRoots = this._onDidChangeRoots.event;
1159
+ this.roots = [];
1160
+ }
1161
+ async getChildren(element) {
1162
+ if (element) {
1163
+ const children = await element.getChildren();
1164
+ if (children) {
1165
+ for (const child of children) {
1166
+ if (child.parent.checkbox && child.checkbox) {
1167
+ child.checkbox.isChecked = child.parent.checkbox.isChecked && child.checkbox.isChecked;
1168
+ }
1169
+ }
1170
+ }
1171
+ return children;
1172
+ }
1173
+ else {
1174
+ this.rootsPromise = undefined;
1175
+ this._onDidChangeRoots.fire();
1176
+ return this.getRoots();
1177
+ }
1178
+ }
1179
+ getRoots() {
1180
+ if (!this.rootsPromise) {
1181
+ this.rootsPromise = (async () => {
1182
+ this.roots = await this.fetchRoots();
1183
+ for (const root of this.roots) {
1184
+ root.checkbox = {
1185
+ isChecked: !root.isFromDefaultProfile(),
1186
+ tooltip: ( localizeWithPath(_moduleId, 62, "Select {0}", root.label.label)),
1187
+ accessibilityInformation: {
1188
+ label: ( localizeWithPath(_moduleId, 62, "Select {0}", root.label.label)),
1189
+ }
1190
+ };
1191
+ if (root.isFromDefaultProfile()) {
1192
+ root.description = ( localizeWithPath(_moduleId, 63, "From Default Profile"));
1193
+ }
1194
+ }
1195
+ return this.roots;
1196
+ })();
1197
+ }
1198
+ return this.rootsPromise;
1199
+ }
1200
+ isEnabled(resourceType) {
1201
+ if (resourceType !== undefined) {
1202
+ return (
1203
+ (this.roots.some(root => root.type === resourceType && this.isSelected(root)))
1204
+ );
1205
+ }
1206
+ return (
1207
+ (this.roots.some(root => this.isSelected(root)))
1208
+ );
1209
+ }
1210
+ async getProfileTemplate(name, icon) {
1211
+ const roots = await this.getRoots();
1212
+ let settings;
1213
+ let keybindings;
1214
+ let tasks;
1215
+ let snippets;
1216
+ let extensions;
1217
+ let globalState;
1218
+ for (const root of roots) {
1219
+ if (!this.isSelected(root)) {
1220
+ continue;
1221
+ }
1222
+ if (root instanceof SettingsResourceTreeItem) {
1223
+ settings = await root.getContent();
1224
+ }
1225
+ else if (root instanceof KeybindingsResourceTreeItem) {
1226
+ keybindings = await root.getContent();
1227
+ }
1228
+ else if (root instanceof TasksResourceTreeItem) {
1229
+ tasks = await root.getContent();
1230
+ }
1231
+ else if (root instanceof SnippetsResourceTreeItem) {
1232
+ snippets = await root.getContent();
1233
+ }
1234
+ else if (root instanceof ExtensionsResourceTreeItem) {
1235
+ extensions = await root.getContent();
1236
+ }
1237
+ else if (root instanceof GlobalStateResourceTreeItem) {
1238
+ globalState = await root.getContent();
1239
+ }
1240
+ }
1241
+ return {
1242
+ name,
1243
+ icon,
1244
+ settings,
1245
+ keybindings,
1246
+ tasks,
1247
+ snippets,
1248
+ extensions,
1249
+ globalState
1250
+ };
1251
+ }
1252
+ isSelected(treeItem) {
1253
+ if (treeItem.checkbox) {
1254
+ return treeItem.checkbox.isChecked || !!treeItem.children?.some(child => child.checkbox?.isChecked);
1255
+ }
1256
+ return true;
1257
+ }
1258
+ };
1259
+ UserDataProfileImportExportState = ( (__decorate([
1260
+ ( (__param(0, IQuickInputService)))
1261
+ ], UserDataProfileImportExportState)));
1262
+ let UserDataProfileExportState = class UserDataProfileExportState extends UserDataProfileImportExportState {
1263
+ constructor(profile, quickInputService, fileService, instantiationService) {
1264
+ super(quickInputService);
1265
+ this.profile = profile;
1266
+ this.fileService = fileService;
1267
+ this.instantiationService = instantiationService;
1268
+ this.disposables = this._register(( (new DisposableStore())));
1269
+ }
1270
+ async fetchRoots() {
1271
+ this.disposables.clear();
1272
+ this.disposables.add(this.fileService.registerProvider(USER_DATA_PROFILE_EXPORT_SCHEME, this._register(( (new InMemoryFileSystemProvider())))));
1273
+ const previewFileSystemProvider = this._register(( (new InMemoryFileSystemProvider())));
1274
+ this.disposables.add(this.fileService.registerProvider(USER_DATA_PROFILE_EXPORT_PREVIEW_SCHEME, previewFileSystemProvider));
1275
+ const roots = [];
1276
+ const exportPreviewProfle = this.createExportPreviewProfile(this.profile);
1277
+ const settingsResource = this.instantiationService.createInstance(SettingsResource);
1278
+ const settingsContent = await settingsResource.getContent(this.profile);
1279
+ await settingsResource.apply(settingsContent, exportPreviewProfle);
1280
+ const settingsResourceTreeItem = this.instantiationService.createInstance(SettingsResourceTreeItem, exportPreviewProfle);
1281
+ if (await settingsResourceTreeItem.hasContent()) {
1282
+ roots.push(settingsResourceTreeItem);
1283
+ }
1284
+ const keybindingsResource = this.instantiationService.createInstance(KeybindingsResource);
1285
+ const keybindingsContent = await keybindingsResource.getContent(this.profile);
1286
+ await keybindingsResource.apply(keybindingsContent, exportPreviewProfle);
1287
+ const keybindingsResourceTreeItem = this.instantiationService.createInstance(KeybindingsResourceTreeItem, exportPreviewProfle);
1288
+ if (await keybindingsResourceTreeItem.hasContent()) {
1289
+ roots.push(keybindingsResourceTreeItem);
1290
+ }
1291
+ const snippetsResource = this.instantiationService.createInstance(SnippetsResource);
1292
+ const snippetsContent = await snippetsResource.getContent(this.profile);
1293
+ await snippetsResource.apply(snippetsContent, exportPreviewProfle);
1294
+ const snippetsResourceTreeItem = this.instantiationService.createInstance(SnippetsResourceTreeItem, exportPreviewProfle);
1295
+ if (await snippetsResourceTreeItem.hasContent()) {
1296
+ roots.push(snippetsResourceTreeItem);
1297
+ }
1298
+ const tasksResource = this.instantiationService.createInstance(TasksResource);
1299
+ const tasksContent = await tasksResource.getContent(this.profile);
1300
+ await tasksResource.apply(tasksContent, exportPreviewProfle);
1301
+ const tasksResourceTreeItem = this.instantiationService.createInstance(TasksResourceTreeItem, exportPreviewProfle);
1302
+ if (await tasksResourceTreeItem.hasContent()) {
1303
+ roots.push(tasksResourceTreeItem);
1304
+ }
1305
+ const globalStateResource = joinPath(exportPreviewProfle.globalStorageHome, 'globalState.json').with({ scheme: USER_DATA_PROFILE_EXPORT_PREVIEW_SCHEME });
1306
+ const globalStateResourceTreeItem = this.instantiationService.createInstance(GlobalStateResourceExportTreeItem, exportPreviewProfle, globalStateResource);
1307
+ const content = await globalStateResourceTreeItem.getContent();
1308
+ if (content) {
1309
+ await this.fileService.writeFile(globalStateResource, VSBuffer.fromString(JSON.stringify(JSON.parse(content), null, '\t')));
1310
+ roots.push(globalStateResourceTreeItem);
1311
+ }
1312
+ const extensionsResourceTreeItem = this.instantiationService.createInstance(ExtensionsResourceExportTreeItem, exportPreviewProfle);
1313
+ if (await extensionsResourceTreeItem.hasContent()) {
1314
+ roots.push(extensionsResourceTreeItem);
1315
+ }
1316
+ previewFileSystemProvider.setReadOnly(true);
1317
+ return roots;
1318
+ }
1319
+ createExportPreviewProfile(profile) {
1320
+ return {
1321
+ id: profile.id,
1322
+ name: profile.name,
1323
+ location: profile.location,
1324
+ isDefault: profile.isDefault,
1325
+ shortName: profile.shortName,
1326
+ icon: profile.icon,
1327
+ globalStorageHome: profile.globalStorageHome,
1328
+ settingsResource: profile.settingsResource.with({ scheme: USER_DATA_PROFILE_EXPORT_SCHEME }),
1329
+ keybindingsResource: profile.keybindingsResource.with({ scheme: USER_DATA_PROFILE_EXPORT_SCHEME }),
1330
+ tasksResource: profile.tasksResource.with({ scheme: USER_DATA_PROFILE_EXPORT_SCHEME }),
1331
+ snippetsHome: profile.snippetsHome.with({ scheme: USER_DATA_PROFILE_EXPORT_SCHEME }),
1332
+ extensionsResource: profile.extensionsResource,
1333
+ cacheHome: profile.cacheHome,
1334
+ useDefaultFlags: profile.useDefaultFlags,
1335
+ isTransient: profile.isTransient
1336
+ };
1337
+ }
1338
+ async getProfileToExport() {
1339
+ let name = this.profile.name;
1340
+ if (this.profile.isDefault) {
1341
+ name = await this.quickInputService.input({
1342
+ placeHolder: ( localizeWithPath(_moduleId, 64, "Name the profile")),
1343
+ title: ( localizeWithPath(_moduleId, 65, "Export Profile")),
1344
+ async validateInput(input) {
1345
+ if (!input.trim()) {
1346
+ return ( localizeWithPath(_moduleId, 66, "Profile name must be provided."));
1347
+ }
1348
+ return undefined;
1349
+ },
1350
+ });
1351
+ if (!name) {
1352
+ return null;
1353
+ }
1354
+ }
1355
+ return super.getProfileTemplate(name, this.profile.icon);
1356
+ }
1357
+ };
1358
+ UserDataProfileExportState = ( (__decorate([
1359
+ ( (__param(1, IQuickInputService))),
1360
+ ( (__param(2, IFileService))),
1361
+ ( (__param(3, IInstantiationService)))
1362
+ ], UserDataProfileExportState)));
1363
+ let UserDataProfileImportState = class UserDataProfileImportState extends UserDataProfileImportExportState {
1364
+ constructor(profile, fileService, quickInputService, instantiationService) {
1365
+ super(quickInputService);
1366
+ this.profile = profile;
1367
+ this.fileService = fileService;
1368
+ this.instantiationService = instantiationService;
1369
+ this.disposables = this._register(( (new DisposableStore())));
1370
+ }
1371
+ async fetchRoots() {
1372
+ this.disposables.clear();
1373
+ const inMemoryProvider = this._register(( (new InMemoryFileSystemProvider())));
1374
+ this.disposables.add(this.fileService.registerProvider(USER_DATA_PROFILE_IMPORT_PREVIEW_SCHEME, inMemoryProvider));
1375
+ const roots = [];
1376
+ const importPreviewProfle = toUserDataProfile(generateUuid(), this.profile.name, URI.file('/root').with({ scheme: USER_DATA_PROFILE_IMPORT_PREVIEW_SCHEME }), URI.file('/cache').with({ scheme: USER_DATA_PROFILE_IMPORT_PREVIEW_SCHEME }));
1377
+ if (this.profile.settings) {
1378
+ const settingsResource = this.instantiationService.createInstance(SettingsResource);
1379
+ await settingsResource.apply(this.profile.settings, importPreviewProfle);
1380
+ const settingsResourceTreeItem = this.instantiationService.createInstance(SettingsResourceTreeItem, importPreviewProfle);
1381
+ if (await settingsResourceTreeItem.hasContent()) {
1382
+ roots.push(settingsResourceTreeItem);
1383
+ }
1384
+ }
1385
+ if (this.profile.keybindings) {
1386
+ const keybindingsResource = this.instantiationService.createInstance(KeybindingsResource);
1387
+ await keybindingsResource.apply(this.profile.keybindings, importPreviewProfle);
1388
+ const keybindingsResourceTreeItem = this.instantiationService.createInstance(KeybindingsResourceTreeItem, importPreviewProfle);
1389
+ if (await keybindingsResourceTreeItem.hasContent()) {
1390
+ roots.push(keybindingsResourceTreeItem);
1391
+ }
1392
+ }
1393
+ if (this.profile.snippets) {
1394
+ const snippetsResource = this.instantiationService.createInstance(SnippetsResource);
1395
+ await snippetsResource.apply(this.profile.snippets, importPreviewProfle);
1396
+ const snippetsResourceTreeItem = this.instantiationService.createInstance(SnippetsResourceTreeItem, importPreviewProfle);
1397
+ if (await snippetsResourceTreeItem.hasContent()) {
1398
+ roots.push(snippetsResourceTreeItem);
1399
+ }
1400
+ }
1401
+ if (this.profile.tasks) {
1402
+ const tasksResource = this.instantiationService.createInstance(TasksResource);
1403
+ await tasksResource.apply(this.profile.tasks, importPreviewProfle);
1404
+ const tasksResourceTreeItem = this.instantiationService.createInstance(TasksResourceTreeItem, importPreviewProfle);
1405
+ if (await tasksResourceTreeItem.hasContent()) {
1406
+ roots.push(tasksResourceTreeItem);
1407
+ }
1408
+ }
1409
+ if (this.profile.globalState) {
1410
+ const globalStateResource = joinPath(importPreviewProfle.globalStorageHome, 'globalState.json');
1411
+ const content = VSBuffer.fromString(JSON.stringify(JSON.parse(this.profile.globalState), null, '\t'));
1412
+ if (content) {
1413
+ await this.fileService.writeFile(globalStateResource, content);
1414
+ roots.push(this.instantiationService.createInstance(GlobalStateResourceImportTreeItem, this.profile.globalState, globalStateResource));
1415
+ }
1416
+ }
1417
+ if (this.profile.extensions) {
1418
+ const extensionsResourceTreeItem = this.instantiationService.createInstance(ExtensionsResourceImportTreeItem, this.profile.extensions);
1419
+ if (await extensionsResourceTreeItem.hasContent()) {
1420
+ roots.push(extensionsResourceTreeItem);
1421
+ }
1422
+ }
1423
+ inMemoryProvider.setReadOnly(true);
1424
+ return roots;
1425
+ }
1426
+ isEmpty() {
1427
+ return !(this.profile.settings || this.profile.keybindings || this.profile.tasks || this.profile.snippets || this.profile.globalState || this.profile.extensions);
1428
+ }
1429
+ async getProfileTemplateToImport() {
1430
+ return this.getProfileTemplate(this.profile.name, this.profile.icon);
1431
+ }
1432
+ };
1433
+ UserDataProfileImportState = ( (__decorate([
1434
+ ( (__param(1, IFileService))),
1435
+ ( (__param(2, IQuickInputService))),
1436
+ ( (__param(3, IInstantiationService)))
1437
+ ], UserDataProfileImportState)));
1438
+ class BarrierAction extends Action {
1439
+ constructor(barrier, action, notificationService) {
1440
+ super(action.id, action.label, action.class, action.enabled, async () => {
1441
+ try {
1442
+ await action.run();
1443
+ }
1444
+ catch (error) {
1445
+ notificationService.error(error);
1446
+ throw error;
1447
+ }
1448
+ barrier.open();
1449
+ });
1450
+ }
1451
+ }
1452
+
1453
+ export { UserDataProfileImportExportService };