@codingame/monaco-vscode-localization-service-override 4.1.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/external/tslib/tslib.es6.js +11 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/localization.d.ts +14 -0
- package/localization.js +550 -0
- package/override/vs/platform/dialogs/common/dialogs.js +10 -0
- package/package.json +32 -0
- package/vscode/src/vs/platform/actions/common/actions.contribution.js +5 -0
- package/vscode/src/vs/platform/actions/common/menuResetAction.js +21 -0
- package/vscode/src/vs/platform/sign/browser/signService.js +66 -0
- package/vscode/src/vs/platform/sign/common/abstractSignService.js +51 -0
- package/vscode/src/vs/platform/telemetry/browser/errorTelemetry.js +50 -0
- package/vscode/src/vs/platform/telemetry/common/errorTelemetry.js +83 -0
- package/vscode/src/vs/platform/telemetry/common/telemetryService.js +251 -0
- package/vscode/src/vs/workbench/browser/actions/helpActions.js +356 -0
- package/vscode/src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.js +236 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/manageTrustedExtensionsForAccountAction.js +206 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/actions/signOutOfAccountAction.js +64 -0
- package/vscode/src/vs/workbench/contrib/authentication/browser/authentication.contribution.js +223 -0
- package/vscode/src/vs/workbench/contrib/bracketPairColorizer2Telemetry/browser/bracketPairColorizer2Telemetry.contribution.js +37 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/editorSettingsMigration.js +14 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/inspectKeybindings.js +46 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.js +89 -0
- package/vscode/src/vs/workbench/contrib/deprecatedExtensionMigrator/browser/deprecatedExtensionMigrator.contribution.js +98 -0
- package/vscode/src/vs/workbench/contrib/localization/browser/localization.contribution.js +10 -0
- package/vscode/src/vs/workbench/contrib/localization/common/localization.contribution.js +160 -0
- package/vscode/src/vs/workbench/contrib/localization/common/localizationsActions.js +129 -0
- package/vscode/src/vs/workbench/contrib/logs/browser/logs.contribution.js +37 -0
- package/vscode/src/vs/workbench/contrib/logs/common/logsDataCleaner.js +43 -0
- package/vscode/src/vs/workbench/contrib/scrollLocking/browser/scrollLocking.contribution.js +4 -0
- package/vscode/src/vs/workbench/contrib/scrollLocking/browser/scrollLocking.js +214 -0
- package/vscode/src/vs/workbench/contrib/splash/browser/partsSplash.js +117 -0
- package/vscode/src/vs/workbench/contrib/splash/browser/splash.contribution.js +5 -0
- package/vscode/src/vs/workbench/contrib/splash/browser/splash.js +5 -0
- package/vscode/src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.js +227 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js +9 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.js +573 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfileActions.js +197 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilePreview.js +24 -0
- package/vscode/src/vs/workbench/services/dialogs/browser/fileDialogService.js +244 -0
- package/vscode/src/vs/workbench/services/issue/browser/issueTroubleshoot.js +418 -0
- package/vscode/src/vs/workbench/services/localization/browser/localeService.js +98 -0
- package/vscode/src/vs/workbench/services/search/browser/searchService.js +167 -0
- package/vscode/src/vs/workbench/services/textMate/browser/textMateTokenizationFeature.contribution.js +13 -0
- package/vscode/src/vs/workbench/services/userActivity/browser/domActivityTracker.js +41 -0
- package/vscode/src/vs/workbench/services/userActivity/browser/userActivityBrowser.js +4 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { Separator } from 'vscode/vscode/vs/base/common/actions';
|
|
2
|
+
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
3
|
+
import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
4
|
+
import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
|
|
5
|
+
import { createAndFillInActionBarActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
|
|
6
|
+
import { Action2, registerAction2, IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
7
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
8
|
+
import { ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
9
|
+
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
10
|
+
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
|
|
11
|
+
import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
|
|
12
|
+
import { PROFILES_CATEGORY, PROFILES_ENABLEMENT_CONTEXT, IUserDataProfileManagementService, HAS_PROFILES_CONTEXT, IUserDataProfileService, MANAGE_PROFILES_ACTION_ID, ProfilesMenu } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
|
|
13
|
+
|
|
14
|
+
class CreateTransientProfileAction extends Action2 {
|
|
15
|
+
static { this.ID = 'workbench.profiles.actions.createTemporaryProfile'; }
|
|
16
|
+
static { this.TITLE = ( localize2WithPath(
|
|
17
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
18
|
+
'create temporary profile',
|
|
19
|
+
"Create a Temporary Profile"
|
|
20
|
+
)); }
|
|
21
|
+
constructor() {
|
|
22
|
+
super({
|
|
23
|
+
id: CreateTransientProfileAction.ID,
|
|
24
|
+
title: CreateTransientProfileAction.TITLE,
|
|
25
|
+
category: PROFILES_CATEGORY,
|
|
26
|
+
f1: true,
|
|
27
|
+
precondition: PROFILES_ENABLEMENT_CONTEXT,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async run(accessor) {
|
|
31
|
+
return accessor.get(IUserDataProfileManagementService).createAndEnterTransientProfile();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
registerAction2(CreateTransientProfileAction);
|
|
35
|
+
class RenameProfileAction extends Action2 {
|
|
36
|
+
static { this.ID = 'workbench.profiles.actions.renameProfile'; }
|
|
37
|
+
constructor() {
|
|
38
|
+
super({
|
|
39
|
+
id: RenameProfileAction.ID,
|
|
40
|
+
title: ( localize2WithPath(
|
|
41
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
42
|
+
'rename profile',
|
|
43
|
+
"Rename..."
|
|
44
|
+
)),
|
|
45
|
+
category: PROFILES_CATEGORY,
|
|
46
|
+
f1: true,
|
|
47
|
+
precondition: ( ContextKeyExpr.and(PROFILES_ENABLEMENT_CONTEXT, HAS_PROFILES_CONTEXT)),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async run(accessor, profile) {
|
|
51
|
+
const quickInputService = accessor.get(IQuickInputService);
|
|
52
|
+
const userDataProfileService = accessor.get(IUserDataProfileService);
|
|
53
|
+
const userDataProfilesService = accessor.get(IUserDataProfilesService);
|
|
54
|
+
const userDataProfileManagementService = accessor.get(IUserDataProfileManagementService);
|
|
55
|
+
const notificationService = accessor.get(INotificationService);
|
|
56
|
+
if (!profile) {
|
|
57
|
+
profile = await this.pickProfile(quickInputService, userDataProfileService, userDataProfilesService);
|
|
58
|
+
}
|
|
59
|
+
if (!profile || profile.isDefault) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const name = await quickInputService.input({
|
|
63
|
+
value: profile.name,
|
|
64
|
+
title: ( localizeWithPath(
|
|
65
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
66
|
+
'select profile to rename',
|
|
67
|
+
'Rename {0}',
|
|
68
|
+
profile.name
|
|
69
|
+
)),
|
|
70
|
+
validateInput: async (value) => {
|
|
71
|
+
if (profile.name !== value && ( userDataProfilesService.profiles.some(p => p.name === value))) {
|
|
72
|
+
return ( localizeWithPath(
|
|
73
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
74
|
+
'profileExists',
|
|
75
|
+
"Profile with name {0} already exists.",
|
|
76
|
+
value
|
|
77
|
+
));
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if (name && name !== profile.name) {
|
|
83
|
+
try {
|
|
84
|
+
await userDataProfileManagementService.updateProfile(profile, { name });
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
notificationService.error(error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async pickProfile(quickInputService, userDataProfileService, userDataProfilesService) {
|
|
92
|
+
const profiles = userDataProfilesService.profiles.filter(p => !p.isDefault && !p.isTransient);
|
|
93
|
+
if (!profiles.length) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
const pick = await quickInputService.pick(( profiles.map(profile => ({
|
|
97
|
+
label: profile.name,
|
|
98
|
+
description: profile.id === userDataProfileService.currentProfile.id ? ( localizeWithPath(
|
|
99
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
100
|
+
'current',
|
|
101
|
+
"Current"
|
|
102
|
+
)) : undefined,
|
|
103
|
+
profile
|
|
104
|
+
}))), {
|
|
105
|
+
title: ( localizeWithPath(
|
|
106
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
107
|
+
'rename specific profile',
|
|
108
|
+
"Rename Profile..."
|
|
109
|
+
)),
|
|
110
|
+
placeHolder: ( localizeWithPath(
|
|
111
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
112
|
+
'pick profile to rename',
|
|
113
|
+
"Select Profile to Rename"
|
|
114
|
+
)),
|
|
115
|
+
});
|
|
116
|
+
return pick?.profile;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
registerAction2(RenameProfileAction);
|
|
120
|
+
registerAction2(class ManageProfilesAction extends Action2 {
|
|
121
|
+
constructor() {
|
|
122
|
+
super({
|
|
123
|
+
id: MANAGE_PROFILES_ACTION_ID,
|
|
124
|
+
title: ( localize2WithPath(
|
|
125
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
126
|
+
'mange',
|
|
127
|
+
"Manage..."
|
|
128
|
+
)),
|
|
129
|
+
category: PROFILES_CATEGORY,
|
|
130
|
+
precondition: ( ContextKeyExpr.and(PROFILES_ENABLEMENT_CONTEXT, HAS_PROFILES_CONTEXT)),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async run(accessor) {
|
|
134
|
+
const quickInputService = accessor.get(IQuickInputService);
|
|
135
|
+
const menuService = accessor.get(IMenuService);
|
|
136
|
+
const contextKeyService = accessor.get(IContextKeyService);
|
|
137
|
+
const commandService = accessor.get(ICommandService);
|
|
138
|
+
const menu = menuService.createMenu(ProfilesMenu, contextKeyService);
|
|
139
|
+
const actions = [];
|
|
140
|
+
createAndFillInActionBarActions(menu, undefined, actions);
|
|
141
|
+
menu.dispose();
|
|
142
|
+
if (actions.length) {
|
|
143
|
+
const picks = ( actions.map(action => {
|
|
144
|
+
if (action instanceof Separator) {
|
|
145
|
+
return { type: 'separator' };
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
id: action.id,
|
|
149
|
+
label: `${action.label}${action.checked ? ` $(${Codicon.check.id})` : ''}`,
|
|
150
|
+
};
|
|
151
|
+
}));
|
|
152
|
+
const pick = await quickInputService.pick(picks, { canPickMany: false, title: PROFILES_CATEGORY.value });
|
|
153
|
+
if (pick?.id) {
|
|
154
|
+
await commandService.executeCommand(pick.id);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
registerAction2(class CleanupProfilesAction extends Action2 {
|
|
160
|
+
constructor() {
|
|
161
|
+
super({
|
|
162
|
+
id: 'workbench.profiles.actions.cleanupProfiles',
|
|
163
|
+
title: ( localize2WithPath(
|
|
164
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
165
|
+
'cleanup profile',
|
|
166
|
+
"Cleanup Profiles"
|
|
167
|
+
)),
|
|
168
|
+
category: Categories.Developer,
|
|
169
|
+
f1: true,
|
|
170
|
+
precondition: PROFILES_ENABLEMENT_CONTEXT,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async run(accessor) {
|
|
174
|
+
return accessor.get(IUserDataProfilesService).cleanUp();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
registerAction2(class ResetWorkspacesAction extends Action2 {
|
|
178
|
+
constructor() {
|
|
179
|
+
super({
|
|
180
|
+
id: 'workbench.profiles.actions.resetWorkspaces',
|
|
181
|
+
title: ( localize2WithPath(
|
|
182
|
+
'vs/workbench/contrib/userDataProfile/browser/userDataProfileActions',
|
|
183
|
+
'reset workspaces',
|
|
184
|
+
"Reset Workspace Profiles Associations"
|
|
185
|
+
)),
|
|
186
|
+
category: Categories.Developer,
|
|
187
|
+
f1: true,
|
|
188
|
+
precondition: PROFILES_ENABLEMENT_CONTEXT,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
async run(accessor) {
|
|
192
|
+
const userDataProfilesService = accessor.get(IUserDataProfilesService);
|
|
193
|
+
return userDataProfilesService.resetWorkspaces();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
export { RenameProfileAction };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { getErrorMessage } from 'vscode/vscode/vs/base/common/errors';
|
|
3
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
4
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
5
|
+
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
6
|
+
import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
|
|
7
|
+
import { IUserDataProfileImportExportService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
|
|
8
|
+
|
|
9
|
+
let UserDataProfilePreviewContribution = class UserDataProfilePreviewContribution extends Disposable {
|
|
10
|
+
constructor(environmentService, userDataProfileImportExportService, logService) {
|
|
11
|
+
super();
|
|
12
|
+
if (environmentService.options?.profileToPreview) {
|
|
13
|
+
userDataProfileImportExportService.importProfile(URI.revive(environmentService.options.profileToPreview), { mode: 'both' })
|
|
14
|
+
.then(null, error => logService.error('Error while previewing the profile', getErrorMessage(error)));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
UserDataProfilePreviewContribution = ( __decorate([
|
|
19
|
+
( __param(0, IBrowserWorkbenchEnvironmentService)),
|
|
20
|
+
( __param(1, IUserDataProfileImportExportService)),
|
|
21
|
+
( __param(2, ILogService))
|
|
22
|
+
], UserDataProfilePreviewContribution));
|
|
23
|
+
|
|
24
|
+
export { UserDataProfilePreviewContribution };
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { __decorate } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
3
|
+
import { AbstractFileDialogService } from 'vscode/vscode/vs/workbench/services/dialogs/browser/abstractFileDialogService';
|
|
4
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
5
|
+
import { memoize } from 'vscode/vscode/vs/base/common/decorators';
|
|
6
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
7
|
+
import { getMediaOrTextMime } from 'vscode/vscode/vs/base/common/mime';
|
|
8
|
+
import { basename } from 'vscode/vscode/vs/base/common/resources';
|
|
9
|
+
import { getActiveWindow, triggerDownload, triggerUpload } from 'vscode/vscode/vs/base/browser/dom';
|
|
10
|
+
import Severity$1 from 'vscode/vscode/vs/base/common/severity';
|
|
11
|
+
import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
|
|
12
|
+
import { extractFileListData } from 'vscode/vscode/vs/platform/dnd/browser/dnd';
|
|
13
|
+
import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
|
|
14
|
+
import { WebFileSystemAccess } from 'vscode/vscode/vs/platform/files/browser/webFileSystemAccess';
|
|
15
|
+
import { EmbeddedCodeEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/codeEditor/embeddedCodeEditorWidget';
|
|
16
|
+
|
|
17
|
+
class FileDialogService extends AbstractFileDialogService {
|
|
18
|
+
get fileSystemProvider() {
|
|
19
|
+
return this.fileService.getProvider(Schemas.file);
|
|
20
|
+
}
|
|
21
|
+
async pickFileFolderAndOpen(options) {
|
|
22
|
+
const schema = this.getFileSystemSchema(options);
|
|
23
|
+
if (!options.defaultUri) {
|
|
24
|
+
options.defaultUri = await this.defaultFilePath(schema);
|
|
25
|
+
}
|
|
26
|
+
if (this.shouldUseSimplified(schema)) {
|
|
27
|
+
return super.pickFileFolderAndOpenSimplified(schema, options, false);
|
|
28
|
+
}
|
|
29
|
+
throw new Error(localizeWithPath('vs/workbench/services/dialogs/browser/fileDialogService', 'pickFolderAndOpen', "Can't open folders, try adding a folder to the workspace instead."));
|
|
30
|
+
}
|
|
31
|
+
addFileSchemaIfNeeded(schema, isFolder) {
|
|
32
|
+
return (schema === Schemas.untitled) ? [Schemas.file]
|
|
33
|
+
: (((schema !== Schemas.file) && (!isFolder || (schema !== Schemas.vscodeRemote))) ? [schema, Schemas.file] : [schema]);
|
|
34
|
+
}
|
|
35
|
+
async pickFileAndOpen(options) {
|
|
36
|
+
const schema = this.getFileSystemSchema(options);
|
|
37
|
+
if (!options.defaultUri) {
|
|
38
|
+
options.defaultUri = await this.defaultFilePath(schema);
|
|
39
|
+
}
|
|
40
|
+
if (this.shouldUseSimplified(schema)) {
|
|
41
|
+
return super.pickFileAndOpenSimplified(schema, options, false);
|
|
42
|
+
}
|
|
43
|
+
const activeWindow = getActiveWindow();
|
|
44
|
+
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
45
|
+
return this.showUnsupportedBrowserWarning('open');
|
|
46
|
+
}
|
|
47
|
+
let fileHandle = undefined;
|
|
48
|
+
try {
|
|
49
|
+
([fileHandle] = await activeWindow.showOpenFilePicker({ multiple: false }));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const uri = await this.fileSystemProvider.registerFileHandle(fileHandle);
|
|
58
|
+
this.addFileToRecentlyOpened(uri);
|
|
59
|
+
await this.openerService.open(uri, { fromUserGesture: true, editorOptions: { pinned: true } });
|
|
60
|
+
}
|
|
61
|
+
async pickFolderAndOpen(options) {
|
|
62
|
+
const schema = this.getFileSystemSchema(options);
|
|
63
|
+
if (!options.defaultUri) {
|
|
64
|
+
options.defaultUri = await this.defaultFolderPath(schema);
|
|
65
|
+
}
|
|
66
|
+
if (this.shouldUseSimplified(schema)) {
|
|
67
|
+
return super.pickFolderAndOpenSimplified(schema, options);
|
|
68
|
+
}
|
|
69
|
+
throw new Error(localizeWithPath('vs/workbench/services/dialogs/browser/fileDialogService', 'pickFolderAndOpen', "Can't open folders, try adding a folder to the workspace instead."));
|
|
70
|
+
}
|
|
71
|
+
async pickWorkspaceAndOpen(options) {
|
|
72
|
+
options.availableFileSystems = this.getWorkspaceAvailableFileSystems(options);
|
|
73
|
+
const schema = this.getFileSystemSchema(options);
|
|
74
|
+
if (!options.defaultUri) {
|
|
75
|
+
options.defaultUri = await this.defaultWorkspacePath(schema);
|
|
76
|
+
}
|
|
77
|
+
if (this.shouldUseSimplified(schema)) {
|
|
78
|
+
return super.pickWorkspaceAndOpenSimplified(schema, options);
|
|
79
|
+
}
|
|
80
|
+
throw new Error(localizeWithPath('vs/workbench/services/dialogs/browser/fileDialogService', 'pickWorkspaceAndOpen', "Can't open workspaces, try adding a folder to the workspace instead."));
|
|
81
|
+
}
|
|
82
|
+
async pickFileToSave(defaultUri, availableFileSystems) {
|
|
83
|
+
const schema = this.getFileSystemSchema({ defaultUri, availableFileSystems });
|
|
84
|
+
const options = this.getPickFileToSaveDialogOptions(defaultUri, availableFileSystems);
|
|
85
|
+
if (this.shouldUseSimplified(schema)) {
|
|
86
|
+
return super.pickFileToSaveSimplified(schema, options);
|
|
87
|
+
}
|
|
88
|
+
const activeWindow = getActiveWindow();
|
|
89
|
+
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
90
|
+
return this.showUnsupportedBrowserWarning('save');
|
|
91
|
+
}
|
|
92
|
+
let fileHandle = undefined;
|
|
93
|
+
const startIn = Iterable.first(this.fileSystemProvider.directories);
|
|
94
|
+
try {
|
|
95
|
+
fileHandle = await activeWindow.showSaveFilePicker({ types: this.getFilePickerTypes(options.filters), ...{ suggestedName: basename(defaultUri), startIn } });
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return this.fileSystemProvider.registerFileHandle(fileHandle);
|
|
104
|
+
}
|
|
105
|
+
getFilePickerTypes(filters) {
|
|
106
|
+
return filters?.filter(filter => {
|
|
107
|
+
return !((filter.extensions.length === 1) && ((filter.extensions[0] === '*') || filter.extensions[0] === ''));
|
|
108
|
+
}).map(filter => {
|
|
109
|
+
const accept = {};
|
|
110
|
+
const extensions = filter.extensions.filter(ext => (ext.indexOf('-') < 0) && (ext.indexOf('*') < 0) && (ext.indexOf('_') < 0));
|
|
111
|
+
accept[getMediaOrTextMime(`fileName.${filter.extensions[0]}`) ?? 'text/plain'] = ( extensions.map(ext => ext.startsWith('.') ? ext : `.${ext}`));
|
|
112
|
+
return {
|
|
113
|
+
description: filter.name,
|
|
114
|
+
accept
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async showSaveDialog(options) {
|
|
119
|
+
const schema = this.getFileSystemSchema(options);
|
|
120
|
+
if (this.shouldUseSimplified(schema)) {
|
|
121
|
+
return super.showSaveDialogSimplified(schema, options);
|
|
122
|
+
}
|
|
123
|
+
const activeWindow = getActiveWindow();
|
|
124
|
+
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
125
|
+
return this.showUnsupportedBrowserWarning('save');
|
|
126
|
+
}
|
|
127
|
+
let fileHandle = undefined;
|
|
128
|
+
const startIn = Iterable.first(this.fileSystemProvider.directories);
|
|
129
|
+
try {
|
|
130
|
+
fileHandle = await activeWindow.showSaveFilePicker({ types: this.getFilePickerTypes(options.filters), ...(options.defaultUri ? { suggestedName: basename(options.defaultUri) } : undefined), ...{ startIn } });
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
if (!WebFileSystemAccess.isFileSystemFileHandle(fileHandle)) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
return this.fileSystemProvider.registerFileHandle(fileHandle);
|
|
139
|
+
}
|
|
140
|
+
async showOpenDialog(options) {
|
|
141
|
+
const schema = this.getFileSystemSchema(options);
|
|
142
|
+
if (this.shouldUseSimplified(schema)) {
|
|
143
|
+
return super.showOpenDialogSimplified(schema, options);
|
|
144
|
+
}
|
|
145
|
+
const activeWindow = getActiveWindow();
|
|
146
|
+
if (!WebFileSystemAccess.supported(activeWindow)) {
|
|
147
|
+
return this.showUnsupportedBrowserWarning('open');
|
|
148
|
+
}
|
|
149
|
+
let uri;
|
|
150
|
+
const startIn = Iterable.first(this.fileSystemProvider.directories) ?? 'documents';
|
|
151
|
+
try {
|
|
152
|
+
if (options.canSelectFiles) {
|
|
153
|
+
const handle = await activeWindow.showOpenFilePicker({ multiple: false, types: this.getFilePickerTypes(options.filters), ...{ startIn } });
|
|
154
|
+
if (handle.length === 1 && WebFileSystemAccess.isFileSystemFileHandle(handle[0])) {
|
|
155
|
+
uri = await this.fileSystemProvider.registerFileHandle(handle[0]);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const handle = await activeWindow.showDirectoryPicker({ ...{ startIn } });
|
|
160
|
+
uri = await this.fileSystemProvider.registerDirectoryHandle(handle);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
}
|
|
165
|
+
return uri ? [uri] : undefined;
|
|
166
|
+
}
|
|
167
|
+
async showUnsupportedBrowserWarning(context) {
|
|
168
|
+
if (context === 'save') {
|
|
169
|
+
const activeCodeEditor = this.codeEditorService.getActiveCodeEditor();
|
|
170
|
+
if (!(activeCodeEditor instanceof EmbeddedCodeEditorWidget)) {
|
|
171
|
+
const activeTextModel = activeCodeEditor?.getModel();
|
|
172
|
+
if (activeTextModel) {
|
|
173
|
+
triggerDownload(VSBuffer.fromString(activeTextModel.getValue()).buffer, basename(activeTextModel.uri));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const buttons = [
|
|
179
|
+
{
|
|
180
|
+
label: ( localizeWithPath(
|
|
181
|
+
'vs/workbench/services/dialogs/browser/fileDialogService',
|
|
182
|
+
{ key: 'openRemote', comment: ['&& denotes a mnemonic'] },
|
|
183
|
+
"&&Open Remote..."
|
|
184
|
+
)),
|
|
185
|
+
run: async () => { await this.commandService.executeCommand('workbench.action.remote.showMenu'); }
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
label: ( localizeWithPath(
|
|
189
|
+
'vs/workbench/services/dialogs/browser/fileDialogService',
|
|
190
|
+
{ key: 'learnMore', comment: ['&& denotes a mnemonic'] },
|
|
191
|
+
"&&Learn More"
|
|
192
|
+
)),
|
|
193
|
+
run: async () => { await this.openerService.open('https://aka.ms/VSCodeWebLocalFileSystemAccess'); }
|
|
194
|
+
}
|
|
195
|
+
];
|
|
196
|
+
if (context === 'open') {
|
|
197
|
+
buttons.push({
|
|
198
|
+
label: ( localizeWithPath(
|
|
199
|
+
'vs/workbench/services/dialogs/browser/fileDialogService',
|
|
200
|
+
{ key: 'openFiles', comment: ['&& denotes a mnemonic'] },
|
|
201
|
+
"Open &&Files..."
|
|
202
|
+
)),
|
|
203
|
+
run: async () => {
|
|
204
|
+
const files = await triggerUpload();
|
|
205
|
+
if (files) {
|
|
206
|
+
const filesData = (await this.instantiationService.invokeFunction(accessor => extractFileListData(accessor, files))).filter(fileData => !fileData.isDirectory);
|
|
207
|
+
if (filesData.length > 0) {
|
|
208
|
+
this.editorService.openEditors(( filesData.map(fileData => {
|
|
209
|
+
return {
|
|
210
|
+
resource: fileData.resource,
|
|
211
|
+
contents: fileData.contents?.toString(),
|
|
212
|
+
options: { pinned: true }
|
|
213
|
+
};
|
|
214
|
+
})));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
await this.dialogService.prompt({
|
|
221
|
+
type: Severity$1.Warning,
|
|
222
|
+
message: ( localizeWithPath(
|
|
223
|
+
'vs/workbench/services/dialogs/browser/fileDialogService',
|
|
224
|
+
'unsupportedBrowserMessage',
|
|
225
|
+
"Opening Local Folders is Unsupported"
|
|
226
|
+
)),
|
|
227
|
+
detail: ( localizeWithPath(
|
|
228
|
+
'vs/workbench/services/dialogs/browser/fileDialogService',
|
|
229
|
+
'unsupportedBrowserDetail',
|
|
230
|
+
"Your browser doesn't support opening local folders.\nYou can either open single files or open a remote repository."
|
|
231
|
+
)),
|
|
232
|
+
buttons
|
|
233
|
+
});
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
shouldUseSimplified(scheme) {
|
|
237
|
+
return ![Schemas.file, Schemas.vscodeUserData, Schemas.tmp].includes(scheme);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
FileDialogService.__decorator = ( __decorate([
|
|
241
|
+
memoize
|
|
242
|
+
], FileDialogService.prototype, "fileSystemProvider", null));
|
|
243
|
+
|
|
244
|
+
export { FileDialogService };
|