Skip to content

Commit f33c06f

Browse files
committed
use npm serial-plotter package
1 parent 4c58d9b commit f33c06f

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

arduino-ide-extension/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"description": "An extension for Theia building the Arduino IDE",
55
"license": "AGPL-3.0-or-later",
66
"scripts": {
7-
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn clean && yarn download-examples && yarn build && yarn test",
7+
"prepare": "yarn download-cli && yarn download-fwuploader && yarn download-ls && yarn copy-serial-plotter && yarn clean && yarn download-examples && yarn build && yarn test",
88
"clean": "rimraf lib",
99
"download-cli": "node ./scripts/download-cli.js",
1010
"download-fwuploader": "node ./scripts/download-fwuploader.js",
11+
"copy-serial-plotter": "npx ncp ../node_modules/arduino-serial-plotter-webapp ./build/arduino-serial-plotter-webapp",
1112
"download-ls": "node ./scripts/download-ls.js",
1213
"download-examples": "node ./scripts/download-examples.js",
1314
"generate-protocol": "node ./scripts/generate-protocol.js",
@@ -18,6 +19,7 @@
1819
"test:watch": "mocha --watch --watch-files lib \"./lib/test/**/*.test.js\""
1920
},
2021
"dependencies": {
22+
"arduino-serial-plotter-webapp": "0.0.2",
2123
"@grpc/grpc-js": "^1.3.7",
2224
"@theia/application-package": "1.18.0",
2325
"@theia/core": "1.18.0",

arduino-ide-extension/src/node/plotter/plotter-backend-contribution.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,20 @@ export class PlotterBackendContribution
1010
async initialize(): Promise<void> {}
1111

1212
configure(app: express.Application): void {
13-
app.use(
14-
express.static(
15-
path.join(
16-
__dirname,
17-
'../../../node_modules/arduino-serial-plotter-webapp/build'
18-
)
19-
)
20-
);
21-
app.get('/plotter', (req, res) =>
22-
res.sendFile(
23-
path.join(
24-
__dirname,
25-
'../../../node_modules/arduino-serial-plotter-webapp/build/index.html'
26-
)
27-
)
28-
);
13+
const relativePath = [
14+
'..',
15+
'..',
16+
'..',
17+
'build',
18+
'arduino-serial-plotter-webapp',
19+
'build',
20+
];
21+
app.use(express.static(path.join(__dirname, ...relativePath)));
22+
app.get('/plotter', (req, res) => {
23+
console.log(
24+
`Serving serial plotter on http://${req.headers.host}${req.url}`
25+
);
26+
res.sendFile(path.join(__dirname, ...relativePath, 'index.html'));
27+
});
2928
}
3029
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4012,6 +4012,11 @@ archive-type@^4.0.0:
40124012
dependencies:
40134013
file-type "^4.2.0"
40144014

4015+
arduino-serial-plotter-webapp@0.0.1:
4016+
version "0.0.1"
4017+
resolved "https://registry.yarnpkg.com/arduino-serial-plotter-webapp/-/arduino-serial-plotter-webapp-0.0.1.tgz#a66b512df72432bdb0f48495955351e637190943"
4018+
integrity sha512-6k+8MF6LtMdEZUSDh1FY/pmrI2wCTpFTVriEt5/sa9vJKnoZxkxwoSZzbYNtsqbJU2D4knzoVyS4J/LjaTbkOg==
4019+
40154020
are-we-there-yet@~1.1.2:
40164021
version "1.1.5"
40174022
resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz#4b35c2944f062a8bfcda66410760350fe9ddfc21"

0 commit comments

Comments
 (0)