Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use vscode-file:// instead of file:// #101837

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
86b7bbc
feat: add vscode-file scheme
deepak1556 May 27, 2020
09e273a
Merge remote-tracking branch 'origin/master' into robo/vscode-file
alexdima Jun 24, 2020
505b841
Experimental tweaks to load from vscode-file:
alexdima Jun 24, 2020
560df14
Merge remote-tracking branch 'origin/master' into robo/vscode-file
alexdima Jun 24, 2020
42aff25
Merge remote-tracking branch 'origin/master' into robo/vscode-file
alexdima Jun 25, 2020
71a03e1
support fetch api in vscode-file:
deepak1556 Jun 26, 2020
e88395e
Define node modules, to avoid attempting loading them as AMD modules
alexdima Jun 26, 2020
5224c7e
Massage dom uris
alexdima Jun 26, 2020
d56bd13
Merge remote-tracking branch 'origin/master' into robo/vscode-file
alexdima Jul 7, 2020
ca503e7
Merge remote-tracking branch 'origin/master' into robo/vscode-file
alexdima Jul 7, 2020
b47e26a
Adopt `preferScriptTags`
alexdima Jul 7, 2020
1fa495c
Fix a couple of tests
alexdima Jul 8, 2020
9fedad2
Fix test on Windows
alexdima Jul 8, 2020
a417d00
Merge branch 'master' into robo/vscode-file
bpasero Jul 20, 2020
2132f0f
Merge branch 'master' into robo/vscode-file
deepak1556 Jul 20, 2020
1de2e79
address review feedback
deepak1556 Jul 20, 2020
473cfd6
fix bad check
deepak1556 Jul 20, 2020
62c31e5
fix double encoding
deepak1556 Jul 21, 2020
8de656d
Merge branch 'origin/master' into robo/vscode-file
deepak1556 Jul 21, 2020
4539119
Merge branch 'origin/master' into robo/vscode-file
deepak1556 Jul 21, 2020
0e14a64
Merge branch 'master' into robo/vscode-file
bpasero Sep 15, 2020
c86abd4
Merge branch 'master' into robo/vscode-file
bpasero Sep 15, 2020
7180a48
adopt new path for native env service interface
bpasero Sep 15, 2020
24b5423
address review feedback
deepak1556 Sep 16, 2020
52c90cd
Merge remote-tracking branch 'origin' into robo/vscode-file
deepak1556 Sep 16, 2020
a3873d9
Merge remote-tracking branch 'origin' into robo/vscode-file
deepak1556 Sep 18, 2020
75e26bd
address review feedback
deepak1556 Sep 18, 2020
623990b
Merge branch 'master' into robo/vscode-file
bpasero Sep 18, 2020
88809ba
some :lipstick:
bpasero Sep 18, 2020
83c9a49
Merge branch 'master' into robo/vscode-file
bpasero Sep 21, 2020
e657360
Merge branch 'master' into robo/vscode-file
bpasero Sep 22, 2020
a1b667d
fix windows loading
bpasero Sep 22, 2020
a27854f
add v8CacheOptions (configurable via CLI arg)
bpasero Sep 22, 2020
0400631
Merge branch 'master' into robo/vscode-file
bpasero Sep 22, 2020
7347078
remove unused variables
bpasero Sep 22, 2020
e2316cf
clarify authority requirement
bpasero Sep 24, 2020
bcfc1a9
consolidate toCodeFileUri into LocalFileAccessImpl
bpasero Sep 24, 2020
7431395
some clarifications
bpasero Sep 24, 2020
81ec8ec
towards supporting authorities
bpasero Sep 24, 2020
4726868
Merge branch 'master' into robo/vscode-file
bpasero Sep 24, 2020
3fe9d3f
add some tests
bpasero Sep 24, 2020
ea4e572
fix tests
bpasero Sep 24, 2020
53c881a
clarify comment
bpasero Sep 24, 2020
ff6b6cd
use getUriFromAmdModule
bpasero Sep 24, 2020
c1cb360
Merge branch 'master' into robo/vscode-file
bpasero Sep 24, 2020
f5513f0
fix webview working
bpasero Sep 24, 2020
c32d682
valid roots: add extension dev location too
bpasero Sep 25, 2020
70b6ab0
:lipstick:
bpasero Sep 25, 2020
01d9bd1
Merge branch 'master' into robo/vscode-file
bpasero Sep 25, 2020
faf30a7
fix duplicate import
bpasero Sep 25, 2020
80e6e0c
touchbar - restore file protocol for icons
bpasero Sep 25, 2020
894f1a8
refactor network methods to make meaning clear
bpasero Sep 25, 2020
1529615
simplify moduleId usage
bpasero Sep 25, 2020
adb9b2c
further renames
bpasero Sep 25, 2020
76f8e44
adopt FileAccess in more places
bpasero Sep 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/bootstrap-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,16 @@

window.document.documentElement.setAttribute('lang', locale);

// do not advertise AMD to avoid confusing UMD modules loaded with nodejs
window['define'] = undefined;

// replace the patched electron fs with the original node fs for all AMD code
require.define('fs', ['original-fs'], function (originalFS) { return originalFS; });
require.define('fs', [], function () { return require.__$__nodeRequire('original-fs'); });

window['MonacoEnvironment'] = {};

const loaderConfig = {
baseUrl: `${bootstrap.uriFromPath(configuration.appRoot)}/out`,
baseUrl: 'vscode-file://localhost/' + `${bootstrap.uriFromPath(configuration.appRoot)}/out`.substr(8),
'vs/nls': nlsConfig,
amdModulesPattern: /^vs\//,
preferScriptTags: true,
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
};

// cached data config
Expand Down
27 changes: 27 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ protocol.registerSchemesAsPrivileged([
corsEnabled: true,
}
},
{
scheme: 'vscode-file',
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
privileges: {
bpasero marked this conversation as resolved.
Show resolved Hide resolved
secure: true,
standard: true,
supportFetchAPI: true,
corsEnabled: true
}
}
]);

// Global app listeners
Expand Down Expand Up @@ -174,6 +183,24 @@ async function onReady() {
try {
const [cachedDataDir, nlsConfig] = await Promise.all([nodeCachedDataDir.ensureExists(), resolveNlsConfiguration()]);

protocol.registerFileProtocol('vscode-file', async (request, callback) => {
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
const uri = new URL(request.url);

if (uri.pathname.startsWith(app.getAppPath())) {
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
return callback({
path: uri.pathname
});
} else {
console.error('vscode-file: Cannot load resource outside of app root');
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
return callback({ error: -3 /* ABORTED */ });
}
});

protocol.interceptFileProtocol('file', async (request, callback) => {
console.error('file: protocol is not allowed in this app');
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
return callback({ error: -3 /* ABORTED */ });
});

startup(cachedDataDir, nlsConfig);
} catch (error) {
console.error(error);
Expand Down
3 changes: 3 additions & 0 deletions src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,9 @@ export function asDomUri(uri: URI): URI {
if (Schemas.vscodeRemote === uri.scheme) {
return RemoteAuthorities.rewrite(uri);
}
if (platform.isNative && Schemas.file === uri.scheme) {
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
return uri.with({ scheme: 'vscode-file' });
}
return uri;
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/sharedProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class SharedProcess implements ISharedProcess {
};

const url = `${require.toUrl('vs/code/electron-browser/sharedProcess/sharedProcess.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;
this.window.loadURL(url);
this.window.loadURL('vscode-file://localhost' + url.slice(7));
bpasero marked this conversation as resolved.
Show resolved Hide resolved
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved

// Prevent the window from dying
const onClose = (e: ElectronEvent) => {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {

// Load URL
perf.mark('main:loadWindow');
this._win.loadURL(this.getUrl(configuration));
this._win.loadURL('vscode-file://localhost' + this.getUrl(configuration).slice(7));
bpasero marked this conversation as resolved.
Show resolved Hide resolved
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved

// Make window visible if it did not open in N seconds because this indicates an error
// Only do this when running out of sources and not when running tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,33 @@ suite('Decoration Render Options', () => {
assert(readStyleSheet(styleSheet).indexOf(`{background:url('data:image/svg+xml;base64,PHN2ZyB4b+') center center no-repeat;}`) > 0);
s.removeDecorationType('example');

function assertBackground(url1: string, url2: string) {
const actual = readStyleSheet(styleSheet);
assert(
actual.indexOf(`{background:url('${url1}') center center no-repeat;}`) > 0
|| actual.indexOf(`{background:url('${url2}') center center no-repeat;}`) > 0
);
}

if (platform.isWindows) {
// windows file path (used as string)
s.registerDecorationType('example', { gutterIconPath: URI.file('c:\\files\\miles\\more.png') });
assert(readStyleSheet(styleSheet).indexOf(`{background:url('file:///c:/files/miles/more.png') center center no-repeat;}`) > 0);
assertBackground('file:///c:/files/miles/more.png', 'vscode-file:/c:/files/miles/more.png');
s.removeDecorationType('example');

// single quote must always be escaped/encoded
s.registerDecorationType('example', { gutterIconPath: URI.file('c:\\files\\foo\\b\'ar.png') });
assert(readStyleSheet(styleSheet).indexOf(`{background:url('file:///c:/files/foo/b%27ar.png') center center no-repeat;}`) > 0);
assertBackground('file:///c:/files/foo/b%27ar.png', 'vscode-file:/c:/files/foo/b%27ar.png');
s.removeDecorationType('example');
} else {
// unix file path (used as string)
s.registerDecorationType('example', { gutterIconPath: URI.file('/Users/foo/bar.png') });
assert(readStyleSheet(styleSheet).indexOf(`{background:url('file:///Users/foo/bar.png') center center no-repeat;}`) > 0);
assertBackground('file:///Users/foo/bar.png', 'vscode-file:/Users/foo/bar.png');
s.removeDecorationType('example');

// single quote must always be escaped/encoded
s.registerDecorationType('example', { gutterIconPath: URI.file('/Users/foo/b\'ar.png') });
assert(readStyleSheet(styleSheet).indexOf(`{background:url('file:///Users/foo/b%27ar.png') center center no-repeat;}`) > 0);
assertBackground('file:///Users/foo/b%27ar.png', 'vscode-file:/Users/foo/b%27ar.png');
s.removeDecorationType('example');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ suite('ExtensionsWorkbenchServiceTest', () => {
assert.equal('1.1.0', actual.version);
assert.equal('1.1.0', actual.latestVersion);
assert.equal('localDescription1', actual.description);
assert.equal('file:///localPath1/localIcon1', actual.iconUrl);
assert.equal('file:///localPath1/localIcon1', actual.iconUrlFallback);
assert.ok(actual.iconUrl === 'file:///localPath1/localIcon1' || actual.iconUrl === 'vscode-file:/localPath1/localIcon1');
assert.ok(actual.iconUrlFallback === 'file:///localPath1/localIcon1' || actual.iconUrlFallback === 'vscode-file:/localPath1/localIcon1');
deepak1556 marked this conversation as resolved.
Show resolved Hide resolved
assert.equal(null, actual.licenseUrl);
assert.equal(ExtensionState.Installed, actual.state);
assert.equal(null, actual.installCount);
Expand Down