@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.
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +31 -0
- package/userDataProfile.js +118 -0
- package/vscode/src/vs/platform/userDataProfile/browser/userDataProfile.js +95 -0
- package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.js +84 -0
- package/vscode/src/vs/platform/userDataSync/common/extensionsMerge.js +331 -0
- package/vscode/src/vs/platform/userDataSync/common/extensionsSync.js +545 -0
- package/vscode/src/vs/platform/userDataSync/common/globalStateMerge.js +102 -0
- package/vscode/src/vs/platform/userDataSync/common/globalStateSync.js +431 -0
- package/vscode/src/vs/platform/userDataSync/common/keybindingsMerge.js +277 -0
- package/vscode/src/vs/platform/userDataSync/common/keybindingsSync.js +328 -0
- package/vscode/src/vs/platform/userDataSync/common/settingsSync.js +322 -0
- package/vscode/src/vs/platform/userDataSync/common/snippetsMerge.js +126 -0
- package/vscode/src/vs/platform/userDataSync/common/snippetsSync.js +478 -0
- package/vscode/src/vs/platform/userDataSync/common/tasksSync.js +245 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js +9 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.js +495 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfileActions.js +159 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilePreview.js +24 -0
- package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +62 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/extensionsResource.js +328 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/globalStateResource.js +144 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/keybindingsResource.js +119 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/media/userDataProfileView.css.js +6 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/settingsResource.js +140 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/snippetsResource.js +155 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/tasksResource.js +118 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.js +1453 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileInit.js +151 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.js +180 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileStorageService.js +39 -0
- package/vscode/src/vs/workbench/services/userDataSync/browser/userDataSyncInit.js +448 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
|
|
3
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
4
|
+
import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment.service';
|
|
5
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
6
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
7
|
+
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
8
|
+
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
|
|
9
|
+
import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
10
|
+
import { AbstractFileSynchroniser, AbstractInitializer } from 'vscode/vscode/vs/platform/userDataSync/common/abstractSynchronizer';
|
|
11
|
+
import { USER_DATA_SYNC_SCHEME } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
|
|
12
|
+
import { IUserDataSyncStoreService, IUserDataSyncLocalStoreService, IUserDataSyncLogService, IUserDataSyncEnablementService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync.service';
|
|
13
|
+
|
|
14
|
+
function getTasksContentFromSyncContent(syncContent, logService) {
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(syncContent);
|
|
17
|
+
return parsed.tasks ?? null;
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
logService.error(e);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
let TasksSynchroniser = class TasksSynchroniser extends AbstractFileSynchroniser {
|
|
25
|
+
constructor(profile, collection, userDataSyncStoreService, userDataSyncLocalStoreService, logService, configurationService, userDataSyncEnablementService, fileService, environmentService, storageService, telemetryService, uriIdentityService) {
|
|
26
|
+
super(profile.tasksResource, { syncResource: "tasks" , profile }, collection, fileService, environmentService, storageService, userDataSyncStoreService, userDataSyncLocalStoreService, userDataSyncEnablementService, telemetryService, logService, configurationService, uriIdentityService);
|
|
27
|
+
this.version = 1;
|
|
28
|
+
this.previewResource = this.extUri.joinPath(this.syncPreviewFolder, 'tasks.json');
|
|
29
|
+
this.baseResource = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'base' });
|
|
30
|
+
this.localResource = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'local' });
|
|
31
|
+
this.remoteResource = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'remote' });
|
|
32
|
+
this.acceptedResource = this.previewResource.with({ scheme: USER_DATA_SYNC_SCHEME, authority: 'accepted' });
|
|
33
|
+
}
|
|
34
|
+
async generateSyncPreview(remoteUserData, lastSyncUserData, isRemoteDataFromCurrentMachine, userDataSyncConfiguration) {
|
|
35
|
+
const remoteContent = remoteUserData.syncData ? getTasksContentFromSyncContent(remoteUserData.syncData.content, this.logService) : null;
|
|
36
|
+
lastSyncUserData = lastSyncUserData === null && isRemoteDataFromCurrentMachine ? remoteUserData : lastSyncUserData;
|
|
37
|
+
const lastSyncContent = lastSyncUserData?.syncData ? getTasksContentFromSyncContent(lastSyncUserData.syncData.content, this.logService) : null;
|
|
38
|
+
const fileContent = await this.getLocalFileContent();
|
|
39
|
+
let content = null;
|
|
40
|
+
let hasLocalChanged = false;
|
|
41
|
+
let hasRemoteChanged = false;
|
|
42
|
+
let hasConflicts = false;
|
|
43
|
+
if (remoteUserData.syncData) {
|
|
44
|
+
const localContent = fileContent ? ( fileContent.value.toString()) : null;
|
|
45
|
+
if (!lastSyncContent
|
|
46
|
+
|| lastSyncContent !== localContent
|
|
47
|
+
|| lastSyncContent !== remoteContent
|
|
48
|
+
) {
|
|
49
|
+
this.logService.trace(`${this.syncResourceLogLabel}: Merging remote tasks with local tasks...`);
|
|
50
|
+
const result = merge(localContent, remoteContent, lastSyncContent);
|
|
51
|
+
content = result.content;
|
|
52
|
+
hasConflicts = result.hasConflicts;
|
|
53
|
+
hasLocalChanged = result.hasLocalChanged;
|
|
54
|
+
hasRemoteChanged = result.hasRemoteChanged;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else if (fileContent) {
|
|
58
|
+
this.logService.trace(`${this.syncResourceLogLabel}: Remote tasks does not exist. Synchronizing tasks for the first time.`);
|
|
59
|
+
content = ( fileContent.value.toString());
|
|
60
|
+
hasRemoteChanged = true;
|
|
61
|
+
}
|
|
62
|
+
const previewResult = {
|
|
63
|
+
content: hasConflicts ? lastSyncContent : content,
|
|
64
|
+
localChange: hasLocalChanged ? fileContent ? 2 : 1 : 0 ,
|
|
65
|
+
remoteChange: hasRemoteChanged ? 2 : 0 ,
|
|
66
|
+
hasConflicts
|
|
67
|
+
};
|
|
68
|
+
const localContent = fileContent ? ( fileContent.value.toString()) : null;
|
|
69
|
+
return [{
|
|
70
|
+
fileContent,
|
|
71
|
+
baseResource: this.baseResource,
|
|
72
|
+
baseContent: lastSyncContent,
|
|
73
|
+
localResource: this.localResource,
|
|
74
|
+
localContent,
|
|
75
|
+
localChange: previewResult.localChange,
|
|
76
|
+
remoteResource: this.remoteResource,
|
|
77
|
+
remoteContent,
|
|
78
|
+
remoteChange: previewResult.remoteChange,
|
|
79
|
+
previewResource: this.previewResource,
|
|
80
|
+
previewResult,
|
|
81
|
+
acceptedResource: this.acceptedResource,
|
|
82
|
+
}];
|
|
83
|
+
}
|
|
84
|
+
async hasRemoteChanged(lastSyncUserData) {
|
|
85
|
+
const lastSyncContent = lastSyncUserData?.syncData ? getTasksContentFromSyncContent(lastSyncUserData.syncData.content, this.logService) : null;
|
|
86
|
+
if (lastSyncContent === null) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const fileContent = await this.getLocalFileContent();
|
|
90
|
+
const localContent = fileContent ? ( fileContent.value.toString()) : null;
|
|
91
|
+
const result = merge(localContent, lastSyncContent, lastSyncContent);
|
|
92
|
+
return result.hasLocalChanged || result.hasRemoteChanged;
|
|
93
|
+
}
|
|
94
|
+
async getMergeResult(resourcePreview, token) {
|
|
95
|
+
return resourcePreview.previewResult;
|
|
96
|
+
}
|
|
97
|
+
async getAcceptResult(resourcePreview, resource, content, token) {
|
|
98
|
+
if (this.extUri.isEqual(resource, this.localResource)) {
|
|
99
|
+
return {
|
|
100
|
+
content: resourcePreview.fileContent ? ( resourcePreview.fileContent.value.toString()) : null,
|
|
101
|
+
localChange: 0 ,
|
|
102
|
+
remoteChange: 2 ,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (this.extUri.isEqual(resource, this.remoteResource)) {
|
|
106
|
+
return {
|
|
107
|
+
content: resourcePreview.remoteContent,
|
|
108
|
+
localChange: 2 ,
|
|
109
|
+
remoteChange: 0 ,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (this.extUri.isEqual(resource, this.previewResource)) {
|
|
113
|
+
if (content === undefined) {
|
|
114
|
+
return {
|
|
115
|
+
content: resourcePreview.previewResult.content,
|
|
116
|
+
localChange: resourcePreview.previewResult.localChange,
|
|
117
|
+
remoteChange: resourcePreview.previewResult.remoteChange,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return {
|
|
122
|
+
content,
|
|
123
|
+
localChange: 2 ,
|
|
124
|
+
remoteChange: 2 ,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
throw ( new Error(`Invalid Resource: ${( resource.toString())}`));
|
|
129
|
+
}
|
|
130
|
+
async applyResult(remoteUserData, lastSyncUserData, resourcePreviews, force) {
|
|
131
|
+
const { fileContent } = resourcePreviews[0][0];
|
|
132
|
+
const { content, localChange, remoteChange } = resourcePreviews[0][1];
|
|
133
|
+
if (localChange === 0 && remoteChange === 0 ) {
|
|
134
|
+
this.logService.info(`${this.syncResourceLogLabel}: No changes found during synchronizing tasks.`);
|
|
135
|
+
}
|
|
136
|
+
if (localChange !== 0 ) {
|
|
137
|
+
this.logService.trace(`${this.syncResourceLogLabel}: Updating local tasks...`);
|
|
138
|
+
if (fileContent) {
|
|
139
|
+
await this.backupLocal(JSON.stringify(this.toTasksSyncContent(( fileContent.value.toString()))));
|
|
140
|
+
}
|
|
141
|
+
if (content) {
|
|
142
|
+
await this.updateLocalFileContent(content, fileContent, force);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
await this.deleteLocalFile();
|
|
146
|
+
}
|
|
147
|
+
this.logService.info(`${this.syncResourceLogLabel}: Updated local tasks`);
|
|
148
|
+
}
|
|
149
|
+
if (remoteChange !== 0 ) {
|
|
150
|
+
this.logService.trace(`${this.syncResourceLogLabel}: Updating remote tasks...`);
|
|
151
|
+
const remoteContents = JSON.stringify(this.toTasksSyncContent(content));
|
|
152
|
+
remoteUserData = await this.updateRemoteUserData(remoteContents, force ? null : remoteUserData.ref);
|
|
153
|
+
this.logService.info(`${this.syncResourceLogLabel}: Updated remote tasks`);
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
await this.fileService.del(this.previewResource);
|
|
157
|
+
}
|
|
158
|
+
catch (e) { }
|
|
159
|
+
if (lastSyncUserData?.ref !== remoteUserData.ref) {
|
|
160
|
+
this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized tasks...`);
|
|
161
|
+
await this.updateLastSyncUserData(remoteUserData);
|
|
162
|
+
this.logService.info(`${this.syncResourceLogLabel}: Updated last synchronized tasks`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async hasLocalData() {
|
|
166
|
+
return this.fileService.exists(this.file);
|
|
167
|
+
}
|
|
168
|
+
async resolveContent(uri) {
|
|
169
|
+
if (this.extUri.isEqual(this.remoteResource, uri)
|
|
170
|
+
|| this.extUri.isEqual(this.baseResource, uri)
|
|
171
|
+
|| this.extUri.isEqual(this.localResource, uri)
|
|
172
|
+
|| this.extUri.isEqual(this.acceptedResource, uri)) {
|
|
173
|
+
return this.resolvePreviewContent(uri);
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
toTasksSyncContent(tasks) {
|
|
178
|
+
return tasks ? { tasks } : {};
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
TasksSynchroniser = ( __decorate([
|
|
182
|
+
( __param(2, IUserDataSyncStoreService)),
|
|
183
|
+
( __param(3, IUserDataSyncLocalStoreService)),
|
|
184
|
+
( __param(4, IUserDataSyncLogService)),
|
|
185
|
+
( __param(5, IConfigurationService)),
|
|
186
|
+
( __param(6, IUserDataSyncEnablementService)),
|
|
187
|
+
( __param(7, IFileService)),
|
|
188
|
+
( __param(8, IEnvironmentService)),
|
|
189
|
+
( __param(9, IStorageService)),
|
|
190
|
+
( __param(10, ITelemetryService)),
|
|
191
|
+
( __param(11, IUriIdentityService))
|
|
192
|
+
], TasksSynchroniser));
|
|
193
|
+
let TasksInitializer = class TasksInitializer extends AbstractInitializer {
|
|
194
|
+
constructor(fileService, userDataProfilesService, environmentService, logService, storageService, uriIdentityService) {
|
|
195
|
+
super("tasks" , userDataProfilesService, environmentService, logService, fileService, storageService, uriIdentityService);
|
|
196
|
+
this.tasksResource = this.userDataProfilesService.defaultProfile.tasksResource;
|
|
197
|
+
}
|
|
198
|
+
async doInitialize(remoteUserData) {
|
|
199
|
+
const tasksContent = remoteUserData.syncData ? getTasksContentFromSyncContent(remoteUserData.syncData.content, this.logService) : null;
|
|
200
|
+
if (!tasksContent) {
|
|
201
|
+
this.logService.info('Skipping initializing tasks because remote tasks does not exist.');
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const isEmpty = await this.isEmpty();
|
|
205
|
+
if (!isEmpty) {
|
|
206
|
+
this.logService.info('Skipping initializing tasks because local tasks exist.');
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
await this.fileService.writeFile(this.tasksResource, VSBuffer.fromString(tasksContent));
|
|
210
|
+
await this.updateLastSyncUserData(remoteUserData);
|
|
211
|
+
}
|
|
212
|
+
async isEmpty() {
|
|
213
|
+
return this.fileService.exists(this.tasksResource);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
TasksInitializer = ( __decorate([
|
|
217
|
+
( __param(0, IFileService)),
|
|
218
|
+
( __param(1, IUserDataProfilesService)),
|
|
219
|
+
( __param(2, IEnvironmentService)),
|
|
220
|
+
( __param(3, IUserDataSyncLogService)),
|
|
221
|
+
( __param(4, IStorageService)),
|
|
222
|
+
( __param(5, IUriIdentityService))
|
|
223
|
+
], TasksInitializer));
|
|
224
|
+
function merge(originalLocalContent, originalRemoteContent, baseContent) {
|
|
225
|
+
if (originalLocalContent === null && originalRemoteContent === null && baseContent === null) {
|
|
226
|
+
return { content: null, hasLocalChanged: false, hasRemoteChanged: false, hasConflicts: false };
|
|
227
|
+
}
|
|
228
|
+
if (originalLocalContent === originalRemoteContent) {
|
|
229
|
+
return { content: null, hasLocalChanged: false, hasRemoteChanged: false, hasConflicts: false };
|
|
230
|
+
}
|
|
231
|
+
const localForwarded = baseContent !== originalLocalContent;
|
|
232
|
+
const remoteForwarded = baseContent !== originalRemoteContent;
|
|
233
|
+
if (!localForwarded && !remoteForwarded) {
|
|
234
|
+
return { content: null, hasLocalChanged: false, hasRemoteChanged: false, hasConflicts: false };
|
|
235
|
+
}
|
|
236
|
+
if (localForwarded && !remoteForwarded) {
|
|
237
|
+
return { content: originalLocalContent, hasRemoteChanged: true, hasLocalChanged: false, hasConflicts: false };
|
|
238
|
+
}
|
|
239
|
+
if (remoteForwarded && !localForwarded) {
|
|
240
|
+
return { content: originalRemoteContent, hasLocalChanged: true, hasRemoteChanged: false, hasConflicts: false };
|
|
241
|
+
}
|
|
242
|
+
return { content: originalLocalContent, hasLocalChanged: true, hasRemoteChanged: true, hasConflicts: true };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export { TasksInitializer, TasksSynchroniser, getTasksContentFromSyncContent };
|
package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
2
|
+
import { Extensions, registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
3
|
+
import { UserDataProfilesWorkbenchContribution } from './userDataProfile.js';
|
|
4
|
+
import './userDataProfileActions.js';
|
|
5
|
+
import { UserDataProfilePreviewContribution } from './userDataProfilePreview.js';
|
|
6
|
+
|
|
7
|
+
const workbenchRegistry = ( Registry.as(Extensions.Workbench));
|
|
8
|
+
registerWorkbenchContribution2(UserDataProfilesWorkbenchContribution.ID, UserDataProfilesWorkbenchContribution, 2 );
|
|
9
|
+
workbenchRegistry.registerWorkbenchContribution(UserDataProfilePreviewContribution, 3 );
|