Skip to content

Commit

Permalink
Merge branch 'release/v2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Nov 5, 2021
2 parents a5e2385 + 7b415f5 commit 8ef67ef
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 80 deletions.
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"plugins": [
"transform-class-properties"
"@babel/plugin-proposal-class-properties"
],
"presets": [
[
"env",
"@babel/preset-env",
{
"targets": {
"node": "8"
"node": "12"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
'plugin:import/errors',
'plugin:import/warnings'
],
'parser': 'babel-eslint',
'parser': '@babel/eslint-parser',
'parserOptions': {
'ecmaVersion': 6,
'sourceType': 'module'
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
# Release Notes

## 2.4.0 (2021-11-05)

**Requires VSCode 1.57 or above**

- Added named status bars: "PlatformIO: Toolbar" and "PlatformIO: Project Environment Switcher" (ability to hide them separately) (issue [#2593](https://github.com/platformio/platformio-vscode-ide/issues/2593))
- Added "Verbose Check" project task
- Synchronize VSCode workspaces with PlatformIO Home Projects (requires PlatformIO Core 5.2.3 or above) (issue [#1367](https://github.com/platformio/platformio-vscode-ide/issues/1367))
- Automatically switch to newly created project's environment (issue [#2414](https://github.com/platformio/platformio-vscode-ide/issues/2414))
- Fixed an issue when "Copy to Clipboard" does not work in PlatformIO Home on macOS (requires PlatformIO Core 5.2.3 or above) (issue [#2570](https://github.com/platformio/platformio-vscode-ide/issues/2570))
- PlatformIO IDE Installer
* Updated installer script to 1.1.0
* Check global PlatformIO Core installation when built-in is disabled
* Handle "Could not find distutils module" error on Linux
* Rebuild project IDE configuration on "platformio.ini" change

## 2.3.4 (2021-10-19)

- Start debugging without firmware uploading using a new ``loadMode`` launch option (see docs for [debug_load_mode](https://docs.platformio.org/en/latest/projectconf/section_env_debug.html#debug-load-mode) for more details). **Requires PlatformIO Core 5.2.2 or above**.
- Start debugging without firmware uploading using a new ``loadMode`` launch option (see docs for [debug_load_mode](https://docs.platformio.org/en/latest/projectconf/section_env_debug.html#debug-load-mode) for more details).
- PlatformIO IDE Installer
* Ask the user to install Python manually if the portable version does not work
* Check compatible Python using the installer script
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.3.4",
"publisher": "platformio",
"engines": {
"vscode": "^1.44.0"
"vscode": "^1.57.0"
},
"license": "Apache-2.0",
"displayName": "PlatformIO IDE",
Expand Down Expand Up @@ -636,27 +636,27 @@
"format": "prettier --single-quote --print-width 88 --write \"src/**/*.js\"",
"vscode:package": "webpack --mode production && vsce package"
},
"devDependencies": {
"@babel/core": "~7.15.8",
"@types/node": "~12",
"@types/vscode": "~1.44.0",
"babel-eslint": "~10.1.0",
"babel-loader": "~8.2.2",
"babel-plugin-transform-class-properties": "~6.24.1",
"babel-preset-env": "~1.7.0",
"eslint": "~7.32.0",
"eslint-import-resolver-webpack": "~0.13.1",
"eslint-plugin-import": "~2.24.2",
"prettier": "~2.3.2",
"vsce": "~1.96.3",
"webpack": "~5.50.0",
"webpack-cli": "~4.7.2"
},
"dependencies": {
"fs-plus": "~3.1.1",
"platformio-node-helpers": "~9.2.4",
"platformio-node-helpers": "~9.4.0",
"platformio-vscode-debug": "~1.4.0"
},
"devDependencies": {
"@babel/core": "~7.16.0",
"@babel/eslint-parser": "~7.16.0",
"@babel/plugin-proposal-class-properties": "~7.16.0",
"@babel/preset-env": "~7.16.0",
"@types/node": "~12",
"@types/vscode": "~1.57.0",
"babel-loader": "~8.2.3",
"eslint": "~8.1.0",
"eslint-import-resolver-webpack": "~0.13.2",
"eslint-plugin-import": "~2.25.2",
"prettier": "~2.4.1",
"vsce": "~2.2.0",
"webpack": "~5.61.0",
"webpack-cli": "~4.9.1"
},
"extensionDependencies": [
"ms-vscode.cpptools"
]
Expand Down
135 changes: 78 additions & 57 deletions src/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import * as pioNodeHelpers from 'platformio-node-helpers';

import { IS_OSX } from './constants';
import ProjectObservable from './project/observable';
import crypto from 'crypto';
import { extension } from './main';
import { notifyError } from './utils';
import path from 'path';
Expand Down Expand Up @@ -96,70 +98,37 @@ export default class PIOHome {
await pioNodeHelpers.home.ensureServerStarted({
port: extension.getSetting('pioHomeServerHttpPort'),
host: extension.getSetting('pioHomeServerHttpHost'),
onIDECommand: async (command, params) => {
if (command === 'open_project') {
if (extension.projectObservable) {
extension.projectObservable.saveProjectStateItem(
vscode.Uri.file(params).fsPath,
'activeEnv',
undefined
);
}
this.disposePanel();
if (vscode.workspace.workspaceFolders) {
vscode.workspace.updateWorkspaceFolders(
vscode.workspace.workspaceFolders.length,
null,
{ uri: vscode.Uri.file(params) }
);
} else {
vscode.commands.executeCommand(
'vscode.openFolder',
vscode.Uri.file(params)
);
}
vscode.commands.executeCommand('workbench.view.explorer');
} else if (command === 'open_text_document') {
const editor = await vscode.window.showTextDocument(
vscode.Uri.file(params.path)
);
const gotoPosition = new vscode.Position(
(params.line || 1) - 1,
(params.column || 1) - 1
);
editor.selection = new vscode.Selection(gotoPosition, gotoPosition);
editor.revealRange(
new vscode.Range(gotoPosition, gotoPosition),
vscode.TextEditorRevealType.InCenter
);
}
},
onIDECommand: await this.onIDECommand.bind(this),
});
const theme = this.getTheme();
const iframeId =
'pioHomeIFrame-' +
crypto.createHash('sha1').update(crypto.randomBytes(512)).digest('hex');
const iframeScript = `
<script>
for (const command of ['selectAll', 'copy', 'paste', 'cut', 'undo', 'redo']) {
document.addEventListener(command, (e) => {
document.getElementById('${iframeId}').contentWindow.postMessage({'command': 'execCommand', 'data': command}, '*');
});
}
window.addEventListener('message', (e) => {
if (e.data.command === 'kbd-event') {
window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
}
});
</script>
`;
return `<!DOCTYPE html>
<html lang="en">
<head>
<script>
window.addEventListener('message', (e) => {
switch (e.data.command) {
case 'kbd-event': {
if (${IS_OSX}) {
window.dispatchEvent(new KeyboardEvent('keydown', e.data.data));
}
break;
}
}
}, false);
</script>
</head>
<head>${IS_OSX ? iframeScript : ''}</head>
<body style="margin: 0; padding: 0; height: 100%; overflow: hidden; background-color: ${
theme === 'light' ? '#FFF' : '#1E1E1E'
}">
<iframe src="${pioNodeHelpers.home.getFrontendUrl({
start: startUrl,
theme,
workspace: extension.getEnterpriseSetting('defaultPIOHomeWorkspace'),
})}"
<iframe id="${iframeId}" src="${pioNodeHelpers.home.getFrontendUrl({
start: startUrl,
theme,
workspace: extension.getEnterpriseSetting('defaultPIOHomeWorkspace'),
})}"
width="100%"
height="100%"
frameborder="0"
Expand All @@ -169,6 +138,58 @@ export default class PIOHome {
`;
}

async onIDECommand(command, params) {
switch (command) {
case 'open_project':
return this.onOpenProjectCommand(params);
case 'open_text_document':
return await this.onOpenTextDocumentCommand(params);
case 'get_pio_project_dirs':
return this.onGetPIOProjectDirs();
}
}

onOpenProjectCommand(params) {
if (extension.projectObservable) {
extension.projectObservable.saveProjectStateItem(
vscode.Uri.file(params).fsPath,
'activeEnv',
undefined
);
extension.projectObservable.switchToProject(vscode.Uri.file(params).fsPath);
}
this.disposePanel();
if (vscode.workspace.workspaceFolders) {
vscode.workspace.updateWorkspaceFolders(
vscode.workspace.workspaceFolders.length,
null,
{ uri: vscode.Uri.file(params) }
);
} else {
vscode.commands.executeCommand('vscode.openFolder', vscode.Uri.file(params));
}
vscode.commands.executeCommand('workbench.view.explorer');
return true;
}

async onOpenTextDocumentCommand(params) {
const editor = await vscode.window.showTextDocument(vscode.Uri.file(params.path));
const gotoPosition = new vscode.Position(
(params.line || 1) - 1,
(params.column || 1) - 1
);
editor.selection = new vscode.Selection(gotoPosition, gotoPosition);
editor.revealRange(
new vscode.Range(gotoPosition, gotoPosition),
vscode.TextEditorRevealType.InCenter
);
return true;
}

onGetPIOProjectDirs() {
return ProjectObservable.getPIOProjectDirs();
}

onPanelDisposed() {
this._currentPanel = undefined;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,11 @@ class PlatformIOVSCodeExtension {
.forEach((item, index) => {
const [text, tooltip, command] = item;
const sbItem = vscode.window.createStatusBarItem(
'pio-toolbar',
vscode.StatusBarAlignment.Left,
STATUS_BAR_PRIORITY_START + index + 1
);
sbItem.name = 'PlatformIO: Toolbar';
sbItem.text = text;
sbItem.tooltip = tooltip;
sbItem.command = command;
Expand Down
2 changes: 2 additions & 0 deletions src/project/observable.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,11 @@ export default class ProjectObservable {

registerEnvSwitcher() {
this._sbEnvSwitcher = vscode.window.createStatusBarItem(
'pio-env-switcher',
vscode.StatusBarAlignment.Left,
STATUS_BAR_PRIORITY_START
);
this._sbEnvSwitcher.name = 'PlatformIO: Project Environment Switcher';
this._sbEnvSwitcher.tooltip = 'Switch PlatformIO Project Environment';
this._sbEnvSwitcher.command = 'platformio-ide.switchProjectEnv';
this._sbEnvSwitcher.text = '$(root-folder) Loading...';
Expand Down

0 comments on commit 8ef67ef

Please sign in to comment.