@codingame/monaco-vscode-quickaccess-service-override 4.1.0 → 4.1.2
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/override/vs/platform/dialogs/common/dialogs.js +10 -0
- package/package.json +2 -2
- package/quickaccess.js +6 -6
- package/vscode/src/vs/editor/contrib/quickAccess/browser/commandsQuickAccess.js +25 -0
- package/vscode/src/vs/platform/quickinput/browser/commandsQuickAccess.js +357 -0
- package/vscode/src/vs/platform/quickinput/browser/helpQuickAccess.js +67 -0
- package/vscode/src/vs/workbench/browser/actions/quickAccessActions.js +228 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/quickaccess/gotoLineQuickAccess.js +88 -0
- package/vscode/src/vs/workbench/contrib/quickaccess/browser/commandsQuickAccess.js +295 -0
- package/vscode/src/vs/workbench/contrib/quickaccess/browser/quickAccess.contribution.js +168 -0
- package/vscode/src/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.js +266 -0
- package/vscode/src/vs/workbench/contrib/url/browser/externalUriResolver.js +28 -0
- package/vscode/src/vs/workbench/contrib/url/browser/trustedDomains.js +200 -0
- package/vscode/src/vs/workbench/contrib/url/browser/trustedDomainsFileSystemProvider.js +137 -0
- package/vscode/src/vs/workbench/contrib/url/browser/trustedDomainsValidator.js +205 -0
- package/vscode/src/vs/workbench/contrib/url/browser/url.contribution.js +67 -0
- package/vscode/src/vs/workbench/services/quickinput/browser/quickInputService.js +39 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
3
|
+
import { parse } from 'vscode/vscode/vs/base/common/json';
|
|
4
|
+
import { FileType, IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
5
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
6
|
+
import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
|
|
7
|
+
import { TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, readTrustedDomains, TRUSTED_DOMAINS_STORAGE_KEY } from './trustedDomains.js';
|
|
8
|
+
import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
|
|
9
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
10
|
+
|
|
11
|
+
const TRUSTED_DOMAINS_SCHEMA = 'trustedDomains';
|
|
12
|
+
const TRUSTED_DOMAINS_STAT = {
|
|
13
|
+
type: FileType.File,
|
|
14
|
+
ctime: Date.now(),
|
|
15
|
+
mtime: Date.now(),
|
|
16
|
+
size: 0
|
|
17
|
+
};
|
|
18
|
+
const CONFIG_HELP_TEXT_PRE = `// Links matching one or more entries in the list below can be opened without link protection.
|
|
19
|
+
// The following examples show what entries can look like:
|
|
20
|
+
// - "https://microsoft.com": Matches this specific domain using https
|
|
21
|
+
// - "https://microsoft.com:8080": Matches this specific domain on this port using https
|
|
22
|
+
// - "https://microsoft.com:*": Matches this specific domain on any port using https
|
|
23
|
+
// - "https://microsoft.com/foo": Matches https://microsoft.com/foo and https://microsoft.com/foo/bar,
|
|
24
|
+
// but not https://microsoft.com/foobar or https://microsoft.com/bar
|
|
25
|
+
// - "https://*.microsoft.com": Match all domains ending in "microsoft.com" using https
|
|
26
|
+
// - "microsoft.com": Match this specific domain using either http or https
|
|
27
|
+
// - "*.microsoft.com": Match all domains ending in "microsoft.com" using either http or https
|
|
28
|
+
// - "http://192.168.0.1: Matches this specific IP using http
|
|
29
|
+
// - "http://192.168.0.*: Matches all IP's with this prefix using http
|
|
30
|
+
// - "*": Match all domains using either http or https
|
|
31
|
+
//
|
|
32
|
+
`;
|
|
33
|
+
const CONFIG_HELP_TEXT_AFTER = `//
|
|
34
|
+
// You can use the "Manage Trusted Domains" command to open this file.
|
|
35
|
+
// Save this file to apply the trusted domains rules.
|
|
36
|
+
`;
|
|
37
|
+
const CONFIG_PLACEHOLDER_TEXT = `[
|
|
38
|
+
// "https://microsoft.com"
|
|
39
|
+
]`;
|
|
40
|
+
function computeTrustedDomainContent(defaultTrustedDomains, trustedDomains, userTrustedDomains, workspaceTrustedDomains, configuring) {
|
|
41
|
+
let content = CONFIG_HELP_TEXT_PRE;
|
|
42
|
+
if (defaultTrustedDomains.length > 0) {
|
|
43
|
+
content += `// By default, VS Code trusts "localhost" as well as the following domains:\n`;
|
|
44
|
+
defaultTrustedDomains.forEach(d => {
|
|
45
|
+
content += `// - "${d}"\n`;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
content += `// By default, VS Code trusts "localhost".\n`;
|
|
50
|
+
}
|
|
51
|
+
if (userTrustedDomains.length) {
|
|
52
|
+
content += `//\n// Additionally, the following domains are trusted based on your logged-in Accounts:\n`;
|
|
53
|
+
userTrustedDomains.forEach(d => {
|
|
54
|
+
content += `// - "${d}"\n`;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (workspaceTrustedDomains.length) {
|
|
58
|
+
content += `//\n// Further, the following domains are trusted based on your workspace configuration:\n`;
|
|
59
|
+
workspaceTrustedDomains.forEach(d => {
|
|
60
|
+
content += `// - "${d}"\n`;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
content += CONFIG_HELP_TEXT_AFTER;
|
|
64
|
+
content += configuring ? `\n// Currently configuring trust for ${configuring}\n` : '';
|
|
65
|
+
if (trustedDomains.length === 0) {
|
|
66
|
+
content += CONFIG_PLACEHOLDER_TEXT;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
content += JSON.stringify(trustedDomains, null, 2);
|
|
70
|
+
}
|
|
71
|
+
return content;
|
|
72
|
+
}
|
|
73
|
+
let TrustedDomainsFileSystemProvider = class TrustedDomainsFileSystemProvider {
|
|
74
|
+
static { this.ID = 'workbench.contrib.trustedDomainsFileSystemProvider'; }
|
|
75
|
+
constructor(fileService, storageService, instantiationService) {
|
|
76
|
+
this.fileService = fileService;
|
|
77
|
+
this.storageService = storageService;
|
|
78
|
+
this.instantiationService = instantiationService;
|
|
79
|
+
this.capabilities = 2 ;
|
|
80
|
+
this.onDidChangeCapabilities = Event.None;
|
|
81
|
+
this.onDidChangeFile = Event.None;
|
|
82
|
+
this.fileService.registerProvider(TRUSTED_DOMAINS_SCHEMA, this);
|
|
83
|
+
}
|
|
84
|
+
stat(resource) {
|
|
85
|
+
return Promise.resolve(TRUSTED_DOMAINS_STAT);
|
|
86
|
+
}
|
|
87
|
+
async readFile(resource) {
|
|
88
|
+
let trustedDomainsContent = this.storageService.get(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, -1 );
|
|
89
|
+
const configuring = resource.fragment;
|
|
90
|
+
const { defaultTrustedDomains, trustedDomains, userDomains, workspaceDomains } = await this.instantiationService.invokeFunction(readTrustedDomains);
|
|
91
|
+
if (!trustedDomainsContent ||
|
|
92
|
+
trustedDomainsContent.indexOf(CONFIG_HELP_TEXT_PRE) === -1 ||
|
|
93
|
+
trustedDomainsContent.indexOf(CONFIG_HELP_TEXT_AFTER) === -1 ||
|
|
94
|
+
trustedDomainsContent.indexOf(configuring ?? '') === -1 ||
|
|
95
|
+
( [...defaultTrustedDomains, ...trustedDomains, ...userDomains, ...workspaceDomains].some(d => !assertIsDefined(trustedDomainsContent).includes(d)))) {
|
|
96
|
+
trustedDomainsContent = computeTrustedDomainContent(defaultTrustedDomains, trustedDomains, userDomains, workspaceDomains, configuring);
|
|
97
|
+
}
|
|
98
|
+
const buffer = VSBuffer.fromString(trustedDomainsContent).buffer;
|
|
99
|
+
return buffer;
|
|
100
|
+
}
|
|
101
|
+
writeFile(resource, content, opts) {
|
|
102
|
+
try {
|
|
103
|
+
const trustedDomainsContent = ( VSBuffer.wrap(content).toString());
|
|
104
|
+
const trustedDomains = parse(trustedDomainsContent);
|
|
105
|
+
this.storageService.store(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, trustedDomainsContent, -1 , 0 );
|
|
106
|
+
this.storageService.store(TRUSTED_DOMAINS_STORAGE_KEY, JSON.stringify(trustedDomains) || '', -1 , 0 );
|
|
107
|
+
}
|
|
108
|
+
catch (err) { }
|
|
109
|
+
return Promise.resolve();
|
|
110
|
+
}
|
|
111
|
+
watch(resource, opts) {
|
|
112
|
+
return {
|
|
113
|
+
dispose() {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
mkdir(resource) {
|
|
119
|
+
return Promise.resolve(undefined);
|
|
120
|
+
}
|
|
121
|
+
readdir(resource) {
|
|
122
|
+
return Promise.resolve(undefined);
|
|
123
|
+
}
|
|
124
|
+
delete(resource, opts) {
|
|
125
|
+
return Promise.resolve(undefined);
|
|
126
|
+
}
|
|
127
|
+
rename(from, to, opts) {
|
|
128
|
+
return Promise.resolve(undefined);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
TrustedDomainsFileSystemProvider = ( __decorate([
|
|
132
|
+
( __param(0, IFileService)),
|
|
133
|
+
( __param(1, IStorageService)),
|
|
134
|
+
( __param(2, IInstantiationService))
|
|
135
|
+
], TrustedDomainsFileSystemProvider));
|
|
136
|
+
|
|
137
|
+
export { TrustedDomainsFileSystemProvider };
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { WindowIdleValue } from 'vscode/vscode/vs/base/browser/dom';
|
|
3
|
+
import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
4
|
+
import { matchesScheme, Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
5
|
+
import Severity$1 from 'vscode/vscode/vs/base/common/severity';
|
|
6
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
7
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
8
|
+
import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
|
|
9
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
10
|
+
import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
|
|
11
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
12
|
+
import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
|
|
13
|
+
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
|
|
14
|
+
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
|
|
15
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
16
|
+
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
|
|
17
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
18
|
+
import { IWorkspaceTrustManagementService } from 'vscode/vscode/vs/platform/workspace/common/workspaceTrust';
|
|
19
|
+
import { readAuthenticationTrustedDomains, readWorkspaceTrustedDomains, readStaticTrustedDomains, configureOpenerTrustedDomainsHandler } from './trustedDomains.js';
|
|
20
|
+
import { testUrlMatchesGlob } from 'vscode/vscode/vs/workbench/contrib/url/common/urlGlob';
|
|
21
|
+
import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication';
|
|
22
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
23
|
+
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
24
|
+
|
|
25
|
+
let OpenerValidatorContributions = class OpenerValidatorContributions {
|
|
26
|
+
constructor(_openerService, _storageService, _dialogService, _productService, _quickInputService, _editorService, _clipboardService, _telemetryService, _instantiationService, _authenticationService, _workspaceContextService, _configurationService, _workspaceTrustService) {
|
|
27
|
+
this._openerService = _openerService;
|
|
28
|
+
this._storageService = _storageService;
|
|
29
|
+
this._dialogService = _dialogService;
|
|
30
|
+
this._productService = _productService;
|
|
31
|
+
this._quickInputService = _quickInputService;
|
|
32
|
+
this._editorService = _editorService;
|
|
33
|
+
this._clipboardService = _clipboardService;
|
|
34
|
+
this._telemetryService = _telemetryService;
|
|
35
|
+
this._instantiationService = _instantiationService;
|
|
36
|
+
this._authenticationService = _authenticationService;
|
|
37
|
+
this._workspaceContextService = _workspaceContextService;
|
|
38
|
+
this._configurationService = _configurationService;
|
|
39
|
+
this._workspaceTrustService = _workspaceTrustService;
|
|
40
|
+
this._openerService.registerValidator({ shouldOpen: (uri, options) => this.validateLink(uri, options) });
|
|
41
|
+
this._readAuthenticationTrustedDomainsResult = ( new WindowIdleValue(
|
|
42
|
+
mainWindow,
|
|
43
|
+
() => this._instantiationService.invokeFunction(readAuthenticationTrustedDomains)
|
|
44
|
+
));
|
|
45
|
+
this._authenticationService.onDidRegisterAuthenticationProvider(() => {
|
|
46
|
+
this._readAuthenticationTrustedDomainsResult?.dispose();
|
|
47
|
+
this._readAuthenticationTrustedDomainsResult = ( new WindowIdleValue(
|
|
48
|
+
mainWindow,
|
|
49
|
+
() => this._instantiationService.invokeFunction(readAuthenticationTrustedDomains)
|
|
50
|
+
));
|
|
51
|
+
});
|
|
52
|
+
this._readWorkspaceTrustedDomainsResult = ( new WindowIdleValue(
|
|
53
|
+
mainWindow,
|
|
54
|
+
() => this._instantiationService.invokeFunction(readWorkspaceTrustedDomains)
|
|
55
|
+
));
|
|
56
|
+
this._workspaceContextService.onDidChangeWorkspaceFolders(() => {
|
|
57
|
+
this._readWorkspaceTrustedDomainsResult?.dispose();
|
|
58
|
+
this._readWorkspaceTrustedDomainsResult = ( new WindowIdleValue(
|
|
59
|
+
mainWindow,
|
|
60
|
+
() => this._instantiationService.invokeFunction(readWorkspaceTrustedDomains)
|
|
61
|
+
));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async validateLink(resource, openOptions) {
|
|
65
|
+
if (!matchesScheme(resource, Schemas.http) && !matchesScheme(resource, Schemas.https)) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (openOptions?.fromWorkspace && this._workspaceTrustService.isWorkspaceTrusted() && !this._configurationService.getValue('workbench.trustedDomains.promptInTrustedWorkspace')) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
const originalResource = resource;
|
|
72
|
+
let resourceUri;
|
|
73
|
+
if (typeof resource === 'string') {
|
|
74
|
+
resourceUri = ( URI.parse(resource));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
resourceUri = resource;
|
|
78
|
+
}
|
|
79
|
+
const { scheme, authority, path, query, fragment } = resourceUri;
|
|
80
|
+
const domainToOpen = `${scheme}://${authority}`;
|
|
81
|
+
const [workspaceDomains, userDomains] = await Promise.all([this._readWorkspaceTrustedDomainsResult.value, this._readAuthenticationTrustedDomainsResult.value]);
|
|
82
|
+
const { defaultTrustedDomains, trustedDomains, } = this._instantiationService.invokeFunction(readStaticTrustedDomains);
|
|
83
|
+
const allTrustedDomains = [...defaultTrustedDomains, ...trustedDomains, ...userDomains, ...workspaceDomains];
|
|
84
|
+
if (isURLDomainTrusted(resourceUri, allTrustedDomains)) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
let formattedLink = `${scheme}://${authority}${path}`;
|
|
89
|
+
const linkTail = `${query ? '?' + query : ''}${fragment ? '#' + fragment : ''}`;
|
|
90
|
+
const remainingLength = Math.max(0, 60 - formattedLink.length);
|
|
91
|
+
const linkTailLengthToKeep = Math.min(Math.max(5, remainingLength), linkTail.length);
|
|
92
|
+
if (linkTailLengthToKeep === linkTail.length) {
|
|
93
|
+
formattedLink += linkTail;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
formattedLink += linkTail.charAt(0) + '...' + linkTail.substring(linkTail.length - linkTailLengthToKeep + 1);
|
|
97
|
+
}
|
|
98
|
+
const { result } = await this._dialogService.prompt({
|
|
99
|
+
type: Severity$1.Info,
|
|
100
|
+
message: ( localizeWithPath(
|
|
101
|
+
'vs/workbench/contrib/url/browser/trustedDomainsValidator',
|
|
102
|
+
'openExternalLinkAt',
|
|
103
|
+
'Do you want {0} to open the external website?',
|
|
104
|
+
this._productService.nameShort
|
|
105
|
+
)),
|
|
106
|
+
detail: typeof originalResource === 'string' ? originalResource : formattedLink,
|
|
107
|
+
buttons: [
|
|
108
|
+
{
|
|
109
|
+
label: ( localizeWithPath(
|
|
110
|
+
'vs/workbench/contrib/url/browser/trustedDomainsValidator',
|
|
111
|
+
{ key: 'open', comment: ['&& denotes a mnemonic'] },
|
|
112
|
+
'&&Open'
|
|
113
|
+
)),
|
|
114
|
+
run: () => true
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
label: ( localizeWithPath(
|
|
118
|
+
'vs/workbench/contrib/url/browser/trustedDomainsValidator',
|
|
119
|
+
{ key: 'copy', comment: ['&& denotes a mnemonic'] },
|
|
120
|
+
'&&Copy'
|
|
121
|
+
)),
|
|
122
|
+
run: () => {
|
|
123
|
+
this._clipboardService.writeText(typeof originalResource === 'string' ? originalResource : ( resourceUri.toString(true)));
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
label: ( localizeWithPath(
|
|
129
|
+
'vs/workbench/contrib/url/browser/trustedDomainsValidator',
|
|
130
|
+
{ key: 'configureTrustedDomains', comment: ['&& denotes a mnemonic'] },
|
|
131
|
+
'Configure &&Trusted Domains'
|
|
132
|
+
)),
|
|
133
|
+
run: async () => {
|
|
134
|
+
const pickedDomains = await configureOpenerTrustedDomainsHandler(trustedDomains, domainToOpen, resourceUri, this._quickInputService, this._storageService, this._editorService);
|
|
135
|
+
if (pickedDomains.indexOf('*') !== -1) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
if (isURLDomainTrusted(resourceUri, pickedDomains)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
cancelButton: {
|
|
146
|
+
run: () => false
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
OpenerValidatorContributions = ( __decorate([
|
|
154
|
+
( __param(0, IOpenerService)),
|
|
155
|
+
( __param(1, IStorageService)),
|
|
156
|
+
( __param(2, IDialogService)),
|
|
157
|
+
( __param(3, IProductService)),
|
|
158
|
+
( __param(4, IQuickInputService)),
|
|
159
|
+
( __param(5, IEditorService)),
|
|
160
|
+
( __param(6, IClipboardService)),
|
|
161
|
+
( __param(7, ITelemetryService)),
|
|
162
|
+
( __param(8, IInstantiationService)),
|
|
163
|
+
( __param(9, IAuthenticationService)),
|
|
164
|
+
( __param(10, IWorkspaceContextService)),
|
|
165
|
+
( __param(11, IConfigurationService)),
|
|
166
|
+
( __param(12, IWorkspaceTrustManagementService))
|
|
167
|
+
], OpenerValidatorContributions));
|
|
168
|
+
const rLocalhost = /^localhost(:\d+)?$/i;
|
|
169
|
+
const r127 = /^127.0.0.1(:\d+)?$/;
|
|
170
|
+
function isLocalhostAuthority(authority) {
|
|
171
|
+
return rLocalhost.test(authority) || r127.test(authority);
|
|
172
|
+
}
|
|
173
|
+
function normalizeURL(url) {
|
|
174
|
+
const caseInsensitiveAuthorities = ['github.com'];
|
|
175
|
+
try {
|
|
176
|
+
const parsed = typeof url === 'string' ? ( URI.parse(url, true)) : url;
|
|
177
|
+
if (caseInsensitiveAuthorities.includes(parsed.authority)) {
|
|
178
|
+
return ( parsed.with({ path: parsed.path.toLowerCase() }).toString(true));
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return ( parsed.toString(true));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return ( url.toString());
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function isURLDomainTrusted(url, trustedDomains) {
|
|
189
|
+
url = ( URI.parse(normalizeURL(url)));
|
|
190
|
+
trustedDomains = ( trustedDomains.map(normalizeURL));
|
|
191
|
+
if (isLocalhostAuthority(url.authority)) {
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
for (let i = 0; i < trustedDomains.length; i++) {
|
|
195
|
+
if (trustedDomains[i] === '*') {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
if (testUrlMatchesGlob(url, trustedDomains[i])) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export { OpenerValidatorContributions, isURLDomainTrusted };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
2
|
+
import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { registerAction2, MenuRegistry, MenuId, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
4
|
+
import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
5
|
+
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
|
|
6
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
7
|
+
import { IURLService } from 'vscode/vscode/vs/platform/url/common/url';
|
|
8
|
+
import { Extensions, registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
9
|
+
import { ExternalUriResolverContribution } from './externalUriResolver.js';
|
|
10
|
+
import { manageTrustedDomainSettingsCommand } from './trustedDomains.js';
|
|
11
|
+
import { TrustedDomainsFileSystemProvider } from './trustedDomainsFileSystemProvider.js';
|
|
12
|
+
import { OpenerValidatorContributions } from './trustedDomainsValidator.js';
|
|
13
|
+
import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
|
|
14
|
+
import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
|
|
15
|
+
import { workbenchConfigurationNodeBase } from 'vscode/vscode/vs/workbench/common/configuration';
|
|
16
|
+
|
|
17
|
+
class OpenUrlAction extends Action2 {
|
|
18
|
+
constructor() {
|
|
19
|
+
super({
|
|
20
|
+
id: 'workbench.action.url.openUrl',
|
|
21
|
+
title: ( localize2WithPath('vs/workbench/contrib/url/browser/url.contribution', 'openUrl', 'Open URL')),
|
|
22
|
+
category: Categories.Developer,
|
|
23
|
+
f1: true
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async run(accessor) {
|
|
27
|
+
const quickInputService = accessor.get(IQuickInputService);
|
|
28
|
+
const urlService = accessor.get(IURLService);
|
|
29
|
+
return quickInputService.input({ prompt: ( localizeWithPath(
|
|
30
|
+
'vs/workbench/contrib/url/browser/url.contribution',
|
|
31
|
+
'urlToOpen',
|
|
32
|
+
"URL to open"
|
|
33
|
+
)) }).then(input => {
|
|
34
|
+
if (input) {
|
|
35
|
+
const uri = ( URI.parse(input));
|
|
36
|
+
urlService.open(uri, { originalUrl: input });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
registerAction2(OpenUrlAction);
|
|
42
|
+
CommandsRegistry.registerCommand(manageTrustedDomainSettingsCommand);
|
|
43
|
+
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
|
44
|
+
command: {
|
|
45
|
+
id: manageTrustedDomainSettingsCommand.id,
|
|
46
|
+
title: manageTrustedDomainSettingsCommand.description.description
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(OpenerValidatorContributions, 3 );
|
|
50
|
+
registerWorkbenchContribution2(TrustedDomainsFileSystemProvider.ID, TrustedDomainsFileSystemProvider, 2 );
|
|
51
|
+
registerWorkbenchContribution2(ExternalUriResolverContribution.ID, ExternalUriResolverContribution, 2 );
|
|
52
|
+
const configurationRegistry = ( Registry.as(Extensions$1.Configuration));
|
|
53
|
+
configurationRegistry.registerConfiguration({
|
|
54
|
+
...workbenchConfigurationNodeBase,
|
|
55
|
+
properties: {
|
|
56
|
+
'workbench.trustedDomains.promptInTrustedWorkspace': {
|
|
57
|
+
scope: 1 ,
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
default: false,
|
|
60
|
+
description: ( localizeWithPath(
|
|
61
|
+
'vs/workbench/contrib/url/browser/url.contribution',
|
|
62
|
+
'workbench.trustedDomains.promptInTrustedWorkspace',
|
|
63
|
+
"When enabled, trusted domain prompts will appear when opening links in trusted workspaces."
|
|
64
|
+
))
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { ILayoutService } from 'vscode/vscode/vs/platform/layout/browser/layoutService';
|
|
3
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
4
|
+
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
|
|
5
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
6
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
7
|
+
import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
|
|
8
|
+
import { QuickInputService as QuickInputService$1 } from 'vscode/vscode/vs/platform/quickinput/browser/quickInputService';
|
|
9
|
+
import 'vscode/vscode/vs/platform/quickinput/common/quickInput';
|
|
10
|
+
import { InQuickPickContextKey } from 'vscode/vscode/vs/workbench/browser/quickaccess';
|
|
11
|
+
|
|
12
|
+
let QuickInputService = class QuickInputService extends QuickInputService$1 {
|
|
13
|
+
constructor(configurationService, instantiationService, keybindingService, contextKeyService, themeService, layoutService) {
|
|
14
|
+
super(instantiationService, contextKeyService, themeService, layoutService, configurationService);
|
|
15
|
+
this.keybindingService = keybindingService;
|
|
16
|
+
this.inQuickInputContext = InQuickPickContextKey.bindTo(this.contextKeyService);
|
|
17
|
+
this.registerListeners();
|
|
18
|
+
}
|
|
19
|
+
registerListeners() {
|
|
20
|
+
this._register(this.onShow(() => this.inQuickInputContext.set(true)));
|
|
21
|
+
this._register(this.onHide(() => this.inQuickInputContext.set(false)));
|
|
22
|
+
}
|
|
23
|
+
createController() {
|
|
24
|
+
return super.createController(this.layoutService, {
|
|
25
|
+
ignoreFocusOut: () => !this.configurationService.getValue('workbench.quickOpen.closeOnFocusLost'),
|
|
26
|
+
backKeybindingLabel: () => this.keybindingService.lookupKeybinding('workbench.action.quickInputBack')?.getLabel() || undefined,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
QuickInputService = ( __decorate([
|
|
31
|
+
( __param(0, IConfigurationService)),
|
|
32
|
+
( __param(1, IInstantiationService)),
|
|
33
|
+
( __param(2, IKeybindingService)),
|
|
34
|
+
( __param(3, IContextKeyService)),
|
|
35
|
+
( __param(4, IThemeService)),
|
|
36
|
+
( __param(5, ILayoutService))
|
|
37
|
+
], QuickInputService));
|
|
38
|
+
|
|
39
|
+
export { QuickInputService };
|