claw-dashboard 1.9.0 → 2.1.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/.c8rc.json +38 -0
- package/.dockerignore +68 -0
- package/.github/dependabot.yml +45 -0
- package/.github/pull_request_template.md +39 -0
- package/.github/workflows/ci.yml +147 -0
- package/.github/workflows/release.yml +40 -0
- package/.github/workflows/security.yml +84 -0
- package/.husky/pre-commit +1 -0
- package/.planning/codebase/ARCHITECTURE.md +206 -0
- package/.planning/codebase/INTEGRATIONS.md +150 -0
- package/.planning/codebase/STACK.md +122 -0
- package/.planning/codebase/STRUCTURE.md +201 -0
- package/CHANGELOG.md +293 -0
- package/CONTRIBUTING.md +378 -0
- package/Dockerfile +54 -0
- package/FEATURES.md +195 -21
- package/README.md +83 -6
- package/TODO.md +28 -0
- package/build-cjs.js +127 -0
- package/cjs-shim.js +13 -0
- package/dist/clawdash +1729 -0
- package/dist/clawdash.meta.json +2236 -0
- package/dist/widgets.cjs +6511 -0
- package/docker-compose.yml +67 -0
- package/docs/API.md +1050 -0
- package/docs/PLUGINS.md +1504 -0
- package/esbuild.config.js +158 -0
- package/eslint.config.js +56 -0
- package/examples/plugins/README.md +122 -0
- package/examples/plugins/api-status/index.js +294 -0
- package/examples/plugins/api-status/plugin.json +19 -0
- package/examples/plugins/hello-world/index.js +104 -0
- package/examples/plugins/hello-world/plugin.json +15 -0
- package/examples/plugins/system-metrics-chart/index.js +339 -0
- package/examples/plugins/system-metrics-chart/plugin.json +18 -0
- package/examples/plugins/weather-widget/index.js +136 -0
- package/examples/plugins/weather-widget/plugin.json +19 -0
- package/index.cjs +23005 -0
- package/index.js +5285 -566
- package/jest.config.js +11 -0
- package/man/clawdash.1 +276 -0
- package/package.json +54 -6
- package/schemas/plugin-manifest.json +128 -0
- package/scripts/release.js +595 -0
- package/src/alerts.js +693 -0
- package/src/auto-save.js +584 -0
- package/src/cache.js +390 -0
- package/src/checksum.js +146 -0
- package/src/cli/args.js +110 -0
- package/src/cli/export-schedule.js +423 -0
- package/src/cli/export-snapshot.js +138 -0
- package/src/cli/help.js +69 -0
- package/src/cli/import-snapshot.js +230 -0
- package/src/cli/index.js +14 -0
- package/src/cli/list-templates.js +69 -0
- package/src/cli/validate-config.js +76 -0
- package/src/cli/validate-plugin.js +187 -0
- package/src/cli/version.js +15 -0
- package/src/config-validator.js +586 -0
- package/src/config-watcher.js +401 -0
- package/src/config.js +684 -0
- package/src/container-detector.js +499 -0
- package/src/database.js +734 -0
- package/src/differential-render.js +327 -0
- package/src/errors.js +169 -0
- package/src/export-scheduler.js +581 -0
- package/src/gateway-manager.js +685 -0
- package/src/hints.js +371 -0
- package/src/loading-states.js +509 -0
- package/src/logger.js +185 -0
- package/src/memory-pressure.js +467 -0
- package/src/performance-monitor.js +374 -0
- package/src/plugin-errors.js +586 -0
- package/src/plugin-manifest-validator.js +219 -0
- package/src/plugin-reload.js +481 -0
- package/src/plugin-scaffold.js +1934 -0
- package/src/plugin-validator.js +284 -0
- package/src/retry.js +218 -0
- package/src/security.js +860 -0
- package/src/snapshot.js +372 -0
- package/src/splash.js +115 -0
- package/src/theme-selector.js +411 -0
- package/src/themes.js +874 -0
- package/src/transitions.js +534 -0
- package/src/types.d.ts +174 -0
- package/src/validation.js +926 -0
- package/src/web-server.js +885 -0
- package/src/widgets/builtin-widgets.js +1056 -0
- package/src/widgets/config-processor.js +401 -0
- package/src/widgets/dependency-resolver.js +596 -0
- package/src/widgets/index.js +79 -0
- package/src/widgets/plugin-api.js +845 -0
- package/src/widgets/widget-error-boundary.js +773 -0
- package/src/widgets/widget-error-isolation.js +551 -0
- package/src/widgets/widget-loader.js +1437 -0
- package/src/workers/system-worker.js +130 -0
- package/src/workers/worker-pool.js +633 -0
- package/tests/alerts.test.js +437 -0
- package/tests/auto-save.test.js +529 -0
- package/tests/cache.test.js +317 -0
- package/tests/cli.test.js +351 -0
- package/tests/command-palette.test.js +320 -0
- package/tests/config-processor.test.js +452 -0
- package/tests/config-validator.test.js +710 -0
- package/tests/config-watcher.test.js +594 -0
- package/tests/config.test.js +755 -0
- package/tests/database.test.js +438 -0
- package/tests/errors.test.js +189 -0
- package/tests/example-plugins.test.js +624 -0
- package/tests/integration.test.js +1321 -0
- package/tests/loading-states.test.js +300 -0
- package/tests/manifest-validation-on-load.test.js +671 -0
- package/tests/performance-monitor.test.js +190 -0
- package/tests/plugin-api-rate-limit.test.js +302 -0
- package/tests/plugin-errors.test.js +311 -0
- package/tests/plugin-lifecycle-e2e.test.js +1036 -0
- package/tests/plugin-reload.test.js +764 -0
- package/tests/rate-limiter.test.js +539 -0
- package/tests/retry.test.js +308 -0
- package/tests/security.test.js +411 -0
- package/tests/settings-modal.test.js +226 -0
- package/tests/theme-selector.test.js +57 -0
- package/tests/utils.js +242 -0
- package/tests/utils.test.js +317 -0
- package/tests/validate-plugin-cli.test.js +359 -0
- package/tests/validation.test.js +837 -0
- package/tests/web-server.test.js +646 -0
- package/tests/widget-arrange-mode.test.js +183 -0
- package/tests/widget-config-hot-reload.test.js +465 -0
- package/tests/widget-dependency.test.js +591 -0
- package/tests/widget-error-boundary.test.js +749 -0
- package/tests/widget-error-isolation.test.js +469 -0
- package/tests/widget-integration.test.js +1147 -0
- package/tests/widget-refresh-intervals.test.js +284 -0
- package/tests/worker-pool.test.js +522 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker thread for heavy system information gathering
|
|
3
|
+
* Offloads CPU-intensive systeminformation calls from the main thread
|
|
4
|
+
* to keep the dashboard UI responsive
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { parentPort, isMainThread, workerData } from 'worker_threads';
|
|
8
|
+
import logger from '../logger.js';
|
|
9
|
+
|
|
10
|
+
// Systeminformation module (dynamically imported)
|
|
11
|
+
let si = null;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the systeminformation module
|
|
15
|
+
*/
|
|
16
|
+
async function initSystemInfo() {
|
|
17
|
+
if (!si) {
|
|
18
|
+
const module = await import('systeminformation');
|
|
19
|
+
si = module.default || module;
|
|
20
|
+
}
|
|
21
|
+
return si;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Execute a systeminformation command
|
|
26
|
+
* @param {string} command - Command to execute
|
|
27
|
+
* @param {Object} options - Command options
|
|
28
|
+
* @returns {Promise<any>} Command result
|
|
29
|
+
*/
|
|
30
|
+
async function executeCommand(command, options = {}) {
|
|
31
|
+
const systemInfo = await initSystemInfo();
|
|
32
|
+
|
|
33
|
+
switch (command) {
|
|
34
|
+
case 'currentLoad':
|
|
35
|
+
return await systemInfo.currentLoad();
|
|
36
|
+
|
|
37
|
+
case 'mem':
|
|
38
|
+
return await systemInfo.mem();
|
|
39
|
+
|
|
40
|
+
case 'graphics':
|
|
41
|
+
return await systemInfo.graphics();
|
|
42
|
+
|
|
43
|
+
case 'networkStats':
|
|
44
|
+
return await systemInfo.networkStats();
|
|
45
|
+
|
|
46
|
+
case 'fsSize':
|
|
47
|
+
return await systemInfo.fsSize();
|
|
48
|
+
|
|
49
|
+
case 'osInfo':
|
|
50
|
+
return await systemInfo.osInfo();
|
|
51
|
+
|
|
52
|
+
case 'versions':
|
|
53
|
+
return await systemInfo.versions();
|
|
54
|
+
|
|
55
|
+
case 'time':
|
|
56
|
+
return await systemInfo.time();
|
|
57
|
+
|
|
58
|
+
case 'systemData':
|
|
59
|
+
// Fetch multiple system data in parallel
|
|
60
|
+
const [os, ver, time] = await Promise.all([
|
|
61
|
+
systemInfo.osInfo(),
|
|
62
|
+
systemInfo.versions(),
|
|
63
|
+
systemInfo.time(),
|
|
64
|
+
]);
|
|
65
|
+
return { os, ver, time };
|
|
66
|
+
|
|
67
|
+
case 'processes':
|
|
68
|
+
return await systemInfo.processes();
|
|
69
|
+
|
|
70
|
+
case 'diskLayout':
|
|
71
|
+
return await systemInfo.diskLayout();
|
|
72
|
+
|
|
73
|
+
case 'battery':
|
|
74
|
+
return await systemInfo.battery();
|
|
75
|
+
|
|
76
|
+
case 'users':
|
|
77
|
+
return await systemInfo.users();
|
|
78
|
+
|
|
79
|
+
default:
|
|
80
|
+
throw new Error(`Unknown command: ${command}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Handle messages from the main thread
|
|
86
|
+
*/
|
|
87
|
+
if (!isMainThread && parentPort) {
|
|
88
|
+
parentPort.on('message', async (message) => {
|
|
89
|
+
const { id, command, options } = message;
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
const startTime = Date.now();
|
|
93
|
+
const result = await executeCommand(command, options);
|
|
94
|
+
const duration = Date.now() - startTime;
|
|
95
|
+
|
|
96
|
+
// Send successful result back to main thread
|
|
97
|
+
parentPort.postMessage({
|
|
98
|
+
id,
|
|
99
|
+
success: true,
|
|
100
|
+
data: result,
|
|
101
|
+
duration,
|
|
102
|
+
});
|
|
103
|
+
} catch (error) {
|
|
104
|
+
// Send error back to main thread
|
|
105
|
+
parentPort.postMessage({
|
|
106
|
+
id,
|
|
107
|
+
success: false,
|
|
108
|
+
error: error.message,
|
|
109
|
+
stack: error.stack,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Signal that worker is ready
|
|
115
|
+
parentPort.postMessage({ type: 'ready' });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Worker thread entry point validation
|
|
120
|
+
* Prevents accidental execution in main thread
|
|
121
|
+
*/
|
|
122
|
+
if (isMainThread) {
|
|
123
|
+
// This file should only be run as a worker thread
|
|
124
|
+
// Export a marker for the main thread to detect
|
|
125
|
+
export const IS_WORKER_THREAD_MODULE = true;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default {
|
|
129
|
+
IS_WORKER_THREAD_MODULE: true,
|
|
130
|
+
};
|