Skip to content

Commit f0c37b4

Browse files
PeterStaevCopilot
andauthored
feat: Add support for vscode web (#71)
* try to communicate over the web * test web serial port with vscode * - add main plugin implementation for web - refactor code to support both web and non-web extensions * add mpy compile to web * bump version * Update src/web/message-transformer.ts Co-authored-by: Copilot <[email protected]> * Update src/web/message-transformer.ts Co-authored-by: Copilot <[email protected]> * bump change log * cleanup --------- Co-authored-by: Copilot <[email protected]>
1 parent dadc70d commit f0c37b4

26 files changed

+1910
-448
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ dist
33
lib
44
node_modules
55
.vscode-test/
6+
.vscode-test-web/
67
*.vsix
78
.DS_Store

.vscode/launch.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,35 @@
3333
"${workspaceFolder}/out/test/**/*.js"
3434
],
3535
"preLaunchTask": "npm: test-compile"
36+
},
37+
{
38+
"name": "Run Web Extension in VS Code",
39+
"type": "extensionHost",
40+
"debugWebWorkerHost": true,
41+
"request": "launch",
42+
"args": [
43+
"--extensionDevelopmentPath=${workspaceFolder}",
44+
"--extensionDevelopmentKind=web"
45+
],
46+
"outFiles": [
47+
"${workspaceFolder}/dist/web/**/*.js"
48+
],
49+
"preLaunchTask": "npm: compile"
50+
},
51+
{
52+
"name": "Extension Tests in VS Code",
53+
"type": "extensionHost",
54+
"debugWebWorkerHost": true,
55+
"request": "launch",
56+
"args": [
57+
"--extensionDevelopmentPath=${workspaceFolder}",
58+
"--extensionDevelopmentKind=web",
59+
"--extensionTestsPath=${workspaceFolder}/dist/web/test/suite/index"
60+
],
61+
"outFiles": [
62+
"${workspaceFolder}/dist/web/**/*.js"
63+
],
64+
"preLaunchTask": "npm: compile"
3665
}
3766
]
3867
}

.vscode/tasks.json

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55
"tasks": [
66
{
77
"type": "npm",
8-
"script": "watch",
9-
"problemMatcher": "$tsc-watch",
10-
"isBackground": true,
11-
"presentation": {
12-
"reveal": "never"
13-
},
8+
"script": "compile",
149
"group": {
1510
"kind": "build",
1611
"isDefault": true
1712
},
18-
"label": "npm: watch",
19-
"detail": "tsc -watch -p ./"
13+
"problemMatcher": [],
14+
"label": "npm: compile",
15+
"detail": "webpack --mode development"
2016
}
2117
]
2218
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 3.0.0 - 2025-05-28
4+
5+
- Add support to use the extension as web extension. Currently supporting only connection through USB!
6+
37
## 2.1.0 - 2025-05-25
48

59
- Add USB connection support for HubOS3

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ from file_name import *
3232

3333
is supported. Files not found are skipped (in the hope they exist on the hub). Nevertheless an error will inform you.
3434

35+
> [!NOTE]
36+
> This is not supported for web extension usage.
37+
3538
### Custom Preprocessor
3639

3740
The plugin has a settings where you can specify an external program/script that should be executed before uploading the program
@@ -40,6 +43,9 @@ to the hub. This will receive the contents of the file as stdin. It should outpu
4043
> [!NOTE]
4144
> This will be executed AFTER the builtin preprocessor for combining the files and right before compiling and uploading the program to the hub!
4245
46+
> [!NOTE]
47+
> This is not supported for web extension usage.
48+
4349
### Compilation
4450

4551
The extension supports compiling Python files to binary (MPY) before uploading. This is controlled by a setting:

eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { defineConfig, globalIgnores } from "eslint/config";
1010
import _import from "eslint-plugin-import";
1111
import preferArrow from "eslint-plugin-prefer-arrow";
1212
import simpleImportSort from "eslint-plugin-simple-import-sort";
13+
import importNewLines from "eslint-plugin-import-newlines";
1314
import globals from "globals";
1415
import path from "node:path";
1516
import { fileURLToPath } from "node:url";
@@ -33,6 +34,7 @@ export default defineConfig([globalIgnores(["**/*.d.ts"]), {
3334
import: fixupPluginRules(_import),
3435
"prefer-arrow": preferArrow,
3536
"simple-import-sort": simpleImportSort,
37+
"import-newlines": importNewLines,
3638
"@typescript-eslint": typescriptEslint,
3739
"@stylistic/ts": stylisticTs,
3840
},
@@ -52,6 +54,7 @@ export default defineConfig([globalIgnores(["**/*.d.ts"]), {
5254
},
5355

5456
rules: {
57+
"no-undef": "off",
5558
"@typescript-eslint/adjacent-overload-signatures": "error",
5659

5760
"@typescript-eslint/array-type": ["error", {
@@ -169,6 +172,12 @@ export default defineConfig([globalIgnores(["**/*.d.ts"]), {
169172

170173
"id-match": "error",
171174
"import/no-extraneous-dependencies": "error",
175+
"import-newlines/enforce": [
176+
"error",
177+
{
178+
"items": 2
179+
}
180+
],
172181
"max-len": "off",
173182
"new-parens": "error",
174183
"no-bitwise": "error",

0 commit comments

Comments
 (0)