termweb-dashboard 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/server.js CHANGED
@@ -5,7 +5,7 @@ const http = require('http');
5
5
  const path = require('path');
6
6
  const fs = require('fs');
7
7
  const WebSocket = require('ws');
8
- const { collectMetrics, collectLightMetrics, getMetricsCached, startBackgroundPolling, killProcess, getConnections, getFolderSizes } = require('./metrics');
8
+ const { collectMetrics, collectLightMetrics, getMetricsCached, startBackgroundPolling, killProcess, deleteFolder, getConnections, getFolderSizes } = require('./metrics');
9
9
 
10
10
  /**
11
11
  * Start the metrics server
@@ -106,18 +106,27 @@ function startServer(port = 0) {
106
106
  } else if (cmd.type === 'kill' && cmd.pid) {
107
107
  const success = killProcess(cmd.pid);
108
108
  ws.send(JSON.stringify({ type: 'kill', success, pid: cmd.pid }));
109
+ } else if (cmd.type === 'delete' && cmd.path) {
110
+ const success = deleteFolder(cmd.path);
111
+ ws.send(JSON.stringify({ type: 'delete', success, path: cmd.path }));
109
112
  } else if (cmd.type === 'connections') {
110
113
  const connections = await getConnections();
111
114
  ws.send(JSON.stringify({ type: 'connections', data: connections }));
112
115
  } else if (cmd.type === 'folderSizes' && cmd.path) {
116
+ // Resolve ~ to home directory
117
+ let resolvedPath = cmd.path;
118
+ if (resolvedPath.startsWith('~')) {
119
+ const home = process.env.HOME || process.env.USERPROFILE || '/';
120
+ resolvedPath = resolvedPath.replace(/^~/, home);
121
+ }
113
122
  // Progressive scanning - returns estimates immediately, pushes updates
114
123
  const onUpdate = (path, data) => {
115
124
  if (ws.readyState === WebSocket.OPEN) {
116
- ws.send(JSON.stringify({ type: 'folderSizes', path, data }));
125
+ ws.send(JSON.stringify({ type: 'folderSizes', path: resolvedPath, data }));
117
126
  }
118
127
  };
119
- const sizes = await getFolderSizes(cmd.path, onUpdate);
120
- ws.send(JSON.stringify({ type: 'folderSizes', path: cmd.path, data: sizes }));
128
+ const sizes = await getFolderSizes(resolvedPath, onUpdate);
129
+ ws.send(JSON.stringify({ type: 'folderSizes', path: resolvedPath, data: sizes }));
121
130
  }
122
131
  } catch (err) {
123
132
  // Ignore invalid messages
File without changes
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "termweb-dashboard",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "Terminal-based system monitoring dashboard powered by termweb",
5
5
  "bin": {
6
6
  "termweb-dashboard": "bin/cli.js"
7
7
  },
8
8
  "scripts": {
9
9
  "build": "esbuild src/app.js --bundle --minify --outfile=dist/app.bundle.js",
10
+ "build:native": "cd native && zig build -Doptimize=ReleaseFast",
10
11
  "start": "node bin/cli.js"
11
12
  },
12
13
  "files": [
13
14
  "bin/",
14
15
  "dist/",
15
- "lib/"
16
+ "lib/",
17
+ "native/prebuilt/"
16
18
  ],
17
19
  "keywords": [
18
20
  "terminal",