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.
Files changed (135) hide show
  1. package/.c8rc.json +38 -0
  2. package/.dockerignore +68 -0
  3. package/.github/dependabot.yml +45 -0
  4. package/.github/pull_request_template.md +39 -0
  5. package/.github/workflows/ci.yml +147 -0
  6. package/.github/workflows/release.yml +40 -0
  7. package/.github/workflows/security.yml +84 -0
  8. package/.husky/pre-commit +1 -0
  9. package/.planning/codebase/ARCHITECTURE.md +206 -0
  10. package/.planning/codebase/INTEGRATIONS.md +150 -0
  11. package/.planning/codebase/STACK.md +122 -0
  12. package/.planning/codebase/STRUCTURE.md +201 -0
  13. package/CHANGELOG.md +293 -0
  14. package/CONTRIBUTING.md +378 -0
  15. package/Dockerfile +54 -0
  16. package/FEATURES.md +195 -21
  17. package/README.md +83 -6
  18. package/TODO.md +28 -0
  19. package/build-cjs.js +127 -0
  20. package/cjs-shim.js +13 -0
  21. package/dist/clawdash +1729 -0
  22. package/dist/clawdash.meta.json +2236 -0
  23. package/dist/widgets.cjs +6511 -0
  24. package/docker-compose.yml +67 -0
  25. package/docs/API.md +1050 -0
  26. package/docs/PLUGINS.md +1504 -0
  27. package/esbuild.config.js +158 -0
  28. package/eslint.config.js +56 -0
  29. package/examples/plugins/README.md +122 -0
  30. package/examples/plugins/api-status/index.js +294 -0
  31. package/examples/plugins/api-status/plugin.json +19 -0
  32. package/examples/plugins/hello-world/index.js +104 -0
  33. package/examples/plugins/hello-world/plugin.json +15 -0
  34. package/examples/plugins/system-metrics-chart/index.js +339 -0
  35. package/examples/plugins/system-metrics-chart/plugin.json +18 -0
  36. package/examples/plugins/weather-widget/index.js +136 -0
  37. package/examples/plugins/weather-widget/plugin.json +19 -0
  38. package/index.cjs +23005 -0
  39. package/index.js +5285 -566
  40. package/jest.config.js +11 -0
  41. package/man/clawdash.1 +276 -0
  42. package/package.json +54 -6
  43. package/schemas/plugin-manifest.json +128 -0
  44. package/scripts/release.js +595 -0
  45. package/src/alerts.js +693 -0
  46. package/src/auto-save.js +584 -0
  47. package/src/cache.js +390 -0
  48. package/src/checksum.js +146 -0
  49. package/src/cli/args.js +110 -0
  50. package/src/cli/export-schedule.js +423 -0
  51. package/src/cli/export-snapshot.js +138 -0
  52. package/src/cli/help.js +69 -0
  53. package/src/cli/import-snapshot.js +230 -0
  54. package/src/cli/index.js +14 -0
  55. package/src/cli/list-templates.js +69 -0
  56. package/src/cli/validate-config.js +76 -0
  57. package/src/cli/validate-plugin.js +187 -0
  58. package/src/cli/version.js +15 -0
  59. package/src/config-validator.js +586 -0
  60. package/src/config-watcher.js +401 -0
  61. package/src/config.js +684 -0
  62. package/src/container-detector.js +499 -0
  63. package/src/database.js +734 -0
  64. package/src/differential-render.js +327 -0
  65. package/src/errors.js +169 -0
  66. package/src/export-scheduler.js +581 -0
  67. package/src/gateway-manager.js +685 -0
  68. package/src/hints.js +371 -0
  69. package/src/loading-states.js +509 -0
  70. package/src/logger.js +185 -0
  71. package/src/memory-pressure.js +467 -0
  72. package/src/performance-monitor.js +374 -0
  73. package/src/plugin-errors.js +586 -0
  74. package/src/plugin-manifest-validator.js +219 -0
  75. package/src/plugin-reload.js +481 -0
  76. package/src/plugin-scaffold.js +1934 -0
  77. package/src/plugin-validator.js +284 -0
  78. package/src/retry.js +218 -0
  79. package/src/security.js +860 -0
  80. package/src/snapshot.js +372 -0
  81. package/src/splash.js +115 -0
  82. package/src/theme-selector.js +411 -0
  83. package/src/themes.js +874 -0
  84. package/src/transitions.js +534 -0
  85. package/src/types.d.ts +174 -0
  86. package/src/validation.js +926 -0
  87. package/src/web-server.js +885 -0
  88. package/src/widgets/builtin-widgets.js +1056 -0
  89. package/src/widgets/config-processor.js +401 -0
  90. package/src/widgets/dependency-resolver.js +596 -0
  91. package/src/widgets/index.js +79 -0
  92. package/src/widgets/plugin-api.js +845 -0
  93. package/src/widgets/widget-error-boundary.js +773 -0
  94. package/src/widgets/widget-error-isolation.js +551 -0
  95. package/src/widgets/widget-loader.js +1437 -0
  96. package/src/workers/system-worker.js +130 -0
  97. package/src/workers/worker-pool.js +633 -0
  98. package/tests/alerts.test.js +437 -0
  99. package/tests/auto-save.test.js +529 -0
  100. package/tests/cache.test.js +317 -0
  101. package/tests/cli.test.js +351 -0
  102. package/tests/command-palette.test.js +320 -0
  103. package/tests/config-processor.test.js +452 -0
  104. package/tests/config-validator.test.js +710 -0
  105. package/tests/config-watcher.test.js +594 -0
  106. package/tests/config.test.js +755 -0
  107. package/tests/database.test.js +438 -0
  108. package/tests/errors.test.js +189 -0
  109. package/tests/example-plugins.test.js +624 -0
  110. package/tests/integration.test.js +1321 -0
  111. package/tests/loading-states.test.js +300 -0
  112. package/tests/manifest-validation-on-load.test.js +671 -0
  113. package/tests/performance-monitor.test.js +190 -0
  114. package/tests/plugin-api-rate-limit.test.js +302 -0
  115. package/tests/plugin-errors.test.js +311 -0
  116. package/tests/plugin-lifecycle-e2e.test.js +1036 -0
  117. package/tests/plugin-reload.test.js +764 -0
  118. package/tests/rate-limiter.test.js +539 -0
  119. package/tests/retry.test.js +308 -0
  120. package/tests/security.test.js +411 -0
  121. package/tests/settings-modal.test.js +226 -0
  122. package/tests/theme-selector.test.js +57 -0
  123. package/tests/utils.js +242 -0
  124. package/tests/utils.test.js +317 -0
  125. package/tests/validate-plugin-cli.test.js +359 -0
  126. package/tests/validation.test.js +837 -0
  127. package/tests/web-server.test.js +646 -0
  128. package/tests/widget-arrange-mode.test.js +183 -0
  129. package/tests/widget-config-hot-reload.test.js +465 -0
  130. package/tests/widget-dependency.test.js +591 -0
  131. package/tests/widget-error-boundary.test.js +749 -0
  132. package/tests/widget-error-isolation.test.js +469 -0
  133. package/tests/widget-integration.test.js +1147 -0
  134. package/tests/widget-refresh-intervals.test.js +284 -0
  135. 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
+ };