Skip to content

Commit 6b1edd4

Browse files
committed
chore(transport-bridge): simplify ui
1 parent 3736dec commit 6b1edd4

File tree

5 files changed

+15
-34
lines changed

5 files changed

+15
-34
lines changed

packages/transport-bridge/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"devDependencies": {
2222
"@types/json-stable-stringify": "^1",
2323
"esbuild": "^0.23.1",
24+
"html-inline-script-webpack-plugin": "^3.2.1",
2425
"html-webpack-plugin": "^5.6.0",
2526
"pkg": "^5.8.1",
2627
"webpack": "^5.97.1"

packages/transport-bridge/src/http.ts

-32
Original file line numberDiff line numberDiff line change
@@ -441,38 +441,6 @@ export class TrezordNode {
441441
},
442442
]);
443443

444-
app.get('/ui', [
445-
(req, res) => {
446-
const parsedUrl = new URL(req.url, `http://${req.headers.host}/`);
447-
448-
const pathname = path.join(__dirname, this.assetPrefix, parsedUrl.pathname);
449-
450-
const map: Record<string, string> = {
451-
'.ico': 'image/x-icon',
452-
'.html': 'text/html',
453-
'.js': 'text/javascript',
454-
'.json': 'application/json',
455-
'.css': 'text/css',
456-
'.png': 'image/png',
457-
'.jpg': 'image/jpeg',
458-
'.svg': 'image/svg+xml',
459-
};
460-
461-
const { ext } = path.parse(pathname);
462-
fs.stat(pathname)
463-
.then(() => fs.readFile(pathname))
464-
.then(data => {
465-
res.setHeader('Content-type', map[ext] || 'text/plain');
466-
res.end(data);
467-
})
468-
.catch(err => {
469-
this.logger.error('Failed to fetch UI', err);
470-
res.statusCode = 404;
471-
res.end(`File ${pathname} not found!`);
472-
});
473-
},
474-
]);
475-
476444
app.get('/logs', [
477445
(_req, res) => {
478446
res.writeHead(200, {

packages/transport-bridge/webpack/ui.webpack.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import HtmlInlineScriptPlugin from 'html-inline-script-webpack-plugin';
12
import HtmlWebpackPlugin from 'html-webpack-plugin';
23
import path from 'path';
34
import webpack from 'webpack';
@@ -62,10 +63,9 @@ const config: webpack.Configuration = {
6263
plugins: [
6364
new HtmlWebpackPlugin({
6465
template: path.resolve(__dirname, '../src/ui/index.html'),
65-
filename: 'index.html',
6666
inject: 'body',
67-
publicPath: 'http://127.0.0.1:21325/ui',
6867
}),
68+
new HtmlInlineScriptPlugin(),
6969
],
7070
};
7171

scripts/list-outdated-dependencies/connect-dependencies.txt

+1
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,4 @@ scroll-into-view-if-needed
9393
@reown/walletkit
9494
@walletconnect/core
9595
@walletconnect/utils
96+
html-inline-script-webpack-plugin

yarn.lock

+11
Original file line numberDiff line numberDiff line change
@@ -12753,6 +12753,7 @@ __metadata:
1275312753
"@trezor/utils": "workspace:*"
1275412754
"@types/json-stable-stringify": "npm:^1"
1275512755
esbuild: "npm:^0.23.1"
12756+
html-inline-script-webpack-plugin: "npm:^3.2.1"
1275612757
html-webpack-plugin: "npm:^5.6.0"
1275712758
json-stable-stringify: "npm:^1.2.1"
1275812759
pkg: "npm:^5.8.1"
@@ -25999,6 +26000,16 @@ __metadata:
2599926000
languageName: node
2600026001
linkType: hard
2600126002

26003+
"html-inline-script-webpack-plugin@npm:^3.2.1":
26004+
version: 3.2.1
26005+
resolution: "html-inline-script-webpack-plugin@npm:3.2.1"
26006+
peerDependencies:
26007+
html-webpack-plugin: ^5.0.0
26008+
webpack: ^5.0.0
26009+
checksum: 10/f7a67038ee89d6447a0389e92e565fcbe5482091d688096542304ee3d3a163aa3f2d7a725ee5a3eeda707913849cc0dbb2b6489d4fc190951a178492785ebbb5
26010+
languageName: node
26011+
linkType: hard
26012+
2600226013
"html-minifier-terser@npm:^6.0.2":
2600326014
version: 6.1.0
2600426015
resolution: "html-minifier-terser@npm:6.1.0"

0 commit comments

Comments
 (0)