@codingame/monaco-vscode-configuration-service-override 11.1.2 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/index.d.ts +29 -2
  2. package/index.js +138 -1
  3. package/package.json +27 -8
  4. package/vscode/src/vs/editor/common/services/textResourceConfigurationService.d.ts +26 -0
  5. package/vscode/src/vs/editor/common/services/textResourceConfigurationService.js +13 -11
  6. package/vscode/src/vs/workbench/api/common/configurationExtensionPoint.d.ts +1 -0
  7. package/vscode/src/vs/workbench/api/common/configurationExtensionPoint.js +82 -79
  8. package/vscode/src/vs/workbench/contrib/workspaces/browser/workspaces.contribution.d.ts +19 -0
  9. package/vscode/src/vs/workbench/contrib/workspaces/browser/workspaces.contribution.js +31 -32
  10. package/vscode/src/vs/workbench/services/configuration/browser/configuration.d.ts +130 -0
  11. package/vscode/src/vs/workbench/services/configuration/browser/configuration.js +18 -16
  12. package/vscode/src/vs/workbench/services/configuration/browser/configurationService.d.ts +144 -0
  13. package/vscode/src/vs/workbench/services/configuration/browser/configurationService.js +182 -186
  14. package/vscode/src/vs/workbench/services/configuration/common/configurationCache.d.ts +16 -0
  15. package/vscode/src/vs/workbench/services/configuration/common/configurationCache.js +3 -1
  16. package/vscode/src/vs/workbench/services/configuration/common/configurationEditing.d.ts +86 -0
  17. package/vscode/src/vs/workbench/services/configuration/common/configurationEditing.js +219 -194
  18. package/vscode/src/vs/workbench/services/configuration/common/configurationModels.d.ts +43 -0
  19. package/vscode/src/vs/workbench/services/configuration/common/configurationModels.js +1 -0
  20. package/vscode/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.d.ts +37 -0
  21. package/vscode/src/vs/workbench/services/configurationResolver/browser/baseConfigurationResolverService.js +30 -26
  22. package/vscode/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.d.ts +13 -0
  23. package/vscode/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.js +3 -1
  24. package/vscode/src/vs/workbench/services/textresourceProperties/common/textResourcePropertiesService.d.ts +16 -0
  25. package/vscode/src/vs/workbench/services/textresourceProperties/common/textResourcePropertiesService.js +8 -5
  26. package/vscode/src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.d.ts +64 -0
  27. package/vscode/src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.js +54 -53
  28. package/vscode/src/vs/workbench/services/workspaces/browser/workspacesService.d.ts +39 -0
  29. package/vscode/src/vs/workbench/services/workspaces/browser/workspacesService.js +15 -11
  30. package/configuration.js +0 -138
  31. package/tools.js +0 -44
@@ -1,11 +1,13 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
2
3
  import { localize } from 'vscode/vscode/vs/nls';
3
- import { WORKSPACE_FILTER, hasWorkspaceFileExtension, WORKSPACE_EXTENSION, isSavedWorkspace, isUntitledWorkspace, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vscode/vscode/vs/platform/workspace/common/workspace';
4
+ import { WORKSPACE_FILTER, hasWorkspaceFileExtension, WORKSPACE_EXTENSION, isSavedWorkspace, WorkbenchState, isUntitledWorkspace, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vscode/vscode/vs/platform/workspace/common/workspace';
4
5
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
6
+ import { JSONEditingErrorCode } from '@codingame/monaco-vscode-d987325e-3e05-53aa-b9ff-6f97476f64db-common/vscode/vs/workbench/services/configuration/common/jsonEditing';
5
7
  import { IJSONEditingService } from 'vscode/vscode/vs/workbench/services/configuration/common/jsonEditing.service';
6
- import { rewriteWorkspaceFileForNewLocation } from 'vscode/vscode/vs/platform/workspaces/common/workspaces';
8
+ import { rewriteWorkspaceFileForNewLocation } from '@codingame/monaco-vscode-56402b83-4a60-5b15-86f9-71fe99c32744-common/vscode/vs/platform/workspaces/common/workspaces';
7
9
  import { IWorkspacesService } from 'vscode/vscode/vs/platform/workspaces/common/workspaces.service';
8
- import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
10
+ import { ConfigurationScope, Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
9
11
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
10
12
  import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
11
13
  import { distinct } from 'vscode/vscode/vs/base/common/arrays';
@@ -19,13 +21,14 @@ import { mnemonicButtonLabel } from 'vscode/vscode/vs/base/common/labels';
19
21
  import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
20
22
  import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
21
23
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
24
+ import { SaveReason } from 'vscode/vscode/vs/workbench/common/editor';
22
25
  import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
23
26
  import { IWorkspaceTrustManagementService } from 'vscode/vscode/vs/platform/workspace/common/workspaceTrust.service';
24
- import { IWorkbenchConfigurationService } from 'vscode/vscode/vs/workbench/services/configuration/common/configuration.service';
27
+ import { IWorkbenchConfigurationService } from '@codingame/monaco-vscode-422642f2-7e3a-5c1c-9e1e-1d3ef1817346-common/vscode/vs/workbench/services/configuration/common/configuration.service';
25
28
  import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
26
29
  import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
27
30
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
28
- import Severity$1 from 'vscode/vscode/vs/base/common/severity';
31
+ import Severity from 'vscode/vscode/vs/base/common/severity';
29
32
 
30
33
  let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService extends Disposable {
31
34
  constructor(jsonEditingService, contextService, configurationService, notificationService, commandService, fileService, textFileService, workspacesService, environmentService, fileDialogService, dialogService, hostService, uriIdentityService, workspaceTrustManagementService, userDataProfilesService, userDataProfileService) {
@@ -53,8 +56,8 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
53
56
  availableFileSystems.unshift(Schemas.vscodeRemote);
54
57
  }
55
58
  let workspacePath = await this.fileDialogService.showSaveDialog({
56
- saveLabel: mnemonicButtonLabel(( localize(3681, "Save"))),
57
- title: ( localize(3682, "Save Workspace")),
59
+ saveLabel: mnemonicButtonLabel(( localize(12115, "Save"))),
60
+ title: ( localize(12116, "Save Workspace")),
58
61
  filters: WORKSPACE_FILTER,
59
62
  defaultUri: joinPath(await this.fileDialogService.defaultWorkspacePath(), this.getNewWorkspaceName()),
60
63
  availableFileSystems
@@ -82,13 +85,13 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
82
85
  const folders = this.contextService.getWorkspace().folders;
83
86
  let foldersToDelete = [];
84
87
  if (typeof deleteCount === 'number') {
85
- foldersToDelete = ( (folders.slice(index, index + deleteCount).map(folder => folder.uri)));
88
+ foldersToDelete = ( folders.slice(index, index + deleteCount).map(folder => folder.uri));
86
89
  }
87
90
  let foldersToAdd = [];
88
91
  if (Array.isArray(foldersToAddCandidates)) {
89
- foldersToAdd = ( (foldersToAddCandidates.map(
92
+ foldersToAdd = ( foldersToAddCandidates.map(
90
93
  folderToAdd => ({ uri: removeTrailingPathSeparator(folderToAdd.uri), name: folderToAdd.name })
91
- )));
94
+ ));
92
95
  }
93
96
  const wantsToDelete = foldersToDelete.length > 0;
94
97
  const wantsToAdd = foldersToAdd.length > 0;
@@ -105,7 +108,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
105
108
  if (this.includesSingleFolderWorkspace(foldersToDelete)) {
106
109
  return this.createAndEnterWorkspace(foldersToAdd);
107
110
  }
108
- if (this.contextService.getWorkbenchState() !== 3 ) {
111
+ if (this.contextService.getWorkbenchState() !== WorkbenchState.WORKSPACE) {
109
112
  return this.doAddFolders(foldersToAdd, index, donotNotifyError);
110
113
  }
111
114
  return this.doUpdateFolders(foldersToAdd, foldersToDelete, index, donotNotifyError);
@@ -123,18 +126,18 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
123
126
  }
124
127
  }
125
128
  addFolders(foldersToAddCandidates, donotNotifyError = false) {
126
- const foldersToAdd = ( (foldersToAddCandidates.map(
129
+ const foldersToAdd = ( foldersToAddCandidates.map(
127
130
  folderToAdd => ({ uri: removeTrailingPathSeparator(folderToAdd.uri), name: folderToAdd.name })
128
- )));
131
+ ));
129
132
  return this.doAddFolders(foldersToAdd, undefined, donotNotifyError);
130
133
  }
131
134
  async doAddFolders(foldersToAdd, index, donotNotifyError = false) {
132
135
  const state = this.contextService.getWorkbenchState();
133
- if (state !== 3 ) {
134
- let newWorkspaceFolders = ( (this.contextService.getWorkspace().folders.map(folder => ({ uri: folder.uri }))));
136
+ if (state !== WorkbenchState.WORKSPACE) {
137
+ let newWorkspaceFolders = ( this.contextService.getWorkspace().folders.map(folder => ({ uri: folder.uri })));
135
138
  newWorkspaceFolders.splice(typeof index === 'number' ? index : newWorkspaceFolders.length, 0, ...foldersToAdd);
136
139
  newWorkspaceFolders = distinct(newWorkspaceFolders, folder => this.uriIdentityService.extUri.getComparisonKey(folder.uri));
137
- if (state === 1 && newWorkspaceFolders.length === 0 || state === 2 && newWorkspaceFolders.length === 1) {
140
+ if (state === WorkbenchState.EMPTY && newWorkspaceFolders.length === 0 || state === WorkbenchState.FOLDER && newWorkspaceFolders.length === 1) {
138
141
  return;
139
142
  }
140
143
  return this.createAndEnterWorkspace(newWorkspaceFolders);
@@ -164,13 +167,11 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
164
167
  }
165
168
  }
166
169
  includesSingleFolderWorkspace(folders) {
167
- if (this.contextService.getWorkbenchState() === 2 ) {
170
+ if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
168
171
  const workspaceFolder = this.contextService.getWorkspace().folders[0];
169
- return (
170
- (folders.some(
171
- folder => this.uriIdentityService.extUri.isEqual(folder, workspaceFolder.uri)
172
- ))
173
- );
172
+ return ( folders.some(
173
+ folder => this.uriIdentityService.extUri.isEqual(folder, workspaceFolder.uri)
174
+ ));
174
175
  }
175
176
  return false;
176
177
  }
@@ -225,7 +226,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
225
226
  }
226
227
  const isFromUntitledWorkspace = isUntitledWorkspace(configPathURI, this.environmentService);
227
228
  const raw = await this.fileService.readFile(configPathURI);
228
- const newRawWorkspaceContents = rewriteWorkspaceFileForNewLocation(( (raw.value.toString())), configPathURI, isFromUntitledWorkspace, targetConfigPathURI, this.uriIdentityService.extUri);
229
+ const newRawWorkspaceContents = rewriteWorkspaceFileForNewLocation(( raw.value.toString()), configPathURI, isFromUntitledWorkspace, targetConfigPathURI, this.uriIdentityService.extUri);
229
230
  await this.textFileService.create([{ resource: targetConfigPathURI, value: newRawWorkspaceContents, options: { overwrite: true } }]);
230
231
  await this.trustWorkspaceConfiguration(targetConfigPathURI);
231
232
  }
@@ -233,7 +234,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
233
234
  const configPathURI = workspace.configPath;
234
235
  const existingModel = this.textFileService.files.get(configPathURI);
235
236
  if (existingModel) {
236
- await existingModel.save({ force: true, reason: 1 });
237
+ await existingModel.save({ force: true, reason: SaveReason.EXPLICIT });
237
238
  return;
238
239
  }
239
240
  const workspaceFileExists = await this.fileService.exists(configPathURI);
@@ -246,7 +247,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
246
247
  }
247
248
  handleWorkspaceConfigurationEditingError(error) {
248
249
  switch (error.code) {
249
- case 0 :
250
+ case JSONEditingErrorCode.ERROR_INVALID_FILE:
250
251
  this.onInvalidWorkspaceConfigurationFileError();
251
252
  break;
252
253
  default:
@@ -255,38 +256,38 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
255
256
  }
256
257
  onInvalidWorkspaceConfigurationFileError() {
257
258
  const message = ( localize(
258
- 3683,
259
+ 12117,
259
260
  "Unable to write into workspace configuration file. Please open the file to correct errors/warnings in it and try again."
260
261
  ));
261
262
  this.askToOpenWorkspaceConfigurationFile(message);
262
263
  }
263
264
  askToOpenWorkspaceConfigurationFile(message) {
264
- this.notificationService.prompt(Severity$1.Error, message, [{
265
- label: ( localize(3684, "Open Workspace Configuration")),
265
+ this.notificationService.prompt(Severity.Error, message, [{
266
+ label: ( localize(12118, "Open Workspace Configuration")),
266
267
  run: () => this.commandService.executeCommand('workbench.action.openWorkspaceConfigFile')
267
268
  }]);
268
269
  }
269
270
  async doEnterWorkspace(workspaceUri) {
270
271
  if (!!this.environmentService.extensionTestsLocationURI) {
271
- throw ( (new Error('Entering a new workspace is not possible in tests.')));
272
+ throw ( new Error('Entering a new workspace is not possible in tests.'));
272
273
  }
273
274
  const workspace = await this.workspacesService.getWorkspaceIdentifier(workspaceUri);
274
- if (this.contextService.getWorkbenchState() === 2 ) {
275
+ if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) {
275
276
  await this.migrateWorkspaceSettings(workspace);
276
277
  }
277
278
  await this.configurationService.initialize(workspace);
278
279
  return this.workspacesService.enterWorkspace(workspaceUri);
279
280
  }
280
281
  migrateWorkspaceSettings(toWorkspace) {
281
- return this.doCopyWorkspaceSettings(toWorkspace, setting => setting.scope === 3 );
282
+ return this.doCopyWorkspaceSettings(toWorkspace, setting => setting.scope === ConfigurationScope.WINDOW);
282
283
  }
283
284
  copyWorkspaceSettings(toWorkspace) {
284
285
  return this.doCopyWorkspaceSettings(toWorkspace);
285
286
  }
286
287
  doCopyWorkspaceSettings(toWorkspace, filter) {
287
- const configurationProperties = ( (Registry.as(Extensions.Configuration))).getConfigurationProperties();
288
+ const configurationProperties = ( Registry.as(Extensions.Configuration)).getConfigurationProperties();
288
289
  const targetWorkspaceConfiguration = {};
289
- for (const key of ( (this.configurationService.keys())).workspace) {
290
+ for (const key of ( this.configurationService.keys()).workspace) {
290
291
  if (configurationProperties[key]) {
291
292
  if (filter && !filter(configurationProperties[key])) {
292
293
  continue;
@@ -297,7 +298,7 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
297
298
  return this.jsonEditingService.write(toWorkspace.configPath, [{ path: ['settings'], value: targetWorkspaceConfiguration }], true);
298
299
  }
299
300
  async trustWorkspaceConfiguration(configPathURI) {
300
- if (this.contextService.getWorkbenchState() !== 1 && this.workspaceTrustManagementService.isWorkspaceTrusted()) {
301
+ if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.workspaceTrustManagementService.isWorkspaceTrusted()) {
301
302
  await this.workspaceTrustManagementService.setUrisTrust([configPathURI], true);
302
303
  }
303
304
  }
@@ -309,23 +310,23 @@ let AbstractWorkspaceEditingService = class AbstractWorkspaceEditingService exte
309
310
  return undefined;
310
311
  }
311
312
  };
312
- AbstractWorkspaceEditingService = ( (__decorate([
313
- ( (__param(0, IJSONEditingService))),
314
- ( (__param(1, IWorkspaceContextService))),
315
- ( (__param(2, IWorkbenchConfigurationService))),
316
- ( (__param(3, INotificationService))),
317
- ( (__param(4, ICommandService))),
318
- ( (__param(5, IFileService))),
319
- ( (__param(6, ITextFileService))),
320
- ( (__param(7, IWorkspacesService))),
321
- ( (__param(8, IWorkbenchEnvironmentService))),
322
- ( (__param(9, IFileDialogService))),
323
- ( (__param(10, IDialogService))),
324
- ( (__param(11, IHostService))),
325
- ( (__param(12, IUriIdentityService))),
326
- ( (__param(13, IWorkspaceTrustManagementService))),
327
- ( (__param(14, IUserDataProfilesService))),
328
- ( (__param(15, IUserDataProfileService)))
329
- ], AbstractWorkspaceEditingService)));
313
+ AbstractWorkspaceEditingService = ( __decorate([
314
+ ( __param(0, IJSONEditingService)),
315
+ ( __param(1, IWorkspaceContextService)),
316
+ ( __param(2, IWorkbenchConfigurationService)),
317
+ ( __param(3, INotificationService)),
318
+ ( __param(4, ICommandService)),
319
+ ( __param(5, IFileService)),
320
+ ( __param(6, ITextFileService)),
321
+ ( __param(7, IWorkspacesService)),
322
+ ( __param(8, IWorkbenchEnvironmentService)),
323
+ ( __param(9, IFileDialogService)),
324
+ ( __param(10, IDialogService)),
325
+ ( __param(11, IHostService)),
326
+ ( __param(12, IUriIdentityService)),
327
+ ( __param(13, IWorkspaceTrustManagementService)),
328
+ ( __param(14, IUserDataProfilesService)),
329
+ ( __param(15, IUserDataProfileService))
330
+ ], AbstractWorkspaceEditingService));
330
331
 
331
332
  export { AbstractWorkspaceEditingService };
@@ -0,0 +1,39 @@
1
+ import { IWorkspaceFolderCreationData, IEnterWorkspaceResult, IRecentlyOpened, IRecent } from "@codingame/monaco-vscode-56402b83-4a60-5b15-86f9-71fe99c32744-common/vscode/vs/platform/workspaces/common/workspaces";
2
+ import { IWorkspacesService } from "vscode/vscode/vs/platform/workspaces/common/workspaces.service";
3
+ import { URI } from "vscode/vscode/vs/base/common/uri";
4
+ import { IStorageService } from "vscode/vscode/vs/platform/storage/common/storage.service";
5
+ import { IWorkspaceIdentifier } from "vscode/vscode/vs/platform/workspace/common/workspace";
6
+ import { IWorkspaceContextService } from "vscode/vscode/vs/platform/workspace/common/workspace.service";
7
+ import { ILogService } from "vscode/vscode/vs/platform/log/common/log.service";
8
+ import { Disposable } from "vscode/vscode/vs/base/common/lifecycle";
9
+ import { IFileService } from "vscode/vscode/vs/platform/files/common/files.service";
10
+ import { IWorkbenchEnvironmentService } from "vscode/vscode/vs/workbench/services/environment/common/environmentService.service";
11
+ import { IUriIdentityService } from "vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
12
+ import { IWorkspaceBackupInfo, IFolderBackupInfo } from "@codingame/monaco-vscode-56402b83-4a60-5b15-86f9-71fe99c32744-common/vscode/vs/platform/backup/common/backup";
13
+ export declare class BrowserWorkspacesService extends Disposable implements IWorkspacesService {
14
+ private readonly storageService;
15
+ private readonly contextService;
16
+ private readonly logService;
17
+ private readonly fileService;
18
+ private readonly environmentService;
19
+ private readonly uriIdentityService;
20
+ static readonly RECENTLY_OPENED_KEY = "recently.opened";
21
+ readonly _serviceBrand: undefined;
22
+ private readonly _onRecentlyOpenedChange;
23
+ readonly onDidChangeRecentlyOpened: import("vscode/vscode/vs/base/common/event").Event<void>;
24
+ constructor(storageService: IStorageService, contextService: IWorkspaceContextService, logService: ILogService, fileService: IFileService, environmentService: IWorkbenchEnvironmentService, uriIdentityService: IUriIdentityService);
25
+ private registerListeners;
26
+ private onDidChangeWorkspaceFolders;
27
+ private addWorkspaceToRecentlyOpened;
28
+ getRecentlyOpened(): Promise<IRecentlyOpened>;
29
+ addRecentlyOpened(recents: IRecent[]): Promise<void>;
30
+ removeRecentlyOpened(paths: URI[]): Promise<void>;
31
+ private doRemoveRecentlyOpened;
32
+ private saveRecentlyOpened;
33
+ clearRecentlyOpened(): Promise<void>;
34
+ enterWorkspace(workspaceUri: URI): Promise<IEnterWorkspaceResult | undefined>;
35
+ createUntitledWorkspace(folders?: IWorkspaceFolderCreationData[], remoteAuthority?: string): Promise<IWorkspaceIdentifier>;
36
+ deleteUntitledWorkspace(workspace: IWorkspaceIdentifier): Promise<void>;
37
+ getWorkspaceIdentifier(workspaceUri: URI): Promise<IWorkspaceIdentifier>;
38
+ getDirtyWorkspaces(): Promise<Array<IWorkspaceBackupInfo | IFolderBackupInfo>>;
39
+ }
@@ -1,13 +1,17 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { restoreRecentlyOpened, isRecentFolder, isRecentWorkspace, isRecentFile, toStoreData, getStoredWorkspaceFolder } from 'vscode/vscode/vs/platform/workspaces/common/workspaces';
1
+
2
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6';
3
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
4
+ import { restoreRecentlyOpened, isRecentFolder, isRecentWorkspace, isRecentFile, toStoreData, getStoredWorkspaceFolder } from '@codingame/monaco-vscode-56402b83-4a60-5b15-86f9-71fe99c32744-common/vscode/vs/platform/workspaces/common/workspaces';
3
5
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
4
6
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
7
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
5
8
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
6
- import { isTemporaryWorkspace, WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
9
+ import { isTemporaryWorkspace, WorkbenchState, WORKSPACE_EXTENSION } from 'vscode/vscode/vs/platform/workspace/common/workspace';
7
10
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
8
11
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
9
- import { Disposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
12
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
10
13
  import { getWorkspaceIdentifier } from 'vscode/vscode/vs/workbench/services/workspaces/browser/workspaces';
14
+ import { FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
11
15
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
12
16
  import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
13
17
  import { joinPath } from 'vscode/vscode/vs/base/common/resources';
@@ -33,7 +37,7 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
33
37
  this.registerListeners();
34
38
  }
35
39
  registerListeners() {
36
- this._register(this.storageService.onDidChangeValue(-1 , BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, this._register(( new DisposableStore())))(() => this._onRecentlyOpenedChange.fire()));
40
+ this._register(this.storageService.onDidChangeValue(StorageScope.APPLICATION, BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, this._store)(() => this._onRecentlyOpenedChange.fire()));
37
41
  this._register(this.contextService.onDidChangeWorkspaceFolders(e => this.onDidChangeWorkspaceFolders(e)));
38
42
  }
39
43
  onDidChangeWorkspaceFolders(e) {
@@ -48,16 +52,16 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
48
52
  const workspace = this.contextService.getWorkspace();
49
53
  const remoteAuthority = this.environmentService.remoteAuthority;
50
54
  switch (this.contextService.getWorkbenchState()) {
51
- case 2 :
55
+ case WorkbenchState.FOLDER:
52
56
  this.addRecentlyOpened([{ folderUri: workspace.folders[0].uri, remoteAuthority }]);
53
57
  break;
54
- case 3 :
58
+ case WorkbenchState.WORKSPACE:
55
59
  this.addRecentlyOpened([{ workspace: { id: workspace.id, configPath: workspace.configuration }, remoteAuthority }]);
56
60
  break;
57
61
  }
58
62
  }
59
63
  async getRecentlyOpened() {
60
- const recentlyOpenedRaw = this.storageService.get(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, -1 );
64
+ const recentlyOpenedRaw = this.storageService.get(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, StorageScope.APPLICATION);
61
65
  if (recentlyOpenedRaw) {
62
66
  const recentlyOpened = restoreRecentlyOpened(JSON.parse(recentlyOpenedRaw), this.logService);
63
67
  recentlyOpened.workspaces = recentlyOpened.workspaces.filter(recent => {
@@ -105,10 +109,10 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
105
109
  });
106
110
  }
107
111
  async saveRecentlyOpened(data) {
108
- return this.storageService.store(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, JSON.stringify(toStoreData(data)), -1 , 0 );
112
+ return this.storageService.store(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, JSON.stringify(toStoreData(data)), StorageScope.APPLICATION, StorageTarget.USER);
109
113
  }
110
114
  async clearRecentlyOpened() {
111
- this.storageService.remove(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, -1 );
115
+ this.storageService.remove(BrowserWorkspacesService_1.RECENTLY_OPENED_KEY, StorageScope.APPLICATION);
112
116
  }
113
117
  async enterWorkspace(workspaceUri) {
114
118
  return { workspace: await this.getWorkspaceIdentifier(workspaceUri) };
@@ -131,7 +135,7 @@ let BrowserWorkspacesService = class BrowserWorkspacesService extends Disposable
131
135
  await this.fileService.del(workspace.configPath);
132
136
  }
133
137
  catch (error) {
134
- if (error.fileOperationResult !== 1 ) {
138
+ if (error.fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) {
135
139
  throw error;
136
140
  }
137
141
  }
package/configuration.js DELETED
@@ -1,138 +0,0 @@
1
- import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
3
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
4
- import { URI } from 'vscode/vscode/vs/base/common/uri';
5
- import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
6
- import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vscode/vscode/vs/editor/common/services/textResourceConfiguration';
7
- import { TextResourceConfigurationService } from './vscode/src/vs/editor/common/services/textResourceConfigurationService.js';
8
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
9
- import { Extensions } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
10
- export { ConfigurationScope } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
11
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
12
- import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
13
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
14
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
15
- import { IPolicyService } from 'vscode/vscode/vs/platform/policy/common/policy.service';
16
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
17
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
18
- import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
19
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
20
- import { IWorkspacesService } from 'vscode/vscode/vs/platform/workspaces/common/workspaces.service';
21
- import './vscode/src/vs/workbench/api/common/configurationExtensionPoint.js';
22
- import './vscode/src/vs/workbench/contrib/workspaces/browser/workspaces.contribution.js';
23
- import { WorkspaceService } from './vscode/src/vs/workbench/services/configuration/browser/configurationService.js';
24
- import { ConfigurationCache } from './vscode/src/vs/workbench/services/configuration/common/configurationCache.js';
25
- import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
26
- import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
27
- import { TextResourcePropertiesService } from './vscode/src/vs/workbench/services/textresourceProperties/common/textResourcePropertiesService.js';
28
- import { IUserDataProfileService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
29
- import { AbstractWorkspaceEditingService } from './vscode/src/vs/workbench/services/workspaces/browser/abstractWorkspaceEditingService.js';
30
- import { BrowserWorkspacesService } from './vscode/src/vs/workbench/services/workspaces/browser/workspacesService.js';
31
- import { IWorkspaceEditingService } from 'vscode/vscode/vs/workbench/services/workspaces/common/workspaceEditing.service';
32
- import { ConfigurationResolverService } from './vscode/src/vs/workbench/services/configurationResolver/browser/configurationResolverService.js';
33
- import { IConfigurationResolverService } from 'vscode/vscode/vs/workbench/services/configurationResolver/common/configurationResolver.service';
34
- import getServiceOverride$1, { initFile } from '@codingame/monaco-vscode-files-service-override';
35
- import { registerServiceInitializePreParticipant } from 'vscode/lifecycle';
36
- import { getService, withReadyServices } from 'vscode/services';
37
- import { unsupported, memoizedConstructor } from './tools.js';
38
- import { getWorkspaceIdentifier } from 'vscode/workbench';
39
-
40
- const defaultUserConfigurationFile = ( URI.from({
41
- scheme: Schemas.vscodeUserData,
42
- path: '/User/settings.json'
43
- }));
44
- async function initUserConfiguration(configurationJson, options, file = defaultUserConfigurationFile) {
45
- await initFile(file, configurationJson, options);
46
- }
47
- async function updateUserConfiguration(configurationJson) {
48
- const userDataProfilesService = await getService(IUserDataProfilesService);
49
- const fileService = await getService(IFileService);
50
- await fileService.writeFile(userDataProfilesService.defaultProfile.settingsResource, VSBuffer.fromString(configurationJson));
51
- }
52
- async function getUserConfiguration() {
53
- const userDataProfilesService = await getService(IUserDataProfilesService);
54
- const fileService = await getService(IFileService);
55
- return ( (await fileService.readFile(userDataProfilesService.defaultProfile.settingsResource)).value.toString());
56
- }
57
- function onUserConfigurationChange(callback) {
58
- return withReadyServices((accessor) => {
59
- const userDataProfilesService = accessor.get(IUserDataProfilesService);
60
- return accessor.get(IFileService).onDidFilesChange((e) => {
61
- if (e.affects(userDataProfilesService.defaultProfile.settingsResource)) {
62
- callback();
63
- }
64
- });
65
- });
66
- }
67
- const configurationRegistry = ( Registry.as(Extensions.Configuration));
68
- let InjectedConfigurationService = class InjectedConfigurationService extends WorkspaceService {
69
- constructor(workbenchEnvironmentService, userDataProfileService, userDataProfilesService, fileService, remoteAgentService, uriIdentityService, logService, policyService) {
70
- const configurationCache = new ConfigurationCache([Schemas.file, Schemas.vscodeUserData, Schemas.tmp], workbenchEnvironmentService, fileService);
71
- super({ configurationCache }, workbenchEnvironmentService, userDataProfileService, userDataProfilesService, fileService, remoteAgentService, uriIdentityService, logService, policyService);
72
- }
73
- };
74
- InjectedConfigurationService = __decorate([
75
- ( __param(0, IWorkbenchEnvironmentService)),
76
- ( __param(1, IUserDataProfileService)),
77
- ( __param(2, IUserDataProfilesService)),
78
- ( __param(3, IFileService)),
79
- ( __param(4, IRemoteAgentService)),
80
- ( __param(5, IUriIdentityService)),
81
- ( __param(6, ILogService)),
82
- ( __param(7, IPolicyService))
83
- ], InjectedConfigurationService);
84
- class MonacoWorkspaceEditingService extends AbstractWorkspaceEditingService {
85
- constructor() {
86
- super(...arguments);
87
- this.enterWorkspace = unsupported;
88
- }
89
- }
90
- let _defaultWorkspace;
91
- registerServiceInitializePreParticipant(async (accessor) => {
92
- const workspaceService = accessor.get(IWorkspaceContextService);
93
- workspaceService.acquireInstantiationService(accessor.get(IInstantiationService));
94
- const workspace = _defaultWorkspace ?? getWorkspaceIdentifier();
95
- if (URI.isUri(workspace)) {
96
- const configPath = workspace.with({ path: '/workspace.code-workspace' });
97
- try {
98
- const fileService = accessor.get(IFileService);
99
- await fileService.createFolder(workspace);
100
- await fileService.writeFile(configPath, VSBuffer.fromString(JSON.stringify({
101
- folders: [
102
- {
103
- path: workspace.path
104
- }
105
- ]
106
- })));
107
- }
108
- catch (err) {
109
- }
110
- await workspaceService.initialize({
111
- id: generateUuid(),
112
- configPath
113
- });
114
- }
115
- else {
116
- await workspaceService.initialize(workspace);
117
- }
118
- });
119
- const MemoizedInjectedConfigurationService = memoizedConstructor(InjectedConfigurationService);
120
- async function reinitializeWorkspace(workspace) {
121
- const workspaceService = (await getService(IWorkspaceContextService));
122
- await workspaceService.initialize(workspace);
123
- }
124
- function getServiceOverride(defaultWorkspace) {
125
- _defaultWorkspace = defaultWorkspace;
126
- return {
127
- ...getServiceOverride$1(),
128
- [( IConfigurationService.toString())]: new SyncDescriptor(MemoizedInjectedConfigurationService, [], true),
129
- [( IWorkspaceContextService.toString())]: new SyncDescriptor(MemoizedInjectedConfigurationService, [], true),
130
- [( ITextResourceConfigurationService.toString())]: new SyncDescriptor(TextResourceConfigurationService, [], true),
131
- [( IWorkspaceEditingService.toString())]: new SyncDescriptor(MonacoWorkspaceEditingService, [], true),
132
- [( IWorkspacesService.toString())]: new SyncDescriptor(BrowserWorkspacesService, [], true),
133
- [( ITextResourcePropertiesService.toString())]: new SyncDescriptor(TextResourcePropertiesService, [], true),
134
- [( IConfigurationResolverService.toString())]: new SyncDescriptor(ConfigurationResolverService, [], true)
135
- };
136
- }
137
-
138
- export { configurationRegistry, getServiceOverride as default, defaultUserConfigurationFile, getUserConfiguration, initUserConfiguration, onUserConfigurationChange, reinitializeWorkspace, updateUserConfiguration };
package/tools.js DELETED
@@ -1,44 +0,0 @@
1
- function unsupported() {
2
- throw new Error('unsupported');
3
- }
4
- function memoized(fct) {
5
- let v = null;
6
- return (...args) => {
7
- if (v == null) {
8
- v = fct(...args);
9
- }
10
- return v;
11
- };
12
- }
13
- function memoizedConstructor(ctor) {
14
- return new Proxy(ctor, {
15
- construct: memoized((target, args) => {
16
- return Reflect.construct(ctor, args);
17
- })
18
- });
19
- }
20
- async function sleep(duration) {
21
- await new Promise((resolve) => setTimeout(resolve, duration));
22
- }
23
- function throttle(fct, merge, delay) {
24
- let lastPromise = Promise.resolve();
25
- let toConsume = null;
26
- return async (param) => {
27
- if (toConsume == null) {
28
- toConsume = param;
29
- lastPromise = lastPromise
30
- .then(async () => await sleep(delay))
31
- .then(async () => {
32
- const _toConsume = toConsume;
33
- toConsume = null;
34
- await fct(_toConsume);
35
- });
36
- }
37
- else {
38
- toConsume = merge(toConsume, param);
39
- }
40
- await lastPromise;
41
- };
42
- }
43
-
44
- export { memoized, memoizedConstructor, sleep, throttle, unsupported };