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

chore: update to electron 13 #124666

Merged
merged 9 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ jobs:
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModules13-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules13-
key: ${{ runner.os }}-cacheNodeModules14-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules14-
- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
Expand Down Expand Up @@ -165,8 +165,8 @@ jobs:
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModules13-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules13-
key: ${{ runner.os }}-cacheNodeModules14-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules14-
- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
Expand Down Expand Up @@ -218,8 +218,8 @@ jobs:
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModules13-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules13-
key: ${{ runner.os }}-cacheNodeModules14-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules14-
- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
disturl "https://electronjs.org/headers"
target "12.0.13"
target "13.1.6"
runtime "electron"
2 changes: 1 addition & 1 deletion build/.cachesalt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2021-04-07T03:52:18.011Z
2021-05-26T10:17:08.678Z
8 changes: 4 additions & 4 deletions cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"git": {
"name": "chromium",
"repositoryUrl": "https://chromium.googlesource.com/chromium/src",
"commitHash": "cd7a46bf02a768a1aabf9443f6ee469bc6e28e7c"
"commitHash": "7a7e35991d61ce564ed3641222da2c4ed7a65535"
}
},
"licenseDetail": [
Expand Down Expand Up @@ -40,7 +40,7 @@
"SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
],
"isOnlyProductionDependency": true,
"version": "89.0.4389.128"
"version": "91.0.4472.124"
},
{
"component": {
Expand All @@ -60,12 +60,12 @@
"git": {
"name": "electron",
"repositoryUrl": "https://github.com/electron/electron",
"commitHash": "14ae30aa9b2619358298b525acd398446b385151"
"commitHash": "ddc44e1af4fa6bf0c4c05f3dd48270ef308bc470"
}
},
"isOnlyProductionDependency": true,
"license": "MIT",
"version": "12.0.13"
"version": "13.1.6"
},
{
"component": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"cssnano": "^4.1.11",
"debounce": "^1.0.0",
"deemon": "^1.4.0",
"electron": "12.0.13",
"electron": "13.1.6",
"eslint": "6.8.0",
"eslint-plugin-jsdoc": "^19.1.0",
"event-stream": "3.3.4",
Expand Down
45 changes: 30 additions & 15 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,18 @@ const argvConfig = configureCommandlineSwitchesSync(args);

// Configure crash reporter
perf.mark('code/willStartCrashReporter');
configureCrashReporter();
// If a crash-reporter-directory is specified we store the crash reports
// in the specified directory and don't upload them to the crash server.
//
// Appcenter crash reporting is enabled if
// * enable-crash-reporter runtime argument is set to 'true'
// * --disable-crash-reporter command line parameter is not set
//
// Disable crash reporting in all other cases.
if (args['crash-reporter-directory'] ||
(argvConfig['enable-crash-reporter'] && !args['disable-crash-reporter'])) {
configureCrashReporter();
}
perf.mark('code/didStartCrashReporter');

// Set logs path before app 'ready' event if running portable
Expand Down Expand Up @@ -321,8 +332,6 @@ function getArgvConfigPath() {

function configureCrashReporter() {

// If a crash-reporter-directory is specified we store the crash reports
// in the specified directory and don't upload them to the crash server.
let crashReporterDirectory = args['crash-reporter-directory'];
let submitURL = '';
if (crashReporterDirectory) {
Expand Down Expand Up @@ -351,11 +360,7 @@ function configureCrashReporter() {
// Otherwise we configure the crash reporter from product.json
else {
const appCenter = product.appCenter;
// Disable Appcenter crash reporting if
// * --crash-reporter-directory is specified
// * enable-crash-reporter runtime argument is set to 'false'
// * --disable-crash-reporter command line parameter is set
if (appCenter && argvConfig['enable-crash-reporter'] && !args['disable-crash-reporter']) {
if (appCenter) {
const isWindows = (process.platform === 'win32');
const isLinux = (process.platform === 'linux');
const isDarwin = (process.platform === 'darwin');
Expand Down Expand Up @@ -410,13 +415,23 @@ function configureCrashReporter() {
// Start crash reporter for all processes
const productName = (product.crashReporter ? product.crashReporter.productName : undefined) || product.nameShort;
const companyName = (product.crashReporter ? product.crashReporter.companyName : undefined) || 'Microsoft';
crashReporter.start({
companyName: companyName,
productName: process.env['VSCODE_DEV'] ? `${productName} Dev` : productName,
submitURL,
uploadToServer: !crashReporterDirectory,
compress: true
});
if (process.env['VSCODE_DEV']) {
crashReporter.start({
companyName: companyName,
productName: `${productName} Dev`,
submitURL,
uploadToServer: false,
compress: true
});
} else {
crashReporter.start({
companyName: companyName,
productName: productName,
submitURL,
uploadToServer: !crashReporterDirectory,
compress: true
});
}
}

/**
Expand Down
9 changes: 2 additions & 7 deletions src/vs/base/parts/sandbox/electron-browser/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,13 @@
// Use `contextBridge` APIs to expose globals to VSCode
// only if context isolation is enabled, otherwise just
// add to the DOM global.
let useContextBridge = process.argv.includes('--context-isolation');
if (useContextBridge) {
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('vscode', globals);
} catch (error) {
console.error(error);

useContextBridge = false;
}
}

if (!useContextBridge) {
} else {
// @ts-ignore
window.vscode = globals;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class CodeApplication extends Disposable {
// !!! DO NOT CHANGE without consulting the documentation !!!
//

const isUrlFromWebview = (requestingUrl: string) => requestingUrl.startsWith(`${Schemas.vscodeWebview}://`);
const isUrlFromWebview = (requestingUrl: string | undefined) => requestingUrl?.startsWith(`${Schemas.vscodeWebview}://`);

session.defaultSession.setPermissionRequestHandler((_webContents, permission /* 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal' */, callback, details) => {
if (isUrlFromWebview(details.requestingUrl)) {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/environment/node/userDataPath.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
/**
* Returns the user data path to use with some rules:
* - respect portable mode
* - respect --user-data-dir CLI argument
* - respect VSCODE_APPDATA environment variable
* - respect --user-data-dir CLI argument
*/
export function getUserDataPath(args: NativeParsedArgs): string;
54 changes: 29 additions & 25 deletions src/vs/platform/environment/node/userDataPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,42 @@
return path.join(portablePath, 'user-data');
}

// 2. Support explicit --user-data-dir
// 2. Support global VSCODE_APPDATA environment variable
let appDataPath = process.env['VSCODE_APPDATA'];
if (appDataPath) {
return path.join(appDataPath, productName);
}

// With Electron>=13 --user-data-dir switch will be propagated to
// all processes https://github.com/electron/electron/blob/1897b14af36a02e9aa7e4d814159303441548251/shell/browser/electron_browser_client.cc#L546-L553
// Check VSCODE_PORTABLE and VSCODE_APPDATA before this case to get correct values.
// 3. Support explicit --user-data-dir
const cliPath = cliArgs['user-data-dir'];
if (cliPath) {
return cliPath;
}

// 3. Support global VSCODE_APPDATA environment variable
let appDataPath = process.env['VSCODE_APPDATA'];

// 4. Otherwise check per platform
if (!appDataPath) {
switch (process.platform) {
case 'win32':
appDataPath = process.env['APPDATA'];
if (!appDataPath) {
const userProfile = process.env['USERPROFILE'];
if (typeof userProfile !== 'string') {
throw new Error('Windows: Unexpected undefined %USERPROFILE% environment variable');
}

appDataPath = path.join(userProfile, 'AppData', 'Roaming');
switch (process.platform) {
case 'win32':
appDataPath = process.env['APPDATA'];
if (!appDataPath) {
const userProfile = process.env['USERPROFILE'];
if (typeof userProfile !== 'string') {
throw new Error('Windows: Unexpected undefined %USERPROFILE% environment variable');
}
break;
case 'darwin':
appDataPath = path.join(os.homedir(), 'Library', 'Application Support');
break;
case 'linux':
appDataPath = process.env['XDG_CONFIG_HOME'] || path.join(os.homedir(), '.config');
break;
default:
throw new Error('Platform not supported');
}

appDataPath = path.join(userProfile, 'AppData', 'Roaming');
}
break;
case 'darwin':
appDataPath = path.join(os.homedir(), 'Library', 'Application Support');
break;
case 'linux':
appDataPath = process.env['XDG_CONFIG_HOME'] || path.join(os.homedir(), '.config');
break;
default:
throw new Error('Platform not supported');
}

return path.join(appDataPath, productName);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/issue/electron-main/issueMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export class IssueMainService implements ICommonIssueService {
backgroundColor: options.backgroundColor || IssueMainService.DEFAULT_BACKGROUND_COLOR,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
additionalArguments: [`--vscode-window-config=${ipcObjectUrl.resource.toString()}`, '--context-isolation' /* TODO@bpasero: Use process.contextIsolateed when 13-x-y is adopted (https://github.com/electron/electron/pull/28030) */],
additionalArguments: [`--vscode-window-config=${ipcObjectUrl.resource.toString()}`],
v8CacheOptions: browserCodeLoadingCacheStrategy,
enableWebSQL: false,
spellcheck: false,
Expand Down
4 changes: 1 addition & 3 deletions src/vs/platform/windows/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
title: this.productService.nameLong,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
additionalArguments: this.environmentMainService.sandbox ?
[`--vscode-window-config=${this.configObjectUrl.resource.toString()}`, '--context-isolation' /* TODO@bpasero: Use process.contextIsolateed when 13-x-y is adopted (https://github.com/electron/electron/pull/28030) */] :
[`--vscode-window-config=${this.configObjectUrl.resource.toString()}`],
additionalArguments: [`--vscode-window-config=${this.configObjectUrl.resource.toString()}`],
v8CacheOptions: browserCodeLoadingCacheStrategy,
enableWebSQL: false,
spellcheck: false,
Expand Down
2 changes: 1 addition & 1 deletion test/smoke/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { setup as setupDataMultirootTests } from './areas/multiroot/multiroot.te
import { setup as setupDataLocalizationTests } from './areas/workbench/localization.test';
import { setup as setupLaunchTests } from './areas/workbench/launch.test';

const tmpDir = tmp.dirSync({ prefix: 't' }) as { name: string; removeCallback: Function; };
const tmpDir = tmp.dirSync({ name: 't' }) as { name: string; removeCallback: Function; };
bpasero marked this conversation as resolved.
Show resolved Hide resolved
const testDataPath = tmpDir.name;
process.once('exit', () => {
try {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3039,10 +3039,10 @@ electron-to-chromium@^1.3.723:
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.737.tgz#196f2e9656f4f3c31930750e1899c091b72d36b5"
integrity sha512-P/B84AgUSQXaum7a8m11HUsYL8tj9h/Pt5f7Hg7Ty6bm5DxlFq+e5+ouHUoNQMsKDJ7u4yGfI8mOErCmSH9wyg==

electron@12.0.13:
version "12.0.13"
resolved "https://registry.yarnpkg.com/electron/-/electron-12.0.13.tgz#f1c7f3d8b25078d7622ed900cc8f2aa4731a5e0a"
integrity sha512-2yx102mhqgyaTVH+GCet4hURKOIuI27DcVdlval5T3eOEZMOHNrCbi8/8PZ7MqMfB5PIxJ+grS5S00/n5Zcu2Q==
electron@13.1.6:
version "13.1.6"
resolved "https://registry.yarnpkg.com/electron/-/electron-13.1.6.tgz#6ecaf969255d62ce82cc0b5c948bf26e7dfb489b"
integrity sha512-XiB55/JTaQpDFQrD9pulYnOGwaWeMyRIub5ispvoE2bWBvM5zVMLptwMLb0m3KTMrfSkzhedZvOu7fwYvR7L7Q==
dependencies:
"@electron/get" "^1.0.1"
"@types/node" "^14.6.2"
Expand Down