@codingame/monaco-vscode-user-data-profile-service-override 5.3.0 → 6.0.1
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.
- package/package.json +2 -2
- package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.js +7 -9
- package/vscode/src/vs/platform/userDataSync/common/extensionsSync.js +21 -20
- package/vscode/src/vs/platform/userDataSync/common/globalStateSync.js +26 -25
- package/vscode/src/vs/platform/userDataSync/common/keybindingsSync.js +26 -25
- package/vscode/src/vs/platform/userDataSync/common/settingsSync.js +20 -18
- package/vscode/src/vs/platform/userDataSync/common/snippetsSync.js +40 -40
- package/vscode/src/vs/platform/userDataSync/common/tasksSync.js +14 -14
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/media/userDataProfilesEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js +4 -3
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.js +91 -25
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditor.js +943 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditorModel.js +481 -0
- package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +2 -1
- package/vscode/src/vs/workbench/services/userDataProfile/browser/extensionsResource.js +14 -8
- package/vscode/src/vs/workbench/services/userDataProfile/browser/globalStateResource.js +10 -8
- package/vscode/src/vs/workbench/services/userDataProfile/browser/keybindingsResource.js +5 -4
- package/vscode/src/vs/workbench/services/userDataProfile/browser/settingsResource.js +7 -6
- package/vscode/src/vs/workbench/services/userDataProfile/browser/snippetsResource.js +4 -3
- package/vscode/src/vs/workbench/services/userDataProfile/browser/tasksResource.js +5 -4
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.js +119 -70
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileInit.js +9 -7
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.js +1 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileStorageService.js +4 -3
- package/vscode/src/vs/workbench/services/userDataSync/browser/userDataSyncInit.js +15 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-user-data-profile-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "CodinGame",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"vscode": "npm:@codingame/monaco-vscode-api@
|
|
29
|
+
"vscode": "npm:@codingame/monaco-vscode-api@6.0.1"
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { Disposable, isDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
3
|
import { Storage } from 'vscode/vscode/vs/base/parts/storage/common/storage';
|
|
4
|
-
import { AbstractStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
4
|
+
import { StorageScope, StorageTarget, AbstractStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
5
5
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
6
6
|
import 'vscode/vscode/vs/base/common/event';
|
|
7
7
|
import 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
|
|
@@ -37,18 +37,16 @@ let AbstractUserDataProfileStorageService = class AbstractUserDataProfileStorage
|
|
|
37
37
|
getItems(storageService) {
|
|
38
38
|
const result = ( new Map());
|
|
39
39
|
const populate = (target) => {
|
|
40
|
-
for (const key of ( storageService.keys(
|
|
41
|
-
result.set(key, { value: storageService.get(key,
|
|
40
|
+
for (const key of ( storageService.keys(StorageScope.PROFILE, target))) {
|
|
41
|
+
result.set(key, { value: storageService.get(key, StorageScope.PROFILE), target });
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
populate(
|
|
45
|
-
populate(
|
|
44
|
+
populate(StorageTarget.USER);
|
|
45
|
+
populate(StorageTarget.MACHINE);
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
48
|
writeItems(storageService, items, target) {
|
|
49
|
-
storageService.storeAll(( Array.from(items.entries()).map(
|
|
50
|
-
([key, value]) => ({ key, value, scope: 0 , target })
|
|
51
|
-
)), true);
|
|
49
|
+
storageService.storeAll(( Array.from(items.entries()).map(([key, value]) => ({ key, value, scope: StorageScope.PROFILE, target }))), true);
|
|
52
50
|
}
|
|
53
51
|
async closeAndDispose(storageDatabase) {
|
|
54
52
|
try {
|
|
@@ -73,7 +71,7 @@ class StorageService extends AbstractStorageService {
|
|
|
73
71
|
return this.profileStorage.init();
|
|
74
72
|
}
|
|
75
73
|
getStorage(scope) {
|
|
76
|
-
return scope ===
|
|
74
|
+
return scope === StorageScope.PROFILE ? this.profileStorage : undefined;
|
|
77
75
|
}
|
|
78
76
|
getLogDetails() { return undefined; }
|
|
79
77
|
async switchToProfile() { }
|
|
@@ -9,12 +9,12 @@ import { compare } from 'vscode/vscode/vs/base/common/strings';
|
|
|
9
9
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
10
10
|
import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment.service';
|
|
11
11
|
import { GlobalExtensionEnablementService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionEnablementService';
|
|
12
|
-
import { DISABLED_EXTENSIONS_STORAGE_PATH, EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT,
|
|
12
|
+
import { DISABLED_EXTENSIONS_STORAGE_PATH, EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT, EXTENSION_INSTALL_SOURCE_CONTEXT, ExtensionInstallSource, ExtensionManagementError, ExtensionManagementErrorCode } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement';
|
|
13
13
|
import { IExtensionManagementService, IExtensionGalleryService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
|
|
14
14
|
import { areSameExtensions } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
|
|
15
15
|
import { ExtensionStorageService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionStorage';
|
|
16
16
|
import { IExtensionStorageService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionStorage.service';
|
|
17
|
-
import { isApplicationScopedExtension } from 'vscode/vscode/vs/platform/extensions/common/extensions';
|
|
17
|
+
import { ExtensionType, isApplicationScopedExtension } from 'vscode/vscode/vs/platform/extensions/common/extensions';
|
|
18
18
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
19
19
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
20
20
|
import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
|
|
@@ -26,7 +26,7 @@ import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProf
|
|
|
26
26
|
import { AbstractSynchroniser, getSyncResourceLogLabel, AbstractInitializer } from 'vscode/vscode/vs/platform/userDataSync/common/abstractSynchronizer';
|
|
27
27
|
import { merge } from './extensionsMerge.js';
|
|
28
28
|
import { IIgnoredExtensionsManagementService } from 'vscode/vscode/vs/platform/userDataSync/common/ignoredExtensions.service';
|
|
29
|
-
import { USER_DATA_SYNC_SCHEME } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
29
|
+
import { SyncResource, USER_DATA_SYNC_SCHEME, Change } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
30
30
|
import { IUserDataSyncStoreService, IUserDataSyncLocalStoreService, IUserDataSyncLogService, IUserDataSyncEnablementService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync.service';
|
|
31
31
|
import { IUserDataProfileStorageService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfileStorageService.service';
|
|
32
32
|
|
|
@@ -34,7 +34,7 @@ async function parseAndMigrateExtensions(syncData, extensionManagementService) {
|
|
|
34
34
|
const extensions = JSON.parse(syncData.content);
|
|
35
35
|
if (syncData.version === 1
|
|
36
36
|
|| syncData.version === 2) {
|
|
37
|
-
const builtinExtensions = (await extensionManagementService.getInstalled(
|
|
37
|
+
const builtinExtensions = (await extensionManagementService.getInstalled(ExtensionType.System)).filter(e => e.isBuiltin);
|
|
38
38
|
for (const extension of extensions) {
|
|
39
39
|
if (syncData.version === 1) {
|
|
40
40
|
if (extension.enabled === false) {
|
|
@@ -69,7 +69,7 @@ function stringify(extensions, format) {
|
|
|
69
69
|
let ExtensionsSynchroniser = class ExtensionsSynchroniser extends AbstractSynchroniser {
|
|
70
70
|
constructor(
|
|
71
71
|
profile, collection, environmentService, fileService, storageService, userDataSyncStoreService, userDataSyncLocalStoreService, extensionManagementService, ignoredExtensionsManagementService, logService, configurationService, userDataSyncEnablementService, telemetryService, extensionStorageService, uriIdentityService, userDataProfileStorageService, instantiationService) {
|
|
72
|
-
super({ syncResource:
|
|
72
|
+
super({ syncResource: SyncResource.Extensions, profile }, collection, fileService, environmentService, storageService, userDataSyncStoreService, userDataSyncLocalStoreService, userDataSyncEnablementService, telemetryService, logService, configurationService, uriIdentityService);
|
|
73
73
|
this.extensionManagementService = extensionManagementService;
|
|
74
74
|
this.ignoredExtensionsManagementService = ignoredExtensionsManagementService;
|
|
75
75
|
this.instantiationService = instantiationService;
|
|
@@ -100,8 +100,8 @@ let ExtensionsSynchroniser = class ExtensionsSynchroniser extends AbstractSynchr
|
|
|
100
100
|
const previewResult = {
|
|
101
101
|
local, remote,
|
|
102
102
|
content: this.getPreviewContent(localExtensions, local.added, local.updated, local.removed),
|
|
103
|
-
localChange: local.added.length > 0 || local.removed.length > 0 || local.updated.length > 0 ?
|
|
104
|
-
remoteChange: remote !== null ?
|
|
103
|
+
localChange: local.added.length > 0 || local.removed.length > 0 || local.updated.length > 0 ? Change.Modified : Change.None,
|
|
104
|
+
remoteChange: remote !== null ? Change.Modified : Change.None,
|
|
105
105
|
};
|
|
106
106
|
const localContent = this.stringify(localExtensions, false);
|
|
107
107
|
return [{
|
|
@@ -171,8 +171,8 @@ let ExtensionsSynchroniser = class ExtensionsSynchroniser extends AbstractSynchr
|
|
|
171
171
|
content: resourcePreview.localContent,
|
|
172
172
|
local,
|
|
173
173
|
remote,
|
|
174
|
-
localChange: local.added.length > 0 || local.removed.length > 0 || local.updated.length > 0 ?
|
|
175
|
-
remoteChange: remote !== null ?
|
|
174
|
+
localChange: local.added.length > 0 || local.removed.length > 0 || local.updated.length > 0 ? Change.Modified : Change.None,
|
|
175
|
+
remoteChange: remote !== null ? Change.Modified : Change.None,
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
async acceptRemote(resourcePreview) {
|
|
@@ -186,8 +186,8 @@ let ExtensionsSynchroniser = class ExtensionsSynchroniser extends AbstractSynchr
|
|
|
186
186
|
content: resourcePreview.remoteContent,
|
|
187
187
|
local,
|
|
188
188
|
remote,
|
|
189
|
-
localChange: local.added.length > 0 || local.removed.length > 0 || local.updated.length > 0 ?
|
|
190
|
-
remoteChange: remote !== null ?
|
|
189
|
+
localChange: local.added.length > 0 || local.removed.length > 0 || local.updated.length > 0 ? Change.Modified : Change.None,
|
|
190
|
+
remoteChange: remote !== null ? Change.Modified : Change.None,
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
@@ -195,18 +195,18 @@ let ExtensionsSynchroniser = class ExtensionsSynchroniser extends AbstractSynchr
|
|
|
195
195
|
content: resourcePreview.remoteContent,
|
|
196
196
|
local: { added: [], removed: [], updated: [] },
|
|
197
197
|
remote: null,
|
|
198
|
-
localChange:
|
|
199
|
-
remoteChange:
|
|
198
|
+
localChange: Change.None,
|
|
199
|
+
remoteChange: Change.None,
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
async applyResult(remoteUserData, lastSyncUserData, resourcePreviews, force) {
|
|
204
204
|
let { skippedExtensions, builtinExtensions, localExtensions } = resourcePreviews[0][0];
|
|
205
205
|
const { local, remote, localChange, remoteChange } = resourcePreviews[0][1];
|
|
206
|
-
if (localChange ===
|
|
206
|
+
if (localChange === Change.None && remoteChange === Change.None) {
|
|
207
207
|
this.logService.info(`${this.syncResourceLogLabel}: No changes found during synchronizing extensions.`);
|
|
208
208
|
}
|
|
209
|
-
if (localChange !==
|
|
209
|
+
if (localChange !== Change.None) {
|
|
210
210
|
await this.backupLocal(JSON.stringify(localExtensions));
|
|
211
211
|
skippedExtensions = await this.localExtensionsProvider.updateLocalExtensions(local.added, local.removed, local.updated, skippedExtensions, this.syncResource.profile);
|
|
212
212
|
}
|
|
@@ -323,7 +323,7 @@ let LocalExtensionsProvider = class LocalExtensionsProvider {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
catch (error) {
|
|
326
|
-
this.logService.info(`${getSyncResourceLogLabel(
|
|
326
|
+
this.logService.info(`${getSyncResourceLogLabel(SyncResource.Extensions, profile)}: Error while parsing extension state`, getErrorMessage(error));
|
|
327
327
|
}
|
|
328
328
|
return syncExntesion;
|
|
329
329
|
}));
|
|
@@ -331,7 +331,7 @@ let LocalExtensionsProvider = class LocalExtensionsProvider {
|
|
|
331
331
|
return { localExtensions, ignoredExtensions };
|
|
332
332
|
}
|
|
333
333
|
async updateLocalExtensions(added, removed, updated, skippedExtensions, profile) {
|
|
334
|
-
const syncResourceLogLabel = getSyncResourceLogLabel(
|
|
334
|
+
const syncResourceLogLabel = getSyncResourceLogLabel(SyncResource.Extensions, profile);
|
|
335
335
|
const extensionsToInstall = [];
|
|
336
336
|
const syncExtensionsToInstall = ( new Map());
|
|
337
337
|
const removeFromSkipped = [];
|
|
@@ -393,10 +393,11 @@ let LocalExtensionsProvider = class LocalExtensionsProvider {
|
|
|
393
393
|
isMachineScoped: false ,
|
|
394
394
|
donotIncludePackAndDependencies: true,
|
|
395
395
|
installGivenVersion: e.pinned && !!e.version,
|
|
396
|
+
pinned: e.pinned,
|
|
396
397
|
installPreReleaseVersion: e.preRelease,
|
|
397
398
|
profileLocation: profile.extensionsResource,
|
|
398
399
|
isApplicationScoped: e.isApplicationScoped,
|
|
399
|
-
context: { [EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT]: true, [
|
|
400
|
+
context: { [EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT]: true, [EXTENSION_INSTALL_SOURCE_CONTEXT]: ExtensionInstallSource.SETTINGS_SYNC }
|
|
400
401
|
}
|
|
401
402
|
});
|
|
402
403
|
syncExtensionsToInstall.set(extension.identifier.id.toLowerCase(), e);
|
|
@@ -477,7 +478,7 @@ let LocalExtensionsProvider = class LocalExtensionsProvider {
|
|
|
477
478
|
async withProfileScopedServices(profile, fn) {
|
|
478
479
|
return this.userDataProfileStorageService.withProfileScopedStorageService(profile, async (storageService) => {
|
|
479
480
|
const disposables = ( new DisposableStore());
|
|
480
|
-
const instantiationService = this.instantiationService.createChild(( new ServiceCollection([IStorageService, storageService])));
|
|
481
|
+
const instantiationService = disposables.add(this.instantiationService.createChild(( new ServiceCollection([IStorageService, storageService]))));
|
|
481
482
|
const extensionEnablementService = disposables.add(instantiationService.createInstance(GlobalExtensionEnablementService));
|
|
482
483
|
const extensionStorageService = disposables.add(instantiationService.createInstance(ExtensionStorageService));
|
|
483
484
|
try {
|
|
@@ -499,7 +500,7 @@ LocalExtensionsProvider = ( __decorate([
|
|
|
499
500
|
], LocalExtensionsProvider));
|
|
500
501
|
let AbstractExtensionsInitializer = class AbstractExtensionsInitializer extends AbstractInitializer {
|
|
501
502
|
constructor(extensionManagementService, ignoredExtensionsManagementService, fileService, userDataProfilesService, environmentService, logService, storageService, uriIdentityService) {
|
|
502
|
-
super(
|
|
503
|
+
super(SyncResource.Extensions, userDataProfilesService, environmentService, logService, fileService, storageService, uriIdentityService);
|
|
503
504
|
this.extensionManagementService = extensionManagementService;
|
|
504
505
|
this.ignoredExtensionsManagementService = ignoredExtensionsManagementService;
|
|
505
506
|
}
|
|
@@ -11,13 +11,14 @@ import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/commo
|
|
|
11
11
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
12
12
|
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
13
13
|
import { getServiceMachineId } from 'vscode/vscode/vs/platform/externalServices/common/serviceMachineId';
|
|
14
|
+
import { StorageTarget, StorageScope } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
14
15
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
15
16
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
16
17
|
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
17
18
|
import { AbstractSynchroniser, getSyncResourceLogLabel, AbstractInitializer, isSyncData } from 'vscode/vscode/vs/platform/userDataSync/common/abstractSynchronizer';
|
|
18
19
|
import { edit } from 'vscode/vscode/vs/platform/userDataSync/common/content';
|
|
19
20
|
import { merge } from './globalStateMerge.js';
|
|
20
|
-
import { USER_DATA_SYNC_SCHEME, ALL_SYNC_RESOURCES, getEnablementKey, SYNC_SERVICE_URL_TYPE, createSyncHeaders, UserDataSyncError } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
21
|
+
import { SyncResource, USER_DATA_SYNC_SCHEME, Change, ALL_SYNC_RESOURCES, getEnablementKey, SYNC_SERVICE_URL_TYPE, createSyncHeaders, UserDataSyncError, UserDataSyncErrorCode } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
21
22
|
import { IUserDataSyncStoreService, IUserDataSyncLocalStoreService, IUserDataSyncLogService, IUserDataSyncEnablementService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync.service';
|
|
22
23
|
import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
23
24
|
import { IUserDataProfileStorageService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfileStorageService.service';
|
|
@@ -35,7 +36,7 @@ function stringify(globalState, format) {
|
|
|
35
36
|
const GLOBAL_STATE_DATA_VERSION = 1;
|
|
36
37
|
let GlobalStateSynchroniser = class GlobalStateSynchroniser extends AbstractSynchroniser {
|
|
37
38
|
constructor(profile, collection, userDataProfileStorageService, fileService, userDataSyncStoreService, userDataSyncLocalStoreService, logService, environmentService, userDataSyncEnablementService, telemetryService, configurationService, storageService, uriIdentityService, instantiationService) {
|
|
38
|
-
super({ syncResource:
|
|
39
|
+
super({ syncResource: SyncResource.GlobalState, profile }, collection, fileService, environmentService, storageService, userDataSyncStoreService, userDataSyncLocalStoreService, userDataSyncEnablementService, telemetryService, logService, configurationService, uriIdentityService);
|
|
39
40
|
this.userDataProfileStorageService = userDataProfileStorageService;
|
|
40
41
|
this.version = GLOBAL_STATE_DATA_VERSION;
|
|
41
42
|
this.previewResource = this.extUri.joinPath(this.syncPreviewFolder, 'globalState.json');
|
|
@@ -51,7 +52,7 @@ let GlobalStateSynchroniser = class GlobalStateSynchroniser extends AbstractSync
|
|
|
51
52
|
return true;
|
|
52
53
|
}
|
|
53
54
|
if (( e.valueChanges.some(
|
|
54
|
-
({ profile, changes }) => this.syncResource.profile.id === profile.id && ( changes.some(change => change.target ===
|
|
55
|
+
({ profile, changes }) => this.syncResource.profile.id === profile.id && ( changes.some(change => change.target === StorageTarget.USER))
|
|
55
56
|
))) {
|
|
56
57
|
return true;
|
|
57
58
|
}
|
|
@@ -75,8 +76,8 @@ let GlobalStateSynchroniser = class GlobalStateSynchroniser extends AbstractSync
|
|
|
75
76
|
content: null,
|
|
76
77
|
local,
|
|
77
78
|
remote,
|
|
78
|
-
localChange: ( Object.keys(local.added)).length > 0 || ( Object.keys(local.updated)).length > 0 || local.removed.length > 0 ?
|
|
79
|
-
remoteChange: remote.all !== null ?
|
|
79
|
+
localChange: ( Object.keys(local.added)).length > 0 || ( Object.keys(local.updated)).length > 0 || local.removed.length > 0 ? Change.Modified : Change.None,
|
|
80
|
+
remoteChange: remote.all !== null ? Change.Modified : Change.None,
|
|
80
81
|
};
|
|
81
82
|
const localContent = stringify(localGlobalState, false);
|
|
82
83
|
return [{
|
|
@@ -125,8 +126,8 @@ let GlobalStateSynchroniser = class GlobalStateSynchroniser extends AbstractSync
|
|
|
125
126
|
content: resourcePreview.localContent,
|
|
126
127
|
local: { added: {}, removed: [], updated: {} },
|
|
127
128
|
remote: { added: ( Object.keys(resourcePreview.localUserData.storage)), removed: [], updated: [], all: resourcePreview.localUserData.storage },
|
|
128
|
-
localChange:
|
|
129
|
-
remoteChange:
|
|
129
|
+
localChange: Change.None,
|
|
130
|
+
remoteChange: Change.Modified,
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
async acceptRemote(resourcePreview) {
|
|
@@ -137,8 +138,8 @@ let GlobalStateSynchroniser = class GlobalStateSynchroniser extends AbstractSync
|
|
|
137
138
|
content: resourcePreview.remoteContent,
|
|
138
139
|
local,
|
|
139
140
|
remote,
|
|
140
|
-
localChange: ( Object.keys(local.added)).length > 0 || ( Object.keys(local.updated)).length > 0 || local.removed.length > 0 ?
|
|
141
|
-
remoteChange: remote !== null ?
|
|
141
|
+
localChange: ( Object.keys(local.added)).length > 0 || ( Object.keys(local.updated)).length > 0 || local.removed.length > 0 ? Change.Modified : Change.None,
|
|
142
|
+
remoteChange: remote !== null ? Change.Modified : Change.None,
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
145
|
else {
|
|
@@ -146,24 +147,24 @@ let GlobalStateSynchroniser = class GlobalStateSynchroniser extends AbstractSync
|
|
|
146
147
|
content: resourcePreview.remoteContent,
|
|
147
148
|
local: { added: {}, removed: [], updated: {} },
|
|
148
149
|
remote: { added: [], removed: [], updated: [], all: null },
|
|
149
|
-
localChange:
|
|
150
|
-
remoteChange:
|
|
150
|
+
localChange: Change.None,
|
|
151
|
+
remoteChange: Change.None,
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
async applyResult(remoteUserData, lastSyncUserData, resourcePreviews, force) {
|
|
155
156
|
const { localUserData } = resourcePreviews[0][0];
|
|
156
157
|
const { local, remote, localChange, remoteChange } = resourcePreviews[0][1];
|
|
157
|
-
if (localChange ===
|
|
158
|
+
if (localChange === Change.None && remoteChange === Change.None) {
|
|
158
159
|
this.logService.info(`${this.syncResourceLogLabel}: No changes found during synchronizing ui state.`);
|
|
159
160
|
}
|
|
160
|
-
if (localChange !==
|
|
161
|
+
if (localChange !== Change.None) {
|
|
161
162
|
this.logService.trace(`${this.syncResourceLogLabel}: Updating local ui state...`);
|
|
162
163
|
await this.backupLocal(JSON.stringify(localUserData));
|
|
163
164
|
await this.localGlobalStateProvider.writeLocalGlobalState(local, this.syncResource.profile);
|
|
164
165
|
this.logService.info(`${this.syncResourceLogLabel}: Updated local ui state`);
|
|
165
166
|
}
|
|
166
|
-
if (remoteChange !==
|
|
167
|
+
if (remoteChange !== Change.None) {
|
|
167
168
|
this.logService.trace(`${this.syncResourceLogLabel}: Updating remote ui state...`);
|
|
168
169
|
const content = JSON.stringify({ storage: remote.all });
|
|
169
170
|
remoteUserData = await this.updateRemoteUserData(content, force ? null : remoteUserData.ref);
|
|
@@ -200,10 +201,10 @@ let GlobalStateSynchroniser = class GlobalStateSynchroniser extends AbstractSync
|
|
|
200
201
|
const storageData = await this.userDataProfileStorageService.readStorageData(this.syncResource.profile);
|
|
201
202
|
const user = [], machine = [];
|
|
202
203
|
for (const [key, value] of storageData) {
|
|
203
|
-
if (value.target ===
|
|
204
|
+
if (value.target === StorageTarget.USER) {
|
|
204
205
|
user.push(key);
|
|
205
206
|
}
|
|
206
|
-
else if (value.target ===
|
|
207
|
+
else if (value.target === StorageTarget.MACHINE) {
|
|
207
208
|
machine.push(key);
|
|
208
209
|
}
|
|
209
210
|
}
|
|
@@ -251,7 +252,7 @@ let LocalGlobalStateProvider = class LocalGlobalStateProvider {
|
|
|
251
252
|
}
|
|
252
253
|
const storageData = await this.userDataProfileStorageService.readStorageData(profile);
|
|
253
254
|
for (const [key, value] of storageData) {
|
|
254
|
-
if (value.value && value.target ===
|
|
255
|
+
if (value.value && value.target === StorageTarget.USER) {
|
|
255
256
|
storage[key] = { version: 1, value: value.value };
|
|
256
257
|
}
|
|
257
258
|
}
|
|
@@ -270,7 +271,7 @@ let LocalGlobalStateProvider = class LocalGlobalStateProvider {
|
|
|
270
271
|
return '{}';
|
|
271
272
|
}
|
|
272
273
|
async writeLocalGlobalState({ added, removed, updated }, profile) {
|
|
273
|
-
const syncResourceLogLabel = getSyncResourceLogLabel(
|
|
274
|
+
const syncResourceLogLabel = getSyncResourceLogLabel(SyncResource.GlobalState, profile);
|
|
274
275
|
const argv = {};
|
|
275
276
|
const updatedStorage = ( new Map());
|
|
276
277
|
const storageData = await this.userDataProfileStorageService.readStorageData(profile);
|
|
@@ -312,7 +313,7 @@ let LocalGlobalStateProvider = class LocalGlobalStateProvider {
|
|
|
312
313
|
}
|
|
313
314
|
if (updatedStorage.size) {
|
|
314
315
|
this.logService.trace(`${syncResourceLogLabel}: Updating global state...`);
|
|
315
|
-
await this.userDataProfileStorageService.updateStorageData(profile, updatedStorage,
|
|
316
|
+
await this.userDataProfileStorageService.updateStorageData(profile, updatedStorage, StorageTarget.USER);
|
|
316
317
|
this.logService.info(`${syncResourceLogLabel}: Updated global state`, [...( updatedStorage.keys())]);
|
|
317
318
|
}
|
|
318
319
|
}
|
|
@@ -325,7 +326,7 @@ LocalGlobalStateProvider = ( __decorate([
|
|
|
325
326
|
], LocalGlobalStateProvider));
|
|
326
327
|
let GlobalStateInitializer = class GlobalStateInitializer extends AbstractInitializer {
|
|
327
328
|
constructor(storageService, fileService, userDataProfilesService, environmentService, logService, uriIdentityService) {
|
|
328
|
-
super(
|
|
329
|
+
super(SyncResource.GlobalState, userDataProfilesService, environmentService, logService, fileService, storageService, uriIdentityService);
|
|
329
330
|
}
|
|
330
331
|
async doInitialize(remoteUserData) {
|
|
331
332
|
const remoteGlobalState = remoteUserData.syncData ? JSON.parse(remoteUserData.syncData.content) : null;
|
|
@@ -340,7 +341,7 @@ let GlobalStateInitializer = class GlobalStateInitializer extends AbstractInitia
|
|
|
340
341
|
argv[key.substring(argvStoragePrefx.length)] = remoteGlobalState.storage[key].value;
|
|
341
342
|
}
|
|
342
343
|
else {
|
|
343
|
-
if (this.storageService.get(key,
|
|
344
|
+
if (this.storageService.get(key, StorageScope.PROFILE) === undefined) {
|
|
344
345
|
storage[key] = remoteGlobalState.storage[key].value;
|
|
345
346
|
}
|
|
346
347
|
}
|
|
@@ -360,7 +361,7 @@ let GlobalStateInitializer = class GlobalStateInitializer extends AbstractInitia
|
|
|
360
361
|
if (( Object.keys(storage)).length) {
|
|
361
362
|
const storageEntries = [];
|
|
362
363
|
for (const key of ( Object.keys(storage))) {
|
|
363
|
-
storageEntries.push({ key, value: storage[key], scope:
|
|
364
|
+
storageEntries.push({ key, value: storage[key], scope: StorageScope.PROFILE, target: StorageTarget.USER });
|
|
364
365
|
}
|
|
365
366
|
this.storageService.storeAll(storageEntries, true);
|
|
366
367
|
}
|
|
@@ -394,7 +395,7 @@ let UserDataSyncStoreTypeSynchronizer = class UserDataSyncStoreTypeSynchronizer
|
|
|
394
395
|
catch (e) {
|
|
395
396
|
if (e instanceof UserDataSyncError) {
|
|
396
397
|
switch (e.code) {
|
|
397
|
-
case
|
|
398
|
+
case UserDataSyncErrorCode.PreconditionFailed:
|
|
398
399
|
this.logService.info(`Failed to synchronize UserDataSyncStoreType as there is a new remote version available. Synchronizing again...`);
|
|
399
400
|
return this.doSync(userDataSyncStoreType, syncHeaders);
|
|
400
401
|
}
|
|
@@ -403,12 +404,12 @@ let UserDataSyncStoreTypeSynchronizer = class UserDataSyncStoreTypeSynchronizer
|
|
|
403
404
|
}
|
|
404
405
|
}
|
|
405
406
|
async doSync(userDataSyncStoreType, syncHeaders) {
|
|
406
|
-
const globalStateUserData = await this.userDataSyncStoreClient.readResource(
|
|
407
|
+
const globalStateUserData = await this.userDataSyncStoreClient.readResource(SyncResource.GlobalState, null, undefined, syncHeaders);
|
|
407
408
|
const remoteGlobalState = this.parseGlobalState(globalStateUserData) || { storage: {} };
|
|
408
409
|
remoteGlobalState.storage[SYNC_SERVICE_URL_TYPE] = { value: userDataSyncStoreType, version: GLOBAL_STATE_DATA_VERSION };
|
|
409
410
|
const machineId = await getServiceMachineId(this.environmentService, this.fileService, this.storageService);
|
|
410
411
|
const syncDataToUpdate = { version: GLOBAL_STATE_DATA_VERSION, machineId, content: stringify(remoteGlobalState, false) };
|
|
411
|
-
await this.userDataSyncStoreClient.writeResource(
|
|
412
|
+
await this.userDataSyncStoreClient.writeResource(SyncResource.GlobalState, JSON.stringify(syncDataToUpdate), globalStateUserData.ref, undefined, syncHeaders);
|
|
412
413
|
}
|
|
413
414
|
parseGlobalState({ content }) {
|
|
414
415
|
if (!content) {
|
|
@@ -3,11 +3,12 @@ import { isNonEmptyArray } from 'vscode/vscode/vs/base/common/arrays';
|
|
|
3
3
|
import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
|
|
4
4
|
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
5
5
|
import { parse } from 'vscode/vscode/vs/base/common/json';
|
|
6
|
-
import { OS } from 'vscode/vscode/vs/base/common/platform';
|
|
6
|
+
import { OS, OperatingSystem } from 'vscode/vscode/vs/base/common/platform';
|
|
7
7
|
import { isUndefined } from 'vscode/vscode/vs/base/common/types';
|
|
8
8
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
9
9
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
10
10
|
import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment.service';
|
|
11
|
+
import { FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
|
|
11
12
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
12
13
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
13
14
|
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
@@ -15,7 +16,7 @@ import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/commo
|
|
|
15
16
|
import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
16
17
|
import { AbstractJsonFileSynchroniser, AbstractInitializer } from 'vscode/vscode/vs/platform/userDataSync/common/abstractSynchronizer';
|
|
17
18
|
import { merge } from './keybindingsMerge.js';
|
|
18
|
-
import { USER_DATA_SYNC_SCHEME, UserDataSyncError, CONFIG_SYNC_KEYBINDINGS_PER_PLATFORM } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
19
|
+
import { SyncResource, USER_DATA_SYNC_SCHEME, UserDataSyncError, UserDataSyncErrorCode, Change, CONFIG_SYNC_KEYBINDINGS_PER_PLATFORM } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
19
20
|
import { IUserDataSyncStoreService, IUserDataSyncLocalStoreService, IUserDataSyncLogService, IUserDataSyncEnablementService, IUserDataSyncUtilService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync.service';
|
|
20
21
|
|
|
21
22
|
const _moduleId = "vs/platform/userDataSync/common/keybindingsSync";
|
|
@@ -26,11 +27,11 @@ function getKeybindingsContentFromSyncContent(syncContent, platformSpecific, log
|
|
|
26
27
|
return isUndefined(parsed.all) ? null : parsed.all;
|
|
27
28
|
}
|
|
28
29
|
switch (OS) {
|
|
29
|
-
case
|
|
30
|
+
case OperatingSystem.Macintosh:
|
|
30
31
|
return isUndefined(parsed.mac) ? null : parsed.mac;
|
|
31
|
-
case
|
|
32
|
+
case OperatingSystem.Linux:
|
|
32
33
|
return isUndefined(parsed.linux) ? null : parsed.linux;
|
|
33
|
-
case
|
|
34
|
+
case OperatingSystem.Windows:
|
|
34
35
|
return isUndefined(parsed.windows) ? null : parsed.windows;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
@@ -41,7 +42,7 @@ function getKeybindingsContentFromSyncContent(syncContent, platformSpecific, log
|
|
|
41
42
|
}
|
|
42
43
|
let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJsonFileSynchroniser {
|
|
43
44
|
constructor(profile, collection, userDataSyncStoreService, userDataSyncLocalStoreService, logService, configurationService, userDataSyncEnablementService, fileService, environmentService, storageService, userDataSyncUtilService, telemetryService, uriIdentityService) {
|
|
44
|
-
super(profile.keybindingsResource, { syncResource:
|
|
45
|
+
super(profile.keybindingsResource, { syncResource: SyncResource.Keybindings, profile }, collection, fileService, environmentService, storageService, userDataSyncStoreService, userDataSyncLocalStoreService, userDataSyncEnablementService, telemetryService, logService, userDataSyncUtilService, configurationService, uriIdentityService);
|
|
45
46
|
this.version = 2;
|
|
46
47
|
this.previewResource = this.extUri.joinPath(this.syncPreviewFolder, 'keybindings.json');
|
|
47
48
|
this.baseResource = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'base' });
|
|
@@ -68,7 +69,7 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
68
69
|
_moduleId,
|
|
69
70
|
0,
|
|
70
71
|
"Unable to sync keybindings because the content in the file is not valid. Please open the file and correct it."
|
|
71
|
-
),
|
|
72
|
+
), UserDataSyncErrorCode.LocalInvalidContent, this.resource));
|
|
72
73
|
}
|
|
73
74
|
if (!lastSyncContent
|
|
74
75
|
|| lastSyncContent !== localContent
|
|
@@ -91,8 +92,8 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
91
92
|
}
|
|
92
93
|
const previewResult = {
|
|
93
94
|
content: hasConflicts ? lastSyncContent : mergedContent,
|
|
94
|
-
localChange: hasLocalChanged ? fileContent ?
|
|
95
|
-
remoteChange: hasRemoteChanged ?
|
|
95
|
+
localChange: hasLocalChanged ? fileContent ? Change.Modified : Change.Added : Change.None,
|
|
96
|
+
remoteChange: hasRemoteChanged ? Change.Modified : Change.None,
|
|
96
97
|
hasConflicts
|
|
97
98
|
};
|
|
98
99
|
const localContent = fileContent ? ( fileContent.value.toString()) : null;
|
|
@@ -129,15 +130,15 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
129
130
|
if (this.extUri.isEqual(resource, this.localResource)) {
|
|
130
131
|
return {
|
|
131
132
|
content: resourcePreview.fileContent ? ( resourcePreview.fileContent.value.toString()) : null,
|
|
132
|
-
localChange:
|
|
133
|
-
remoteChange:
|
|
133
|
+
localChange: Change.None,
|
|
134
|
+
remoteChange: Change.Modified,
|
|
134
135
|
};
|
|
135
136
|
}
|
|
136
137
|
if (this.extUri.isEqual(resource, this.remoteResource)) {
|
|
137
138
|
return {
|
|
138
139
|
content: resourcePreview.remoteContent,
|
|
139
|
-
localChange:
|
|
140
|
-
remoteChange:
|
|
140
|
+
localChange: Change.Modified,
|
|
141
|
+
remoteChange: Change.None,
|
|
141
142
|
};
|
|
142
143
|
}
|
|
143
144
|
if (this.extUri.isEqual(resource, this.previewResource)) {
|
|
@@ -151,8 +152,8 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
151
152
|
else {
|
|
152
153
|
return {
|
|
153
154
|
content,
|
|
154
|
-
localChange:
|
|
155
|
-
remoteChange:
|
|
155
|
+
localChange: Change.Modified,
|
|
156
|
+
remoteChange: Change.Modified,
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
159
|
}
|
|
@@ -161,7 +162,7 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
161
162
|
async applyResult(remoteUserData, lastSyncUserData, resourcePreviews, force) {
|
|
162
163
|
const { fileContent } = resourcePreviews[0][0];
|
|
163
164
|
let { content, localChange, remoteChange } = resourcePreviews[0][1];
|
|
164
|
-
if (localChange ===
|
|
165
|
+
if (localChange === Change.None && remoteChange === Change.None) {
|
|
165
166
|
this.logService.info(`${this.syncResourceLogLabel}: No changes found during synchronizing keybindings.`);
|
|
166
167
|
}
|
|
167
168
|
if (content !== null) {
|
|
@@ -172,10 +173,10 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
172
173
|
_moduleId,
|
|
173
174
|
0,
|
|
174
175
|
"Unable to sync keybindings because the content in the file is not valid. Please open the file and correct it."
|
|
175
|
-
),
|
|
176
|
+
), UserDataSyncErrorCode.LocalInvalidContent, this.resource));
|
|
176
177
|
}
|
|
177
178
|
}
|
|
178
|
-
if (localChange !==
|
|
179
|
+
if (localChange !== Change.None) {
|
|
179
180
|
this.logService.trace(`${this.syncResourceLogLabel}: Updating local keybindings...`);
|
|
180
181
|
if (fileContent) {
|
|
181
182
|
await this.backupLocal(this.toSyncContent(( fileContent.value.toString())));
|
|
@@ -183,7 +184,7 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
183
184
|
await this.updateLocalFileContent(content || '[]', fileContent, force);
|
|
184
185
|
this.logService.info(`${this.syncResourceLogLabel}: Updated local keybindings`);
|
|
185
186
|
}
|
|
186
|
-
if (remoteChange !==
|
|
187
|
+
if (remoteChange !== Change.None) {
|
|
187
188
|
this.logService.trace(`${this.syncResourceLogLabel}: Updating remote keybindings...`);
|
|
188
189
|
const remoteContents = this.toSyncContent(content || '[]', remoteUserData.syncData?.content);
|
|
189
190
|
remoteUserData = await this.updateRemoteUserData(remoteContents, force ? null : remoteUserData.ref);
|
|
@@ -210,7 +211,7 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
213
|
catch (error) {
|
|
213
|
-
if (error.fileOperationResult !==
|
|
214
|
+
if (error.fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) {
|
|
214
215
|
return true;
|
|
215
216
|
}
|
|
216
217
|
}
|
|
@@ -249,13 +250,13 @@ let KeybindingsSynchroniser = class KeybindingsSynchroniser extends AbstractJson
|
|
|
249
250
|
parsed.all = keybindingsContent;
|
|
250
251
|
}
|
|
251
252
|
switch (OS) {
|
|
252
|
-
case
|
|
253
|
+
case OperatingSystem.Macintosh:
|
|
253
254
|
parsed.mac = keybindingsContent;
|
|
254
255
|
break;
|
|
255
|
-
case
|
|
256
|
+
case OperatingSystem.Linux:
|
|
256
257
|
parsed.linux = keybindingsContent;
|
|
257
258
|
break;
|
|
258
|
-
case
|
|
259
|
+
case OperatingSystem.Windows:
|
|
259
260
|
parsed.windows = keybindingsContent;
|
|
260
261
|
break;
|
|
261
262
|
}
|
|
@@ -280,7 +281,7 @@ KeybindingsSynchroniser = ( __decorate([
|
|
|
280
281
|
], KeybindingsSynchroniser));
|
|
281
282
|
let KeybindingsInitializer = class KeybindingsInitializer extends AbstractInitializer {
|
|
282
283
|
constructor(fileService, userDataProfilesService, environmentService, logService, storageService, uriIdentityService) {
|
|
283
|
-
super(
|
|
284
|
+
super(SyncResource.Keybindings, userDataProfilesService, environmentService, logService, fileService, storageService, uriIdentityService);
|
|
284
285
|
}
|
|
285
286
|
async doInitialize(remoteUserData) {
|
|
286
287
|
const keybindingsContent = remoteUserData.syncData ? this.getKeybindingsContentFromSyncContent(remoteUserData.syncData.content) : null;
|
|
@@ -303,7 +304,7 @@ let KeybindingsInitializer = class KeybindingsInitializer extends AbstractInitia
|
|
|
303
304
|
return !isNonEmptyArray(keybindings);
|
|
304
305
|
}
|
|
305
306
|
catch (error) {
|
|
306
|
-
return error.fileOperationResult ===
|
|
307
|
+
return error.fileOperationResult === FileOperationResult.FILE_NOT_FOUND;
|
|
307
308
|
}
|
|
308
309
|
}
|
|
309
310
|
getKeybindingsContentFromSyncContent(syncContent) {
|